// JavaScript Document
   function nuevoAjax(){
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;
}

/****************** Envia todo los datos POST por medio de ajax ******************/
  
  function enviarFormulario(url, formid){
    //par.getElementById('iframe').appendChild(new_iframe);
	   
	   var Formulario = document.getElementById(formid);
        var longitudFormulario = Formulario.elements.length;
        var cadenaFormulario = ""
        var sepCampos
            sepCampos = ""
       for (var i=0; i <= Formulario.elements.length-1;i++) {
		   if(Formulario.elements[i].type =="checkbox" && Formulario.elements[i].checked==0){
			   Formulario.elements[i].name='';
			}else{
cadenaFormulario += sepCampos+Formulario.elements[i].name+'='+encodeURI(Formulario.elements[i].value);
            sepCampos="&";}
   }
     peticion=new nuevoAjax();
	
	 peticion.open("POST", url, true);
     peticion.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
    peticion.onreadystatechange = function () {
     if (peticion.readyState==1)
   {
    // Mientras carga elimino la opcion "Elige pais" y pongo una que dice "Cargando"
     document.getElementById('load').innerHTML = '<p style="text-align:center;"><img src="gif/remembermilk_orange.gif"/><br><font color="#fffff">Loading.....</font></p>';
   
   }
	 if (peticion.readyState == 4) {
		 //alert('Hola');
        document.getElementById('conte').innerHTML = peticion.responseText;
		document.getElementById('load').innerHTML = '';
   }
   }
   peticion.send(cadenaFormulario);
   }
   
   
 /******************** Envia todo los datos GET por medio de ajax *****************/
   
  function cargaContenido(valor,idpg,id,accion,pg,order,campob,busq)
{
	//var valor=document.getElementById(cmborigen).options[document.getElementById(cmborigen).selectedIndex].value;
	//alert("Ente -->"+cmbdest);
	if(valor==0)
	{
		// Si el usuario eligio la opcion "Elige", no voy al servidor y pongo todo por defecto
		
	//var combo=document.getElementById(cmbdest);
		//document.getElementById(cmbdest).length=0;
		//var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Selecciona Pais...";
		//document.getElementById(cmbdest).appendChild(nuevaOpcion);	document.getElementById(cmbdest).disabled=true;
	}
	else
	{
		ajax=nuevoAjax();
		
		//document.getElementById('conte').innerHTML = '<p style="text-align:center;"><img src="image/esperando.gif"/></p>';
		ajax.open("GET", "proceso1.php?idpg="+idpg+"&id="+id+"&accion="+accion+"&pg="+pg+"&ordeby="+order+"&txtcampob="+campob+"&txtbuscatabla="+busq+"&ms"+new Date().getTime(), true);
		ajax.onreadystatechange=function()
		{ 
			if (ajax.readyState==1)
			{
				document.getElementById('load').innerHTML = '<p style="text-align:center;"><img src="gif/remembermilk_orange.gif"/><br><font color="#fffff">Loading.....</font></p>';
			}
			//alert("Ente -->"+ajax.readyState);
			if (ajax.readyState==4)
			{ 
				//alert("Ente -->"+ajax.responseText);
				document.getElementById("conte").innerHTML=ajax.responseText;
				document.getElementById('load').innerHTML = '';
			} 
		}
		ajax.send(null);
	}
}

/******************** Cambia el tipo de visualizacion de la tabla *****************/
   
  function vista(url)
{
	//var valor=document.getElementById(cmborigen).options[document.getElementById(cmborigen).selectedIndex].value;
	//alert("Ente -->"+cmbdest);
	
		ajax=nuevoAjax();
		
		//document.getElementById('conte').innerHTML = '<p style="text-align:center;"><img src="image/esperando.gif"/></p>';
		ajax.open("GET", url+"&ms"+new Date().getTime(), true);
		ajax.onreadystatechange=function()
		{ 
			if (ajax.readyState==1)
			{
				document.getElementById('load').innerHTML = '<p style="text-align:center;"><img src="gif/remembermilk_orange.gif"/><br><font color="#fffff">Loading.....</font></p>';
			}
			//alert("Ente -->"+ajax.readyState);
			if (ajax.readyState==4)
			{ 
				//alert("Ente -->"+ajax.responseText);
				document.getElementById("conte").innerHTML=ajax.responseText;
				document.getElementById('load').innerHTML = '';
			} 
		}
		ajax.send(null);
	
}

function col4(url)
{
	//var valor=document.getElementById(cmborigen).options[document.getElementById(cmborigen).selectedIndex].value;
	//alert("Ente -->"+cmbdest);
	
		ajax=nuevoAjax();
		
		//document.getElementById('conte').innerHTML = '<p style="text-align:center;"><img src="image/esperando.gif"/></p>';
		ajax.open("GET", url+"&ms"+new Date().getTime(), true);
		ajax.onreadystatechange=function()
		{ 
			if (ajax.readyState==1)
			{
				document.getElementById('load').innerHTML = '<p style="text-align:center;"><img src="gif/remembermilk_orange.gif"/><br><font color="#fffff">Loading.....</font></p>';
			}
			//alert("Ente -->"+ajax.readyState);
			if (ajax.readyState==4)
			{ 
				//alert("Ente -->"+ajax.responseText);
				document.getElementById("conte").innerHTML=ajax.responseText;
				document.getElementById('load').innerHTML = '';
			} 
		}
		ajax.send(null);
	
}


function validarcampos(tabla,cid,cval,cajatxt)
{
	//var valor=document.getElementById(cmborigen).options[document.getElementById(cmborigen).selectedIndex].value;
	//alert("Ente -->"+cmbdest);
	var valor =document.form[cajatxt].value;
	if(valor==''){
		//document.frmmy['txtcaja'].value="Obligatorio";
		document.getElementById("mostrar").innerHTML=" * ";
		return;
	}
		ajax=nuevoAjax();
		
		//document.getElementById('conte').innerHTML = '<p style="text-align:center;"><img src="image/esperando.gif"/></p>';
		ajax.open("GET", "validaajax.php?valor="+valor+"&tabla="+tabla+"&campoid="+cid+"&campoval="+cval+"&ms"+new Date().getTime(), true);
		ajax.onreadystatechange=function()
		{ 
			if (ajax.readyState==1)
			{
				document.getElementById('mostrar').innerHTML = '<img src="gif/mozilla_blu.gif" width="16" height="16"/>';
			}
			//alert("Ente -->"+ajax.readyState);
			if (ajax.readyState==4)
			{ 
				//alert("Ente -->"+ajax.responseText);
				document.getElementById("mostrar").innerHTML=ajax.responseText;
				//document.getElementById('load').innerHTML = '';
			} 
		}
		ajax.send(null);
	
}




/********************************* Funciones varias ************************************/


function seleccionar_todo(){ 
   for (i=0;i<document.frm.elements.length;i++) 
      if(document.frm.elements[i].type == "checkbox") 
         document.frm.elements[i].checked=1 
} 

function deseleccionar_todo(){ 
   for (i=0;i<document.frm.elements.length;i++) 
      if(document.frm.elements[i].type == "checkbox") 
         document.frm.elements[i].checked=0 
} 

function submitselect(url){
	band=false; 
   for (i=0;i<document.frm.elements.length;i++){
      if(document.frm.elements[i].type == "checkbox") {
			if (document.frm.elements[i].checked==1){
			 	band=true;
			} 
		}
	}	
	if (band){
		if(document.frm.cmbaccion.value=='el'){
			borrar=confirm('confirma');if(borrar){enviarFormulario(url,'frm');}else{document.frm.cmbaccion.selectedIndex=0;}
		}else{
			//alert(pg);
enviarFormulario(url,'frm');
		}
		
	}else{
		alert("<?php echo $this->pleasesel; ?>");
		document.frm.cmbaccion.selectedIndex=0;
	}
} 

/*****************************************************************************/
function IsNumeric(valor)
{
var log=valor.length; var sw="S";
 for (x=0; x<log; x++)
 { v1=valor.substr(x,1);
 v2 = parseInt(v1);
 //Compruebo si es un valor numérico
 if (isNaN(v2)) { sw= "N";}
}
if (sw=="S") {return true;} else {return false; }
}

var primerslap=false;
var segundoslap=false;
function formateafecha(fecha)
{
var long = fecha.length;
var dia;
var mes;
var ano;

if ((long>=2) && (primerslap==false)) { dia=fecha.substr(0,2);
if ((IsNumeric(dia)==true) && (dia<=12) && (dia!="00")) { fecha=fecha.substr(0,2)+"/"+fecha.substr(3,7); primerslap=true; }
else { fecha=""; primerslap=false;}
}
else
{ dia=fecha.substr(0,1);
if (IsNumeric(dia)==false)
{fecha="";}
if ((long<=2) && (primerslap=true)) {fecha=fecha.substr(0,1); primerslap=false; }
}
if ((long>=5) && (segundoslap==false))
{ mes=fecha.substr(3,2);
if ((IsNumeric(mes)==true) &&(mes<=31) && (mes!="00")) { fecha=fecha.substr(0,5)+"/"+fecha.substr(6,4); segundoslap=true; }
else { fecha=fecha.substr(0,3);; segundoslap=false;}
}
else { if ((long<=5) && (segundoslap=true)) { fecha=fecha.substr(0,4); segundoslap=false; } }
if (long>=7)
{ ano=fecha.substr(6,4);
if (IsNumeric(ano)==false) { fecha=fecha.substr(0,6); }
else { if (long==10){ if ((ano==0) || (ano<1900) || (ano>2100)) { fecha=fecha.substr(0,6); } } }
}

if (long>=10)
{
fecha=fecha.substr(0,10);
dia=fecha.substr(0,2);
mes=fecha.substr(3,2);
ano=fecha.substr(6,4);
// Año no viciesto y es febrero y el dia es mayor a 28
if ( (ano%4 != 0) && (mes ==02) && (dia > 28) ) { fecha=fecha.substr(0,2)+"/"; }
}
return (fecha);
}
function IsNumeric2(valor)
{
var log=valor.length; var sw='S';
 for (x=0; x<log; x++)
 { v1=valor.substr(x,1);
 v2 = parseInt(v1);
 //Compruebo si es un valor numérico
 if (isNaN(v2)) { sw= 'N';}
}
if (sw=='S') {return true;} else {return false; }
}

var primerslap=false;
var segundoslap=false;
function formateahorario(horario)
{
var long = horario.length;
var hora;
var mint;
var seg;
var mer;

if ((long>=2) && (primerslap==false)) { hora=horario.substr(0,2);
if ((IsNumeric2(hora)==true) && (hora<=12) && (hora!='00')) { horario=horario.substr(0,2)+':'+horario.substr(3,7); primerslap=true; }
else { horario=''; primerslap=false;}
}
else
{ hora=horario.substr(0,1);
if (IsNumeric2(hora)==false)
{horario='';}
if ((long<=2) && (primerslap=true)) {horario=horario.substr(0,1); primerslap=false; }
}
if ((long>=5) && (segundoslap==false))
{ mint=horario.substr(3,2);
if ((IsNumeric2(mint)==true) &&(mint<=59)) { horario=horario.substr(0,5)+':'+horario.substr(6,4); segundoslap=true; }
else { horario=horario.substr(0,3);; segundoslap=false;}
}
else { if ((long<=5) && (segundoslap=true)) { horario=horario.substr(0,4); segundoslap=false; } }
if (long>=7) 
{ seg=horario.substr(6,2);
if (IsNumeric2(seg)==false) { horario=horario.substr(0,6); }
else { if (long==8){ if((seg>59)){ horario=horario.substr(0,6); }else{horario=horario.substr(0,8)+'  '; }} }
}
if (long>=11) 
{ mer=horario.substr(10,2);
if (IsNumeric2(mer)==true) { horario=horario.substr(0,10); }
else { if (long==12){ if(((mer!='pm'))&&((mer!='am'))){ horario=horario.substr(0,10); }else{horario=horario.substr(0,12); }} }
}
if (long>=12)
{
horario=horario.substr(0,12);
hora=horario.substr(0,2);
mint=horario.substr(3,2);
seg=horario.substr(6,2);
mer=horario.substr(8,4);
// Año no viciesto y es febrero y el hora es mayor a 28

}
return (horario);
}

function lanzarSubmenu(){
  window.open("../classform/sqleditor.php","ventana1","width=550,height=600,scrollbars=YES") 
 }
 isIE=document.all?true:false;
var isNS4=document.layers?true:false; 
var isNS6=navigator.userAgent.indexOf('Gecko')!=-1?true:false;
var bC=new Array('pink','white');
var C=new Array('black','hotpink');

function doIt(_v)
{
  var X=eval('document.frm.chkactivar[_v]'.checked?0:1);
  if(isIE)
  {
    eval('t'+_v+'.style.backgroundColor=bC[X]');
    eval('t'+_v+'.style.color=C[X]');
  }
  if(isNS6)
  {
    document.getElementById('t'+_v).style.backgroundColor=bC[X];
    document.getElementById('t'+_v).style.color=C[X];
  }
}
 

function makevisible(cur,which){
if (which==0){
cur.filters.alpha.opacity=100;}
else{
cur.filters.alpha.opacity=40;}
}

//***********************************************
/***********************************************
* Bottom slide tooltip- by Ron Grafe (mailto:grafer@REMOVETHIScolumbus.rr.com)
* Website URL: http://www.gdevresources.com
* Script modified by and available at Dynamic Drive: http://www.dynamicdrive.com/
***********************************************/

//SET TOOLTIP DESCRIPTIONS BELOW
//Extend or contract array as needed
var description=new Array()
description[0]='This is tool-tip description 1'
description[1]='<b>This is tool-tip descrition 2'
description[2]='<i>This is tool-tip description 3'

//Do not edit below here

iens6=document.all||document.getElementById
ns4=document.layers

<!--GLOBAL VARIABLES-->
var thename
var theobj
var thetext
var winHeight
var winPositionFromTop
var winWidth
var startH=2
var openTimer
<!--END GLOBAL VARIABLES-->

<!--GLOBAL FUNCTIONS-->

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function setObj(text,theswitch,inwidth,inheight) {
 thetext=text
 if(iens6){
  thename = "viewer"
  theobj=document.getElementById? document.getElementById(thename):document.all.thename
  winHeight=100
   if(iens6&&document.all) {
    winPositionFromTop=!window.opera? ietruebody().clientHeight : document.body.clientHeight
    winWidth=(ietruebody().clientWidth-ietruebody().leftMargin)
   }
   if(iens6&&!document.all) {
    winPositionFromTop=window.innerHeight
    winWidth=(window.innerWidth-(ietruebody().offsetLeft+30))
   }
   if(theswitch=="override") {
    winWidth=inwidth
    winHeight=inheight
   }
  theobj.style.width=winWidth+"px"
  theobj.style.height=startH+"px"
   if(iens6&&document.all) {
    theobj.style.top=ietruebody().scrollTop+winPositionFromTop+"px"
    //window.status=winPositionFromTop
    theobj.innerHTML = ""
    theobj.insertAdjacentHTML("BeforeEnd","<table cellspacing=0 width="+winWidth+" height="+winHeight+" border=1><tr><td width=100% valign=top><font type='times' size='2' style='color:black;font-weight:normal'>"+thetext+"</font></td></tr></table>")
   }
   if(iens6&&!document.all) {
    theobj.style.top=window.pageYOffset+winPositionFromTop+"px"
    theobj.innerHTML = ""
    theobj.innerHTML="<table cellspacing=0 width="+winWidth+" height="+winHeight+" border=1><tr><td width=100% valign=top><font type='times' size='2' style='color:black;font-weight:normal'>"+thetext+"</font></td></tr></table>"
   }
 }
 if(ns4){
  thename = "nsviewer"
  theobj = eval("document."+thename)
  winPositionFromTop=window.innerHeight
  winWidth=window.innerWidth
  winHeight=100
   if(theswitch=="override") {
    winWidth=inwidth
    winHeight=inheight
   }
  theobj.moveTo(0,eval(window.pageYOffset+winPositionFromTop))
  theobj.width=winWidth
  theobj.clip.width=winWidth
  theobj.document.write("<table cellspacing=0 width="+winWidth+" height="+winHeight+" border=1><tr><td width=100% valign=top><font type='times' size='2' style='color:black;font-weight:normal'>"+thetext+"</font></td></tr></table>")
  theobj.document.close()
 }
 viewIt()
}

function viewIt() {
 if(startH<=winHeight) {
  if(iens6) {
   theobj.style.visibility="visible"
    if(iens6&&document.all) {
     theobj.style.top=(ietruebody().scrollTop+winPositionFromTop)-startH+"px"
    }
    if(iens6&&!document.all) {
     theobj.style.top=(window.pageYOffset+winPositionFromTop)-startH+"px"
    }
   theobj.style.height=startH+"px"
   startH+=2
   openTimer=setTimeout("viewIt()",10)
  }
  if(ns4) {
   theobj.visibility = "visible"
   theobj.moveTo(0,(eval(window.pageYOffset+winPositionFromTop)-startH))
   theobj.height=startH
   theobj.clip.height=(startH)
   startH+=2
   openTimer=setTimeout("viewIt()",10)
  }
 }else{
  clearTimeout(openTimer)
 }
}

function stopIt() {
 if(iens6) {
  theobj.innerHTML = ""
  theobj.style.visibility="hidden"
  startH=2
 }
 if(ns4) {
  theobj.document.write("")
  theobj.document.close()
  theobj.visibility="hidden"
  theobj.width=0
  theobj.height=0
  theobj.clip.width=0
  theobj.clip.height=0
  startH=2
 }
}


//*************************** largero ************************************
var description=new Array()
description[0]='This field requires'
description[1]='This field requires email'
description[2]='This field requires Number'

//Do not edit below here

iens6=document.all||document.getElementById
ns4=document.layers

<!--GLOBAL VARIABLES-->
var thename
var theobj
var thetext
var winHeight
var winPositionFromTop
var winWidth
var startH=2
var openTimer
<!--END GLOBAL VARIABLES-->

<!--GLOBAL FUNCTIONS-->

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function setObj(text,theswitch,inwidth,inheight) {
 thetext=text
 if(iens6){
  thename = "viewer"
  theobj=document.getElementById? document.getElementById(thename):document.all.thename
  winHeight=100
   if(iens6&&document.all) {
    winPositionFromTop=!window.opera? ietruebody().clientHeight : document.body.clientHeight
    winWidth=(ietruebody().clientWidth-ietruebody().leftMargin)
   }
   if(iens6&&!document.all) {
    winPositionFromTop=window.innerHeight
    winWidth=(window.innerWidth-(ietruebody().offsetLeft+30))
   }
   if(theswitch=="override") {
    winWidth=inwidth
    winHeight=inheight
   }
  theobj.style.width=winWidth+"px"
  theobj.style.height=startH+"px"
   if(iens6&&document.all) {
    theobj.style.top=ietruebody().scrollTop+winPositionFromTop+"px"
    //window.status=winPositionFromTop
    theobj.innerHTML = ""
    theobj.insertAdjacentHTML("BeforeEnd","<table cellspacing=0 width="+winWidth+" height="+winHeight+" border=1><tr><td><img src='gif/error.gif.png' width='50' height='50'></td><td width=100% valign=top><font type='times' size='2' style='color:black;font-weight:normal'>"+thetext+"</font></td></tr></table>")
   }
   if(iens6&&!document.all) {
    theobj.style.top=window.pageYOffset+winPositionFromTop+"px"
    theobj.innerHTML = ""
    theobj.innerHTML="<table cellspacing=0 width="+winWidth+" height="+winHeight+" border=1><tr><td><img src='gif/error.gif.png' width='50' height='50'></td><td width=100% valign=top><font type='times' size='2' style='color:black;font-weight:normal'>"+thetext+"</font></td></tr></table>"
   }
 }
 if(ns4){
  thename = "nsviewer"
  theobj = eval("document."+thename)
  winPositionFromTop=window.innerHeight
  winWidth=window.innerWidth
  winHeight=100
   if(theswitch=="override") {
    winWidth=inwidth
    winHeight=inheight
   }
  theobj.moveTo(0,eval(window.pageYOffset+winPositionFromTop))
  theobj.width=winWidth
  theobj.clip.width=winWidth
  theobj.document.write("<table cellspacing=0 width="+winWidth+" height="+winHeight+" border=1><tr><td><img src='gif/error.gif.png' width='50' height='50'></td><td width=100% valign=top><font type='times' size='2' style='color:black;font-weight:normal'>"+thetext+"</font></td></tr></table>")
  theobj.document.close()
 }
 viewIt()
}

function viewIt() {
 if(startH<=winHeight) {
  if(iens6) {
   theobj.style.visibility="visible"
    if(iens6&&document.all) {
     theobj.style.top=(ietruebody().scrollTop+winPositionFromTop)-startH+"px"
    }
    if(iens6&&!document.all) {
     theobj.style.top=(window.pageYOffset+winPositionFromTop)-startH+"px"
    }
   theobj.style.height=startH+"px"
   startH+=2
   openTimer=setTimeout("viewIt()",10)
  }
  if(ns4) {
   theobj.visibility = "visible"
   theobj.moveTo(0,(eval(window.pageYOffset+winPositionFromTop)-startH))
   theobj.height=startH
   theobj.clip.height=(startH)
   startH+=2
   openTimer=setTimeout("viewIt()",10)
  }
 }else{
  clearTimeout(openTimer)
 }
}

function stopIt() {
 if(iens6) {
  theobj.innerHTML = ""
  theobj.style.visibility="hidden"
  startH=2
 }
 if(ns4) {
  theobj.document.write("")
  theobj.document.close()
  theobj.visibility="hidden"
  theobj.width=0
  theobj.height=0
  theobj.clip.width=0
  theobj.clip.height=0
  startH=2
 }
}


function idioma() { 
if (navigator.userAgent.indexOf("Opera")!=-1) (language=navigator.language) 
else { if (navigator.appName == "Netscape") (language=navigator.language) 
else language=navigator.browserLanguage }; 

if (language){language=language.substring(0,2)} 
else {language="zz"} 
switch (language) { 
case "en" : window.location="Pagina_en_ingles.html"; break; 
case "es" : window.location="Pagina_en_espanol.html"; break; 
case "ca" : window.location="Pagina_en_catalan.html"; break; 
case "zz" : window.location="Pagina_en_catalan.html"; break; 
default : window.location="Pagina_en_catalan.html" } } 




