﻿// JScript Default.aspx
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//------------------------------------------------
function objAjax(){
    try { xmlhttp = new XMLHttpRequest(); } 
    catch(e) { 	try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } 
		    catch(ee){	try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");} 
					    catch(E){xmlhttp = false;}
					    }
		    } return xmlhttp;
} 
//------------------------------------------------
function getCookie(arg) {
 var sp = document.getElementById("spCookie");
 
 if(sp)
   sp.innerHTML =  arg;
 else
  alert('Erro');
  
 setTimeout("loadingClear()",5000);   
}
function getPage(arg) {
 var sp = document.getElementById("spLista");
 
 if(sp)
   sp.innerHTML =  arg;         
 
 setTimeout("loadingClear()",5000); 
}
function getGrid(arg) {          
  loading('Aguarde, carregando...');
  var sp = document.getElementById("spLista");
  
  if(sp)
   sp.innerHTML =  arg;
     
}
function getMenu(arg) {       
  var sp = document.getElementById("spMenu");  
  
  if(sp)
   sp.innerHTML =  arg.replace(/\+/g," ");       
}
function ProcessCallBackError(arg) {
   location.href='Default.aspx';
}
//======================= sobre imagem 
nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
    if (object != "[object]"){  //do this so I can take a string too
        setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
        
    clearTimeout(nereidFadeTimers[object.sourceIndex]);
    
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;

    if (object.filters.alpha.opacity != destOp){
        nereidFadeObjects[object.sourceIndex]=object;
        nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}
//===============================================
function xmlhttpPostBot() 
{
	var strURL     = 'pageConsultaRapida.aspx';
	var xmlHttpReq = false;

   // Mozilla/Safari
    if (window.XMLHttpRequest) 
	{
        xmlHttpReq = new XMLHttpRequest();
	 if (xmlHttpReq.overrideMimeType) {
	       xmlHttpReq.overrideMimeType('text/xml');
		}
    }	
   // IE			
    else if (window.ActiveXObject) 

	try {
	    xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e) {
	try {
		 xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {}
	}

    xmlHttpReq.open('POST', strURL, true);
    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   	xmlHttpReq.onreadystatechange = function() {
    if (xmlHttpReq.readyState == 4) 
	{
        updatepage(xmlHttpReq.responseText);
    }
	}
    xmlHttpReq.send(getquerystring());
}
function xmlhttpPost() 
{    
 	if(event.keyCode==13)
	{  	   
		var strURL     = 'pageConsultaRapida.aspx';
    	var xmlHttpReq = false;

    // Mozilla/Safari
		if (window.XMLHttpRequest) 
		{
	        xmlHttpReq = new XMLHttpRequest();
		 if (xmlHttpReq.overrideMimeType) {
    	       xmlHttpReq.overrideMimeType('text/xml');
			}
	    }
    // IE
	    else if (window.ActiveXObject) 

		try {
		   xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
			xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
		}

	    xmlHttpReq.open('POST', strURL, true);
	    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	   	xmlHttpReq.onreadystatechange = function() {				
          if(xmlHttpReq.readyState == 4) 
		  {
            updatepage(xmlHttpReq.responseText);              
	      }
    	}
	    xmlHttpReq.send(getquerystring());	
	    return false;	
	}
}

function getquerystring() 
{
    var nomeProduto = document.getElementById("produto").value;
    qstr = 'nomeProduto='+escape(nomeProduto);  // NOTE: no '?' before querystring
    return qstr;
}

function updatepage(str)
{
	if(str.length > 0)
	{
		var strURL     = 'pageConsultaRapida.aspx';
		//var form        = document.forms['form1'];
	    var nomeProduto = document.getElementById('produto').value;
	
		if(nomeProduto.length > 2)
	    {
			document.getElementById("busca").style.display  =  '';
			document.getElementById("busca").style.visibility  = 'visible';					
		    document.getElementById("buscaI").src = strURL + '?nomeProduto='+escape(nomeProduto);   
		}
		else
		{
		    alert("É necessário no mínimo 3 letras para efetuar a busca!!!");
			document.getElementById("busca").style.display     =  'none';
			document.getElementById("busca").style.visibility  = 'hidden';	
			return false;				
		}
	}			
}
function fecharConsulta(param)
{
  document.getElementById("busca").style.display     =  'none';
  document.getElementById("busca").style.visibility  = 'hidden';	
  viewPage(param);
}
function tituloDefaultIFrame(titulo,obj,oFrame)
{    	
    str = '<table cellpadding="2" cellspacing="0" width="100%" height="5">' + 
	      '<tr><td height="5" class="fn11BrancaBold" background="imagens/fundo_menu_01.jpg">&nbsp;&nbsp;<b>&raquo;</b>&nbsp;'+titulo+'</td>' +
	      '<td height="5" class="fn10" width="12">' +
	      '<a style="cursor:hand;" onclick="document.all.'+oFrame+'.src=\'\'; document.all.'+obj+'.style.display=\'none\'; document.all.'+obj+'.style.visibility=\'hidden\';">' + 
	      '<img src="imagens/fecahr.jpg" border="0"></a></td></tr></table>';
    document.write(str);
}
function muda()
{		    
	parent.document.getElementById("auto").style.display = parent.document.getElementById("auto").style.display=='none'?'':'none';
	parent.document.getElementById("fixa").style.display = parent.document.getElementById("fixa").style.display=='none'?'':'none';	
}
//===============================================
 function newwind() {  
     window.open('../video/jn_video.asp','','toolbar=no,location=no,directories=no,status=nos,scrollbars=yes,menubar=no,resizable=no,top=50,left=400,width=637,height=419');
 }
function popup(_url,_w,_h,_l,_t,_scro){
   window.open(_url,'winpopup', 'width='+_w+', height='+_h+', top='+_t+', left='+_l+', scrollbars='+_scro+', status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}
function muda() {    
	parent.document.getElementById("auto").style.display = parent.document.getElementById("auto").style.display=='none'?'':'none';
	parent.document.getElementById("fixa").style.display = parent.document.getElementById("fixa").style.display=='none'?'':'none';	
}
//muda abas
function mudaAba(obj) {
  if(obj.id == 'aba1') {	     
     obj.src = 'imagens/aba2_caract.gif'
     document.getElementById('aba2').src = 'imagens/aba1_esp.gif';
     document.getElementById('tr1').style.display = '';
     document.getElementById('tr2').style.display = 'none';
  } else {
     obj.src = 'imagens/aba2_esp.gif'
     document.getElementById('aba1').src = 'imagens/aba1_caract.gif';
     document.getElementById('tr1').style.display = 'none';
     document.getElementById('tr2').style.display = '';	 
  }
} 
//mostra div condição
function mostraDvCond() {
  var dvCond = document.getElementById('dvCond');
  dvCond.style.display = dvCond.style.display == 'none' ? '' : 'none';
  
  var trCond1 = document.getElementById('trCond1');
  trCond1.style.display = trCond1.style.display == 'none' ? '' : 'none';
  
  var trCond2 = document.getElementById('trCond2');
  trCond2.style.display = trCond2.style.display == 'none' ? '' : 'none';
}
//muda foto
function mudaFoto(foto) {
  document.getElementById('fotoProd').src = foto;
} 
//carregador load Carrinho
function loadingCarrinho(texto) { 

    var div = document.createElement("div"); 
    div.id = "divLoadCarrinho"; 
    div.innerHTML = "<div id=carregador><img src='imagens/loader2.gif'> "+texto+"...</div>"; 
    document.body.appendChild(div); 

    setTimeout("loadingClearCarrinho()",6000); 
} 
//Esconde o carregador Carrinho
function loadingClearCarrinho(){ 
    var div = document.getElementById("divLoadCarrinho"); 
    if (div) div.parentNode.removeChild(div); 
} 
//carregador load 
function loading(texto) { 

    var div = document.createElement("div"); 
    div.id = "divLoad"; 
    div.innerHTML = "<div id=carregador><img src='imagens/loader2.gif'> "+texto+"...</div>"; 
    document.body.appendChild(div); 

    setTimeout("loadingClear()",6000); 
} 
//Esconde o carregador 
function loadingClear(){ 
    var div = document.getElementById("divLoad"); 
    if (div) div.parentNode.removeChild(div); 
} 
function OpenSaibaMais(){
  window.open('http://www.visa.com.br/vbv/vbv_saibamais.asp','principal','height=435,width=270,top=0,left=0,resizable=no,status=1')
}

