$(document).ready(function(){
  	 $('li.headlink').hover(
  	 	function() { $('ul', this).css('display', 'block'); },
  	 	function() { $('ul', this).css('display', 'none'); });	
		
  	 $('#btn_serie_okanagan').hover(
  	 	function() { 
			var link_src = $(this).attr("src");
			link_src = link_src.replace(".gif","_hover.gif"); 
			$(this).attr("src",link_src);
		},
  	 	function() { 
			var link_src = $(this).attr("src");
			link_src = link_src.replace("_hover.gif",".gif"); 
			$(this).attr("src",link_src);
		});
	 	// $('#btn_envoyer').hover(
	 	// 	  	 	function() { 
	 	// 				$(this).addClass("over");
	 	// 			},
	 	// 	  	 	function() { 
	 	// 				$(this).removeClass("over");
	 	// 			});
	 $("#img_couleurs img").hover(
		function() { 
			if(($(this).attr("id")).indexOf("rouge") != -1){
				if(($(".ul_couleurs li.rouge img").attr("id")).indexOf("_active") == -1){
					var link_src = $(".ul_couleurs li.rouge img").attr("src");
					link_src = link_src.replace("_up","_down");
			    	$(".ul_couleurs li.rouge img").attr("src", link_src);
				}
			}else{
				if(($(".ul_couleurs li.blanc img").attr("id")).indexOf("_active") == -1){
					var link_src = $(".ul_couleurs li.blanc img").attr("src");
					link_src = link_src.replace("_up","_down");
			    	$(".ul_couleurs li.blanc img").attr("src", link_src);
				}
			}
  	 	},
  	 	function() { 
  	 		if(($(this).attr("id")).indexOf("rouge") != -1){
				if(($(".ul_couleurs li.rouge img").attr("id")).indexOf("_active") == -1){
					var link_src = $(".ul_couleurs li.rouge img").attr("src");
					link_src = link_src.replace("_down","_up");
					$(".ul_couleurs li.rouge img").attr("src", link_src);
				}
			}else{
				if(($(".ul_couleurs li.blanc img").attr("id")).indexOf("_active") == -1){
					var link_src = $(".ul_couleurs li.blanc img").attr("src");
					link_src = link_src.replace("_down","_up");
					$(".ul_couleurs li.blanc img").attr("src", link_src);
				}
			}
  	 	});
	if($(this).attr("class") != "current_page_coordonnees"){
	$('#contact_btn').hover(function() {
		$(this).addClass("current_page_coordonnees")
	}, function() {
		$(this).removeClass("current_page_coordonnees")
	})
	}

  	 $('#couleurs li img,#couleurs_en li img,#sizes li img,#liste_capacite li img').hover(img_over,img_out);
  	 $(".carousel").jCarouselLite({
  	    btnNext: ".next",
  	    btnPrev: ".prev",   
  	    circular: false
  	 });
	$("#list_accordeon div p.lien,#btn_envoyer,#btn_envoyer_en").hover(function() {
		$(this).addClass("hover")
	}, function() {
		$(this).removeClass("hover")
	})
  	 $('#list_accordeon div p.lien').click(function() { 
  	 	if($(this).next().css("display") == "none"){
			$("#list_accordeon div p.lien").removeClass("current");
			$("#list_accordeon div p.lien img").attr("src", "../assets/medias/arrow_accordeon_up.gif");
  	 		$('#list_accordeon div div.down').slideUp("slow");
			$(this).children("img").attr("src", "../assets/medias/arrow_accordeon_down.gif");
  	 		$(this).parent().find(".down").slideDown("slow");	
			$(this).addClass("current");
			if($(this).attr("rel") != undefined) {
				$(".box-gauche-many").hide();
				$(".box-gauche-many."+$(this).attr("rel")).show();
			}
		}
  	 });
});

function img_over(){
	if(($(this).attr("id")).indexOf("_active") == -1){
		var link_src = $(this).attr("src");
		link_src = link_src.replace("_up","_down");
    	$(this).attr("src", link_src);
	}
}
function img_out(){
	if(($(this).attr("id")).indexOf("_active") == -1){
		var link_src = $(this).attr("src");
		link_src = link_src.replace("_down","_up");
		$(this).attr("src", link_src);
	}	
}
function print_r(theObj){
	if(theObj.constructor == Array || theObj.constructor == Object) {
		document.write("<ul>");
		for(var p in theObj){
			if(theObj[p].constructor == Array || theObj[p].constructor == Object) {
				document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
				document.write("<ul>");
				print_r(theObj[p]);
				document.write("</ul>");
			} else {
				document.write("<li>["+p+"] => "+theObj[p]+"</li>");
			}
		}
		document.write("</ul>");
	}
}
