/*
 * GLOBAL DOCUMENT READY
 ***************************************************************/

$(document).ready(function() {

	$("#staging_exit").click(function(e) {
		
		$.ajax({
		
			type: "post",
			url: "includes/inc.ajax.php",
			data: { "action" : "clear_staging" },
			success: function(msg) {
			
				self.location = location.href;
			
			}
		
		});
		
		e.preventDefault();
		
	});
	
	
	if($("#slideshow").length>0) {
		
		var max = $("#slideshow li").length;
		
		var current = 1;
		
		$("#slideshow li:first").fadeIn(1500, function() {
		
			setInterval(function() {
			
				// Fade out current image
				$("#slideshow li:nth-child(" + current + ")").fadeOut(1500);
				
				// Increment, or reset if greater than max
				if(current++ >= max) current = 1;
				$("#slideshow li:nth-child(" + current + ")").fadeIn(1500);
				
			}, 5000);
		
		});
	
	}

		/*
		 * CALENDAR FUNCTIONS
		 ***************************************************************/

		if($("#customer_calendar").length>0) {
			$("#customer_calendar").datepicker({ 
			
				minDate: 0,
				onSelect: function(dateText, inst){
					window.location.href = "/scheduler/" + dateText;
	    			}
									
			});
			$("#customer_calendar .ui-datepicker-inline").show();
			
		
		}

});







