

regEmail=/^[a-zA-Z0-9]*[\w\.-]*[a-zA-Z0-9_]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/


DetectaFrame();
function DetectaFrame()
{
	if(self!=top)
	{
		window.top.location.href="http://www.beep.es/default.html";
	}
}


String.prototype.fechaMMDDAAAA = function() {
	return this.replace(/^(\d{2})\/(\d{2})\/(\d{4})$/, "$2/$1/$3");
}


function sinSession()
{
    Avisos("Para poder unirte o ver detalles tendras que registrarte.","window.open('/registrarse/default.aspx','_self')#CerrarPopup()","Registrarse#Cerrar");
}




var dateFormat = function () {
	var	token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
			val = String(val);
			len = len || 2;
			while (val.length < len) val = "0" + val;
			return val;
		};

	
	return function (date, mask, utc) {
		var dF = dateFormat;

		
		if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}

		
		date = date ? new Date(date) : new Date;
		if (isNaN(date)) throw SyntaxError("invalid date");

		mask = String(dF.masks[mask] || mask || dF.masks["default"]);

		
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}

		var	_ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();


dateFormat.masks = {
	"default":      "ddd mmm dd yyyy HH:MM:ss",
	shortDate:      "m/d/yy",
	mediumDate:     "mmm d, yyyy",
	longDate:       "mmmm d, yyyy",
	fullDate:       "dddd, mmmm d, yyyy",
	shortTime:      "h:MM TT",
	mediumTime:     "h:MM:ss TT",
	longTime:       "h:MM:ss TT Z",
	isoDate:        "yyyy-mm-dd",
	isoTime:        "HH:MM:ss",
	isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
	isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};


dateFormat.i18n = {
	dayNames: [
		"Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab",
		"Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado"
	],
	monthNames: [
		"Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Set", "Oct", "Nov", "Dec",
		"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Setiembre", "Octubre", "Noviembre", "Diciembre"
	]
};


Date.prototype.format = function (mask, utc) {
	return dateFormat(this, mask, utc);
};


function cambiarInputType(
  oldElm, // a reference to the input element
  iType, // value of the type property: 'text' or 'password'
  iValue, // the default value, set to 'password' in the demo
  blankValue, // true if the value should be empty, false otherwise
  noFocus) {  // set to true if the element should not be given focus
 
  if(!oldElm || !oldElm.parentNode || (iType.length<4) || 
    !document.getElementById || !document.createElement) return;
  var newElm = document.createElement('input');
  newElm.type = iType;
  if(oldElm.name) newElm.name = oldElm.name;
  if(oldElm.id) newElm.id = oldElm.id;
  if(oldElm.className) newElm.className = oldElm.className;
  if(oldElm.size) newElm.size = oldElm.size;
  if(oldElm.tabIndex) newElm.tabIndex = oldElm.tabIndex;
  if(oldElm.accessKey) newElm.accessKey = oldElm.accessKey;
  if(oldElm.style.width) newElm.style.width  = oldElm.style.width;
  if(oldElm.onkeyup) newElm.onkeyup  = oldElm.onkeyup;
  newElm.onfocus = function(){return function(){
    if(this.hasFocus) return;
    var newElm = cambiarInputType(this,'password',iValue,
      (this.value.toLowerCase()==iValue.toLowerCase())?true:false);
    if(newElm) newElm.hasFocus=true;
  }}();
  newElm.onblur = function(){return function(){
    if(this.hasFocus)
    if(this.value=='' || (this.value.toLowerCase()==iValue.toLowerCase())) {
      cambiarInputType(this,'text',iValue,false,true);
    }
  }}();
 // hasFocus is to prevent a loop where onfocus is triggered over and over again
  newElm.hasFocus=false;
  oldElm.parentNode.replaceChild(newElm,oldElm);
  if(!blankValue) newElm.value = iValue;
  if(!noFocus || typeof(noFocus)=='undefined') {
    window.tempElm = newElm;
    setTimeout("tempElm.hasFocus=true;tempElm.focus();",1);
  }
  return newElm;
}


function ponerEventosFalse(evento,elem)
{
    

    if (elem.attachEvent) 
    {
        elem.attachEvent(evento, cancelaKey)
    }else{
        
        elem.setAttribute(evento, "return false");
        
        
    } 
 
}


function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}



function volver()
{
    history.back(-1)
}


function enviarLogin()
{
     if(document.getElementById("nick").value=='')
     {
            Avisos("No has introducido el Nick","CerrarPopup();","Aceptar",true);
     }else{
         if(document.getElementById("clave").value=='')
         {
                Avisos("No has introducido la clave","CerrarPopup();","Aceptar",true);
         }else{
            var recordar=0;
            if(document.getElementById("recordar").checked) recordar=1;
            Request("/ajax/comprobarLogin.aspx?nick="+escape(document.getElementById("nick").value)+"&clave="+encodeURIComponent(document.getElementById("clave").value)+"&recordar="+recordar+"&r="+document.getElementById("r").value,RespuestaVacia,""); 
         }
     }
}




function limiteText(id,limit)
{
    if(document.getElementById(id).value.length>limit)
    {
        Avisos("Has alcanzado el tamaño maximo del texto","CerrarPopup();","Aceptar",true);
		document.getElementById(id).value=document.getElementById(id).value.substr(0,limit)
    }
}



function fechaValida(Day,Mn,Yr){
    var DateVal = Mn + "/" + Day + "/" + Yr;
    var dt = new Date(DateVal);

    if(dt.getDate()!=Day){
      
        return(false);
        }
    else if(dt.getMonth()!=Mn-1){
   
        return(false);
        }
    else if(dt.getFullYear()!=Yr){
      
        return(false);
        }
        
    return(true);
 }



function mostrarId(id)
{
    if(document.getElementById(id).style.display=='none')
    {
        document.getElementById(id).style.display='inline';
    }else{
        document.getElementById(id).style.display='none';
    }
}


function rellenarRegistro()
{
    Avisos("Debes rellenar tu perfil para continuar","CerrarPopup()","Aceptar",true);
}


function mostrarEditar(total)
{
   document.getElementById("mostrareditar").style.top=total+"px";
}
function quitarEditar(total)
{
    document.getElementById("mostrareditar").style.top=total+"px";
}


function verPerfil(cod,v)
{
    
    Request("/ajax/verPerfil.aspx?cod="+cod+"&v="+v,RespuestaVerPerfil,"");
}
function RespuestaVerPerfil(s)
{   
    
    Popup(s,516);
}


function cambiarCheckMensajes()
{
    var mostrar="";
    var i=1;
    mostrar="mens1";
    while(document.getElementById(mostrar))
    {
        if(document.getElementById("todosmens").checked)
        {
             document.getElementById(mostrar).checked=true;
        }else{
            document.getElementById(mostrar).checked=false;
        }
        i=i+1;
        mostrar="mens"+i;
    }
}

function cargarDestinatarios(v)
{
    if (todosusuarios=="")
    {
        Avisos("No hay usuarios en la lista","CerrarPopup()","Aceptar",true);
    }else{
        cargarEnviarMensajes(todosusuarios,v)
    }
}

function cargarEnviarMensajes(cod,v)
{
    
    Request("/ajax/cargarEnviarMensajes.aspx?cod="+cod+"&v="+v,RespuestaCargarEnviarMensajes,"");   
}

function RespuestaCargarEnviarMensajes(s)
{
   
    Popup(s,516);
}

function enviarMensajes(cod)
{
    
    with(document.mensaje)
    {
        if(asunto.value=="")
        {
            Avisos("Debes de indicar el asunto del mensaje","CerrarPopup()","Aceptar",true);
            
        }else{
            if(mensaje.value=="")
            {
                Avisos("Debes de completar el texto del mensaje","CerrarPopup()","Aceptar",true);
                
            }else{
                
                var mostrar="asunto="+encodeURIComponent(asunto.value)+"&mensaje="+encodeURIComponent(mensaje.value)
                Request("/ajax/enviarMensajes.aspx?cod="+cod,RespuestaVacia,mostrar);
            }
        }
    }
}


function cargarRecomendar()
{
    
    Request("/ajax/cargarRecomendar.aspx",RespuestaCargarRecomendar,"");   
}
function RespuestaCargarRecomendar(s)
{
    Popup(s,516);
}
function enviarRecomendar()
{
    with(document.recomendar)
    {
        if(email.value=="")
        {
            Avisos("Debes de completar el e-mail del destinatario","CerrarPopup()","Aceptar",true);
            
        }else{
            if( email.value.search(regEmail)!=0)
            {
                Avisos("El e-mail del destinatario no tiene el formato correcto","CerrarPopup()","Aceptar",true);
            }else{
                
                if(tuemail.value=="")
                {
                    Avisos("Debes de completar tu e-mail","CerrarPopup()","Aceptar",true);
                    
                }else{
                    if( tuemail.value.search(regEmail)!=0)
                    {
                        Avisos("Tu e-mail no tiene el formato correcto","CerrarPopup()","Aceptar",true);
                    }else{
                           
                            
                            var mostrar="email="+encodeURIComponent(email.value)+"&comentario="+encodeURIComponent(comentario.value)+"&tuemail="+encodeURIComponent(tuemail.value)
                            Request("/ajax/enviarRecomendar.aspx",RespuestaVacia,mostrar);
                       
                    }
                
                }
            }
            
            
            
        }
    }
    
    
}



function abrirCapa(div)
{
    if(document.getElementById(div).style.display=="none")
    {
       document.getElementById(div).style.display="inline"; 
    }else{
        document.getElementById(div).style.display="none";
    }
}

function Imprimir(id)
{
    document.getElementById(id).style.visibility="hidden";
    print();
    window.close();
}


function verCondiciones()
{
    Request("/ajax/condiciones.aspx",RespuestaVerCondiciones,"");
}
function RespuestaVerCondiciones(s)
{
    Popup(s,619);
}


function abrirImagen(imagen,anchura,altura)
{
    var mostrar="";
   
    var mostrar='';
    var altu=altura;
    if(altura>500) altu=500;
    
    
    mostrar='<div style="width:'+(anchura+40)+'px; height:'+(altu)+'px"><table border="0" cellpadding="0" cellspacing="0"   style="width:'+(anchura+40)+'px; height:'+(altu)+'px">';         
	
    mostrar=mostrar+'<tr><td style="font-size:1px;width:10px; height:9px  " valign="bottom"><img src="/imagenes/borderBlancoIzqArr.gif" alt="" /></td><td valign="middle" align="center"  style="background-color:white;font-size:1px;" >&nbsp;</td><td style="font-size:1px;width:10px;height:9px  " valign="bottom"><img src="/imagenes/borderBlancoDerArr.gif" alt="" /></td></tr>'; 
    mostrar=mostrar+'<tr><td style="background-color:white">&nbsp;</td>'; 
    mostrar=mostrar+'<td align="right" style="background-color:white; padding-bottom:5px"><a href="javascript:CerrarPopup()" class="Azul">Cerrar X</a>';
    mostrar=mostrar+'</td><td style="background-color:white">&nbsp;</td></tr>'; 
    mostrar=mostrar+'<tr><td style="background-color:white">&nbsp;</td>'; 
    mostrar=mostrar+'<td align="center" style="background-color:white">';
    
    if(altura>500)
    {
	    mostrar=mostrar+'<div style="width:'+(anchura+20)+'px;height:'+(altu)+'px;overflow:auto; border:1px #333333 solid"><img src="'+imagen+'" alt=""  /></div>';
    }else{
	    mostrar=mostrar+'<img src="'+imagen+'" alt=""  />';
    }
    mostrar=mostrar+'</td><td style="background-color:white">&nbsp;</td></tr>'; 
    mostrar=mostrar+'<tr><td style="font-size:1px;width:10px"><img src="/imagenes/borderBlancoIzqAba.gif" alt="" /></td><td valign="middle" align="center"  style="background-color:white;font-size:1px;">&nbsp;</td><td style="font-size:1px;width:10px"><img src="/imagenes/borderBlancoDerAba.gif" alt="" />';    
    mostrar=mostrar+'</table></div>'; 
    	
	   
   
     Popup(mostrar,(anchura+40));
}


