function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth - 18;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function footerPosition() {
	var pos = getPageSize();
	document.getElementById('container').style.height = (pos[1] - 60) + 'px';
	document.getElementById('main').style.height = (pos[1] - 93) + 'px';
	document.getElementById('footer').style.top = (pos[1] - 60) + 'px';

}

/* início do HACK PARA CORRIGIR O LI:HOVER NO IE6*/
over = function() 
{
	var sfEls = $("#menuProdutos ul li");
	for (var i=0; i<sfEls.length; i++)
	{
		sfEls[i].onmouseover=function() 
		{
			this.className+=" over";
		}
		sfEls[i].onmouseout=function() 
		{
			this.className=this.className.replace(new RegExp(" over\\b"), "");
		}
	}
}
	if (window.attachEvent) window.attachEvent("onload", over);		
/* final do HACK PARA CORRIGIR O LI:HOVER NO IE6*/


function validaContato()
{
	if($("#nome").val() == "")
	{
		$("#respostaForm").html("* Existe um campo obrigatório vazio ou inválido, localize o campo destacado e preencha corretamente.");
		$("#nome").css({ backgroundColor:"#EAF3D8" });
		$("#email").css({ backgroundColor:"#FFFFFF" });
		$("#assunto").css({ backgroundColor:"#FFFFFF" });
		$("#mensagem").css({ backgroundColor:"#FFFFFF" });
		
		$("#respostaForm").css({ color:"#AA2222", fontWeight:"lighter" });
		
		$("#nome").focus();
		return false;
	}
	
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('formContato').email.value))
	{
	}
	else
	{
		if($("#email").val() == "")
		{
			$("#respostaForm").html("* Existe um campo obrigatório vazio ou inválido, localize o campo destacado e preencha corretamente.");
			$("#email").css({ backgroundColor:"#EAF3D8" });
			
			$("#nome").css({ backgroundColor:"#FFFFFF" });
			$("#assunto").css({ backgroundColor:"#FFFFFF" });
			$("#mensagem").css({ backgroundColor:"#FFFFFF" });
			
			$("#respostaForm").css({ color:"#AA2222", fontWeight:"lighter" });
			
			$("#email").focus();
			return false;
		}
		else
		{
			$("#respostaForm").html("* Existe um campo obrigatório vazio ou inválido, localize o campo destacado e preencha corretamente");
			$("#email").css({ backgroundColor:"#EAF3D8" });
			
			$("#nome").css({ backgroundColor:"#FFFFFF" });
			$("#assunto").css({ backgroundColor:"#FFFFFF" });
			$("#mensagem").css({ backgroundColor:"#FFFFFF" });
			
			$("#respostaForm").css({ color:"#AA2222", fontWeight:"lighter" });
			
			$("#email").focus();
			return false;
		}
	}
	
	if($("#assunto").val() == "")
	{
		$("#respostaForm").html("* Existe um campo obrigatório vazio ou inválido, localize o campo destacado e preencha corretamente");
		$("#assunto").css({ backgroundColor:"#EAF3D8" });
		
		$("#nome").css({ backgroundColor:"#FFFFFF" });
		$("#email").css({ backgroundColor:"#FFFFFF" });
		$("#mensagem").css({ backgroundColor:"#FFFFFF" });
		
		$("#respostaForm").css({ color:"#AA2222", fontWeight:"lighter" });
	
		$("#assunto").focus();
		return false;
	}

	if($("#mensagem").val() == "")
	{
		$("#respostaForm").html("* Existe um campo obrigatório vazio ou inválido, localize o campo destacado e preencha corretamente");
		$("#mensagem").css({ backgroundColor:"#EAF3D8" });
		
		$("#nome").css({ backgroundColor:"#FFFFFF" });
		$("#email").css({ backgroundColor:"#FFFFFF" });
		$("#assunto").css({ backgroundColor:"#FFFFFF" });
		
		$("#respostaForm").css({ color:"#AA2222", fontWeight:"lighter" });
		
		$("#mensagem").focus();
		return false;
	}
}


function msgEnviada()
{
	$("#respostaForm").html("A mensagem foi enviada com sucesso.<br /> Retornaremos com a maior brevidade possível.");
	$("#respostaForm").css({ color:"#228B48" });
}

function msgNaoEnviada()
{
	$("#respostaForm").html("A mensagem não pode ser enviada.");
	$("#respostaForm").css({ color:"#AA2222", fontWeight:"lighter" });
}


/* ------------------------->>>>>>>>>>>>>> início funções da página de ORÇAMENTOS <<<<<<<<<<<<<<<<<<<<------------------------ */
function validaOrcamento()
{
	if($("#nome").val() == "")
	{
		$("#respostaForm").html("* Existe um campo obrigatório vazio ou inválido, localize o campo destacado e preencha corretamente.");
		$("#nome").css({ backgroundColor:"#EAF3D8" });
		
		$("#email").css({ backgroundColor:"#FFFFFF" });
		$("#telefone").css({ backgroundColor:"#FFFFFF" });
		
		$("#respostaForm").css({ color:"#AA2222", fontWeight:"lighter" });
		
		$("#nome").focus();
		return false;
	}
	
	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('formOrcamentos').email.value))
	{
	}
	else
	{
		if($("#email").val() == "")
		{
			$("#respostaForm").html("* Existe um campo obrigatório vazio ou inválido, localize o campo destacado e preencha corretamente.");
			$("#email").css({ backgroundColor:"#EAF3D8" });
			
			$("#nome").css({ backgroundColor:"#FFFFFF" });
			$("#telefone").css({ backgroundColor:"#FFFFFF" });
			
			$("#respostaForm").css({ color:"#AA2222", fontWeight:"lighter" });
			
			$("#email").focus();
			return false;
		}
		else
		{
			$("#respostaForm").html("* Existe um campo obrigatório vazio ou inválido, localize o campo destacado e preencha corretamente");
			$("#email").css({ backgroundColor:"#EAF3D8" });
			
			$("#nome").css({ backgroundColor:"#FFFFFF" });
			$("#telefone").css({ backgroundColor:"#FFFFFF" });
			
			$("#respostaForm").css({ color:"#AA2222", fontWeight:"lighter" });
			
			$("#email").focus();
			return false;
		}
	}
	
	if($("#telefone").val() == "")
	{
		$("#respostaForm").html("* Existe um campo obrigatório vazio ou inválido, localize o campo destacado e preencha corretamente");
		$("#telefone").css({ backgroundColor:"#EAF3D8" });
		
		$("#nome").css({ backgroundColor:"#FFFFFF" });
		$("#email").css({ backgroundColor:"#FFFFFF" });
		
		$("#respostaForm").css({ color:"#AA2222", fontWeight:"lighter" });
	
		$("#telefone").focus();
		return false;
	}
}

function orcamentoEnviado()
{
	$("#respostaForm").html("O pedido de orçamento foi enviado com sucesso.<br /> Em breve encaminharemos as informações solicitadas.");
	$("#respostaForm").css({ color:"#228B48" });
}

function orcamentoNaoEnviado()
{
	$("#respostaForm").html("O pedido de orçamento não pode ser enviado.");
	$("#respostaForm").css({ color:"#AA2222", fontWeight:"lighter" });
}

/* --------------------------------- FUNÇÃO PARA ADICIONAR PRODUTOS PARA A LISTA DE ORÇAMENTOS ---------------------------- */
function addProdListaOrcamento(divMensagem,idProduto)
{
	$("#"+divMensagem).load("load_orcamento.php?id_produto="+idProduto);
	// Item adicionado ao pedido de orçamento.

}
/* ------------------------->>>>>>>>>>>>>> final funções da página de ORÇAMENTOS <<<<<<<<<<<<<<<<<<<<------------------------ */

function loadListaProdutos(divAlvo,idProduto)
{
	if(!idProduto)
	{
		$("#"+divAlvo).load("load_produtos_orcamento.php");	
	}
	else
	{
		$("#"+divAlvo).load("load_produtos_orcamento.php?id_produto="+idProduto);
	}
}

/* Ações a serem executadas quando a página estiver carregada */
$(document).ready (
	function()
	{
		$("#limparContato").click
		(
			function()
			{
				$("#respostaForm").html("");
				$("#nome").css({ backgroundColor:"#FFFFFF" });
				$("#email").css({ backgroundColor:"#FFFFFF" });
				$("#assunto").css({ backgroundColor:"#FFFFFF" });
				$("#mensagem").css({ backgroundColor:"#FFFFFF" });
			}
		);
		
		$(".menuPai").click
		(
			function()
			{
				return false;
			}
		);
		
		$("#telefone").mask("(99) 9999-9999");
		
		var img1 = new Image();
		img1.src="img/btadd_prod_hover.png";
		var img2 = new Image();
		img2.src="img/x_fecharhover.gif";

	}
);