var Nono = null;
var PegaFlashNS;
function GetTotalFlash(Total,Menu){

	if(navigator.appName.indexOf("Microsoft") != -1){
		Movie=window.document.FlashTopo;
	}
	else{
		Movie=document.embeds[0];
	}
	

	if (Movie.PercentLoaded() == 100){


		
		if (Menu==1){
	//		Movie.SetVariable("/:titulo","a_mundial");
			setTimeout('Movie.TGotoFrame("/titulos",2)',1000);
		}
		if (Menu==2){
	//		Movie.SetVariable("/:titulo","responsabilidade_social");
			setTimeout('Movie.TGotoFrame("/titulos",5)',1000);
		}
		if (Menu==3){
	//		Movie.SetVariable("/:titulo","relacao_com_investidores");
			setTimeout('Movie.TGotoFrame("/titulos",8)',1000);
		}
		if (Menu==4){
	//		Movie.SetVariable("/:titulo","relacao_com_colaboradores");
			setTimeout('Movie.TGotoFrame("/titulos",11)',1000);
		}
		if (Menu==5){
	//		Movie.SetVariable("/:titulo","oportunidades");
			setTimeout('Movie.TGotoFrame("/titulos",14)',1000);
		}
		if (Menu==6){
	//		Movie.SetVariable("/:titulo","destaques_mundial");
			setTimeout('Movie.TGotoFrame("/titulos",17)',1000);
		}
		if (Menu==7){
	//		Movie.SetVariable("/:titulo","downloads");
			setTimeout('Movie.TGotoFrame("/titulos",21)',1000);
		}
		if (Menu==8){
			setTimeout('Movie.TGotoFrame("/titulos",24)',1000);
	//		Movie.SetVariable("/:titulo","sala_de_imprensa");
		}
		if (Menu==9){
			setTimeout('Movie.TGotoFrame("/titulos",27)',1000);
	//		Movie.SetVariable("/:titulo","fale_conosco");
		}

		clearInterval(Nono);
		
	}
}

function GetNSFlashPercent(Menu){
	if (document.embeds[0].PercentLoaded()==100){
		Nono = setInterval("GetTotalFlash(100,"+Menu+")",1000);
	}
}

function SetaTituloFlash(Menu)
{
		if(navigator.appName.indexOf("Microsoft") != -1){
			Movie=window.document.FlashTopo;
			Nono = setInterval("GetTotalFlash("+Movie.PercentLoaded()+","+Menu+")",1000);
		}
		else{
			Movie=document.embeds[0];
			var NSIntervalo = setInterval("GetNSFlashPercent("+Menu+")",1000)
		}
//		alert(Movie);
	

}

function EscondeLayerProcurarProduto(Status)
{
	var Layer =	document.getElementById('LayerProdutos');
	Layer.style.visibility = Status;
}

function LoadLayer()
{
		LayerOver = false;
		if(navigator.appName.indexOf("Microsoft") == -1){
			MM_showHideLayers('LayerProdutosTopNs','','hide')
		}
		else{
			document.all.FlashTopo.TGotoFrame("/tabelaLayer",2);
			MM_showHideLayers('LayerProdutos','','show');
		}
}

function VoltaMenuProdutosFlash()
{
	document.all.inicial.TGotoFrame("_level3/produtos_marcas/mc_linhas", 11);
	document.all.inicial.TPlay("_level3/produtos_marcas/mc_linhas");
}

function Trim(str)
{
	if ( str != "" && str != null )
	{
		while ( ( ( str.indexOf(" ") == 0 ) && ( str.indexOf(" ") != -1 )  ) || ( (str.lastIndexOf(" ") == str.length-1) && (str.lastIndexOf(" ") != -1)  ) )
		{
			str = str.replace(/^ /,"");
			str = str.replace(/ $/,"");
		}		
	}
	return(str);
}
	
function valida_email(strEmail) {

	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]?&'%~#´`"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	
	var matchArray=strEmail.match(emailPat)
	if (matchArray==null) {
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	
	if (user.match(userPat)==null) {
	    return false
	}
	
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
			return false
		    }
	    }
	    return true
	}
	
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
	    return false
	}
	
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
	    domArr[domArr.length-1].length>3) {
	   return false
	}
	
	if (len<2) {
	   return false
	}
	
	return true;
}

function fnc_KeyPressEnterLogin(tecla){
	if(tecla == 13)
	{
		fnc_SendLogin();
	}
}

function fnc_SendLogin(){
	var strLogin = document.getElementById("f_txtLogin").value;
	var strSenha = document.getElementById("f_pswSenha").value;
	
	if( Trim(strLogin)=="" ){
		alert("Por favor, digite seu nome usuário.");
		document.getElementById("f_txtLogin").focus();
		return;
	}
	
	if( Trim(strSenha)=="" ){
		alert("Por favor, digite sua senha.");
		document.getElementById("f_pswSenha").focus();
		return;
	}
	window.open("action_login.asp?f_txtLogin="+strLogin+"&f_pswSenha="+strSenha,"_self");
}

function fnc_BuscaSimples()
{

	var strSel;
	strSel = document.frm_Index.f_selBusca.value;
	var intSelecionado;
	
	if (strSel != -1) {
		document.frm_Index.action = "resultado_dabusca_produtos.asp?q_LinhaProduto="+strSel;
		document.frm_Index.submit();
		}
	else
				{
					alert("Por favor, selecione uma linha de produtos para continuar a busca.");
				}
}

function fnc_SubmitTopo(P) {
	var F;
	var strSel;
	F = document.frm_Topo;
	strSel = F.f_selLayerCombo1;
	var intSelecionado;
		for (i=0; i < strSel.options.length; i++)
		{ 
			if (strSel.options[i].selected) 
		{ 
			intSelecionado = strSel.options[i].value; 
		break; 
		} 
		}			
				if ((intSelecionado > 0)&&(P != ""))
				{				
					F.submit();
				}
	
}
