$(document).ready(function(){
	var path = "/";
	//alert(typeof(prettyCheckboxes));
	/*$('input[type=checkbox],input[type=radio]').prettyCheckboxes();*/
	/*** inicio de sesi&oacute;n ***/
	/*$('#apartado-login').css('display','none');*/
	$('.boxgrid.captionfull').hover(function(){$(".cover", this).stop().animate({top:'70px'},{queue:false,duration:160});}, function() {$(".cover", this).stop().animate({top:'124px'},{queue:false,duration:160});}); /* Fondos multimedia */
	var abutton = $('#accountbutton'),
	submenu = $('div#caja-login').get(0) || $('ul#caja-menu').get(0);
	if (submenu) {
		submenu = $(submenu);
		var clickOutside,
		hideMenu = function(){
			abutton.removeClass('selected').unbind('click').click(showMenu);
			$('div.inicio1_on').removeClass('inicio1_on').addClass('inicio1');
			$('div.inicio2_on').removeClass('inicio2_on').addClass('inicio2');
			$('div.inicio3_on').removeClass('inicio3_on').addClass('inicio3');
			abutton.addClass('blanco');
			abutton.find("img:first").attr("src", path+"img/flecha_inicio_abajo.png");
			abutton.css("color","white");
			submenu.hide();
			$(document).unbind('click', clickOutside);
			return false;
		},
		showMenu = function(){
			abutton.addClass('selected').unbind('click').click(hideMenu);
			$('div.inicio1').removeClass('inicio1').addClass('inicio1_on');
			$('div.inicio2').removeClass('inicio2').addClass('inicio2_on');
			$('div.inicio3').removeClass('inicio3').addClass('inicio3_on');
			abutton.removeClass('blanco');
			submenu.show();
			abutton.find("img:first").attr("src", path+"img/flecha_inicio_arriba.png");
			abutton.css("color","#666");
			submenu.find('input[name="user"]').focus();
			$(document).click(clickOutside);
			return false;
		};
		clickOutside = function(e){
			var elems = $(e.target).parents().andSelf();
			if ($.inArray(submenu[0], elems) == -1 && $.inArray(abutton[0], elems) == -1)
				hideMenu();
		};
		hideMenu();
	}
	/*** fin de inicio de sesi&oacute;n ***/
	$("#load_web").css('display','block');
	/*$("#form_autentificacion label").inFieldLabels(); //para mostrar el texto que debe ir dentro de los formularios */
	$("h4").hover(function(){$(this).css("backgroundColor", "#ccffff");},function(){$(this).css("backgroundColor", "#ccc");});
	$("li.entra a img").hover(function(){$(this).attr("src", path+"img/entra_on.png");},function(){$(this).attr("src", path+"img/entra_off.png");});
	
	$(".texto-noticia").hide(); // esconder las noticias
	$(".separador:first").hide(); //esconder los separadores en la cabecera de la noticia
	$(".texto-noticia:first").show(); // mostrar la primera noticia como desplegada
	
	$("ul.desplegable").hide(); // esconder el desplegable del menu
	$("ul.desplegado").show(); // mostrar el menu desplegado si es necesario
	$(window).bind("load",function() {$("#load_web").fadeOut(100,function() {$(window).unbind("load");});}); //precarga de la web
	$("a[rel='externo']").click(function(){this.target = "_blank";});
	$("a[class='ventana']").click(function () {  
		var propiedades = this.getAttribute('rel').split("-");
		if(propiedades[0] == 'fullscreen'){
			var caracteristicas = "scrollTo,resizable=1,scrollbars=1,location=0,fullscreen=1";
		}else{
			var caracteristicas = "height="+propiedades[0]+",width="+propiedades[1]+",scrollTo,resizable=1,scrollbars=1,location=0";
		}
		nueva=window.open(this.href, 'Ventana', caracteristicas);  
		return false;  
	});
	$("input:text, input:password, textarea").tipTip({activation: "focus", defaultPosition: "left"});
	$("input:checkbox, input:image, a.ventana").tipTip();
	//$("input:text, input:password, textarea").each(function(){$(this).css({backgroundColor: "#ccc", border: "1px solid #ccc"})});
	$("input:text, input:password, textarea").each(function(){$(this).addClass('inputs')});
	/*$("#form_autentificacion input:text, #form_autentificacion input:password").each(function(){$(this).css({backgroundColor: "#ccc", border: "1px solid #ccc"})});*/
	/*** $("#form_registro input:text, #form_registro input:password").each(function(){$(this).css({width:"166px"})});***/
	/* inicio prueba */
	$("input, textarea").focusin(function(){$(this).css('backgroundColor', '#00ffff');}).focusout(function(){$(this).css('backgroundColor', 'white');});
	/*$("input, textarea").focusin(function(){$(this).addClass('sffocus');}).focusout(function(){$(this).removeClass('sffocus');});*/
	/*$("input:text, textarea").each(function(){if(this.value == ''){this.value = this.title;}});
	$("input:text, textarea").focus(function(){if(this.value == this.title){this.value = '';}});
	$("input:text, textarea").blur(function(){if(this.value == ''){this.value = this.title;}});*/
	//$("input:image, input:button, input:submit").click(function(){$(this.form.elements).each(function(){if(this.type == 'text' || this.type == 'textarea'){if(this.value == this.title && this.title != ''){this.value='';}}});});
	/*** fin prueba ***/
	$(".desplegar h2 a").bind('click', function(e){ // despliega el menu y cambia la imagen del primero segun este desplegado o no
		var imagen = $(this).attr("id");
		if ($(this).attr("class") == imagen+'_seleccionado'){var color = "azul";}else{var color = "gris";}
		if($(this).parent().parent().find("ul.desplegable:first").is(":hidden")){
			$(this).parent().parent().find("ul.desplegable:first").show("normal");
			$(this).parent().parent().find("img:first").attr("src", path+"img/"+imagen+"_"+color+"_abierto.png");
			$(this).css("background-image", "url("+path+"img/"+imagen+"_azul_abierto.png)");
		}else{
			$(this).parent().parent().find("ul.desplegable:first").hide("normal");
			$(this).parent().parent().find("img:first").attr("src", path+"img/"+imagen+"_"+color+"_cerrado.png");
			$(this).css("background-image", "url("+path+"img/"+imagen+"_azul_cerrado.png)");
		}
	});
	$('label.txtarea_oculto').bind('click', function(e){
		if($(this).parent().find('textarea').is(":hidden")){
			$(this).parent().find('textarea').show();$(this).parent().find('img').attr('src','../img/flecha_perfil_down.png');
		}else{
			$(this).parent().find('textarea').hide();$(this).parent().find('img').attr('src','../img/flecha_perfil_up.png');
		}
	});
	$(".gris").hover(function(){$(this).find("img:first").attr("src", path+"img/bola_on.png");},function(){$(this).find("img:first").attr("src", path+"img/bola_off.png");});
	$("img.a").hover(function(){ // efecto para el menu
		$(this).parent().css({backgroundPosition: "0px 0px"});$(this).stop().animate({"opacity": "0"}, "normal");},function() {$(this).stop().animate({"opacity": "1"}, "normal", function(){$(this).parent().css({backgroundPosition: "163px 0px"});});
	});
	$(".cabecera-noticia").bind('click', function(e){ //noticias
		if($(this).attr("class") == "cabecera-noticia cabecera-noticia-desplegada"){
			$(this).find("img:first").attr("src", path+"img/flecha_abajo.png");
			$(this).find("img:first").removeClass("flecha-arriba").addClass("flecha-abajo");
			$(this).removeClass("cabecera-noticia-desplegada").addClass("cabecera-noticia-plegada");
			$(this).find("span.separador:first").show();
			$(this).find("div.fecha-noticia-desplegada:first").removeClass("fecha-noticia-desplegada").addClass("fecha-noticia-plegada");
			$(this).find("h3.titular-noticia-desplegada:first").removeClass("titular-noticia-desplegada").addClass("titular-noticia-plegada");
			$(this).parent().find("div.texto-noticia:first").hide();
		}else{
			$(this).find("img:first").attr("src", path+"img/flecha_arriba.png");
			$(this).find("img:first").removeClass("flecha-abajo").addClass("flecha-arriba");
			$(this).removeClass("cabecera-noticia-plegada").addClass("cabecera-noticia-desplegada");
			$(this).find("div.fecha-noticia-plegada:first").removeClass("fecha-noticia-plegada").addClass("fecha-noticia-desplegada");
			$(this).find("span.separador:first").hide();
			$(this).find("h3.titular-noticia-plegada:first").removeClass("titular-noticia-plegada").addClass("titular-noticia-desplegada");
			$(this).parent().find("div.texto-noticia:first").show();
		}
	});
	if($('.avatar').length){$('.avatar').unity3d();}
});
function dame_correo(usuario,forma){if(forma == 1){document.write(usuario+"@"+"biworld3d.com");}else if(forma == 2){document.write("<a href=\"mailto:"+usuario+"@"+"domethegame.com\">"+usuario+"@"+"domethegame.com</a>");}}
// Para el ticker de prueba de la parte de abajo del juego.
jQuery.fn.liScroll = function(settings) {
		settings = jQuery.extend({
		travelocity: 0.07
		}, settings);		
		return this.each(function(){
				var $strip = jQuery(this);
				$strip.addClass("newsticker")
				var stripWidth = 0;
				var $mask = $strip.wrap("<div class='mask'></div>");
				var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");								
				var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width 	
				$strip.find("li").each(function(i){
				stripWidth += jQuery(this, i).outerWidth(true); // thanks to Michael Haszprunar
				});
				$strip.width(stripWidth);			
				var totalTravel = stripWidth+containerWidth;
				var defTiming = totalTravel/settings.travelocity;	// thanks to Scott Waye		
				function scrollnews(spazio, tempo){
				$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth); scrollnews(totalTravel, defTiming);});
				}
				scrollnews(totalTravel, defTiming);				
				$strip.hover(function(){
				jQuery(this).stop();
				},
				function(){
				var offset = jQuery(this).offset();
				var residualSpace = offset.left + stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollnews(residualSpace, residualTime);
				});			
		});	
};