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;
}


