







// JavaScript Document

function objetoAjax(){

	var xmlhttp=false;

	try {

		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

	} catch (e) {

		try {

		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

		} catch (E) {

			xmlhttp = false;

  		}

	}



	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {

		xmlhttp = new XMLHttpRequest();

	}

	return xmlhttp;

}







function buscaFecha(fecha){

	

	Resultado = document.getElementById('campoFantasma');

	ajax=objetoAjax();

	ajax.open("GET", "ajax.php?rand=" + Math.random() + "&fecha=" + fecha);

	ajax.onreadystatechange=function() {

		if (ajax.readyState==4) {

			Resultado.value = ajax.responseText;

		}

	}

	

	ajax.send(null)

}







 

 function addEvent(elemento,nomevento,funcion,captura)

{

  if (elemento.attachEvent)

  {

    elemento.attachEvent('on'+nomevento,funcion);

    return true;

  }

  else  

    if (elemento.addEventListener)

    {

      elemento.addEventListener(nomevento,funcion,captura);

      return true;

    }

    else

      return false;

}



var ev;

var x;

var y;



function setEvento(evento){

	this.ev=evento;

}

function getEvento(){

    

   return this.ev;

}





function setX(x){

	this.x=x;

}



function getX(){

	return this.x;

}



function setY(y){

	this.y=y;

}



function getY(){

	return this.y;

}







function  verifica(anio, mes, dia, eve){

	
   
    // alert("evento:" + eve);

	//alert("valor de x:" + event.x);

	fecha=anio+'-'+ mes + '-' + dia;

	

	

	setEvento(eve);
   
   //alert("Y=" +  document.documentElement.scrollTop);
	

	//alert(eve.offsetY);

	//setX(eve.pageX);

	//setY(eve.pageY);

	

	setX(eve.clientX);
    if(navigator.appName=="Netscape")
	setY(eve.pageY);
	else
	setY(document.documentElement.scrollTop+eve.y);
	//setY(eve.clientY);
    //setY(eve.screenY);

	/*

	setEvento(event);

	setX(event.x);

	setY(event.y);

	*/

			

	//Resultado = document.getElementById('campoFantasma');

	ajax=objetoAjax();

	ajax.open("GET", "ajax.php?rand=" + Math.random() + "&fecha=" + fecha);

	ajax.onreadystatechange=function() {

		

		if (ajax.readyState==4) {

			//alert(ajax.responseText);

			//Resultado.value = ajax.responseText;

			if(ajax.responseText!="-1")

			new ToolTip(ajax.responseText).mostrar();

		}

	}

	

	ajax.send(null)

}



var d, dias;





function  existe2(anio, mes, dia){
	// alert("mes:"+ mes);	
	// mes=parseInt(mes);
	 //if(mes<10)
	 //mes="0"+ mes;
	 
	 dia=parseInt(dia);
	 if(dia<10)
	 dia="0"+ dia;
	 //alert("dentro");
	 fecha=anio+'-'+ mes + '-' + dia;
	//alert("fecha:" + fecha);
	//alert(mes);
	//alert(dia);
	
	ajax=objetoAjax();
	ajax.open("GET", "ajax.php?rand=" + Math.random() + "&anio=" + anio + "&mes=" + mes + "&dia=" + dia);
	ajax.onreadystatechange=function() {
		
		if (ajax.readyState==4) {
		
		  
		   
			if(ajax.responseText!=""){
				
				cont=0;
				d="";
				ide="";
				
				 
				for(z=0;z<ajax.responseText.length;++z){
								     
					 if(cont<2){
					     //alert(ajax.responseText.substr(z));
					     d=d+ajax.responseText.substr(z,1);
				    
				     }
				     if(cont==3){
					 	
				  		ide=ajax.responseText.substr(z,1);	
						
				  		var c=document.getElementById(d);
				  		if(ide=="1"){
				  		 c.style.textDecoration="underline";
				 		 c.style.color='#FFFFFF';
				 		 c.style.height='22px';
				 		 c.style.background='#66CC00';
				 		//c.style.background='#CCCCCC';
				 		 c.style.border='#FFFFFF solid 2px';
						}
				  		if(ide=="2"){
						 c.style.textDecoration="underline";
				 		 c.style.color='#FFFFFF';
				 		 c.style.height='22px';
				 		 c.style.background='#FF0000';
 				 		//c.style.background='#CCCCFF';
				 		c.style.border='#FFFFFF solid 2px';
						}
				  		
				  		if(ide=="3"){
				  		 c.style.textDecoration="underline";
				 		 c.style.color='#FFFFFF';
				 		 c.style.height='22px';
				 		 c.style.background='#FF6A00';
				 		 //c.style.background='#CC00CC';
				 		 c.style.border='#FFFFFF solid 2px';
				 
						}
										  				 
				  				  
				 	}
				 
				    ++cont;
				
				    if(cont>4){
				    	cont=0;
						d="";
				    	ide="";
				 	}
				
				}
				
			}
			 
			
			
			
			  
		}
	}
	

	ajax.send(null)
}





function  existe(anio, mes, dia){
	
	 mes=parseInt(mes);

	 if(mes<10)

	 mes="0"+ mes;

	 

	 dia=parseInt(dia);

	 if(dia<10)

	 dia="0"+ dia;

	//alert("dentro");

	 fecha=anio+'-'+ mes + '-' + dia;

	//alert("fecha:" + fecha);

	

	

	ajax=objetoAjax();

	ajax.open("GET", "ajax.php?rand=" + Math.random() + "&fecha2=" + fecha);

	ajax.onreadystatechange=function() {

		

		if (ajax.readyState==4) {

		

		  

		   

			if(ajax.responseText!="-1" && ajax.responseText!=""){

				

				c=document.getElementById(dia);

				if(ajax.responseText=="1"){
				 c.style.textDecoration="underline";
				 c.style.color='#FFFFFF';
				 c.style.height='22px';
				 c.style.background='#66CC00';
				 //c.style.background='#CCCCCC';
				 c.style.border='#FFFFFF solid 2px';
				}

				if(ajax.responseText=="2"){
				 c.style.textDecoration="underline";
				 c.style.color='#FFFFFF';
				 c.style.height='22px';
				 c.style.background='#FF0000';
 				 //c.style.background='#CCCCFF';
				 c.style.border='#FFFFFF solid 2px';
				}

				if(ajax.responseText=="3"){
				 c.style.textDecoration="underline";
				 c.style.color='#FFFFFF';
				 c.style.height='22px';
				 c.style.background='#FF6A00';
				 //c.style.background='#CC00CC';
				 c.style.border='#FFFFFF solid 2px';
				 document.getElementById(dia)=c;
				}
			}
			else{
				 c=document.getElementById(dia);
				 c.style.textDecoration='none';
				 c.style.color='#19A9CC';
				 c.style.background='#FFFFFF';
				 //c.style.height='32px';
				 c.style.border='#FFFFFF solid 2px';
				 document.getElementById(dia)=c;
			}
		}
	}
	ajax.send(null)
}


function MostrarDelegacion(datos){

	

	divResultado = document.getElementById('delegacion');

	ajax=objetoAjax();

	ajax.open("GET", "ajax.php?rand=" + Math.random() + "&id_estado=" + datos);

	ajax.onreadystatechange=function() {

		if (ajax.readyState==4) {

			divResultado.innerHTML = ajax.responseText;

		}

	}

	

	ajax.send(null)

}







function muestraLudo(datos){

	

	divResultado = document.getElementById('info');

	ajax=objetoAjax();

	ajax.open("GET", "ajax.php?rand=" + Math.random() + "&id_ludo=" + datos);

	ajax.onreadystatechange=function() {

		if (ajax.readyState==4) {

			divResultado.innerHTML = ajax.responseText;

		}

	}

	

	ajax.send(null)

}



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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener una dirección valida de e-mail.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es un campo requerido.\n'; }
  } if (errors) alert('Ocurrieron los siguientes errores:\n'+errors);
  document.MM_returnValue = (errors == '');
}	




