// Funçoes JavaScript
////////////////////////////////////////////////////////////////////////////////////////////
// Insere flash ativado
function hp_escreveflash(piWid, piHei, psSrc, psWm, psId) {
	var strSwf;

	strSwf = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" id="+psId+" width="+piWid+" height="+piHei+">";
	strSwf += "<param name=\"movie\" value="+psSrc+" />";
	strSwf += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
	strSwf += "<param name=\"quality\" value=\"high\" />";
	strSwf += "<param name=\"wmode\" value=\""+psWm+"\" />";
	strSwf += "<embed id="+psId+" name="+psId+" allowScriptAccess=\"sameDomain\" swLiveConnect=\"true\" src="+psSrc+" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width="+piWid+" height="+piHei+"></embed></object>";
	
	this.document.write(strSwf);
} 

////////////////////////////////////////////////////////////////////////////////////////////
// Validador dos Campos de Login e Senha da Tarja Superior das Escolas
function ValidaLogin(form) {

 if (form.strLogin.value == "") {
  window.alert('Favor entrar com um valor no campo "Login".');
  form.strLogin.focus();
  return (false);
 }
 try{
	if (form.strSenha.value == "") {
		window.alert('Favor entrar com um valor no campo "Senha".');
		form.strSenha.focus();
		return (false);
	}else
	{
		return true;
	}
 }catch(erross){}
 	
 if (document.getElementById('strSenhaSS').value == "") {
  window.alert('Favor entrar com um valor no campo "Senha".');
  form.strSenhaSS.focus();
  return (false);
 }
 
 return (true);
}

///////////////////////////////////////////////////////////////////////////////////////////

var intervalo;

// Menu de A a Z XML
function Go2(address) {
	
	if ((address.indexOf('redireciona_blogs') != -1) || (address.indexOf('redireciona_explore') != -1) )  {
		window.open(address)
		//isso abaixo dá bug no FF
		//document.getElementById('linkaz').target = '_blank';

	} else {
		document.getElementById('linkaz').href = address;
		document.getElementById('linkaz').target = '_top';
		//document.getElementById('linkaz').click();
		window.location.href = address;
	}
	
}
	
function focoLogin(){		
	var newImage = "url('/esc_include/imagens/templates/2010/bg_inputlimpo.gif')";
	document.getElementById('strLogin').style.backgroundImage = "";
	document.getElementById('strLogin').style.backgroundImage = newImage;
	
	intervalo = window.setInterval('verificaAuto()', 1);	
}

function verificaAuto(){	
	
	try {
		if(document.getElementById("strLogin").value.length > 0){		
				
			var newImage2 = "url('/esc_include/imagens/templates/2010/bg_inputlimpo.gif')";
		
			if(document.getElementById("strLogin").value.length > 0){			
				document.getElementById('strLogin').style.backgroundImage = newImage2;
			}
				
			if(document.getElementById("strSenhaSS").value.length > 0){		
				document.getElementById('strSenhaSS').style.backgroundImage = newImage2;
			}
		}	
	}catch(erro){
	}
}

function blurLogin(){	
	if(document.getElementById('strLogin').value == ""){
		var newImage = "url('/esc_include/imagens/templates/2010/bg_login.gif')";
		document.getElementById('strLogin').style.backgroundImage = newImage;
	}
	clearInterval(intervalo);
}

function focoSenha(){
	/*
	if(document.getElementById('strSenhaSS').value == "Senha"){
		document.getElementById('strSenhaSS').value = "";	
		document.getElementById('strSenhaSS').type = "password";
	}
	*/
	var newImage = "url('/esc_include/imagens/templates/2010/bg_inputlimpo.gif')";
	document.getElementById('strSenhaSS').style.backgroundImage = newImage;
	
}

function blurSenha(){
	/*
	if(document.getElementById('strSenhaSS').value == ""){
		document.getElementById('strSenhaSS').value = "Senha";
		document.getElementById('strSenhaSS').type = "text";
	}
	*/
	if(document.getElementById('strSenhaSS').value == ""){
		var newImage = "url('/esc_include/imagens/templates/2010/bg_senha.gif')";
		document.getElementById('strSenhaSS').style.backgroundImage = newImage;
	}
	
}

function focoPesquisa(){
	document.getElementById('strpc_topo').value = "";	
}

function blurPesquisa(){	
	if(document.getElementById('strpc_topo').value == ""){
		document.getElementById('strpc_topo').value = "Pesquisa Escolar";	
	}
}



function ocultarSenhaSS(oCampo){
  oCampo.style.display = "none";
  document.getElementById("strSenhaSS").style.display = "";
  document.getElementById("strSenhaSS").focus();
}

function restaurarCampoSS(oCampo){
	if(oCampo.value==""){
	  document.getElementById("strSenhaSS").style.display = "none";
	  document.getElementById("strSenhaSSFD").style.display = "";
	  document.getElementById("strSenhaSSFD").value = "Senha";
    }
}



function initSS()
{
	try{
		var intervalo = window.setInterval(function() {
			verificaAuto()
		}, 50);
		window.setTimeout(function() {
			clearInterval(intervalo);
		}, 3000);		
	
	}
	catch(erro){
		window.setTimeout('verificaAuto()', 2000);
	}
}

//window.onload = init();
//document.addEventListener("load", init(), false);   

function addEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}
addEvent(window, 'load', initSS);




