/*# IMAGE CHANGER #*/
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_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 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;
}

/*# POP-UP (Localização) #*/
function abre_pop(theURL,winName,W,H) {
	var X = Math.ceil( (window.screen.height - H) / 2 );
	var Y = Math.ceil( (window.screen.width - W) / 2 );
	window.open(theURL,winName,'width='+W+',height='+H+',top='+X+',left='+Y+',location=no,status=no,menubar=no,scrollbars=auto,resizable=no,directories=no,toolbar=no');
}

/*# BANNER #*/
function banner(bannerID) {
	codigos.location.href = 'codigos/banner.asp?bannerID='+bannerID;
}

/*# POP ESPECIFICAÇÕES TÉCNICAS #*/
function pop_produto(id_especificacao_tecnica) {
	var W = 650;
	var H = 500;
	var X = Math.ceil( (window.screen.height - H) / 2 ) - 20;
	var Y = Math.ceil( (window.screen.width - W) / 2 ) - 16;
	window.open('popups/especificacao_tecnica.asp?id_especificacao_tecnica='+id_especificacao_tecnica,'produto','width='+W+',height='+H+',top='+X+',left='+Y+',location=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,toolbar=no');
}

/*# VERIFICAR NEWSLETTER #*/
function verificar_newsletter() {
	vc_erro		= '';
	vc_erro_mail = '';
	
	if (frm.vc_nome.value.length == 0) {
	 	vc_erro	= vc_erro + '- Digite o NOME.\n';		
	}

	if (frm.vc_email.value.length != 0) {
			invalidChars	= "/:,;!?<>*&^%$#(){}|~`"
			atPos			= frm.vc_email.value.indexOf("@",1)
			periodPos		= frm.vc_email.value.indexOf(".",atPos)
			
			for (i=0; i<invalidChars.lenght; i++) {
				badChar		= invalidChars.charAt(i)
				if (frm.vc_email.value.length.indexOf(badChar,0) > -1) {
					vc_erro_mail = '- O E-MAIL digitado é inválido.\n';
				}
			}
			if (atPos == -1) {
				 vc_erro_mail	= '- O E-MAIL digitado é inválido.\n';
			}
			if(frm.vc_email.value.indexOf("@",atPos+1) > -1) {
				 vc_erro_mail	= '- O E-MAIL digitado é inválido.\n';
			}
			if (periodPos == -1) {
				 vc_erro_mail	= '- O E-MAIL digitado é inválido.\n';
			}
			if ((periodPos+3) > frm.vc_email.value.length) {
				 vc_erro_mail	= '- O E-MAIL digitado é inválido.\n';
			}
			vc_erro = vc_erro + vc_erro_mail;
	} else {
 		vc_erro	= vc_erro + '- Digite o E-MAIL.\n';		
	}

	if (vc_erro.length == 0) {
		document.frm.submit();
	} else {
		alert('ATENÇÃO!\n\n' + vc_erro);
		return false;
	}
}
/*# MASCARA */
function mascarar(vc_campo,vc_mascara) {
	var i		= vc_campo.value.length;
	var x		= vc_mascara.substring(0,1);
	var y		= vc_mascara.substring(i);
	
	if (y.substring(0,1) != x) {
		vc_campo.value += y.substring(0,1);
	}
}
/*#SO NUMERO#*/
function soNumero(e) {
	if (document.all) {
		var tecla	= event.keyCode;
	} else if(document.layers) {
		var tecla	= e.which;
	}
	
	if (tecla >= 48 && tecla <= 57) {
		return true;
	} else if (tecla != 8) {
		event.keyCode = 0;
	} else {
		return true;
	}
}

function frase_popup(campo){

	if (typeof(campo) != "object"){
		var campo = eval('document.frm.'+campo);
	}

	if(campo.value==''){
		campo.value = 'Somente Números';
	}
}

function limpa_frase_popup(campo){

	if (typeof(campo) != "object"){
		var campo = eval('document.frm.'+campo);
	}
	
	if(campo.value=='Somente Números'){
		campo.value = '';
	}
}

function desabilitaBtNews(it){

	if(document.getElementById('it_status').checked == true){
		document.getElementById('bt_envio').disabled = false;
	}else{
		document.getElementById('bt_envio').disabled = true;		
	}
}
