function trackAjax(pageId, url) {
	pageTracker._trackPageview(url);
	reloadAds(pageId);
	qpquantserve(strQPDomain + url);
}
function reloadOAS() {
	if (document.getElementById('osaIframeTop')) {
document.getElementById('osaIframeTop').src=strsitepage+'d=14;w=728;h=90';
 }
if (document.getElementById('osaIframeMiddle')) {
document.getElementById('osaIframeMiddle').src=strsitepage+'d=9;w=300;h=250';
  }
if (document.getElementById('osaIframeLeft')) {
document.getElementById('osaIframeLeft').src=strsitepage+'d=7;w=160;h=600';
  }
if (document.getElementById('osaIframeBottom')) {
document.getElementById('osaIframeBottom').src=strsitepage+'w=468;h=60';
  }
setTimeout("reloadOAS()",120000);
}

function reloadAds(page) {
	if (document.getElementById('osaIframeTop')) {
document.getElementById('osaIframeTop').src=strsitepage+'d=14;w=728;h=90';
 }
if (document.getElementById('osaIframeMiddle')) {
document.getElementById('osaIframeMiddle').src=strsitepage+'d=9;w=300;h=250';
  }
if (document.getElementById('osaIframeLeft')) {
document.getElementById('osaIframeLeft').src=strsitepage+'d=7;w=160;h=600';
  }
if (document.getElementById('osaIframeBottom')) {
document.getElementById('osaIframeBottom').src=strsitepage+'w=468;h=60';
  }
   
}
function old_ie_fixes() {
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
      var ieversion = new Number(RegExp.$1);
        if (ieversion<7){
            if (document.getElementById('nav')) {
                addEventMenu(document.getElementById('nav'));
            }
            if (document.getElementById('nav2')) {
                addEventMenu(document.getElementById('nav2'));
            } 
        }
    } 
}
function addEventMenu(oElement){
    var arrLi = oElement.getElementsByTagName("li");
    for(var numI =0;numI<arrLi.length;numI++){
        arrLi[numI].onmouseover=function(){   
            this.className="sfhover";
        };
        arrLi[numI].onmouseout=function(){
            this.className="";
        };
    }
}
function trim(str) {     
    if(!str || typeof str != 'string')         
        return null;     
    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' '); 
}

function chatNoficiationMover() {
    //setMenuOffset.initialPos = getStyle('header','top');
    window.onscroll = document.documentElement.onscroll = chatNotification;
    chatNotification();
}

function chatNotification() {
    var notification = document.getElementById('chat-notification');
    if (!notification) return;
    var currentOffset = document.documentElement.scrollTop || document.body.scrollTop; // body for Safari
    var desiredOffset = currentOffset;
    if (desiredOffset != parseInt(notification.style.top))
        notification.style.top = desiredOffset + 'px';

/*    var currentLeftOffset = document.documentElement.scrollLeft || document.body.scrollLeft; // body for Safari
    if (currentLeftOffset != - parseInt(notification.style.left))
    notification.style.left = '-' + currentLeftOffset + 'px';*/
}

function closeNotification() {
    var notification = document.getElementById('chat-notification');
    notification.style.display = 'none';
}
/*****************************************************************
 *  Empiezan las funciones del registro/login del grey box       *
 */
function registerpop(playboy,register,community,drreyvar){
    var sURL ='';
	if( playboy==true ){
        sURL = '/register/popup/step1popup.php?playboy=true';
    }else {

        if (community != 0){
            sURL = '/register/popup/step1popup.php?community='+community;
        }else{
            sURL = '/register/popup/step1popup.php?';
        }
         if (drreyvar== 'drrey'){
               sURL = '/register/popup/step1popup.php?drrey=true';
           }
    }
    if (register==true){
        sURL = sURL+"&register=true&height=480&width=600&modal=true";
    }else{
        sURL = sURL+"&height=355&width=600&modal=true";
    }
    tb_show('', sURL, false);
}
function step2pop(playboy,community,drreyvar,language){
    var sURL ='';
	if (playboy == true){
        sURL = '/'+language+'/register/popup/step2popup.php?playboy=true';
    }else {
        if (community > 0){
            sURL = '/'+language+'/register/popup/step2popup.php?community='+community;
        }else{
            sURL = '/'+language+'/register/popup/step2popup.php?';
        }
        if (drreyvar== true){
           sURL = '/'+language+'/register/popup/step2popup.php?drrey=true';
        }
    }
    sURL = sURL+"&height=450&width=600&modal=true";
    tb_show('', sURL, false);
}
function loginpop(community){
    var username = $('#textfieldloginun').val();
    var password = $('#textfieldloginpass').val();
    var qprememberme = false;
    if (document.getElementById('textfieldqprememberme').checked){
        qprememberme = true;
    }
    var sData = 'username='+username+'&password=' + password + '&qprememberme=' + qprememberme;
    var sURL = "/register/popup/actions/login.php";
    var html = $.ajax({type: "POST", url: sURL, async: false,data: sData}).responseText;
    if (html=='reactivate') {
        window.location.href='/home/deactivate/reactiveaccount.php';
    } else {
        if (html==0){
            document.getElementById('wrongpass').style.display="";
            return false;
        }
        if (html==1){
            //if (community > 0){
            if (undefined != community){
                var alianza = document.getElementById('alianza');
                if (undefined != alianza){
                    alizanjoin();
                }else{
                    window.location.href=window.location.href
                }
            }else{
                window.location.href=window.location.href
            }
        }
    }
    return false;
}
function registeraction(community,language){
    var usr_email = $('#usr_emailpu').val();
	var usr_pass      = $('#usr_passpu').val();
	var yeardropdown     = $('#year_1pu').val();
	var monthdropdown     = $('#month_1pu').val();
	var daydropdown   = $('#day_1pu').val();
    /**Cuidado! hay que deshabilidar todos los mensajes de error aqui **/
        document.getElementById('correopu').style.display='none';
        document.getElementById('passpu').style.display='none';
        document.getElementById('pass1pu').style.display='none';
        document.getElementById('passwordmessagepu').style.display='none';
        document.getElementById('nodatepu').style.display='none';
        document.getElementById('correophppu').style.display='none';
        document.getElementById('dberrorpu').style.display='none';
        document.getElementById('invalidmailpu').style.display='none';
        document.getElementById('passpu').style.display='none';
    /**Termina deshabilitar mensajes de error **/
    /**Variables**/
    var registerError= true;
    var mail = document.getElementById('usr_emailpu');
    var pass = document.getElementById('usr_passpu');
    var regPassword = /^([A-Za-z0-9\!\@\#\$\%\^\&\*\(\)\-\_\=\\\+\.\,\/\;\:\'\?\|\"\}\{\]\[])*$/;
    var bdayMonth = document.getElementById('month_1pu').options[document.getElementById('month_1pu').selectedIndex].value;
    var bdayDay = document.getElementById('day_1pu').options[document.getElementById('day_1pu').selectedIndex].value;
    var bdayYear = document.getElementById('year_1pu').options[document.getElementById('year_1pu').selectedIndex].value;
    /**Variables**/
    /**Comprobacion de correo**/
	var filter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
    document.getElementById('correopu').style.display='none';
	if (mail.value=='' && registerError){
		document.getElementById('correopu').style.display='';
		registerError = false;
	}
	if (mail.value.length > 125 && registerError){
	document.getElementById('correopu').style.display='';
		registerError = false;
	}
	if ( ((mail.value.indexOf ('@',0)==-1) || (mail.value.indexOf ('.',0)==-1) || (mail.value.length <5) )&& registerError){
		document.getElementById('correopu').style.display='';
		registerError = false;
	}
	if (mail.value.indexOf ('@',0)==(mail.value.indexOf ('.',0)-1) && registerError){
		document.getElementById('correopu').style.display='';
		registerError = false;
	}
	if(!filter.test(mail.value) && registerError){
		document.getElementById('correopu').style.display='';
		registerError = false;
	}
 /**Termina comprobacion de correos **/
/**Empieza password **/
    if(!regPassword.test(pass.value) && registerError){
        document.getElementById('passpu').style.display='';
        document.getElementById('pass1pu').style.display='none';

        pass.focus();
        registerError = false;
    }
    if((pass.value.length < 6 || pass.value.length > 25) && registerError){
        document.getElementById('passpu').style.display='';
        document.getElementById('pass1pu').style.display='none';

        pass.focus();
        registerError = false;
    }
/**Termina password**/
/**Fecha de nacimiento**/
    if (((bdayMonth=="--") || (bdayDay=="--") || (bdayYear=="--")) && registerError){
		var tempalert = document.getElementById('bdaytextpu').value;
        document.getElementById('nodatepu').style.display='';
		registerError = false;
	}

/**Termina Fecha de nacimiento**/
    if (registerError==true){
        $('.divloading').show();
        document.getElementById('usr_emailpu').disabled = true;
        document.getElementById('usr_passpu').disabled = true;
        document.getElementById('month_1pu').disabled = true;
        document.getElementById('day_1pu').disabled = true;
        document.getElementById('year_1pu').disabled = true;
        document.getElementById('btregisterblock').style.display='none';

        var playboy = document.getElementById('playboy');
        if (playboy.value=='playboy'){
        var playboyparam = true;
        } else {
            playboyparam = "";
        }
        var drrey = document.getElementById('drrey');
        if (drrey.value=='drrey'){
        var drreyparam = true;
        } else {
            drreyparam = "";
        }
        var sData = 'usr_email='+usr_email+'&usr_pass=' + usr_pass + '&yeardropdown=' + yeardropdown + '&monthdropdown=' + monthdropdown + "&daydropdown=" + daydropdown+ "&popupreg=true";
        var sURL = "/register/popup/actions/actionstep1.php";
        var html = $.ajax({type: "POST", url: sURL, async: false,data: sData}).responseText;
        if (html==2){
            $('.divloading').hide();
            document.getElementById('usr_emailpu').disabled = false;
            document.getElementById('usr_passpu').disabled = false;
            document.getElementById('month_1pu').disabled = false;
            document.getElementById('day_1pu').disabled = false;
            document.getElementById('year_1pu').disabled = false;
            document.getElementById('btregisterblock').style.display='';
            document.getElementById('correophppu').style.display='';
            return false;
        }
        if (html==16 || html==128 ){
            document.getElementById('dberrorpu').style.display='';
            $('.divloading').hide();
            document.getElementById('usr_emailpu').disabled = false;
            document.getElementById('usr_passpu').disabled = false;
            document.getElementById('month_1pu').disabled = false;
            document.getElementById('day_1pu').disabled = false;
            document.getElementById('year_1pu').disabled = false;
            document.getElementById('btregisterblock').style.display='';
            return false;
        }
        if (html==32 || html==2448 || html==2560 || html==2048 || html==2308 || html==512 || html==2820){
            $('.divloading').hide();
            document.getElementById('usr_emailpu').disabled = false;
            document.getElementById('usr_passpu').disabled = false;
            document.getElementById('month_1pu').disabled = false;
            document.getElementById('day_1pu').disabled = false;
            document.getElementById('year_1pu').disabled = false;
            document.getElementById('btregisterblock').style.display='';
            document.getElementById('invalidmailpu').style.display='';
            return false;
        }
        if(html==256 || html==2820){
            $('.divloading').hide();
            document.getElementById('usr_emailpu').disabled = false;
            document.getElementById('usr_passpu').disabled = false;
            document.getElementById('month_1pu').disabled = false;
            document.getElementById('day_1pu').disabled = false;
            document.getElementById('year_1pu').disabled = false;
            document.getElementById('btregisterblock').style.display='';
            document.getElementById('passpu').style.display='';
            return false;
        }
        if(html==4){
            $('.divloading').hide();
            document.getElementById('usr_emailpu').disabled = false;
            document.getElementById('usr_passpu').disabled = false;
            document.getElementById('month_1pu').disabled = false;
            document.getElementById('day_1pu').disabled = false;
            document.getElementById('year_1pu').disabled = false;
            document.getElementById('btregisterblock').style.display='';
            document.getElementById('nodatedbpu').style.display='';
            return false;
        }

        $('.divloading').hide();
        document.getElementById('usr_emailpu').disabled = false;
        document.getElementById('usr_passpu').disabled = false;
        document.getElementById('month_1pu').disabled = false;
        document.getElementById('day_1pu').disabled = false;
        document.getElementById('year_1pu').disabled = false;
        document.getElementById('btregisterblock').style.display='';
        step2pop(playboyparam,community,drreyparam,language);
    }
    return false;
}
function registerfinish(community){
    var usr_firstname = $('#usr_firstname').val();
	var usr_lastname      = $('#usr_lastname').val();
	var usr_name     = $('#usr_name').val();
    var usr_mobilenumber = $('#usr_mobilenumber').val();
    var drrey = document.getElementById('drrey');
    if (drrey.value=='drrey'){
        var drreyparam = true;
    } else {
        drreyparam = "";
    }
    if (document.getElementById('hombre').checked){
       var sex = $('#hombre').val();
    }
    if (document.getElementById('mujer').checked){
        var sex = $('#mujer').val();
    }
    //Validaciones
    var firstname = document.getElementById('usr_firstname');
    var lastname = document.getElementById('usr_lastname');

    var username = document.getElementById('usr_name');
    var genderm = document.getElementById('hombre');
    var genderf = document.getElementById('mujer');
    var regusername =/^([A-Za-z0-9\-\_\.])*$/;
    var regTxt = /^([a-zA-Z\sáéíóúñÁÉÍÓÚÑÄËÏÖÜäëïöüãâêôõçÃÂÊÔÕÇ])*$/;
    var reguser =/^([\-\_\.])*$/;
    var username_exist = document.getElementById('user_exist');
    document.getElementById('nombre').style.display='none';
    document.getElementById('nombre1').style.display='none';
    document.getElementById('nombre2').style.display='none';
    document.getElementById('apellido').style.display='none';
    document.getElementById('apellido1').style.display='none';
    document.getElementById('apellido2').style.display='none';
    document.getElementById('usrname1').style.display='none';
    document.getElementById('usrname2').style.display='none';
    document.getElementById('usrname3').style.display='none';
    document.getElementById('usrname4').style.display='none';
    document.getElementById('gender').style.display='none';
    document.getElementById('usrname4').style.display='none';
    document.getElementById('arrDisponibles').style.display="none";
    document.getElementById('usernameaction').style.display="none";
    document.getElementById('nombre1').style.display="none";
    document.getElementById('mistakeserverv3').style.display="none";
    var registerError= true;
    //User login
    if (username.value=='' && registerError){
        document.getElementById('usrname4').style.display='';
        document.getElementById('usrname1').style.display='none';
        document.getElementById('usrname2').style.display='none';
        document.getElementById('usrname3').style.display='none';
        username.focus();
        registerError = false;
    }
    if (username.value.length > 50 && registerError){
        document.getElementById('usrname2').style.display='';
        document.getElementById('usrname1').style.display='none';
        document.getElementById('usrname3').style.display='none';
        document.getElementById('usrname4').style.display='none';
        username.focus();
        registerError = false;
    }
    if (!regusername.test(username.value) && registerError){
        document.getElementById('usrname1').style.display='';
        document.getElementById('usrname3').style.display='none';
        document.getElementById('usrname4').style.display='none';
        document.getElementById('usrname2').style.display='none';
        username.focus();
        registerError = false;
    }
    if (username.value != "" && registerError){
		if (username.value.length < 4 ){
            document.getElementById('usrname4').style.display='';
            document.getElementById('usrname3').style.display='none';
            document.getElementById('usrname2').style.display='none';
            document.getElementById('usrname1').style.display='none';
			firstname.focus();
            registerError = false;
		}else if (reguser.test(username.value.charAt(0))){
			document.getElementById('usrname3').style.display='';
			document.getElementById('usrname1').style.display='none';
			document.getElementById('usrname2').style.display='none';
			document.getElementById('usrname4').style.display='none';
			username.focus();
			registerError = false;
		}else if (reguser.test(username.value.charAt(username.value.length-1))){
			document.getElementById('usrname3').style.display='';
			document.getElementById('usrname2').style.display='none';
			document.getElementById('usrname1').style.display='none';
			document.getElementById('usrname4').style.display='none';
			username.focus();
			registerError = false;
		}
    }
    //Nombre
    if (firstname.value=='' && registerError){
        document.getElementById('nombre').style.display='';
        firstname.focus();
        registerError = false;
    }
    if (!regTxt.test(firstname.value) && registerError){
        document.getElementById('nombre1').style.display='';
        firstname.focus();
         registerError = false;
    }else if (firstname.value.length == 1 && registerError){
		document.getElementById('nombre2').style.display='';
        firstname.focus();
        registerError = false;
    }
    //Apellido
    if (lastname.value=='' && registerError){
        document.getElementById('apellido').style.display='';
        lastname.focus();
        registerError = false;
    }
    if (!regTxt.test(lastname.value) && registerError){
        document.getElementById('apellido1').style.display='';
        lastname.focus();
        registerError = false;
    }else if (lastname.value.length == 1 && registerError){
        document.getElementById('apellido2').style.display='';
        firstname.focus();
        registerError = false;
    }
    //Gender
    if (!(genderm.checked || genderf.checked) && registerError){
        document.getElementById('gender').style.display='';
        genderm.focus();
        registerError = false;
    }
    //Se acaban validaciones
    if(registerError==true){

        $('.divloading').show();
        document.getElementById('usr_firstname').disabled = true;
        document.getElementById('usr_lastname').disabled = true;
        document.getElementById('hombre').disabled = true;
        document.getElementById('mujer').disabled = true;
        document.getElementById('usr_name').disabled = true;
        document.getElementById('usr_mobilenumber').disabled = true;
        document.getElementById('btregisterst2block').style.display='none';
        var sData = 'usr_firstname='+usr_firstname+'&usr_lastname=' + usr_lastname + '&usr_name=' + usr_name + '&sex=' + sex +"&usr_mobilenumber="+usr_mobilenumber;
        var sURL = "/register/popup/actions/actionstep2.php";
        var html = $.ajax({type: "POST", url: sURL, async: false,data: sData}).responseText;
        if(html==1){
            document.getElementById('usr_firstname').disabled = false;
            document.getElementById('usr_lastname').disabled = false;
            document.getElementById('hombre').disabled = false;
            document.getElementById('mujer').disabled = false;
            document.getElementById('usr_name').disabled = false;
            document.getElementById('usr_mobilenumber').disabled = false;
            document.getElementById('btregisterst2block').style.display='';
            document.getElementById('arrDisponibles').style.display="";
            document.getElementById('usernameaction').style.display="";
            $('.divloading').hide();
            return false;
        }
        if(html==81920 || html==212992 || html==163840 || html==258048  || html==245760){
            $('.divloading').hide();
            document.getElementById('usr_firstname').disabled = false;
            document.getElementById('usr_lastname').disabled = false;
            document.getElementById('hombre').disabled = false;
            document.getElementById('mujer').disabled = false;
            document.getElementById('usr_name').disabled = false;
            document.getElementById('usr_mobilenumber').disabled = false;
            document.getElementById('btregisterst2block').style.display='';
            document.getElementById('nombre1').style.display="";
            return false;
        }
        if(html==4096){
            $('.divloading').hide();
            document.getElementById('usr_firstname').disabled = false;
            document.getElementById('usr_lastname').disabled = false;
            document.getElementById('hombre').disabled = false;
            document.getElementById('mujer').disabled = false;
            document.getElementById('usr_name').disabled = false;
            document.getElementById('usr_mobilenumber').disabled = false;
            document.getElementById('btregisterst2block').style.display='';
            document.getElementById('usrname1').style.display="";
            return false;
        }
        if(html==128){
            $('.divloading').hide();
            document.getElementById('usr_firstname').disabled = false;
            document.getElementById('usr_lastname').disabled = false;
            document.getElementById('hombre').disabled = false;
            document.getElementById('mujer').disabled = false;
            document.getElementById('usr_name').disabled = false;
            document.getElementById('usr_mobilenumber').disabled = false;
            document.getElementById('btregisterst2block').style.display='';
            document.getElementById('mistakeserverv3').style.display="";
            return false;
        }
        $('.divloading').hide();
        document.getElementById('usr_firstname').disabled = true;
        document.getElementById('usr_lastname').disabled = true;
        document.getElementById('hombre').disabled = true;
        document.getElementById('mujer').disabled = true;
        document.getElementById('usr_name').disabled = true;
        document.getElementById('usr_mobilenumber').disabled = true;
        document.getElementById('btregisterst2block').style.display='none';

        tb_remove();
        setTimeout('showthirdstep('+community+')','300');
    }
    return false;
}

function showthirdstep(community){
    tb_show('', '/register/popup/step3popup.php?community='+community+'&height=450&width=600&modal=true', false);
}
function showthirdsteperror(error,community){
    tb_show('', '/register/popup/step3popup.php?community='+community+'&e='+error+'&height=450&width=600&modal=true', false);
}
function closethirdstep(community){
    tb_remove();
    registerthirdstep(community);
}
function registerthirdstep(community){
    if (community > 0){
        var alianza = document.getElementById('alianza');
        if (undefined != alianza){
            alizanjoin();
        }else{
            window.location.href=window.location.href
        }
    }else{
        window.location.href=window.location.href
    }
}

function thirdstepvalidate(){
    var photo = $('#pic').val();
    document.getElementById('errnopic').style.display='none';
    document.getElementById('errwrongfiletype').style.display='none';
    document.getElementById('submitbutton').disabled=true;
    document.getElementById('submitbutton').style.display='none';
    if (photo == "" ){
        document.getElementById('errnopic').style.display='';
        document.getElementById('submitbutton').disabled=false;
        document.getElementById('submitbutton').style.display='';
        return false;
    } else{
        foto= photo.toString().toLowerCase();
        foto = foto.substring(foto.length-4,foto.length);
        if( foto != '.jpg' && foto != 'jpeg' && foto != '.gif' && foto != '.png' && foto != '.bmp'){
            document.getElementById('errwrongfiletype').style.display='';
            document.getElementById('submitbutton').disabled=false;
            document.getElementById('submitbutton').style.display='';
            return false;
        }
    }
    return true;
}
function thirdstepSubmit(resp,community){
    if (resp != 0){
        showthirdsteperror(resp,community);
    }else{
        registerthirdstep(community);
    }
}

function isset(varname){
  return(typeof(window[varname])!='undefined');
}

/**
 * Funcion JS para remover el espacio en blanco usado en los combos
 */
function removeSpacepu(selectObj){
	if (selectObj.options[0].value=="--") {
		selectObj.remove(0);
		//Caso extraordinario donde selecciono el dia al final
		if ((selectObj.id=="day_1pu") && validSpacespu()) {
			ValidateDate();
		}
		if (selectObj.id=="month_1pu") {
			reindexMonths(selectObj);
		}
	}
	return true;
}

/**
 * Funcion JS para validar que los espacios han sido removidos.
 */
function validSpacespu(){
	var monthVal = document.getElementById('month_1pu').options[document.getElementById('month_1pu').selectedIndex].value;
	var yearVal = document.getElementById('year_1pu').options[document.getElementById('year_1pu').selectedIndex].value;
	var dayVal = document.getElementById('day_1pu').options[document.getElementById('day_1pu').selectedIndex].value;
	if ((monthVal=="--") || (dayVal=="--") || (yearVal=="--")) {
		return false;
	}
	return true;
}
/**
 * Funcion JS que valida la fecha seleccionada
 */
function ValidateDatepu() {
	if (!validSpacespu()) {
		return false;
	}
	var month = document.getElementById('month_1pu').selectedIndex;
	var year = document.getElementById('year_1pu').options[document.getElementById('year_1pu').selectedIndex].value;
	var currentmaxdays = document.getElementById('day_1pu').options.length;
	var day = document.getElementById('day_1pu').options[document.getElementById('day_1pu').selectedIndex].value;
	//Convertir a enteros
	month = parseInt(month);
	day = parseInt(day);
	year = parseInt(year);
	var maxdays = getMaxDays(month, year);
	var blnNeedUpdateDays = false;
	//Si el total de dias seleccionados es diferente al total de dias que se tiene actual se tiene que actualizar
	if (currentmaxdays!=maxdays) {
		blnNeedUpdateDays = true;
	}
	if (blnNeedUpdateDays) {
		var oSelectDay = document.getElementById('day_1pu');
		//Si tenemos actualmente mas dias, de los permitidos hay que remover los que sobran
		if (currentmaxdays>maxdays) {
			//El menos 1 es por que son indices, y van de 0 a 29, o 0 a 30, o 0 a 27, o 0 a 28
			for (i = currentmaxdays-1; i >(maxdays-1); i--) {
				oSelectDay.remove(i);
			}
		//Si tenemos actualmente menos dias de los permitidos hay que agregar los que faltan
		} else {
			for (i = currentmaxdays+1; i<=maxdays; i++) {
				var optNew = document.createElement('option');
				optNew.value = i;
				optNew.text = i;
				try {
					oSelectDay.add(optNew, null);
				} catch (ex) {
					oSelectDay.add(optNew); //IE only
				}
			}
		}
	}
	//Si el dia seleccionado esta fuera del rango de dias permitidos, hay que colocarlo dentro del rango
	if (day>maxdays) {
		document.getElementById('day_1pu').selectedIndex = (maxdays-1);
	}
}

function getMaxDays(month, year) {
	month = parseInt(month);
	year = parseInt(year);
	var result = 0;
	//Obtener los dias maximos segun el mes seleccionado
	switch(month) {
		case 0:
		case 2:
		case 4:
		case 6:
		case 7:
		case 9:
		case 11:
			result = 31;
			break;
		case 3:
		case 5:
		case 8:
		case 10:
			result = 30;
			break;
		case 1:
			result = 28;
			if ((year%4==0 && year%100!=0) || (year%4==0 && year%400==0)) {
				result = 29;
			}
	}
	return result;
}

/**
 * Funcion JS, para depurar los valores de los meses.
 */
function reindexMonths(monthSelect) {
	var arrOptions = monthSelect.options
	var numOptions = arrOptions.length;
	for (var x =0; x < numOptions; x++) {
 		var valor = arrOptions[x].value;
 		if (valor) {
			arrOptions[x].value = valor - 1;
		}
	}
}
/**
 * Funcion JS para remover el espacio en blanco usado en los combos
 */
function removeSpace(selectObj){
	if (selectObj.options[0].value=="--") {
		selectObj.remove(0);
		//Caso extraordinario donde selecciono el dia al final
		if ((selectObj.id=="day_1pu") && validSpacespu()) {
			ValidateDate();
		}
		if (selectObj.id=="month_1pu") {
			reindexMonths(selectObj);
		}
	}
	return true;
}
/*
 *  Terninan las funciones del registro/login del grey box       *
 *****************************************************************/
/*****************************************************************
 *  Empiezan las funciones de utils                              *
 */
var globalUserView;
var globalLimit=0;

function resizeProfileImg() {
	var newdimension = 200;
	var profileimage=$('#imgprofile');
	if(profileimage.width()!=null){
		if(isTaller(profileimage.width(),profileimage.height())){if(profileimage.height()>=newdimension)$(profileimage).css('height',newdimension)} else {if(profileimage.width()>=newdimension)$(profileimage).css('width',newdimension)}profileimage.show();
	}
	$('#imgprofile').load(function() {
		if( isTaller(this.width,this.height) ){if(($this).height()>=newdimension)$(this).css('height',newdimension)} else {if($(this).width()>=newdimension)$(this).css('width',newdimension)}$(this).show();
	});
}
function isTaller(width,height) {
	if(height>width){ return true;}
	else {return false};
}
function getContries(){
	$("#DisplayStates").html('');
	$("#DisplayCities").html('');
	$.ajax({type: "GET", url: "/locations/country/countries00.xml",data:'',dataType: 'xml', success: DisplayContries, timeout:3000});
}
function getStates(sContry){
	$("#DisplayStates").html('');
	$("#DisplayCities").html('');
	$.ajax({type: "GET", url:"/locations/region/cty"+sContry+".xml",data: '',dataType: 'xml', success: DisplayStates, timeout:3000});
}
function getCities(sState){
	$("#DisplayCities").html('');
	$.ajax({type: "GET", url: "/locations/city/reg"+sState+".xml",data: '',dataType: 'xml', success: DisplayCities, timeout:10000});
}
function DisplayContries(postData){
	var sSelectedContry=$('#Contries').attr('value');
	var root = postData.getElementsByTagName("countries")[0];
    var countries = root.getElementsByTagName("country");
    var ctySelect = document.getElementById("DisplayContries");
    for(var i = 0; i < countries.length; i++) {
    	if (sSelectedContry == countries[i].getAttribute("id")){
    		ctySelect.options[i+1] = new Option(countries[i].getAttribute("name"), countries[i].getAttribute("id"),true,true);
    	}else{
    		ctySelect.options[i+1] = new Option(countries[i].getAttribute("name"), countries[i].getAttribute("id"),false,false);
    	}
    }
	if ( typeof(sSelectedContry) == 'undefined' || sSelectedContry == '0'){
		var elSel = document.getElementById("DisplayContries");
		sSelectedContry = elSel.options[ elSel.selectedIndex ].value
	}
    getStates(sSelectedContry);
}
function DisplayStates(postData){
	var sSelectedState=$('#States').attr('value');
    var root = postData.getElementsByTagName("country")[0];
    var regions = root.getElementsByTagName("region");
    var regionSelect = document.getElementById("DisplayStates");
	for(var i = 0; i < regions.length; i++) {
	   	if (sSelectedState == regions[i].getAttribute("id")){
    		regionSelect.options[i+1] = new Option(regions[i].getAttribute("name"), regions[i].getAttribute("id"),true,true);
    	}else{
    		regionSelect.options[i+1] = new Option(regions[i].getAttribute("name"), regions[i].getAttribute("id"),false,false);
    	}
    }
	if ( typeof(sSelectedState) == 'undefined' || sSelectedState == '0'){
		var elSel = document.getElementById("DisplayStates");
		sSelectedState = elSel.options[ elSel.selectedIndex ].value
	}
    getCities(sSelectedState);
}
function DisplayCities(postData){
	var sSelectedCity=$('#Cities').attr('value');
	var citieSelect = document.getElementById("DisplayCities");
    citieSelect.innerHtml = '';
    var root = postData.getElementsByTagName("region")[0];
    var regions = root.getElementsByTagName("city");
    for(var i = 0; i < regions.length; i++) {
    	if (sSelectedCity == regions[i].getAttribute("id")){
    		citieSelect.options[i+1] = new Option(regions[i].getAttribute("name"), regions[i].getAttribute("id"),true,true);
    	}else{
        	citieSelect.options[i+1] = new Option(regions[i].getAttribute("name"), regions[i].getAttribute("id"),false,false);
		}
    }
}
function getOriginContries(){
	$.ajax({type: "GET", url:  "/locations/country/countries00.xml",data:'',dataType: 'xml', success: DisplayOriginContries, timeout:3000});
}
function DisplayOriginContries(postData){
	var sSelectedOriginContry=$('#OriginCountryId').attr('value');
	$("#DisplayOriginContries").html('');
	var root = postData.getElementsByTagName("countries")[0];
    var countries = root.getElementsByTagName("country");
    var ctySelect = document.getElementById("DisplayOriginContries");
    if ( typeof(sSelectedContry) == 'undefined'){
		ctySelect.options[0] = new Option("", 0,false,false);
	}
    for(var i = 0; i < countries.length; i++) {
    	if (sSelectedOriginContry == countries[i].getAttribute("id")){
    		ctySelect.options[i+1] = new Option(countries[i].getAttribute("name"), countries[i].getAttribute("id"),true,true);
    	}else{
    		ctySelect.options[i+1] = new Option(countries[i].getAttribute("name"), countries[i].getAttribute("id"),false,false);
    	}
    }
}
function addFriend(usernum){
	var sURL='/user/actions/addFriend.php?iduser=';
	if (usernum > 0){
		sURL=sURL+usernum;
		var html = $.ajax({type: "GET",url: sURL,data:'',async: false}).responseText;
		if (html == '0'){$("#aF0").show();}
		if (html == '1'){$("#aF1").show();}
		if (html == '2'){$("#aF2").show();}
		if (html == '-1' || html == '-2'){$("#aF3").show();}
		if (html == 'no'){$("#aF4").show();}
	}
}
function addFriendAlt(usernum){
	var sURL='/user/actions/addFriend.php?iduser=';
	if (usernum > 0){
		sURL=sURL+usernum;
		var html = $.ajax({type: "GET",url: sURL,data:'',async: false}).responseText;
		if (html == '0'){ $("#addCommMsg").html( $("#aF0").html() ); }
		if (html == '1'){ $("#addCommMsg").html( $("#aF1").html() ); }
		if (html == '2'){ $("#addCommMsg").html( $("#aF2").html() ); }
		if (html == '-1' || html == '-2'){ $("#addCommMsg").html( $("#aF3").html() ); }
		if (html == 'no'){ $("#addCommMsg").html( $("#aF4").html() ); }
	}
}

var gblResultCommentAdd = true;
function AddComment(msg,msg2){
        var commentTxT = $("#commentText").val();
        if (commentTxT.length > 1000){
                alert(msg2);
                document.getElementById('cmdCommentSubmit').disabled=false
                return false;
        }
        if (commentTxT.length < 1){
                alert(msg);
                document.getElementById('cmdCommentSubmit').disabled=false
                return false;
        }
        var rec = document.getElementById("reciber").value;
        var msg1 = document.getElementById("commentText").value;
        $.ajax({type: "POST",url: "/user/actions/addcomment.php",data:'reciber='+ rec +'&commentText=' + encodeURIComponent(msg1) ,success:getAddCommSuccess, async:false});
        return gblResultCommentAdd;
}
function getAddCommSuccess(postData){
        var res =  postData.substring(4);
        if (res<0)
        {
                document.getElementById("commentText").value = "";
                document.getElementById("cmdCommentSubmit").disabled = true;
                $("#errAddComment").html( $.ajax({type: "GET",url: '/user/addCommErrBox.php',data:'userid=' + globalUserView, async: false}).responseText );
                gblResultCommentAdd = false;
        } else {
                gblResultCommentAdd = true;
        }

}
function getPComments(UserView,limit){
	globalUserView = UserView;
	globalLimit = limit;
	var sURL='/user/actions/pagingComments.php?id=';
	if (UserView != null){sURL=sURL+UserView;}
	if (limit != null){sURL=sURL+"&limit="+limit;}
	$.ajax({type: "GET",url: sURL,data:'',success:getPCommentsSuccess});
}
function deleteComment(comemntid,UserView,limit){
	var sURL='/user/actions/delcomments.php';
	$.ajax({type: "GET",url: sURL,data:'commid='+comemntid+'&user='+UserView,success:successDeleteComments});
}

var maxWidthUnit = 415;
function successDeleteComments(postData){
	getPComments(globalUserView,globalLimit);
}
function getPCommentsSuccess(postData){
	comment = document.getElementById('comments');
	comment.innerHTML = postData;
	var itableComment = document.getElementById('comments');
	var arrImages = itableComment.getElementsByTagName("img");
	$(arrImages).each(function() {
		$(this).load(function() {
			if( this.width > maxWidthUnit ){
				var Imgsrc = this.src;
				this.style.cursor="pointer";
				assignOnClick(this,this.width,this.height);
				this.title="Zoom";
				this.height=this.height-(((this.width-maxWidthUnit)/this.width)*this.height);
				this.width = maxWidthUnit;
			}
		});
	});
}
function resizeImage (elementId, maxWidth) {
    var itableComment = document.getElementById(elementId);
    if( itableComment ){
        var ifr = itableComment.getElementsByTagName("img");
        for (x = 0; x < ifr.length ;x++ ){
            try{
                var im = ifr[x];
                if( im.width > maxWidth ){
                    var Imgsrc = im.src;
                    im.style.cursor="pointer";
                    assignOnClick(im,im.width,im.height);
                    im.title="Zoom";
                    im.height=im.height-(((im.width-maxWidth)/im.width)*im.height);
                    im.width = maxWidth;
                }
            }catch(e){}
        }
	}
}
function assignOnClick(im,width,height) {
    var src = im.src;
    if (document.all){
        im.attachEvent("onclick",function(){params ="width="+width+",height="+height;window.open(src,"zoomimage",params);});
    }else {
        im.addEventListener("click",function(){params ="width="+width+",height="+height; window.open(src,"zoomimage",params);}, true);
    }
}
function flaguser(profileid){
	var sURL='/user/actions/actionflag.php?WReport=';
	var intflaglist= $('#flaglist').val();
	var regUrl = /^([0-9])*$/;
	if (regUrl.test(profileid)){
		sURL=sURL+profileid;
		sURL=sURL+"&flaglist="+intflaglist;
		var html = $.ajax({type: "GET",url: sURL,data:'',async: false}).responseText;
		$('#flagbk').hide();
		if (html == 'no'){$("#rF0").show();}
		if (html == '1'){$("#rF1").show();}
		if (html == '0'){$("#rF2").show();}
	}


}
function sendprofile(profileid,msj1,msj2,msj3,msj4){
	var mensaje = document.getElementById('mensaje');
    var mail = document.getElementById('mail');
    var mensavalue = mensaje.value;
    var idprofile = profileid;
    //Mensaje
       	if (mensaje.value==''){
		    alert(msj1);
			mensaje.focus();
			return false;
       	}
		if (mensavalue.length > 200){
			alert(msj2);
			mensaje.focus();
			return false;
       	}
		//Mail
        if (mail.value==''){
            alert(msj3);
            mail.focus();
            return false;
        }
        if ((mail.value.indexOf ('@',0)==-1) || (mail.value.indexOf ('.',0)==-1) || (mail.value.length <5)){
			alert(msj4);;
			mail.focus();
			return false;
		}
		if (mail.value.indexOf ('@',0)==(mail.value.indexOf ('.',0)-1)){
			alert(msj4);;
			mail.focus();
			return false;
		}
	var mailsend= $('#mail').val();
	var mensaje=$('#mensaje').val();
	var sURL='/user/actions/sendprofile.php';
		var html = $.ajax({type: "POST",url: sURL,async: false,data:'mail='+mailsend+'&mensaje='+mensaje+'&idprofile='+idprofile}).responseText;
		if(html!=0){
            document.getElementById('mail').value="";
            document.getElementById('mensaje').value="";
            mensaje.value="";
    		$('#profilebk').hide();
	    	$("#sendprofile").show();
		}else {
			$('#profilebk').hide();
		    $("#errorsendprofile").show();
		}
}
//Musisca en el perfil publico
function showPlayer(_index,idAlbum,iduser,idaudio) {
	$.ajax({type: "GET", url: "/multimedia/audioplayer.php", data: "_index="+_index+"&idalbum="+idAlbum+"&iduser="+iduser+"&idaudio="+idaudio, success: successShowPlayer,timeout:1000});
    trackAjax(numPageId,'/'+strUrl+'.html?uid='+iduser+'&idalbum='+idAlbum+'&idaudio='+idaudio);
}
function successShowPlayer(postData) {
	document.getElementById('player').innerHTML = postData;
}
function togglemore(id){
	$('#desc'+id).toggle();
    $('#menos'+id).toggle();
    $('#mas'+id).toggle();
}
//Video en el perfil publico
function getVideoComments(limit,offset,idvideo,iduser,profile){
	$.ajax({type: "GET", url: "/multimedia/showvideocommentspublic.php", data: "limit="+limit+"&offset="+offset+"&idvi="+idvideo+"&idusr="+iduser+"&profile=1", success: showVideoComments});
}
function showVideoComments(postData){
	$('#Videocomments').html(postData);
}
function needHelpModalBackground() {
	var background = document.createElement("div");
	background.id = "background-modal";
	$(background).css('position','absolute').css('top',0).css('left',0).css('z-index',100).css('background','#000000').css('display','none')
	.appendTo(document.body).css('opacity',0).show();
	$(background).css('height',$(window).height()+'px')
	.css('width',$(window).width()+'px').fadeTo(500, 0.25).bind('click',needHelpHideModalBackground);
	$(window).resize(function(){
		$('#background-modal').css('height',$(window).height()+'px').css('width',$(window).width()+'px');
	});
}
function needHelpNewForm( normalClass, onloadClass) {
	var newForm = document.createElement("div");
	newForm.id = "new-form";
	$(newForm).css('position','absolute').css('z-index',100)
	.appendTo(document.body).addClass(onloadClass)
	.addClass(normalClass).show();
	$('#background-modal').bind('click',needHelpHideNewForm);
}
function needHelpHideNewForm() {$('#new-form').remove();}
function needHelpHideModalBackground() {
	$('#background-modal').remove();
	$(window).resize(null);
}
function successNeedHelp(postData) {
	$('#new-form').removeClass('smail-form-onload').html(postData);
	$('#background-modal').unbind('click',needHelpHideModalBackground).unbind('click',needHelpHideNewForm);
	$('#cancel-smail').bind('click',function(){needHelpHideNewForm();needHelpHideModalBackground();});
	$('#cancel-smails').bind('click',function(){needHelpHideNewForm();needHelpHideModalBackground();});
}
function needHelp(){
	needHelpModalBackground();
	needHelpNewForm('smail-form','smail-form-onload');
	var sURL = '/user/mail.php';
	$.ajax({type: "POST", url: sURL, async: false, data: 'status=admin',success: successNeedHelp});
}
function needHelpSendMessage(){
	var idRecipient = $('#idRecipient').val();
	var status      = $('#statusfb').val();
	var Message     = $('#textmessage').val();
	var Subject     = $('#textsubject').val();
	var Numaction   = $('#Numaction').val();

	if (Subject.length==0 || Message.length ==0){
		var sAlertMessage = $('#alerttext').val();
		alert(sAlertMessage);
		return false;
	}
	var sURL = "/user/actions/actionmail.php";
	var sData = 'numaction='+Numaction+'&textsubject=' + Subject + '&textmessage=' + Message + '&idRecipient=' + idRecipient + "&status=" + status;
	var html = $.ajax({type: "POST", url: sURL, async: false, data: sData}).responseText;
	$('#textmessage').hide();
	$('#divbtsend').hide();
	$('#textsubject').hide();
	$('#senderName').hide();
	$('#recipientName').hide();
	$('#subjectMail').hide();
	$('#numaction').hide();
	if(html=="yes"){
		$('#notsent').hide();
		$('#oksend').show();
	}else{
		$('#oksend').hide();
		$('#notsent').show();
	}
}
function sendProfile(idlogged){
     document.getElementById('errorsendprofile').style.display='none';
     document.getElementById('sendprofile').style.display='none';
     if(idlogged!=0) {
      	$("#profilebk").show();
     }else{
     	$("#profilebk1").show();
     }
}
function changeAltemail(uno){
	var alt = uno;
	var pagina='/home/?ocp=6';
	location.href=pagina;
}
function alternative(altemail){
    var AltEmail = 0;
    var AltEmail=altemail;
    if (AltEmail == 1 ) {
        $('.selection-button').hide();
        $('#Preferences').show();
    }
}
function feedback(var1){
	needHelpModalBackground();
	needHelpNewForm('smail-form','smail-form-onload');
	if (var1!= ' ') {
	var sURL = '/user/feedback.php?new='+var1;
	} else {var sURL = '/user/feedback.php';}
	$.ajax({type: "POST", url: sURL, async: false, data: 'status=feedback',success: successNeedHelp});
}
function feedbackSendMessage(msj3,msj4){
	var idRecipient = $('#idRecipient').val();
	var status      = $('#statusfb').val();
	var Message     = $('#textmessage').val();
	var Subject     = $('#textsubject').val();
	var Numaction   = $('#Numaction').val();
	var EmailNo   = $('#idEmail').val();

	if (EmailNo==''){
        alert(msj3);
        EmailNo.focus();
        return false;
    }
    if ((EmailNo.indexOf ('@',0)==-1) || (EmailNo.indexOf ('.',0)==-1) || (EmailNo.length <5)){
        alert(msj4);;
        EmailNo.focus();
        return false;
    }
    if (EmailNo.indexOf ('@',0)==(EmailNo.indexOf ('.',0)-1)){
        alert(msj4);;
        EmailNo.focus();
        return false;
    }
	if (Subject.length==0 || Message.length ==0){
		var sAlertMessage = $('#alerttext').val();
		alert(sAlertMessage);
		return false;
	}
	var sURL = "/user/actions/actionfeedback.php";
	var sData = 'numaction='+Numaction+'&textsubject=' + Subject + '&textmessage=' + Message + '&idRecipient=' + idRecipient + "&status=" + status + "&emailno=" + EmailNo;
	var html = $.ajax({type: "POST", url: sURL, async: false, data: sData}).responseText;
	$('#textmessage').hide();
	$('#divbtsend').hide();
	$('#textsubject').hide();
	$('#senderName').hide();
	$('#recipientName').hide();
	$('#subjectMail').hide();
	$('#numaction').hide();
	$('#idEmail').hide();
	$('#nose').hide();
	if(html=="yes"){
		$('#notsent').hide();
		$('#oksend').show();
	}else{
		$('#oksend').hide();
		$('#notsent').show();
	}
}
function coordenadas(event) {
    x=event.clientX;
    y=event.clientY;
    document.getElementById("addcomment").value = x;
    document.getElementById("linkotro").value = y;
    alert(y);
}
function needCommentModalBackground() {
	var background = document.createElement("div");
	background.id = "background-modal";
	$(background).css('position','absolute').css('top',0).css('left',0).css('z-index',100).css('background','#000000').css('display','none')
	.appendTo(document.body).css('opacity',0).show();
	$(background).css('height',$(window).height()+'px')
	.css('width',$(window).width()+'px').fadeTo(500, 0.25).bind('click',needHelpHideModalBackground);
	$(window).resize(function(){
		$('#background-modal').css('height',$(window).height()+'px').css('width',$(window).width()+'px');
	});
}
function needCommentNewForm(normalClass,onloadClass,event) {
    x=event.clientX + document.body.scrollLeft;
    if ( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    y=event.screenY + window.pageYOffset-200;
    } else {
    y=event.screenY + document.documentElement.scrollTop-200;
    }
    scrOfY = document.documentElement.scrollTop;
    document.getElementById("addcomment").value = x;
    document.getElementById("linkotro").value = y;
	var newForm = document.createElement("div");
	newForm.id = "new-form";
	$(newForm).css('position','absolute').css('top',y).css('z-index',100)
	.appendTo(document.body).addClass(onloadClass)
	.addClass(normalClass).show();
	$('#background-modal').bind('click',needHelpHideNewForm);
}

function URLEncode1( ){
// The Javascript escape and unescape functions do not correspond
// with what browsers actually do...
//var SAFECHARS = "0123456789" + "��" + "��� + "� + "� + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "-_.!~*'()";// RFC2396 Mark characters
var SAFECHARS = "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "-_.!~*'()";// RFC2396 Mark characters
var HEX = "0123456789ABCDEF";
var commentText = $('#commentText').val();
var plaintext = commentText;
var encoded = "";
for (var i = 0; i < plaintext.length; i++ ) {
var ch = plaintext.charAt(i);
  //alert(ch+"   "+SAFECHARS);
if (ch == " ") {
	encoded += "+";// x-www-urlencoded, rather than %20
} else if (SAFECHARS.indexOf(ch) != -1) {
	encoded += ch;
} else {
	var charCode = ch.charCodeAt(0);
	//alert(charCode);
	if (charCode == 241 || charCode == 225 ||charCode == 233 || charCode == 237 || charCode == 243 || charCode == 250 || charCode == 193 || charCode == 201 || charCode == 205 || charCode == 211 || charCode == 218 || charCode == 252 || charCode == 471 || charCode == 220 || charCode == 191 || charCode == 161 || charCode == 176 || charCode == 172) {
		encoded += ch;
		//alert(encoded);
	} else if (charCode > 255) {
		//alert( "Unicode Character '"+ch+"' cannot be encoded using standard URL encoding.\n"+"(URL encoding only supports 8-bit characters.)\n" +"A space (+) will be substituted." );
 		encoded += "+";
 	} else {
		encoded += "%";
		encoded += HEX.charAt((charCode >> 4) & 0xF);
		encoded += HEX.charAt(charCode & 0xF);
	}
	}
} // for

return encoded;
}
function previewcomment(msg,msg2,msg3,event){
	var commentText = $('#commentText').val();
	var commentText1 = URLEncode1( );
	var reciber = $('#reciber').val();
	if (commentText.length > 1000){
		alert(msg2);
		return false;
	}
	if (commentText.length < 1 || commentText1.length < 1){
		alert(msg);
		return false;
	}
	var sURL = '/user/actions/previewcomment.php';
	var sData = 'reciber='+reciber+'&comment='+commentText1
	var oRequest = getHttpRequest();
	oRequest.open("POST", sURL, false);
	oRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	oRequest.onreadystatechange = function() {
		if (oRequest.readyState==4) {
			if (oRequest.status != 200) {
				alert(msg3);
				return false;
			}
		}
	};
	oRequest.send(sData);
	if (oRequest.status==200) {
		needCommentModalBackground();
		needCommentNewForm('comment-form','comment-form-onload',event);
		return successNeedHelp(oRequest.responseText);
	}
	return false;
}
function getHttpRequest() {
	var httpRequest = null;
	if (window.XMLHttpRequest) {
		httpRequest = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			var xmlVersions = new Array('MSXML2.XMLHTTP.6.0','MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP');
			for (var i=0; i<xmlVersions.length; i++) {
				try {
					httpRequest = new ActiveXObject(xmlVersions[i]);
				} catch(e){
                                    //Empty by default
                                }
			}
                }
	}
	return httpRequest;
}
function CountContTextArea(ObjTextArea, numLimit) {
	if(ObjTextArea.value.length > numLimit){
 		ObjTextArea.value = ObjTextArea.value.substring(0,numLimit);
	}
	return ObjTextArea.value.length
}
function trackComments(UserView,limit) {
trackAjax(numPageId,'/qp/'+strUrl+'.php?uid='+UserView+'&limit='+limit);
}
function swapImage(img, url) {
    img.src = url;
}
/*
 *  Terninan las funciones de utils                              *
 *****************************************************************/
/*****************************************************************
 *  Empiezan las funciones de flashcoms                          *
 */
var serverEngine = "php";
var projectRoot = "/flashcoms/";

function openQPCommunityChatWindow( _numComId ) {
    var url = "communitychat.php?idcom="+ _numComId;
    openWindow(url, 'Quepasa Chat', 720, 480, true);
}
function openVideochatWindow(roomId, uid, langId)
{
    if(!roomId) roomId = "";
    if(!uid) uid = "Test";
	if(!langId) langId = "";
    var name = "videochat_" + uid;
    var url = makeUrl("videochat") + "?roomId=" + roomId + "&uid=" + uid + "&langId=" + langId;
    openWindow(url, name, 720, 480, true);
}
function openChatWindow(roomId, uid, langId)
{
    if(!roomId) roomId = "";
    if(!uid) uid = "Test";
	if(!langId) langId = "";
    var name = "chat_" + uid;
    var url = makeUrl("chat") + "?roomId=" + roomId + "&uid=" + uid + "&langId=" + langId;
    openWindow(url, name, 720, 480, true);
}
function openCommunicatorWindow(friendName, uid, langId)
{
    if(!friendName) friendName = "";
    if(!uid) uid = "0";
	if(!langId) langId = "";
    var name = "communicator_" + uid + "_" + friendName;
    var url = makeUrl("communicator") + "?uid=" + uid + "&friendName=" + friendName + "&langId=" + langId;
    var windowOpened = openWindow(url, name, 540, 400, true);

    if(windowOpened  == null) {
        divNotification = document.getElementById("chat-notification");
        divNotification.style.display = 'inline';
        var currentOffset = document.documentElement.scrollTop || document.body.scrollTop;
        divNotification.style.top = currentOffset;

    }

}
function openMessengerWindow(friendName, uid, langId)
{
    if(!friendName) friendName = "";
    if(!uid) uid = "0";
	if(!langId) langId = "";
    var name = "messenger_" + uid + "_" + friendName;
    var url = makeUrl("messenger") + "?uid=" + uid + "&friendName=" + friendName + "&langId=" + langId;
    openWindow(url, name, 540, 400, true);
}
function openRecorderWindow(userName)
{
    if(!userName) userName = "Test";
    var name = "recorder_" + userName
    var url = makeUrl("recorder") + "?userName=" + userName;
    openWindow(url, name, 397, 301, false);
}
function openPlayerWindow(userName)
{
    if(!userName) userName = "Test";
    var name = "player_" + userName
    var url = makeUrl("player") + "?userName=" + userName;
    openWindow(url, name, 500, 255, false);
}
function openSiteMailWindow(uid, receiverId)
{
    if(!uid) uid = "0";
    if(!receiverId) receiverId = "0";
    var name = "site_mail_" + uid;
    var url = makeUrl("site_mail") + "?uid=" + uid + "&receiverId=" + receiverId;
    openWindow(url, name, 560, 404, true);
}
function openDebugWindow()
{
    var url = projectRoot + "common/debug/";
    var styleStr = makeStyle(0, 0, 400, 820, true);
    window.open(url, "DebugConsole", styleStr);
}
function openWindow(url, name, width, height, isResizeAble)
{
    url = projectRoot + url;
    name = name.replace(/[^\w\d]/, "_");
    name = name.replace(/undefined/, "_");
    name = name.replace(/\./, "_");

    var left = Math.round((screen.width - width) / 2);
    var top = Math.round((screen.height - height) / 2);
    var styleStr = makeStyle(left, top, width, height, isResizeAble);
    var windowOpened = window.open(url, name, styleStr);
    return windowOpened;
}
function openHelp(url)
{
    var name = "help";
    var width = 350;
    var height = 500;
    var left = screen.width - width - 10;
    var top = 10;
    var styleStr = makeStyle(left, top, width, height, true);
    window.open(url, name, styleStr);
}
function makeUrl(application)
{
    return application + "/server/" + serverEngine + "/" + application + "." + serverEngine;
}
function makeStyle(left, top, width, height, isResizeAble)
{
    var styleStr = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no";
    styleStr += ",resizable=" + (isResizeAble ? "yes" : "no");
    styleStr += ",width=" + width + ",height=" + height;
    styleStr += ",left=" + left + ",top=" + top;
    styleStr += ",screenX=" + left + ",screenY=" + top;
    return styleStr;
}
////
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed wmode=\"transparent\" type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" wmode=\"transparent\"  classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){
return false;
}return true;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;
/*
 *  Terninan las funciones de flashcoms                          *
 *****************************************************************/
/*****************************************************************
 *  Empiezan las funciones de metrics                            *
 */
function newXMLHttpRequest(){
    var xmlreq = false;
    if (window.XMLHttpRequest){
        xmlreq = new XMLHttpRequest();
    }else if (window.ActiveXObject){
        try{
            xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e1){
            try{
                xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
            }catch(e2){ }
        }
    }
    return xmlreq;
}
function setOnlineAjax(){
	ajax=newXMLHttpRequest();
	if (ajax==null){return}
	var url = "/include/register_online.php";
	ajax.open("GET", url, true);
	ajax.onreadystatechange=function(){
		if(ajax.readyState==4){setGlbOnline();}
	}
	ajax.send(null);
}
function setGlbOnline(){
	setTimeout("setOnlineAjax()", 600000);//10min
	return;
}

/*
 *  Terninan las funciones de metrics                            *
 *****************************************************************/
function loadBalance(){
 var ajax = newXMLHttpRequest();
 if (ajax) {
  ajax.open("GET", "/economy/action/balance.php?", true);
  ajax.onreadystatechange=function(){
   if (ajax.readyState==4){if (ajax.status==200){processBalance(eval('('+ajax.responseText+')'));processBalanceheader(eval('('+ajax.responseText+')')); }}
  }
  ajax.send(null);
 }
}
function processBalance(a){
 if (a) {
  var qp=document.getElementById("_qplblqpoints");
  if (qp) {
   qp.innerHTML=a.qpoints;
   if (qp.style.fontSize) {
     qp.style.fontSize="12px";
   }
  }
  var qd=document.getElementById("_qplblqdollars");
  if (qd) {
   qd.innerHTML=a.qdollars;
   if (qd.style.fontSize) {
     qd.style.fontSize="12px";
   }
  }
 }
}

function processBalanceheader(a){
	 if (a) {
	  var qp=document.getElementById("_qplblqpoints-header");
	  if (qp) {
	   qp.innerHTML=a.qpoints;
	   if (qp.style.fontSize) {
	     qp.style.fontSize="12px";
	   }
	  }
	  var qd=document.getElementById("_qplblqdollars-header");
	  if (qd) {
	   qd.innerHTML=a.qdollars;
	   if (qd.style.fontSize) {
	     qd.style.fontSize="12px";
	   }
	  }
	 }
	}
