 $(function(){
		
		
		/**** set IE classes for <body> ***/
		    if (!$.support.cssFloat) {
			  $("body").addClass("ie");
			  //affects ie7 and ie8
		    }
		    if (!$.support.boxModel || ($.browser.msie && parseInt($.browser.version) == 7)) {
			  $("body").addClass("ie7");
		    }
	    /**************************/
	    
	    
		$(document).ready(function(){
			
			
			$(".thumb, .enlargePic, .enlargeLink").fancybox();
			
			$(".sideLink").bind("click",function(){
			
				 var section = $(this).data("section")
				 if(!$(this).hasClass('active')){
					 
						$(".inner_box").css("display","none");
						
						$(".sideLink").removeClass('active');
						$(this).addClass('active');
							
						$("#_" + section).fadeIn("normal");
				 }
			});
			
			//fixes safari bug where font size is a bit bigger
			var timeFix = setTimeout(function(){
				if($(".menu_last").position().top > 74){
					var newPadding = $('body').hasClass('fr') ? "0 20px" : "0 26px";
					//li:not(.menu_last) because last one should not be changed.
					$("#sub-menu li:not(.menu_last)").find("a").css("padding",newPadding)
				}
			},2000);
			
			var currentLink = $("body").attr("id");
			var myData = "";
			$(".nav").find("a").each(function(){
				myData = $(this).data("link");
				if(myData == currentLink){
					$(this).addClass("active");
					return false;
				}
			});
				
		});
		
		$("#newsletter_link").bind("click",function(){
				if($("#newsletter_legend").length==0){	
					var legend, policy, email;
					if($("body").hasClass("fr")){
						email = "Courriel";
						legend = "Souscrivez à notre bulletin";
						policy = "Nous respectons votre vie privée et ne vendons ni ne partageons vos informations avec quiconque. Vous pouvez vous désabonner de notre bulletin à tout moment.";
					}else{
						email = "Email";
						legend = "Subscribe to our newsletter";
						policy = "We respect your privacy and do not sell or share your information with anyone. You can unsubscribe from the newsletter at any time.";
					}
					var myForm = "<fieldset id='newsletter_legend'><legend>" + legend + "</legend>" +
										"<label for='email'>" + email + ":</label><input type='text' name='email' id='email' size='25' />" +
										"<input type='button' name='submit' id='submit' value='' />" +
										"<p class='policy'>" + policy + "</p>" +
									"</fieldset><p id='response'></p>";
								
					$("#register_newsletter").html(myForm);
				}								 
		}).fancybox({
					'scrolling'		: 'no',
					'titleShow'		: false,
					'autoScale' 	: true,
					'onClosed'		: function() {
						 $("#login_error").hide();
					}
		});	
		
		$("#tripleRewardPlus").fancybox({
					'scrolling'		: 'no',
					'titleShow'		: false,
					'autoDimensions'	: false,
					'width'			: '450',
					'height'        		: 'auto'
		});	
		
		$("#submit").live( "click", function () {
					var email = $("input#email").val();  								  
						
					if (email == "") {  
							$("#email").focus();  
							return false;  
					} else{
							$.ajax({
									type: "POST",
									url: "submit_data.php",
									data: "email=" + email ,
									success: function(html){
										$("#register_newsletter fieldset").hide();
										$("#response").css("padding","10px").html(html);
									}
							});
				   }
		});
		
		
		
		$(".banner_link").hover(
		  function () {
			  $(this).find(".super_mask").fadeIn();
			  $(this).find("h3").css("background-position","-300px 0")
		  }, 
		  function () {
			  $(this).find("h3").css("background-position","right 0")
			  $(this).find(".super_mask").fadeOut();
		  }
		);

		
		
 });
 
