<!-- hide from JavaScript-challenged browsers
function f_aviso(vMsg)
{
  vWin = window.open('','Aviso','toolbar=no,status=no,width=400,height=150,resizable=0,scrollbars=1')
  vMensagem = "<body bgcolor=#B70000><center>"
  vMensagem += "<br><font size=1 color=#FFFFFF face=Verdana,Helvetica><b>Prezado Cliente,<br> "
  vMensagem += vMsg+"<br></b></font>"
  vMensagem += "<br><b><a href='javascript: window.close();'><font size=1 color=#FFFFFF face=Verdana,Helvetica>Fechar</font></a></b></center></body>"
  vWin.document.write(vMensagem);
}
  
function openWindow(url, name)
{ var winWidth = 480;
  var winHeight = 500;
  var winTop = parseInt((screen.availHeight - winHeight) / 2);
  var winLeft = parseInt((screen.availWidth - winWidth) / 2);
     
  popupWin = window.open(url,name,"width=" + winWidth + ",height=" + winHeight + ",top=" + winTop + ",left=" + winLeft + ",resizable=no,scrollbars=no,statusbar=no");
  if (popupWin.opener == null) popupWin.opener = self;
}
// done hiding -->

function ChecaPesquisa(vForm)
{
// if (vForm.PChave.value == "")
// {
//  alert('Por favor, informe o termo a pesquisar.');
//  vForm.PChave.focus();
//  return false;
// }
 return true;
}

function Limpar_Blank(vCampo)
{
 var vStr = vCampo.value;
 vStr = vStr.replace('-','');
 vStr = vStr.replace('.','');
 vStr = vStr.replace('/','');
 vCampo.value = vStr.replace(' ','');
}

function ListProm()
{
  if (document.frmLPMail.Email.value == "")
   {
     window.alert("Informe seu \"E-mail\"");
     document.frmLPMail.Email.focus();
     return false;
   }
    else if (ValidaEmail(document.frmLPMail.Email)==false)
   {
     document.frmLPMail.Email.focus();
     return false;
   }
  Janela_Pop('mail_ofertas.asp?Email='+document.frmLPMail.Email.value,'150','200')
}

function Janela_Pop(vURL,vAlt,vLarg,vScroll,vRell)
 {
  window.open(vURL,'Janela','width='+vLarg+',height='+vAlt+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+vScroll+',resizable='+vRell+',copyhistory=no,maximized=no');
 }

function AbreItauShopline()
{
  window.open('','SHOPLINE','width=675,height=485,toolbar=yes,status=no,menubar=yes,scrollbars=yes,resizable=yes');
}
              
function W_Prom_F(vAlt, vLarg, vName) {
  var archivo = vName; 
  var ancho = vLarg;
  var alto = vAlt; 
  var version = "7,0,19,0"; // Versao do Flash Player - NAO É NECESSÁRIO MEXER AQUI
  var quality = "high"; // Qualidade da visualizacao do flash
  var bgcolor = "#000000"; 
  var wmode = "transparent"; 
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version+'" width='+ancho+' height='+alto+'>\n');
document.write('<param name="movie" value='+archivo+' />\n');
document.write('<param name="quality" value='+quality+'>\n');
document.write('<param name="bgcolor" value='+bgcolor+'>\n');
document.write('<param name="wmode" value='+wmode+'>\n');
document.write('<embed src='+archivo+' bgcolor='+bgcolor+' quality='+quality+' wmode='+wmode+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+ancho+' height='+alto+'></embed>');
document.write('</object>\n');
}

var delay = 200;

function countHide() {
	delayhide = setTimeout("MenuLojas('MiniLojas', 'off')",delay);
}

function clearDelay() {
	if (window.delayhide) {
		clearTimeout(delayhide);
	}
}

function MaisImg(URL) {
  window.open(URL,'JanelaImagens','width=550,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,maximized=no');
}

function MenuLojas(Div,Lock) {

  if(navigator.appName == "Microsoft Internet Explorer") {

    if(Lock == 'on')
	  {
      document.all(Div).style.display = 'block';
	  document.Pesquisa.IdL.style.visibility = 'hidden';
      var link = location.href;
	  if (link.indexOf("pesquisa") > 0)
	    { 
	    document.frmListagem.NFab.style.visibility = 'hidden';
		document.frmListagem.NCat.style.visibility = 'hidden';
		}
	  else if (link.indexOf("listagem") > 0)
	    document.frmListagem.NFab.style.visibility = 'hidden';
	  else if (link.indexOf("entrecontato") > 0)
	    document.frmContato.Assunto.style.visibility = 'hidden';
	  else if (link.indexOf("fabri") > 0)
	    document.frmFab.Fab.style.visibility = 'hidden';
	  }
    else if (Lock == 'off')
	  {
      document.all(Div).style.display = 'none';
	  document.Pesquisa.IdL.style.visibility = 'visible';
      var link = location.href;
	  if (link.indexOf("pesquisa") > 0)
	    { 
	    document.frmListagem.NFab.style.visibility = 'visible';
		document.frmListagem.NCat.style.visibility = 'visible';
		}
	  else if (link.indexOf("listagem") > 0)
	    document.frmListagem.NFab.style.visibility = 'visible';
	  else if (link.indexOf("entrecontato") > 0)
	    document.frmContato.Assunto.style.visibility = 'visible';
	  else if (link.indexOf("fabri") > 0)
	    document.frmFab.Fab.style.visibility = 'visible';		
	  }
   }

  else if(navigator.appName == "Netscape") {

    if(Lock == 'on')
      document.getElementById(Div).style.display = 'block';
    else if (Lock == 'off')
      document.getElementById(Div).style.display = 'none';
  }
}
function ProdInfo(Show,B1,B2,B3) {

  if(navigator.appName == "Microsoft Internet Explorer") {

    if(document.all(Show).style.display == 'none')
      document.all(Show).style.display = 'block';
      document.all(B1).style.display = 'none';
      document.all(B2).style.display = 'none';
      document.all(B3).style.display = 'none';
   
   }

  else if(navigator.appName == "Netscape") {

    if(document.getElementById(Show).style.display == 'none')
      document.getElementById(Show).style.display = 'block';
      document.getElementById(B1).style.display = 'none';
      document.getElementById(B2).style.display = 'none';
      document.getElementById(B3).style.display = 'none';
    
  }
}

function PRecomendados(Div,Lock,vId) {

  if(navigator.appName == "Microsoft Internet Explorer") {

    if(Lock == 'on')
	  {
      document.all(Div).style.display = 'block';
	  document.Pesquisa.IdL.style.visibility = 'hidden';
      var link = location.href;
	  if (link.indexOf("pesquisa") > 0)
	    {
	    document.frmListagem.NFab.style.visibility = 'hidden';
		document.frmListagem.NCat.style.visibility = 'hidden';
		}
	  else if (link.indexOf("listagem") > 0)
	    document.frmListagem.NFab.style.visibility = 'hidden';
	  else if (link.indexOf("entrecontato") > 0)
	    document.frmContato.Assunto.style.visibility = 'hidden';

	  }
    else if (Lock == 'off')
	  {
      document.all(Div).style.display = 'none';
	  document.Pesquisa.IdL.style.visibility = 'visible';
      var link = location.href;
	  if (link.indexOf("pesquisa") > 0)
	    {
	    document.frmListagem.NFab.style.visibility = 'visible';
		document.frmListagem.NCat.style.visibility = 'visible';
		}
	  else if (link.indexOf("listagem") > 0)
	    document.frmListagem.NFab.style.visibility = 'visible';
	  else if (link.indexOf("entrecontato") > 0)
	    document.frmContato.Assunto.style.visibility = 'visible';
	  }
   }

  else if(navigator.appName == "Netscape") {

    if(Lock == 'on')
      document.getElementById(Div).style.display = 'block';
    else if (Lock == 'off')
      document.getElementById(Div).style.display = 'none';
  }
}



function Filtrar()
{
  document.frmListagem.submit();
}

//--------------------------------------------------------------------------- Funçoes da comparacao
function Mkp_Comp(Campo)
{
 if (Campo.checked)
  {
    if (parseInt(document.frmComparar.cont.value) < 5)
    {
     document.frmComparar.cont.value =  parseInt(document.frmComparar.cont.value) + 1;
    } else {
     alert('Escolha até 5 produtos para comparar');
	 Campo.checked = false;
	}
  } else {
    document.frmComparar.cont.value =  parseInt(document.frmComparar.cont.value) - 1;
  }
}

function Comparar()
{
 if (parseInt(document.frmComparar.cont.value) > 1)
 {
  document.frmComparar.submit();
 } else {
  alert('Selecione de 2 a 5 produtos para comparação clicando na checkbox.');
 }
}


function ValidaEmail(Tfrm) {   
  if (Tfrm.value == "")
  {
    alert("Por favor, digite o \"e-mail\".");
    Tfrm.focus();
    return false;
  }
  
  if ((Tfrm.value.indexOf('@') == -1) || (Tfrm.value.indexOf('.') == -1) || (Tfrm.value.substring(0 , 1) == "@") || (Tfrm.value.substring(0 , 1) == "."))
  {
    alert("Por favor, digite o seu \"e-mail\" de forma correta.");
    Tfrm.focus();
    return false;
  }
  return true;
}


/**********************************************************************/ 
/*Function name :isDigit(theDigit) */ 
/*Usage of this function :test for an digit */ 
/*Input parameter required:thedata=string for test whether is digit */ 
/*Return value :if is digit,return true */ 
/* else return false */ 
/**********************************************************************/ 
function isDigit(theDigit) 
{ 
  var digitArray = new Array('0','1','2','3','4','5','6','7','8','9'),j; 

  for (j = 0; j < digitArray.length; j++) 
  {
	  if (theDigit == digitArray[j]) 
   return true 
  } 
return false 

} 
/*************************************************************************/ 
/*Function name :isPositiveInteger(theString) */ 
/*Usage of this function :test for an +ve integer */ 
/*Input parameter required:thedata=string for test whether is +ve integer*/ 
/*Return value :if is +ve integer,return true */ 
/* else return false */ 
/*function require :isDigit */ 
/*************************************************************************/ 
function isPositiveInteger(theString) 
{ 
  var theData = new String(theString); 

  if (!isDigit(theData.charAt(0))) 
  if (!(theData.charAt(0)== '+')) 
  return false 

  for (var i = 1; i < theData.length; i++) 
  if (!isDigit(theData.charAt(i))) 
  return false 
  return true 
} 
/**********************************************************************/ 
/*Function name :isDate(s,f) */ 
/*Usage of this function :To check s is a valid format */ 
/*Input parameter required:s=input string */ 
/* f=input string format */ 
/* =1,in mm/dd/yyyy format */ 
/* else in dd/mm/yyyy */ 
/*Return value :if is a valid date return 1 */ 
/* else return 0 */ 
/*Function required :isPositiveInteger() */ 
/**********************************************************************/ 
function isDate(s,f) 
{
  var a1=s.split("/"); 
  var a2=s.split("-"); 
  var e=true; 
  if ((a1.length!=3) && (a2.length!=3)) 
  { 
    e=false; 
  } 
    else
	{
	  if (a1.length==3)
		  var na=a1;
			if (a2.length==3)
			  var na=a2;
				if (isPositiveInteger(na[0]) && isPositiveInteger(na[1]) && isPositiveInteger(na[2]))
				{
				  if (f==1)
					{
					  var d=na[1],m=na[0];
				  }
					else
					{
					  var d=na[0],m=na[1];
				  }
					var y=na[2];
					if (((e) && (y<1000)||y.length>4))
					  e=false
					if (e)
					{
					  v=new Date(m+"/"+d+"/"+y);
						if (v.getMonth()!=m-1)
						e=false;
					}
					}
					else
					{
					e=false;
					}
				}
				return e
			}
			 
function checkDate(v) 
{ 
  var s=v.value; 
	if (s.length>8)
	{
   if (isDate(s,0)) //dd/mm/yyyy format
	  { 
  //   alert("Data válida!");
		} 
   else
	  {
     alert("A data informada não é uma data válida!");
			v.focus();
		}
    return false;
	}
	else
	{
	  if (s.length>0)
		 {
    	alert("Preencha o campo com uma data válida!");
			v.value = "";
			v.focus();
		 }
	} 
}

// ------------------------------------------------------------------------------------------------ Bloco AJAX
var req; 
var vCRet;

function loadXMLDoc(url) 
{ 
    req = null; 
    // Procura por um objeto nativo (Mozilla/Safari) 
    if (window.XMLHttpRequest) { 
        req = new XMLHttpRequest(); 
        req.onreadystatechange = processReqChange; 
        req.open("GET", url, true); 
	req.setRequestHeader( "Content-Type","text/html; charset=UTF-8" );
        req.send(null); 
    // Procura por uma versão ActiveX (IE) 
    } else if (window.ActiveXObject) { 
        req = new ActiveXObject("Microsoft.XMLHTTP"); 
        if (req) {
            req.onreadystatechange = processReqChange; 
            req.open("GET", url, true);
	    req.setRequestHeader( "Content-Type","text/html; charset=iso-8859-1" );
            req.send(); 
        } 
    } 
} 

function processReqChange() 
{ 
    // apenas quando o estado for "completado" 
    //document.getElementById(vCRet).innerHTML='carregando...'
    if (req.readyState == 4) { 
        // apenas se o servidor retornar "OK" 
        if (req.status == 200) { 
            // procura pela div id= e insere o conteudo 
            // retornado nela, como texto HTML 
            var texto = req.responseText;
            texto=texto.replace(/\+/g," ");
            document.getElementById(vCRet).innerHTML = unescape(texto);
	    //document.getElementById(vCRet).innerHTML = decodeURI(texto);
        } else { 
            alert("Houve um problema ao obter os dados:\n" + req.statusText); 
        } 
    } 
} 

function BuscaDados_Ajax(vLink,vR) 
{ 
  vCRet = vR;
  loadXMLDoc(vLink);
  vCRet = vR;
}

function Ajax_Pega(vCampo,vDiv,vUrl)
{
// vCampo = 'form.campo' dos dados a serem capturados do formulario
// vDiv = Nome da div de retorno
// vUrl = Caminho do arquivo q o AJAX vai buscar o novo corpo para a vDiv

  var vValor;
  vValor = eval(vCampo+'.value');
  if (vValor.length > 0)
  {
  BuscaDados_Ajax(vUrl+'&V='+ vValor,vDiv);
  }
}