$(document).ready(function(){
	//mainmenu
	$(function () {
			
		if($.browser.msie){
			var img = $("a:not(#logo) img");
		}else{
			var img = $("a img");
		}
		img.hover(function(){
			$(this).animate({ 
	        opacity: 0.8
	      }, 50 );
		},function(){
			$(this).animate({ 
	        opacity: 1
	      }, 50 );
		});

if ($('#body').height() < 800) {
  $('#toTheTop').css('display','none');
};

$('#date_achat').datepicker({dateFormat: 'yy-mm-dd'});


$('.btnOnglet 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(250, 1);
			}, function () {
				$img.stop().fadeTo(250, 0);
			});
		});

///// Scroll Follow
		$( '#catSearch' ).scrollFollow(
							{
								speed: 250,
								offset: 0,
								killSwitch: 'exampleLink',
								onText: 'Disable Follow',
								offText: 'Enable Follow'
							}
						);

	


//// tab 
$("#onglets ul").tabs("#panes > div", {effect: 'fade', fadeOutSpeed: 400});	

		
//////////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
					
	});	
});

$(function() {

	// if the function argument is given to overlay,
	// it is assumed to be the onBeforeLoad event listener
	$("a[rel]").overlay({

		expose: '#2c56a0',
		effect: 'apple',

		onBeforeLoad: function() {

			// grab wrapper element inside content
			var wrap = this.getContent().find(".contentWrap");

			// load the page specified in the trigger
			wrap.load(this.getTrigger().attr("href"));
		}

	});
});

$(function() { 
    $("#apple img[rel]").overlay({
    	expose: '#2c56a0',
		effect: 'apple'    	
	}); 
});
