//NEWSLETTER - VALIDA
function validaNews(){
	frm=document.formNews;
	if (frm.nome.value.length==0){
		alert ("Preencha o campo Nome!");
		frm.nome.focus();
		return false;
	}
	if (frm.email.value.length==0){
		alert ("Preencha o campo E-mail!");
		frm.email.focus();
		return false;
	}
}
// POP UP
function popup(theURL, width, height, features) { 
	//"location=no,menubar=no,resiable=no,toolbar=no,scroollbars=yes"
	if(window.screen){
		per_ancho=(width/screen.width)*100;
		per_alto=(height/width)*100;
		win_ancho=(screen.width*per_ancho)/100;
		win_alto=(win_ancho*per_alto)/100;
		x=(screen.width-win_ancho)/2;
		y=(screen.height-win_alto)/2;
	}else{
		x=0;
		y=0;
		win_ancho=w;
		win_alto=y;
	}
	winfeatures=("top="+y+",left="+x+",width="+win_ancho+",height="+win_alto+","+features);
	window.open(theURL, 'popup', winfeatures);
}

function nada() {
   return;
}
//FLASH
function flash(versao, largura, altura, nome, modo, cor)
{
	/*
	versao = 8 .................. <- Versão do player
	largura = 200px ............. <- Largura do SWF
	altura = 200px .............. <- Altura do SWF
	id = nome ................... <- ID do arquivo
	nome = arquivo.swf .......... <- Caminho do SWF, essa opção não pode ser vazia
	modo = transparent/opaque ... <- Flash transparente ou opaco / pode ser vazia
	cor = #ffffff ............... <- Cor de fundo
	*/
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="'+versao+',0,0,0" width="'+largura+'" height="'+altura+'">\n');
	document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write('<param name="movie" value="'+nome+'" />\n');
	document.write('<param name="wmode" value="'+modo+'" />\n');
	document.write('<param name="bgcolor" value="'+cor+'" />\n');
	document.write('<embed src="'+nome+'" wmode="'+modo+'" bgcolor="'+cor+'" width="'+largura+'" height="'+altura+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
	document.write('</object>\n');
}
/// DATA - ÍNICIO
function data() {
	mdata = new Date();
	mhora = mdata.getHours();
	mminuto = mdata.getMinutes();
	msegundos = mdata.getSeconds();
	mdia = mdata.getDate();
	mdiasemana = mdata.getDay();
	mmes = mdata.getMonth();
	mano = mdata.getFullYear();
	if (mdiasemana == 0) {
		document.write("'Domingo, ");
	} else if (mdiasemana == 1) {
		document.write("Segunda-feira, ");
	} else if (mdiasemana == 2) {
		document.write("Ter&ccedil;a-feira, ");
	} else if (mdiasemana == 3) {
		document.write("Quarta-feira, ");
	} else if (mdiasemana == 4) {
		document.write("Quinta-feira, ");
	} else if (mdiasemana == 5) {
		document.write("Sexta-feira, ");
	} else if (mdiasemana == 6) {
		document.write("S&aacute;bado, ");
	}
	document.write(+mdia+' de ');
	if (mmes == 0) {
		document.write("janeiro de ");
	} else if (mmes == 1) {
		document.write("fevereiro de ");
	} else if (mmes == 2) {
		document.write("mar&ccedil;o de ");
	} else if (mmes == 3) {
		document.write("abril de ");
	} else if (mmes == 4) {
		document.write("maio de ");
	} else if (mmes == 5) {
		document.write("junho de ");
	} else if (mmes == 6) {
		document.write("julho de ");
	} else if (mmes == 7) {
		document.write("agosto de ");
	} else if (mmes == 8) {
		document.write("setembro de ");
	} else if (mmes == 9) {
		document.write("outubro de ");
	} else if (mmes == 10) {
		document.write("novembro de ");
	} else if (mmes == 11) {
		document.write("dezembro de ");
	}
	document.write(mano);
}
// DATA - FIM
// IS NUMERIC
//onKeyPress="return(IsNumeric(this,event))"
function IsNumeric(fld, e) 
{
	var strCheck = '0123456789';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	key = String.fromCharCode(whichCode);
	if (strCheck.indexOf(key) == -1) return false;
}
//LAYER
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_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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;
			}
			if (obj.visibility=='hidden'){
				obj.visibility='visible';
			}
			else{
				obj.visibility='hidden';
			}
			
		}
	}
}

function mask(fld, e) 
{
	if(fld.value.length == 2){
		fld.value = fld.value + "/";
	}
	if(fld.value.length == 5 ){
		fld.value = fld.value + "/";
	}
	var strCheck = '0123456789';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	key = String.fromCharCode(whichCode);
	if (strCheck.indexOf(key) == -1) return false;
}
function validaProposta(){
	frmProposta = document.formProposta;
	if (frmProposta.nome.value.length==0){
		alert('Preencha o campo Nome !!');
		frmProposta.nome.focus();
		frmProposta.nome.select();
		return false;
	}
	if (frmProposta.cpf.value.length==0){
		alert('Preencha o campo CPF !!');
		frmProposta.cpf.focus();
		frmProposta.cpf.select();
		return false;
	}
	if (frmProposta.rg.value.length==0){
		alert('Preencha o campo RG !!');
		frmProposta.rg.focus();
		frmProposta.rg.select();
		return false;
	}
	if (frmProposta.endereco.value.length==0){
		alert('Preencha o campo Endereço !!');
		frmProposta.endereco.focus();
		frmProposta.endereco.select();
		return false;
	}
	if (frmProposta.cep.value.length==0){
		alert('Preencha o campo CEP !!');
		frmProposta.cep.focus();
		frmProposta.cep.select();
		return false;
	}
	if (frmProposta.bairro.value.length==0){
		alert('Preencha o campo Bairro !!');
		frmProposta.bairro.focus();
		frmProposta.bairro.select();
		return false;
	}
	if (frmProposta.cidade.value.length==0){
		alert('Preencha o campo Cidade !!');
		frmProposta.cidade.focus();
		frmProposta.cidade.select();
		return false;
	}
	if (frmProposta.estado.value==0){
		alert('Preencha o campo Estado !!');
		frmProposta.estado.focus();
		return false;
	}
	if (frmProposta.dddTel.value.length==0){
		alert('Preencha o campo DDD do Telefone !!');
		frmProposta.dddTel.focus();
		frmProposta.dddTel.select();
		return false;
	}
	if (frmProposta.telefone.value.length==0){
		alert('Preencha o campo Telefone !!');
		frmProposta.telefone.focus();
		frmProposta.telefone.select();
		return false;
	}
	if (frmProposta.dddCel.value.length==0){
		alert('Preencha o campo DDD do Celular !!');
		frmProposta.dddCel.focus();
		frmProposta.dddCel.select();
		return false;
	}
	if (frmProposta.celular.value.length==0){
		alert('Preencha o campo Celular !!');
		frmProposta.celular.focus();
		frmProposta.celular.select();
		return false;
	}
	if (frmProposta.email.value.length==0){
		alert('Preencha o campo Email !!');
		frmProposta.email.focus();
		frmProposta.email.select();
		return false;
	}
}
function validaCampos(){
	frm = document.form1;
	
	if (frm.nome.value.length==0){
		alert('Preencha o campo Nome !!');
		frm.nome.focus();
		frm.nome.select();
		return false;
	}
	if (frm.email.value.length==0){
		alert('Preencha o campo E-Mail !!');
		frm.email.focus();
		frm.email.select();
		return false;
	}
	if (frm.ddd.value.length==0){
		alert('Preencha o campo DDD !!');
		frm.ddd.focus();
		frm.ddd.select();
		return false;
	}
	if (frm.telefone.value.length==0){
		alert('Preencha o campo Telefone !!');
		frm.telefone.focus();
		frm.telefone.select();
		return false;
	}
	if (frm.comentarios.value.length==0){
		alert('Preencha o campo Comentários !!');
		frm.comentarios.focus();
		frm.comentarios.select();
		return false;
	}
}

//ORÇAMENTO
function validaOrcamento(){
	frm = document.form1;
	if (frm.empresa.value.length==0){
		alert('Preencha o campo Empresa !!');
		frm.empresa.focus();
		frm.empresa.select();
		return false;
	}
	if (frm.nome.value.length==0){
		alert('Preencha o campo Nome !!');
		frm.nome.focus();
		frm.nome.select();
		return false;
	}
	if (frm.email.value.length==0){
		alert('Preencha o campo E-Mail !!');
		frm.email.focus();
		frm.email.select();
		return false;
	}
	if (frm.cidade.value.length==0){
		alert('Preencha o campo Cidade !!');
		frm.cidade.focus();
		frm.cidade.select();
		return false;
	}
	if (frm.estado.value==0){
		alert('Preencha o campo UF !!');
		frm.estado.focus();
		return false;
	}
	if (frm.ddd.value.length==0){
		alert('Preencha o campo DDD !!');
		frm.ddd.focus();
		frm.ddd.select();
		return false;
	}
	if (frm.telefone.value.length==0){
		alert('Preencha o campo Telefone !!');
		frm.telefone.focus();
		frm.telefone.select();
		return false;
	}
	if (frm.descricao.value.length==0){
		alert('Preencha o campo Descrição !!');
		frm.descricao.focus();
		frm.descricao.select();
		return false;
	}
}
//MENU
var anterior,subAnterior;

function menuShow(div){
	document.getElementById(div).style.display = ("none" == document.getElementById(div).style.display)  ? "block" : "none";
	
	if((anterior) && (anterior !=div)){
		document.getElementById(anterior).style.display = 'none';
	}
	 anterior = div;
}

//MENU SUB
function menuSubShow(div){
	document.getElementById(div).style.display = ("none" == document.getElementById(div).style.display)  ? "block" : "none";
	
	if((subAnterior) && (subAnterior !=div)){
		document.getElementById(subAnterior).style.display = 'none';
	}
	 subAnterior = div;
}