/* atalho $ para elemntsById */
function $()
{
	if(arguments[1] != undefined)
	{
		return document.getElementById(arguments[0]).getElementsByTagName(arguments[1]);
	}
	else
	{
		return document.getElementById(arguments[0]);
	}
}
/* // */

/* incluindo div para IE */
(function() {
 var
 ua=navigator.userAgent.toLowerCase(),
 is=function(t){ return ua.indexOf(t) != -1; },
 h=document.getElementsByTagName('html')[0],
 b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
 os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
 var c=b+os+' js';
 h.className += h.className?' '+c:c;
})();    
/* // */


if(typeof(activePage) == 'undefined')
{
	activePage = 0;
}


/* funções do menu e submenu */
function menuAtivo(lang){
	//alert('m '+lang);
	var nomeimgmenu = 'menu' + activePage;
	var imgmenu = $(nomeimgmenu);
	imgmenu.src = ("imgs/menu/menu_"+ lang + activePage + "-on.gif");
	for (i=1; i<=8; i++){
		var nomesubmenu = 'submenu' + i;
		var submenu = $(nomesubmenu);
		if (i == activePage){
			submenu.style.display = "block";
		} else {
			submenu.style.display = "none";
		}
	}
}

startList = function(lang) {
//idm=lang;
//alert('s '+idm);
	navRoot = $("menuprincipal");
	for (i=0; i<navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
		if (node.nodeName=="LI") {
			node.onmouseover=function() {
				//alert('over '+idm);
				this.className+=" over";
				var nomeimgmenu = 'menu' + activePage;
				var imgmenu = $(nomeimgmenu);
				imgmenu.src = ("imgs/menu/menu_"+ lang + activePage + ".gif");
				var nomesubmenu = 'submenu' + activePage;
				var submenu = $(nomesubmenu);
				submenu.style.display = "none";
				var pegaNum = this.className;
				var pegaId = pegaNum.substr(7,1);
				var nomeimgmenu = 'menu' + pegaId;
				var imgmenu = $(nomeimgmenu);
				imgmenu.src = ("imgs/menu/menu_"+ lang + pegaId + "-on.gif");
				var nomesubmenu = 'submenu' + pegaId;
				var submenu = $(nomesubmenu);
				submenu.style.display = "block";
			}
			node.onmouseout=function() {
				//alert('out '+idm);
				this.className=this.className.replace(" over", "");
				var pegaNum = this.className;
				var pegaId = pegaNum.substr(7,1);
				var nomeimgmenu = 'menu' + pegaId;
				var imgmenu = $(nomeimgmenu);
				imgmenu.src = ("imgs/menu/menu_"+ lang + pegaId + ".gif");
				var nomesubmenu = 'submenu' + pegaId;
				var submenu = $(nomesubmenu);
				submenu.style.display = "none";
				var nomeimgmenu = 'menu' + activePage;
				var imgmenu = $(nomeimgmenu);
				imgmenu.src = ("imgs/menu/menu_"+ lang + activePage + "-on.gif");
				var nomesubmenu = 'submenu' + activePage;
				var submenu = $(nomesubmenu);
				submenu.style.display = "block";
			}
		}
	}
}
window.onload=startList(lang);
/* // */

/*conferindo compos obrigatórios*/
function validaCampos() {
	var posNome = $('nome');
	var posEmpresa = $('empresa');
	var posEmail = $('email');
	var posFone = $('fone');
	var posOrcamento = $('orcamento');
	
	if (posNome.value == '') {
		showErros ();
		$('nome').style.background = '#F7FFB9';
	} else {
		$('nome').style.background = '#E6E7E8';
	}
	
	if (posEmpresa.value == '') {
		showErros ();
		$('empresa').style.background = '#F7FFB9';
	} else {
		$('empresa').style.background = '#E6E7E8';
	}
	
	if (posEmail.value == '') {
		showErros ();
		$('email').style.background = '#F7FFB9';
	} else {
		$('email').style.background = '#E6E7E8';
	}
	if (posFone.value == '') {
		showErros ();
		$('fone').style.background = '#F7FFB9';
	} else {
		$('fone').style.background = '#E6E7E8';
	}

	if(posOrcamento.selectedIndex == 0)
	{		
		showErros ();
		$('orcamento').style.background = '#F7FFB9';
		//alert("Debe seleccionar un motivo de su contacto.") 
	} else {
		$('orcamento').style.background = '#E6E7E8';
	}


	
	if (posNome.value != '' && posEmpresa.value != '' &&  posEmail.value != '' && posFone.value != '' && posOrcamento.selectedIndex != 0) {
		validaEmail();
	}

	/*
	if (document.fvalida.interes.selectedIndex==0){ 
       alert("Debe seleccionar un motivo de su contacto.") 
       document.fvalida.interes.focus() 
       return 0; 
    } 
	*/
}

/*validando e-mail*/
function validaEmail(){
	var txt = document.getElementById('email').value;
	if ((txt.length != 0) && ((txt.indexOf("@") < 1))){
		document.getElementById('email').style.background = '#F7FFB9';
		document.getElementById('erroEmail').style.display = 'block';
		sentTimer = setTimeout("hideErros()",6000);
	} else {
		//alert("Mail válido");
		$('form1').submit();
	}
}

function showErros () {
	document.getElementById('mostraErros').style.display = 'block';
	sentTimer = setTimeout("hideErros()",6000);
}

function hideErros () {
	document.getElementById('mostraErros').style.display = 'none';
	document.getElementById('erroEmail').style.display = 'none';
}
/* // */

/*/ imprimir tabela de preços /*/
function printpage(){
  window.print();
}

/* // */
