////////////////////////////////////////////////////////
// Menu Categorias
////////////////////////////////////////////////////////

var timeBeforeAutoHide = 1000;	// Microseconds to wait before auto hiding menu(1000 = 1 second)
	var slideSpeed_out = 20;	// Steps to move sub menu at a time ( higher = faster)
	var slideSpeed_in = 10;
		
	
	var slideTimeout_out = 25;	// Microseconds between slide steps ( lower = faster)
	var slideTimeout_in = 10;	// Microseconds between slide steps ( lower = faster)
	
	var showSubOnMouseOver = true;	// false = show sub menu on click, true = show sub menu on mouse over
	var fixedSubMenuWidth = false;	// Width of sub menu items - A number(width in pixels) or false when width should be dynamic
	
	var xOffsetSubMenu = 5; 	// Offset x-position of sub menu items - use negative value if you want the sub menu to overlap main menu
	
	var slideDirection = "right";	// Slide to left or right ?
	
	/* Don't change anything below here */
	
	var activeSubMenuId = false;
	var activeMainMenuItem = false;
	var currentZIndex = 1000;		
	var autoHideTimer = 0;
	var submenuObjArray = new Array();
	var okToSlideInSub = new Array();
	var subPositioned = new Array();
	

	function stopAutoHide()
	{
		autoHideTimer = -1;
	}
	
	function initAutoHide()
	{
		autoHideTimer = 0;
		if(autoHideTimer>=0)autoHide();
	}
	
	function autoHide()
	{
		
		if(autoHideTimer>timeBeforeAutoHide)
		{
			
			if(activeMainMenuItem){
				activeMainMenuItem.className="";
				activeMainMenuItem = false;
			}
			
			if(activeSubMenuId){
				var obj = document.getElementById("subMenuDiv" + activeSubMenuId);
				showSub();
			}
		}else{
			if(autoHideTimer>=0){
				autoHideTimer+=50;
				setTimeout('autoHide()',50);
			}
		}
	}	
	
	function getTopPos(inputObj)
	{		
	  var returnValue = inputObj.offsetTop;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
	  return returnValue;
	}
	
	function getLeftPos(inputObj)
	{
	  var returnValue = inputObj.offsetLeft;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
	  return returnValue;
	}
	
	function showSub()
	{
		var subObj = false;
		if(this && this.tagName){
			var numericId = this.parentNode.id.replace(/[^0-9]/g,'');
			okToSlideInSub[numericId] = false;
			var subObj = document.getElementById("subMenuDiv" + numericId);
			if(activeMainMenuItem)activeMainMenuItem.className='';
			if(subObj){
				if(!subPositioned[numericId]){
					if(slideDirection=="right"){
						subObj.style.left = getLeftPos(submenuObjArray[numericId]['parentDiv']) + submenuObjArray[numericId]['parentDiv'].offsetWidth + xOffsetSubMenu + 'px';
					}else{
						subObj.style.left = getLeftPos(submenuObjArray[numericId]['parentDiv']) + xOffsetSubMenu + 'px';
						
					}
					submenuObjArray[numericId]['left'] = subObj.style.left.replace(/[^0-9]/g,'');
					subObj.style.top = getTopPos(submenuObjArray[numericId]['parentDiv']) + 'px';
					subPositioned[numericId] = true;
				}				
				subObj.style.visibility = "visible";
				subObj.style.zIndex = currentZIndex;
				currentZIndex++;	
				this.className="activeMainMenuItem";
				activeMainMenuItem = this;
			}
		}else{
			var numericId = activeSubMenuId;
		}
		if(activeSubMenuId && (numericId!=activeSubMenuId || !subObj))slideMenu(activeSubMenuId,(slideSpeed_in*-1));
		if(numericId!=activeSubMenuId && this && subObj){
			subObj.style.width = "0px";	
			slideMenu(numericId,slideSpeed_out);
			activeSubMenuId = numericId;
		}else{
			if(numericId!=activeSubMenuId)activeSubMenuId = false;
		}
		if(showSubOnMouseOver)stopAutoHide();
	}
	
	function slideMenu(menuIndex,speed){
		var obj = submenuObjArray[menuIndex]['divObj'];
		var obj2 = submenuObjArray[menuIndex]['ulObj'];
		var width = obj.offsetWidth + speed;
		if(speed<0){
			if(width<0)width = 0;
			obj.style.width = width + 'px';
			if(slideDirection=='left'){
				obj.style.left = submenuObjArray[menuIndex]['left'] - width + 'px';
				obj2.style.left = '0px';
			}else{
				obj2.style.left = width - submenuObjArray[menuIndex]['width'] + 'px' 
			}
			if(width>0 && okToSlideInSub[menuIndex])setTimeout('slideMenu(' + menuIndex + ',' + speed + ')',slideTimeout_in); else{
				obj.style.visibility = "hidden";
				obj.style.width = "0px";
				if(activeSubMenuId==menuIndex)activeSubMenuId=false;
			}
			
		}else{
			if(width>submenuObjArray[menuIndex]['width'])width = submenuObjArray[menuIndex]['width'];
			if(slideDirection=="left"){
				obj.style.left = submenuObjArray[menuIndex]['left'] - width + 'px';
				obj2.style.left = '0px';
			}else{
				obj2.style.left = width - submenuObjArray[menuIndex]['width'] + 'px' 
			}		
			
			obj.style.width = width + 'px';
			if(width<submenuObjArray[menuIndex]['width']){
				setTimeout('slideMenu(' + menuIndex + ',' + speed + ')',slideTimeout_out);
			}else{
				okToSlideInSub[menuIndex] = true;
			}
		}
	}
	function resetPosition()
	{
		subPositioned.length = 0;
	}
			
	function initLeftMenu()
	{
		var isMSIE = navigator.userAgent.indexOf("MSIE")>=0 ? true:false;
		var browserVersion = parseInt(navigator.userAgent.replace(/.*?MSIE ([0-9]+?)[^0-9].*/g,'$1'));
		if(!browserVersion)browserVersion=1;
		
		var menuObj = document.getElementById("dhtmlgoodies_menu");	
		var mainMenuItemArray = new Array();
		
		var mainMenuItem = menuObj.getElementsByTagName("li")[0];
		while(mainMenuItem){
			if(mainMenuItem.tagName && mainMenuItem.tagName.toLowerCase()=="li"){
				mainMenuItemArray[mainMenuItemArray.length] = mainMenuItem;
				var aTag = mainMenuItem.getElementsByTagName("A")[0];
				if(showSubOnMouseOver)
					aTag.onmouseover = showSub;	
				else
					aTag.onclick = showSub;	
			}
			mainMenuItem = mainMenuItem.nextSibling;
		}		
		
		var lis = menuObj.getElementsByTagName("a");
		for(var no=0;no<lis.length;no++){
			if(!showSubOnMouseOver)lis[no].onmouseover = stopAutoHide;
			lis[no].onmouseout = initAutoHide;
			lis[no].onmousemove = stopAutoHide;
		}
				
		for(var no=0;no<mainMenuItemArray.length;no++){
			var sub = mainMenuItemArray[no].getElementsByTagName("ul")[0];
			if(sub){
				mainMenuItemArray[no].id = "mainMenuItem" + (no+1);
				var div = document.createElement("div");
				div.className="dhtmlgoodies_subMenu";
				document.body.appendChild(div);
				div.appendChild(sub);
				if(slideDirection=="right"){
					div.style.left = getLeftPos(mainMenuItemArray[no]) + mainMenuItemArray[no].offsetWidth + xOffsetSubMenu + 'px';
				}else{
					div.style.left = getLeftPos(mainMenuItemArray[no]) + xOffsetSubMenu + 'px';
				}
				div.style.top = getTopPos(mainMenuItemArray[no]) + 'px';
				div.id = 'subMenuDiv' + (no+1);
				sub.id = 'submenuUl' + (no+1);
				sub.style.position = "relative";	

				if(navigator.userAgent.indexOf("Opera")>=0){
					submenuObjArray[no+1] = new Array();
					submenuObjArray[no+1]['parentDiv'] = mainMenuItemArray[no];
					submenuObjArray[no+1]['divObj'] = div;
					submenuObjArray[no+1]['ulObj'] = sub;
					submenuObjArray[no+1]['width'] = sub.offsetWidth;
					submenuObjArray[no+1]['left'] = div.style.left.replace(/[^0-9]/g,'');
				}
				sub.style.left = 1 - sub.offsetWidth + 'px';	
				
				
				
				if(browserVersion<7 && isMSIE)div.style.width = "1px";	
					
				if(navigator.userAgent.indexOf("Opera")<0){
					submenuObjArray[no+1] = new Array();
					submenuObjArray[no+1]['parentDiv'] = mainMenuItemArray[no];
					submenuObjArray[no+1]['divObj'] = div;
					submenuObjArray[no+1]['ulObj'] = sub;
					submenuObjArray[no+1]['width'] = sub.offsetWidth;
					
					
					
					submenuObjArray[no+1]['left'] = div.style.left.replace(/[^0-9]/g,'');
					if(fixedSubMenuWidth)submenuObjArray[no+1]['width'] = fixedSubMenuWidth;
				}	

				if(!document.all)div.style.width = "1px";			
					
			}			
		}
			
		menuObj.style.visibility = "visible";
		
		window.onresize = resetPosition;
	}
	window.onload = initLeftMenu;
	
////////////////////////////////////////////////////////
// Menu Categorias
////////////////////////////////////////////////////////


////////////////////////////////////////////////////////
// Valida Fale conosco
////////////////////////////////////////////////////////

function valida_faleconosco(){
	
	if(document.fale_conosco.nome.value =='')
	{
		alert('Preencha o campo com seu nome');
    	document.fale_conosco.nome.focus();
    	return false;
	}
	
	if(document.fale_conosco.nome.value.length < 3)
	{
		alert('Seu nome é inválido');
    	document.fale_conosco.nome.focus();
    	return false;
	}
	
	if (document.fale_conosco.email.value=='')
	{
    	alert('Preencha com seu e-mail');
    	document.fale_conosco.email.focus();
    	return false;
    }
	
	if ((document.fale_conosco.email.value.length < 7) || (document.fale_conosco.email.value.indexOf('@', 0) == -1))
	{
    	alert('Seu e-mail está incorreto');
    	document.fale_conosco.email.focus();
    	return false;
    }

	
    if (document.fale_conosco.email.value.indexOf('.', 0) == -1)
    {
    	alert('Seu e-mail está incorreto');
    	document.fale_conosco.email.focus();
    	return false;
    }
	
	if ((document.fale_conosco.ddd.value == '') || (document.fale_conosco.ddd.value.length < 2))
    {
    	alert('Coloque o DDD de sua cidade');
    	document.fale_conosco.ddd.focus();
    	return false;
    }
	
	if ((document.fale_conosco.fone.value == '') || (document.fale_conosco.fone.value.length < 8))
    {
    	alert('Preencha com seu telefone');
    	document.fale_conosco.fone.focus();
    	return false;
    }
	
	if (document.fale_conosco.assunto.value == '')
    {
    	alert('Preencha o assunto da mensagem');
    	document.fale_conosco.assunto.focus();
    	return false;
    }
	
	 if (document.fale_conosco.mensagem.value==''){
    alert('Preencha com sua mensagem');
    document.fale_conosco.mensagem.focus();
    return false;
  }
	
	return true;
}

////////////////////////////////////////////////////////
// Valida busca
////////////////////////////////////////////////////////
function checa_busca(){
	
	if(document.busca.criterio.value ==''){
	alert('Sua busca n&atilde;o pode ser VAZIA');
    document.busca.criterio.focus();
    return false;
	}
	
	if(document.busca.criterio.value =='Digite o que você procura...'){
	alert('Sua busca n&atilde;o pode ser VAZIA');
    document.busca.criterio.focus();
    return false;
	}
	
	
	if(document.busca.criterio.value.length < 3){
	alert('Sua busca deve ter no mínimo 3 caracteres');
    document.busca.criterio.focus();
    return false;
	}
	
	return true;
}

function apaga_criterio(){
document.busca.criterio.value ='';
document.busca.criterio.focus();
}


////////////////////////////////////////////////////////
// Pop Up
////////////////////////////////////////////////////////
function Popup(url,largura,altura,res,scr){
	window.open(url,'window','width='+largura+', height='+altura+', resizable='+res+', scrollbars='+scr+', location=no, toolbar=no, menubar=no, status=no');
}


////////////////////////////////////////////////////////
// Imprimir
////////////////////////////////////////////////////////

function imprimir(){
  if (!window.print){
    alert("Use o Netscape ou Internet Explorer nas versões 4.0 ou superior!")
    return false;
  }
  window.print();
}


function impswf(arqflash,largura,altura) {
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
document.write('<param name="movie" value="' + arqflash + '" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="menu" value="false" />');
document.write('<param name="wmode" value="transparent" />');
document.write('<embed src="' + arqflash + '" width="' + largura + '" height="' + altura + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" wmode="transparent"></embed>');
document.write('</object>');
}



////////////////////////////////////////////////////////
// Valida indicação do site
////////////////////////////////////////////////////////

function apg_nome_ind()
{
	document.ind_site.ind_nome.value = '';
}
function apg_nomea_ind()
{
	document.ind_site.ind_nomea.value = '';
}
function apg_email_ind()
{
	document.ind_site.ind_email.value = '';
}
function valida_ind_site(){
	
	if(document.ind_site.ind_nome.value =='' || document.ind_site.ind_nome.value =='seu nome')
	{
		alert('Preencha o campo com seu nome');
    	document.ind_site.ind_nome.focus();
    	return false;
	}
	
	if(document.ind_site.ind_nome.value.length < 3)
	{
		alert('Seu nome é inválido');
    	document.ind_site.ind_nome.focus();
    	return false;
	}
	
	if(document.ind_site.ind_nomea.value =='' || document.ind_site.ind_nomea.value =='nome do amigo')
	{
		alert('Preencha o campo com o nome do seu amigo(a)');
    	document.ind_site.ind_nomea.focus();
    	return false;
	}
	
	if(document.ind_site.ind_nomea.value.length < 3)
	{
		alert('O nome do seu amigo(a) é inválido');
    	document.ind_site.ind_nomea.focus();
    	return false;
	}
	
	if (document.ind_site.ind_email.value=='')
	{
    	alert('Preencha com o email do seu amigo(a)');
    	document.ind_site.ind_email.focus();
    	return false;
    }
	
	if ((document.ind_site.ind_email.value.length < 7) || (document.ind_site.ind_email.value.indexOf('@', 0) == -1))
	{
    	alert('O email está incorreto');
    	document.ind_site.ind_email.focus();
    	return false;
    }

	
    if (document.ind_site.ind_email.value.indexOf('.', 0) == -1)
    {
    	alert('O email está incorreto');
    	document.ind_site.ind_email.focus();
    	return false;
    }
	
	return true;
}





////////////////////////////////////////////////////////
// Valida formulário de hospedagem
////////////////////////////////////////////////////////

function valida_host()
{
	 
	if (document.form_host.plano.value=='0')
	{
    	alert('Escolha o PLANO DE HOSPEDAGEM');
    	document.form_host.plano.focus();
    	return false;
	}
	
	if (document.form_host.nome.value=='' || document.form_host.nome.value.length < 5)
	{
    	alert('Coloque seu NOME COMPLETO ou RAZÃO SOCIAL');
    	document.form_host.nome.focus();
    	return false;
	}
	
	if (document.form_host.cpf.value=='' || document.form_host.cpf.value.length < 5)
	{
    	alert('Coloque seu CPF ou CNPJ');
    	document.form_host.cpf.focus();
    	return false;
	}
	
	if (document.form_host.resp.value=='' || document.form_host.resp.value.length < 5)
	{
    	alert('Coloque o NOME COMPLETO do RESPONSÁVEL');
    	document.form_host.resp.focus();
    	return false;
	}
	
	
	if (document.form_host.rg.value=='' || document.form_host.rg.value.length < 5)
	{
    	alert('Coloque o RG do RESPONSÁVEL');
    	document.form_host.rg.focus();
    	return false;
	}
	
	if (document.form_host.endereco.value=='' || document.form_host.endereco.value.length < 5)
	{
    	alert('Coloque o ENDEREÇO COMPLETO');
    	document.form_host.endereco.focus();
    	return false;
	}
	
	if (document.form_host.n.value=='')
	{
    	alert('Coloque o NÚMERO da residência');
    	document.form_host.n.focus();
    	return false;
	}
	
	if (document.form_host.bairro.value=='')
	{
    	alert('Coloque o BAIRRO');
    	document.form_host.bairro.focus();
    	return false;
	}
	
	if (document.form_host.cid.value=='')
	{
    	alert('Coloque a CIDADE');
    	document.form_host.cid.focus();
    	return false;
	}
	
	if (document.form_host.estado.value=='0')
	{
    	alert('Escolha o ESTADO');
    	document.form_host.estado.focus();
    	return false;
	}
	
	if (document.form_host.cep.value=='' || document.form_host.cep.value.length < 8)
	{
    	alert('Coloque o CEP');
    	document.form_host.cep.focus();
    	return false;
	}
	
	if (document.form_host.ddd.value=='' || document.form_host.ddd.value.length < 2)
	{
    	alert('Coloque o DDD');
    	document.form_host.ddd.focus();
    	return false;
	}
	
	if (document.form_host.fone.value=='' || document.form_host.fone.value.length < 8)
	{
    	alert('Coloque o TELEFONE');
    	document.form_host.fone.focus();
    	return false;
	}
	
	if (document.form_host.email_a.value=='')
	{
    	alert('Coloque seu E-MAIL');
    	document.form_host.email_a.focus();
    	return false;
    }
	
	if ((document.form_host.email_a.value.length < 7) || (document.form_host.email_a.value.indexOf('@', 0) == -1) || (document.form_host.email_a.value.indexOf('.', 0) == -1))
	{
    	alert('O E-MAIL está incorreto');
    	document.form_host.email_a.focus();
    	return false;
    }
	
	if (document.form_host.op.value=='0')
	{
    	alert('Escolha a OPÇÃO SOBRE O DOMÍNIO');
    	document.form_host.op.focus();
    	return false;
	}
	
	if (document.form_host.dom.value=='')
	{
    	alert('Coloque seu DOMÍNIO');
    	document.form_host.dom.focus();
    	return false;
    }
	
	if (document.form_host.ext.value=='0')
	{
    	alert('Escolha a EXTENSÃO para SEU DOMÍNIO');
    	document.form_host.ext.focus();
    	return false;
	}
	
	if (!document.form_host.contrato.checked)
	{
    	alert('Marque a opção \"Aceito todos os termos do contrato de hospedagem\"');
    	document.form_host.contrato.focus();
    	return false;
    }
	 
	return true;
}
