// Villa Mauresque main javascript


$(document).ready(function()
       {
		  
		
		
		//$('#photos').fadeIn('slow');
		
		//$('#room_photos').fadeIn('slow');
		
		/*$('#photos').galleryView({
		panel_width: 620,
		panel_height: 358,
		background_color: 'black',
		frame_width: 100,
		frame_height: 67,
		transition_interval : 3000,
		transition_speed : 1500,
		
 		});*/
				
		/*$('#rooms_photos').galleryView({
		panel_width: 700,
		panel_height: 400,
		background_color: 'transparent',
		frame_width: 120,
		frame_height: 120,
		transition_interval : 3000,
		transition_speed : 1500,



		
 		});*/
		
		 
		//$('#photos').cycle();
		
		$('#photos') 
	.after('<div id="nav">') 
	.cycle({ 
    fx:     'fade', 
    speed:   2000, 
    timeout: 2000, 
    pager:  '#nav' 
	});
	
		$('.date-pick').datePicker();
		 zebraRows('tbody tr:odd td', 'odd');  
		 
 		$('#guest_book_form_container').css('display', 'none');
		
		/*$('fieldset#guest_book_form legend')
 			 .click(function(){
    			$(this).parent().children().filter('h1,h2,h3,h4,p,img,table,ul,div,span, input, textarea, label').toggle('slow');
  			});*/
		
		
		$('fieldset#guest_book_form legend')
 			 .click(function(){
						  $("#guest_book_form_container").fadeToggle('slow')
        }); 	 
							 

		 
		 
		 //post guest book form via ajax
		 
		 $("input#save").click(function() {
      // validate and process form here
	  		//alert ('hello');
	  		var name = $("input#name").val();
			if (name == "") {
    			$("label#name_error").show();
   				$("input#name").focus();
    			return false;
  			}
			
			
			var email = $("input#user_email").val();
			if (email == "") {
    			$("label#email_error").show();
   				$("input#user_email").focus();
    			return false;
  			}
			
			var comment = $("textarea#comment").val();
	  		if (comment == "") {
    			$("label#comment_error").show();
   				$("textarea#comment").focus();
    			return false;
  			}
	  
	  		var dataString = 'submit=submit' + '&name='+ name + '&email=' + email + '&comment=' + comment;
  			//alert (dataString);return false;
 			$.ajax({
    			type: "POST",
    			url: "http://www.hotelsfrench-riviera.com/add_guestbook.php",
    			data: dataString,
    			success: function() {
      				$('#guest_book_form_container').html("<div id='message'></div>");
      				$('#message').html("<h3>Merci pour votre commentaire!</h3>")
      				.append("<p>Nous le publierions d&egrave;s que possible.</p>")
      				.hide()
      				.fadeIn(1500, function() {
        			$('#message').append("<img id='checkmark' src='images/check.png' />");
      		});
    		}
  			});
 		
		return false;
	  
    	});
		 
		 
$('p.email').defuscate();
DD_belatedPNG.fix('.png_fix');		
});



//used to apply alternating row styles
		function zebraRows(selector, className)
		{
  			$(selector).removeClass(className).addClass(className);
		}
		
//fade in / out

		jQuery.fn.fadeToggle = function(speed, easing, callback)
		{
  			 return this.animate({opacity: 'toggle'}, speed, easing, callback);

		}; 