function urldecode (str) {
    // Decodes URL-encoded string  
    // 
    // version: 1004.2314
    // discuss at: http://phpjs.org/functions/urldecode    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brett-zamir.me)    // +      input by: travc
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Lars Fischer
    // +      input by: Ratheous    // +   improved by: Orlando
    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
    // +      bugfixed by: Rob
    // %        note 1: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // %        note 2: Please be aware that this function expects to decode from UTF-8 encoded strings, as found on    // %        note 2: pages served as UTF-8
    // *     example 1: urldecode('Kevin+van+Zonneveld%21');
    // *     returns 1: 'Kevin van Zonneveld!'
    // *     example 2: urldecode('http%3A%2F%2Fkevin.vanzonneveld.net%2F');
    // *     returns 2: 'http://kevin.vanzonneveld.net/'    // *     example 3: urldecode('http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a');
    // *     returns 3: 'http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a'
    
    return decodeURIComponent(str.replace(/\+/g, '%20'));
}

function number_format(number, decimals, dec_point, thousands_sep) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://getsprink.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +     bugfix by: Howard Yeend
    // +    revised by: Luke Smith (http://lucassmith.name)
    // +     bugfix by: Diogo Resende
    // +     bugfix by: Rival
    // +      input by: Kheang Hok Chin (http://www.distantia.ca/)
    // +   improved by: davook
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Jay Klehr
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Amir Habibi (http://www.residence-mixte.com/)
    // +     bugfix by: Brett Zamir (http://brett-zamir.me)
    // +   improved by: Theriault
    // *     example 1: number_format(1234.56);
    // *     returns 1: '1,235'
    // *     example 2: number_format(1234.56, 2, ',', ' ');
    // *     returns 2: '1 234,56'
    // *     example 3: number_format(1234.5678, 2, '.', '');
    // *     returns 3: '1234.57'
    // *     example 4: number_format(67, 2, ',', '.');
    // *     returns 4: '67,00'
    // *     example 5: number_format(1000);
    // *     returns 5: '1,000'
    // *     example 6: number_format(67.311, 2);
    // *     returns 6: '67.31'
    // *     example 7: number_format(1000.55, 1);
    // *     returns 7: '1,000.6'
    // *     example 8: number_format(67000, 5, ',', '.');
    // *     returns 8: '67.000,00000'
    // *     example 9: number_format(0.9, 0);
    // *     returns 9: '1'
    // *    example 10: number_format('1.20', 2);
    // *    returns 10: '1.20'
    // *    example 11: number_format('1.20', 4);
    // *    returns 11: '1.2000'
    // *    example 12: number_format('1.2000', 3);
    // *    returns 12: '1.200'
    var n = !isFinite(+number) ? 0 : +number, 
        prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
        sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
        dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
        s = '',
        toFixedFix = function (n, prec) {
            var k = Math.pow(10, prec);
            return '' + Math.round(n * k) / k;
        };
    // Fix for IE parseFloat(0.55).toFixed(0) = 0;
    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
    if (s[0].length > 3) {
        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
    }
    if ((s[1] || '').length < prec) {
        s[1] = s[1] || '';
        s[1] += new Array(prec - s[1].length + 1).join('0');
    }
    return s.join(dec);
}

function str_replace (search, replace, subject, count) {
    // Replaces all occurrences of search in haystack with replace  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/str_replace
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   input by: Oleg Eremeev
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Oleg Eremeev
    // %          note 1: The count parameter must be passed as a string in order
    // %          note 1:  to find a global variable in which the result will be given
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
    var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
            f = [].concat(search),
            r = [].concat(replace),
            s = subject,
            ra = r instanceof Array, sa = s instanceof Array;
    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }

    for (i=0, sl=s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j=0, fl=f.length; j < fl; j++) {
            temp = s[i]+'';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length-s[i].length)/f[j].length;}
        }
    }
    return sa ? s : s[0];
}


function makeSelection(frm,ob_name,est)
{
	for (var i = 0; i < frm.elements.length; i++)
	{
        if (frm.elements[i].name == ob_name)
		{
            frm.elements[i].checked = est;
        }
    }
}

function makeSelectionRadio(obj,est)
{
		//alert(obj.length);
	
	for (var i = 0; i < obj.length; i++)
	{
		var rd = obj.elements[i];
		
		if (rd.type == 'radio' && rd.name == obj.name)
		{
			rd.checked = est;
		}
	}
}



function roundjs ( val, precision ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +    revised by: Onno Marsman
    // *     example 1: round(1241757, -3);
    // *     returns 1: 1242000
    // *     example 2: round(3.6);
    // *     returns 2: 4
 
    return parseFloat(parseFloat(val).toFixed(precision));
}

function checkNull(inComp, inMsg)
{
  var er_empty = /^$/ 
	while (er_empty.test(inComp.value))
	{
	   alert(inMsg); 
	   inComp.focus(); 
	   return false;
	    
	 }
	 return true
}



function checkEmailb(inEmail)
{
 var er_email1 = /^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/ ;//primer filtro
 var er_email2 = /^([0-9]|[a-z]|[A-Z]|\.|\@|\_|-)+$/ ;//segundo filtro
 var myTest1 =! er_email1.test(inEmail.value); 
 var myTest2 =! er_email2.test(inEmail.value);

    xvar = checkNull(inEmail, "Ingrese por favor su e-mail"); 
	if (!xvar)return false; 
	
	if (inEmail.value.indexOf('@') == -1)
	{
		alert ("Ingrese un e-mail valido"); 
		inEmail.focus(); 
		return false 
	}
	
	if (myTest1 || myTest2) 
	{
		alert('Su e-mail no es Válido\n'
		+'Verifique que este correctamente escrito\n'
		+'Posibles errores:\n'
		+'- Su e-mail contiene caracteres especiales [#$%&8¿?Çñ]\n'
		+'- Su e-mail contiene tildes [áéíóú]\n- Su e-mail contiene espacios en blanco');
		inEmail.focus(); 
		return false;
	}
	return true
}


function checkList(inComp, inMsg){
	if(inComp.options[inComp.selectedIndex].value == -1)
	{
		alert(inMsg);
		inComp.focus();
		return false;
	}
	return true;
}


function confirmLink(f,g)
{
		e = confirm(g);
		return e
		
}

function msgBox(){  

	myWidth	 = 400;
	myHeight = 40;
	myLeft = (window.screen.width / 2) - (myWidth / 2)
	myTop = (window.screen.height / 2) - (myHeight / 2)
	
	if (window.showModalDialog) {
		modal = window.showModalDialog("msgbox.php","name","dialogWidth: "+ myWidth +"px; dialogHeight:124px; center:yes; help:no; scroll:no; status:no");
	}else{
		modal = window.open("msgbox.php","name","width =" + myWidth + ", height =" + myHeight + ", left =" + myLeft + ", top =" + myTop +", toolbar=no, directories=no, status=no, linemenubar=no, scrollbars=no, resizable=no, modal=yes");
	}

}

/* Version 2.0 - 08/03/2005  */
function trim(str)
{
	if (typeof str != "string") return str;
	str = str.replace(/(^\s*)|(\s*$)/g,"");
	return str;
}

//popups emergentes
var w_emergenet = 425;
function emergentes(page, params, name, myWidth, myHeight)
{
	myLeft = (window.screen.width / 2) - (myWidth / 2);
	myTop = (window.screen.height / 2) - (myHeight / 2)	- 25;
	scrollbars = 0;	
	url_href = SERVER_NAME+"emergente.php?PG="+page+"&"+params;	
	windowsopen2(url_href,name,myWidth,myHeight)
}

function emergentesini(page, params, name, myWidth, myHeight)
{
	myLeft = (window.screen.width / 2) - (myWidth / 2)
	myTop = (window.screen.height / 2) - (myHeight / 2)	
	scrollbars = 1;
	//alert(SERVER_NAME);
	/*myWindow = window.open(SERVER_NAME+"emergente.php?PG="+page+"&"+params, name, "width =" + myWidth + ", height =" + myHeight + " , left =" + myLeft + ", top =" + myTop +", toolbar=0, resizable=0, scrollbars="+scrollbars+", status=no, menubar=no")
	myWindow.focus();*/
	url_href = SERVER_NAME+"emergente.php?PG="+page+"&"+params;
	//myLightWindow.activateWindow({href: url_href, height:(myHeight+25)});
	//myLightWindow.activateWindow({href: url_href, height:(myHeight+110),width:w_emergenet});
	windowsopen2(url_href,name,myWidth,myHeight)
}

function emergentesAdm(params, name, myWidth, myHeight, isdialog)
{
	myLeft = (window.screen.width / 2) - (myWidth / 2)
	myTop = (window.screen.height / 2) - (myHeight / 2)
	
	scrollbars = 1;
	if (window.showModalDialog && isdialog != 1) {
		//myWindow = window.showModalDialog("msgbox.php","name","dialogWidth: "+ myWidth +"px; dialogHeight:124px; center:yes; help:no; scroll:no; status:no");
		myWindow = window.showModalDialog(SERVER_NAME+"index.php?emergente=1&dialog=1&"+params, name, "dialogWidth =" + myWidth + "px; dialogHeight =" + myHeight + "px ; center:yes; help:no; scroll:"+scrollbars+"; status:no");
		document.location.reload();
		
	}else{
		myWindow = window.open(SERVER_NAME+"index.php?emergente=1&dialog=0&"+params, name, "width =" + myWidth + ", height =" + myHeight + " , left =" + myLeft + ", top =" + myTop +", toolbar=0, resizable=0, scrollbars="+scrollbars+", status=no, menubar=no")
		myWindow.focus();
	}	
}

function emergentesAdmPage(page,params, name, myWidth, myHeight)
{
	myLeft = (window.screen.width / 2) - (myWidth / 2)
	myTop = (window.screen.height / 2) - (myHeight / 2) - 30
	
	scrollbars = 0;
	
	myWindow = window.open(SERVER_NAME+"pages/"+page+".php?emergente=1&"+params, name, "width =" + myWidth + ", height =" + myHeight + " , left =" + myLeft + ", top =" + myTop +", toolbar=0, resizable=0, scrollbars="+scrollbars+", status=no, menubar=no")
	myWindow.focus();
}

function emergente(page, params, name, myWidth, myHeight)
{
	myLeft = (window.screen.width / 2) - (myWidth / 2)
	myTop = (window.screen.height / 2) - (myHeight / 2)	
	scrollbars = 0;
	myWindow = window.open(SERVER_NAME+"emergente.php?PGE="+page+"&"+params, name, "width =" + myWidth + ", height =" + myHeight + " , left =" + myLeft + ", top =" + myTop +", toolbar=0, resizable=0, scrollbars="+scrollbars+", status=no, menubar=no")
	myWindow.focus();
}

function emergenteP(page, params, name, myWidth, myHeight)
{
	myLeft = (window.screen.width / 2) - (myWidth / 2)
	myTop = (window.screen.height / 2) - (myHeight / 2)	
	scrollbars = 0;
	myWindow = window.open(SERVER_NAME+"index.php?emergente=1&PG="+page+"&"+params, name, "width =" + myWidth + ", height =" + myHeight + " , left =" + myLeft + ", top =" + myTop +", toolbar=0, resizable=0, scrollbars="+scrollbars+", status=no, menubar=no")
	myWindow.focus();
}

//popups
function windowsopen(url, name, myWidth, myHeight)
{
		
	myLeft = (window.screen.width / 2) - (myWidth / 2)
	myTop = (window.screen.height / 2) - (myHeight / 2)
	myWindow = window.open(url, name, "width =" + myWidth + ", height =" + myHeight + " , left =" + myLeft + ", top =" + myTop +", toolbar=0, resizable=1, scrollbars=yes, status=no, menubar=no")
	myWindow.focus();
}

function windowsopen2(url, name, myWidth, myHeight)
{
	url_href = url;
	
	
	myLeft = (window.screen.width / 2) - (myWidth / 2)
	myTop = (window.screen.height / 2) - (myHeight / 2)
	myWindow = window.open(url_href, name, "width =" + myWidth + ", height =" + myHeight + " , left =" + myLeft + ", top =" + myTop +", toolbar=0, resizable=1, scrollbars=yes, status=no, menubar=no")
	myWindow.focus();
}

function windowsImage(page,img,name){	
 img1 = new Image()
 img1.src = img
 //alert(img1.width+'-'+img1.height);
 url = page+"?img="+img
 //alert(url);
 myWindow = window.open(url,name,"width =" + (img1.width+20) + ", height =" + (img1.height+50) + " ,left =50, top =50, toolbar=no, resizable=no, scrollbars=yes, status=no, menubar=no")
// alert(10);
 myWindow.focus();
}


/*function view(url){
	windows(url, "catalogo", 330, 460);
}*/

function pd(url){
	windows(url, "pd", 300, 235);	
}

//Constructor del objeto XMLHttpRequest
function getHTTPObject() {
	try {
		objetus = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try { 
			objetus= new ActiveXObject ("Microsoft.XMLHTTP");
		} catch (E) {
			objetus= false; 
		} 
	}
	
	if (!objetus && typeof XMLHttpRequest!= 'undefined') {
		objetus = new XMLHttpRequest();
	} 
	
	return objetus
}

//Carga una pagina y la muestra
function view(url, inDIV) {
	var sec = getHTTPObject();
	sec.open("GET", url, true); 
	
	//alert(url);
	sec.onreadystatechange = function() {
		if(sec.readyState == 1)
		{
				document.getElementById(inDIV).innerHTML = "Cargando...";
		}
		if(sec.readyState == 4) 
		{
			if(sec.status == 200) { 
				document.getElementById(inDIV).innerHTML = sec.responseText;
			} else {
				switch(sec.status) {
					case 404:
						alert("404: " + sec.statusText);
						alert("No se encontró URL");
						break;						
					case 414:
						alert("414: " + sec.statusText);					
						alert("Los valores pasados por GET superan los 512");
						break;						
				}
			}
		}
	}
	 sec.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
	sec.send(null);
}

//Carga una pagina y la muestra
function ajaxPost(url, valores, inDIV, isloader,textoloadin,iscloseothers) {
	var sec = getHTTPObject();
	sec.open("POST", url, true); 
	if(iscloseothers)
	{
		//sec.close();
	}
	//alert(url);
	sec.onreadystatechange = function() {
		if(sec.readyState == 1)
		{
				if(!textoloadin)
				{
					textoloadin = "Cargando...";
				}				
				if(isloader == null)
				{
					isloader = true;
				}
				
				//alert(isloader);
				
				if(isloader)
				{
					document.getElementById(inDIV).innerHTML = '<table border="0" align="center" height="100%"><tr><td height="100%" style="color:#527fbf; font-family:Arial; font-size:11px"><img src="'+SERVER_NAME+'public/images/ajax-loader.gif" border="0" /><br>'+textoloadin+'</td></tr></table>'
				}else
				{
					document.getElementById(inDIV).innerHTML = '';
				}
				
				
				
		}
		if(sec.readyState == 4) 
		{
			if(sec.status == 200) { 
				
				
				document.getElementById(inDIV).innerHTML = sec.responseText;
				
			} else {
				switch(sec.status) {
					case 404:
						alert("404: " + sec.statusText);
						alert("No se encontró URL");
						document.getElementById(inDIV).innerHTML = "No se encontró URL";
						document.getElementById(inDIV).innerHTML = "";
						break;						
					case 414:
						alert("414: " + sec.statusText);					
						alert("Los valores pasados por GET superan los 512");
						document.getElementById(inDIV).innerHTML = "Los valores pasados por GET superan los 512";
						document.getElementById(inDIV).innerHTML = "";
						break;						
				}
			}
		}
	}
	sec.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
	sec.send(valores);
}

function ajaxSetCountGusta(url, valores,inDiv) {
	var sec = getHTTPObject();
	sec.open("POST", url, true);
	sec.onreadystatechange = function() {
		if(sec.readyState == 1)
		{
			
		}
		if(sec.readyState == 4) 
		{
			if(sec.status == 200)
			{
				document.getElementById(inDiv).innerHTML = sec.responseText;
				//alert(sec.responseText);
			} else {
				switch(sec.status) {
					case 404:
						alert("404: " + sec.statusText);
						alert("No se encontró URL");
						document.getElementById(inDIV).innerHTML = "No se encontró URL";
						document.getElementById(inDIV).innerHTML = "";
						break;						
					case 414:
						alert("414: " + sec.statusText);					
						alert("Los valores pasados por GET superan los 512");
						document.getElementById(inDIV).innerHTML = "Los valores pasados por GET superan los 512";
						document.getElementById(inDIV).innerHTML = "";
						break;						
				}
			}
		}
	}
	sec.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
	sec.send(valores);
}

function sendMailAjax(url, inDIV,isreolad) {
	var sec = getHTTPObject();
	sec.open("GET", url, true); 
	//alert(url);
	sec.onreadystatechange = function() {
		if(sec.readyState == 1)
		{			
			//document.getElementById(inDIV).innerHTML = "Enviando Correos...";
		}
		if(sec.readyState == 4) 
		{
			if(sec.status == 200) { 
				alert(sec.responseText);
				if(isreolad)
				{
					document.location.reload()
				}
			} else {
				switch(sec.status) {
					case 404:
						alert("404: " + sec.statusText);
						alert("No se encontró URL");
						break;						
					case 414:
						alert("414: " + sec.statusText);					
						alert("Los valores pasados por GET superan los 512");
						break;						
				}
			}
		}
	}
	   
	sec.send(null);
}


function viewValidEmail(url,email,inDIVt,inbtnnameideDIVt)
{
	if(checkEmail(email))
	{
		//alert("dd");
		url = url+"?email="+email;
		var sec = getHTTPObject();
		sec.open("GET", url, true); 
		//alert(url);
		sec.onreadystatechange = function() {
			if(sec.readyState == 1)
			{
					document.getElementById(inDIVt).innerHTML = "Validando...";
			}
			if(sec.readyState == 4) 
			{
				if(sec.status == 200) {
					respot = sec.responseText;
					if(respot == "1")
					{
						document.getElementById(inDIVt).innerHTML = "<font color=#006600>Disponible.</font>";
						document.getElementById(inbtnnameideDIVt).disabled = false;
						
					}else
					{
						document.getElementById(inDIVt).innerHTML = "<font color=#990000>"+respot+"</font>";				
						document.getElementById(inbtnnameideDIVt).disabled = true;
					}
					//document.getElementById(inDIVt).innerHTML = "<font color=#990000>"+respot+"</font>";
				} else {
					switch(sec.status) {
						case 404:
							alert("404: " + sec.statusText);
							alert("No se encontró URL "+url);
							break;						
						case 414:
							alert("414: " + sec.statusText);					
							alert("Los valores pasados por GET superan los 512");
							break;						
					}
				}
			}
		}
		   
		sec.send(null);
	}else
	{
			document.getElementById(inDIVt).innerHTML = "<font color=#990000>No válido.</font>";
			document.getElementById(inbtnnameideDIVt).disabled = true;
	}
}


function viewValidLogin(url,inDIVt,inbtnnameideDIVt) {
	var sec = getHTTPObject();
	sec.open("GET", url, true); 
	//alert(url);
	sec.onreadystatechange = function() {
		if(sec.readyState == 1)
		{
				document.getElementById(inDIVt).innerHTML = "Validando...";
		}
		if(sec.readyState == 4) 
		{
			if(sec.status == 200) {
				respot = sec.responseText;
				if(respot == "1")
				{
					document.getElementById(inDIVt).innerHTML = "<font color=#006600>Disponible.</font>";
					document.getElementById(inbtnnameideDIVt).disabled = false;
					
				}else
				{
					document.getElementById(inDIVt).innerHTML = "<font color=#990000>"+respot+"</font>";				
					document.getElementById(inbtnnameideDIVt).disabled = true;
				}
			} else {
				switch(sec.status) {
					case 404:
						alert("404: " + sec.statusText);
						alert("No se encontró URL "+url);
						break;						
					case 414:
						alert("414: " + sec.statusText);					
						alert("Los valores pasados por GET superan los 512");
						break;						
				}
			}
		}
	}
	   
	sec.send(null);
}

function viewValidDNI(url,inDIVt,inbtnnameideDIVt) {
	var sec = getHTTPObject();
	sec.open("GET", url, true); 
	//alert(url);
	sec.onreadystatechange = function() {
		if(sec.readyState == 1)
		{
				document.getElementById(inDIVt).innerHTML = "Validando DNI...";
		}
		if(sec.readyState == 4) 
		{
			if(sec.status == 200) {
				respot = sec.responseText;
				if(respot == "1")
				{
					document.getElementById(inDIVt).innerHTML = "<font color=#006600>El Número de DNI no está registrado. puede continuar.</font>";
					document.getElementById(inbtnnameideDIVt).disabled = false;
					
				}else
				{
					document.getElementById(inDIVt).innerHTML = "<font color=#990000>"+respot+"</font>";				
					document.getElementById(inbtnnameideDIVt).disabled = true;
				}
			} else {
				switch(sec.status) {
					case 404:
						alert("404: " + sec.statusText);
						alert("No se encontró URL "+url);
						break;						
					case 414:
						alert("414: " + sec.statusText);					
						alert("Los valores pasados por GET superan los 512");
						break;						
				}
			}
		}
	}
	   
	sec.send(null);
}


function viewValidCodePartToChange(url,inDIVt,inbtnnameideDIVt) {
	var sec = getHTTPObject();
	sec.open("GET", url, true); 
	//alert(url);
	sec.onreadystatechange = function() {
		if(sec.readyState == 1)
		{
				document.getElementById(inDIVt).innerHTML = "Validando...";
		}
		if(sec.readyState == 4) 
		{
			if(sec.status == 200) {
				respot = sec.responseText;
				if(respot != "1")
				{
					document.getElementById(inDIVt).innerHTML = "<font color=#990000>"+respot+"</font>";					
					document.getElementById(inbtnnameideDIVt).disabled = true;
					
				}else
				{
					document.getElementById(inDIVt).innerHTML = "<font color=#006600>Ok</font>";
					document.getElementById(inbtnnameideDIVt).disabled = false;
					
				}
			} else {
				switch(sec.status) {
					case 404:
						alert("404: " + sec.statusText);
						alert("No se encontró URL "+url);
						break;						
					case 414:
						alert("414: " + sec.statusText);					
						alert("Los valores pasados por GET superan los 512");
						break;						
				}
			}
		}
	}
	   
	sec.send(null);
}


/*requeridos*/

function cloneObj(obj){
	return get(obj).cloneNode(true);
}
function get(obj) {
  return document.getElementById(obj);
}

/**
 * Opens calendar window.
 *
 * @param   string      calendar.php parameters
 * @param   string      form name
 * @param   string      field name
 * @param   string      edit type - date/timestamp
 */
function openCalendar(params, form, field, type) {
    window.open("./calendar.php?" + params, "calendar", "width=400,height=200,status=yes");
    dateField = eval("document." + form + "." + field);
    dateType = type;
}

//Mas en: http://javascript.espaciolatino.com/
//Objeto oNumero
function oNumero(numero)
{
	//Propiedades
	this.valor = numero || 0
	this.dec = -1;
	//Métodos
	this.formato = numFormat;
	this.ponValor = ponValor;
	//Definición de los métodos
	
	function ponValor(cad)
	{
		if (cad =='-' || cad=='+') return
		if (cad.length ==0) return
		if (cad.indexOf('.') >=0)
			this.valor = parseFloat(cad);
		else
			this.valor = parseInt(cad);
	}

function numFormat(dec, miles)
{
	var num = this.valor, signo=3, expr;
	var cad = ""+this.valor;
	var ceros = "", pos, pdec, i;
	for (i=0; i < dec; i++)
		ceros += '0';
		pos = cad.indexOf('.')
		if (pos < 0)
	    	cad = cad+"."+ceros;
		else
    	{
		    pdec = cad.length - pos -1;
		    if (pdec <= dec)
        	{
		        for (i=0; i< (dec-pdec); i++)
        		    cad += '0';
		    }
		    else
        	{
				num = num*Math.pow(10, dec);
				num = Math.round(num);
				num = num/Math.pow(10, dec);
				cad = new String(num);
	        }
    	}
		pos = cad.indexOf('.')
		if (pos < 0) pos = cad.lentgh
		if (cad.substr(0,1)=='-' || cad.substr(0,1) == '+')
	       signo = 4;
		if (miles && pos > signo)
		    do{
        	expr = /([+-]?\d)(\d{3}[\.\,]\d*)/
	        cad.match(expr)
    	    cad=cad.replace(expr, RegExp.$1+','+RegExp.$2)
        	}
			while (cad.indexOf(',') > signo)
		    if (dec<=0) cad = cad.replace(/\./,'')
        		return cad;
			}
	}//Fin del objeto oNumero:

function formateranumero(textfield)
{
	var numero = new oNumero(textfield.value);
	textfield.value = numero.formato(0, true);
}

function formateraNumIn(num,decimales)
{
	var numero = new oNumero(num);
	return numero.formato(decimales, true);
}


function disabledAllElements(frm)
{
		if (frm.elements.length) 
		for (var i = 0; i < frm.elements.length; i++){

			var obj = frm.elements[i];			
			switch (obj.type){
				
				case 'text':									
				case 'file':										
				case 'password':									
				case 'textarea':				
				case 'radio':				
				case 'checkbox':
				case 'select-one':
					obj.disabled = true;
			}
		}

}


function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}

function printswftransparent(ruta, ancho, alto)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ancho+'" height="'+alto+'">');
	document.write('  <param name="movie" value="'+ruta+'" />');
	document.write('  <param name="quality" value="high" />');
	document.write('  <PARAM NAME=wmode VALUE=transparent />');
	document.write('  <PARAM NAME=bgcolor VALUE=#FFFFFF>');
	document.write('  <embed src="'+ruta+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode=transparent bgcolor=#FFFFF type="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" width="'+ancho+'" height="'+alto+'"></embed>');
	document.write('</object>');
}

function printswf(ruta, ancho, alto)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ancho+'" height="'+alto+'">');
	document.write('  <param name="movie" value="'+ruta+'" />');
	document.write('  <param name="quality" value="high" />');
	document.write('  <embed src="'+ruta+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ancho+'" height="'+alto+'"></embed>');
	document.write('</object>');
}

