<!--
function pop1(codigo){
	window.open("./produtos_img_grande.php?cod="+codigo,"","left=300,top=50,width=350,height=315,location=no,directories=no,toolbar=no,resizable=yes,scrollbars=yes")
};

function pop(codimagem){
	window.open("./mostra_imagem_grande.php?cod="+codimagem,"","left=300,top=50,width=570,height=400,location=no,directories=no,toolbar=no,resizable=yes,scrollbars=yes")
};

function popImg(codimagem, cor){
	if (cor == 0)
		window.open("./mostra_imagem_grande2.php?cod="+codimagem,"","left=300,top=50,width=570,height=450,location=no,directories=no,toolbar=no,resizable=yes,scrollbars=yes")
	else
		window.open("./mostra_imagem_grande2.php?cod="+codimagem+"&tam="+cor,"","left=300,top=50,width=570,height=450,location=no,directories=no,toolbar=no,resizable=yes,scrollbars=yes")
};

function MM_preloadImages() { //v2.0
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}

function FindGroup(grp, imageName) {
        var img = FWFindImage(document, imageName, 0);
        if (!img) return(false);
        var docGroup = eval("document.FWG_"+grp);
        if (!docGroup) {
                docGroup = new Object;
                eval("document.FWG_"+grp+" = docGroup");
                docGroup.theImages = new Array;
        }
        if (img) {
                var i;
                for (i=0; i<docGroup.theImages.length; i++) {
                        if (docGroup.theImages[i] == img) break;
                }
                docGroup.theImages[i] = img;
                if (!img.atRestSrc) {
                        img.atRestSrc = img.src;
                        img.initialSrc = img.src;
                }
        }
        return(docGroup);
}

function FWFindImage(doc, name, j)
{
        var theImage=false;
        if (doc.images) {
                theImage = doc.images[name];
        }
        if (theImage) return theImage;
        if (doc.layers) {
                for (j=0; j<doc.layers.length; j++) {
                        theImage = FWFindImage(doc.layers[j].document, name, 0);
                        if (theImage) return(theImage);
                }
        }
        return(false);
}

function GrpRestore(grp){
        var docGroup = eval("document.FWG_"+grp);if (!docGroup) return;
        theImages = docGroup.theImages;
        if (theImages) {
                for (i=0; i<theImages.length; i++) {
                        var curImg = theImages[i];
                        if (curImg.atRestSrc) {
                                curImg.src = curImg.atRestSrc;
                        }
                }
        }
}

function GrpSwap(grp){
        var i,j=0,newSrc,objName;
        var docGroup = false;
        for (i=1; i < (GrpSwap.arguments.length-1); i+=2) {
                objName = GrpSwap.arguments[i];
                newSrc = GrpSwap.arguments[i+1];
                docGroup = FindGroup(grp, objName);
                if (!docGroup) continue;
                obj = FWFindImage(document,objName,0);
                if (!obj) continue;
                if (obj.isDown) {
                        if (obj.downOver) {
                                obj.src = obj.downOver;
                        }
                } else {
                        obj.src = newSrc;
                        obj.atRestSrc = obj.initialSrc;
                }
                obj.skipMe = true;
                j++;
        }
        if (!docGroup) return;
        theImages = docGroup.theImages;
        if (theImages) {
                for (i=0; i<theImages.length; i++) {
                        var curImg = theImages[i];
                        if (curImg.atRestSrc && !curImg.skipMe) {
                                curImg.src = curImg.atRestSrc;
                        }
                        curImg.skipMe = false;
                }
        }
}

function envia(fomularioCGC){
	if (fomularioCGC.cgc1.value!="" & fomularioCGC.cgc2.value!="" & fomularioCGC.cgc3.value!="" & fomularioCGC.cgc4.value!="" & fomularioCGC.cgc5.value!=""){
                fomularioCGC.cgc.value = fomularioCGC.cgc1.value + "." +fomularioCGC.cgc2.value + "." + fomularioCGC.cgc3.value + "/" + fomularioCGC.cgc4.value + "/" + fomularioCGC.cgc5.value;
                if(fomularioCGC.cgc.value!="00.000.000/0000/00"){
                        fomularioCGC.submit();
                }else{
                        window.alert("E preciso informar um CNPJ válido...");
                };
        }
        else{
                window.alert("E preciso informar um CNPJ válido...");
        };
}

function envia2(){
        window.open("produtos_novo/produto_cadastro_cliente.php3","","resizable=yes,width=600,height=400,location=no,directories=no,toolbar=no,scrollbars=yes")
//                document.forme.action="produtos/produto_consulta.php3";
//                document.forme.submit();
}

function InicializarIndices()
{
        if (document.CargaInicial==null)
        {
                document.CargaInicial=false;                // Seta para só fazer uma vez por documento
                var ctrlAnterior=null;
                var IndAnt=0;
                for ( var i=0; i<document.forms[0].elements.length;i++)
                {
                        var e=document.forms[0].elements[i];
                        if ( e.type!="hidden" && e.type!="image" )
                        {
                                if ( ctrlAnterior != null )
                                        ctrlAnterior.IndicePosterior=i;
                                ctrlAnterior=e;
                                e.Indice=i;
                                e.IndiceAnterior=IndAnt;
                        }
                }
                //if ( ctrlAnterior!=null )
                //{
                //        ctrlAnterior.IndicePosterior=i-1;
                //}
        }
}

// Colocar o foco em determinado campo
function SetarFoco ( ind )
        {
        InicializarIndices();
        if ( isNaN(ind) && document.forms[0].elements[ind].type!="hidden" )
                document.forms[0].elements[ind].focus();
        else
                for (;ind<document.forms[0].elements.length;ind++)
                        if ( document.forms[0].elements[ind].type!="hidden" )
                                break;
                if ( ind<=document.forms[0].elements.length )
                        document.forms[0].elements[ind].focus();
        }

// Limpar o conteúdo do(s) campo(s)
function LimparCampo ( ind )
        // Para -1, limpa todos os elementos
        {
        if (isNaN(ind))                        // Limpa pelo nome
                document.forms[0].elements[ind].value="";
        else if (ind != -1 )        // Limpa o elemento "ind" ( só considera "text" e "password" )
                for ( var i=ind; i < document.forme[0].elements.length;i++ )
                        if ( document.forms[0].elements[i].type=="text" || document.forms[0].elements[i].type=="password")                // Só limpa campo "text"
                                {
                                document.forms[0].elements[i].value="";
                                break;
                                }
        else                                        // Limpa todos os elementos "text" e "password"
                for ( var i=0; i < document.forms[0].elements.length; i++ )
                        if ( document.forms[0].elements[i].type=="text" || document.forms[0].elements[i].type=="password" )
                                document.forms[0].elements[i].value="";

        }

// Verificar qual navegador
function QualNavegador()
{
        var s = navigator.appName;
        if ( s == "Microsoft Internet Explorer" )
                return "IE";
        else if ( s == "Netscape" )
                return "NE";
        else
                return "";
}

// Verificar qual a versão do navegador
function QualVersao()
{
        var s = navigator.appVersion;
        if ( QualNavegador() == "IE" )
        {
                var i = s.search("MSIE");
                s=s.substring(i+5);
                i=s.search(".");
                return parseInt(s.substring(0,i+1));
        }
        else if ( QualNavegador() == "NE" )
                return parseInt(s.substring(0,1));
        else
                return 0;
}


// Setar o evento
function SetarEvento(ctrl, Tam, Tipo, AutoSkip )
{
        // Filtra navegadores conhecidos
        var s = QualNavegador();
        if ( s.length==0 )
                return;
        if ( s=="IE" && QualVersao()>5 )
                return;
        if ( s=="NE" && QualVersao()>4 )
                return;

        if (ctrl.onkeypress==null)
        {
                if (AutoSkip==null)
                        AutoSkip=true;
                if (Tipo!=null)
                        Tipo.toUpperCase();
                ctrl.Tam=Tam;
                ctrl.Tipo=Tipo;
                ctrl.AutoSkip=true;
                ctrl.Saltar=false;
                InicializarIndices();
                ctrl.onkeypress=ValidarTecla;
                if (QualNavegador()=="IE" && QualVersao()==5)
                        ctrl.onkeyup=SaltarCampo;
        }
}

function SaltarCampo(ctrl)
{
        if (ctrl==null)
                ctrl=this;
        if ( ctrl.AutoSkip && ctrl.Saltar)
                if (ctrl.Saltar)
                {
                        ctrl.Saltar=false;
                        if ( ctrl.IndicePosterior != null )
                                SetarFoco(ctrl.IndicePosterior);
                }
}

// Fazer o salto de campo
function ValidarTecla (evnt)
{
        var tk;
    var c;
        // Recebe a tela pressionada
        tk = ( (QualNavegador()=="IE") ? event.keyCode : evnt.which);
    c=String.fromCharCode(tk);
        c=c.toUpperCase();

        // -- Este trecho faz com que o <Enter> tenha a função de <Tab>, mas acho inviável, pois não é possível
        //       colocar o foco em campos do Tipo "image", e, neste caso, nunca seria possível fazer a submissão
        //       do formulário
        // if ( tk == 13 )
        // {
        //        this.Saltar=true;
        //        SaltarCampo(this);
        //        return false;
        // }

        // Só aceita teclas alfanuméricas. Não aceita teclas de controle
    if ( tk < 32 )
                return true;
        if ( tk > 127 )
                return false;

        switch ( this.Tipo )
        {
        case "D":
                if ( c<"0" || c>"9" )
                        return false;
                break;
        case "N":
                if ( (c<"0" || c>"9") && (c!="." && c!=",") )
                        return false;
                if ( (c==",") && ((this.value.search(",")>-1) || (this.value.length==0)) )
                        return false;
                if ( (c==".") && (this.value.length==0) )
                        return false;
                break;
        case "C":
                if ( c<"A" || c>"Z" )
                        return false;
                break;
        default:
                break;
        }

        this.Saltar=(this.value.length==this.Tam-1);
        if ( ((QualNavegador()=="IE") && QualVersao()<5) || (QualNavegador()!="IE") )
                SaltarCampo(this);

        return true;
}//-->

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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

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 right(e) {
  var msg = "Essa imagem é de propriedade da XILYA Traders. A cópia é proibida.";

  if (navigator.appName == 'Netscape' && e.which == 3) {
   alert(msg);
   return false;
  }

  if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) {
   alert(msg);
   return false;
  }
  else return true;
}

function trap() {
  if(document.images) {
    for(i=0;i<document.images.length;i++) {
      document.images[i].onmousedown = right;
      document.images[i].onmouseup = right;
    }
  }
}

function valida(oformulariopedido,nome,preco,usuarioquant,cor){
                with(oformulariopedido){
                        if(usuarioquant == ""){
                                window.alert("E preciso informar a quantidade do produto que deseja encomendar");
                                quantidade.focus();
                        }else{
                           if(digitvalidation(usuarioquant)){
                                produto_nome.value = nome;
                                produto_preco.value = preco;
                                window.location="produtos_pedido_ver.php?acao=incluir&tipo=<? echo $tipo; ?>&produto=<? echo $produto; ?>&produto_nome=" + nome + "&produto_preco=" + preco + "&produtoADD=" + produtoADD.value + "&quantidade=" + usuarioquant + "&produto_cor=" + cor + "&adiciona=ok";
                                }else{
                                        window.alert("Você precisa digitar números inteiros!");
                                }
                        }
                }
}

function digitvalidation(valor){
                        checkvalue=parseFloat(valor);
                        checkvalue=parseInt(valor);
                        if (valor!=checkvalue || valor.indexOf("produtos/produtos/.")!=-1){
                                return false;
                        }else{
                                   return true;
                        }
};

function valida_envio(thisform){
	with (thisform){
		if((email.value == "")||(transportadora.value == "")||(contato.value == "")||(ddd.value == "")||(tel.value == "")){
			window.alert("É necessário o preenchimento de todos os campos");
		}else{
			//if(confirm('Deseja imprimir uma cópia do pedido ?')){
			//	window.open('produtos_pedido_ver.php?imprimir=ok','','toolbar=0,location=0,directories=0,status=0, menubar=1,scrollbars=1,resizable=1,width=315,height=225');
			//};
			thisform.submit();
                }
        }
}


//-->
