image1 = new Image();
image1.src = "../img/menu/home_on.jpg";
image2 = new Image();
image2.src = "../img/menu/empresa_on.jpg";
image3 = new Image();
image3.src = "../img/menu/servicos_on.jpg";
image4 = new Image();
image4.src = "../img/menu/obras_on.jpg";
image5 = new Image();
image5.src = "../img/menu/novidades_on.jpg";
image6 = new Image();
image6.src = "../img/menu/contato_on.jpg";

function getWidth(){  
	return window.innerWidth ? window.innerWidth : /* For non-IE */  
		document.documentElement ? document.documentElement.clientWidth : /* IE 6+ (Standards Compilant Mode) */  
		document.body ? document.body.clientWidth : /* IE 4 Compatible */  
		window.screen.width; /* Others (It is not browser window size, but screen size) */  
} 

function showMenu(num){
	w = getWidth();
	
	if (num == '1'){
		offset = 261;
	}
	else {
		if (num == '2'){
			offset = 44;
		}
		else {
			if (num == '3'){
				offset = 117;
			}
		}
	}
	
	pos = (w / 2) + offset;
	pos = Math.floor(pos);
	
	document.getElementById('submenu_'+num).style.left = pos+'px';
	document.getElementById('submenu_'+num).style.display = 'block';
}

function hideMenu(num){
	document.getElementById('submenu_'+num).style.display = 'none';
}

function validaContato(frm){
	if (frm.nome.value.length < 1){
		alert("Preencha o campo 'Nome'.");
		frm.nome.focus();
		return (false);
	}
	if (frm.email.value.length < 1){
		alert("Preencha o campo 'E-mail'.");
		frm.email.focus();
		return (false);
	}
	if (frm.msg.value.length < 1){
		alert("Preencha o campo 'Mensagem'.");
		frm.msg.focus();
		return (false);
	}
	return (true);
}

function validaRastreamento(frm){
	if (frm.nome.value.length < 1){
		alert("Preencha o campo 'Nome'.");
		frm.nome.focus();
		return (false);
	}
	
	if (frm.email.value.length < 1){
		alert("Preencha o campo 'E-mail'.");
		frm.email.focus();
		return (false);
	}
	if (frm.codigo.value.length < 1){
		alert("Preencha o campo 'Código de Rastreamento'.");
		frm.codigo.focus();
		return (false);
	}
	return (true);
}

function validaNews(frm){
	if (frm.nome.value.length < 1){
		alert("Preencha o campo 'Nome'.");
		frm.nome.focus();
		return (false);
	}
	if (frm.email.value.length < 1){
		alert("Preencha o campo 'E-mail'.");
		frm.email.focus();
		return (false);
	}
	return (true);
}

function validaIndique(frm){
	if (frm.nome.value.length < 1){
		alert("Preencha o campo 'Seu Nome'.");
		frm.nome.focus();
		return (false);
	}
	if (frm.email.value.length < 1){
		alert("Preencha o campo 'Seu E-mail'.");
		frm.email.focus();
		return (false);
	}
	if (frm.nome_des.value.length < 1){
		alert("Preencha o campo 'Nome destino'.");
		frm.nome_des.focus();
		return (false);
	}
	if (frm.email_des.value.length < 1){
		alert("Preencha o campo 'E-mail destino'.");
		frm.email_des.focus();
		return (false);
	}
	return (true);
}

function change_menu(item,state){
	document.getElementById(item).src = '../img/menu/' + item + '_' + state + '.jpg';
}

function change_categoria(obj){
	valor = obj.options[obj.selectedIndex].value
	if (valor > 0){
		document.location = 'index.php?case1_cod='+valor;
	}
}

function unidades(obj){
	valor = obj.options[obj.selectedIndex].value
	if (valor > 0){
		document.location = '../unidades/index.php#unid'+valor;
	}
}

function change_categoria_prod(obj){
	valor = obj.options[obj.selectedIndex].value
	if (valor > 0){
		document.location = 'index.php?capr1_cod='+valor;
	}
}

function confirma(hp){
	if (confirm("Deseja realmente apagar este registro?")){
		document.location = hp;
	}
}

function atualizaCarrinho(){
	document.frmCarrinho.acao.value = "REFRESH";
	document.frmCarrinho.submit();
}

function limparCarrinho(){
	document.frmCarrinho.acao.value = "LIMPAR";
	document.frmCarrinho.submit();
}

function finalizarPedido(){
	document.frmCarrinho.acao.value = "REFRESH";
	document.frmCarrinho.go.value = "1";
	document.frmCarrinho.submit();
}
