// PRE - HOME
function prehome_cargarRegistracion(){
	
	$('container').innerHTML = '';
	// Cargo el preloader.
	$('container').innerHTML = '<div id="preloading"><img height="30" width="30" src="/imgs/ajax-loader.gif"/></div>';
		
	cargarGenerico('prehome_registracion','body','','container','0.2','0.5','550');	
	
	return false;
}

// FUNCIONES: HOME ANONIMA
function home_cargarRegistracion(){
	cargarGenericoEffectUpDown('panelderecho_registracion','body','','box_perfil','0.6','0.6','550');
	return false;
}

// FUNCION DE LOGOUT
function process_logout() {
	cargarGenerico('logout.script','body','','container_not_exist','0.2','0.5','550');		
}


// FUNCTION DE ENVIO DE INVITACION
function invitar_amigo(div_correo,div_error) {
	$(div_error).style.display = 'none';
	var campo = $(div_correo);
	
	// Valido el correo.
	if($(div_correo).value == '') {
		$(div_error).style.display = 'block';
		$(div_error).innerHTML = "<span class='txt_Rojo'>Por favor ingrese un email.</span><br/>";
		return false;
	}

	var emailFilter = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+.([a-zA-Z]{2,4})$/ ;
	if (!emailFilter.test($(div_correo).value)) {     
		$(div_error).style.display = 'block';
        $(div_error).innerHTML = "<span class='txt_Rojo'>Por favor ingrese un email v&aacute;lido.<br /></span>";
		return false;
    }
	lightbox.prototype.open_iframe('/body/importador/paso4.php?correo=' + $(div_correo).value + '&');
	return true;
}

// FUNCTION COMENTARIOS:
function displayFloatingDiv() {
}

// FUNCTION GENERICA DE DIV
function cargar_div_flotante(href,alto) {
	lightbox.prototype.open_iframe(href);
	setTimeout("$('frame_div_container').style.height = '" + alto +"px';",1500);
	setTimeout("$('lightbox_frame').style.height = '" + alto +"px';",1500);	
	return true;
}

//FUNCTION DE RICH MEDIA
function showDivRichMedia() {
	if($('div_rich_media')) {
		var fo = new FlashObject("/swf/grandes/tutorial.swf", "mov", "920", "100%", "9");
		fo.addParam("scale", "noscale");
		fo.addParam("wmode", "transparent");
		fo.write("div_rich_media");	
		$('div_rich_media').style.display = 'block';
	}
}
function hideDivRichMedia() {
	$('div_rich_media').style.display = 'none';
}

// FUNCTION DIV FLOTANTE
var allow_lightbox = false;
function init_floatdiv() {
	allow_lightbox = true;
}

function check_lightbox() {
	return allow_lightbox;
}
function hideDivFlotante() {
	
	// new Effect.Fade('div_flotante', { duration: 0.4} );	
	setTimeout("closeLightBox()",550);
}

// FUNCTION DE NOTICIAS
function cargar_Noticias(action) {
	cargarGenerico('noticias','body','&action=' + action + '&' ,'noticiasNotiTotal','0.1','0.2','150');
}
function noticias_Cargar(action) {
	cargarGenerico('noticias_load','noticias','&action=' + action + '&' ,'perfil_right','0.1','0.2','150');
}
function amigos_Cargar(action) {
	cargarGenerico('amigos_load','amigos','&action=' + action + '&' ,'perfil_right','0.1','0.2','150');
}


// FUNCION DE TRIVIA
function trivia_cargar_pregunta(idTrivia) {
	parametros = "&idTrivia=" + idTrivia;
	if ($('form_trivia')) { 
		parametros = $('form_trivia').serialize();
	}
	// Cargo los resultados y la nueva pregunta.
	$('area_triviaBunbury').innerHTML = '<div id="preloading" style="margin-left:400px;margin-top:200px"><img src="/imgs/loader_trivia.gif"/></div>';
	cargarGenerico('pregunta','trivia',parametros,'area_triviaBunbury','0.2','0.5','100');		
}

// FUNCION DE CORCHOLATA
function cargarFormCodigo(tipo) {
	$('ajax_container').innerHTML = '<div id="preloading" style="margin:auto;padding:auto"><br><br<br><br><br><br><br<br><img src="/imgs/ajax-loader.gif"/></div>';
	cargarGenerico('formulario','corcholata','&tipo=' + tipo + '&' ,'ajax_container','0.1','0.2','150');
}
function cargarFormCodigoMoenia() {
	$('ajax_container').innerHTML = '<div id="preloading" style="margin:auto;padding:auto"><br<br><img src="/imgs/ajax-loader.gif"/></div>';
	cargarGenerico('formulario','carga-codigo-moenia','' ,'ajax_container','0.1','0.2','150');
}

function elegirCodigo() {
	$('ajax_container').innerHTML = '<div id="preloading" style="margin:auto;padding:auto"><br><br<br><br><br><br><br<br><img src="/imgs/ajax-loader.gif"/></div>';
	cargarGenerico('choose','corcholata','','ajax_container','0.1','0.2','150');
}
function cargarCodigo() {
	parametros = $('formulario_codigo').serialize();
	$('error_msg_codigo').innerHTML = '';
	if($('codigo').value.length < 12) {
		$('error_msg_codigo').innerHTML = '*Error: Debe ingresar un codigo de 12 caracteres.';	
	} else {
		$('ajax_container').innerHTML = '<div id="preloading" style="margin:auto;padding:auto"><br><br<br><br><br><br><br<br><img src="/imgs/ajax-loader.gif"/></div>';
		cargarGenerico('gracias','corcholata',parametros,'ajax_container','0.1','0.2','150');
	}
}
function cargarCodigoMoenia() {
	parametros = $('formulario_codigo').serialize();
	$('error_msg_codigo').innerHTML = '';
	if($('codigo').value.length < 8) {
		$('error_msg_codigo').innerHTML = '*Error: Debe ingresar un codigo de 8 caracteres.';	
	} else {
		$('ajax_container').innerHTML = '<div id="preloading" style="margin:auto;padding:auto"><br><br<br><img src="/imgs/ajax-loader.gif"/></div>';
		cargarGenerico('gracias','carga-codigo-moenia',parametros,'ajax_container','0.1','0.2','150');
	}
}
// FUNCTION DE COMENTARIOS
function comment_comentario(idSeccion,idNota) {
	lightbox.prototype.open_iframe('/body/comentarios/nuevo_comentario.php?idSeccion=' + idSeccion + '&idNota=' + idNota + '&');
}
function comment_show_id(divId){
	 $('subirFoto').style.display = 'none';
	 $('subirVideo').style.display = 'none';
	 
	 $(divId).style.display = '';
	 resizeWindows(); 
}
function reloadComentarios(idSeccion,idNota,tipo,idGeneral,idpage){
	$('comentarios_total').innerHTML = '<div style="clear:both"><div id="preloading" style="height:250px;padding-top:150px;"><img height="30" width="30" src="/imgs/ajax-loader.gif"/></div></div>';
	cargarGenerico('comentarios','body','&idSeccion=' + idSeccion + '&idNota=' + idNota + '&tipo=' + tipo + '&idGeneral=' + idGeneral + '&idpage=' + idpage  + '&' ,'comentarios_total','0.1','0.2','150');
	$('comentarios_total').scrollTo();
}
function reloadComentariosCarnaval(idCarnaval){
	window.location.reload(true);
}
var totalHeight = 0 ;
function getHeight() {
	totalHeight = $('contentWindow').offsetHeight;
	alert(totalHeight);
	return $('contentWindow').offsetHeight;
}
function resizeWindows(total) {
	// Calculo el tamano nuevo de la aplicacion.
	alert(total);
	$('lightbox_frame').style.visibility = 'hidden';
	$('lightbox_frame').height = total;
	$('lightbox_frame').style.visibility = 'visible';
}
function calcHeight()
{
	var the_height = 410
  //find the height of the internal page
  if(document.getElementById('lightbox_frame').contentWindow.document.getElementById('DatosIngresadosCorrectamente')) {
	    the_height = document.getElementById('lightbox_frame').contentWindow.document.getElementById('DatosIngresadosCorrectamente').offsetHeight;
	}
  	//change the height of the iframe
	$('frame_div_container').style.height = the_height + 'px';
	$('lightbox_frame').height = the_height;
}

function CheckAll(fmobj) { 
	for (var i=0;i<fmobj.elements.length;i++) { 
		var e = fmobj.elements[i]; 
		if ( (e.name != 'allbox') && (e.type=='checkbox') && (!e.disabled) ) { 
			e.checked = fmobj.allbox.checked; 
		} 
	}
} 

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

MM_preloadImages('images/fondo_grande.jpg');


// Funciones para "DIV FLOTANTE" + AJAX.

function showRegistrados(div,path,loader) {
    var loader = loader;

    $(''+div+'').innerHTML = '';
	$(''+div+'').innerHTML = '<div id="preloading"><img src="/imgs/importador_loader.gif"/>';

    new Ajax.Updater(div,path,{evalScripts: true ,method: 'get'});

}

function updatePorcentaje(porcentaje) {
	    $('perfil_izq_percent').innerHTML = porcentaje + '%';
        $('perfil_perfil_percent').innerHTML = porcentaje + '%';

        setTimeout("hide_img_datos_guardados()",1500);    
}
function hide_img_datos_guardados() {
	for(i=1;i<6 ; i++) {
		if($('img_datos_guardados' + i)) {
			new Effect.Fade('img_datos_guardados' + i, { duration: 0.5} );
			// $('img_datos_guardados' + i).style.visibility = 'hidden';
		}
	}
}
function showCambiarFoto() {
	displayFloatingDiv('div_flotante', '', 720, 370, screen.width/4, screen.height/10);	
	new Ajax.Updater('div_flotante','/body/sube_foto.php', {method: 'get',evalScripts: true});
}

function updateFoto() {
	if($('imagen_perfil_panel_izq'))
		$('imagen_perfil_panel_izq').src = '/body/images/imagen_panel.php?' + Math.floor(Math.random()*1000);
	if($('imagen_perfil_perfil'))
		$('imagen_perfil_perfil').src = '/body/images/imagen_perfil.php';
}

function updateMinutos() {
	if($('div_rich_media')) {
		var fo = new FlashObject("/swf/minutos.swf", "mov", "242", "80", "9");
		fo.addParam("scale", "noscale");
		fo.addParam("wmode", "transparent");
		fo.write("minutos_container");
	}	
}

function cargarPremiosFiltro(tipo) {
	$('perfil_right').innerHTML = '';	
	$('perfil_right').innerHTML = '<div id="preloading"><img height="30" width="30" src="/imgs/ajax-loader.gif"/></div>';
	cargarGenerico('cargar.premios','process', 'TipoPremio='+tipo+'&' ,'perfil_right','0.1','0.2','150');
}

function canjearPremiosFiltro() {
	$('perfil_right').innerHTML = '';	
	$('perfil_right').innerHTML = '<div id="preloading"><img height="30" width="30" src="/imgs/ajax-loader.gif"/></div>';
	cargarGenerico('premios.script','process','','perfil_right','0.1','0.2','150');		
}

var isIE7 = false;
function esMayor() {
	deactivate_logout = false;
	cargarGenerico('es_mayor','process','','contenedor_confirm','0.0','0.0','0'); 
	if(isIE7 == true) {
		hideDivFlotante();	
		setTimeout("recargarSitio()",1500)
	} else {
		hideDivFlotante();	
	}
}
function recargarSitio() {
	window.location.reload();
}

function checkLogin() {
	cargarGenerico('login_home.ajax.php','body',$('home_login_form').serialize(),'divErroresIngreso','0.2','0.5','550');		
}

function gotoHome(url) {
	location.href = url;	
}

// VALIDAR  
function checkWholeForm(theForm) {
	
    var why = "";

	why += checkEmail(theForm.Correo.value,theForm.Correo2.value);	
    why += checkPassword(theForm.Password.value,theForm.Password2.value);		
    why += checkUsername(theForm.Nombre.value);
	why += checkRepeat(theForm.Apellido.value, theForm.CredencialIF.value);
	why += checkDate(theForm.dia.value,theForm.mes.value,theForm.anio.value);
	why += checkCredencial(theForm.CredencialIF.value);
      
	if (why != "") {
	   $('prehome_js_errores').innerHTML = why;
       return false;
	}
	
	return true;

}

function checkAnonymous(theForm) {
	var why = "";
	
	why += checkUsername(theForm.Nombre.value);
	why += checkAge(theForm.Edad.value);
	
	if (why != "") {
		$('divErroresInvitado').innerHTML = why;
		return false;
	}
	
	return true;
	
}

function checkIngresar(theForm) {
	var why = "";
	
	why += checkEmail(theForm.email.value,theForm.email.value);
	why += checkPassword(theForm.pass.value,theForm.pass.value);

	if (why != "") {
		$('divErroresIngreso').innerHTML = why;
		return false;
	}
	
	return true;
	
}

function checkDate(dia,mes,anio) {
	var error = "";
	
	if(dia == "" || dia == "D&iacute;a"){
		error = "Ingresa correctamente su fecha de nacimiento.<br />";
	}
	if(mes == "" || mes == "Mes"){
		error = "Ingresa correctamente su fecha de nacimiento.<br />";
	}
	if(anio == "" || anio == "A&ntilde;o de Nacimiento"){
		error = "Ingresa correctamente su fecha de nacimiento.<br />";
	}
	
	
	if(dia > 31) {
		error = "Ingresa correctamente su fecha de nacimiento.<br />";	
	}
	
	if(mes > 12){
		error = "Ingresa correctamente su fecha de nacimiento.<br />";	
	}

	if(anio > 1991) {
		error = "Debes ser mayor de 18 a&ntilde;os para poder ingresar.<br />";
	}
	
	return error;
}

function checkUsername (strng) {
	
	var error = "";
	
	if (strng == "") {		
		error = "Ingresa un nombre.<br />";
	} else if (strng == "Nombre") {
        error = "Ingresa un nombre v&aacute;lido.<br />";	 
    } 
	
	return error;
}

function checkCredencial(strng) {
	
	var error = "";
	
	if (strng == "") {		
		error = "Ingresa tu credencial.<br />";
	} else if (strng == "Credencial IFE") {
        error = "Ingresa una credencial v&aacute;lida.<br />";	 
	} else if (isNaN(strng)) {
        error = "Ingresa una credencial v&aacute;lida.<br />";	 
    } 
	
	
	return error;
}

function checkRepeat(cadena,cadena2) {
	var error = "";
	
	var cad = cadena;
	var cad2 = cadena2;
	
	if (cad == "Apellido") {
		error = "Ingresa correctamente tu apellido.<br />";

	} else if (cad2 == "CredencialIF") {
		error = "Ingresa correctamente tu Credencial IF.<br />";

	}
			return error;
}
	
	
function checkPassword (cadena,cadena2) {
	 var error = "";

	 var illegalChars = /[\W_]/; // allow only letters and numbers
	
	 if (cadena == "" || cadena2 == "") {
		 error = "No has ingresado una contrase&ntilde;a.<br />";
	 }
	 
	 if(cadena2 == "") {
	 	error= "Debes confirmar tu contrase&ntilde;a.<br />";
	 }
	 
	 if(cadena2 != cadena){
		error= "Las contrase&ntilde;as deben ser iguales.<br />"; 
	 }
	 
	 
	return error;

}

function checkEmail(fld,fld2) {
	
	var error="";
	var campo = fld;
	var campo2 = fld2;
	
    var emailFilter = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+.([a-zA-Z]{2,4})$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;

    if (campo == "") {     
        error = "No has ingresado tu correo.<br />"; 
    } 
	
	if (!emailFilter.test(campo)) { 
        error = "Por favor ingresa un correo v&aacute;lido.<br />";
	
    } 
	
	if (campo.match(illegalChars)) {
        error = "Por favor ingresa un correo v&aacute;lido.<br />"; 		
    }
	
	
	if(campo2 == "") {
		error= "Debes confirmar tu correo.<br />";	
	}		
	
	if(campo2 != campo){
		error = "Los correos deben ser iguales.<br />";
	}
		
	    return error;	

}


function checkAge(edad){
	var error ="";
	
	if(edad < "18" || edad == "Edad") {
		error = "Debes ser mayor de 18 a&ntilde;os para poder ingresar.<br />";
	}
	
	return error;
}

/**
 * Ajax Functions
 *
 * FlashObject is (c) 2005 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
function cargarGenerico(pagina,folder,formulario,container_local,tim1,tim2,tim3) {

	tim2 = '0.8';
	tim3 = '1500';
	// Actualizo la URL
	var some_url = "/" + folder+"/"+pagina+".php"
	var parametros = null;
	if (formulario != undefined && formulario != null ) {
		parametros = formulario;
	} else {
	}
	//new Effect.Fade(container_local, { duration: tim1} );
	setTimeout("new Ajax.Updater('" + container_local + "','" + some_url + "',{onComplete:function(){ new Effect.Appear('" + container_local + "', { duration: " + tim2 + "} );}, method: 'post', parameters: '" + parametros + "', asynchronous:true, evalScripts:true});",tim3);
	//return false;
	//new Ajax.Updater(container_local, some_url , { method: 'post',  parameters: parametros, asynchronous:true, evalScripts:true});
	
	return false;
}
function cargarGenericoEffectUpDown(pagina,folder,formulario,container_local,tim1,tim2,tim3) {

	// Actualizo la URL
	var some_url = "/" + folder+"/"+pagina+".php"
	var parametros = null;
	if (formulario != undefined && formulario != null ) {
		parametros = formulario;
	} else {
	}
	new Effect.SlideUp(container_local, { duration: tim1} );
	setTimeout("new Ajax.Updater('" + container_local + "','" + some_url + "',{onComplete:function(){ new Effect.SlideDown('" + container_local + "', { duration: " + tim2 + "} );}, method: 'post', parameters: '" + parametros + "', asynchronous:true, evalScripts:true});",tim3);
	//return false;
	
	return false;
}
function getScript(form,div,script) {
	
	switch(form) {		
		case "form_musica":
		var formulario = $('form_musica').serialize();	
		break;
		
		case "form_futbol":
		var formulario = $('form_futbol').serialize();
		break;
		
		case "form_adicional":
		var formulario = $('form_adicional').serialize();
		break;
		
		case "form_personal":
		var formulario = $('form_personal').serialize();
		break;	
		
		case "form_propio":
		var formulario = $('form_propio').serialize();
		break;	
	}
			
	$(''+div+'').innerHTML = '';	
	$(''+div+'').innerHTML = '<div id="preloading"><img src="/imgs/importador_loader.gif"/></div>';
		
	cargarGenerico(script,'process',formulario,div,'0.1','0.2','150')	

}

/**
 * FlashObject v1.2.2: Flash detection and embed - http://blog.deconcept.com/flashobject/
 *
 * FlashObject is (c) 2005 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof com == "undefined") var com = new Object();
if(typeof com.deconcept == "undefined") com.deconcept = new Object();
if(typeof com.deconcept.util == "undefined") com.deconcept.util = new Object();
if(typeof com.deconcept.FlashObjectUtil == "undefined") com.deconcept.FlashObjectUtil = new Object();
com.deconcept.FlashObject = function(swf, id, w, h, ver, c, quality, redirectUrl, detectKey){
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = com.deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();

	if(swf) this.setAttribute('swf', swf);
	if(id) this.setAttribute('id', id);
	if(w) this.setAttribute('width', w);
	if(h) this.setAttribute('height', h);
	if(ver) this.setAttribute('version', new com.deconcept.PlayerVersion(ver.toString().split(".")));
	if(c) this.addParam('bgcolor', c);
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) this.setAttribute('redirectUrl', redirectUrl);
}
com.deconcept.FlashObject.prototype.setAttribute = function(name, value){
	this.attributes[name] = value;
}
com.deconcept.FlashObject.prototype.getAttribute = function(name){
	return this.attributes[name];
}
com.deconcept.FlashObject.prototype.getAttributes = function(){
	return this.attributes;
}
com.deconcept.FlashObject.prototype.addParam = function(name, value){
	this.params[name] = value;
}
com.deconcept.FlashObject.prototype.getParams = function(){
	return this.params;
}
com.deconcept.FlashObject.prototype.getParam = function(name){
	return this.params[name];
}
com.deconcept.FlashObject.prototype.addVariable = function(name, value){
	this.variables[name] = value;
}
com.deconcept.FlashObject.prototype.getVariable = function(name){
	return this.variables[name];
}
com.deconcept.FlashObject.prototype.getVariables = function(){
	return this.variables;
}
com.deconcept.FlashObject.prototype.getParamTags = function(){
   var paramTags = ""; var key; var params = this.getParams();
   for(key in params) {
        paramTags += '<param name="' + key + '" value="' + params[key] + '" />';
    }
   return paramTags;
}
com.deconcept.FlashObject.prototype.getVariablePairs = function(){
	var variablePairs = new Array();
	var key;
	var variables = this.getVariables();
	for(key in variables){
		variablePairs.push(key +"="+ variables[key]);
	}
	return variablePairs;
}
com.deconcept.FlashObject.prototype.getHTML = function() {
    var flashHTML = "";
    if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
        flashHTML += '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" id="'+ this.getAttribute('id') + '" name="'+ this.getAttribute('id') +'"';
		var params = this.getParams();
        for(var key in params){ flashHTML += ' '+ key +'="'+ params[key] +'"'; }
		pairs = this.getVariablePairs().join("&");
        if (pairs.length > 0){ flashHTML += ' flashvars="'+ pairs +'"'; }
        flashHTML += '></embed>';
    } else { // PC IE
        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" id="'+ this.getAttribute('id') +'">';
        flashHTML += '<param name="movie" value="' + this.getAttribute('swf') + '" />';
		var tags = this.getParamTags();
        if(tags.length > 0){ flashHTML += tags; }
		var pairs = this.getVariablePairs().join("&");
        if(pairs.length > 0){ flashHTML += '<param name="flashvars" value="'+ pairs +'" />'; }
        flashHTML += '</object>';
    }
    return flashHTML;
}
com.deconcept.FlashObject.prototype.write = function(elementId){
	if(this.skipDetect || com.deconcept.FlashObjectUtil.getPlayerVersion().versionIsValid(this.getAttribute('version'))){
		if(document.getElementById){
			document.getElementById(elementId).innerHTML = this.getHTML();
		}
	}else{
		if(this.getAttribute('redirectUrl') != "") {
			document.location.replace(this.getAttribute('redirectUrl'));
		}
	}
}
/* ---- detection functions ---- */
com.deconcept.FlashObjectUtil.getPlayerVersion = function(){
   var PlayerVersion = new com.deconcept.PlayerVersion(0,0,0);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else if (window.ActiveXObject){
	   try {
   	   var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
   		PlayerVersion = new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
	   } catch (e) {}
	}
	return PlayerVersion;
}
com.deconcept.PlayerVersion = function(arrVersion){
	this.major = parseInt(arrVersion[0]) || 0;
	this.minor = parseInt(arrVersion[1]) || 0;
	this.rev = parseInt(arrVersion[2]) || 0;
}
com.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;
}
/* ---- get value of query string param ---- */
com.deconcept.util.getRequestParameter = function(param){
	var q = document.location.search || document.location.href.hash;
	if(q){
		var startIndex = q.indexOf(param +"=");
		var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
		if (q.length > 1 && startIndex > -1) {
			return q.substring(q.indexOf("=", startIndex)+1, endIndex);
		}
	}
	return "";
}

/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* add some aliases for ease of use / backwards compatibility */
var getQueryParamValue = com.deconcept.util.getRequestParameter;
var FlashObject = com.deconcept.FlashObject;


/*
Created By: Chris Campbell
Website: http://particletree.com
Date: 2/1/2006

Inspired by the lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
*/

/*-------------------------------GLOBAL VARIABLES------------------------------------*/

var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

/*-----------------------------------------------------------------------------------------------*/

//Browser detect script origionally created by Peter Paul Koch at http://www.quirksmode.org/

function getBrowserInfo() {
	if (checkIt('konqueror')) {
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkIt('safari')) browser 	= "Safari"
	else if (checkIt('omniweb')) browser 	= "OmniWeb"
	else if (checkIt('opera')) browser 		= "Opera"
	else if (checkIt('webtv')) browser 		= "WebTV";
	else if (checkIt('icab')) browser 		= "iCab"
	else if (checkIt('msie')) browser 		= "Internet Explorer"
	else if (!checkIt('compatible')) {
		browser = "Netscape Navigator"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";

	if (!version) version = detect.charAt(place + thestring.length);

	if (!OS) {
		if (checkIt('linux')) OS 		= "Linux";
		else if (checkIt('x11')) OS 	= "Unix";
		else if (checkIt('mac')) OS 	= "Mac"
		else if (checkIt('win')) OS 	= "Windows"
		else OS 								= "an unknown operating system";
	}
}

function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

/*-----------------------------------------------------------------------------------------------*/

Event.observe(window, 'load', initialize, false);
Event.observe(window, 'load', getBrowserInfo, false);
Event.observe(window, 'unload', Event.unloadCache, false);

var deactivate_logout = false;
var lightbox = Class.create();

lightbox.prototype = {

	yPos : 0,
	xPos : 0,

	initialize: function(ctrl) {
		this.content = ctrl.href;
		Event.observe(ctrl, 'click', this.activate.bindAsEventListener(this), false);
		ctrl.onclick = function(){return false;};
	},
	
	open_iframe: function(ctrl) {
		this.content = ctrl;
		this.activate();
	},
	
	// Turn everything on - mainly the IE fixes
	activate: function(){
		if (browser == 'Internet Explorer'){
			this.getScroll();
			this.prepareIE('100%', 'hidden');
			this.setScroll(0,0);
			this.hideSelects('hidden');
		}
		this.displayLightbox("block");
	},
	
	// Ie requires height to 100% and overflow hidden or else you can scroll down past the lightbox
	prepareIE: function(height, overflow){
		bod = document.getElementsByTagName('body')[0];
		bod.style.height = height;
		bod.style.overflow = overflow;
  
		htm = document.getElementsByTagName('html')[0];
		htm.style.height = height;
		htm.style.overflow = overflow; 
	},
	
	// In IE, select elements hover on top of the lightbox
	hideSelects: function(visibility){
		selects = document.getElementsByTagName('select');
		for(i = 0; i < selects.length; i++) {
			selects[i].style.visibility = visibility;
		}
	},
	
	// Taken from lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
	getScroll: function(){
		if (self.pageYOffset) {
			this.yPos = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){
			this.yPos = document.documentElement.scrollTop; 
		} else if (document.body) {
			this.yPos = document.body.scrollTop;
		}
	},
	
	setScroll: function(x, y){
		window.scrollTo(x, y); 
	},
	
	displayLightbox: function(display){
		$('overlay').style.display = display;
		$('lightbox').style.display = display;
		if(display != 'none') this.loadInfo();
	},
	
    loadInfo: function() {
        info = "<div id='lbContent'>		<div id='window'>  <div id='topWindow'>    <div id='btn_Cerrar'>      <a href='#' class='lbAction' rel='deactivate' onclick='javascript: closeLightBox();'><img name='button2' id='button2' src='/imgs/x.jpg' alt='Cerrar' border='0' style='cursor:pointer;' /></a>    </div>  </div><div id='frame_div_container' style='float: left;width:509px;height:310px;overflow:hidden;background-color: #F2F2F2; border-left: 13px solid #FFF; border-right: 13px solid #FFF;'><iframe id='lightbox_frame' frameborder='2' width='525' height='310' src='" + this.content + "' onLoad='javascript: calcHeight();' scrolling='no'></iframe></div><div id='buttomWindow'></div></div></div>";
        new Insertion.Before($('lbLoadMessage'), info)
        $('lightbox').className = "done";   
        this.actions();   
    },


	// Begin Ajax request based off of the href of the clicked linked
	loadInfo2: function() {
		if ($('form')) { 
			var myAjax = new Ajax.Request(
			this.content,
			{method: 'post', parameters: $('form').serialize(), onComplete: this.processInfo.bindAsEventListener(this)}
			);
		} else {
			var myAjax = new Ajax.Request(
			this.content,
			{method: 'post', parameters: "", onComplete: this.processInfo.bindAsEventListener(this)}
			);
			
		}
		
	},
	
	// Display Ajax response
	processInfo3: function(response){
		info = "<div id='lbContent'>" + response.responseText + "</div>";
		new Insertion.Before($('lbLoadMessage'), info)
		$('lightbox').className = "done";	
		this.actions();			
	},
	
	// Search through new links within the lightbox, and attach click event
	actions: function(){
		lbActions = document.getElementsByClassName('lbAction');

		for(i = 0; i < lbActions.length; i++) {
			Event.observe(lbActions[i], 'click', this[lbActions[i].rel].bindAsEventListener(this), false);
			lbActions[i].onclick = function(){return false;};
		}

	},
	
	// Example of creating your own functionality once lightbox is initiated
	insert: function(e){
	   link = Event.element(e).parentNode;
	   Element.remove($('lbContent'));
	 
		if ($('form')) { 
			var myAjax = new Ajax.Request(
			this.content,
			{method: 'post', parameters: $('form').serialize(), onComplete: this.processInfo.bindAsEventListener(this)}
			);
		} else {
			var myAjax = new Ajax.Request(
			this.content,
			{method: 'post', parameters: "", onComplete: this.processInfo.bindAsEventListener(this)}
			);
			
		}
	 
	},
	
	// Example of creating your own functionality once lightbox is initiated
	deactivate: function(){
		if (deactivate_logout == true) {
			location.href='http://www.sol.com.mx/debes_ser_mayor_edad.php';
			deactivate_logout = false;
			return true;
		}
		Element.remove($('lbContent'));
		
		if (browser == "Internet Explorer"){
			this.setScroll(0,this.yPos);
			this.prepareIE("auto", "auto");
			this.hideSelects("visible");
		}
		
		this.displayLightbox("none");
	}
}

/*-----------------------------------------------------------------------------------------------*/

// Onload, make all links that need to trigger a lightbox active
function initialize(){
	addLightboxMarkup();
	var lbox = document.getElementsByClassName('lbOn');
	if(lbox) { 
		for(i = 0; i < lbox.length; i++) {
			valid = new lightbox(lbox[i]);
		}
	}
}
var closeLightBox_logout = false;
function closeLightBox() {

	 Element.remove($('lbContent'));
		if (browser == "Internet Explorer"){
			window.scrollTo(0,0); 
			
			bod = document.getElementsByTagName('body')[0];
			bod.style.height = "auto";
			bod.style.overflow = "auto";
	  
			htm = document.getElementsByTagName('html')[0];
			htm.style.height = "auto";
			htm.style.overflow = "auto";
		
			// SELECT VISIBLE			
			selects = document.getElementsByTagName('select');
			for(i = 0; i < selects.length; i++) {
				selects[i].style.visibility = "visible";
			}
		}
		
		$('overlay').style.display = 'none';
		$('lightbox').style.display = 'none';	 
}
// Add in markup necessary to make this work. Basically two divs:
// Overlay holds the shadow
// Lightbox is the centered square that the content is put into.
function addLightboxMarkup() {
	bod 				= document.getElementsByTagName('body')[0];
	overlay 			= document.createElement('div');
	overlay.id		= 'overlay';
	lb					= document.createElement('div');
	lb.id				= 'lightbox';
	lb.className 	= 'loading';
	lb.innerHTML	= '<div id="lbLoadMessage">' +
						  '' +
						  '</div>';
	bod.appendChild(overlay);
	bod.appendChild(lb);
}

/* FUNCIONES PARA DIV DESPLEGABLE */

var timeout         = 400;
var closetimer		= 0;
var ddmenuitem      = 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 

function changeSelects(tipo,subtipo) {
	
	var aInfo = new Array;
	var selection = new Array;
	var i;
	var str;
	var sel;
	
	aInfo[0] = ['Pintura','Escultura','Arte callejero','Ilustraciones','Otro'];	
	aInfo[1] = ['F&uacute;tbol','Basket','Rugby','Volley','Hockey','Tenis','Handball','Otro'];	 
	aInfo[2] = ['Poes&iacute;as','Novelas','Cuentos','Mitolog&iacute;a','Otro'];	
	aInfo[3] = ['Ficci&oacute;n','Documental','Vanguardia','Independiente','Otro'];	
	aInfo[4] = ['Rock','Cl&aacute;sica','Cumbia','Ranchera','Pop','Otro'];	
	aInfo[5] = ['De revista','Musicales','Teatro Negro '];	

	if (tipo == "Deportes"){			
		selection = aInfo[1];		
	} else if (tipo == "Arte"){
		selection = aInfo[0];
	} else if (tipo == "Literatura"){
		selection = aInfo[2];
	} else if (tipo == "Cine"){
		selection = aInfo[3];
	} else if (tipo == "Teatro"){
		selection = aInfo[5];	
	} else {
		selection = aInfo[4];
	}

	
	
	for(i=0;i<selection.length;i++){
		if(selection[i] == subtipo) {
			str += "<option selected>"+selection[i]+"</option>";	
		} else {
			str += "<option>"+selection[i]+"</option>";	
		}		
	}
	
 	$('changeAboutMe').innerHTML = str; 
}
