$(document).ready(function()
	{
	$(function () {
			
//////////When you pass over me, I'm shining like the sun
		$('#mainMenu li').find('a').each(function () {
			var $img = $('img.hover', this).css("opacity", "0");
			var $img = $('img.hover', this).css("display", "block");
			$(this).hover(function () {
				$img.stop().fadeTo(350, 1);
			}, function () {
				$img.stop().fadeTo(750, 0);
			});
		});
		
		$('#directionMenu li').find('a').each(function () {
			var $img = $('img.hover', this).css("opacity", "0");
			var $img = $('img.hover', this).css("display", "block");
			$(this).hover(function () {
				$img.stop().fadeTo(350, 1);
			}, function () {
				$img.stop().fadeTo(250, 0);
			});
		});
		
		$('#footerLogo').find('a').each(function () {
			var $img = $('img.hover', this).css("opacity", "0");
			var $img = $('img.hover', this).css("display", "block");
			$(this).hover(function () {
				$img.stop().fadeTo(350, 1);
			}, function () {
				$img.stop().fadeTo(250, 0);
			});
		});
		
//////////The last one doesn't get a piece of cake
		$("ul").find("li:last").each(function(){
			$(this).css({"border":"none"});
		});
		
		
		
////////////////////////
$(" #mainMenu ul ul ").css('opacity', 0);
$(" #mainMenu ul ul ").css({display: "none"}); // Opera Fix
$(" #mainMenu li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).animate({ 
        "height": "toggle",
        opacity: 1      
      }, 300 );
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"}).animate({ 
        "height": "toggle",
        opacity: 0      
      }, 200 );
		});
/*
$(" #mainMenu ul ul .contact").hover(function(){
	$(this).parents("li").find('a:first').css("left", 100);
});*/

		
//////////When you look at me ... I completely disappear
		$("#top").find("input").each(function(){
			$(this).focus(function () {
				$(this).val("");
			});
		});
		
		
//////////Tell me where i'm going
		$("a[rel='3m4il']").each(function(){
			var spaceShip = $(this).text();
			var spaceStation = $(this).attr('href');
			
			$(this).attr({
				href: 'mailto:'+ spaceShip +'@'+ spaceStation +'',
				rel: 'nofollow'
			});
			$(this).text(''+ spaceShip +'@'+ spaceStation +'');
		});
			
				
//////////Cookie monster just around the corner
		function setCookie(name,value,expiredays){
			var exdate=new Date();
			exdate.setDate(exdate.getDate()+expiredays);
			document.cookie=name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
		}
		
		function getCookie(c_name){
			if (document.cookie.length>0){
			  c_start=document.cookie.indexOf(c_name + "=");
				  if (c_start!=-1){ 
				    c_start=c_start + c_name.length+1; 
				    c_end=document.cookie.indexOf(";",c_start);
				    if (c_end==-1) c_end=document.cookie.length;
				    return unescape(document.cookie.substring(c_start,c_end));
			    } 
			}
		return "";
		}
		
		function checkCookie(c_name){
			getSizeCookie=getCookie(c_name);
			if (getSizeCookie!=null && getSizeCookie!=""){
				//alert('The number is '+getSizeCookie+'!');
				}
			else{
				size=prompt('Please enter a number:',"");
					if (size!=null && size!=""){
						setCookie('textSize',size,365);
					}
			}
		}

	//checkCookie();
	
	
//////////Make me bigger or smaller, I don't care		
		// Original Font Size
		var originalFontSize = $('#pageContent').css('font-size');
		//	alert(originalFontSize);
		if ($.browser.msie) {
			var originalFontSize = parseInt(originalFontSize, 10);
			//var originalFontSize = originalFontSize-1;
		//	alert(originalFontSize);
		}
		$("#normal").click(function(){
			$('#pageContent').css('font-size', originalFontSize);
			setCookie('textSize',""+ originalFontSize + "",365);
		});
		
		var getSizeCookie = getCookie("textSize");
		if(getSizeCookie!=null && getSizeCookie!=""){
			var getSizeCookieNum = parseInt(getSizeCookie, 10);
		//	alert(getSizeCookieNum);
			$('#pageContent').css('font-size', getSizeCookieNum);
		};
		
		// Increase Font Size
		$("#plus").click(function(){
			var currentFontSize = $('#pageContent').css('font-size');
			var currentFontSizeNum = parseInt(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*1.2;
			$('#pageContent').css('font-size', newFontSize);
			setCookie('textSize',""+ newFontSize + "",365);
			return false;
		});
		// Decrease Font Size
		$("#minus").click(function(){
			var currentFontSize = $('#pageContent').css('font-size');
			var currentFontSizeNum = parseInt(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*0.8;
			$('#pageContent').css('font-size', newFontSize);
			setCookie('textSize',""+ newFontSize + "",365);
			return false;
		});

				
		
//////////Little bubble falling from the sky
		$(".bubble").css('opacity', 0);
		$("#soon").hover(function(){
			$(".bubble")
			.css({
				display: "block"
			})
			.animate( { opacity:1 }, { queue:false, duration:500 })
			.animate({top: "0px"},{ queue: false, duration:500});
		}, function(){
			$(".bubble").stop()
			.animate( { opacity:0 }, {duration:500 })
			.animate({top: "-45px"},{duration:1});
		});
		
		
//////////The french connection
		$("#connexion").each(function(){
			// options
			var hideDelay = 500;
			var hideDelayTimer = null;
		
			// tracker
			var beingShown = false;
			var shown = false;
			
			$("#connexion,#connectMe")
			.mouseover(function(){
				if (hideDelayTimer) clearTimeout(hideDelayTimer);
				if (beingShown || shown) {
				return;
				} else {
				beingShown = true;
				
				$("#connectMe")
				.css({
					display: "block"
				})
				.animate({ 
					opacity:1,
					top:0
				},500, "swing", function() {
		          beingShown = false;
		          shown = true;
		        });
		        }
			}).mouseout(function(){
				hideDelayTimer = setTimeout(function () {
					hideDelayTimer = null;
					$("#connectMe")
					.animate({ 
						opacity:0,
						top:-45
					}, 500, 'swing', function () {
					shown = false;
					$("#connectMe").css('display', 'none');
					});
					}, hideDelay);
			});
		});



		
//////////Print me me me...
		$("#print").click(function(){
			window.print();
		});
		
		

/////////She's The Form, you have to do what she say...
		$(".post").find(":text").each(function(){
			$(this).addClass("text");
		});
		$(".post").find(":password").each(function(){
			$(this).addClass("password");
		});
		$(".post").find(":checkbox").each(function(){
			$(this).addClass("checkbox");
		});
		$(".post").find(":submit").each(function(){
			$(this).addClass("submit");
		});
		$(".post").find(":button").each(function(){
			$(this).addClass("submit");
		});
				
//////////Calendrier open Overlay...
//$(".gallery:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast',slideshow:10000});
			
			
/*
function eventinfocontent() {
		    var latlng = new google.maps.LatLng(45.4551, -73.4466);
		    var myOptions = {
		      zoom: 8,
		      center: latlng,
		      mapTypeId: google.maps.MapTypeId.ROADMAP
		    };
		    var map = new google.maps.Map(document.getElementById("map_canvas"),
		        myOptions);
		  }
		  	
$("div.custom_content a[rel^='prettyPhoto']").each(
	function(i) {
		
		$(this).prettyPhoto({
				custom_markup: '<div id="map_canvas" style="width:758px; height:462px"></div>',
				changepicturecallback: function(){ eventinfocontent(); }
			});	
		
	});	
*/	



		
//////////Picasso would have been proud...
		$(".gallery a").lightBox();
		
	});	
});

/*
$(function() {
    // Setup a basic iframe for use inside overlays.
    var theframe = $('<iframe id="ifframe" frameborder="0" scrolling="no"></iframe>');
     // Overlay
    $('a[rel]').overlay({
        mask: '#575850',
        effect: 'apple',
        onBeforeLoad: function() {
            //First get the wrap
            var wrap = this.getOverlay().find(".contentWrap");
            //Get the URL from the trigger
            var link = this.getTrigger().attr("href");
            //Add the link and style attributes to the basic iframe
            $(theframe).attr({ src: link, style: 'height:506px; width:690px; border:none; overflow:hidden;' });
            //Write the iframe into the wrap
            wrap.html(theframe);
        }
    });
});
*/



