//Flash detect
var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
if (navigator.plugins && navigator.plugins.length)
{
	x = navigator.plugins["Shockwave Flash"];
	if (x)
	{
		flashinstalled = 2;
		if (x.description)
		{
			y = x.description;
			flashversion = y.charAt(y.indexOf('.')-1);
		}
	}
	else
		flashinstalled = 1;
	if (navigator.plugins["Shockwave Flash 2.0"])
	{
		flashinstalled = 2;
		flashversion = 2;
	}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
	x = navigator.mimeTypes['application/x-shockwave-flash'];
	if (x && x.enabledPlugin)
		flashinstalled = 2;
	else
		flashinstalled = 1;
}
else
	MSDetect = "true";


// Resize do objeto do Flash para casos de resize da Janela
noSubmit = false;
function checkSearchPost(myForm){
  if (noSubmit == true){
    myForm.text.value = '';
    myForm.from_day.value = '';
    myForm.from_month.value = '';
    myForm.from_year.value = '';
    myForm.to_day.value = '';
    myForm.to_month.value = '';
    myForm.to_year.value = '';
    myForm.search_text_options.selectedIndex = 0;
    myForm.search_by_section.selectedIndex = 0;
    
    return false;
  }
  
  if (myForm.text.value == ''){
    alert("Não é permitido uma consulta em branco.");
    myForm.text.focus();
    return false;
  }
  
  return true;
}

function resizeFlashObj() {
	document.getElementById("home_vale").width = document.body.offsetWidth;
}

// Expansão do flash da Home
var minCurtainHeight = 65;
var boolLoad = false;
function bCurtainPlay() {
	return false;
	/*
	objLayer = document.getElementById("cortina");
	objTd = document.getElementById("flash_header");
	var reductionFactor;

	if (minCurtainHeight <= 180) {
		reductionFactor = ((180 - minCurtainHeight) * 5) / 65;
		if (reductionFactor < 1) reductionFactor = 1;
		minCurtainHeight = minCurtainHeight + reductionFactor;
		objLayer.style.clip = 'rect(0px, '+document.body.offsetWidth+'px, '+minCurtainHeight+'px, 0px)';
		objTd.style.height = minCurtainHeight+"px";
		stInterval = window.setTimeout('bCurtainPlay()', 20);
	}
	else
		clearTimeout(stInterval);
	*/
}
// Ao carregar o body o flash é direcionado para o frame 4
function bodyLoaded() {
	//if (flashinstalled == 2)
		//document.getElementById("home_vale").GotoFrame(4);
}

// Troca dos destaques da Home
var index = 1;
var totalNews = 2;
function ocultarNews(){
	for(x=1;x<=totalNews;x++){
		document.getElementById("noticia"+x).style.display="none";
	}
}
function order(ord){
	if(ord=="up" && index<totalNews){
		ocultarNews();
		index+=1;
		document.getElementById("noticia"+index).style.display="block";
	}else if(ord=="down" && index>1){
		ocultarNews();
		index-=1;
		document.getElementById("noticia"+index).style.display="block";
	}
}

// Abas da Home
var count = 1;
var segundosExibicao = 7;
function mostraAba(id, estado){
	if(estado != 'continue'){
		clearInterval(intervalo);
	}
	var divAba     = document.getElementById("a" + id);
	var divContent = document.getElementById("c" + id);
	for(x = 1; x <= 3; x++){
		if(id != x) {
			document.getElementById("a"+x).className='abaNormal';
			document.getElementById("c"+x).style.display='none';
		}
	}
	divAba.className          = 'abaClick';
	divContent.style.display  = 'block';
}
function alternaAba() {
	if(count == 3) {
		count = 0;
	}
	count += 1;
	mostraAba(count, 'continue');
}

function validarLoginSenha( ){
 	if ( validar() ){
         window.document.form1.method = "post";
         window.document.form1.action = "http://www.vale.com/logistica/espacoconhecimento/login_start.asp";
         return true;
        }
return false;
}


function validar()
{

	if (document.form1.login.value == "")
	{
		alert("Preencha o campo 'Login'");
		document.form1.login.focus();
		return false;
	}
	if (document.form1.senha.value == "")
	{
		alert("Preencha o campo 'Senha'");
		document.form1.senha.focus();
		return false;
	}
	return true;
}

// Limpa campo busca
function editBusca(bus){
	if(bus.value=="Search" || bus.value=="Busca") {
		bus.value="";
	}
}

//Imprimir
function btImprimir() {
	if (top.location.toString().lastIndexOf("?") != -1)
		window.open(top.location + "&print=1", "ValeImprimir", "width=600,height=500,scrollbars=yes");
	else
		window.open(top.location + "?print=1", "ValeImprimir", "width=600,height=500,scrollbars=yes");
}

shortcut.add("CTRL+ALT+1",function() {
	window.location="/vale/cgi/cgilua.exe/sys/start.htm?tpl=home";
});
shortcut.add("CTRL+ALT+Q",function() {
	window.location="/vale/cgi/cgilua.exe/sys/start.htm?sid=2";
});
shortcut.add("CTRL+ALT+N",function() {
	window.location="/vale/cgi/cgilua.exe/sys/start.htm?sid=3";
});
shortcut.add("CTRL+ALT+I",function() {
	window.location="/vale/cgi/cgilua.exe/sys/start.htm?sid=4";
});
shortcut.add("CTRL+ALT+S",function() {
	window.location="/vale/cgi/cgilua.exe/sys/start.htm?sid=5";
});
shortcut.add("CTRL+ALT+M",function() {
	window.location="/saladeimprensa/pt/home/imprensa.asp";
});
shortcut.add("CTRL+ALT+P",function() {
	window.location="/vale/cgi/cgilua.exe/sys/start.htm?sid=8";
});