//<!-- Function Checkbox (alternate selection)-->

	function MM_openBrWindow(theURL,winName,features) { //v2.0
		  window.open(theURL,winName,features);
}


//<!-- Function Max Chars (limits)-->

	function LimitaTexto(CampoTexto,MaxChars,iIdioma){
	
	if(CampoTexto.value.length>MaxChars){
		
	    CampoTexto.value=CampoTexto.value.substring(0,MaxChars);
	    if(iIdioma==0)alert('Este campo pode conter até '+MaxChars+' caracteres.');
	    else if(iIdioma==1)alert('Maximum capacity is '+MaxChars+' characters.');
	    else if(iIdioma==2)alert('Este campo puede contener hasta '+MaxChars+' caracteres.');
	    else if(iIdioma==3)alert('Este campo pode conter até '+MaxChars+' caracteres.');
	    CampoTexto.focus();
    
    }
}


//<!-- Function Popup -->

   
	function NewWindow(mypage, myname, w, h, scroll) {
	
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+0+',resizable='+0+', statusbar=' +0+',toolbar=' +0+''
	
	win = window.open(mypage, myname, winprops)
	
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus(); 
	}
}


	function NewWindow2(mypage, myname, w, h, scroll) {
	
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+0+',resizable='+0+', statusbar=' +0+',toolbar=' +0+''
	
	win = window.open(mypage, myname, winprops)
	
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus(); 
	}
}
//<!-- Function Popup 2 -->


function newWindow2(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}
//  End -->





//<!-- Function Pulldown Menu -->

	function pulldown_menu() {
	
	// Create a variable url to contain the value of the
	// selected option from the the form named pulldown and variable selectname
	var url = document.pulldown.selectname.options[document.pulldown.selectname.selectedIndex].value
	
	// Re-direct the browser to the url value
	window.location.href = url
}
// END -->



//<!-- Function Popup imagens -->

	function CaricaFoto(img){
	  foto1= new Image();
	  foto1.src=(img);
	  Control(img);
	}
	function Control(img){
	  if((foto1.width!=0)&&(foto1.height!=0)){
	    viewFoto(img);
	  }
	  else{
	    funzione="Control('"+img+"')";
	    interval=setTimeout(funzione,20);
	  }
	}
	function viewFoto(img){
	  larg=foto1.width+20;
	  alt=foto1.height+30;
	  string="width="+larg+",height="+alt;
	  finestra=window.open(img,"",string);
	}
//  End -->

	

//<!-- Function Forms: Submit Once -->

	var submitcount=0;

	function reset() {
	document.emailform.name.value="";
	document.emailform.email.value="";
	document.emailform.mensagem.value="";
}
//  End -->



//<!-- Function Forms: Check Fields -->

	function checkFields() {                       // field validation -
	if ( (document.emailform.name.value=="")  ||   // checks if fields are blank.
	     (document.emailform.email.value=="") ||   // More validation scripts at
	     (document.emailform.comments.value=="") ) // forms.javascriptsource.com
	   {
	   alert("(*) Campos Obrigatórios / Obrigatory Fields.");
	   return false;
	   }
	
	else 
	   {
	   if (submitcount == 0)
	      {
	      submitcount++;
	      return true;
	      }
	   else 
	      {
	      alert("Obrigado / Thanks!");
	      return false;
	      }
	   }
}
//  End -->






//<!-- Function Price Format (Reais) -->

	function FormatPrecoReais(num){
	
	num=num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))num="0";
	sign=(num==(num=Math.abs(num)));
	num=Math.floor(num*100+0.50000000001);
	cents=num%100;
	num=Math.floor(num/100).toString();
	if(cents<10)cents="0"+cents;
	for(var i=0;i<Math.floor((num.length-(1+i))/3);i++)num=num.substring(0,num.length-(4*i+3))+'.'+num.substring(num.length-(4*i+3));
	return ((sign)?'':'-')+'R$&nbsp;'+num+','+cents;
}
//  End -->





//MÁSCARA DE VALORES
function txtBoxFormat(objeto, sMask, evtKeyPress) {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;


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

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

    objeto.value = sCod;

    if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "9") { // apenas números...

        return ((nTecla > 47) && (nTecla < 58)); } 
      else { // qualquer caracter...
        return true;
      } 
    }
    else {
      return true;
    }
  }
//  End -->


