$(document).ready ( function() {

	// acordio home
	//____________________________________________________________________ *//
	$("body").addClass("js");
	
	$(".contingut-acordio").hrzAccordion({eventTrigger:"click",openOnLoad:"1",handlePositionArray:"left,left,left"});
	$("#contingut-acordioHandle0").append('<img src="/en/binaris/agenda.png" alt="agenda" />');
	$("#contingut-acordioHandle1").append('<img src="/en/binaris/noticies.png" alt="noticies" />');
	$("#contingut-acordioHandle2").append('<img src="/en/binaris/butlleti.png" alt="butlleti" />');	

	// howto home
	//____________________________________________________________________ *//
	
	$("#carroussel-imatges img").click(function () {
		$("#carroussel-imatges img").removeAttr('id');
		$("#carroussel-info div").hide();
		$("#"+this.className+" img").fadeIn(2000);
		$("#"+this.className+" div.howto-info").show();
		$("#"+this.className+"").show();
		$(this).attr('id', 'howto-active'); 
	});
	
	$("div#carroussel-info div[id^=howto-]").click(function(){
		var linkHowTo = $("a:first",this).attr("href");
		window.location = linkHowTo;
		return false;
	});

	$("#carroussel-info div[id^=howto-]").hover(function(){
		$(this).css("cursor", "hand");
	});
	
	$('#carroussel-info').each(function(){
		var HowToClass = "";
		var IdView = Math.floor(Math.random() * 100);
		if(IdView > 0 && IdView <= 30){
			HowToClass = 'howto-1'
		}else if(IdView > 30 && IdView <= 44){
			HowToClass = 'howto-2'
		}else if(IdView > 44 && IdView <= 58){
			HowToClass = 'howto-3'
		}else if(IdView > 58 && IdView <= 72){
			HowToClass = 'howto-4'
		}else if(IdView > 72 && IdView <= 86){
			HowToClass = 'howto-5'
		}else if(IdView > 86 && IdView <= 100){
			HowToClass = 'howto-6'
		}else{
			HowToClass = 'howto-1'
		}
		
		$("div#"+HowToClass).attr('style', 'display: block');
		$("#carroussel-imatges img."+HowToClass).attr('id', 'howto-active'); 
	});

});


