function createxml(xmlq)
{
        if (window.XMLHttpRequest) 
        { // Mozilla, Safari,...
            xml0 = new XMLHttpRequest();
            if (xml0.overrideMimeType) {
                xml0.overrideMimeType('text/xml');
                // Ver nota sobre esta linea al final
            }
        } else if (window.ActiveXObject) { // IE
            try {
                xml0 = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    xml0 = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        //if(navigator.appName=='Microsoft Internet Explorer')xml0 = new ActiveXObject("Microsoft.XMLHTTP");
        if (!xml0) {
            alert('Falla :( No es posible crear una instancia XMLHTTP');
            
        }else{}

        if(xmlq==0)xml =xml0;
        if(xmlq==1)xml1=xml0;
        if(xmlq==2)xml2=xml0;
        if(xmlq==3)xml3=xml0;
        if(xmlq==4)xml4=xml0;
        if(xmlq==5)xml5=xml0;
        if(xmlq==6)xml6=xml0;
        if(xmlq==7)xml7=xml0;
        if(xmlq==8)xml8=xml0;
        if(xmlq==9)xml9=xml0;
}


function timer()
{
d=new Date();
ho=d.getHours();
se=d.getSeconds();
mi=d.getMinutes();
di=d.getDate();
ye=d.getYear();
me=d.getMonth();
return ye+'/'+me+'/'+di+'__'+ho+':'+mi+':'+se;
}

function fechahora()
{
d=new Date();
ho=d.getHours();
se=d.getSeconds();
mi=d.getMinutes();
di=d.getDate();
ye=d.getFullYear();
me=d.getMonth();
if(me*1<10)me='0'+(me*1)
if(di*1<10)di='0'+(di*1)
if(ho*1<10)ho='0'+(ho*1)
if(mi*1<10)mi='0'+(mi*1)



return ye+'-'+me+'-'+di+' '+ho+':'+mi;
}
loadingfl='<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="30" HEIGHT="30" ALIGN=""> <PARAM NAME=movie VALUE="banners/loading.swf?'+timer()+'">  <PARAM NAME=quality VALUE=high>  <PARAM NAME=wmode VALUE=transparent> <EMBED src="banners/loading.swf?'+timer()+'" quality=high  WIDTH="30" HEIGHT="30" NAME="loading" ALIGN="" wmode=transparent TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
    function xml_inner(url,xmlcontenedor) {createxml(0);

        xmlcontenedor.innerHTML=loadingfl;
        xml_contenedor=xmlcontenedor;
        xml.onreadystatechange = alertContents;
        xml.open('GET', url, true);
        xml.send(null);

    }
    function alertContents() {
        if (xml.readyState == 4) {
            if (xml.status == 200) {
                xml_contenedor.innerHTML=xml.responseText;
                } else {
                self.status='No se pueden actualizar los mensajes enviados...';
            }
        }

    }
///*********************************************** 1 *************************************************************************
    function xml_alert(url) {
        createxml(0);
        xml.onreadystatechange = alertContents_alert;
        xml.open('GET', url, true);
        xml.send(null);

    }
    function alertContents_alert() {
        if (xml.readyState == 4) {
            if (xml.status == 200) {
                alert(xml.responseText);
                } else {
                alert('Error...');
            }
        }

    }
///*********************************************** 1 *************************************************************************
    function xmlpost_alert(url,postdata) {
        createxml(0);
        xml.onreadystatechange = postContents_alert;
        xml.open('POST', url, false);
        xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xml.send(postdata);
        //alert(xml.responseText);

    }
    function postContents_alert() {
        if (xml.readyState == 4) {
            if (xml.status == 200) {
                alert(xml.responseText);
                } else {
                alert('Error...');
            }
        }

    }
    function xmlpost_con(url,postdata) {
        createxml(0);
        
        xml.open('POST', url, false);
        xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xml.send(postdata);
        //xml.onreadystatechange = function(){if (xml.readyState == 4)alert(xml.responseText);}
		return xml.responseText;
    }

///*********************************************** 1 *************************************************************************
    function xml_alert_r(url) {
        createxml(0);
        xml.onreadystatechange = alertContents_r;
        xml.open('GET', url, true);
        xml.send(null);

    }
    function alertContents_r() {
        if (xml.readyState == 4) {
            if (xml.status == 200) {
                alert(xml.responseText);
                location.reload();
                } else {
                alert('Error...');
            }
        }

    }
///*********************************************** 1 *************************************************************************
    function xml_inner1(url1,xmlcontenedor1) {createxml(1);
        xmlcontenedor1.innerHTML=loadingfl;
        xml_contenedor1=xmlcontenedor1;
        xml1.onreadystatechange = alertContents1;
        xml1.open('GET', url1, true);
        xml1.send(null);
    }
    function alertContents1() {
        if (xml1.readyState == 4) {
            if (xml1.status == 200) {
                xml_contenedor1.innerHTML=xml1.responseText;
                } else {
                self.status='No se pueden actualizar los mensajes enviados...';
            }
        }

    }
///******************************************** 2 ****************************************************************************
    function xml_inner2(url2,xmlcontenedor2) {createxml(2);
        xmlcontenedor2.innerHTML=loadingfl;
        xml_contenedor2=xmlcontenedor2;
        xml2.onreadystatechange = alertContents2;
        xml2.open('GET', url2, true);
        xml2.send(null);
    }
    function alertContents2() {
        if (xml2.readyState == 4) {
            if (xml2.status == 200) {
                xml_contenedor2.innerHTML=xml2.responseText;
                } else {
                self.status='No se pueden actualizar los mensajes enviados...';
            }
        }

    }

///********************************************* 3 ***************************************************************************
    function xml_inner3(url3,xmlcontenedor3) {createxml(3);
        xmlcontenedor3.innerHTML=loadingfl;
        xml_contenedor3=xmlcontenedor3;
        xml3.onreadystatechange = alertContents3;
        xml3.open('GET', url3, true);
        xml3.send(null);
    }
    function alertContents3() {
        if (xml3.readyState == 4) {
            if (xml3.status == 200) {
                xml_contenedor3.innerHTML=xml3.responseText;
                } else {
                self.status='No se pueden actualizar los mensajes enviados...';
            }
        }

    }

///********************************************** 4 **************************************************************************
    function xml_inner4(url4,xmlcontenedor4) {createxml(4);
        xmlcontenedor4.innerHTML=loadingfl;
        xml_contenedor4=xmlcontenedor4;
        xml4.onreadystatechange = alertContents4;
        xml4.open('GET', url4, true);
        xml4.send(null);
    }
    function alertContents4() {
        if (xml4.readyState == 4) {
            if (xml4.status == 200) {
                xml_contenedor4.innerHTML=xml4.responseText;
                } else {
                self.status='No se pueden actualizar los mensajes enviados...';
            }
        }

    }
///*********************************************** 5 *************************************************************************
    function xml_inner5(url5,xmlcontenedor5) {createxml(5);
        xmlcontenedor5.innerHTML=loadingfl;
        xml_contenedor5=xmlcontenedor5;
        xml5.onreadystatechange = alertContents5;
        xml5.open('GET', url5, true);
        xml5.send(null);
    }
    function alertContents5() {
        if (xml5.readyState == 4) {
            if (xml5.status == 200) {
                xml_contenedor5.innerHTML=xml5.responseText;
                } else {
                self.status='No se pueden actualizar los mensajes enviados...';
            }
        }

    }
///*********************************************** 6 *************************************************************************
    function xml_inner6(url6,xmlcontenedor6) {createxml(6);
        xmlcontenedor6.innerHTML=loadingfl;
        xml_contenedor6=xmlcontenedor6;
        xml6.onreadystatechange = alertContents6;
        xml6.open('GET', url6, true);
        xml6.send(null);
    }
    function alertContents6() {
        if (xml6.readyState == 4) {
            if (xml6.status == 200) {
                xml_contenedor6.innerHTML=xml6.responseText;
                } else {
                self.status='No se pueden actualizar los mensajes enviados...';
            }
        }

    }
///*********************************************** 7 *************************************************************************
    function xml_inner7(url7,xmlcontenedor7) {createxml(7);
        xmlcontenedor7.innerHTML=loadingfl;
        xml_contenedor7=xmlcontenedor7;
        xml7.onreadystatechange = alertContents7;
        xml7.open('GET', url7, true);
        xml7.send(null);
    }
    function alertContents7() {
        if (xml7.readyState == 4) {
            if (xml7.status == 200) {
                xml_contenedor7.innerHTML=xml7.responseText;
                } else {
                self.status='No se pueden actualizar los mensajes enviados...';
            }
        }

    }
///*********************************************** 8 *************************************************************************
    function xml_inner8(url8,xmlcontenedor8) {createxml(8);
        //xmlcontenedor8.innerHTML=loadingfl;
        xml_contenedor8=xmlcontenedor8;
        xml8.onreadystatechange = alertContents8;
        xml8.open('GET', url8, true);
        xml8.send(null);
    }
    function alertContents8() {
        if (xml8.readyState == 4) {
            if (xml8.status == 200) {
                xml_contenedor8.innerHTML=xml8.responseText;
                } else {
                self.status='No se pueden actualizar los mensajes enviados...';
            }
        }

    }
///*********************************************** 9 *************************************************************************
    function xml_inner9(url9,xmlcontenedor9) {createxml(9);
        //xmlcontenedor9.innerHTML=loadingfl;
        xml_contenedor9=xmlcontenedor9;
        xml9.onreadystatechange = alertContents9;
        xml9.open('GET', url9, true);
        xml9.send(null);
    }
    function alertContents9() {
        if (xml9.readyState == 4) {
            if (xml9.status == 200) {
                xml_contenedor9.innerHTML=xml9.responseText;
                } else {
                self.status='No se pueden actualizar los mensajes enviados...';
            }
        }

    }


	function bprincipal(bp_url)
	{
	    b_principal.url=bp_url;
        //secc1=document.body.getElementById("seccion1");
        xml_inner(bp_url+"?reload="+escape(timer()),b_principal);
        {
            //self.setTimeout("if(b_principal.url=='"+bp_url+"')bprincipal('"+bp_url+"')",(bpreload.time*1000)+5000);
        }
    }

function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

function FormSubmit(SelectedForm)
{
results=new Array();
results['result']='';
results['reload']='';
results['location']='';
s=SelectedForm.getElementsByTagName('input');
postdataText='';
for(i=0;i<=s.length-1;i++)
{
	if(s[i].name!='')postdataText+=s[i].name+'='+s[i].value+'&';
}

s=SelectedForm.getElementsByTagName('textarea');
for(i=0;i<=s.length-1;i++)
{
	if(s[i].name!='')postdataText+=s[i].name+'='+s[i].value+'&';
}

s=SelectedForm.getElementsByTagName('select');
for(i=0;i<=s.length-1;i++)
{
	if(s[i].name!='')postdataText+=s[i].name+'='+s[i].value+'&';
}


postdataText=postdataText.substring(0,postdataText.length-1);

res0=xmlpost_con(SelectedForm.action,postdataText);
res=res0.split("&");
for(i=0;i<=res.length-1;i++)
{
	res2=res[i].split("=");
	results[res2[0]+'']=res2[1];
}
if(results['result']=='')
{
	alert(res0);
}
else
{
	alert(results['result']);
}

if(results['reload']=='ok')location.reload();
if(results['location']!='')location.href=unescape(results['location']);

}

function ParseGET(GETVARS)
{
	arr=new Array();
	
	GETVARS=unescape(GETVARS).split("&");
	for(i=0;i<=GETVARS.length-1;i++)
	{
		indexof=GETVARS[i].lastIndexOf("=");
		vname=GETVARS[i].substring(0,indexof);
		vvalue=GETVARS[i].substring(indexof+1,GETVARS[i].length);
		arr[''+vname]=vvalue;
		//alert(vname+'='+vvalue+'');
	}
	return arr;
}


function NumberFormat(Numero,Decimales,Max,Min)
{
if(Decimales+''=='undefined')Decimales=0;
if(Max+''=='undefined')Max=999999999999;
if(Min+''=='undefined')Min=-999999999999;


if(parseInt(Numero)=='NaN')
{
	alert('Este campo es numerico');
	return 0;
}else{}

if(Decimales<1)
{
	return Math.floor(Numero);
}else{}



n = parseFloat(Numero); 

n = Math.round(n * Math.pow(10, Decimales)) / Math.pow(10, Decimales); 
s = String(n) + "." + String(Math.pow(10, Decimales)).substr(1); 
s = s.substr(0, s.indexOf(".") + Decimales + 1);


if(parseFloat(s,Decimales)>=Max)
{
	alert("El numero no deve ser mayor que "+Max);
	return Max;
}else

if(parseFloat(s,Decimales)<=Min)
{
	alert("El numero no deve ser menor que "+Min);
	return Max;
}else


return s; 
} 

function validaNum(texto)
{
	var mailres = texto; 
	var cadena = "1234567890"; 
	var textof="";
	for (var contador = 0 ; contador < texto.length ; contador++)
	{
		if (cadena.indexOf(texto.substr(contador, 1),0) == -1)
		{
			textof=textof+"";
		}
		else
		{
			textof=textof+texto.substr(contador, 1);
		}
	}
	
	return textof; 
} 

function validaChar(texto,Validos)
{
	str="ÑÁÉÍÓÚÀÈÌÒÙ";
	str=str+str.toLowerCase();
	rep="NAEIOUAEIOU";
	rep=rep+rep.toLowerCase();

	str=str.split("");
	rep=rep.split("");
	for(i=0;i<=str.length-1;i++)
	{
		texto=texto.split(str[i]).join(rep[i]);
	}
	
	texto=escape(texto);
	texto=texto.split('%0D%0A').join(" ");
	texto=texto.split('%0A').join(" ");
	texto=texto.split('%0D').join(" ");
	texto=unescape(texto);
	var mailres = texto;
	
	if(Validos+""=="undefined")
	{
		var cadena = "$%&/?¿,:;*+[]@._-() abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890";
	}
	else
	{
		var cadena = Validos;
	}
	 
	var textof="";
	prevchr="";
	for (var contador = 0 ; contador < texto.length ; contador++)
	{
		chr=
		Indof=cadena.indexOf(texto.substr(contador, 1),0);
		if (Indof == -1)
		{
			//alert(Indof);
			if(prevchr==" "){}else{textof=textof+" ";}
			prevchr=" ";
		}
		else
		{
			//alert(Indof);
			tx=texto.substr(contador, 1);
			
			if(prevchr==" " && tx==" "){}else{textof=textof+tx;}
			prevchr=tx;
		}
	}
	
	return textof; 
}

