$(document).ready(function()
	{
	$(function () {

//////////Make me bigger or smaller, I don't care

		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 "";
		}
		
		var getSizeCookie = getCookie("textSize");
		if(getSizeCookie!=null && getSizeCookie!=""){
			var getSizeCookieNum = parseFloat(getSizeCookie, 10);
			$('html').css('font-size', getSizeCookieNum);
		};
		
		// Original Font Size
		var originalFontSize = $('html').css('font-size');
			$("#normal").click(function(){
				$('html').css('font-size', originalFontSize);
				setCookie('textSize',""+ originalFontSize + "",365);
		});
		
		// Increase Font Size
		$("#plus").click(function(){
			var currentFontSize = $('html').css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*1.2;
			$('html').css('font-size', newFontSize);
			setCookie('textSize',""+ newFontSize + "",365);
			return false;
		});
		// Decrease Font Size
		$("#minus").click(function(){
			var currentFontSize = $('html').css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*0.8;
			$('html').css('font-size', newFontSize);
			setCookie('textSize',""+ newFontSize + "",365);
			return false;
		});
		
//////////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(200, 1);
			}, function () {
				$img.stop().fadeTo(300, 0);
			});
		});
			
//////////Print me me me...
		$("#print").click(function(){
			window.print();
		});
		
//////////The last one doesn't get a piece of cake

		$("ul").find("li:last").each(function(){
			$(this).css({"border-right":"none"});
		});

//////////Open sesame
			//initialize
			/*
			var sizeSideBarProduits = $('.sideBarProduits:nth-child(1)').height();
			var sizeOpenMenu = $('#tree').height();
			var state = 'close';
			$('#sidetree').height(0).css("overflow-y", "hidden");
			
			$('#openMenu').click(function(){
				if (state == 'close') {
					$('.sideBarProduits:nth-child(1)').css("height", "auto");
					$('#sidetree').css("height","auto");
					state = 'open';
				}else{
					$('.sideBarProduits:nth-child(1)').height(sizeSideBarProduits).css("overflow-y", "hidden");
					$('#sidetree').height(0).css("overflow-y", "hidden");
					state = 'close';
				};
			});
			*/
			
//////////My treeview	
		/*
		$("#tree").treeview({
			collapsed: true,
			unique: true
		});
		*/
//////////Mon slideshow de logo
			$('#slideshow1').cycle();

//////////When you look at me ... I completely disappear
		$("#top").find("input").each(function(){
			$(this).focus(function () {
				$(this).val("");
			});
		});
		
		/*
		<script language="JavaScript" type="text/javascript" src="/catalogue_tree/catalogue_tree.js"></script>
		<script language="JavaScript" type="text/javascript">
		//Cette fonction va ajouter les tags LI des categorie trouvees et imbriquer les
		//sous-categories avec des tags UL
		//Le contenu sera insere dans le UL portant l'ID tree
		//Ce bloc doit se trouver sous l'id tree afin que celui-ci soit déclaré avant d'etre utilise
		//url du catalogue
		//path de categories si necessaire
		//nombre de niveau a afficher si necessaire
		Get_Catalogue_Tree('http://catalogue.dblectro.com/produits/','','3');
		</script>
		
		
		$.ajaxSetup({ cache: true });
		$.getScript("/catalogue_tree/catalogue_tree.js",
					function ()
					{
						Get_Catalogue_Tree('http://catalogue.dblectro.com/produits/','','3');
					});
		$.ajaxSetup({ cache: false });
		*/
		
	});	
});

