function ValidateForm(form, _return) {
	if (!_return) _return = true;
	form = (!jsGetObject(form)) ? form : jsGetObject(form);
	var onAfterSubmit = form.getAttribute("onaftersubmit",2);
	var returnSubmit = form.getAttribute("returnsubmit",2);
	if (!returnSubmit) returnSubmit = true;
	
	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;
				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];
					
					if (!eval(_validation_function)) {
						alert(_validation_msg);
						if(__obj.type != "hidden") __obj.focus();
						return false;
					}
				}
				
				if (validation && validationMsg) {
					var wv = false;
					var _obj_array = jsGetObject(__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.";
						alert(validationMsg);
						if(__obj.type != "hidden") __obj.focus();
						return false;
					}
				}
			}
		}
	}
	
	if (onAfterSubmit) {
		try {
			if (onAfterSubmit.indexOf('(') < 0) {
				onAfterSubmit += "(form);"
			}
			return eval(onAfterSubmit);
		} catch(err) {
			
		}
	}
	
	if (returnSubmit == true) {
		form.submit();
	}
	
	DisableFormElements(form);
	
	return false;
}


var __last_submit_button_caption;

function DisableFormElements(form) {
	form = (!jsGetObject(form)) ? form : jsGetObject(form);
	
	document.body.style.cursor = "wait";
	jsSetStyle("ProcesingData", "visibility", "visible");
	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;
		}
	}
}

function EnableFormElements(form) {
	form = (!jsGetObject(form)) ? form : jsGetObject(form);
	
	document.body.style.cursor = "default";
	jsSetStyle("ProcesingData", "visibility", "hidden");
	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;
		}
	}
}

function isEmail(obj) {
	obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
	if (obj) {
		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 false;
	}
}

function KeyAscii(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 (KeyAscii(event) == 27) { window.close(); return; }
}

function InitESC() {
	document.body.onkeypress = _CloseOnEsc;
}

function ToggleDisplay(obj) {
	obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
	if (obj) jsSetStyle2(obj, "display", (jsGetStyle2(obj, "display") == "none") ? "block" : "none")
}


/*------------------------------------------------------------------------------------------------------------\
	Date Created: 12-30-05
	Modified Date: 12-30-05
	Function Name: ClearHTML(sHTML)
	Porpouse: Limpia el código HTML.
		sHTML: HTML Tags a limpiar.
/-------------------------------------------------------------------------------------------------------------*/
function ClearHTML(sHTML) {
	sHTML = CleanWord(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;
}


/*------------------------------------------------------------------------------------------------------------\
	Date Created: 12-30-05
	Modified Date: 12-30-05
	Function Name: CleanWord(html)
	Porpouse: Limpia el código HTML generado por Microsoft Word.
		html: HTML Tags a limpiar.
/-------------------------------------------------------------------------------------------------------------*/
function CleanWord(html) {
	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 ;
}


function InputType(e, flag, _teclas) {
	var patron;
	var tecla = KeyAscii(e);
	var extrakey = -1;
	if (_teclas != "" && _teclas) {
		_teclas = _teclas.toString();
		extrakey = _teclas.indexOf(tecla.toString());
	}
	
	if (tecla == 8 || tecla == 13 || extrakey >= 0) return true; 
	//Tecla de retroceso (para poder borrar) y enter (para poder enviar)
	
	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);
}


function InputCheck(obj, flag) {
	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;
}


function ClearSelect(obj) {
	obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
	obj.options.length = 0;	
}

function AddSelectOption(obj, txt, val, selected) {
	obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
	
	selected = (selected == true) ? "defauldSelected" : "";
	var sub0 = new Option(txt, val, selected);
	obj.options[obj.options.length] = sub0;
}


/*------------------------------------------------------------------------------------------------------------\
	Date Created: 12-31-05
	Modified Date: 12-31-05
	Function Name: jsSetAttribute(obj, _name, _value)
	Porpouse: Asigna un atributo a un objeto o elemento.
		obj: Id del Objeto.
		_name: Nombre del atributo.
		_value: Valor del atributo.
/-------------------------------------------------------------------------------------------------------------*/
function jsSetAttribute(obj, _name, _value) {
	obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
	obj.setAttribute(_name, _value);
}


function CargarSelect(obj1, obj2, parent_field, tabla, _default_txt) {
	if (obj1) {
		if (!_default_txt) _default_txt = "Seleccione";
		var obj_values = jsGetObject("txtcargar_select_elements");
		obj2 = jsGetObject(obj2);
		obj_values.value = "";
		
		var cargar = new SetAjax();
		cargar.FilePath = __strMainDir + "includes/procesos/cargar_select.php";
		cargar.setVar = [["tabla", tabla], ["parentid", obj1.value], ["parent_field", parent_field]];
		cargar.Element = obj_values;
		cargar.onLoading = function() {
			document.body.style.cursor = "wait";
			obj1.disabled = true;
			obj2.disabled = true;
			ClearSelect(obj2);
			AddSelectOption(obj2, "Cargando...", "0");
		}
		cargar.onCompletion = function() {
			document.body.style.cursor = "default";
			obj1.disabled = false;
			ClearSelect(obj2);
			AddSelectOption(obj2, _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("[-]");
					AddSelectOption(obj2, split2[1], split2[0]);
				}
			}
			
			obj2.disabled = false;
		}
		cargar.Execute();
	}
}


document.write('<input type="hidden" name="txtcargar_select_elements" id="txtcargar_select_elements">');


function FixPNG(myImage)  {
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);
	
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : "";
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : "";
	   var imgTitle = (myImage.title) ? "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' ";
	   var imgStyle = "display:inline-block;" + myImage.style.cssText;
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>";
	   myImage.outerHTML = strNewHTML;
    }
}


function SetBgPNG(img_path) {
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);
	var _style;
	if (_jslib_isIE && version >= 5.5 && version < 7) {
		_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) {
		imgtags = "<div " + _id + " style=\"width:" + w + "px; height:" + h 
		+ "px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src 
		+ "', sizingMethod='scale');\"></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 (!_jslib_isSafari) ? curtop : (curtop + 30);
}


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, sString);
	var RegX = new RegExp(String.fromCharCode(13), 'g');
	sHTML = sHTML.replace(RegX, sString);
	
	return sHTML;
}

function FileExtension(__file) {
	__file = __file.toString();
	return __file.substr(__file.lastIndexOf('.')+1).toLowerCase();
}

function jsShowErrors(_func_name, _err) {
	var desc = (jsIsString(_err)) ? _err : _err.description;
	alert(_func_name + ": " + desc);
	return false;
}

var _Flash = null;
var _FlashTop = null;

function SearchItems(txt) {
	try {
		if (txt  && jsGetObject('Options')) {
			var t1 = jsGetObject('t1');
			if (t1) t1.value = 4;
			var t2 = jsGetObject('t2');
			if (t2) t2.value = 0;
			
			var Src = new SetAjax();
			Src.ElementPlainText = false;
			Src.FilePath = __strMainDir + "includes/procesos/search.php";
			Src.setVar = [["t1", 4], ["t2", 0], ["txt", txt]];
			Src.Element = jsGetObject('Options');
			Src.onLoading = function() {
				setLoading('Options');
				document.body.style.cursor = "wait";
			}
			Src.onCompletion = function() {
				jsSetStyle('ContentLoader2', 'display', 'none');
				if (_jslib_isIE) jsSetStyle('iframeContentLoader2', 'display', 'none');
				document.body.style.cursor = "default";
								
				var firstprop = jsGetObject('firstprop');
				var firstproptype = jsGetObject('firstproptype');
				if (firstprop && firstproptype) {
					if (firstprop.value != '' && firstprop.value != '0') {
						LoadContent(firstprop.value,firstproptype.value);
					} else {
						LoadContent('home');
					}
				} else {
					LoadContent('home');
				}
			}
			Src.Execute();
			delete Src;
		}
	} catch(err) {
		jsShowErrors("SearchItems", err);
	}
}

var _div_loader_1 = null;
var _div_loader_2 = null;
var _iframe_loader_1 = null;
var _iframe_loader_2 = null;

function setLoading(obj) {
	try {
		if (!obj) obj = 'Content';
		
		var content_w = parseInt(jsGetStyle(obj,'width').replace('px',''));
		var content_h = parseInt(jsGetStyle(obj,'height').replace('px',''));
		var content_t = findPosY(obj);
		var content_l = findPosX(obj);
		
		var html = '';
		html += '<table height="46" border="0" cellspacing="0" cellpadding="0">';
		html += '<tr>';
		html += '<td width="20">' + DisplayPicture(__strMainDir + 'images/loader01.png',20,46) + '</td>';
		html += '<td style="' + SetBgPNG(__strMainDir + 'images/loader02.png') + '"><img src="' + __strMainDir + 
		'images/loading.gif" border="0"></td>';
		html += '<td width="19">' + DisplayPicture(__strMainDir + 'images/loader03.png',19,46) + '</td>';
		html += '</tr>';
		html += '</table>';
		
		if (obj == 'Content') {
			if (!_div_loader_1) {
				_div_loader_1 = document.createElement('div');
				_div_loader_1.id = 'ContentLoader1';
				_div_loader_1.style.position = 'absolute';
				_div_loader_1.style.display = 'block';
				_div_loader_1.style.zIndex = 100;
				_div_loader_1.innerHTML = html;
				document.body.appendChild(_div_loader_1);
				
				_div_loader_1.style.left = Math.ceil((content_l + ((content_w - _div_loader_1.offsetWidth) / 2))) + 'px';
				_div_loader_1.style.top = Math.ceil((content_t + ((content_h / 2) - (_div_loader_1.offsetHeight / 2)))) + 'px';
				
				if (_jslib_isIE) {
					_iframe_loader_1 = document.createElement('iframe');
					_iframe_loader_1.id = 'iframeContentLoader1';
					_iframe_loader_1.style.position = 'absolute';
					_iframe_loader_1.style.display = 'block';
					_iframe_loader_1.style.filter = 'alpha(opacity=0)';
					_iframe_loader_1.style.zIndex = _div_loader_1.style.zIndex - 1;
					_iframe_loader_1.style.left = _div_loader_1.style.left;
					_iframe_loader_1.style.top = _div_loader_1.style.top;
					_iframe_loader_1.style.width = _div_loader_1.offsetWidth + 'px';
					_iframe_loader_1.style.height = _div_loader_1.offsetHeight + 'px';
					document.body.insertBefore(_iframe_loader_1, _div_loader_1);
				}
			} else {
				if (_div_loader_1) _div_loader_1.style.display = 'block';
				if (_iframe_loader_1 && _jslib_isIE) _iframe_loader_1.style.display = 'block';
			}
		} else {
			if (!_div_loader_2) {
				_div_loader_2 = document.createElement('div');
				_div_loader_2.id = 'ContentLoader2';
				_div_loader_2.style.position = 'absolute';
				_div_loader_2.style.display = 'block';
				_div_loader_2.style.zIndex = 100;
				_div_loader_2.innerHTML = html;
				document.body.appendChild(_div_loader_2);
				
				_div_loader_2.style.left = Math.ceil((content_l + ((content_w - _div_loader_2.offsetWidth) / 2))) + 'px';
				_div_loader_2.style.top = Math.ceil((content_t + ((content_h / 2) - (_div_loader_2.offsetHeight / 2)))) + 'px';
				
				if (_jslib_isIE) {
					_iframe_loader_2 = document.createElement('iframe');
					_iframe_loader_2.id = 'iframeContentLoader2';
					_iframe_loader_2.style.position = 'absolute';
					_iframe_loader_2.style.display = 'block';
					_iframe_loader_2.style.filter = 'alpha(opacity=0)';
					_iframe_loader_2.style.zIndex = _div_loader_2.style.zIndex - 1;
					_iframe_loader_2.style.left = _div_loader_2.style.left;
					_iframe_loader_2.style.top = _div_loader_2.style.top;
					_iframe_loader_2.style.width = _div_loader_2.offsetWidth + 'px';
					_iframe_loader_2.style.height = _div_loader_2.offsetHeight + 'px';
					document.body.insertBefore(_iframe_loader_2, _div_loader_2);
				}
			} else {
				if (_div_loader_2) _div_loader_2.style.display = 'block';
				if (_iframe_loader_2 && _jslib_isIE) _iframe_loader_2.style.display = 'block';
			}
		}
	} catch(err) {
		jsShowErrors("setLoading", err);
	}
}

function LoadOptions(p,src,search_in) {
	try {
		var t1 = !jsGetObject('t1') ? 0 : jsGetObject('t1').value;
		var t2 = !jsGetObject('t2') ? 0 : jsGetObject('t2').value;
		var t3 = !jsGetObject('t3') ? 4 : jsGetObject('t3').value;
		var p = !p ? jsGetObject('pagenum').value : p;
		if (!src) src = '';
		if (!search_in) search_in = 1;	
		
		var pagenum = jsGetObject('pagenum');
		if (pagenum) pagenum.value = p;
		
		if (src != '') {
			advancedSearch(p,src,search_in);
			return false;
		}
		
		if (jsGetObject('Options')) {
			var cargar = new SetAjax();
			cargar.ElementPlainText = false;
			cargar.FilePath = __strMainDir + "includes/procesos/cargar_opciones.php";
			cargar.setVar = [['t1', t1], ['t2', t2], ['t3', t3], ['_pagi_pg', p], ['src', src]];
			cargar.Element = jsGetObject('Options');
			cargar.onLoading = function() {
				setLoading('Options');
				document.body.style.cursor = "wait";
			}
			cargar.onCompletion = function() {
				jsSetStyle('ContentLoader2', 'display', 'none');
				if (_jslib_isIE) jsSetStyle('iframeContentLoader2', 'display', 'none');
				document.body.style.cursor = "default";
				
				var firstprop = jsGetObject('firstprop');
				if (!firstprop && t1!=4) {
					LoadContent('home');
				}
			}
			cargar.Execute();
			delete cargar;
		}
	} catch(err) {
		jsShowErrors("LoadOptions", err);
	}
}


function LoadContent(target,type,codigo,nombre) {
	try {
		if (!type) type = 0;
		
		if (jsGetObject('sell_form') && _Flash) {
			_Flash.HideTabs(1);
		}
		
		if (jsGetObject('Content')) {
			var cargar = new SetAjax();
			cargar.ElementPlainText = false;
			cargar.FilePath = __strMainDir + "includes/procesos/cargar_contenido.php";
			cargar.setVar = [["target", target], ["type", type], ["codigo", codigo], ["nombre", nombre]];
			cargar.Element = jsGetObject('Content');
			cargar.onLoading = function() {
				setLoading('Content');
				document.body.style.cursor = "wait";
			}
			cargar.onCompletion = function() {
				jsSetStyle('ContentLoader1', 'display', 'none');
				if (type == 0) PropertyGallery();
				if (_jslib_isIE) jsSetStyle('iframeContentLoader1', 'display', 'none');
				document.body.style.cursor = "default";
			}
			cargar.Execute();
			delete cargar;
		}
	} catch(err) {
		jsShowErrors("LoadContent", err);
	}
}

function ShowBox(val) {
	try {
		if (val == "1") {
			jsSetStyle('Propiedades','display','block');
			jsSetStyle('Proyectos','display','none');
		} else {
			jsSetStyle('Propiedades','display','none');
			jsSetStyle('Proyectos','display','block');
		}
	} catch(err) {
		jsShowErrors("ShowBox", err);
	}
}

function resetSearchForm() {
	var referencia = jsGetObject('referencia');
	if (referencia) referencia.value = '';
	var provincia = jsGetObject('provincia');
	if (provincia) provincia.value = '0';
	var distrito = jsGetObject('distrito');
	if (distrito) distrito.value = '0';
	var banos = jsGetObject('banos');
	if (banos) banos.value = '0';
	var camas = jsGetObject('camas');
	if (camas) camas.value = '0';
	var area_const1 = jsGetObject('area_const1');
	if (area_const1) area_const1.value = '';
	var area_const2 = jsGetObject('area_const2');
	if (area_const2) area_const2.value = '';
	
	var tipo = jsGetObject('tipo');
	if (tipo) tipo.value = '0';
	
	var categoria = jsGetObject('categorias');
	if (categoria) categoria.value = '0';
	var categoria = jsGetObject('categorias_proyecto');
	if (categoria) categoria.value = '0';
	
	var pmenor = jsGetObject('pmenor');
	if (pmenor) pmenor.value = '';
	var pmayor = jsGetObject('pmayor');
	if (pmayor) pmayor.value = '';
	var pmenor = jsGetObject('pmenor2');
	if (pmenor) pmenor.value = '';
	var pmayor = jsGetObject('pmayor2');
	if (pmayor) pmayor.value = '';
	
	var t3 = jsGetObject('t3');
	if (t3) t3.value = 4;
	
	var pagenum = jsGetObject('pagenum');
	if (pagenum) pagenum.value = 1;
	
	for(var i=1; i<=4; i++) {
		var obj_clic = jsGetObject('sbfilter'+i);
		if (obj_clic) {
			if (obj_clic.nodeName.toLowerCase() == 'img') {
				obj_clic.src = obj_clic.src.replace('over','out');
			} else {
				obj_clic.style.color = '#88A1B1';
			}
			obj_clic.style.cursor = 'pointer';
			obj_clic.setAttribute('clicked','0');
		}
	}
	
	var allobj = jsGetObject('sbfilter4');
	if (allobj) {
		allobj.style.color = '#FFFFFF';
		allobj.setAttribute('clicked','1');
		allobj.style.cursor = 'default';
	}
}

function advancedSearch(p,src,search_in) {
	//try {
		var t1 = !jsGetObject('t1') ? 0 : jsGetObject('t1').value;
		if (t1 == 4) jsGetObject('t1').value = 0;
		var t2 = !jsGetObject('t2') ? 0 : jsGetObject('t2').value;
		var t3 = !jsGetObject('t3') ? 4 : jsGetObject('t3').value;
		if (!p) p = 1;
		if (!src) src = '';
		if (!search_in) search_in = 1;
		
		var src_obj = jsGetObject('src');
		if (src_obj) src_obj.value = src;
		
		if (src == '') {
			var referencia = jsGetObject('referencia').value;
			var provincia = jsGetObject('provincia').value;
			var distrito = jsGetObject('distrito').value;
			var banos = jsGetObject('banos').value;
			var camas = jsGetObject('camas').value;
			var area_const1 = jsGetObject('area_const1').value;
			var area_const2 = jsGetObject('area_const2').value;
			var area_const_medida = jsGetObject('area_const_medida').value;
			
			var tipo = jsGetObject('tipo').value;
			
			if (search_in == '1') {
				var categoria = jsGetObject('categorias').value;
			} else {
				var categoria = jsGetObject('categorias_proyecto').value;
			}
			
			if (tipo != '2') {
				var pmenor = jsGetObject('pmenor').value;
				var pmayor = jsGetObject('pmayor').value;
			} else {
				var pmenor = jsGetObject('pmenor2').value;
				var pmayor = jsGetObject('pmayor2').value;
			}
		}
		
		if (jsGetObject('Options')) {
			var Search = new SetAjax();
			Search.FilePath = __strMainDir + "includes/procesos/search.php";
			Search.ElementPlainText = false;
			Search.Element = jsGetObject('Options');
			if (src == '') {
				Search.setVar = [["t1", t1], ["t2", t2], ["t3", t3], ["referencia", referencia], 
				["provincia", provincia], ["distrito", distrito], ["banos", banos], ["camas", camas], 
				["area_const1", area_const1], ["area_const2", area_const2], ["area_const_medida", area_const_medida], 
				["tipo", tipo], ["categoria", categoria], ["pmenor", pmenor], ["pmayor", pmayor]];
			} else {
				Search.setVar = [["t1", t1], ["t2", t2], ["t3", t3], ["_pagi_pg", p], ["src", src], ["search_in", search_in]];
			}
			Search.onLoading = function() {
				setLoading('Options');
				document.body.style.cursor = "wait";
			}
			Search.manageError = function(err,val) {
				jsSetStyle('ContentLoader2', 'display', 'none');
				if (_jslib_isIE) jsSetStyle('iframeContentLoader2', 'display', 'none');
				document.body.style.cursor = "default";
				jsGetObject('b_search').disabled = false;
				alert(val);
			}
			Search.onCompletion = function() {
				jsSetStyle('ContentLoader2', 'display', 'none');
				if (_jslib_isIE) jsSetStyle('iframeContentLoader2', 'display', 'none');
				document.body.style.cursor = "default";
				
				var firstprop = jsGetObject('firstprop');
				var firstproptype = jsGetObject('firstproptype');
				if (firstprop && firstproptype) {
					if (firstprop.value != '' && firstprop.value != '0') {
						LoadContent(firstprop.value,firstproptype.value);
					} else {
						LoadContent('home');
					}
				} else {
					LoadContent('home');
				}
			}
			Search.Execute();
			delete Search;
		}
		
		return false;
	/*} catch(err) {
		jsShowErrors("advancedSearch", err);
	}*/
}

var divProperty;
var ruta;
var fotos;
var textos;
function preLoadingImg(imagens){
	var fotos = new Image();
	for (var cuenta=0; cuenta<imagens.length;cuenta++) {
		fotos[cuenta].src = imagens[cuenta];
	}
	return fotos;
}

function PropertyGallery(cont) {
	try {
		if (!cont) cont = 0;
		var divProperty = jsGetObject('PropertyPictures');
		if (divProperty) {
			ruta = divProperty.getAttribute('ruta');
			fotos = divProperty.getAttribute('fotos').split('|');
			textos = divProperty.getAttribute('descripcion').split('|');
			if (cont == 0) {
				for (var cuenta=0; cuenta<fotos.length;cuenta++) {
					if(fotos[cuenta]!=''){
						var funcion = 'AbrirFotoProperty('+cuenta+');';
						divProperty.innerHTML += '<a id="linkImage'+cuenta+'" href="javascript:void(0);" onclick="paginacao=0;' + 
						funcion + '"><img src="' + ruta + 'tn_' + fotos[cuenta] + '" border="0" id="PropertyFoto' + cuenta + '" width="104" style="margin-bottom:4px;"></a>';
					/*var imagen = document.createElement('img');
					imagen.src = ruta + 'tn_' + fotos[cuenta];
					imagen.style.width = '104px';
					imagen.style.border = '1px solid #2172AA';
					imagen.style.marginBottom = '4px';
					imagen.setAttribute('id','PropertyFoto'+cuenta);*/
					/*if (!_jslib_isIE){
						imagen.onerror = function() {
							jsGetObject(this.id).src = ruta + 'tn_not_image.jpg';
							jsGetObject(this.id.replace('PropertyFoto','linkImage')).onclick = null;
						}
					}*/
					//jsGetObject('linkImage'+cuenta).appendChild(imagen);
					}else{
							divProperty.innerHTML = '<img src="' + ruta +'tn_not_image.jpg" border="0" id="PropertyFoto' + cuenta + '" width="104" height="70" style="margin-bottom:4px;">'
					}
				}
				if (_jslib_isIE) window.setTimeout('verificarImagens();',300);
			} else {
				cont--;
				AbrirFotoProperty(cont);
			}
		}
	} catch(err) {
		jsShowErrors("PropertyGallery", err);
	}
}
var fotos_cargadas = new Array();
function verificarImagens(){
	try {
		/*for (var cuenta=0; cuenta<fotos.length;cuenta++) {
			var img = jsGetObject('PropertyFoto'+cuenta);
			var alink = jsGetObject('linkImage'+cuenta);
			if(!img.complete){
				img.src = ruta + 'tn_not_image.jpg';
				alink.onclick = null;
			}else{
				fotos_cargadas;
			}
		}*/
	} catch(err) {
		jsShowErrors("verificarImagens", err);
	}
}

var ShadowObj = null;
var ShadowIframeObj = null;
var direction=1;
function AbrirFotoProperty(index) {
	try {
		if(!paginacao){
			ShadowObj = document.createElement('div');
			ShadowObj.id = 'Shadow';
			document.body.appendChild(ShadowObj);
			
			if (_jslib_isIE) {
				ShadowIframeObj = document.createElement('iframe');
				ShadowIframeObj.setAttribute('id','iframeShadow')
				ShadowIframeObj.vSpace = 0;
				ShadowIframeObj.hSpace = 0;
				document.body.insertBefore(ShadowIframeObj, ShadowObj);
			}
			/*
			//btrans = new BlendTransition();
			//btrans.ObjId = ShadowObj;
			//btrans.opacStart = 1;
			//btrans.opacEnd = 30;
			//btrans.milliSec = 500;
			//btrans.onCompletion = function() {
				
			//}
			//btrans.opacity();
			//delete btrans;
			*/
		}
		var funcionAjiba = function(){llamar('setScrollValue(\'divImage\',getScrollValue(\'divImage\')+10)');}
		var funcionAbajo = function(){llamar('setScrollValue(\'divImage\',getScrollValue(\'divImage\')-10)');}	
		var div = document.createElement('div');
		div.setAttribute('id','MirarFoto');
		var divImagen = document.createElement('div');
		divImagen.setAttribute('id','divImage');
		var divCerrado = document.createElement('div');
		divCerrado.innerHTML = 'X';
		divCerrado.setAttribute('id','divCerrarFotoProperty');
		/*var imagen = document.createElement('img');
		imagen.src = ruta + fotos[index];
		imagen.setAttribute('id','FotoPosta');*/
		var next = document.createElement('img');
		next.src = 'images/btn_arrow_right.jpg' ;
		next.setAttribute('id','imgnext');
		var previous = document.createElement('img');
		previous.src = 'images/btn_arrow.jpg' 
		previous.setAttribute('id','imgprevious');
		var span = document.createElement('span');
		span.setAttribute('id','textoDescripcion');
		span.innerHTML = textos[index];
		var hr = document.createElement('hr');
		document.body.appendChild(div);
		div.appendChild(divImagen);
		//divImagen.appendChild(imagen);
		divImagen.innerHTML = '<img src="' + ruta + fotos[index] + '" border="0" id="FotoPosta">';
		if(!_jslib_isNS6)jsAddEvent(divImagen,"mouseover",funcionAjiba);
		if(!_jslib_isNS6)jsAddEvent(divImagen,"mouseout",funcionAbajo);
		div.appendChild(hr);
		div.appendChild(previous);
		div.appendChild(span);	
		div.appendChild(next);
		div.appendChild(divCerrado);
		nextFuncion = function(){
			paginacao=1;
			index+=1;
			Pagination(index);	
		}
		PrevFuncion = function(){
			paginacao=1;
			index-=1;
			Pagination(index);	
		}
		resetPagination = function(){
			paginacao=0 ;
			cerrarFotoProperty();
		}
		jsAddEvent(next,"click",nextFuncion);
		jsAddEvent(previous,"click",PrevFuncion);
		jsAddEvent(divCerrado.id,'click',resetPagination);
		imgPaginacion(index);
		div.style.left = (window.screen.width-450)/2;
		div.style.width = '500px';
		if(_jslib_isNS6)divImagen.style.overflow = 'auto';
		divImagen.innerHTML = '<img src="' + ruta + fotos[index] + '" border="0" id="FotoPosta">';		
		delete div;
		delete divImagen;
		delete divCerrado;
		delete next;
		delete previous;
		jsGetObject('FotoPosta').onerror = function(){
				jsGetObject('FotoPosta').src = ruta + 'tn_not_image.jpg';
		}
		jsGetObject('FotoPosta').onload = function(){
			if(jsGetObject('FotoPosta').offsetHeight>380){
				jsGetObject('FotoPosta').style.height = 360;
			};
		}
		
	} catch(err) {
		jsShowErrors("AbrirFotoProperty", err);
	}
}

function verificaFoto(index){
	try {
		var objeto = jsGetObject('FotoPosta');
		if(!objeto.complete){
			objeto.src = ruta + 'tn_not_image.jpg'
			objeto.style.width = '80px';
			objeto.style.height = '104px';
		}
	} catch(err) {
		jsShowErrors("verificaFoto", err);
	}
}
var paginacao = 0;
function Pagination(index){
	try {
		alto();
		if (!_jslib_isIE){
			paginacao=0;
			jsGetObject('FotoPosta').style.width=null;
			jsGetObject('FotoPosta').style.height=null;
			var imagen = jsGetObject('FotoPosta');
			imagen.src = ruta + fotos[index];			
			setScrollValue('divImage',0);
			var texto  = jsGetObject('textoDescripcion');
			texto.innerHTML = textos[index];
			imgPaginacion(index);
		}else{
			cerrarFotoProperty();
			AbrirFotoProperty(index);
		}
	} catch(err) {
		jsShowErrors("Pagination", err);
	}
}
function imgPaginacion(index) {
	try {
		(index<fotos.length-1) ? jsGetObject('imgnext').style.visibility='visible' : 
		jsGetObject('imgnext').style.visibility='hidden';
		(index>0) ? jsGetObject('imgprevious').style.visibility='visible' : 
		jsGetObject('imgprevious').style.visibility='hidden';
	} catch(err) {
		jsShowErrors("imgPaginacion", err);
	}
}
function cerrarFotoProperty(){
	try {
		alto();
		if(!paginacao){ 
			/*btrans = new BlendTransition();
			btrans.ObjId = ShadowObj;
			btrans.opacStart = 30;
			btrans.opacEnd = 0;
			btrans.milliSec = 500;
			btrans.onCompletion = function() {
				document.body.removeChild(ShadowObj);
				if (_jslib_isIE) document.body.removeChild(ShadowIframeObj);
			}
			btrans.opacity();
			delete btrans;*/
			
			document.body.removeChild(ShadowObj);
			if (_jslib_isIE) document.body.removeChild(ShadowIframeObj);
		}
		document.body.removeChild(jsGetObject('MirarFoto'));
	} catch(err) {
		jsShowErrors("cerrarFotoProperty", err);
	}
}
var idTimeOut=null;
function llamar(funcao){
	try {
		alto();
		idTimeOut = setInterval(funcao,100);
	} catch(err) {
		jsShowErrors("llamar", err);
	}
}
function alto(){
	try {
		if(idTimeOut) clearInterval(idTimeOut);
	} catch(err) {
		jsShowErrors("alto", err);
	}
}
function setScrollValue(id,value){
	if (jsGetObject(id)) jsGetObject(id).scrollTop = value;
}
function getScrollValue(id){
	if (jsGetObject(id)) return jsGetObject(id).scrollTop;
}

function showSection(obj) {
	try {
		objs = Array('Information','PropertyPictures','ModelsAndOptions');
		for(i=0; i<objs.length; i++) {
			jsSetStyle(objs[i], 'display', 'none');
		}
		
		jsSetStyle(obj, 'display', 'block');
	} catch(err) {
		jsShowErrors("showSection", err);
	}
}
function ancora(os,oa){
	jsGetObject(os).scrollTop=findPosY(oa)-findPosY(os);
}

function menuTop(obj,color,clicked) {
	var id = obj.id.replace('tab_','');
	if (clicked) {
		for(var i=1; i<=5; i++) {
			var obj_clic = jsGetObject('clicked_'+i);
			if (obj_clic) obj_clic.style.display = 'none';
			var obj_norm = jsGetObject('tab_'+i);
			if (obj_norm) obj_norm.style.display = 'block';
		}
		
		obj.style.display = 'none';
		var obj_clicked = jsGetObject('clicked_'+id);
		if (obj_clicked) obj_clicked.style.display = 'block';
		
		var t1 = jsGetObject('t1');
		var t = obj.getAttribute('t');
		if (t && t1) {
			t1.value = t;
			resetSearchForm();
			LoadOptions();
			if (t == '4') LoadContent('sell');
		}
	} else {
		var arrow_bottom = jsGetObject('arrow_bottom'+id);
		if (arrow_bottom) arrow_bottom.style.backgroundColor = color;
		obj.style.backgroundColor = color;
	}
}

function menuTopClicked(obj,id) {
	if (obj.style.display == 'none') {
		obj.style.display = 'none';
		var obj_normal = jsGetObject(id);
		if (obj_normal) obj_normal.style.display = 'block';
	}
}

function searchBFilter(obj,over) {
	var clicked = obj.getAttribute('clicked');
	if (!clicked) clicked = '0';
	if (clicked == '0') {
		if (obj.nodeName.toLowerCase() == 'img') {
			if (obj.src.indexOf('over') < 0) {
				obj.src = obj.src.replace('out','over');
			} else {
				obj.src = obj.src.replace('over','out');
			}
		} else {
			if (over) {
				obj.style.color = '#FFFFFF';
			} else {
				obj.style.color = '#88A1B1';
			}
		}
	}
}

function searchBFilterClick(obj) {
	var clicked = obj.getAttribute('clicked');
	if (!clicked) clicked = '0';
	if (clicked == '0') {
		for(var i=1; i<=4; i++) {
			var obj_clic = jsGetObject('sbfilter'+i);
			if (obj_clic) {
				if (obj_clic.nodeName.toLowerCase() == 'img') {
					obj_clic.src = obj_clic.src.replace('over','out');
				} else {
					obj_clic.style.color = '#88A1B1';
				}
				obj_clic.style.cursor = 'pointer';
				obj_clic.setAttribute('clicked','0');
			}
		}
		
		if (obj.nodeName.toLowerCase() == 'img') {
			obj.src = obj.src.replace('out','over');
		} else {
			obj.style.color = '#FFFFFF';
		}
		obj.setAttribute('clicked','1');
		obj.style.cursor = 'default';
		
		var t3 = jsGetObject('t3');
		if (t3) t3.value = obj.id.replace('sbfilter','');
		
		var src = jsGetObject('src');
		if (src) {
			LoadOptions(1,src.value);
		}
	}
}

function expandSearchFilter(lbl1,lbl2) {
	var img = jsGetObject(lbl1+'arrow');
	var txt = jsGetObject(lbl1+'txt');
	var obj1 = jsGetObject(lbl1);
	var obj2 = jsGetObject(lbl2);
	var search_content = jsGetObject('search_content');
	if (search_content && obj1 && obj2) {
		obj1.appendChild(search_content);
		
		for(var i=1; i<=2; i++) {
			var arrow = jsGetObject('bsearchf'+i+'arrow');
			if (arrow) {
				arrow.src = arrow.src.replace('white','blue');
				arrow.width = 6;
				arrow.height = 9;
			}
			var text = jsGetObject('bsearchf'+i+'txt');
			if (text) text.style.color = '#025992';
			var drop = jsGetObject('bsearchf'+i+'_drops');
			if (drop) drop.style.display = 'none';
		}
		
		if (img.src.indexOf('blue') < 0) {
			img.src = img.src.replace('white','blue');
			img.width = 6;
			img.height = 9;
			txt.style.color = '#025992';
		} else {
			img.src = img.src.replace('blue','white');
			img.width = 9;
			img.height = 6;
			txt.style.color = '#FFFFFF';
		}
		
		var t = lbl1 == 'bsearchf1' ? 1 : 0;
		var t2 = jsGetObject('t2');
		if (t1 && t2) {
			t2.value = t;
			LoadOptions();
		}
		
		var drop = jsGetObject(lbl1+'_drops');
		if (drop) drop.style.display = 'block';
	}
}

function submitSearch(e) {
	var tecla = KeyAscii(e);
	if (tecla == 13) {
		advancedSearch();
	}
}

function Validar_es() {
	var _firstName = document.getElementById("first_name");
	var _LastName = document.getElementById("last_name");
	var _email = document.getElementById("email1");
	var _leadSource = document.getElementById("lead_source");
	var _Confirma = document.getElementById("confirma");
	
	if (_firstName.value == '') {
		alert("Por favor, complete los campos requeridos.");
		_firstName.focus();
		return false;
	}
	
	if (_LastName.value == '') {
		alert("Por favor, complete los campos requeridos.");
		_LastName.focus();
		return false;
	}
	
	if ((_email.value == "")|| (_email.value.indexOf('@') == -1) || (_email.value.indexOf('.') == -1)) {
		alert("Por favor, complete los campos requeridos.");
		_email.focus();
		return false;
	}
	
	if (_leadSource.value == '') {
		alert("Por favor, complete los campos requeridos.");
		_leadSource.focus();
		return false;
	}
	
	if (_Confirma.value == '') {
		alert("Por favor, complete los campos requeridos.");
		_Confirma.focus();
		return false;
	}
}

function Validar_en() {
	var _firstName = document.getElementById("first_name");
	var _LastName = document.getElementById("last_name");
	var _email = document.getElementById("email1");
	var _leadSource = document.getElementById("lead_source");
	var _Confirma = document.getElementById("confirma");
	
	if (_firstName.value == '') {
		alert("Please, complete the required fields.");
		_firstName.focus();
		return false;
	}
	
	if (_LastName.value == '') {
		alert("Please, complete the required fields.");
		_LastName.focus();
		return false;
	}
	
	if ((_email.value == "")|| (_email.value.indexOf('@') == -1) || (_email.value.indexOf('.') == -1)) {
		alert("Please, complete the required fields.");
		_email.focus();
		return false;
	}
	
	if (_leadSource.value == '') {
		alert("Please, complete the required fields.");
		_leadSource.focus();
		return false;
	}
	
	if (_Confirma.value == '') {
		alert("Please, complete the required fields.");
		_Confirma.focus();
		return false;
	}
}

function Validar2_en() {
	var _firstName = document.getElementById("first_name");
	var _LastName = document.getElementById("last_name");
	var _email = document.getElementById("email1");
	var _Phone = document.getElementById("phone_home");
	var _leadSource = document.getElementById("lead_source");
	var _lead_Price = document.getElementById("lead_price_range_c");
	var _Confirma = document.getElementById("confirma");
	
	if (_firstName.value == '') {
		alert("Please, complete the required fields.");
		_firstName.focus();
		return false;
	}
	
	if (_LastName.value == '') {
		alert("Please, complete the required fields.");
		_LastName.focus();
		return false;
	}
	
	if (_Phone.value == '') {
		alert("Please, complete the required fields.");
		_Phone.focus();
		return false;
	}
	
	if ((_email.value == "")|| (_email.value.indexOf('@') == -1) || (_email.value.indexOf('.') == -1)) {
		alert("Please, complete the required fields.");
		_email.focus();
		return false;
	}
	
	if (_leadSource.value == '') {
		alert("Please, complete the required fields.");
		_leadSource.focus();
		return false;
	}
	
	if (_lead_Price.value == '') {
		alert("Please, complete the required fields.");
		_lead_Price.focus();
		return false;
	}
	
	if (_Confirma.value == '') {
		alert("Please, complete the required fields.");
		_Confirma.focus();
		return false;
	}
}

function Validar2_es() {
	var _firstName = document.getElementById("first_name");
	var _LastName = document.getElementById("last_name");
	var _email = document.getElementById("email1");
	var _Phone = document.getElementById("phone_home");
	var _leadSource = document.getElementById("lead_source");
	var _lead_Price = document.getElementById("lead_price_range_c");
	var _Confirma = document.getElementById("confirma");
	
	if (_firstName.value == '') {
		alert("Por favor, complete los campos requeridos.");
		_firstName.focus();
		return false;
	}
	
	if (_LastName.value == '') {
		alert("Por favor, complete los campos requeridos.");
		_LastName.focus();
		return false;
	}
	
	if (_Phone.value == '') {
		alert("Por favor, complete los campos requeridos.");
		_Phone.focus();
		return false;
	}
	
	if ((_email.value == "")|| (_email.value.indexOf('@') == -1) || (_email.value.indexOf('.') == -1)) {
		alert("Por favor, complete los campos requeridos.");
		_email.focus();
		return false;
	}
	
	if (_leadSource.value == '') {
		alert("Por favor, complete los campos requeridos.");
		_leadSource.focus();
		return false;
	}
	
	if (_lead_Price.value == '') {
		alert("Por favor, complete los campos requeridos.");
		_lead_Price.focus();
		return false;
	}
	
	if (_Confirma.value == '') {
		alert("Por favor, complete los campos requeridos.");
		_Confirma.focus();
		return false;
	}
}

function sendFriend(elemid,type) {
	var email = jsGetObject('to_email');
	var email_from = jsGetObject('email_from');
	var nombre = jsGetObject('nombre');
	var comentarios = jsGetObject('comments');
	
	if (email.value == '') {
		alert("Por favor, escriba el(los) correo(s) del(los) destinatario(s).");
		email.focus();
		return false;
	}
	
	if (nombre.value == '') {
		alert("Por favor, coloque su Nombre completo.");
		nombre.focus();
		return false;
	}
	
	if (email_from.value == '') {
		alert("Por favor, coloque su correo electrónico.");
		email_from.focus();
		return false;
	}
	
	var ajx = new SetAjax();
	ajx.FilePath = __strMainDir + "includes/procesos/send_friend.php";
	ajx.ElementPlainText = false;
	//ajx.Element = jsGetObject('Options');
	ajx.setVar = [["elemid", elemid], ["type", type], ["email", email.value], ["email_from", email_from.value], ["nombre", nombre.value], 
	["comentarios", comentarios.value]];
	ajx.onLoading = function() {
		document.body.style.cursor = "wait";
	}
	ajx.manageError = function(err,val) {
		document.body.style.cursor = "default";
	}
	ajx.onCompletion = function() {
		document.body.style.cursor = "default";
		email.value = '';
		email_from.value = '';
		nombre.value = '';
		comentarios.value = '';
		jsGetObject('sent_email').style.visibility = 'visible';		
	}
	ajx.Execute();
	delete ajx;
}