


$(document).ready(function()
{
	initNavigation();
	initCufon();
	
	
	
	
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
    // alert( $.browser.version );
   } else { $.backstretch("images/" + myBgImage[randomnumber]); }

	
    $(".sidebar-img-area img").attr("src","images/left/" + myLeftImage[randomnumber2]);
    $('.sidebar-img-area-ico').css("background-image","url(images/left/" + myIco[randomnumber3] +")");  
	
	if (randomnumber3 == 0){$('.sidebar-img-area ').css("margin-top",50);};
   
   // $('#cssmw li a').eq(5).addClass("link-pdf").attr("href", "documents/fichiers/Inscription.pdf").attr('target', '_blank');
    $('#cssmw li a').eq(5).addClass("link-pdf") ;

	
	
						$("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;
						 });
	
	
});
function initCufon() {
	Cufon.replace('#cssmw a', { fontFamily: "Dax", hover: true });
	Cufon.replace('.btns-area a', { fontFamily: "Dax", hover: true });
	Cufon.replace('.contact-new a', { fontFamily: "Dax", hover: true });
}
function initNavigation()
{
	$('.navigation li').hover(function()
	{
		$(this).addClass('hover');
	},
	function()
	{
		$(this).removeClass('hover');
		setTimeout(function(){Cufon.refresh('ul.navigation > li > a')}, 10);
	});
}


// full background random image
var randomnumber = Math.floor(Math.random()*7)
var myBgImage = new Array();
    myBgImage[0]="bg-body1.jpg"; 
    myBgImage[1]="bg-body2.jpg";
    myBgImage[2]="bg-body3.jpg";
    myBgImage[3]="bg-body4.jpg";
    myBgImage[4]="bg-body5.jpg";
    myBgImage[5]="bg-body6.jpg";
    myBgImage[6]="bg-body7.jpg";
// left column random image
var randomnumber2 = Math.floor(Math.random()*3)
var myLeftImage = new Array();
    myLeftImage[0]="imgLeft00.jpg"; 
    myLeftImage[1]="imgLeft02.jpg";
    myLeftImage[2]="imgLeft03.jpg";
// left ICO random image
var randomnumber3 = Math.floor(Math.random()*3)
var myIco = new Array();
    myIco[0]="ico01.png"; 
    myIco[1]="ico02.png";
    myIco[2]="ico03.png";
  
  

