$(document).ready(function() {
						   
	// Preload Images
	jQuery.preloadImages = function()
	{
	for(var i = 0; i<arguments.length; i++)
		{
		jQuery("<img>").attr("src", arguments[i]);
		}
	}
	$.preloadImages("../images/main-alert.jpg");
						   
	
	// Rotate the images inside the #rotate div
	$('#rotate').cycle('fade');
	
	// Apply lightbox plugin to any links with the class of .lightbox
	$('a.lightbox').lightBox();
	
	// Use cycle plugin to rotate office images
	$('#waiting-room-box').cycle({fx:'fade', timeout: 7000, speed: 3000, delay:  -4000});
	
	// Use cycle plugin to control the before and after images
	$('#facelift-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#face-next', 
    	prev:   '#face-previous' 		
	});
	
	$('#nosejob-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#nosejob-next', 
    	prev:   '#nosejob-previous' 		
	});
	
	$('#mentoplasty-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#mentoplasty-next', 
    	prev:   '#mentoplasty-previous' 		
	});
	
	$('#fatgrafting-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#fatgrafting-next', 
    	prev:   '#fatgrafting-previous' 		
	});
	
	$('#otoplasty-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#otoplasty-next', 
    	prev:   '#otoplasty-previous' 		
	});
	
	$('#blepharoplasty-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#blepharoplasty-next', 
    	prev:   '#blepharoplasty-previous' 		
	});
	
	$('#botox-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#botox-next', 
    	prev:   '#botox-previous' 		
	});	
	
	$('#fillers-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#fillers-next', 
    	prev:   '#fillers-previous' 		
	});	
	// End of Cycle Plugin
	
	// AJAX Quick Form Stuff
	$.ajaxSettings.cache = false; 
	
	$('#main-loader').hide();
	$('p.alert').hide();
	
	var options = {
		target: '#main-output',
		url: 'form2mail.php',
		clearForm: true,
		beforeSubmit: function() {
			$('#main-loader').fadeIn(50);
			$('#thank-you').hide();
			},
		success: function() {
			$('#main-loader').fadeOut(300);
			$('p.alert').fadeIn(200).animate({opacity: 1}, 3000).fadeOut(1000);
			$('#thank-you').hide().fadeIn(500);
			}
		} // End of Options	
		
		$('#main-contact').ajaxForm(options); // End of form submit
		
	
});