// JavaScript Document
    
jQuery(document).ready(function() {
  
	jQuery("#contentMain .disseny li").mouseover(function() {
		atrbRel = jQuery(this).attr("rel");												
		jQuery("img",this).attr('src','/img/categories-disseny/'+atrbRel+'-hover.jpg').css("border-color", "#999");
		jQuery("p",this).css("background-image", "url(/img/backtitcategoria.jpg)");
		jQuery("p",this).css("color", "#330000");
	}).mouseout(function() {
		jQuery("img",this).attr('src','/img/categories-disseny/'+atrbRel+'.jpg').css("border-color", "#999");
		jQuery("p",this).css("background-image", "none");
		jQuery("p",this).css("color", "#666666");
	});
	jQuery("#contentMain .llista li").mouseover(function() {
		atrbRel = jQuery(this).attr("rel");												
		jQuery("img",this).css("border-color", "#666");
		jQuery("p",this).css("background-image", "url(/img/backtitcategoria.jpg)");
		jQuery("p",this).css("color", "#330000");
	}).mouseout(function() {
		jQuery("img",this).css("border-color", "#999");
		jQuery("p",this).css("background-image", "none");
		jQuery("p",this).css("color", "#666666");
	});
	
	// GLOBO INFO

	jQuery(".llista li").mouseover(function() {
		
		posicionLi = jQuery(this).offset();
		//alert(posicionLi.top);
		widthGlobo = jQuery(this).innerWidth();
		titol = jQuery(this).attr("title");
		client = jQuery(this).attr("id");
		mides = jQuery(this).attr("data-mides");
		pos = jQuery(this).attr("data-pos");
		multimedia = jQuery(this).attr("data-multimedia");
		
		if (pos == "4") {
			jQuery("#globo").css("background-image", "url(/img/globo2.jpg)");
			jQuery("#globo").css("left", posicionLi.left-widthGlobo-20+"px");
		} else {
			jQuery("#globo").css("background-image", "url(/img/globo.jpg)");
			jQuery("#globo").css("left", posicionLi.left+widthGlobo+3+"px");
		}
		
		jQuery("#globo").css("top", posicionLi.top+"px");
		jQuery("#globo").fadeIn("fast");
		jQuery("#globo .title").html(titol);
		jQuery("#globo .client span").html(client);	

		if (jQuery(this).attr('data-multimedia')) {
			jQuery("#globo .multimedia span").html(multimedia);
			jQuery("#globo .mides").css("display", "none");
			jQuery("#globo .multimedia").css("display", "block");
		} else {
			jQuery("#globo .mides span").html(mides);
			jQuery("#globo .multimedia").css("display", "none");
			jQuery("#globo .mides").css("display", "block");
		}

	}).mouseout(function() {
		jQuery("#globo").css("display", "none");
	});
	
	jQuery("#tabs .ulTabs li a").click(function() {
		jQuery("#globo").css("display", "none");
	});
	
	// MENÚ CABECERA
	
	//jQuery("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	
	jQuery("ul.topnav li").mouseover(function() {
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		jQuery(this).find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
		jQuery(this).css("background-color", "#330000");
		jQuery('.linkTopnav',this).css("color", "#fff");

		jQuery(this).hover(function() {
		}, function(){	
			jQuery(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
			jQuery(this).css("background", "none");
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			jQuery(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			jQuery(this).removeClass("subhover"); //On hover out, remove class "subhover"
			jQuery('.linkTopnav',this).css("color", "#666")
			
	});
	
	// Div Ampliar Fotos
	jQuery(".divAmpliar").append('<div style="position:relative"><div class="content"><div class="txt">Ampliar + &nbsp;&nbsp;</div><div class="back"></div></div></div>');
	jQuery(".divAmpliar").mouseover(function() {
			medida = jQuery("img",this).innerWidth();
			jQuery(this).css("width", medida+2);
		jQuery(".back",this).fadeTo('fast', 0.9, function() {
		});
		jQuery("div",this).fadeIn("fast");
	}).mouseout(function() {
		jQuery("div",this).fadeOut("fast");
	});
	
	// UI TABS
	
	jQuery(function() {
		jQuery( "#tabs" ).tabs();
	});
});

function toolRedes(name) {
	if (jQuery("."+name).css("display")=="none") {	
		jQuery("."+name).fadeIn("slow");
	} else {
		jQuery("."+name).fadeOut("fast");
	}
}


