// Intranet de la Secretaría de Gobernanción 
// Desarrollo: Beatriz Hernández
// Objetivo:   Modulo que incluye funciones java script para usarlas en la intranet generada dinamicamente.


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  //eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  eval("top.location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  //var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
  var selObj = MM_findObj('menu1'); if (selObj) MM_jumpMenu('top',selObj,restore);  
}

function esconde()
{
rest.style.display = "none";
}
 
function presenta()
{
rest.style.display = "block";
} 

function doit()
{
if (rest.style.display == "none")
	{
		rest.style.display = "block";
	}
	else
	{
		rest.style.display = "none";
	}
} 

function doit1()
{
	if (rest1.style.display == "none"){
		rest1.style.display = "block";
	}
	else{
		rest1.style.display = "none";
	}
} 
function doit2()
{
if (rest2.style.display == "none")
	{
		rest2.style.display = "block";
	}
	else
	{
		rest2.style.display = "none";
	}
} 
function doit3()
{
if (rest3.style.display == "block")
	{
		rest3.style.display = "none";
	}
	else
	{
		rest3.style.display = "block";
	}
}
function fun_buscar(){
var ff= document.formbus;
if(ff.elements[0].value=='' || ff.elements[0].value=='Buscar'){
alert('Introduzca la información');ff.elements[0].focus(); return false; 
}else{return true;}
}
//POPuP de impresión
function popWindow(){
var pop = window.open('PtPrint.php','','');
if(pop.focus){pop.focus();}
}
//AJAX
function funNull(){ return; }
function ajax_setData(id,text){	
if (document.getElementById){
document.getElementById(id).innerHTML = '';
document.getElementById(id).innerHTML = text;
}else if (document.all){
x = document.all[id];
x.innerHTML = text;
}else if (document.layers){
x = document.layers[id];
x.document.open();
x.document.write(text);
x.document.close();
}
}
function ajax_getData(page,capa,id,template){
var xmlHttp=false;
if(typeof(XMLHttpRequest)!='undefined'){
try { xmlHttp = new XMLHttpRequest();
} 
catch(exepcion){  }
}else{ try{ xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');  } 
catch(excepcion){  xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');  }
}
if (template!=1){ template=0; }
try{ xmlHttp.open('POST',page+'.php?hash=' + Math.random() * 123456789,true ); 
xmlHttp.onreadystatechange=function() 
{ switch(xmlHttp.readyState)
{ case 1: if(template==1) {	ajax_setData(capa,'<table width="497" height="255" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" bgcolor="white"><img src="../archivos/images/cargando.gif"/></td></tr></table>');
} else {ajax_setData(capa,'<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" bgcolor="white"  width="130" height="67"><img src="../archivos/images/cargando.gif"/></td></tr></table>');
} break;
case 4: ajax_setData(capa,xmlHttp.responseText); break;				
}		
}
}
catch(excepcion){  return false;    }
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.send('id=' + id);
return true;      
}
function ajax_banner(capa,id){	ajax_getData('../archivos/php/bannerRotatorio',capa,id,999); }
function iniciarBanners(){	ajax_banner('bannerRotatorio',3);setInterval("ajax_banner('bannerRotatorio',3)",10000); }