var ajax=false;

function trim(s) {
	return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
}

function iniciaAjax(){
   try {
         ajax = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
         try {
                ajax = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (E) {
               try{
                   ajax = new XMLHttpRequest();
               } catch(E2){
                    ajax = false;
               }
         }
    }
   if (!ajax && typeof XMLHttpRequest!='undefined') {
        ajax = new XMLHttpRequest();
   }
}

function cambiaImg2(){
	var total = aImg.length;
	var indice = Math.floor(Math.random() * total);

	if(aImg[indice].length > 0){
		document.getElementById('foco_central').style.backgroundImage="url("+aImg[indice]+")";
		setTimeout("cambiaImg2()",45000);
	}else{
		document.getElementById('doc').style.backgroundImage="url("+aImg[0]+")";
		setTimeout("cambiaImg2()",45000);
	}
}

function cambiaImg(){
	aleat = Math.floor(Math.random() * 4);
	if (document.body){
		document.body.background = aImg[aleat];
	}
	setTimeout("cambiaImg()",45000);
}

function verDato(op1,op2,val){
		var ruta = window.location.pathname;
		ruta = ruta.split("/");
		document.getElementById('div_text').style.display='block';
		document.getElementById('div_text').innerHTML = '<img src="img/indicator.gif"> Por favor espere ....';
		iniciaAjax();

		var query = "accion=menu";
		query += '&op1=' + op1;
		query += '&op2=' + op2;
		query += '&val=' + val;
		if(ruta[ruta.length -1 ] != 'index.php'){
			//document.location='index.php?'+query;
		}
		ajax.open("POST","process.php", true);
		ajax.onreadystatechange=function()
		{
		if (ajax.readyState==4)
			{
				document.getElementById('div_text').innerHTML = ajax.responseText;
				ocultaSubMenu();
			}
		}
		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax.send(query);	
}