function esValidoEmail(valor){if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){return(true)}else{return(false);}}
function popup(url,name,ancho,alto){var caracteristicas;caracteristicas="screenX=50,screenY=50,location=0,resizable=0,status=0,titlebar=1,directories=0,toolbar=0,menubar=0,scrollbars=1,status=0";ancho=ancho+50;alto=alto+70;if(ancho>0)caract_ancho=",WIDTH="+ancho;else caract_ancho="WIDTH=300";if(alto>0)caract_alto=",HEIGHT="+alto;else caract_alto=",HEIGHT=350";caracteristicas=caracteristicas+caract_ancho+caract_alto;newWin=window.open(url,name,caracteristicas);var windowX=(screen.width/2)-(ancho/2);var windowY=(screen.height/2)-(alto/2);newWin.moveTo(windowX,windowY)
newWin.focus();onscreen=true;}<!--
function setPointer(theRow,thePointerColor)
{thePointerColor="url("+thePointerColor+")";if(thePointerColor==''||typeof(theRow.style)=='undefined'){return false;}
if(typeof(document.getElementsByTagName)!='undefined'){var theCells=theRow.getElementsByTagName('td');}
else if(typeof(theRow.cells)!='undefined'){var theCells=theRow.cells;}
else{return false;}
var rowCellsCnt=theCells.length;for(var c=0;c<rowCellsCnt;c++){theCells[c].style.backgroundImage=thePointerColor;}
return true;}
function setBrowser()
{if(document.all)
{isIE4=true;isNav6=true;}
else if(document.layers)
{isNav4=true}
else if(document.getElementById)
{isNav6=true}}
function getElementById(strId)
{setBrowser();if(isNav6)
{return document.getElementById(strId);}
else if(isIE4)
{return document.all[strId]}
else
{return null}}
function getElementObject(element)
{setBrowser();var oElement=null;if(typeof element=="object")
{oElement=element;}
else if(typeof element=="string")
{oElement=getElementById(element);}
return oElement;}
function getStyleBySelector(selector)
{setBrowser();if(!isNav6)
{return null;}
var sheetList=document.styleSheets;var ruleList;var i,j;for(i=sheetList.length-1;i>=0;i--)
{ruleList=sheetList[i].cssRules;for(j=0;j<ruleList.length;j++)
{if(ruleList[j].type==CSSRule.STYLE_RULE&&ruleList[j].selectorText==selector)
{return ruleList[j].style;}}}
return null;}
function getStylePropertyById(strId,strProperty)
{setBrowser();if(isNav6)
{var styleObject=document.getElementById(strId);if(styleObject!=null)
{styleObject=styleObject.style;if(styleObject[strProperty])
{return styleObject[strProperty];}}
styleObject=getStyleBySelector("#"+strId);return(styleObject!=null)?styleObject[strProperty]:null;}
else if(isIE4)
{return document.all[strId].style[strProperty];}
else
{return""}}
function setStylePropertyById(strId,strProperty,strValue)
{setBrowser();if(isNav6)
{var styleObject=document.getElementById(strId);if(styleObject!=null)
{styleObject=styleObject.style;styleObject[strProperty]=strValue;}}
else if(isIE4)
{if(document.all[strId]!=null)
document.all[strId].style[strProperty]=strValue;}
else
{}}
function setStylePropertyByElement(oElement,strProperty,strValue)
{setBrowser();if(isNav6)
{var styleObject=oElement;if(styleObject!=null)
{styleObject=styleObject.style;styleObject[strProperty]=strValue;}}
else if(isIE4)
{if(oElement!=null)
oElement.style[strProperty]=strValue;}
else
{}}
function toggleElementDisplay(element,strStyle)
{setBrowser();var strID
if(typeof element=="object")
{strID=element.id}
else if(typeof element=="string")
{strID=element}
if((strID!="")&&(strID!=null)){if(getStylePropertyById(strID,'display')=='none'){setStylePropertyById(strID,'display',strStyle)}else{setStylePropertyById(strID,'display','none')}}}
function toggleLayer(element,strStyle)
{setBrowser();var strID
if(typeof element=="object")
{strID=element.id}
else if(typeof element=="string")
{strID=element}
if((strID!="")&&(strID!=null)){if(getStylePropertyById(strID,'display')=='none'){if(empezar){clearTimeout(retardo)
setStylePropertyById(strID,'display',strStyle)}}else{if(empezar){clearTimeout(retardo)
retardo=setTimeout("setStylePropertyById( "+strID+", 'display', 'none' )",1000)}}}}

function agregarComentario(id) {
	if (document.getElementById){
 	       var el=document.getElementById(id);
               el.style.display=(el.style.display=='none')?'block':'none';
        }
}

function verContenido(capa, id){
	var url = document.location.host
        divResultado = document.getElementById(capa);
        ajax = objetoAjax();
        ajax.open("GET", "http://"+url+"/content.php?id=" + id);
        ajax.onreadystatechange=function() {
        	if (ajax.readyState==4) {
		        divResultado.innerHTML = ajax.responseText
                }
        }
        ajax.send(null)
}

function validarComentario(cat, subcat, lang)
{
        var url = document.location.host;
        var nombre = document.getElementById('nombre2').value;
        var email = document.getElementById('email').value;
        var comentario = document.getElementById('comentario').value;
        var codigo = document.getElementById('recaptcha_response_field').value;
        var codigo2 = document.getElementById('recaptcha_challenge_field').value;
        var error = false;
        var url_validar = "http://" + url + "/comment_validate.php?";

        /* Mensajes de error por defecto en espaÃ±ol */
        var str_error_nombre = 'Por favor ingrese un nombre';
        var str_error_email = 'Por favor ingrese un email';
        var str_error_email_valido = 'Por favor ingrese un email valido';
        var str_error_comentario = 'Por favor ingrese un comentario';
        var str_prohibido = 'Tu comentario contiene palabras prohibidas. Revisa tu mensaje y cambialo';
        var str_error_codigo1 = 'Por favor ingrese el codigo de seguridad';
        var str_error_codigo2 = 'El codigo debe ser igual a la imagen';

        if (lang == 'en') {
                var str_error_nombre = 'Please enter a name';
                var str_error_email = 'Please enter a email';
                var str_error_email_valido = 'Please enter a valid email';
                var str_error_comentario = 'Please enter a comment';
                var str_prohibido = 'Your comment contains forbidden words. Review your message and change';
                var str_error_codigo1 = 'Please enter the security code';
                var str_error_codigo2 = 'The code must be equal to the image';
        } else if (lang == 'pt') {
                var str_error_nombre = 'Por favor, indique um nome';
                var str_error_email = 'Por favor, indique um e-mail';
                var str_error_email_valido = 'Por favor insira um email valido';
                var str_error_comentario = 'Por favor, indique um comentario';
                var str_prohibido = 'Seu comentario contiver palavras proibidas. Reveja sua mensagem e altera-lo';
                var str_error_codigo1 = 'Por favor insira o codigo de seguranca';
                var str_error_codigo2 = 'O codigo deve ser igual a imagem';
        }

        var error_comentario = document.getElementById('error_comentario');

        document.getElementById('nombre1').innerHTML = '';
        document.getElementById('email1').innerHTML = '';
        document.getElementById('comentario1').innerHTML = '';
        document.getElementById('codigo1').innerHTML = '';
        error_comentario.innerHTML = '';

        if (nombre == '') {
                document.getElementById('nombre1').innerHTML = str_error_nombre;
                error = true;
        }

        /*if (email == '') {
                document.getElementById('email1').innerHTML = str_error_email;
                error = true;
        } else if (!esValidoEmail(email)){
                document.getElementById('email1').innerHTML = str_error_email_valido;
                error = true;
        }*/

        if (comentario == '') {
                document.getElementById('comentario1').innerHTML = str_error_comentario;
                error = true;
        }

        if (codigo == '') {
                document.getElementById('codigo1').innerHTML = str_error_codigo1;
                error = true;
        }

        if (nombre) { url_validar += "?nombre=" + nombre; }
        if (comentario) { url_validar += "&comentario=" + comentario; }
        if (cat) { url_validar += "&id_cat=" + cat; }
        if (subcat) { url_validar += "&id_subcat=" + subcat; }
        if (codigo) { url_validar += "&codigo=" + codigo; }
        if (codigo2) { url_validar += "&codigo2=" + codigo2; }

        if (error == false) {
                ajax = objetoAjax();

                ajax.open("GET", url_validar);
                ajax.onreadystatechange=function() {
                if (ajax.readyState==4) {
                                if (ajax.responseText == '1') {
                                        error_comentario.innerHTML = '<img src="http://static01.evisos.com/images/ico_error2.gif" hspace="5"> ' + str_prohibido
                                } else {
                                        if ( ajax.responseText == 'error_code' || ( clStr(ajax.responseText)!=clStr(codigo) ) ) {
                                                Recaptcha.reload ();
                                                document.getElementById('codigo1').innerHTML = str_error_codigo2;
                                        } else {
                                        	document.frmComentario.submit();
                                        }
                                }
                        }
                }
                ajax.send(null)
        }
}

function checkPost ( form, lang )
{
        if (lang == 'es') {
                str_title = 'Debe ingresar un titulo';
                str_zona = 'Debe seleccionar una provincia';
                str_category = 'Debe seleccionar una categoria';
                str_subcategory = 'Debe seleccionar una subcategoria';
                str_text = 'Debe ingresar una descripcion';
                str_email = 'Debe ingresar un email';
        }else if(lang == 'en'){
                str_title = 'You must enter a title';
                str_zona = 'You must select a region';
                str_category = 'You must select a category';
                str_subcategory = 'Your must select a subcategory';
                str_text = 'You must enter a description';
                str_email = 'You must enter a e-mail adress';
        }else if(lang == 'pt') {
                str_title = 'O senhor(a) deve ingressar um titulo';
                str_zona = 'Deve selecionar um estado';
                str_category = 'Deve selecionar uma categoria';
                str_subcategory = 'Deve selecionar uma subcategoria';
                str_text = 'Deve ingressar uma descricao';
                str_email = 'Deve ingressar um e-mail';
        }

        if (form.titulo.value == "") {
                alert( str_title );
                form.titulo.focus();
                return false ;
        }else if (form.lugar.value == "") {
                alert( str_zona );
                form.lugar.focus();
                return false ;
        }else if (form.categoria.value == "") {
                alert( str_category );
                form.categoria.focus();
                return false ;
        }else if (form.subcategory.value == "") {
                alert( str_subcategory );
                form.subcategory.focus();
                return false ;
        }else if (form.texto.value == "") {
                alert( str_text );
                form.texto.focus();
                return false ;
        }else if (form.email.value == "") {
                alert( str_email );
                form.email.focus();
                return false ;
        }

  return true ;
}

function init_detail(url_video)
{
	jQuery.noConflict();
	jQuery(document).ready(function(){
		if(url_video)
		{
			jQuery("#oembed").oembed(url_video, {embedMethod: "replace", maxWidth: 500, maxHeight: 400}, function(container, oembed) {container.replaceWith("<div id='oembed'>" + oembed.code + "</div>")});
		}
		makeFloat();
	});
}

function getNumFrames()
{
	var num_frames = parent.frames.length;
	return num_frames;
}

function clStr(str)
{
    str = str.replace("\r", "");
    str = str.replace("\n", "");
    str = str.replace(" ", "");
    return str;
}

function checkEnter2(e, lang) {

	var characterCode;	
	id_cat = document.getElementById('id_cat').value;
	id_prov = document.getElementById('id_prov').value;
	word = document.getElementById('word').value;

	if(e&&e.which){ e=e;characterCode=e.which; }else{ e=event;characterCode=e.keyCode; }

	if(characterCode==13){
		if (!word) {
                	document.getElementById('error_cat').innerHTML = getLang('ibus', lang);
	                return false;
                } else if (!id_cat) {
	                document.getElementById('error_cat').innerHTML = getLang('scat', lang);
        	        return false;
	        } else if (word.length<3) {
	                document.getElementById('error_cat').innerHTML = getLang('mbus', lang);
        	        return false;
	        }
		buscar(id_cat, id_prov);
	}else{
		return true
	}
}

function subCategory2(id){
	var patron=/subcat/;
	if(patron.test(id)){
		document.getElementById('id_subcat').value=id.substring(7,id.length);
		return true;
	}
	return false;
}

function buscar2(base_url, subdomain, id_cat, id_prov, lang) {
	var url_category = '';
	var url_subcategory = '';
	var url_word = '?word='+document.getElementById('word').value;
	var word = document.getElementById('word').value;
	var url_province = '';
	var str_ibus = '';
	var str_scat = '';
	
	if (!word) { document.getElementById('error_cat').innerHTML = getLang('ibus', lang); return false; }
	else if (word.length<3) { document.getElementById('error_cat').innerHTML = getLang('mbus', lang); return false; }

	if (id_cat){ var url_category = "&id_cat="+document.getElementById('id_cat').value;}
	else { document.getElementById('error_cat').innerHTML = getLang('scat', lang); return false; }



	if (subCategory2(id_cat)){
		var url_subcategory = '&id_subcat='+document.getElementById('id_subcat').value;
		var url_category = '';
	}

	if (id_prov && subdomain == 'www') var url_province = '&id_prov='+document.getElementById('id_prov').value;

	window.location = base_url + 'result.php' + url_word + url_category + url_subcategory + url_province;
}

function getLang(str, lang)
{
	if(str=="ibus")
	{
		if (lang == 'es') { str = 'Por favor ingrese una busqueda'; }
		else if(lang == 'en'){ str = 'Please enter a search'; }
		else if(lang == 'pt') { str = 'Por favor introduza uma busca'; }
		else if(lang == 'fr') { str = 'S\'il vous pla&icirc;t entrer une recherche'; }
	}
	else if(str=="scat")
	{
		if (lang == 'es') { str = 'Por favor seleccione una categoria'; }
		else if(lang == 'en'){ str = 'Please select a category'; }
		else if(lang == 'pt') { str = 'Por favor seleccione uma categoria'; }
		else if(lang == 'fr') { str = 'S\'il vous pla&icirc;t choisir une cat&eacute;gorie'; }
	}
	else if(str=="mbus")
	{
		if (lang == 'es') { str = 'Ingrese al menos 3 caracteres'; }
		else if(lang == 'en'){ str = 'Enter at least 3 characters'; }
		else if(lang == 'pt') { str = 'Digite pelo menos 3 caracteres'; }
		else if(lang == 'fr') { str = 'Entrez au moins 3 caract&egrave;res'; }
	}
	return str;
}

function isIE() {
	return 'v'=='\v';//Detect if the browser is IE
}

function flike() {
    	if(isIE()) {
        	document.write("<div id=\"like\">\n<iframe src='http:\/\/www.facebook.com\/plugins\/like.php?href=http://lapaz.evisos.com.bo/compra-venta-inmuebles/departamentos/departamento-en-venta-13.mhtm&amp;layout=button_count'\n        scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:70px; height:21px;' \n        allowTransparency='true'>\n<\/iframe>\n<\/div>\n");
    	} else {
        	document.write("<div id=\"fb-root\"><\/div>\n<div id=\"like\">\n<fb:like href=\"http://lapaz.evisos.com.bo/compra-venta-inmuebles/departamentos/departamento-en-venta-13.mhtm \"\n         layout=\"button_count\"\n         show_faces=\"false\"\n  font=\"verdana\">\n<\/fb:like>\n<\/div>\n<div id=\"send\">\n    <fb:send href=\"http://lapaz.evisos.com.bo/compra-venta-inmuebles/departamentos/departamento-en-venta-13.mhtm\"><\/fb:send>\n<\/div>\n");
    	}
}

var num_frames = parent.frames.length;

