function PageQuery(q) {
		if(q.length > 1) 
			this.q = q.substring(1, q.length);
		else 
			this.q = null;
		this.keyValuePairs = new Array();
		if(q) {
			for(var i=0; i < this.q.split("&").length; i++) {
				this.keyValuePairs[i] = this.q.split("&")[i];
			}
		}
		this.getKeyValuePairs = function() { return this.keyValuePairs; }
		this.getValue = function(s) {
			for(var j=0; j < this.keyValuePairs.length; j++) {
				if(this.keyValuePairs[j].split("=")[0] == s)
					return this.keyValuePairs[j].split("=")[1];
			}
			return false;
		}
		this.getParameters = function() {
			var a = new Array(this.getLength());
			for(var j=0; j < this.keyValuePairs.length; j++) {
				a[j] = this.keyValuePairs[j].split("=")[0];
			}
			return a;
		}
		this.getLength = function() { return this.keyValuePairs.length; }
	}

function queryString(key){
	var page = new PageQuery(window.location.search);
	return unescape(page.getValue(key));
}

document.write('<script type="text/javascript" src="/vistas/js/languages.php' + ( queryString('lang') != 'false' ? '?lang=' + queryString('lang'):'') + '"></script>');

function getMessage(strMsgId) {
	if (typeof arrLanguages != 'undefined') {
		if (typeof arrLanguages[strMsgId] != 'undefined') {
			 var i = 0, a = arguments, args = Array(arguments.length);
			 a[0]=arrLanguages[strMsgId];
			 if (a[0] == '') {
				return '<Message not set>';
			 }
			 while (i < args.length) args[i] = 'a[' + (i++) + ']';
			 return (eval('sprintf(' + args + ')'));
		} else {
			return '<Message not set>';
		}
	}
	return '<Message not set>';
}

document.write('<script type="text/javascript" src="/vistas/js/prototype.js"></script>');
document.write('<script type="text/javascript" src="/vistas/js/appobj.js"></script>');
document.write('<script type="text/javascript" src="/vistas/js/sprintf.js"></script>');
document.write('<script type="text/javascript" src="/vistas/js/windows_js_1.3/javascripts/effects.js"></script>');
document.write('<script type="text/javascript" src="/vistas/js/windows_js_1.3/javascripts/window.js"></script>');
document.write('<script type="text/javascript" src="/vistas/js/windows_js_1.3/javascripts/window_effects.js"></script>');
document.write('<link href="/vistas/js/windows_js_1.3/themes/default.css" rel="stylesheet" type="text/css" > </link>');
//document.write('<link href="/vistas/js/windows_js_1.3/themes/alert.css" rel="stylesheet" type="text/css" > </link>');

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/g,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/g,"");
}


function $V (object) {
	var obj = $(object);
	if (obj) {
		return obj.value; 
	} 
	return obj;
}

//function alert(str) { Dialog.alert('<span align="center">' + str + '</div>', {width:300, okLabel: "Aceptar"}); }


//funcion que permite en una caja de texto determinada, el ingreso de numeros unicamente
/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function defaultOnEmpty(object,value) {

	if (object == '' || object == null) {
		return value;
	}
	return object;

}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert(getMessage('MSG_DATEFORMAT'))
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert(getMessage('MSG_VALMONTHPLIZ'))
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert(getMessage('MSG_VALDAYPLIZ'))
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert(getMessage('MSG_YEARFOURDIFBET')+minYear+ getMessage('MSG_Y') +maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert(getMessage('MSG_VALDATEPLIZ'))
		return false
	}
return true
}

var nav4 = window.Event ? true : false;

function solonumeros ( evt ) { 
	
	// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57 
	var key = nav4 ? evt.which : evt.keyCode;
	
	return (key <= 13 || (key >= 48 && key <= 57));

}

	/****************************************************************************************
	 * This function verifies if a URI is valid.											*
	 * @todo Validar el string de finalizacion de la url									*
	 * @since 07/11/2007																	*
	 * @version 1.01																		*
	 * @param obj Object that contains the URI to validate.									*
	 * @return boolean 																		*
	 ****************************************************************************************/
	function validaURI(obj) {
		var retorno="";
		//var re=/^(ftp|gopher|http(s)?|mailto|news|telnet|tftp):\/\/S+.(com|net|org|info|biz|ws|us|tv|cc)/;
//		var re0=/^(ftp|gopher|http(s)?|mailto|news|telnet|tftp):\/\//;
		//var re=/.(com|net|org|info|biz|ws|us|tv|cc|uy)/;		
		var invalida=false;
		var url=obj.value;
		if(url!=""){
				if(!/^(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(url)){
					invalida=true;
				}else{
					retorno=true;
//					return true;
//					while (url.indexOf("\\") != -1){
//						url = url.slice(url.indexOf("\\") + 1);
//						
//					}
//					var ultimaparteurl = url.slice(url.indexOf(".")).toLowerCase();		
//					
//					if (re.test(ultimaparteurl)) {
//						return true;
//					}else{
//						invalida=true;
//					}
				}
				if(invalida){
					//alert(getMessage('MSG_URLINVALID'));
					obj.value="";
					obj.focus();
					retorno=false;
//					return false;				
				}			
		}else{
			retorno=false;
//			return false;
		}
		return retorno;
	}


	function solonumerosdecimales ( evt ) { 
		// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57 
		var key = nav4 ? evt.which : evt.keyCode;
		var objElem = evt.target ? evt.target : evt.srcElement;
		var strValue = objElem.value;
		
		var blnPointExist = false;
		if(strValue.indexOf('.') >= 0){
			blnPointExist = true;
		}
		return (key <= 13 || (key >= 48 && key <= 57) || (key == 46 && !blnPointExist));
	}

	var windowRef;
	//Abre un popup
	function MM_openBrWindow ( theURL , winName , features ) { //v2.0
	  windowRef = window.open ( theURL , winName , features ) ;
	}

	//Imprime todo el contenido de una pagina
	function Imprimir() {
		window.print();
	}

	//Cierra el Popup abierto o ventana abierta
	function Cerrar() {
		window.close();
	}

	//Vuelve a la pagina anterior
	function Volver() {
		window.history.go(-1);
	}


//Realiza la validacion del control que se le pasa como parametro en pObj, valida si esta vacio o no y ademas controla que el dato ingresado sea del tipo pTipo, sino devuelve "false" y ademas genera un mensaje de error.
function VerificarForm ( pObj , pControl , pTipo ) {
	pObj = document.getElementById ( pObj ) ;
	if ( (pObj.value.trim() == '' || pObj.value == null || typeof pObj.value == 'undefined') && pTipo != 'validmail' && pTipo != 'validdate') {
		alert(pControl + ' ' + getMessage('MSG_ESREQUERIDO'));
		pObj.focus();
		return false;
	} else {
		//Ahora debo corroborar que el dato sea del tipo que se especifica en el parametro pTipo
		switch ( pTipo ) {
			case "mail":
				//Corroborar que el dato sea una direccion de email valida
				
				if ( pObj.value.indexOf ('@', 0) == -1 || pObj.value.indexOf ('.' , 0) == -1 ) {
					
					alert(pControl+' '+getMessage('MSG_VALMAIL'));
					
					pObj.focus();
					
					return false ;
		
				} else {
					
					return true ;
				
				}
				
				break;

			case "validmail":
				
				if (pObj.value == '') return true;

				if ( pObj.value.indexOf ('@', 0) == -1 || pObj.value.indexOf ('.' , 0) == -1 ) {
					
					alert(pControl + ' '+getMessage('MSG_VALMAIL'));
					
					pObj.focus();
					
					return false ;
		
				} else {
					
					return true ;
				
				}
				
				break;			

			case 'date':
					
			case 'validdate':
				if (pObj.value == '') return true;
			case 'date':
				if (!isDate(pObj.value)) {
					pObj.focus();
					return false;
				}
				return true;
				break;
			case "int":
				
				//Corroborar que el dato sea un valor entero
				
				break;
		}
		
		return true;
		
	}
	
}

//Funcion que inicializa el objeto ajax
function initTGAjax(){

	var ajax=false;

	/*@cc_on @*/
	
	/*@if (@_jscript_version >= 5)
	
	try {
	
	ajax = new ActiveXObject("Msxml2.XMLHTTP");
	
	} catch (e) {
	
		try {
	
	ajax = new ActiveXObject("Microsoft.XMLHTTP");
	
	} catch (E) {
	
	ajax = false;
	
	}
	
	}
	
	@end @*/
	
	if (!ajax && typeof XMLHttpRequest!='undefined') {
	
		ajax = new XMLHttpRequest();
	
	}
	
	return ajax;
}

//Funcion que coloca en el divId el resultado del archivo url
function TGAjax ( url , divId ) {

//	var ajax = initTGAjax() ;    
//
//	var obj = document.getElementById( divId ) ;
//
//	ajax.open ( "GET" , url ) ;
//	
//	ajax.onreadystatechange = function() {
//
//		if (ajax.readyState == 4 && ajax.status == 200) {
//
//			obj.innerHTML = ajax.responseText ;
//			
//		}
//	}
//	
//	ajax.send(null);

	var options = {
				method: 'get',
				evalScripts: true
				};

	new Ajax.Updater(divId, url, options)
	
}

//Funcion que permite comparar que los valores de 2 controles sean identicos para poder enviar el formulario. Esta funcion es muy util a la hora de corroborar confirmaciones de campos
function CompararCampos ( pCampo1 , pLeyendaCampo1 , pCampo2 ) {
	
	pObj1 = document.getElementById ( pCampo1 ) ;
	
	pObj2 = document.getElementById ( pCampo2 ) ;
	
	if ( pObj1.value != pObj2.value ) {
		
		//Si los valores de los campos a comparar son distintos, se devuelve 'false' y se muestra el mensaje de error
		alert ( pLeyendaCampo1 + getMessage('MSG_NOCOINCONF')) ;
		
		pObj2.focus();
		
		return false ;
		
	} else {
		
		//Si los campos son iguales, se devuelve 'true'
		return true ;
		
	}
	
	
}

function ValidarSeleccionMultiple(strElement, intCantidadMinima){
	var arrElements = new Array();
	if(typeof strElement != 'undefined'){
		/**
		* si es un string puede ser:
		* el name en comun de los checkboxs
		* el name/id del select/list - TODO
		* el name/id del div que contiene a los checks - TODO
		*/
		//si es el name en comun de los checkboxs
		arrElements = document.getElementsByName(strElement);
	}
	
	if(arrElements.length <= 0){
		throw new Error(getMessage('MSG_VALIDELEMENT'));
	}
	
	if(typeof intCantidadMinima == 'undefined' 
		|| intCantidadMinima == null 
		|| parseInt(intCantidadMinima) == 0 
		|| !parseInt(intCantidadMinima)){
			
		intCantidadMinima = 1;
	}
	intCantidadMinima = parseInt(intCantidadMinima);
	
	//code si es un name de checkboxs
	var intMinLeft = intCantidadMinima;
	for(var x = 0; x < arrElements.length; x++){
		if( arrElements[x].type == 'checkbox' 
			&& arrElements[x].checked){
			
			intMinLeft--;
		}
	}
	
	if(intMinLeft <= 0) return true; //esta en 0 por consiguiente estan seleccionado el minimo
	
	return false;
}

// Class: Dump
// Author: Shuns (www.netgrow.com.au/files)
// Last Updated: 10/10/06
// Version: 1.1
var_dump=function(object, showTypes){
	var dump='';
	var st=typeof showTypes=='undefined' ? true : showTypes;
	var now = new Date(  );  
	var winName='dumpWin' + now.toString();
	var browser=_dumpIdentifyBrowser();
	var w=760;
	var h=500;
	var leftPos=screen.width ?(screen.width-w)/ 2 : 0;var topPos=screen.height ?(screen.height-h)/ 2 : 0;
	var settings='height='+h+',width='+w+',top='+topPos+',left='+leftPos+',scrollbars=yes,menubar=yes,status=yes,resizable=yes';
	var title='.:: Dump | ' + now.toString() + ' | Fuck You! ::.';
	var script='function tRow(s){t=s.parentNode.lastChild;tTarget(t, tSource(s));}function tTable(s){var switchToState=tSource(s);var table=s.parentNode.parentNode;for(var i=1;i < table.childNodes.length;i++){t=table.childNodes[i];if(t.style){tTarget(t, switchToState);}}}function tSource(s){if(s.style.fontStyle=="italic"||s.style.fontStyle==null){s.style.fontStyle="normal";s.title="click to collapse";return "open";}else{s.style.fontStyle="italic";s.title="click to expand";return "closed";}}function tTarget(t, switchToState){if(switchToState=="open"){t.style.display="";}else{t.style.display="none";}}';
	dump+=(/string|number|undefined|boolean/.test(typeof(object))||object==null)? object : recurse(object, typeof object);
	winName=window.open('', winName, settings);
	if(browser.indexOf('ie')!=-1||browser=='opera'||browser=='ie5mac'||browser=='safari'){winName.document.write('<html><head><title> '+title+' </title><script type="text/javascript">'+script+'</script><head>');winName.document.write('<body>'+dump+'</body></html>');}else{winName.document.body.innerHTML=dump;winName.document.title=title;var ffs=winName.document.createElement('script');ffs.setAttribute('type', 'text/javascript');ffs.appendChild(document.createTextNode(script));winName.document.getElementsByTagName('head')[0].appendChild(ffs);}winName.focus();function recurse(o, type){var i;var j=0;var r='';type=_dumpType(o);switch(type){case 'regexp':var t=type;r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_dumpStyles(t,'td-value')+'><table'+_dumpStyles('arguments','table')+'><tr><td'+_dumpStyles('arguments','td-key')+'><i>RegExp: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case 'date':var t=type;r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_dumpStyles(t,'td-value')+'><table'+_dumpStyles('arguments','table')+'><tr><td'+_dumpStyles('arguments','td-key')+'><i>Date: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case 'function':var t=type;var a=o.toString().match(/^.*function.*?\((.*?)\)/im);var args=(a==null||typeof a[1]=='undefined'||a[1]=='')? 'none' : a[1];r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_dumpStyles(t,'td-value')+'><table'+_dumpStyles('arguments','table')+'><tr><td'+_dumpStyles('arguments','td-key')+'><i>Arguments: </i></td><td'+_dumpStyles(type,'td-value')+'>'+args+'</td></tr><tr><td'+_dumpStyles('arguments','td-key')+'><i>Function: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case 'domelement':var t=type;r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>Node Name: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.nodeName.toLowerCase()+'</td></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>Node Type: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.nodeType+'</td></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>Node Value: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.nodeValue+'</td></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>innerHTML: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.innerHTML+'</td></tr>';j++;break;}if(/object|array/.test(type)){for(i in o){var t=_dumpType(o[i]);if(j < 1){r+='<table'+_dumpStyles(type,'table')+'><tr><th colspan="2"'+_dumpStyles(type,'th')+'>'+type+'</th></tr>';j++;}if(typeof o[i]=='object' && o[i]!=null){r+='<tr><td'+_dumpStyles(type,'td-key')+'>'+i+(st ? ' ['+t+']' : '')+'</td><td'+_dumpStyles(type,'td-value')+'>'+recurse(o[i], t)+'</td></tr>';}else if(typeof o[i]=='function'){r+='<tr><td'+_dumpStyles(type ,'td-key')+'>'+i+(st ? ' ['+t+']' : '')+'</td><td'+_dumpStyles(type,'td-value')+'>'+recurse(o[i], t)+'</td></tr>';}else{r+='<tr><td'+_dumpStyles(type,'td-key')+'>'+i+(st ? ' ['+t+']' : '')+'</td><td'+_dumpStyles(type,'td-value')+'>'+o[i]+'</td></tr>';}}}if(j==0){r+='<table'+_dumpStyles(type,'table')+'><tr><th colspan="2"'+_dumpStyles(type,'th')+'>'+type+' [empty]</th></tr>';}r+='</table>';return r;};};_dumpStyles=function(type, use){var r='';var table='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;cell-spacing:2px;';var th='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;text-align:left;color: white;padding: 5px;vertical-align :top;cursor:hand;cursor:pointer;';var td='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;vertical-align:top;padding:3px;';var thScript='onClick="tTable(this);" title="click to collapse"';var tdScript='onClick="tRow(this);" title="click to collapse"';switch(type){case 'string':case 'number':case 'boolean':case 'undefined':case 'object':switch(use){case 'table':r=' style="'+table+'background-color:#0000cc;"';break;case 'th':r=' style="'+th+'background-color:#4444cc;"'+thScript;break;case 'td-key':r=' style="'+td+'background-color:#ccddff;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'array':switch(use){case 'table':r=' style="'+table+'background-color:#006600;"';break;case 'th':r=' style="'+th+'background-color:#009900;"'+thScript;break;case 'td-key':r=' style="'+td+'background-color:#ccffcc;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'function':switch(use){case 'table':r=' style="'+table+'background-color:#aa4400;"';break;case 'th':r=' style="'+th+'background-color:#cc6600;"'+thScript;break;case 'td-key':r=' style="'+td+'background-color:#fff;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'arguments':switch(use){case 'table':r=' style="'+table+'background-color:#dddddd;cell-spacing:3;"';break;case 'td-key':r=' style="'+th+'background-color:#eeeeee;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;}break;case 'regexp':switch(use){case 'table':r=' style="'+table+'background-color:#CC0000;cell-spacing:3;"';break;case 'th':r=' style="'+th+'background-color:#FF0000;"'+thScript;break;case 'td-key':r=' style="'+th+'background-color:#FF5757;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'date':switch(use){case 'table':r=' style="'+table+'background-color:#663399;cell-spacing:3;"';break;case 'th':r=' style="'+th+'background-color:#9966CC;"'+thScript;break;case 'td-key':r=' style="'+th+'background-color:#B266FF;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'domelement':switch(use){case 'table':r=' style="'+table+'background-color:#FFCC33;cell-spacing:3;"';break;case 'th':r=' style="'+th+'background-color:#FFD966;"'+thScript;break;case 'td-key':r=' style="'+th+'background-color:#FFF2CC;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;}return r;};_dumpIdentifyBrowser=function(){var agent=navigator.userAgent.toLowerCase();if (typeof window.opera != 'undefined'){return 'opera';} else if (typeof document.all != 'undefined'){if (typeof document.getElementById != 'undefined'){var browser = agent.replace(/.*ms(ie[\/ ][^ $]+).*/, '$1').replace(/ /, '');if(typeof document.uniqueID != 'undefined') {if (browser.indexOf('5.5') != -1){return browser.replace(/(.*5\.5).*/, '$1');}else{return browser.replace(/(.*)\..*/, '$1');}}else{return 'ie5mac';}}}else if(typeof document.getElementById != 'undefined'){if (navigator.vendor.indexOf('Apple Computer, Inc.')!=-1) {return 'safari';}else if(agent.indexOf('gecko')!=-1) {return 'mozilla';}}return false;};_dumpType=function(obj){var t=typeof(obj);if(t=='function'){var f=obj.toString();if((/^\/.*\/[gi]??[gi]??$/).test(f)){return 'regexp';}else if((/^\[object.*\]$/i).test(f)){t='object'}}if(t !='object'){return t;}switch(obj){case null:return 'null';case window:return 'window';case document:return document;case window.event:return 'event';}if(window.event &&(event.type==obj.type)){return 'event';}var c=obj.constructor;if(c !=null){switch(c){case Array:t='array';break;case Date:return 'date';case RegExp:return 'regexp';case Object:t='object';break;case ReferenceError:return 'error';default:var sc=c.toString();var m=sc.match(/\s*function(.*)\(/);if(m !=null){return 'object';}}}var nt=obj.nodeType;if(nt !=null){switch(nt){case 1:if(obj.item==null){return 'domelement';}break;case 3:return 'string';}}if(obj.toString !=null){var ex=obj.toString();var am=ex.match(/^\[object(.*)\]$/i);if(am !=null){var am=am[1];switch(am.toLowerCase()){case 'event':return 'event';case 'nodelist':case 'htmlcollection':case 'elementarray':return 'array';case 'htmldocument':return 'htmldocument';}}}return t;};

	
/***/
function getDataByAjax(objData){
	var strUrl = '/admin/getcomboanidado.php';
	var options = {
		parameters: 'jsonData='+Object.toJSON(objData),
		method: 'post',
		evalScripts: true,
		asynchronous: false
	};
		
	var myAjax = new Ajax.Request(strUrl, options);
	var strResp = myAjax.transport.responseText;
	if(strResp != '')
		strResp = eval('o='+strResp);
	return strResp;
}
/*
data.binding.value
data.binding.text
data.info = {
			'index':{
					value: description
					}
			}
data.selected.index
data.selected.text
data.selected.value
data.defaultfill.value
data.defaultfill.text
data.whenemptydisabled
data.notclear
*/
function fillCboByAjax(objToUpdate, data){
	var objToUpdate = $(objToUpdate);
	var blnOptionSelected = false;
	
	//si no esta seteada reseteamos el combo
	if(!data.notclear)
		objToUpdate.options.length = 0;
	
	if(typeof data.defaultfill != 'undefined' && data.defaultfill.text)
		objToUpdate.options[objToUpdate.options.length] = new Option(data.defaultfill.text, typeof data.defaultfill.value != 'undefined' ? data.defaultfill.value : '');
	
	for (prop in data.info){
		blnOptionSelected = false;
		
		var strOptionValue = null;
		var strOptionText = null;
		
		if(data.info[prop][data.binding.value])
			strOptionValue = data.info[prop][data.binding.value];

		if(data.info[prop][data.binding.text])
			strOptionText = data.info[prop][data.binding.text];
		
		if(strOptionValue && strOptionText){
			if(typeof data.selected.index != 'undefined' && parseInt(data.selected.index) == objToUpdate.options.length)
				blnOptionSelected = true;
			
			if(typeof data.selected.text != 'undefined' && data.selected.text == strOptionText)
				blnOptionSelected = true;
				
			if(typeof data.selected.value != 'undefined' && data.selected.value == strOptionValue)
				blnOptionSelected = true;
				
			objToUpdate.options[objToUpdate.options.length] = new Option(strOptionText, strOptionValue, null, blnOptionSelected);
		}
	}
}

function validatefloat(obj, options){
	if(typeof options == 'undefined') return false;
	
	if(typeof options.integerpart == 'undefined') return false;
	
	var strValue = obj.value;
	if(strValue.length <= 0) return false;
	
	var arrParts = strValue.split('.');
	var blnError = false;
	if(typeof arrParts[0] != 'undefined' && arrParts[0].length > options.integerpart){
		blnError = true;
	}
	
	if(typeof arrParts[1] != 'undefined' && arrParts[1].length > options.decimalpart){
		blnError = true;
	}
	
	if(blnError){
		alert('El valor ingresado esta fuera del rango. El valor puede tener como máximo ' + options.integerpart.toString() + ' números en su parte entera y ' + options.decimalpart.toString() + ' en su parte decimal.');
		new PeriodicalExecuter(function(pe) {
		 	obj.focus();
		 	obj.select();
		    pe.stop();
		}, 1);
		return false;
	}
}

function showWaitAjax(intHeight){
	var strHtml = "<div class=waitingimage align=center style=width:100%;min-height:" + intHeight + "px><img border=0 src=/admin/vistas/images/wait.gif><div class=waitingimagetext>" + getMessage('MSG_CARGANDO') + "...</div></div>";
	return strHtml
}

function GenerarAleatorio() {
	return Math.round(Math.random()*1000)
}

function LimpiarCaja(strControl) {
	if (strControl=='username') {
		strVariable = getMessage('MSG_USUARIO');
	} else {
		strVariable = getMessage('MSG_PASSWORD');
	}
	var control = document.getElementById(strControl);
	if (control.value==strVariable) {
		control.value='';
	}
}

function CheckFormLogin() {
	Retorno = true;
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'username' , getMessage('MSG_USUARIO') , 'txt') ;	
		if (Retorno) {
			strControl = document.getElementById('username');
			if (strControl.value==getMessage('MSG_USUARIO')) {
				alert(getMessage('MSG_USUARIO')+' '+getMessage('MSG_ESREQUERIDO'));
				strControl.value='';
				strControl.focus();
				Retorno = false;
			}
		}
	}
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'pass' , getMessage('MSG_PASSWORD') , 'txt') ;	
		if (Retorno) {
			strControl = document.getElementById('pass');
			if (strControl.value==getMessage('MSG_PASSWORD')) {
				alert(getMessage('MSG_PASSWORD')+' '+getMessage('MSG_ESREQUERIDO'));
				strControl.value='';
				strControl.focus();
				Retorno = false;
			}
		}
	}
	if (Retorno) {
		return true;
	} else {
		return false;
	}
}

function checkFormPagoOnline() {
	Retorno = true;
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'nombre' , getMessage('MSG_NOMBRE') , 'txt') ;
	}
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'apellido' , getMessage('MSG_APELLIDO') , 'txt') ;
	}
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'pais' , getMessage('MSG_PAIS') , 'txt') ;
	}
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'email' , getMessage('MSG_EMAIL') , 'mail') ;
	}
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'concepto' , getMessage('MSG_CONCEPTO') , 'txt') ;
	}
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'importe' , getMessage('MSG_IMPORTE') , 'txt') ;
	}
	if (Retorno) {
		return true;
	} else {
		return false;
	}
}

function EnviarFormularioDecidir() {
	document.getElementById('frmDecidir').submit();	
}

function AbrirVentanaRecuperarPass() {
	/*var win = new Window("recuperarpass",{ title: ":. "+getMessage('MSG_OLVIDOCONTRASENA')+" .:",minimizable:false,maximizable:false,*/
	var win = new Window("recuperarpass",{ title: getMessage(''),minimizable:false,maximizable:false,
			top:70, left:100, width:450, height:300,showEffect:Effect.BlindDown,hideEffect: Effect.SlideUp,
			url: "/olvidopass.php", showEffectOptions: {duration:0.5}, hideEffectOptions: {duration:0.5}})
			win.setDestroyOnClose();
			/*win.setStatusBar(":. Gnathos.net .:")*/
			win.showCenter(true);
			win.setZIndex(100);
}

function EnviarFormRecuperaPass() {
	Retorno = true;
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'emailRecuperarPass' , getMessage('MSG_EMAIL') , 'mail') ;
	}
	return Retorno;
}

function EnvioOKFormRecordarPass() {
	alert(getMessage('MSG_ENVIOOKRECUPERARPASS'))
	CerrarVentanaRecuperarPass();
}

function CerrarVentanaRecuperarPass() {
	top.Windows.close('recuperarpass');
}

function EmailInexistenteRecuperarPass() {
	alert(getMessage('MSG_EMAILINEXISTENTE'));
	window.history.go(-1);
}

function VolverUnNivelAtras() {
	window.history.go(-1);
}

function CampusCuentaDeshabilitada() {
	alert(getMessage('MSG_CAMPUSCUENTADESHABILITADA'));
	VolverUnNivelAtras();
}

function CampusLoginDatosIncorrectos() {
	alert(getMessage('MSG_LOGINFAIL'));
	VolverUnNivelAtras();
}

function CampusLoginDatosCorrectos() {
	document.location.href='/campus.php';
}

function SalirDelCampusVirtual() {
	if(window.confirm(getMessage('MSG_SEGUROSALIRCAMPUS'))) {
		document.location.href='/logoutcampus.php';
	}
}

function checkFormPreInscripcion() {
	Retorno = true;
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'nombre' , getMessage('MSG_NOMBRE') , 'txt') ;
	}
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'apellido' , getMessage('MSG_APELLIDO') , 'txt') ;
	}
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'pais' , getMessage('MSG_PAIS') , 'txt') ;
	}
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'caracttel' , getMessage('MSG_TELEFONO') , 'txt') ;
	}
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'telefono' , getMessage('MSG_TELEFONO') , 'txt') ;
	}
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'email' , getMessage('MSG_EMAILPRINCIPAL') , 'mail') ;
	}
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'medio_publicidad' , getMessage('MSG_COMOCONOCIO') , 'txt') ;
	}
	return Retorno;
}

function PreisncripcionGuardoOK() {
	alert(getMessage('MSG_PREINSCRIPCIONGUARDOOK'));
}

function CheckFormEditarDatos() {
	Retorno = true;
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'nombre' , getMessage('MSG_NOMBRE') , 'txt') ;
	}
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'apellido' , getMessage('MSG_APELLIDO') , 'txt') ;
	}
	if (Retorno) 
    {
		Retorno = VerificarForm ( 'pais' , getMessage('MSG_PAIS') , 'txt') ;
	}
	var pass = document.getElementById('pass1').value;
	if (pass!='' && Retorno) {
		Retorno = VerificarForm ( 'pass2' , getMessage('MSG_NUEVACONTRASENACONFIRMAR') , 'txt') ;
		if (Retorno) {
			var pass2 = document.getElementById('pass2').value;
			if (pass!=pass2) {
				alert(getMessage('MSG_PASSNOCONCIDE'));
				return false;
			}
		}
	}
	if (Retorno) {
		document.location.href='#AnchorComienzoFormulario';
		WaitUpload();
	}
	return Retorno;
}

function GuardoDatosAlumnoOK() {
	alert(getMessage('MSG_GUARDODATOSALUMNOOK'));
	document.location.href='/campus.php?imgflashsuperior=campus';
}

function FormatoUpload ( obj , pListaFiles ) {
	var file = obj.value ;
	file = file.toLowerCase();
	var b = pListaFiles ;
	b = b.toLowerCase();
	var temp = new Array() ;
	temp = b.split ( ',' ) ;
	var acummal = 0 ;
	var acumbien = 0 ;
	while (file.indexOf("\\") != -1){
		file = file.slice(file.indexOf("\\") + 1);
	}
	ext = file.slice(file.indexOf(".")+1).toLowerCase();	
	for ( $a = 0 ; $a < temp.length ; $a++ ) {
		if ( ext !=  temp [ $a ] ) {
			acummal++ ;
		} else {
			acumbien++ ;
		}
	}

	if ( acumbien == 0 ) {
		alert ( getMessage('MSG_ARCHIVOEXTENSION') + pListaFiles ) ;
		//Debo crear un elemento debido a que en IE a un control no le puedo cambiar el value		
		var elemento=document.createElement("input");
		var padre=obj.parentNode;
		elemento.name=obj.name;
		elemento.id=obj.id; 
		elemento.size=obj.size; 
		elemento.maxlength=obj.maxlength;
		elemento.type="file";
		elemento.className="caja";
		elemento.onchange=obj.onchange;
		Element.remove(obj);
		padre.insertBefore(elemento,padre.firstChild);
		//	padre.appendChild(elemento);
		////////////////////////////////////////////////////////////////////////////////////////
		return false ;
	} else {
		return true ;
	}
}

function WaitUpload() { //Oculta el MainDiv y muestra el Div llamado "DivWaitUpload". Esto lo utilizamos para el Upload de los archivos, para cuando en el momento que se esta subiendo el archivo o los archivos, exista una barra de progreso simbolica y no se quede muerta la pagina
	document.getElementById ( 'DivWaitUpload' ).style.display = '';
	document.getElementById ( 'DivMain' ).style.display = 'none';
}

function AbrirVentanaMultipleChoice(intIDSeccion,intIDMultipleChoice) {
	/*var win = new Window("multiple_choice",{ title: ":. "+getMessage('MSG_MULTIPLECHOICE')+" .:",minimizable:false,maximizable:false,*/
	var win = new Window("multiple_choice",{ title: "",minimizable:false,maximizable:false,																
			top:70, left:100, width:350, height:450,showEffect:Effect.BlindDown,hideEffect: Effect.SlideUp,
			url: "/campus_multiple_choice.php?idseccion="+intIDSeccion+"&idmultiplechoice="+intIDMultipleChoice, showEffectOptions: {duration:0.5}, hideEffectOptions: {duration:0.5}})
			win.setDestroyOnClose();
			/*win.setStatusBar(":. Gnathos.net .:")*/
			win.showCenter(true);
			win.setZIndex(100);
}

function CheckFormMultipleChoice() {
	//Compruebo por cada pregunta que tenga por lo menos seleccionada una opcion
	idspreguntas =  document.getElementById('hdnIdsPreguntas').value;
	aIdPreguntas = idspreguntas.split(",");
	for (var i=0;i<aIdPreguntas.length-1;i++) {
		var AlMenosUnaOpcionCheckeada = false;
		intIdPregunta = aIdPreguntas[i];
		var opciones_pregunta = document.getElementsByName('opcion_'+intIdPregunta+'[]') ;
		for (var c=0;c<opciones_pregunta.length;c++) {
			if (opciones_pregunta[c].checked) {
				AlMenosUnaOpcionCheckeada = true;
				break;
			}
		}
		if (AlMenosUnaOpcionCheckeada==false) {
			alert(getMessage('MSG_MULTIPLECHOICESELECCIONARUNAOPCION'));
			return false;
		}
	}
	if(window.confirm(getMessage('MSG_SEGUROENVIARMULTIPLECHOICE'))) {
		return true;
	} else {
		return false;
	}
}

function CerrarVentanaMultipleChoice() {
	top.Windows.close('multiple_choice');
}

function VerResultadoMultipleChoice(intIDMultipleChoice) {
	/*var win = new Window("multiple_choice",{ title: ":. "+getMessage('MSG_MULTIPLECHOICE')+" .:",minimizable:false,maximizable:false,*/
	var win = new Window("multiple_choice",{ title: "",minimizable:false,maximizable:false,
			top:70, left:100, width:350, height:450,showEffect:Effect.BlindDown,hideEffect: Effect.SlideUp,
			url: "/campus_multiple_choice_ver.php?id="+intIDMultipleChoice, showEffectOptions: {duration:0.5}, hideEffectOptions: {duration:0.5}})
			win.setDestroyOnClose();
			/*win.setStatusBar(":. Gnathos.net .:")*/
			win.showCenter(true);
			win.setZIndex(100);
}

function GuardoMultipleChoiceOK() {
	alert(getMessage('MSG_GUARDOMULTIPLECHOICEOK'));
}

function AbrirVentanaTarea(intIDTarea,intIDSeccion) {
	/*var win = new Window("tarea",{ title: ":. "+getMessage('MSG_TAREA')+" .:",minimizable:false,maximizable:false,*/
	var win = new Window("tarea",{ title: "",minimizable:false,maximizable:false,
			top:70, left:100, width:350, height:450,showEffect:Effect.BlindDown,hideEffect: Effect.SlideUp,
			url: "/campus_tarea.php?id="+intIDTarea+"&idseccion="+intIDSeccion, showEffectOptions: {duration:0.5}, hideEffectOptions: {duration:0.5}})
			win.setDestroyOnClose();
			/*win.setStatusBar(":. Gnathos.net .:")*/
			win.showCenter(true);
			win.setZIndex(100);
}

function CerrarVentanaTarea() {
	top.Windows.close('tarea');
}

function CheckFormSolicitarArticulo() {
	Retorno = true;
	if (Retorno) {
		Retorno = VerificarForm ( 'revista' , getMessage('MSG_REVISTA') , 'txt') ;
	}
	if (Retorno) {
		Retorno = VerificarForm ( 'ano' , getMessage('MSG_ANO') , 'txt') ;
	}
	if (Retorno) {
		Retorno = VerificarForm ( 'mes' , getMessage('MSG_MES') , 'txt') ;
	}
	if (Retorno) {
		Retorno = VerificarForm ( 'titulo' , getMessage('MSG_TITULO') , 'txt') ;
	}
	return Retorno;
}

function ArticuloSolicitadoOK() {
	alert(getMessage('MSG_ARTICULOSOLICITADOOK'));
}

function CampusNuestrasFotosEliminarFoto(intIDFoto) {
	if(window.confirm(getMessage('MSG_SEGUROELIMINARFOTO'))) {
		document.location.href="/campus_nuestrasfotos.php?op=eliminar_foto&id="+intIDFoto;
	}
}

function CampusNuestrasFotosAgregarFotos(intIDAlbum) {
	document.getElementById('DivAlbumAgregarFoto_'+intIDAlbum).style.display = '';
}

function CampusVirtualEnviarFotos() {
	document.location.href='#AnchorComienzoFormulario';
	WaitUpload();
}

function CampusNuestrasFotosEditarComentario(intIDFoto) {
	/*var win = new Window("nuestras_fotos_editar_comentario",{ title: ":. "+getMessage('MSG_EDITARCOMENTARIO')+" .:",minimizable:false,maximizable:false,*/
	var win = new Window("nuestras_fotos_editar_comentario",{ title: "",minimizable:false,maximizable:false,
		top:70, left:100, width:350, height:230,showEffect:Effect.BlindDown,hideEffect: Effect.SlideUp,
		url: "/campus_nuestrasfotos_editar_comentario.php?id="+intIDFoto, showEffectOptions: {duration:0.5}, hideEffectOptions: {duration:0.5}})
		win.setDestroyOnClose();
		/*win.setStatusBar(":. Gnathos.net .:")*/
		win.showCenter(true);
		win.setZIndex(100);
}

function CerrarVentanaEdicionComentarioFoto() {
	top.Windows.close('nuestras_fotos_editar_comentario');
}

function GuardoComentarioFotoOK() {
	CerrarVentanaEdicionComentarioFoto();
	alert(getMessage('MSG_COMENTARIOFOTOOK'));
}

function NuestrasFotosCrearAlbum() {
	document.getElementById('DivCrearAlbum').style.display = '';
	document.getElementById('nombre').focus();
}

function CheckFormNuevoAlbumFotos() {
	Retorno = true;
	if (Retorno) {
		Retorno = VerificarForm ( 'nombre' , getMessage('MSG_TITULOALBUM') , 'txt') ;
	}
	if (Retorno) {
		WaitUpload();
		return true;
	} else {
		return false;
	}	
}

function CampusNuestrasFotosEditarAlbum(intIDAlbum) {
	/*var win = new Window("nuestras_fotos_editar_album",{ title: ":. "+getMessage('MSG_EDITARALBUM')+" .:",minimizable:false,maximizable:false,*/
	var win = new Window("nuestras_fotos_editar_album",{ title: "",minimizable:false,maximizable:false,
		top:70, left:100, width:350, height:250,showEffect:Effect.BlindDown,hideEffect: Effect.SlideUp,
		url: "/campus_nuestrasfotos_editar_album.php?id="+intIDAlbum, showEffectOptions: {duration:0.5}, hideEffectOptions: {duration:0.5}})
		win.setDestroyOnClose();
		/*win.setStatusBar(":. Gnathos.net .:")*/
		win.showCenter(true);
		win.setZIndex(100);
}

function CerrarVentanaEdicionAlbum() {
	top.Windows.close('nuestras_fotos_editar_album');
}

function GuardoEdicionAlbumOK() {
	CerrarVentanaEdicionAlbum();
	alert(getMessage('MSG_GUARDOEDICIONALBUMOK'));
}

function CheckFormEdicionAlbumFotos() {
	Retorno = true;
	if (Retorno) {
		Retorno = VerificarForm ( 'nombre' , getMessage('MSG_TITULOALBUM') , 'txt') ;
	}
	return Retorno;
}

function CheckFormFichaCefalogramaLateral() {
	if(window.confirm(getMessage('MSG_DESEAENVIARFICHACEFALOGRAMALATERAL'))) {
		return true;
	} else {
		return false;
	}
}

function AbrirVentanaInfoExtendidaCursos(strCampo,intIDCurso) {
	var win = new Window("cursos_info_extendida",{ title: '',minimizable:false,maximizable:false,
	top:70, left:100, width:682, height:530,showEffect:Effect.BlindDown,hideEffect: Effect.SlideUp,
	url: "/cursos_detalle.php?var="+strCampo+"&idcurso="+intIDCurso, showEffectOptions: {duration:0.5}, hideEffectOptions: {duration:0.5}})
	win.setDestroyOnClose();
	win.showCenter(true);
	win.setZIndex(100);
}

function MostrarVideoCampus(strParams,intAncho,intAlto) {
	var win = new Window("mostrar_videos_campus",{ title: '',minimizable:false,maximizable:false,
	top:70, left:100, width:(intAncho+30), height:(intAlto+30),showEffect:Effect.BlindDown,hideEffect: Effect.SlideUp,
	url: "/campus_mostrar_videos.php?strParams="+encodeURIComponent(strParams)+'&intAncho='+intAncho+'&intAlto='+intAlto,showEffectOptions: {duration:0.5}, hideEffectOptions: {duration:0.5}})
	win.setDestroyOnClose();
	win.showCenter(true);
	win.setZIndex(100);
}

function CheckFormPopupRegistro() {
	Retorno = true;
	if (Retorno) {
		Retorno = VerificarForm ( 'nombre' , getMessage('MSG_NOMBRE') , 'txt') ;
	}
	if (Retorno) {
		Retorno = VerificarForm ( 'apellido' , getMessage('MSG_APELLIDO') , 'txt') ;
	}
	if (Retorno) {
		Retorno = VerificarForm ( 'email' , getMessage('MSG_EMAIL') , 'mail') ;
	}
	if (Retorno) {
		Retorno = VerificarForm ( 'pais' , getMessage('MSG_PAIS') , 'txt') ;
	}
	if (Retorno) {
		MM_showHideLayers('popRegister','','hide');
	}
	return Retorno;
}

function PopupReferCerrar () {
	AppObj.Ajax.updaterAjax('/popup_refer_setcookie.php?rand='+GenerarAleatorio(),'DivSetCookiePopupRefer');
	MM_showHideLayers('popRegister','','hide')
}
