﻿function bookmarksite(title, url){ 
    if (document.all) window.external.AddFavorite(url, title); 
    else if (window.sidebar) window.sidebar.addPanel(title, url, "") 
}

function CarregaLoading(Tipo){
    if(Tipo=='Load'){
        document.getElementById("loadDiv").style.display = "block";
    }else{
        document.getElementById("loadDiv").style.display = "none";
    }
}

function MudaCor(campo){
    document.aspnetForm[campo].style.border = '1px solid #FFC615';
}

function TiraCor(campo){
    document.aspnetForm[campo].style.border = '1px solid #AAAAAA';
}

function ReloadSWF_VideoBanner(varDiv){
    var flashBanner = '<object id="videoBannerObject" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="400" height="221">';
        flashBanner +=' <param name="movie" value="/VideoBanner.swf" />';
        flashBanner +=' <param name="quality" value="high" />';
        flashBanner +=' <param name="wmode" value="transparent" />';
        flashBanner +=' <embed src="/VideoBanner.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="400" height="221"></embed>';
        flashBanner +='</object>';
    //document.getElementById(varDiv).innerHTML = flashBanner;
}

function VideoBanner(valor){
    if(valor=='hidden'){
        ReloadSWF_VideoBanner('videoBannerDiv');
        document.getElementById("videoBannerDiv").style.visibility = "hidden";
    }else{
        document.getElementById("videoBannerDiv").style.visibility = "visible";
    }
}

function AbasMeioHome(aba, idioma){
    document.all.ctl00_ContentPlaceHolder1_WUCMeioHome1_cadastroImage.src = "/Local/images/MeioHome/" + idioma + "/caixa_meio_03.jpg";
    document.getElementById("ConteudoMeioDiv11").style.display = "none";
    document.getElementById("ConteudoMeioDiv12").style.display = "none";
    document.all.ctl00_ContentPlaceHolder1_WUCMeioHome1_oportNegociosImage.src = "/Local/images/MeioHome/" + idioma + "/caixa_meio_04.jpg";
    document.getElementById("ConteudoMeioDiv2").style.display = "none";
    document.all.ctl00_ContentPlaceHolder1_WUCMeioHome1_conhecaImage.src = "/Local/images/MeioHome/" + idioma + "/caixa_meio_05.jpg";
    document.getElementById("ConteudoMeioDiv3").style.display = "none";
    if(aba=='1'){
        document.all.ctl00_ContentPlaceHolder1_WUCMeioHome1_cadastroImage.src = "/Local/images/MeioHome/" + idioma + "/caixa_meio_over_03.jpg";
        document.getElementById("ConteudoMeioDiv11").style.display = "block";
    }
    if(aba=='2'){
        document.all.ctl00_ContentPlaceHolder1_WUCMeioHome1_oportNegociosImage.src = "/Local/images/MeioHome/" + idioma + "/caixa_meio_over_04.jpg";
        document.getElementById("ConteudoMeioDiv2").style.display = "block";
    }
    if(aba=='3'){
        document.all.ctl00_ContentPlaceHolder1_WUCMeioHome1_conhecaImage.src = "/Local/images/MeioHome/" + idioma + "/caixa_meio_over_05.jpg";
        document.getElementById("ConteudoMeioDiv3").style.display = "block";
    }
    if(aba=='4'){
        document.all.ctl00_ContentPlaceHolder1_WUCMeioHome1_cadastroImage.src = "/Local/images/MeioHome/" + idioma + "/caixa_meio_over_03.jpg";
        document.getElementById("ConteudoMeioDiv12").style.display = "block";
    }
}

var total=0;
function HabilitaTodos(){
    with(document.aspnetForm){
        elementos = getElementsByTagName('input');
        for(i=0;i < elementos.length;i++){
            if(elementos[i].type=='checkbox'){
                if(total==0){
                    elementos[i].checked = true;
                }else{
                    elementos[i].checked = false;
                }
            }
        }
        if(total==0){
            total=1;
        }else{
            total=0;
        }
    }
}

function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
    
 var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nvendla;

  if(document.all) { // Internet Explorer
    nvendla = evtKeyPress.keyCode; }
  else if(document.layers) { // Nestcape
    nvendla = evtKeyPress.which;
  }

//alert(strField)
  sValue = objForm[strField].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++;
  }

  objForm[strField].value = sCod;

  if (nvendla != 8) { // backspace
    if (sMask.charAt(i-1) == "9") { // apenas números...
      	return ((nvendla > 47) && (nvendla < 58)); 
      } // números de 0 a 9
    else { // qualquer caracter...
      return true;
    } }
  else {
    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_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_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 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 AbasTopo(idImagem, caminhoImagem){
    document.all[idImagem].src = caminhoImagem;
}