 function findPosX(obj)
	{
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}

	function findPosY(obj)
	{
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}


	function position(obj, reference) {

		var newX = findPosX(reference);
		var newY = findPosY(reference);
		obj.style.left = newX;
		obj.style.top = newY - obj.style.height.substring(0, obj.style.height.indexOf("px"));

	}

	function abrirMenu(reference) {
		var menuDiv = document.getElementById("menu");

		if (menuDiv.style.visibility == "hidden") {
			position(menuDiv, reference);
			menuDiv.style.visibility = "visible";
		} else {
			menuDiv.style.visibility = "hidden";
		}

	}

	function validaBusca(){

	if(document.busca.buscaText.value == ""){
		alert("Por Favor preencha o campo busca.");
		//********************************************************
		document.busca.buscaText.focus();
		//********************************************************		
		return false;
	}
	return true;

	}
	
	function selogarlat(){

	//********************************************************
	document.logar_lat.senha.value=document.frm1.senha.value;
	//********************************************************	

	if(document.logar_lat.login.value == ""){
		alert("Por Favor preencha o campo Login com seu Email ou Login.");
		//********************************************************
		document.logar_lat.login.focus();
		//********************************************************		
		return false;
	}
	document.logar_lat.submit();
	return false;

	}
	
	
	function OpenPreviewPopup(arq, width, height, scroll){   
		var URL = arq 
		var W = width 
		var H = height 
		var S = scroll 

		 var Wpopupsize =(W/2); 
		 var Hpopupsize =(H/2); 
		 var CenterPopUpX = (screen.width/2)-(Wpopupsize); 
		 var CenterPopUpY = (screen.height/2)-(Hpopupsize); 
		 var pos = "left="+CenterPopUpX+",top="+CenterPopUpY; 
		 var desktop = window.open( ""+URL, "", "width="+W+",height="+H+",toolbar=no,location=no,status=no,menubar=no,scrollbars="+S+",resizable=no,"+pos); 
	}

	function OpenBEB(){   
		window.location.href="/Web/Br/ForYou/BEB/src/index.asp"
		/*
		var URL = '/Web/Br/ForYou/BEB/src/index.asp' 
		var W = 770 
		var H = 480 
		var S = 'no' 

		var Wpopupsize =(W/2); 
		var Hpopupsize =(H/2); 
		var CenterPopUpX = (screen.width/2)-(Wpopupsize); 
		var CenterPopUpY = (screen.height/2)-(Hpopupsize); 
		var pos = "left="+CenterPopUpX+",top="+CenterPopUpY; 
		var desktop = window.open( ""+URL, "BEB", "width="+W+",height="+H+",toolbar=no,location=no,status=no,menubar=no,scrollbars="+S+",resizable=no,"+pos); 
	}

	function OpenConcurso(){   
		var URL = '/Web/Br/ForYou/HotSites/ConcursoCultural/src/ConcursoIndex.asp' 
		var W = 640 
		var H = 430 
		var S = 'no' 

		OpenPreviewPopup(URL, W, H, S);
		*/
	}
	
function montaFlash(movie, width, height, wmode, FlashVars){  
	var swf  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
    + 'width="'+ width +'" height="'+ height +'"'
    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
    + '<param name="movie" value="'+ movie +'" /><param name="quality" value="high" /><param name="devicefont" value="true" /><param name="wmode" value="'+ wmode +'" /><param name="FlashVars" value="'+ FlashVars +'" />'
    + '<embed src="'+ movie +'" quality="high" devicefont="true" '
    + 'width="'+ width +'" height="'+ height +'" align="middle"'
    + 'play="true"'
    + 'loop="false"'
    + 'quality="high"'
    + 'wmode="'+ wmode +'"'
    + 'allowScriptAccess="sameDomain"'
    + 'type="application/x-shockwave-flash"'
    + 'FlashVars="'+ FlashVars +'"'
    + 'pluginspage="http://www.macromedia.com/go/getflashplayer"'
    + '><\/embed>'
    + '<\/object>';
	document.write(swf);
}

// Funções referentes ao campo busca
function campoBusca() {
	var valor = document.formSearch.UserRestriction.value;
	if (valor == "") {
		document.formSearch.UserRestriction.value = "palavra-chave"
	} else if (valor == "palavra-chave") {
		document.formSearch.UserRestriction.value = ""
	}
}

function verifica() {
	var chave = document.formSearch.UserRestriction.value;
	var conteudo = document.formSearch.busca[0].checked;
	var produtos = document.formSearch.busca[1].checked;
	if ((chave != "" && conteudo) || (chave != "" && produtos)) {
		if (conteudo) {
			document.formSearch.action = "http://www.conteudo.natura.net/?s="+chave
		} else {
			document.formSearch.action = "http://www2.natura.net/Web/Br/Search/src/SearchResult.asp?UserRestriction="+chave+"&CiMaxRecordsPerPage=10&CiScope=%2Fport%2F&CiSort=rank%5Bd%5D&CiTemplate=%2Fport%2Fbusca%2Fret_busca_news.htx&HTMLQueryForm=busca.asp&image1.x=0&image1.y=0"
		}
		form.submit();
	} else {
		alert("Esqueceu de especificar a Palavra-Chave.");
	}
}

function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	} 
}

function checkArea(div) {
	var elm = document.getElementById(div);
	var id_flash = getQueryVariable("id_flash");
	if ((id_flash == 34) || (id_flash == '34')) {
		if ((elm.style.display == 'block') || (elm.style.display == '')) {
			elm.style.display	= 'none';
		} else {
			elm.style.display	= '';
		}
	}
}	