<!-- 
function abre(page) {
 window.open(page,'indique','scrollbars=no,width=400,height=520,top=30,left=30');
}


/**
 * 
 */
function habilitaCampo(master, id_slave) {
   slave = document.getElementById(id_slave);
   if (master.checked == true) {
	   slave.disabled = false;
   }
   else {
	   slave[0].selected=true;
	   slave.disabled = true;
	   if (master.name == "deposito") {
		   mostraTipoDeposito(slave);
	   }
   }
}

/**
 * 
 */
function mostraTipoDeposito(campo) {
	if (campo.value == "INT") {
	    document.getElementById("dep_nac").style.display = "none";
	    document.getElementById("dep_int").style.display = "";
	}
	else
	if (campo.value == "NAC") {
	    document.getElementById("dep_nac").style.display = "";
	    document.getElementById("dep_int").style.display = "none";
	}
	else {
	    document.getElementById("dep_nac").style.display = "none";
	    document.getElementById("dep_int").style.display = "none";
	}
}


/**
 *
 */
function mostraOcultaLocal(radio, local2, local1){

	if (radio.checked == true) {
		document.getElementById(local2).style.display = "";
		document.getElementById(local1).style.display = "none";
	} else {
		document.getElementById(local1).style.display = "";
		document.getElementById(local2).style.display = "none";
	}
}


/**
 *
 */
function setAction(tipo){
	switch (tipo) {
		case 1:
			url="carrinhoPasso2.php";
			break
	}
	document.frmFrete.action=url;
	document.frmFrete.submit();
}

/**
 * 
 */
function soNumero(event){
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	var caract = new RegExp(/^[0-9]+$/i);
	var caract = caract.test(String.fromCharCode(keyCode));

    if (keyCode != 9 && keyCode != 8 && keyCode != 46) // backspace
	if(!caract){
		keyCode=0;
		return false;
	}
}

/**
 *
 */
function limpa() {
    var listElementos  = document.forms[0].elements;
    var totalElementos = document.forms[0].elements.length;
   
    for (i=0; i<totalElementos; i++) {
         elemento = listElementos[i];
	     if (elemento.type == "text" || elemento.type == "textarea") {
		 	 elemento.value = "";
	     }
    }
}

/**
 *
 */
function mostrar(obj) {
   document.getElementById(obj).style.visibility = "visible";
}

/**
 *
 */
function ocultar(obj) {
   document.getElementById(obj).style.visibility = "hidden";
}

/**
 *
 */
function acender( linha ) {
	if ( navigator.appName == "Netscape" ) linha.bgColor = "#FAFAEF"
	else linha.style.backgroundColor = "#FAFAEF";
}

/**
 *
 */
function apagar( linha ) {
    if ( navigator.appName == "Netscape" ) linha.bgColor = "#f5f5f5"
	else linha.style.backgroundColor = "#f5f5f5";
}

/**
 *
 */
function abrePopUp(url, width, height, scrollbars) {
	var w = width;
	var h = height;
	var lado = (screen.width - w) / 2;
	var topo = (screen.height - h) / 2;
	janela	= window.open(url, "Commerce",'height='+h+',width='+w+',top='+topo+',left='+lado+',scrollbars='+scrollbars);
	janela.focus();						
}
	
/**
 *
 */
function fechar() {
   window.close();
}

/**
 * Função usada para limitar a quantidade 
 * de caracteres de um determinado campo.  
 **/
function limite(campo, size) 
{   if (campo.value.length > size)
   	{   event.keyCode=0;
        campo.value = campo.value.substring(0, size);
    }
    return;
}
	
/** 
 * Função que formata um campo do formulário de 
 * acordo com a máscara informada... 
 *
 * Parâmetros: 
 *  => objForm (o Objeto Form);
 *  => strField (string contendo o nome do textbox); 
 *  => sMask (mascara que define o formato que o dado será apresentado, 
 *            usando o algarismo "9" para definir números e o símbolo "!" para 
 *            qualquer caracter... 
 *  => evtKeyPress (evento);
 *
 * Uso..: <input type="textbox" name="xxx" 
 * onkeypress="return txtBoxFormat(document.rcfDownload, 'str_cep', '99999-999', event);"> 
 * 
 * Observação: As máscaras podem ser representadas como os exemplos abaixo: 
 * CEP -> 99.999-999  
 * CPF -> 999.999.999-99 
 * RG -> 99.999.999-9
 * CNPJ -> 99.999.999/9999-99 
 * Data -> 99/99/9999 
 * Tel Resid -> (99) 999-9999 
 * Tel Cel -> (99) 9999-9999 
 * Processo -> 99.999999999/999-99 
 * Inscrição Estadual -> 999.999.999-9999
 * C/C -> 999999-! 
 * E por aí vai... 
 **/
function format(field, sMask, evtKeyPress) 
{
   var i;
   var nCount;
   var sValue;
   var fldLen;
   var mskLen;
   var bolMask;
   var sCod;
   var nTecla;

   if(document.all) { // Internet Explorer
      nTecla = evtKeyPress.keyCode; 
   }
   else 
   if(document.layers) { // Nestcape
   	  nTecla = evtKeyPress.which;
   }

   sValue = field.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( " ", "" );
  
   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) == "/"))
       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++;
   }

   field.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 redirect(url) {
	document.location.href = url;
}
/**
 *
 */
function Enviar(url){
	var l;
	var r;
	l = 420;
	r= 420;
    window.open ('indique.php?u='+url,'enviar', 'width='+l+', height='+r+', left='+((screen.width/2)-(l/2))+',top='+((screen.height/2)-(r/2)) );

}

function isCreditCard(st) {
  if (st.length > 19)
      return (false);

  sum = 0; mul = 1; l = st.length;
  for (i = 0; i < l; i++) {
    digit = st.substring(l-i-1,l-i);
    tproduct = parseInt(digit ,10)*mul;
    if (tproduct >= 10)
      sum += (tproduct % 10) + 1;
    else
      sum += tproduct;
    if (mul == 1)
      mul++;
    else
      mul--;
  }
  if ((sum % 10) == 0)
    return (true);
  else
    return (false);
}

// width to resize large images to
var maxWidth=200;
// height to resize large images to
var maxHeight=200;
// valid file types
var fileTypes=["gif","jpg","jpeg"];
// the id of the preview image tag
var outImage="previewField";
// what to display when the image is not valid
var defaultPic="spacer.gif";
// what to display when the image is not valid
var img="";
// 
var globalPic;

function preview(what, ind){
    outImage='';
    outImage="previewField";
   	outImage=outImage+ind;
    var source=what.value;
	var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
	img = what;

	for (var i=0; i<fileTypes.length; i++) if (fileTypes[i]==ext) break;
	     globalPic=new Image();
     if (i<fileTypes.length) 
		 globalPic.src=source;
     else {
	     globalPic.src=defaultPic;
         alert("IMAGEM INVÁLIDA \nPor favor carregue uma imagem com umas das extensões:\n\n"+fileTypes.join(", "));
	 }

     setTimeout("applyChanges()",200);
}

function applyChanges(){
	 var field=document.getElementById(outImage);
	 var x=parseInt(globalPic.width);
	 var y=parseInt(globalPic.height);

	 if (x>maxWidth) {
	 	 y*=maxWidth/x;
         x=maxWidth;
	 }
	 if (y>maxHeight) {
         x*=maxHeight/y;
         y=maxHeight;
	 }

	 field.style.display = (x<1 || y<1)?"none":"";
	 field.src=globalPic.src;
	 field.width=x;
	 field.height=y;
}

//-->
