// JavaScript Document
var  $D = function(id) 
{
	return document.getElementById(id);
}

function abreMapa(id)
{
	$D(id).style.display = '';
}

function abreConteudo(id,id2,id3,id4,id5)
{
	$D(id).style.display = '';
	$D(id2).style.display = '';
	$D(id3).style.display = 'none';
	$D(id4).style.display = 'none';
	$D(id5).style.display = 'none';

}

function abreConteudoPisc(id,id2,id3,id4,id5)
{
	$D(id).style.display = '';
	$D(id2).style.display = '';
	$D(id3).style.display = 'none';
	$D(id4).style.display = 'none';
	$D(id5).style.display = 'none';
}

function mudaMapa(id)
{
	$D('letra').value = id;
}

function abreResultBanho()
{
	var a = $D('nPessoas').value;
	var b = $D('nBanheiras').value;
	var c = $D('qualAgua').value;
	var d = $D('presRedeHidra').value;
	var e =$D('tempInf0').value;
	var f =$D('letra').value;
	if( (a!='') && (b!='') && (c!='') && (d!='') && (e!='') && (f!='') )
	{		
		$D('resultConsulta').style.display = '';
		$D('btnOkBanho').style.display = 'none';
	}else
	{
		alert('Todos os campos acima devem ser preenchidos para um dimensionamento correto');
	}
}
function abreResultPiscina()
{
	var a = $D('areaPiscina').value;
	var b = $D('periodoUtilizacao').value;
	var c = $D('situacao').value;
	var d = $D('letra').value;
	if( (a!='') && (b!='') && (c!='') && (d!='') )
	{		
		$D('resultPiscina').style.display = '';
		$D('btnOkPiscina').style.display = 'none';
	}else
	{
		alert('Todos os campos acima devem ser preenchidos para um dimensionamento correto');
	}
}


function apareceOk()
{
	$D('resultConsulta').style.display = 'none';
	$D('btnOkBanho').style.display = '';
}
function apareceOkP()
{
	$D('resultPiscina').style.display = 'none';
	$D('btnOkPiscina').style.display = '';
}

function trocaDimen(idOn,idOff)
{
	$D(idOn).style.display = '';
	$D(idOff).style.display = 'none';
}

function alteraPagina()
{
	if($D('linkDoMenu').value!='off')
	{
		location = $D('linkDoMenu').value;
	}
}

function alteraCor(thiss,status)
{	
	if(status=='on')
	{
		thiss.style.cursor = 'pointer';
		thiss.style.backgroundColor = '#E3E3E3';
	}
	else
	{
		thiss.style.backgroundColor = '';
	}
}


function clickMenuOn(links)
{
		var posY = parseFloat(findPosY($D('btn01Menu')))+32;
		$D('divMarcador').style.top = posY+'px';
		var idPos='';
		//alert(posY);
		if(links=='home'){ idPos = 'btn01Menu'; Num=40;}
		if(links=='empresa'){ idPos = 'btn02Menu'; Num=40;}
		if(links=='produtos'){ idPos = 'btn03Menu'; Num=40;}
		if(links=='dimencionamento'){ idPos = 'btn04Menu'; Num=75;}
		if(links=='download'){ idPos = 'btn05Menu'; Num=40;}
		if(links=='portifolio'){ idPos = 'btn06Menu'; Num=40;}
		if(links=='financiamento'){ idPos = 'btn07Menu'; Num=60;}
		if(links=='orcamento'){ idPos = 'btn08Menu';	Num=43;}
		if(links=='duvidas'){ idPos = 'btn09Menu';	Num=40;}

		var posX =  parseFloat(findPosX($D(idPos)))+Num;
		//alert(posX+'Libra Lon');
		$D('divMarcador').style.left = posX+'px';
		$D('divMarcador').style.display = 'block';	}

function overMenu(id,nome,links)
{
	$D('divMaster').style.display = '';	
	var posX = findPosX($D(id));
	var posY = findPosY($D(id))-3;	
	var posWidth = $D(id).offsetWidth-10;
	$D('divFundoTexto').style.top = posY+'px';
	$D('divFundoTexto').style.left = posX+'px';
	$D('divFundoTexto').style.display = 'block';	
	$D('linkDoMenu').value = links;
	
	$D('tdTextoMenu').style.width = posWidth +'px';
	$D('tdTextoMenu').innerHTML = nome;
	
	$D('btn02MenuAbre').style.display = 'none';	
	$D('btn03MenuAbre').style.display = 'none';	
	$D('btn04MenuAbre').style.display = 'none';	
	$D('btn05MenuAbre').style.display = 'none';	
	$D('btn06MenuAbre').style.display = 'none';		
	
	if(id=='btn02Menu')
	{
		var posY = posY+55;	
		$D('btn02MenuAbre').style.top = posY+'px';
		$D('btn02MenuAbre').style.left = posX+'px';		
		$D('btn02MenuAbre').style.display = 'block';	
		$D('hiddenMouseOut').value='btn02MenuAbre';
	}
	else if(id=='btn03Menu')
	{
		var posY = posY+55;	
		$D('btn03MenuAbre').style.top = posY+'px';
		$D('btn03MenuAbre').style.left = posX+'px';	
		$D('btn03MenuAbre').style.display = 'block';	
		$D('hiddenMouseOut').value='btn03MenuAbre';
	}
	else if(id=='btn04Menu')
	{
		var posY = posY+55;	
		$D('btn04MenuAbre').style.top = posY+'px';
		$D('btn04MenuAbre').style.left = posX+'px';		
		$D('btn04MenuAbre').style.display = 'block';	
		$D('hiddenMouseOut').value='btn04MenuAbre';
	}
	else if(id=='btn05Menu')
	{
		var posY = posY+55;	
		$D('btn05MenuAbre').style.top = posY+'px';
		$D('btn05MenuAbre').style.left = posX+'px';		
		$D('btn05MenuAbre').style.display = 'block';	
		$D('hiddenMouseOut').value='btn05MenuAbre';
	}
	else if(id=='btn06Menu')
	{
		var posY = posY+55;	
		$D('btn06MenuAbre').style.top = posY+'px';
		$D('btn06MenuAbre').style.left = posX+'px';		
		$D('btn06MenuAbre').style.display = 'block';	
		$D('hiddenMouseOut').value='btn06MenuAbre';

	}
	//ABAIXO COLOCA OS VALOR NO HIDDEN ROOL OUT
	else if(id=='btn01Menu')
	{
		$D('hiddenMouseOut').value='';
	}
	
	else if(id=='btn07Menu')
	{
		$D('hiddenMouseOut').value='';
	}
	else if(id=='btn08Menu')
	{
		$D('hiddenMouseOut').value='';
	}
	else if(id=='btn09Menu')
	{
		$D('hiddenMouseOut').value='';
	}
	/////////////////////////////////////////////////
}

function mouseOut()
{
	
	$D('divFundoTexto').style.display = 'none';	
	if($D('hiddenMouseOut').value)
	{
		var divAbreBaixo = $D('hiddenMouseOut').value;
		$D(divAbreBaixo).style.display = 'none';	
	}
	$D('divMaster').style.display = 'none';	
	
	/*if(id=='btn02Menu')
	{
		var posY = posY+58;	
		$D('btn02MenuAbre').style.top = posY+'px';
		$D('btn02MenuAbre').style.left = posX+'px';		
		$D('btn02MenuAbre').style.display = 'block';	}
	else if(id=='btn03Menu')
	{
		var posY = posY+58;	
		$D('btn03MenuAbre').style.top = posY+'px';
		$D('btn03MenuAbre').style.left = posX+'px';	
		$D('btn03MenuAbre').style.display = 'block';	}
	else if(id=='btn04Menu')
	{
		var posY = posY+58;	
		$D('btn04MenuAbre').style.top = posY+'px';
		$D('btn04MenuAbre').style.left = posX+'px';		
		$D('btn04MenuAbre').style.display = 'block';	}
	else if(id=='btn05Menu')
	{
		var posY = posY+58;	
		$D('btn05MenuAbre').style.top = posY+'px';
		$D('btn05MenuAbre').style.left = posX+'px';		
		$D('btn05MenuAbre').style.display = 'block';	}*/

}


function findPosY(obj)
{
	//alert(obj);
	var curtop = 0;
	if (obj.offsetParent)
	{
    	while (obj.offsetParent)
    	{
      		curtop += obj.offsetTop
      		obj = obj.offsetParent;
    	}
  	}
	else if (obj.y)
	{
		curtop += obj.y;
	}
 	// alert(curtop);
	return curtop
}

function findPosX(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
    	while (obj.offsetParent)
    	{
      		curtop += obj.offsetLeft
      	obj = obj.offsetParent;
    	}
  	}
  else if (obj.x)
  {
    curtop += obj.x;
  }
  return curtop
}

if(navigator.appName!='Microsoft Internet Explorer')
{
	window.onclick = function()
	{
		/*$D('btn02MenuAbre').style.display = 'none';	
		$D('btn03MenuAbre').style.display = 'none';	
		$D('btn04MenuAbre').style.display = 'none';	
		$D('btn05MenuAbre').style.display = 'none';	
		$D('btn06MenuAbre').style.display = 'none';		
		$D('divFundoTexto').style.display = 'none';	*/
	}
}
else
{
	document.onclick = function()
	{
		$D('btn02MenuAbre').style.display = 'none';	
		$D('btn03MenuAbre').style.display = 'none';	
		$D('btn04MenuAbre').style.display = 'none';	
		$D('btn05MenuAbre').style.display = 'none';	
		$D('btn06MenuAbre').style.display = 'none';		
		$D('divFundoTexto').style.display = 'none';			
	}
}

//MUDA FORMULÁRIO PAGINA CONTATO-E

function mudaForm(valorSel)
{

	if(valorSel=='Orcamento')
	{
		location = '?pagina=orcamento-e';
	}	
	var valorHidden = $D('hiddenForm').value;

	if(valorSel!=valorHidden)
	{
		
		if($D('hiddenForm').value!='')
		{ 
			$D('div'+valorHidden).style.display = 'none'; 
		}
		$D('div'+valorSel).style.display = '';
		$D('hiddenForm').value = valorSel;	
	}
	else
	{
		$D('div'+valorSel).style.display = '';
		$D('hiddenForm').value = valorSel;
	}
}

//APAGA FORMS CONTATO-E
function apagaForm()
{
		document.revenda.reset();
		document.assistencia.reset();
		document.curso.reset();
		document.fornecedor.reset();
		document.curriculo.reset();
		document.sugestoes.reset();

}

//APAGA CAMPO
function apagaCampo(id,valor)
{
	if($D(id).title!=".")
	{
		$D(id).value="";
		$D(id).title=".";

	}
}

//PULA CNPJ
function cnpjPula(id,nextId) 
{
	var cnpj = $D(id).value;
	if(cnpj.length == 2)
	{
		$D(id).value = cnpj+".";
	}
	if(cnpj.length == 6 )
	{
		$D(id).value = cnpj+".";
	}
	if(cnpj.length == 10 )
	{
		$D(id).value = cnpj+"/";
	}
	if(cnpj.length == 15 )
	{
		$D(id).value = cnpj+"-";
	}
	if(cnpj.length == 18 )	
	{
		$D(nextId).focus();
	}
}

function cpfPula(id,nextId) 
{
	var cnpj = $D(id).value;
	if(cnpj.length == 3)
	{
		$D(id).value = cnpj+".";
	}
	if(cnpj.length == 7 )
	{
		$D(id).value = cnpj+".";
	}
	if(cnpj.length == 11 )
	{
		$D(id).value = cnpj+"-";
	}
	if(cnpj.length == 14 )
	{
		$D(nextId).focus();
	}
}

//pula CEP
function pulaCep(id,nextId)
{
	var cep = $D(id).value;
	if(cep.length==5)
	{
		$D(id).value = cep+'-';	
	}
	if(cep.length==9)
	{
		$D(nextId).focus();
	}
}
//pula TELEFONE
function pulaTel(id,nextId)
{
		var telefone = $D(id).value;
		if(telefone.length==2)
		{
		$D(id).value = telefone+' '
			}
		if(telefone.length==7)
		{
			$D(id).value = telefone+'-'
		}
		if(telefone.length==12)
		{
			$D(nextId).focus();	
		}

}
function pulaCampo(quant,id,proxId)
{
	var IDpula = $D(id).value;
	if(IDpula.length==quant)
	{
		$D(id).value = IDpula;
		$D(proxId).focus();
	}
}

function alteraCorOn(id)
{
	$D(id).style.backgroundColor = '#DC251C';	
	$D(id).style.color = '#ffffff';	
}

function alteraCorOff(id)
{
	$D(id).style.backgroundColor = '#FFFFFF';	
	$D(id).style.color = '#000000';	
}
	
function apareceCampo(id,sta)
{
	if(sta=='on')
	{
		$D(id).style.display = '';
	}else if(sta=='off')
	{
		$D(id).style.display = 'none';
	}
}


