$(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(150, 1);
			}, function () {
				$img.stop().fadeTo(450, 0);
			});
		});
		$('#printandresize 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);
			});
		});
		$('#btnTop').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(150, 1);
			}, function () {
				$img.stop().fadeTo(150, 0);
			});
		});
		$('#Activis').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(150, 1);
			}, function () {
				$img.stop().fadeTo(150, 0);
			});
		});
		$('.boxbtn').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(150, 1);
			}, function () {
				$img.stop().fadeTo(150, 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 );
		});


		
//////////When you look at me ... I completely disappear
		$("#top").find("input").each(function(){
			$(this).focus(function () {
				$(this).val("");
			});
		});
		
//////////Make me bigger or smaller, I don't care

		function setCookie(value){
			document.cookie = "textSize="+value+"; expires=; path=/";
		}
		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 getActualSize(){
			var actualSizePx = $(".contenuTexteSize").css("font-size");
			var actualSize = actualSizePx.substr(-0,2);
			//alert(actualSize);
		return actualSize;
		
		
		}

		
		getSize = getCookie("textSize");
		if(getSize!=null && getSize!=""){
			$(".contenuTexteSize").css({"font-size":""+getSize+""});
			getActualSize();	
		};

		$("#minus").click(function(){
			showSize = getActualSize();
			parseSize = parseInt(showSize,10);
			var newSize = parseSize - 1;
			$(".contenuTexteSize").css({"font-size":newSize + "px"});
			setCookie(""+ newSize + "px");
			getActualSize();
			//alert(newSize);
			return false;
		});
		$("#plus").click(function(){
			showSize = getActualSize();
			parseSize = parseInt(showSize,10);
			var newSize = parseSize + 1;
			$(".contenuTexteSize").css({"font-size":newSize + "px"});
			setCookie(""+ newSize + "px");
			getActualSize();
			//alert(newSize);
			return false;
		});
		

 if ($('.ulfade').length !=0) {
			$('.ulfade').cycle({
				speed:5000,
				cleartype: 0,
				pause:1
			});
		};
		

						
		
		
//////////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});
		});
		
		
		
//////////Formulaire de contact
		$(".button").click(function() {   
    // validate and process form here   
  		});
		
		$('.errorForm').hide();
	  	$('input.text-input').css({backgroundColor:"#FFFFFF"});
	  	$('input.text-input').focus(function(){
			$(this).css({backgroundColor:"#FFDDAA"});
	  	});
	 	 $('input.text-input').blur(function(){
			$(this).css({backgroundColor:"#FFFFFF"});
	  	});
	
	 	 $(".button").click(function() {
			// validate and process form
			// first hide any error messages
		$('.errorForm').hide();
			
		  var name = $("input#name").val();
			if (name == "" || name == " ") {
		  $("label#name_error").show();
		  $("input#name").focus();
		  return false;
		}
			var phone = $("input#phone").val();
			if (phone == "" || phone == " ") {
		  $("label#phone_error").show();
		  $("input#phone").focus();
		  return false;
			
		}
			var l3irruoc = $("input#l3irruoc").val();
			if (l3irruoc == "" || l3irruoc == " ") {
		  $("label#l3irruoc_error").show();
		  $("input#l3irruoc").focus();
		  return false;
		}
			var message = $("textarea#message").val();
			var typevenement = $("input#typevenement").val();
			var date = $("input#date").val();
			var heure = $("input#heure").val();
			var nbrpersonnes = $("input#nbrpersonnes").val();
			var typemenu = $("input#typemenu").val();
			
			var dataString = 'name='+ encodeURIComponent(name) + '&l3irruoc=' + encodeURIComponent(l3irruoc) + '&phone=' + encodeURIComponent(phone) + '&typevenement=' + encodeURIComponent(typevenement) + '&date=' + encodeURIComponent(date)  + '&heure=' + encodeURIComponent(heure) + '&nbrpersonnes=' + encodeURIComponent(nbrpersonnes) + '&typemenu=' + encodeURIComponent(typemenu) + '&message=' + encodeURIComponent(message);
			//alert (dataString);return false;
			
		$.ajax({
		  type: "POST",
		   /* url: "/bin/process.php", "/bin/process.php?" + dataString, */
		  data: dataString,
		  success: function() {
			$('#contact_form').html("<div id='messageConf'></div>");
			$('#messageConf').html("<h4>Votre message a été envoyé avec succès.</h4>")
			.append("<p class='highLight'>Nous vous contacterons dans les plus brefs délais.</p>")
			.hide()
			.fadeIn(1500, function() {
			  $('#messageConf').append("<img id='checkmark' src='../img/good_32x32.gif' />");
			});
		  }
		 });
		return false;
		}); 


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


