$(document).ready(function() {
						   
	// Preload Images
	jQuery.preloadImages = function()
	{
	for(var i = 0; i<arguments.length; i++)
		{
		jQuery("<img>").attr("src", arguments[i]);
		}
	}
	$.preloadImages("../images/alert.jpg");
	
	// Try to Preload (IE 6)
	var preloadalert = $(' ').attr('src','../images/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', speed: 'slow'});
	
	// 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' 		
	});	
	
	$('#fillers2-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#fillers2-next', 
    	prev:   '#fillers2-previous' 		
	});	
	
	$('#fillers3-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#fillers3-next', 
    	prev:   '#fillers3-previous' 		
	});	
	
	$('#fillers4-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#fillers4-next', 
    	prev:   '#fillers4-previous' 		
	});
	
	$('#fillers5-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#fillers5-next', 
    	prev:   '#fillers5-previous' 		
	});
	
	$('#latisse-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#latisse-next', 
    	prev:   '#latisse-previous' 		
	});	
	
	$('#obagi-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#obagi-next', 
    	prev:   '#obagi-previous' 		
	});		
	
	$('#skincancer-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#skincancer-next', 
    	prev:   '#skincancer-previous' 		
	});
	
	$('#nasal-reconstruction-gallery').cycle({
 		fx:     'fade', 
    	speed:  'fast', 
    	timeout: 0, 
    	next:   '#nasal-reconstruction-next', 
    	prev:   '#nasal-reconstruction-previous' 		
	});
	// End of Cycle Plugin
	
	
	
	// AJAX Form Stuff
	$.ajaxSettings.cache = false; 
	
	$('#loader').hide();
	$('p.alert').hide();
	
	var options = {
		target: '#output',
		url: 'form2mail.php',
		clearForm: true,
		beforeSubmit: function() {
			$('#loader').fadeIn(50);
			$('#thank-you').hide();
			},
		success: function() {
			$('#loader').fadeOut(300);
			$('p.alert').fadeIn(200).animate({opacity: 1}, 3000).fadeOut(1000);
			$('#thank-you').hide().fadeIn(500);
			}
		} // End of Options	
		
		$('#quick-contact').ajaxForm(options); // End of form submit

	
	
});