$(document).ready(function(){
	//mainmenu
	//#mainMenu .leftColumn ul.nice-menu-right li a
	
	$('#mainMenu ul.sf-menu 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(200, 1);
			}, function () {
				$img.stop().fadeTo(100, 0);
			});
		});
		
////////sous-ssssous menu 
	$("ul.sf-menu").superfish({ 
            animation: {height:'show'},   // slide-down effect without fade-in 
            delay:     1200               // 1.2 second delay on mouseout 
        });	
	
	$('#subMainmenu 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(200, 1);
			}, function () {
				$img.stop().fadeTo(100, 0);
			});
		});
		
	/*boxPromotions*/	
	$('#boxPromotions').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(200, 1);
			}, function () {
				$img.stop().fadeTo(100, 0);
			});
		});			
	$('#mediaLink 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(80, 1);
			}, function () {
				$img.stop().fadeTo(100, 0);
			});
		});
//////////When you look at me ... I completely disappear
		/*$("#search-block-form").find("input").each(function(){
			$(this).focus(function () {
				$(this).val("");
				$(this).css("background", "#fff");
			});
			if()
		});*/
		
		$('input[type="text"]').addClass("idleField");
       		$('input[type="text"]').focus(function() {
       			$(this).removeClass("idleField").addClass("focusField");
    		    if (this.value == this.defaultValue){ 
    		    	this.value = '';
				}
				if(this.value != this.defaultValue){
	    			this.select();
	    		}
    		});
    		$('input[type="text"]').blur(function() {
    			$(this).removeClass("focusField").addClass("idleField");
    		    if ($.trim(this.value) == ''){
			    	this.value = (this.defaultValue ? this.defaultValue : '');
				}
    		});
    		
		
//////////Sponsor
		 $('.imgsponsors').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	}); 
	
	$('.slideshow').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});


//////////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())+";path=/;domains=";
		}
		
		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 "";
		}
		
	 
		 
//////////Make me bigger or smaller, I don't care		
		
		// Original Font Size
		var originalFontSize = $('#post').css('font-size');
		if ($.browser.msie) {
			var originalFontSize = parseInt(originalFontSize, 10);
		}
		$("#normal").click(function(){
			$('#post').css('font-size', originalFontSize);
			setCookie('textSize',""+ originalFontSize + "",365);
			return false;
		});
		
		var getSizeCookie = getCookie("textSize");
		if(getSizeCookie!=null && getSizeCookie!=""){
			var getSizeCookieNum = parseInt(getSizeCookie, 10);
			$('#post').css('font-size', getSizeCookieNum);
		};
		
		// Increase Font Size
		$("#big").click(function(){
			var currentFontSize = $('#post').css('font-size');
			var currentFontSizeNum = parseInt(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*1.2;
			$('#post').css('font-size', newFontSize);
			setCookie('textSize',""+ newFontSize + "",365);
			return false;
		});
		// Decrease Font Size
		$("#small").click(function(){
			var currentFontSize = $('#post').css('font-size');
			var currentFontSizeNum = parseInt(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*0.8;
			$('#post').css('font-size', newFontSize);
			setCookie('textSize',""+ newFontSize + "",365);
			return false;
		});
		
		
//////////Print me me me...
		$("#print").click(function(){
			window.print();
		});
		

/////////She's The Form, you have to do what she say...
		/*$(":text").each(function(){
			$(this).addClass("text");
		});
		$(":password").each(function(){
			$(this).addClass("password");
		});
		$(":checkbox").each(function(){
			$(this).addClass("checkbox");
		});
		$(":submit").each(function(){
			$(this).addClass("submit");
		});
		$(":button").each(function(){
			$(this).addClass("submit");
		});
		*/	
			
//////////Put some decoration on my links
		$("a[href$=pdf]").addClass("pdf").attr("target","_blank");
		$("a[href$=xls]").addClass("xls").attr("target","_blank");
		
//////////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 +'');
		});
		
//////////Please help me J.J. Abrams i'm lost...
		if($("#siteMap").length !=0) {
			$("#siteMap").treeview({
				collapsed: false,
				animated: "medium",
				control:"#expandCollapse",
				persist: "location"
			});
		};

//////////Gmap
		if ($('#gmap').length != 0) {
				function initialize() {
					var latlng = new google.maps.LatLng(45.6824688, -73.9261504);
					var myOptions = {
						zoom: 16,
						center: latlng,
						noClear:false,
						mapTypeId: google.maps.MapTypeId.HYBRID,
						    mapTypeControl: true,
						    mapTypeControlOptions: {
						        style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
						        position: google.maps.ControlPosition.TOP_RIGHT
						    },
						navigationControl: true,
						navigationControlOptions: {
					        style: google.maps.NavigationControlStyle.SMALL,
					        position: google.maps.ControlPosition.LEFT
					    }
					};
					var map = new google.maps.Map(document.getElementById("gmap"), myOptions);
					
					var marker = new google.maps.Marker({
						position: latlng, 
						map: map
						
					
					});
				};
				initialize();
		};

			
});	


