// JavaScript Document
// funcions i crides jQuery per aquest site
$(document).ready(function() {
	$('div.item-llistat').corner();
	$('div.item-detail').corner();
	$('div.item-select-date').corner();
	$('div.search').corner(" bottom 5px");
	$('div.preu').corner("3px");
	$('h4.titol-bg').corner("3px");
	$('div.item-block').corner("6px");
	$("#cercador").focus(function() {if (this.value == "Cercador...") {this.value = "";}});
	$("#cercador").blur(function() {if (this.value == "") {this.value = "Cercador...";}});
	$('.date-pick').datePicker();
	
	var thumbLinks = $('#galleryThumbs a');
	var thumbCount = thumbLinks.length;
	var thumbImages = $('#galleryThumbs img');
	var image = $("#galleryImage");
	var fadeSpeed = "fast";

	image.hide();
	setTimeout("$('#galleryImage').fadeIn('fadeSpeed')", 800);

	thumbLinks.each(function(i) {
		var current = (i+1);
			this.onclick = function () {
				var imageUrl = this.getAttribute('href'); 
				var imageDescription = $(this).find("img").attr("alt");
				image.fadeOut(fadeSpeed, function() {
					$("#galleryImage img").attr({ src: imageUrl, alt: imageDescription});
					setTimeout("$('#galleryImage').fadeIn('fadeSpeed')", 800); 
				})
				return false;	
			}

	})
});