function vis(n,c,iframe){
	var seis=(navigator.appVersion.indexOf('MSIE 6.0')!=-1);
	var IE=(navigator.appName=='Microsoft Internet Explorer');		
	var usoIframe=(iframe==1);
	var IESEIS=seis&&IE;	
	IESEIS=IESEIS&&usoIframe;
	if (c==0){
		document.getElementById(n).style.display="none";
		if(IESEIS){
			document.getElementById("iFrameMenu").style.visibility="hidden";
		}
	}
	if (c==1){		
		if(IESEIS){
			var menu=document.getElementById(n);
			//alert('a');
		    var x = menu.offsetLeft;//menu.style.left;
			var y = menu.offsetTop;
			
			var w = 176;
			if (n=='submenu1') w=165;
			var h = 142;
			if (n=='submenu1') h=102;
	  
			var frameM = document.getElementById("iFrameMenu");
		    menu.style.zIndex=-3;
			
			frameM.style.left = x+'px' ;
		    frameM.style.top  = y+'px' ;
		    frameM.style.width = w+'px' ;
		    frameM.style.height  = h+'px' ;
		    //alert(menu.style.height);
			//alert(menu.id);
		    frameM.style.zIndex = 2;
			menu.style.zIndex=3;
			frameM.style.borderStyle='none';
			frameM.style.border="0px none #FFFFFF";
			frameM.style.visibility = "visible";
		    
		}
		document.getElementById(n).style.display="block";
  
	}
	
}

function img_alterna(xthis,nome,bo){
	if (bo==0){
		//xthis.src='templates/img/botao'+nome+'.jpg';
		document.getElementById('descricao_produto').innerHTML='';
	}
	else{
		//xthis.src='templates/img/botao'+nome+'over.jpg';
		document.getElementById('descricao_produto').innerHTML=xthis.alt;
	
	}
		
}
function cssresolucao(){
	if(window.screen.width<=800) {
	document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/css800.css\" media=\"screen\"/>");
	}
}
function abre_ped_funcs(cdpedido){
		var url="ext_val_funcs.php?pedido="+cdpedido;
		window.open(url,"pedido"," height = 250, width = 575,left=0,top=0,toolbar=0,resizable=0, scrollbars=1");
		}
function abre_funcs(cdpedido,cdproduto){
	var url="ext_val_funcs.php?hist=1&pedido="+cdpedido+"&prod="+cdproduto;
	window.open(url,"pedido"," height = 250, width = 575,left=0,top=0,toolbar=0,resizable=0, scrollbars=1");
}
//Rede credenciada - Fun��es//
function ValidaCampos() {
prod=document.getElementById('menuProduto');
est=document.getElementById('menuEstado');
cid=document.getElementById('menuCidade');

	if (prod.options[prod.selectedIndex].value=='') {
		alert('Escolha um produto para consultar.');
		prod.focus();
		return false;
	}
	if (est.options[est.selectedIndex].value=='') {
		alert('Escolha um estado para consultar.');
		est.focus();
		return false;
	}
	if (cid.options[cid.selectedIndex].value=='') {
		alert('Escolha uma cidade para consultar.');
		cid.focus();
		return false;
	}
	return true;
}

function EnviarForm() {
	if (ValidaCampos()) {
		document.getElementById('formu').submit();
	} 
	return true;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function goProduto(valor){
var x=document.getElementById('menuTipo');
var f=document.getElementById('estab');
var e=f.options[f.selectedIndex].value;
valor= document.getElementById(valor);
//location.href='rede_credenciada.php?codparauf='+valor+'&cv='+x.options[x.selectedIndex].value;
document.location.href='rede_credenciada.php?estab='+e+'&produto='+valor.options[valor.selectedIndex].value+'&cv='+x.options[x.selectedIndex].value;
}
function goUf(valor,est){
var y=document.getElementById('menuTipo');
var f=document.getElementById('estab');
var e=f.options[f.selectedIndex].value;
valor= document.getElementById(valor);
est= document.getElementById(est);
//location.href='rede_credenciada.php?codparauf='+valor+'&cv='+x.options[x.selectedIndex].value;
document.location.href='rede_credenciada.php?estab='+e+'&produto='+valor.options[valor.selectedIndex].value+'&cv='+y.options[y.selectedIndex].value+'&estado='+est.options[est.selectedIndex].value;
}
function goCidade(valor,est,cid){
var z=document.getElementById('menuTipo');
var f=document.getElementById('estab');
var e=f.options[f.selectedIndex].value;
valor= document.getElementById(valor);
est= document.getElementById(est);
cid= document.getElementById(cid);
//location.href='rede_credenciada.php?codparauf='+valor+'&cv='+x.options[x.selectedIndex].value;
document.location.href='rede_credenciada.php?estab='+e+'&produto='+valor.options[valor.selectedIndex].value+'&cv='+z.options[z.selectedIndex].value+'&estado='+est.options[est.selectedIndex].value+'&cidade='+cid.options[cid.selectedIndex].value;
}

function validaBusca(txt){
	document.getElementById(txt).innerHTML='';
    var msg='';
	var ret=true;
	var pro=document.getElementById('menuProduto');
	var est=document.getElementById('menuEstado');
	var cid=document.getElementById('cidade');
	if (cid.selectedIndex==0){
		msg='SELECIONE A CIDADE!';
		ret=false;		
	}	
	if (est.selectedIndex==0){
		msg='SELECIONE O ESTADO!';
		ret=false;		
	}
	if (pro.selectedIndex==0){
		msg='SELECIONE O PRODUTO!';
		ret=false;
	}
	document.getElementById(txt).innerHTML=msg;
	return ret;
}
function abre_recibo(p,d){
//alert("recibo_pedido.php?p="+p+"&d="+d);
var end="ext_recibo_pedido.php?p="+p+"&d="+d;
window.open(end,"rec","height=600,width=800, top=0, left=0,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes");	
}
function abre_lista_funcionarios(dp,at){
		var url="ext_lista_funcionarios.php?dp="+dp+"&at="+at;
		window.open(url,"lista"," height = 550, width = 750,left=0,top=0,toolbar=0,resizable=0, scrollbars=1");
		}
function abre_ext_pj(ap){
		var url="ext_analise_reembolso.php?sint&ap="+ap;
		window.open(url,"ap"," height = 550, width = 650,left=250,top=100,toolbar=0,resizable=0, scrollbars=1");		
		}
function abre_ext_pj_print(ap){
		var url="ext_print_analise_reembolso.php?sint&ap="+ap;
		window.open(url,"ap"," height = 550, width = 650,left=250,top=100,toolbar=0,resizable=0, scrollbars=1");
		}
function abre_lista_funcionarios_vl_padrao(pr,idm){
		var url="lista_funcionarios_vl_padrao.php?id_m="+idm+"&prod="+pr;
		window.open(url,"lista"," height = 550, width = 750,left=250,top=100,toolbar=0,resizable=0, scrollbars=1");		
		}			
function abre_relatorio(url){		
		window.open(url,"rel"," height = 550, width = 800,left=250,top=100,toolbar=0,resizable=0, scrollbars=1");		
		}		
function checaParams(datas){
	if (datas){				
		var falta=((document.getElementById('edtDiaInicial').value=="")||
							(document.getElementById('edtMesInicial').value=="")||
							(document.getElementById('edtAnoInicial').value=="")||
							(document.getElementById('edtDiaFinal').value=="")||
							(document.getElementById('edtMesFinal').value=="")||
							(document.getElementById('edtAnoFinal').value==""));
		
		var branco=((document.getElementById('edtDiaInicial').value=="")&&
							(document.getElementById('edtMesInicial').value=="")&&
							(document.getElementById('edtAnoInicial').value=="")&&
							(document.getElementById('edtDiaFinal').value=="")&&
							(document.getElementById('edtMesFinal').value=="")&&
							(document.getElementById('edtAnoFinal').value==""));
		
		var preench=((document.getElementById('edtDiaInicial').value!="")&&
							(document.getElementById('edtMesInicial').value!="")&&
							(document.getElementById('edtAnoInicial').value!="")&&
							(document.getElementById('edtDiaFinal').value!="")&&
							(document.getElementById('edtMesFinal').value!="")&&
							(document.getElementById('edtAnoFinal').value!=""));
		falta=!preench;
		if(!branco){
			if ((document.getElementById('edtAnoFinal').value<1000)||(document.getElementById('edtAnoInicial').value<1000)){
			alert('Formato de ano é de 4 dígitos! (AAAA) ')
			return false;
		}
		}																					
		if ((falta)&&(!(branco))){
			if(preench){
				return true;
			}else{
				alert('Nem todos os campos de data estão preenchidos!')	
				return false;			
			}
		}else{
			return true;
		}	
	
	}
}
function numero(e){
	var navegador = /msie/i.test(navigator.userAgent);	
	if (navegador)
		var  tecla = e.keyCode;
	else
		var tecla = e.which;	
	if (tecla==0) tecla = e.keyCode;
	var lados_del=((tecla==9)||(tecla>=35 && tecla<=40 )||(tecla==46));	
	if((tecla > 47 && tecla < 58)) // numeros de 0 a 9
		return true;
	else{
		if (tecla == 8) // backspace
			return true;
		else
			if (!lados_del) {				
				return false;
			}
			else 
				return true;
	}
}
		
