$(document).ready(function() {
	
	//Colorbox galeria		
	var url = window.location;    
    var match = url.pathname.indexOf("_galeria");
    if (match != -1) { 
		var url = new String(url.pathname.split("_galeria:"));        
        var content = url.split(",");
        var number = content[1].split("/");
        var getrel = number[0];// id galery
		$("a.colorbox").each(function(){
         if ($(this).attr('rel') == getrel) {
             $(this).colorbox({transition:"fade",title:' '});	
         }
        });  
	}
	
	//Colorbox galeries 	
	var match2 = url.pathname.indexOf("fotos");
    if (match2 != -1) { 
		var url = new String(url.pathname.split(",fotos:"));        
        var content = url.split(",");		
        var number = content[1].split("/");		
        var getrel = number[0];// id galery		
		$("a.colorbox").each(function(){
         if ($(this).attr('rel') == getrel) {
             $(this).colorbox({transition:"fade",title:' '});	
         }
        });  
	}

		
	 // AddClass a inputs
	
	$('input[type="text"],textarea,input[type="email"]').focus(function() {
		$(this).addClass("focusField");
    }).blur(function() {
    	$(this).removeClass("focusField");
    });
	
	$("a[class=external]").click(function(){this.target = "_blank";});
	$("ul#footernav li:last").addClass("last");
	$("ul#nav li:last").addClass("last");
	$("ul#nav li:last").addClass("last");
	$("ul#homelist li:last").addClass("last");
	$("ul#select_idioma li:last").addClass("last");
	 
	// Igualar l'alçada de les columnes
	equalHeight($(".equalHeight_ul li"));
    equalHeight($(".equalHeight_div"));
	
});

function posaLaFoto(quinaFoto,id) { 
	document.getElementById(id).src = quinaFoto;
}

function ver(id) {
	$("#"+id).slideDown(500);
	$("#"+id).fadeIn('slow');
}


function equalHeight(group) {
    var tallest = 0;
    group.each(function() {
        var thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

function mycarousel_initCallback(carousel) {
    jQuery('#mycarousel-next').bind('click', function(e) {
        e.preventDefault();
		carousel.next();
        return false;
    });

    jQuery('#mycarousel-prev').bind('click', function(e) {
		e.preventDefault();
        carousel.prev();
        return false;
    });
};


