// JavaScript Document
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_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_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 mOvr(src,clrOver) {
	if (!src.contains(event.fromElement)) {
		//document.getElementById(font_id).style.fontWeight = 'bold';
		src.style.cursor = 'hand';
		//src.style.cursor = 'default';
		src.bgColor = clrOver;
		//src.background = clrOver;
	}
}
function mOut(src,clrIn) {
	if (!src.contains(event.toElement)) {
		src.style.cursor = 'default';
		//document.getElementById(font_id).style.fontWeight = 'normal';
		src.bgColor = clrIn;
		//src.background = clrIn;
	}
}
function mClk(link_id) {
	//if(event.srcElement.tagName=='TD'){
		//src.children.tags('a')[0].click();
		//alert(link_id);
		//alert(document.getElementById("a_link"));
		e = document.getElementById(link_id);
		e.click();
	//}
}
function setLink(link_id,status) {
	if (status) {
		document.getElementById(link_id).style.color= '#000000';
		document.getElementById(link_id).style.textDecoration= 'none';
		document.getElementById(link_id).style.fontWeight= 'normal';
		/*
		e = document.getElementById(link_id);
		e.className = 'link_estado1';*/
		
	} else {
		document.getElementById(link_id).style.color= '#666666';
		document.getElementById(link_id).style.textDecoration= 'none';
		document.getElementById(link_id).style.fontWeight= 'normal';
		/*
		e = document.getElementById(link_id);
		e.className = 'link_estado2';*/
		
	}
}
function RichInputsOver(src,status) {
	if (status) {
		src.style.borderTopColor = '#f7f7f7';
		src.style.borderRightColor = '#f7f7f7';
		src.style.borderBottomColor = '#ffcc00';
		src.style.borderLeftColor = '#f7f7f7';
	} else {
		src.style.borderTopColor = '#f7f7f7';
		src.style.borderRightColor = '#f7f7f7';
		src.style.borderBottomColor = '#cccccc';
		src.style.borderLeftColor = '#f7f7f7';
	}
}
function ValidacaoEmail(emailad){
    var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
    var check=/@[\w\-]+\./;
    var checkend=/\.[a-zA-Z]{2,3}$/;
    if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1)){
        return false;
    }
    else {
        return true;
    }
}
function validaNewsLetterForm(txt_ob,txt_email) {

	NL_Nome = document.NL_form.NL_Nome.value;
	NL_Email = document.NL_form.NL_Email.value;

	
	chk = true;
	if (NL_Nome == "" || NL_Email == "") {
		alert(txt_ob);
		chk = false;
	}
	if (chk && !ValidacaoEmail(NL_Email)) {
		alert(txt_email);
		chk = false;
	}
	
	
	return chk;
}
function validaContatoForm(txtC_ob,txtC_email) {


	Contato_Nome = document.formContato.Contato_Nome.value;
	Contato_Email = document.formContato.Contato_Email.value;
	Contato_Texto = document.formContato.Contato_texto.value;
	
	ckContato = true;
	if (Contato_Nome == "" || Contato_Email == "" || Contato_Texto == "") {
		alert(txtC_ob);
		ckContato = false;
	}
	if (ckContato && !ValidacaoEmail(Contato_Email)) {
		alert(txtC_email);
		ckContato = false;
	}
	
	return ckContato;
}

function validaClienteForm(txtCC_ob,txtCC_email,txtCC_senha2) {

	Cliente_Nome = document.formClientes.Cliente_Nome.value;
	Cliente_RazaoSocial = document.formClientes.Cliente_RazaoSocial.value;
	Cliente_Email = document.formClientes.Cliente_Email.value;
	Cliente_CNPJ_CPF = document.formClientes.Cliente_CNPJ_CPF.value;
	
	Cliente_Resp = document.formClientes.Cliente_Resp.value;
	Cliente_RespCPF = document.formClientes.Cliente_RespCPF.value;
	Cliente_Tel = document.formClientes.Cliente_Tel.value;
	Cliente_Login = document.formClientes.Cliente_Login.value;
	Cliente_Senha = document.formClientes.Cliente_Senha.value;
	Cliente_Senha2 = document.formClientes.Cliente_Senha2.value;
	
	End_End = document.formClientes.End_End.value;
	End_Num = document.formClientes.End_Num.value;
	End_Bairro = document.formClientes.End_Bairro.value;
	End_CEP = document.formClientes.End_CEP.value;
	End_Cidade = document.formClientes.End_Cidade.value;
	End_UF = document.formClientes.End_UF.value;
	End_Pais = document.formClientes.End_Pais.value;
	
	ckClienteC = true;
	
	if (Cliente_Nome == "" || Cliente_RazaoSocial == "" || Cliente_Email == "" || Cliente_CNPJ_CPF == "" || Cliente_Resp == "" || Cliente_RespCPF == "" || Cliente_Tel == "" || Cliente_Login == "" || Cliente_Senha == "" || Cliente_Senha2 == "" || End_End == "" || End_Num == "" || End_CEP == "" || End_Cidade == "" || End_UF == "" || End_Pais == "") {
		alert(txtCC_ob);
		ckClienteC = false;
	}
	if (ckClienteC && !ValidacaoEmail(Cliente_Email)) {
		alert(txtCC_email);
		ckClienteC = false;
	}
	if (Cliente_Senha != Cliente_Senha2) {
		alert(txtCC_senha2);
		ckClienteC = false;
	}
	return ckClienteC;
}

function MKTviral(status) {
	if (status) {
		document.getElementById('mktViral').className = "show";
	} else {
		document.getElementById('mktViral').className = "hidden";
	}
}

function validaMktForm(txtMV_ob,txt_RemEmail,txt_DestEmail) {

	Viral_RemNome = document.formMKT.Viral_RemNome.value;
	Viral_RemEmail = document.formMKT.Viral_RemEmail.value;
	Viral_DestNome = document.formMKT.Viral_DestNome.value;
	Viral_DestEmail = document.formMKT.Viral_DestEmail.value;
	Viral_Texto = document.formMKT.Viral_Texto.value;
	
	

	
	chkMKTCont = true;
	if (Viral_RemNome == "" || Viral_RemEmail == "" || Viral_DestNome == "" || Viral_DestEmail == "" || Viral_Texto == "") {
		alert(txtMV_ob);
		chkMKTCont = false;
	}
	if (chkMKTCont && !ValidacaoEmail(Viral_RemEmail)) {
		alert(txt_RemEmail);
		chkMKTCont = false;
	}
	if (chkMKTCont && !ValidacaoEmail(Viral_DestEmail)) {
		alert(txt_DestEmail);
		chkMKTCont = false;
	}

	return chkMKTCont;
}

function popitup(url,h,w) {
	newwindow=window.open(url,'name','height='+h+',width='+w+',scrollbars=1,status=1');
	if (window.focus) {newwindow.focus()}
}
function popIMG(img) {
	h=100;
	w=100;
	newwindow=window.open('VIEW/POPUP/img.cfm?img='+img,'Imagem','height='+h+',width='+w+',scrollbars=1,status=1');
	if (window.focus) {newwindow.focus()}
}

//função que altera a classe de um objeto pelo Id - BY BUENO CFD
setClassById = new Function ('id','classe','e = document.getElementById(id);e.className=classe');
