function ValidateForm(form) {
	try {
		form = (!jsGetObject(form)) ? form : jsGetObject(form);
		
		var Icon = form.getAttribute("icon",2);
		if (!Icon) Icon = "alert.png";
		var onBeforeSubmit = form.getAttribute("onbeforesubmit",2);
		var onAfterSubmit = form.getAttribute("onaftersubmit",2);
		var returnSubmit = form.getAttribute("returnsubmit",2);
		if (!returnSubmit) returnSubmit = true;
		var ModalMsg = form.getAttribute("modalwindow",2);
		if (!ModalMsg) ModalMsg = true;
		ModalMsg = (jsIsString(ModalMsg) == true) ? (ModalMsg == "true") ? true : false : ModalMsg;
		
		if (onBeforeSubmit) {
			try {
				if (onBeforeSubmit.indexOf('(') < 0) {
					onBeforeSubmit += "(form);"
				}
				
				if (eval(onBeforeSubmit) == false) {
					return false;	
				}
			} catch(err) {
				jsShowErrors("ValidateForm:onBeforeSubmit", err);
			}
		}
		
		for(i=0; i<form.elements.length; i++) {
			var __obj = form.elements[i];
			if (__obj.type) {
				if (__obj.type != "button" && __obj.type != "submit") {
					validation = __obj.getAttribute("req",2);
					if (!validation) validation = true;
					validation = (jsIsString(validation) == true) ? (validation == "true") ? true : false : validation;
					validationMsg = __obj.getAttribute("msg",2);
					var _elem_type = __obj.type.toLowerCase();
						
					if (__obj.id == "" && __obj.name == "") {
						alert("El Objeto de tipo \"" + _elem_type + "\" debe tener un Id y un Nombre para identificarlo.");
						return false;
					}
					
					var _validation = __obj.getAttribute("validation",2);
					if (_validation) {
						var _validation_s = _validation.split("|");
						var _validation_function = _validation_s[0];
						_validation_function = _validation_function.replace("this", "'" + __obj.name + "'");
						var _validation_msg = _validation_s[1];
						
						try {
							if (!eval(_validation_function)) {
								if (ModalMsg == false) {							
									alert(_validation_msg);
									if(__obj.type != "hidden" && jsGetStyle(__obj, 'display') != 'none' && 
									jsGetStyle(__obj, 'visibility') != 'hidden') {
										__obj.focus();
									}
								} else {
									parent.AlertWinMsg(_validation_msg, "error.png", 0, __obj, "error");
								}
								return false;
							}
						} catch(err) {
							jsShowErrors("ValidateForm:validation", err);
						}
					}
					
					if (validation && validationMsg) {
						var wv = false;
						var _obj_array = document.getElementsByName(__obj.id);
						if (_obj_array && _obj_array.length) {
							for(j=0; j<_obj_array.length; j++) {
								if (_elem_type == "radio" || _elem_type == "checkbox") {
									if (_obj_array[j].checked == true) {
										wv = true;
										break;	
									}
								}
							}
						}
						
						_obj_array = document.getElementsByName(__obj.name);
						if (_obj_array.length == 1) {
							switch (_elem_type) {
								case "select-one":
									wv = (__obj.value.toString() == "0") ? false : true;
									break;
								case "radio", "checkbox":
									wv = (__obj.checked == false) ? false : true;
									break;
								default:
									wv = (__obj.value == "") ? false : true;
									break;
							}
						}
						
						if (wv == false) {
							if (validationMsg == "") validationMsg = "Campo Obligatorio.";
							if (ModalMsg == false) {							
								alert(validationMsg);
								if(__obj.type != "hidden" && jsGetStyle(__obj, 'display') != 'none' && 
								jsGetStyle(__obj, 'visibility') != 'hidden') {
									__obj.focus();
								}
							} else {
								parent.AlertWinMsg(validationMsg, Icon, 0, __obj);
							}
							return false;
						}
					}
				}
			}
		}
		
		if (onAfterSubmit) {
			try {
				if (onAfterSubmit.indexOf('(') < 0) {
					onAfterSubmit += "(form);"
				}
				
				if (eval(onAfterSubmit) == false) {
					return false;	
				}
				//return eval(onAfterSubmit);
			} catch(err) {
				jsShowErrors("ValidateForm:onAfterSubmit", err);
			}
		}
		
		if (returnSubmit == true) {
			form.submit();
		}
		
		DisableFormElements(form);
		
		return false;	
	} catch(err) {
		jsShowErrors("ValidateForm", err);
	}
}


var __last_submit_button_caption;

function DisableFormElements(form) {
	try {
		form = (!jsGetObject(form)) ? form : jsGetObject(form);
		
		document.body.style.cursor = "wait";
		jsSetStyle("ProcesingData", "display", "block");
		var __fieldsets = document.getElementsByTagName("fieldset");
		if (__fieldsets.length) {
			for(i=0; i < __fieldsets.length; i++) {
				__fieldsets[i].style.cursor = "wait";
			}
		}
		
		for(i=0; i<form.elements.length; i++) {
			var __obj = form.elements[i];
			if (__obj.type) {
				if (__obj.type == "submit") {
					__last_submit_button_caption = __obj.value;
					__obj.value = "Espere...";
				}
				__obj.disabled = true;
			}
		}
	} catch(err) {
		jsShowErrors("DisableFormElements", err);
	}
}

function EnableFormElements(form) {
	try {
		form = (!jsGetObject(form)) ? form : jsGetObject(form);
		
		document.body.style.cursor = "default";
		jsSetStyle("ProcesingData", "display", "none");
		var __fieldsets = document.getElementsByTagName("fieldset");
		if (__fieldsets.length) {
			for(i=0; i < __fieldsets.length; i++) {
				__fieldsets[i].style.cursor = "default";
			}
		}
		
		for(i=0; i<form.elements.length; i++) {
			var __obj = form.elements[i];
			if (__obj.type) {
				if (__last_submit_button_caption == "") __last_submit_button_caption = "Guardar";
				if (__obj.type == "submit") __obj.value = __last_submit_button_caption;
				__obj.disabled = false;
			}
		}
	} catch(err) {
		jsShowErrors("EnableFormElements", err);
	}
}


function isEmail(obj) {
	obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
	if (obj) {
		if (obj.value != "") {
			var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
			if (filter.test(obj.value)) {
				return true;
			} else {
				return false;	
			}
		} else {
			return true;	
		}
	} else {
		return false;
	}
}


function isNumeric(obj) {
	try {
		obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
		if (obj) {
			if (obj.value != "") {
				return (parseFloat(obj.value,10)==(obj.value*1));
			} else {
				return true;	
			}
		} else {
			return false;	
		}
	} catch(err) {
		jsShowErrors("isNumeric", err);
	}
}


function jsValidPasswords(obj1,obj2) {
	try {
		var C1 = (!jsGetObject(obj1)) ? obj1 : jsGetObject(obj1);
		var C2 = (!jsGetObject(obj2)) ? obj2 : jsGetObject(obj2);
		
		if (C1 && C2) {
			if (C1.value != "" && C2.value != "") {
				if (C1.value == C2.value) {
					return true;
				}
			} else if (C1.value == "" && C2.value == "") {
				return true;	
			}
		}
		
		return false;
	} catch(err) {
		jsShowErrors("jsValidPasswords", err);
	}
}


function jsKeyAscii(e) {
	return (document.all) ? e.keyCode : e.which;
}


function openWin(eURL,eName,features) {
	window.open(eURL,eName,features);
}


function openCenterWin(eURL,eName,eFeatures,eWidth,eHeight) {
	var _features = "";
	_features = (eFeatures == "") ? "resizable=no,status=no,scrollbars=no" : eFeatures;
	_features += ",width="+eWidth+",height="+eHeight+",left="+((screen.width/2)-(eWidth/2))+",top="+((screen.height/2)-(eHeight/2));
	openWin(eURL,eName,_features);
}


function _CloseOnEsc(e) {
	if (jsKeyAscii(event) == 27) { window.close(); return; }
}


function InitESC() {
	document.body.onkeypress = _CloseOnEsc;
}


function jsToggleDisplay(obj) {
	try {
		if (obj) jsSetStyle(obj, "display", (jsGetStyle(obj, "display") == "none") ? "block" : "none")
	} catch(err) {
		jsShowErrors("jsToggleDisplay", err);
	}
}


function jsClearHTML(sHTML) {
	try {
		sHTML = jsCleanWord(sHTML);
		sHTML = sHTML.replace(/<[^>]*>/gi, "");
		sHTML = sHTML.replace( /\n/gi, "") ;
		sHTML = sHTML.replace(/&nbsp;/gi, "");
		var RegX = new RegExp(String.fromCharCode(10), 'g');
		sHTML = sHTML.replace(RegX, "");
		RegX = new RegExp(String.fromCharCode(13), 'g');
		sHTML = sHTML.replace(RegX, "");
		return sHTML;
	} catch(err) {
		jsShowErrors("jsClearHTML", err);
	}
}


function jsCleanWord(html) {
	try {
		html = html.replace(/<o:p>\s*<\/o:p>/g, "") ;
		html = html.replace(/<o:p>.*?<\/o:p>/g, "&nbsp;") ;
		
		// Remove mso-xxx styles.
		html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, "" ) ;
	
		// Remove margin styles.
		html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, "" ) ;
		html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;
	
		html = html.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, "" ) ;
		html = html.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;
	
		html = html.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;
	
		html = html.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;
	
		html = html.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;
	
		html = html.replace( /\s*tab-stops:[^;"]*;?/gi, "" ) ;
		html = html.replace( /\s*tab-stops:[^"]*/gi, "" ) ;
	
		// Remove FONT face attributes.
		html = html.replace( /\s*face="[^"]*"/gi, "" ) ;
		html = html.replace( /\s*face=[^ >]*/gi, "" ) ;
	
		html = html.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, "" ) ;
		
		// Remove Class attributes
		html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	
		// Remove styles.
		html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;
	
		// Remove empty styles.
		html =  html.replace( /\s*style="\s*"/gi, '' ) ;
		
		html = html.replace( /<SPAN\s*[^>]*>\s*&nbsp;\s*<\/SPAN>/gi, '&nbsp;' ) ;
		
		html = html.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ;
		
		// Remove Lang attributes
		html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
		
		html = html.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ;
		
		html = html.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ;
	
		// Remove XML elements and declarations
		html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;
		
		// Remove Tags with XML namespace declarations: <o:p></o:p>
		html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;
		
		html = html.replace( /<H\d>\s*<\/H\d>/gi, '' ) ;
	
		html = html.replace( /<H1([^>]*)>/gi, '<div$1><b><font size="6">' ) ;
		html = html.replace( /<H2([^>]*)>/gi, '<div$1><b><font size="5">' ) ;
		html = html.replace( /<H3([^>]*)>/gi, '<div$1><b><font size="4">' ) ;
		html = html.replace( /<H4([^>]*)>/gi, '<div$1><b><font size="3">' ) ;
		html = html.replace( /<H5([^>]*)>/gi, '<div$1><b><font size="2">' ) ;
		html = html.replace( /<H6([^>]*)>/gi, '<div$1><b><font size="1">' ) ;
	
		html = html.replace( /<\/H\d>/gi, '</font></b></div>' ) ;
		
		html = html.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' ) ;
	
		// Remove empty tags (three times, just to be sure).
		html = html.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
		html = html.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
		html = html.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
	
		// Transform <P> to <DIV>
		var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ;	// Different because of a IE 5.0 error
		html = html.replace( re, "<div$2</div>" ) ;
	
		return html;
	} catch(err) {
		jsShowErrors("jsCleanWord", err);
	}
}


function InputType(e, flag, _teclas) {
	try {
		var patron;
		var tecla = jsKeyAscii(e);
		var extrakey = -1;
		if (_teclas != "" && _teclas) {
			_teclas = _teclas.toString();
			extrakey = _teclas.indexOf(tecla.toString());
		}
		
		if (tecla == 8 || tecla == 13 || extrakey >= 0) return true; 
		
		switch (flag) {
			case 0:
				patron = /[A-Za-z]/; //Solo acepta letras
				break;
			case 1:
				patron = /\D/; //No acepta números
				break;
			case 2:
				patron = /\w/; //Acepta números y letras
				break;
			default:
				patron = /\d/; //Solo acepta números
				break;
		}
		
		var key = String.fromCharCode(tecla);
		return patron.test(key);
	} catch(err) {
		jsShowErrors("InputType", err);
	}
}


function InputCheck(obj, flag) {
	try {
		obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
		var patron;
		
		switch (flag) {
			case 0:
				patron = /[A-Za-z]/; //Solo acepta letras
				break;
			case 1:
				patron = /\D/; //No acepta números
				break;
			case 2:
				patron = /\w/g; //Acepta números y letras
				break;
			default:
				patron = /\d/; //Solo acepta números
				break;
		}
		
		return (obj.value != "") ? patron.test(obj.value) : true;
	} catch(err) {
		jsShowErrors("InputCheck", err);
	}
}


function jsClearSelect(obj) {
	try {
		obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
		obj.options.length = 0;
	} catch(err) {
		jsShowErrors("jsClearSelect", err);
	}
}

function jsAddSelectOption(obj, txt, val, selected) {
	try {
		obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
		selected = (selected == true) ? "defauldSelected" : "";
		var sub0 = new Option(txt, val, selected);
		obj.options[obj.options.length] = sub0;
	} catch(err) {
		jsShowErrors("jsAddSelectOption", err);
	}
}


function jsSetAttribute(obj, _name, _value) {
	try {
		obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
		obj.setAttribute(_name, _value);
	} catch(err) {
		jsShowErrors("jsSetAttribute", err);
	}
}


function jsCargarSelect(_parent, _child, _child_parent_field, _child_table, _default_txt, _process_file, _process_path, _child_fields, _child_fields_sep) {
	try {
		_parent = (!jsGetObject(_parent)) ? _parent : jsGetObject(_parent);
		_child = (!jsGetObject(_child)) ? _child : jsGetObject(_child);
		var _obj_values = jsGetObject("txtcargar_select_elements");
		
		if (_parent && _child && _obj_values) {
			_default_txt = (!_default_txt && _default_txt != '') ? 'Seleccione' : _default_txt;
			if (!_process_file) _process_file = "cargar_select";
			if (!_process_path) _process_path = "process_call.php";
			if (!_child_fields) _child_fields = 'nombre';
			if (!_child_fields_sep) _child_fields_sep = '';
			_obj_values.value = "";
			
			var cargar = new SetAjax();
			cargar.FilePath = __strMainDir + "includes/procesos/" + _process_path;
			cargar.setVar = [['f', _process_file], ["child_table", _child_table], ["parentid", _parent.value], 
			["child_parent_field", _child_parent_field], ["child_fields", _child_fields], ["child_fields_sep", _child_fields_sep]];
			cargar.Element = _obj_values;
			cargar.onLoading = function() {
				document.body.style.cursor = "wait";
				_parent.disabled = true;
				_child.disabled = true;
				jsClearSelect(_child);
				jsAddSelectOption(_child, "Cargando...", "0");
				jsSetStyle("ProcesingData", "display", "block");
			}
			cargar.onCompletion = function() {
				document.body.style.cursor = "default";
				jsSetStyle("ProcesingData", "display", "none");
				_parent.disabled = false;
				jsClearSelect(_child);
				if (_default_txt != "") jsAddSelectOption(_child, _default_txt, "0");

				var split1 = _obj_values.value.split("[|]");
				for(i=0; i < split1.length; i++) {
					if (split1[i].length > 0) {
						var split2 = split1[i].split("[-]");
						jsAddSelectOption(_child, split2[1], split2[0]);
					}
				}
				
				_child.disabled = false;
			}
			cargar.Execute();
			delete cargar;
		}
	} catch(err) {
		jsShowErrors("jsCargarSelect", err);
	}
}


document.write('<input type="hidden" name="txtcargar_select_elements" id="txtcargar_select_elements">');


function SetBgPNG(img_path) {
	var _style;
	if (_jslib_isIE) {
		_style = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src='" + 
		img_path + "')";
	} else {
		_style = "background-image:url('" + img_path + "')";
	}
	
	return _style;
}

function DisplayPicture(src, w, h, _id) {
	var imgtags;
	_id = (!_id) ? "" : 'id="' + _id + '"';
	if (_jslib_isIE && FileExtension(src).toLowerCase() == "png") {
		imgtags = "<div " + _id + " style=\"width:" + w + "px; height:" + h + 
		"px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src 
		+ "', sizingMethod='image');\"></div>";
	} else {
		imgtags = '<img ' + _id + ' src="' + src + '" border="0" style="width:' + w + 'px; height:' + h + 'px;">';
	}
	
	return imgtags;
}


function findPosX(obj) {
	obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj) {
	obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
	/*var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;*/
	var iTop = 0;
    
    while(obj.tagName != "BODY") {
        iTop += obj.offsetTop;
        obj = obj.offsetParent;
    }
	return iTop;
}


function ReplaceChars(sHTML, CharCode, sString) {
	var RegX = new RegExp(String.fromCharCode(CharCode), 'g');
	sHTML = sHTML.replace(RegX, sString);
	return sHTML;
}


function ReplaceEnters(sHTML, sString) {
	var RegX = new RegExp(String.fromCharCode(10), 'g');
	sHTML = sHTML.replace(RegX, '');
	var RegX = new RegExp(String.fromCharCode(13), 'g');
	sHTML = sHTML.replace(RegX, sString);
	return sHTML;
}


function DelRow(row, msg, start_row, fila1_class, fila2_class) {
	msg = (!msg) ? "" : msg;
	var tmp = (msg != "") ? confirm(msg) : true;
	
	var tmp_val = row.nodeName.toLowerCase();
	while(tmp_val != "tr") {
		row = jsGetParent(row);
		tmp_val = row.nodeName.toLowerCase();
	}
	if (tmp == true) {
		obj = jsGetParent(jsGetParent(row));
		if (obj && row) obj.deleteRow(row.rowIndex);
		if (obj) UpdateTable(obj, start_row, fila1_class, fila2_class);
	}
}

function DeleteData(obj, elemid, tabla, _msg, _shift, start_row, fila1_class, fila2_class) {
	try {
		var MyFrameObj = (_jslib_isSafari) ? window.frames["IM_Iframe"] : window.frames[0];
		if (MyFrameObj) {
			if (jsIsString(obj)) obj = MyFrameObj.document.getElementById(obj);
			var ProcesingData = MyFrameObj.document.getElementById("ProcesingData");
			var PapeleraTotal = MyFrameObj.document.getElementById("papelera_total");
			var ButtonPapelera = MyFrameObj.document.getElementById("ButtonPapelera");
		} else {
			if (jsIsString(obj)) obj = jsGetObject(obj);
			var ProcesingData = jsGetObject("ProcesingData");
			var PapeleraTotal = jsGetObject("papelera_total");
			var ButtonPapelera = jsGetObject("ButtonPapelera");
		}
		
		if (obj) {
			_msg = (!_msg) ? true : confirm(_msg);
			_shift = (!_shift) ? 0 : _shift;
			
			if (_msg) {
				var del = new SetAjax();
				del.FilePath = __strMainDir + "includes/procesos/process_call.php";
				del.setVar = [['f', "eliminar_registro"], ["tabla", tabla], ["elemid", elemid], ["shift", _shift]];
				del.onLoading = function() {
					document.body.style.cursor = "wait";
					ProcesingData.style.display = "block";
				}
				del.onCompletion = function() {
					if (PapeleraTotal) {
						var total = parseInt(PapeleraTotal.value);
						if (_shift == 0) {
							total++;
						} else {
							total--;
						}
						if (total < 0) total = 0;
						PapeleraTotal.value = total;
						if (ButtonPapelera) {
							var icon_tag = ButtonPapelera.rows[0].cells[0].innerHTML;
							if (total > 0) {
								var plural = (total == 1) ? "registro" : "registros";
								ButtonPapelera.title = "La Papelera contiene " + total + " " + plural;
								icon_tag = icon_tag.replace("empty", "full");
							} else {
								ButtonPapelera.title = "La Papelera está vacía";
								icon_tag = icon_tag.replace("full", "empty");
							}
							
							ButtonPapelera.rows[0].cells[0].innerHTML = icon_tag;
						}
					}
					
					if (_shift == 1 || _shift == 0) {
						PlaySound("recycle");
					} else {
						PlaySound("restore");
					}
					
					document.body.style.cursor = "default";
					ProcesingData.style.display = "none";
					DelRow(obj, "", start_row, fila1_class, fila2_class);
				}
				del.Execute();
				delete del;
			}
		}
		
		return false;
	} catch(err) {
		jsShowErrors("DeleteData", err);
	}
}


function UpdateTable(obj, start_row, fila1_class, fila2_class) {
	obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
	
	var tmp = obj.nodeName.toLowerCase();
	while(tmp != "table") {
		obj = jsGetParent(obj);
		tmp = obj.nodeName.toLowerCase();
	}
	
	start_row = (!start_row) ? 1 : start_row;
	fila1_class = (!fila1_class) ? "AdminGridFila" : fila1_class;
	fila2_class = (!fila2_class) ? "AdminGridFila" : fila2_class;
	
	var flag = 1;
	for(i=start_row; i < obj.rows.length; i++) {
		if (flag == 1) {
			obj.rows[i].className = fila1_class;
			flag--;
		} else {
			obj.rows[i].className = fila2_class;
			flag++;
		}
	}
}

function FileExtension(__file) {
	__file = __file.toString();
	return __file.substr(__file.lastIndexOf('.')+1).toLowerCase();
}


function MM_jumpMenu(targ,selObj,restore) {
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}


function jsGetResolution(_type) {
	if (!_type) _type = "w";
	var bodyWidth, bodyHeight; 
	if (self.innerHeight){
	   bodyWidth = self.innerWidth;
	   bodyHeight = self.innerHeight;
	}  else if (document.documentElement && document.documentElement.clientHeight) {
	   bodyWidth = document.documentElement.clientWidth;
	   bodyHeight = document.documentElement.clientHeight;
	} else if (document.body) {
	   bodyWidth = document.body.clientWidth;
	   bodyHeight = document.body.clientHeight;
	}
	
	return (_type == "w") ? bodyWidth : bodyHeight;
}


function jsSetCenterObj(obj) {
	obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
	
	var bodyWidth = jsGetResolution("w");
	var bodyHeight = jsGetResolution("h");
	
	var tmpWidth = obj.offsetWidth;
	var tmpHeight = obj.offsetHeight;
	
	jsSetStyle(obj, "left", Math.ceil((bodyWidth - tmpWidth) / 2) + 'px');
	jsSetStyle(obj, "top", Math.ceil((bodyHeight / 2) - (tmpHeight / 2)) + 'px');
}


function jsGetRandomNum(lbound, ubound) {
	return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}

function jsGetRandomChar(number, lower, upper, other, extra) {
	var numberChars = "0123456789";
	var lowerChars = "abcdefghijklmnopqrstuvwxyz";
	var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var otherChars = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";
	var charSet = extra;
	charSet += numberChars;
	charSet += lowerChars;
	charSet += upperChars;
	return charSet.charAt(jsGetRandomNum(0, charSet.length));
}

function jsGetRandom() {
	var length = 15;
	var extraChars = '';
	var firstNumber = true;
	var firstLower = true;
	var firstUpper = true;
	var firstOther = false;
	var latterNumber = true;
	var latterLower = true;
	var latterUpper = true;
	var latterOther = false;
	
	var rc = "";
	if (length > 0)
		rc = rc + jsGetRandomChar(firstNumber, firstLower, firstUpper, firstOther, extraChars);
	for (var idx = 1; idx < length; ++idx) {
		rc = rc + jsGetRandomChar(latterNumber, latterLower, latterUpper, latterOther, extraChars);
	}
	return rc;
}


function jsShowErrors(_func_name, _err) {
	var desc = (jsIsString(_err)) ? _err : _err.description;
	alert(_func_name + ": " + desc);
	return false;
}



var __MySound = null;
	
function PlaySound(name) {
	try {
		if (!name) name = "alert";
		if (!__strFlashPath) alert("La variable __strFlashPath no está definida.");
		
		if (!__MySound) {
			__MySound = document.createElement('div');
			__MySound.id = "__GlobalSound__";
			__MySound.name = "__GlobalSound__";
			__MySound.style.left = '0px';
			__MySound.style.top = '0px';
			__MySound.style.width = '1px';
			__MySound.style.height = '1px';
			__MySound.style.zIndex = 0;
			__MySound.style.position = "absolute";
			__MySound.style.visibility = 'hidden';
			document.body.appendChild(__MySound);
		}
		
		if (__MySound) {
			var sound = new SWFObject(__strFlashPath + "sounds.swf", "_GloalSound_", 1, 1, 7);
			sound.addVariable("s", name);
			sound.write("__GlobalSound__");
		}
	} catch(err) {
		jsShowErrors("PlaySound", err);
	}
}


function jsImageError(img) {
	try {
		div = document.createElement('div');
		div.style.width = "100px";
		div.style.height = "120px";
		div.innerHTML = DisplayPicture(__strIconsPath + "noimage.jpg",100,120);
		jsGetParent(img).appendChild(div);
		jsGetParent(img).removeChild(img);
	} catch(err) {
		jsShowErrors("jsImageError", err);
	}
}

function jsHideFormContent(_id,_txt1,_txt2) {
	try {
		jsToggleDisplay('_HideForm_' + _id);
		if (jsGetStyle('_HideForm_' + _id, 'display') == 'none') {
			jsGetObject('_HideFormIcon_' + _id).src = __strIconsPath + 'bullet_toggle_plus.gif';
			jsGetObject('_HideFormText_' + _id).innerHTML = _txt2;
		} else {
			jsGetObject('_HideFormIcon_' + _id).src = __strIconsPath + 'bullet_toggle_minus.gif';
			jsGetObject('_HideFormText_' + _id).innerHTML = _txt1;
		}
	} catch(err) {
		jsShowErrors("jsHideFormContent", err);
	}
}