//Visualiza a foto ampliada em popup
//Usar o link javascript:verimg('caminho/nome.jpg')
		function verimg(img){
		  foto1= new Image();
		  foto1.src=(img);
		  Controlla(img);
		}
		function Controlla(img){
		  if((foto1.width!=0)&&(foto1.height!=0)){
			viewFoto(img);
		  }
		  else{
			funzione="Controlla('"+img+"')";
			intervallo=setTimeout(funzione,20);
		  }
		}
		function viewFoto(img){
		  largh=foto1.width+20;
		  altez=foto1.height+20;
		  stringa="width="+largh+",height="+altez;
		  finestra=window.open(img,"",stringa);
		}
		
		function escolha(imagem,alt){
			document.getElementById('imagemdescricao').innerHTML = (alt);
			document.getElementById('imagemg').src=(imagem);
			document.getElementById('imagemg').alt = (alt);
		}
		
		/* pré-carregar menu */
		function MM_preloadImages() { //v3.0
  			var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   			 if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
		}

function timeOut(){
	setTimeout("redir()", 1500);	
}
function redir(){
	location.href = 'index.php';
}
function timeOut2(){
	setTimeout("redir2()", 1500);	
}
function redir2(){
	location.href = 'index.php?secao=opa';
}
function showOverflow(){
	document.getElementById('overflow').style.display = "block";
	}
function hiddenOverflow(valor){
	
	document.getElementById('overflow').style.display = "none";
	document.getElementById('select').innerHTML = valor;
}

function pagina(pag,id){	
	document.getElementById('content').innerHTML = "<div id='load'><img src='img/load.gif' class='loader'><p class='txtloader'>Carregando, aguarde...</p></div>"	
	ajax = ajaxInit();
	if(ajax){
		ajax.open("GET", pag+".php?id="+id, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){		    			
                    document.getElementById('content').innerHTML = ajax.responseText;
					if(id)
					{
						if(id.search("passo2") == 0) { showHidden('passo2'); }
						if(id.search("passo3") == 0) { showHidden('passo3'); }
					}
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}

window.onload = function(){
	if (document.getElementsByTagName) {
		var objs = document.getElementsByTagName("object");
		for (i=0; i<objs.length; i++) {
			objs[i].outerHTML = objs[i].outerHTML;
		}
	}
}

window.onunload = function() {
	if (document.getElementsByTagName) {
		var objs = document.getElementsByTagName("object");
		for (i=0; i<objs.length; i++) {
			objs[i].outerHTML = "";
		}
	}
}

var max=250;
var ancho=300;
function progreso_tecla(obj) {
	if (obj.value.length < max) {
    	var pos = ancho-parseInt((ancho*parseInt(obj.value.length))/250);
  	}else{   		
		document.getElementById('textarea').value = document.getElementById('textarea').value.substring(0, 250);		
  	} 
  	progreso.innerHTML = "("+obj.value.length+" / "+max+")";
}
function gerarSWF($arquivo,$largura,$altura){
    document.writeln('<object type="application/x-shockwave-flash" data="'+ $arquivo +'" width="'+ $largura +'" height="'+ $altura +'">');
    document.writeln('<param name="movie" value="' + $arquivo + '" />');
    document.writeln('<param name="menu" value="false" />');
    document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="wmode" value="transparent" />');
	document.writeln('<embed quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ></embed>');
    document.writeln('</object>');
}

function menor(){
	document.getElementById('open').style.display = "none";
	document.getElementById('close').style.display = "block";
	}
	
function viewFalcan(){
	document.getElementById('urlFalcan').style.display = "block";

}
function ocultFalcan(){
	document.getElementById('urlFalcan').style.display = "none";
}
function txtBoxFormat(objeto, sMask, evtKeyPress) {  
    	var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;  
    	if(document.all) { // Internet Explorer  
    		nTecla = evtKeyPress.keyCode; 
		}else if(document.layers) { // Nestcape  
    		nTecla = evtKeyPress.which;  
    	}  
   		sValue = objeto.value;  
	   // Limpa todos os caracteres de formatação que  
	   // já estiverem no campo.  
	   sValue = sValue.toString().replace( "-", "" );  
	   sValue = sValue.toString().replace( "-", "" );  
	   sValue = sValue.toString().replace( ".", "" );  
	   sValue = sValue.toString().replace( ".", "" );  
	   sValue = sValue.toString().replace( "/", "" );  
	   sValue = sValue.toString().replace( "/", "" );  
	   sValue = sValue.toString().replace( ":", "" );  
	   sValue = sValue.toString().replace( ":", "" );  
	   sValue = sValue.toString().replace( "(", "" );  
	   sValue = sValue.toString().replace( "(", "" );  
	   sValue = sValue.toString().replace( ")", "" );  
	   sValue = sValue.toString().replace( ")", "" );  
	   sValue = sValue.toString().replace( " ", "" );  
	   sValue = sValue.toString().replace( " ", "" );  
	   fldLen = sValue.length;  
	   mskLen = sMask.length;  
	   i = 0;  
	   nCount = 0;  
	   sCod = "";  
	   mskLen = fldLen;  
	   while (i <= mskLen) {  
		   	bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))  
		   	bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))  
		   	if (bolMask) {  
			   sCod += sMask.charAt(i);  
			   mskLen++; 
			} else {  
			   sCod += sValue.charAt(nCount);  
			   nCount++;  
			}  
	   		i++;  
	  }  
   		objeto.value = sCod;  
   if (nTecla != 8) { // backspace  
		if (sMask.charAt(i-1) == "9") { // apenas números...  
   			return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9  
   		else { // qualquer caracter...  
   			return true;  
   		}
	} else {  
   		return true;  
 	}  
 } 		


function viewPDV(){	
	document.getElementById('menuPDV').style.display = "block";
}
function viewVenda(){	
	document.getElementById('menuVenda').style.display = "block";
}
function subPDV(valor){
	document.getElementById('menuPDV').style.display = "none";
	document.getElementById('selectPDV').innerHTML = valor;
}
function subVenda(valor){
	document.getElementById('menuVenda').style.display = "none";
	document.getElementById('selectVenda').innerHTML = valor;
}
function hiddeSubVenda(){
	document.getElementById('menuVenda').style.display = "none";
}
function viewFormS(){
	document.getElementById('add').style.display = "block";
	document.getElementById('dscrap').style.display = "none";
}
function hiddenAdcional(){
	document.getElementById('adcional').style.display = "none";
	document.getElementById('enderecoad').value = "";
	document.getElementById('numeroad').value = "";
	document.getElementById('bairroad').value = "";
	document.getElementById('cidadead').value = "";
	
}	
function blockAdcional(){
	document.getElementById('adcional').style.display = "block";
}	

function showHidden (valor){
	switch (valor){
		case "login":
			document.getElementById('login').style.display = "block";
			document.getElementById('esqueci').style.display = "none";
			document.getElementById('cadastro').style.display = "none";
		break;
		case "cadastro":
			document.getElementById('login').style.display = "none";
			document.getElementById('esqueci').style.display = "none";
			document.getElementById('cadastro').style.display = "block";
		break;
		case "esqueci":
			document.getElementById('login').style.display = "none";
			document.getElementById('esqueci').style.display = "block";
			document.getElementById('cadastro').style.display = "none";
		break;
		case "passo1":
			document.getElementById('passo1').style.display = "block";
			document.getElementById('passo2').style.display = "none";
			document.getElementById('passo3').style.display = "none";
			document.getElementById('passo01').className = "passo11";
			document.getElementById('passo02').className = "passo12";
			document.getElementById('passo03').className = "passo13";
		break;
		case "passo2":
			document.getElementById('passo1').style.display = "none";
			document.getElementById('passo2').style.display = "block";
			document.getElementById('passo3').style.display = "none";
			document.getElementById('passo01').className = "passo21";
			document.getElementById('passo02').className = "passo22";
			document.getElementById('passo03').className = "passo23";
		break;
		case "passo3":			
			document.getElementById('passo1').style.display = "none";
			document.getElementById('passo2').style.display = "none";
			document.getElementById('passo3').style.display = "block";
			document.getElementById('passo01').className = "passo31";
			document.getElementById('passo02').className = "passo32";
			document.getElementById('passo03').className = "passo33";
		break;
		case "fabrica":
			document.getElementById('outroHidden').style.display = "none";
			//document.getElementById('alturaConfirm').style.height = 250+"px";			
		break;
		case "outro":
			document.getElementById('outro').style.display = "block";
			//document.getElementById('alturaConfirm').style.height = 250+"px";
		break;		
		case "outroHidden":
			document.getElementById('outro').style.display = "none";
			//document.getElementById('alturaConfirm').style.height = 180+"px";
		break;
	}
}

function busca_distribuidores(cdonde){	
	document.getElementById('rightP').style.display = 'none';
	document.getElementById('rightD').style.display = '';
	
	document.getElementById('distribuidora').innerHTML = "";
	document.getElementById('distribuidora').innerHTML = "<center><p><img src='img/load.gif'><p>Carregando, aguarde...</p></p></center>";
	ajax = ajaxInit();
	if(ajax){
		ajax.open("GET", "venda_busca_distri.php?cdonde="+cdonde, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){		    			
                    document.getElementById('distribuidora').innerHTML = "";
                    document.getElementById('distribuidora').innerHTML = ajax.responseText;                    
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}

function busca_pontos(cdonde, cdpdv){	
	document.getElementById('rightP').style.display = '';
	document.getElementById('rightD').style.display = 'none';

	document.getElementById('rightP').innerHTML = "";
	document.getElementById('rightP').innerHTML = "<center><p><img src='img/load.gif'><p>Carregando, aguarde...</p></p></center>";
	ajax2 = ajaxInit();
	if(ajax2){
		ajax2.open("GET", "venda_busca_pontos.php?cdonde="+cdonde+"&cdpdv="+cdpdv, true);
		ajax2.onreadystatechange = function(){
	    	if(ajax2.readyState == 4){
	    		if(ajax2.status == 200){		    			
                    document.getElementById('rightP').innerHTML = "";
                    document.getElementById('rightP').innerHTML = ajax2.responseText;
	       		}else{
	         		alert(ajax2.statusText);
	       		}
	     	}		     	
	   	}
		ajax2.send(null);
	}
}

function revenda_envia(form){
	document.getElementById('processando').style.display = 'block';
	dados = RetornaValores(form);
	ajax = ajaxInit();
	if(ajax){
		ajax.open("GET", "revenda_envia.php?"+dados, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){
					eval(ajax.responseText);
					document.getElementById('processando').style.display = 'none';
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}

function faleconosco_envia(form){
	document.getElementById('processando').style.display = 'block';
	dados = RetornaValores(form);
	ajax = ajaxInit();
	if(ajax){
		ajax.open("GET", "faleconosco_envia.php?"+dados, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){
					eval(ajax.responseText);
					document.getElementById('processando').style.display = 'none';
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}

function scrap_grava(){	
	document.getElementById('processando').style.display = 'block';
	dados = RetornaValores(document.frm_scrap);
	ajax = ajaxInit();
	if(ajax){
		ajax.open("GET", "scrap_grava.php?"+dados, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){
					eval(ajax.responseText);
					document.getElementById('processando').style.display = 'none';
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}

function news_grava(email){	
	document.getElementById('processando').style.display = 'block';
	ajax = ajaxInit();
	if(ajax){
		ajax.open("GET", "news_grava.php?email="+email, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){		    			
                    alert(ajax.responseText);
                    document.news.mail.value = '';
					document.getElementById('processando').style.display = 'none';
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}

function pedido_login(form){
	document.getElementById('processando').style.display = 'block';
	ajax = ajaxInit();
	dados = RetornaValores(form);
	if(ajax){
		ajax.open("GET", "pedido_login.php?"+dados, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){		    			
                    eval(ajax.responseText);
					document.getElementById('processando').style.display = 'none';
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}

function pedido_senha(form){
	document.getElementById('processando').style.display = 'block';
	ajax = ajaxInit();
	dados = RetornaValores(form);
	if(ajax){
		ajax.open("GET", "pedido_senha.php?"+dados, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){		    			
                    eval(ajax.responseText);
					document.getElementById('processando').style.display = 'none';
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}

function pedido_cadastro(form){
	document.getElementById('processando').style.display = 'block';
	ajax = ajaxInit();
	dados = RetornaValores(form);
	if(ajax){
		ajax.open("GET", "pedido_cadastro.php?"+dados, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){		    			
                    eval(ajax.responseText);
					document.getElementById('processando').style.display = 'none';
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}

function pedido_dados(form){
	document.getElementById('processando').style.display = 'block';
	ajax = ajaxInit();
	dados = RetornaValores(form);
	if(ajax){
		ajax.open("GET", "pedido_dados.php?"+dados, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){		    			
                    eval(ajax.responseText);
					document.getElementById('processando').style.display = 'none';
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}

function pedido_concluido(form){
	document.getElementById('processando').style.display = 'block';
	ajax = ajaxInit();
	dados = RetornaValores(form);
	if(ajax){
		ajax.open("GET", "pedido_concluido.php?"+dados, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){		    			
                    eval(ajax.responseText);
					document.getElementById('processando').style.display = 'none';
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}
function fechaFloater(){
document.getElementById('fecharOpa').style.display='none';
document.getElementById('floaterOpa').style.display='none';
<!--document.getElementById('floater').style.display='none';-->
}