
/*addthis configs*/
var callermenu;
var addthis_config = {
     ui_language: "fr",
	 ui_header_color: "#000000",
	 services_exclude: 'print',
     ui_header_background: "#EFECDB"

}
/*use my addthis email template*/
var addthis_share = { email_template: "virile" }


$(document).ready(function(){
	$("#searchtopic").click(function() {
		// Act on the event
		if($("#searchtopic").val() == ""){
			$.validationEngine.intercept = true;

		}

	});
	
	$("#searchtopic").blur(function() {
		// Act on the event
		if($("#searchtopic").val() == ""){

			$.validationEngine.closePrompt(".formError",true)
		}
	});	
		/* TEXT SIZE */
		if($.cookie('font_size') == "big"){
			$("p,li,td").css("fontSize","16px")
			$("h2").css("fontSize","19px")
			$(".moreText").html("Raptissez le texte")
	}
/*main navigation*/
		$(".moreText").live("click",function() {
		// Act on the event
		if($(this).html() == "Grossir le texte"){
			$("#contentSection,#menuRecette td table.item th").css("fontSize","16px")
			$(this).html("Raptissez le texte")
			$.cookie('font_size', 'big');// Create cookie
			
		}else{
			$(this).html("Grossir le texte")
			$("#contentSection,#menuRecette td table.item th").not(".mainNav li").css("fontSize","12px")
			$.cookie('font_size', 'small');// Create cookie
		}
		return false;
	});
	$(".textBig").live("click",function() {
		// Act on the event

			$("#contentSection,#menuRecette td table.item th").css("fontSize","16px")
			$(".moreText").html("Raptissez le texte")
			$.cookie('font_size', 'big');// Create cookie
		return false;
	});
	$(".textSmall").live("click",function() {
		// Act on the event
	
			$(".moreText").html("Grossir le texte")
			$("#contentSection,#menuRecette td table.item th").not(".mainNav li").css("fontSize","12px")
			$.cookie('font_size', 'small');// Create cookie

		return false;
	});
	
	$(".btnVoir").click(function() {
		// Act on the event
		return false;
	});
	
	
	$(".print").click(function() {
		// Act on the event
		window.print()
	});
      
      /* CLOSE FORM ERRORS ON MODAL BOX */
       $().bind('cbox_closed', function(){
        	 $.validationEngine.closePrompt('.formError',true)
		});
		
/*main navigation*/
	$("ul.mainSubnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)

	$("ul.mainNav li a.trigger").hover(function() { //When trigger is hovered...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.mainSubnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.mainSubnav").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
	
	
	$("ul.mainNav li .mainSubnav").hover(function() { //When subnav is hovered keep main nav element on over state
			$(this).prev().addClass("active"); //On hover over, add class "subhover"
	}, function(){	//On Hover Out
			$(this).prev().removeClass("active"); //On hover out, remove class "subhover"
	});
	
	
	/*sign in box accordion*/

	$(".connectBloc .content .login").click(function(){

	  $(this).parent().next("div").slideToggle("fast", function() {
		if($(".logBottom").hasClass("active")){
			$(".logBottom").removeClass("active")					  
		}else{
			$(".logBottom").addClass("active")
		}														
		$.validationEngine.closePrompt(".formError",true)	
		$("#logon").validationEngine({
			scroll : false,
	        success :  function(){ userRegistrationClass.validateLogin('#errorLayerConnectionBox2',"#logon")}, 
	        failure : function() {}
	       });
		
		})
		
	  return false;
	});
	
	/*FAQ page questions accordion*/

	$(".faq .toplinks dd span").click(function(){
	caller=$(this).parent()
	  $(this).next("div").slideToggle("fast", function() {
		if($(caller).hasClass("active")){
			$(caller).removeClass("active")					  
		}else{
			$(caller).addClass("active")
		}	
	})
		
	  return false;
	});
	
	/*tooltip testing*/
		$('ul.preparation li .btnVoir').each(function(){
		   
		   	var content = '<img src="';
			content += $(this).attr('rel');
			content += '" alt="Loading thumbnail..."  width="150" /><p>';
			content += $(this).attr('title');
		    content += '</p>';
		    
			  $(this).qtip({
		   		hide: {
					fixed: true
				
				},
			   content: content,
				
				 style: {
				  	tip: {
						corner: 'rightMiddle',
						color: '#E4610C'
					},
					border: {
						width: 1,
						color: '#C4C2BB',
						radius: 2
					},
					textAlign: 'center',
					padding: 5
				  },
				
			   position: {
				  corner: {
					 target: 'rightMiddle',
					 tooltip: 'rightMiddle'
				  },
				  adjust: {
				  	y: 0,
					x: -25
				  }
			   }
			
		})
	})
	

		 $(".searchBox").validationEngine({
		  scroll : false,
		  success :  false,
		  failure : function() { 
		  	$().click(function(){
				$.validationEngine.closePrompt(".searchtopicformError",true)
			})
		  }
		 })

	/*Color box popup*/
	$("a[rel='recette']").colorbox({photo:"true", transition:"fade"});
	$(".colorbox").colorbox();
	/*menu version*/
	$(".menupop").colorbox();
	$(".vidlink").colorbox({iframe:true, width:640, height:480});
	

	/*var zIndexNumber = 1000;
	$('ul.mainNav li ul.mainSubnav,.breadcrumb li h3 a').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});*/




});

