// JavaScript Document
	image0 = new Image();
	image0.src = "images/bg_outerWrapper.jpg";

	$(document).ready(function() {
	   
	   
//	   $("a#lang, a.lang").click(function(){
//			  alert('Version anglaise en construction!');
//			  return false
//		 })
	   
	  
						$("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;
						 });

	 $("a.viewcart").click(function(){
		 tb_show('Diffusions Amal\'Gamme', 'http://www.webloft.ca/shop/shopNew.asp?siteid=339&lang=&TB_iframe=true&height=400&width=800', '','FERMER')						 
	    })
				   

//				$("#iddetail").change(function() {
//				    strSplit = $("select#iddetail").val().split("|");
//					theID = strSplit[0];
//					theText = strSplit[1];
//					$("h6").html(theText);	
//					$("#boxsize").html('<h2>IDPRODUCT: ' + theID + '</h2>' + '<p>' + theText + '</p>');	
//					return false;
//				 } );
	   
	   
				 $(".add2cart").click(function(){
					 strSplit = $("select#iddetail").val().split("|");
					 theID = strSplit[0];
					 tb_show('Diffusions Amal\'Gamme', 'http://www.webloft.ca/shop/shopNew.asp?siteid=339&idproduit=&iddetail=' + theID + '&lang=&TB_iframe=true&height=400&width=800', '','FERMER')					 
					})
	  
	  });

