<script language="JavaScript" type="text/javascript" src="js/toolbar.js"></script>
 <?
include_once("include/css.inc.php"); 
 
class toolbar{
	
    function botaoHelp($tipo="noticia",$edit="", $width=25){
        $style="background-image:url(images/help.gif); width:".$width."px;";
        ?><td width=<?=($width+2)?> align=center>
        	<input type="button" class="botao" name="cmd1" value="" style="<?= $style ?>" onClick="show_help('<?=$tipo?>','<?=$edit?>')"/>
        	</td><?
	}
		
    function botao2($cmd="novo", $width=70){
        global $css;
    	$style="background-image:url(images/$css/".strtolower($cmd).".gif); width:".$width."px;";
        ?><td width=<?=($width+2)?> align=center>
        	<input type="button" class="botao" name="cmd1" value="<?=$cmd?>" style="<?=$style?>" onClick="mostra('<?=$cmd?>')"/>
        </td><?
	}
	
	function botao2_l($cmd="novo", $width=70){
        global $css;
        $style="background-image:url(images/$css/".strtolower($cmd).".gif); width:".$width."px;";
        
        ?><td width=<?=($width+2)?> align=center class="botao_layer">
        	<a class="botao" href="main.php?cmd=<?=$cmd?>" style="<?=$style?>"><span><?=$cmd?></span></a>
        </td><?
	}
	
	function botaoLink($cmd="novo", $width=70, $link=""){
         global $css;
         $style="background-image:url(images/$css/".strtolower($cmd).".gif); width:".$width."px;";

        ?><td width=<?=($width+2)?> align=center>
        	<a href="main.php?<?=$link?>" class="botao" style="<?=$style?>" />
        	 <span><?=$cmd?></span>        	   
        	</a>
          </td><?
	}
	
    function botao($cmd="novo", $width=70){
        global $css;
        $style="background-image:url(images/$css/".strtolower($cmd).".gif) ; width:".$width."px;";
        ?><td width=<?=($width+2)?> align=center>
        	<input type="submit" class="botao" id="<?=$cmd?>" name="cmd" value="<?=$cmd?>" style="<?=$style?>" />
        </td><?
	}
	
	
	function botao_l($cmd="Novo", $width=70){
		global $css;
		$style="background-image:url(images/$css/".strtolower($cmd).".gif); width:".$width."px;";
		
        ?><td width=<?=($width+2)?> align=left class="botao_botao">
        	<a class="botao" href="main.php?cmd=<?=$cmd?>" style="<?=$style?>" ><span><?=$cmd?></span></a>
        </td><?
	}
	
		
    function oldbotao($cmd="novo", $width=70){
        $style="background: transparent url(images/".strtolower($cmd).".gif) no-repeat left; width:".$width."px;";
        ?><td width=<?=($width+2)?> align=center><a href="?cmd=<?=$cmd?>" class="botaoToolbar" onClick="mostra('<?=$cmd?>')"><input type="submit" class="botao" name="cmd" value="<?=$cmd?>" style="<?=$style?>" /></a></td><?
	}

    function toolbar(){
      ?><div id="divToolbar"><table cellspacing="0" cellpadding="0" border="0" width="100%" class="mybg toolbar"><tr><? 
	  $this->ini();
    }
    
    function ini(){
      ?><td width=5>&nbsp;<!-- <img src="images/cabecaTool.gif" width="3" height="31" />  --></td><?
    }

    function sep(){
      ?><td width=2><img src="images/separadorTool.gif" width="2" height="31" /></td><?
    }

    function fim(){
      ?><td width="80%">&nbsp </td></tr></table></div><?
    }
	
	////////////////////////////////////////////////////////////////// nav
	function botaoNav($link, $imagem){
		global $css;
        ?><td class="botaoBD botao_nav"><a href="<?=$link?>"><img src="images/<?=$css?>/<?=$imagem?>" border=0></a></td><?
	}
	
	function botaoNav_dis($imagem){
		global $css;
        ?><td class="botaoBD"><img src="images/<?=$css?>/<?=$imagem?>" border=0></td><?
	}

	function nav($offset, $limit, $total, $extra=""){
    	$max = $offset + $limit;
      	$passoLongo = 10 * $limit;
 		
 		if ($offset >= $passoLongo)
        	$this->botaoNav('?offset='. ($offset - $passoLongo) . $extra, 'nav_left2.gif');
    	else
    		$this->botaoNav_dis('nav_left2_dis.gif');

      	if ($offset >= $limit)
        	$this->botaoNav( '?offset='. ($offset - $limit). $extra, 'nav_left.gif');
        else
    		$this->botaoNav_dis('nav_left_dis.gif');
    	
      	?><td nowrap align=center>&nbsp;<?
	  	if ($total/$limit>1){
	  		//print "<select name='offset' onChange='mudaOffset(this.options[this.selectedIndex].value, \"$extra\")'>";
	  		print "<input type='hidden' value='$extra' id='navextra'/>";
	  		print "<select name='offset' id='navselect'>";
	 	  	for ($i=0; $i< $total; $i+=$limit){
			  	$sel=($offset==$i)?"selected":"";
			  	$max=($total>($i+$limit))?($i+$limit):$total;
				print "<option value=$i $sel>". ($i+1) . " a " . $max ."</option>";
			}
	  		print "</select>de " . $total;
	    }
    	else
        	echo ($offset+1) ." a ".$total;
		?></td><?

		if ($offset+$limit<$total)
        	$this->botaoNav( '?offset='. ($offset+$limit). $extra, 'nav_right.gif');
        else
    		$this->botaoNav_dis('nav_right_dis.gif');

		if ($offset+ $passoLongo < $total)
        	$this->botaoNav( '?offset='. ($offset + $passoLongo). $extra, 'nav_right2.gif');
    	else
    		$this->botaoNav_dis('nav_right2_dis.gif');        
	}

	
	/////////////////////////////////////////////////////////////////////////////////////////////////////
	/*function procurar($procurar){
      ?><td><input type="text" name="procurar" value="<?= $procurar ?>"></td><?
    }*/
	function procurar($procurar){
      ?><td><input type="text" name="procurar" value="<?= $procurar ?>" id="textoprocurar"></td><?
    }
	
    function categoria($tipo, $campo, $value, $todos=false){
		$db= new dbElemento;
		$dados=$db->getListaCategorias($tipo . "Categoria", array("Id"=>"id", "Categoria"=>"categoria") );
		?><td >
		<select name="idCat" class="selectMedia" id="selectMedia<?=$tipo ?>">
<!--		<select name="idCat" onchange="muda('<?//=$tipo?>', this.options[this.selectedIndex].value)">-->
			<? if ($todos==true) { ?><option value="0">Todos</option><? } 
			$max=sizeof($dados);
			for ($i=0;$i<$max; $i++){			
				$sel="";
				if ($value==$dados[$i]['id']) $sel="selected";
				?><option value="<?=$dados[$i]['id']?>" <?=$sel?> ><?=$dados[$i][$campo]?></option><? 
			} ?>
		</select></td>
		<?
	}

	
	function escolhe($table, $nome, $campo, $value, $label="",$todos=false){
		$db= new dbElemento;
		$dados=$db->getLista($table, "", "*", "id" );
		$max=sizeof($dados);

		?><td >
		<select name="filtro[<?=$nome?>]"  onChange="dataform.submit();" >
			<? if ($todos==true) { ?><option value="" selected><?=ucfirst($label)?> (Todos)</option><? } 
			for ($i=0;$i<$max; $i++){			
				$sel="";			
				if ($value==$dados[$i]['id']) $sel="selected";
				?><option value="<?=$dados[$i]['id']?>" <?=$sel?> ><?=$dados[$i][$campo]?></option><? 
			} ?>
		</select></td>
		<?
	} 
	
    function escolhe2($titulo, $nome, $dadosSel, $selIdSel="", $todos = false){
      ?>
      	<style>
      	#escolheEstado label {height: 20px; margin-right: 0; width: 50px}
      	</style>
		<td>
			<div style="width: 250px;" id="escolheEstado" class="clearfix">
				<label for="<?=$nome?>"><?=$titulo?></label>
				<select name="filtro['<?=$nome?>']" id="<?=$nome?>" class="escolheEstado">
					<? if ($todos==true) { ?>
						<option value="999" <?if($selIdSel == 999) echo "selected='selected'";?>><?=ucfirst($label)?> (Todos)</option>
					<? }
					foreach ($dadosSel as $selId => $label){ ?>
						<option value="<?=$selId?>" <? if($selIdSel==$selId) echo "selected='selected'";?>><?=$label?></option>
		            <?}?>
				</select>
			</div>
		</td>
      <?
    }

	// a modificar para calendario novo, do gac
	function data($nome1, $nome2, $data1, $data2){
    	?><td style="width:400px"><?
	    
	    include_once ('include/jscalendar/calendar.php');
	    $calendar = new DHTML_Calendar('include/jscalendar/', 'pt', 'calendar-system', true);
	    $calendar->load_files();
	    $calendar->make_input_field(
	           // calendar options go here; see the documentation and/or calendar-setup.js
	           array('firstDay'       => 0, // show Monday first nao
	                 'showsTime'      => false,
	                 'showOthers'     => true,
	                 'ifFormat'       => '%Y-%m-%d',
	                 'timeFormat'     => '24'),
	           // field attributes go here
	           array('style'       => '',
	                 'name'        => $nome1,
	                 'value'       => $data1));

	    $calendar->make_input_field(
	           // calendar options go here; see the documentation and/or calendar-setup.js
	           array('firstDay'       => 0, // show Monday first nao
	                 'showsTime'      => false,
	                 'showOthers'     => true,
	                 'ifFormat'       => '%Y-%m-%d',
	                 'timeFormat'     => '24'),
	           // field attributes go here
	           array('style'       => '',
	                 'name'        => $nome2,
	                 'value'       => $data2));
		?></td><?
    }
    
	function data2($nome1, $nome2, $data1, $data2){
	    ?>
	    <link href="js/datePicker.css" rel="stylesheet" type="text/css"/>
	    <script type="text/javascript" src="js/date.js"></script>
	    <script type="text/javascript" src="js/jquery.datePicker.js"></script>
		<script type="text/javascript">
		$(document).ready(function(){
			$('.data').datePicker({startDate: '1900-01-01'}); 
		});
		</script>
		<style>
		.tddata a {text-decoration: underline;}
		#data3 span{display:inline;float:left;}
		#data3 label {height: 20px; margin-right: 0; width: 120px}
		</style>
		<td>
			<div style="width: 355px;margin-left: 5px" id="data3" class="clearfix">
				<span><label>Data Início:</label><br><input id="data_inicio" name="<?=$nome1?>" value="<?=$data1?>" type="text" class="data">&nbsp;</span>
				<span><label>Data Fim:</label><br><input id="data_fim" name="<?=$nome2?>" value="<?=$data2?>" type="text" class="data"></span>
			</div>		
		</td>
    <?php }
    
    
	function data3($nome1, $nome2, $data1, $data2){
	    ?>
	    <link href="js/datePicker.css" rel="stylesheet" type="text/css"/>
	    <script type="text/javascript" src="js/date.js"></script>
	    <script type="text/javascript" src="js/jquery.datePicker.js"></script>
		<script type="text/javascript">
		$(document).ready(function(){
			$('.data').datePicker({startDate: '1900-01-01'}); 
		});
		</script>
		<style>
		.tddata a {text-decoration: underline;}
		/*#data3 span{display:inline;float:left;}*/
		#data3 label {height: 18px; margin-right: 0; width: 80px}
		#data3 input {width: 80px}
		</style>
		<td>
			<div style="width: 355px;" id="data3" class="clearfix">
				<label>Entre datas:</label>
				<input id="data_inicio" name="<?=$nome1?>" value="<?=$data1?>" type="text" class="data">&nbsp;
				<input id="data_fim" name="<?=$nome2?>" value="<?=$data2?>" type="text" class="data">
			</div>		
		</td>
    <?php }
    
}
?>