
$(document).ready(function() {
	$("#cell_cistella a").click(function(){toggleCistella(); return false;});
	$("#cell_contactar a").click(function(){toggleContactar(); return false;});
});

function toggleCistella() {
	hideContactar();
	$("#area_cistella").slideToggle("normal", scrollBottom);
	
	if ($("#cell_cistella").attr("class") == "footer") {
		$("#cell_cistella").attr({"class": "footer_on"});
		$("#cell_cistella img").attr({"src": img_base+"hide.gif"});
	}
	else {
		$("#cell_cistella").attr({"class": "footer"});
		$("#cell_cistella img").attr({"src": img_base+"show.gif"});
	}
}

function hideCistella() {
	$("#cell_cistella").attr({"class": "footer"});
	$("#cell_cistella img").attr({"src": img_base+"show.gif"});
	$("#area_cistella").slideUp("normal");
}

function toggleContactar() {
	hideCistella();
	$("#area_contactar").slideToggle("normal", scrollBottom);
	
	if ($("#cell_contactar").attr("class") == "footer") {
		$("#cell_contactar").attr({"class": "footer_on"});
		$("#cell_contactar img").attr({"src": img_base+"hide.gif"});
	}
	else {
		$("#cell_contactar").attr({"class": "footer"});
		$("#cell_contactar img").attr({"src": img_base+"show.gif"});
	}
}

function hideContactar() {
	$("#cell_contactar").attr({"class": "footer"});
	$("#cell_contactar img").attr({"src": img_base+"show.gif"});
	$("#area_contactar").slideUp("normal");
}


function showCistella() {
	hideContactar()
	$("#cell_cistella").attr({"class": "footer_on"});
	$("#cell_cistella img").attr({"src": img_base+"hide.gif"});
	$("#area_cistella").slideDown("normal", scrollBottom);
}

function afegirVi(pid) {
	showCistella();
	$("#ft_prod_c"+pid).show();
	$("#ft_prod_b"+pid).hide();
	
	scrollBottom();
}



function scrollBottom() {
	var x_off = 0;
	if ((window.pageXOffset != null) && (window.pageXOffset != undefined)) {
		x_off = window.pageXOffset;
	}
	else if ((document.body.scrollLeft != null) && (document.body.scrollLeft != undefined)){
		x_off = document.body.scrollLeft;
	}
	window.scrollTo(x_off, $("body").height());
}

