// JavaScript Document
//	image0 = new Image();
//	image0.src = "images/bg_html.jpg";

	$(document).ready(function() {
	   
	   
//	   $("a[href*='#']").click(function(){
//			  alert('En construction!');
//			  return false
//		 })
	   
	   
	//  $("#header").append("<div id='animation'><ul id='welcomeBanner'><li><img src='documents/images/animation/pic1home.jpg'></li><li><img src='documents/images/animation/pic2home.jpg'></li><li><img src='documents/images/animation/pic3home.jpg'></li></ul></div>")
	  
//		$('ul#welcomeBanner').innerfade({
//			speed: 1000,
//			timeout: 3000,
//			type: 'random',
//			containerheight: '258px'
//		});
	   
  
	  
	$("ul#cssmw li, ul#deflist3635 li").hoverIntent(function () {
			$(this).addClass("hovering")
			if ( $(this).hasClass("hovering") ){
				$(this).find(".level-1").queue("fx",[]);
				$(this).find(".level-1").slideDown("fast");
			}
		},
		function () {
			 $(this).find(".level-1").slideUp("fast");
			 $(this).removeClass("hovering");
		}
	);
	  
	  
	  
	  
						$("form#reservation").submit(function() {
																 
							 var theForm = $(this) 
							 var theFormID = $(this).attr('id') 
							 var theName = $("#" + theFormID + " input#NOM").val();
							 var theTelephone = $("#" + theFormID + " input#TELEPHONE").val();
							 var theMessage = $("#" + theFormID + " input#MESSAGE").val();
							 var theEmail = $("#" + theFormID + " input#EMAIL").val();
							 var themessage = 'S.v.p verifier le(s) champ(s) suivant: \n'
							 
							 var hasError = false;
		                     var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
							// $("#" + theFormID + " .error").remove(); 
							 $("#" + theFormID + " .error").removeClass('error'); 
							 
							 
							if(theName == '') {
								//$("#" + theFormID + " input#NOM").before('<span class="error">*</span>');
								$("#" + theFormID + " input#NOM").addClass('error');
								
								themessage = themessage + "\n- Votre Nom";
								hasError = true;
							}
							
							if(theTelephone == '') {
								//$("#" + theFormID + " input#NOM").before('<span class="error">*</span>');
								$("#" + theFormID + " input#TELEPHONE").addClass('error');
								
								themessage = themessage + "\n- Votre Telephone";
								hasError = true;
							}
							

							if(theEmail == '') {
								//$("#" + theFormID + " input#EMAIL").before('<span class="error">*</span>');
								$("#" + theFormID + " input#EMAIL").addClass('error');
								themessage = themessage + "\n- Votre Courriel";
								hasError = true;
							} else if(!emailReg.test(theEmail)) {
								//$("#" + theFormID + " input#EMAIL").before('<span class="error">*</span>');
								$("#" + theFormID + " input#EMAIL").addClass('error');
								themessage = themessage + "\n- Votre Courriel";
								hasError = true;
							}
					
							
						  if(hasError == false) {
							  // theForm.submit();
							 	$("form#" + theFormID + " input[type='submit']").before('<img class="spinner" src="http://bin.webloft.ca/images/wait.gif">');
									
								$.ajax({
								  type: "POST",
								  url: 'ajax/clients_request.asp',
								  cache: false,
								  data: $("form#" + theFormID ).serialize(),
								  success: function(msg){
									  
										if(msg.indexOf("error") > 0 ){
											alert(msg);
											return false;
										 } else {  
										   $("form#" + theFormID + " input[type='submit']").before('<span class="good">' + msg + '</span>');
										   $("form#" + theFormID + " input[type='submit']").remove() ;
 										   $("img.spinner").html(msg).remove() ;
									   }
									  
								  }
								});				   
							  
							  
						  }	else {
							  
							  alert(themessage);
							  return false;
						 }						
						   return false;
						 });

	  
	  
	  
	  
	  
	  });

