
	// --- Date Day & Month Arrays ----
	var longMthArray = new Array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' );
	var shortMthArray = new Array( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec' );
	var longDayArray = new Array( 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' );
	var shortDayArray = new Array( 'Sun', 'Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat' ); 


	jQuery.fn.center = function () {
	    this.css("position","absolute");
	    this.css("top", ( $(window).height() - this.outerHeight() ) / 2+$(window).scrollTop() + "px");
	    this.css("left", ( $(window).width() - this.outerWidth() ) / 2+$(window).scrollLeft() + "px");
	    return this;
	} 
	

$(document).ready(function(){
	
	$.ajaxSetup({
				
		url : "/includes/phpIncs/phpAjax.php", 
		type : 'GET', 
		dataType : 'json' 
		
	}); 
	
	$(document).ajaxError(function(e, xhr, settings, ex){ 
		
		if ( ex ) {
			
			alert("Error: Javascript exception returned: " + ex);
			
		} else {
		
			var errorMsg = 'Unspecified server error returned. (Status #'+xhr.status+') Please try again later.'; 
		
			if ( xhr.status==0 ) errorMsg = 'No connection to the internet can be detected at this time. Try testing your connection first.'; 
			else if ( xhr.status==403 ) errorMsg = 'Requested page is forbidden. Request cannot be completed.'; 
			else if ( xhr.status==404 ) errorMsg = 'Requested page does not exist. Page will need to be replaced.'; 
			else if ( xhr.status==408 ) errorMsg = 'Requested has timed out. Try again later.'; 
			else if ( xhr.status==413 ) errorMsg = 'Request too large. Length of request needs to be shortened.'; 
			
			alert("Error: " + errorMsg); 
			
		}
		
	}); 
	
	$(document).ajaxSuccess(function(e, xhr, settings){ 
		
		if ( !settings.success ) {
		
			jsonObj = (xhr.responseText!="") ? eval("(" + xhr.responseText + ")") : {}; 
			
			if ( typeof(jsonObj)=='object' && typeof(jsonObj.error)!='undefined' && jsonObj.error!="" ) {
				
				alert('Error - Database error has been returned: ' + jsonObj.error + "\n\nYou may need to try again at a later stage."); 
				
			} else { 
			
				
				if ( !document.getElementById('ajaxSuccessBox') ) {
					
					$('<div id="ajaxSuccessBox" />').appendTo('body'); 
					$('div#ajaxSuccessBox').hide(); 
					$('div#ajaxSuccessBox').html('Request completed successfully!'); 
					$('div#ajaxSuccessBox').css({
						"padding" : "10px", 
						"text-align" : "center", 
						"font-style" : "italic", 
						"font-family" : "Verdana, arial, sans-serif", 
						"font-size" : "12pt", 
						"font-weight" : "bold", 
						"border-top" : "4px double black", 
						"border-bottom" : "4px double black", 
						"position" : "absolute", 
						"left" : "0px", 
						"width" : "100%", 
						"background-color" : "white"
					}); 
					
				}
				
				$("div#ajaxSuccessBox").show(); 
				$("div#ajaxSuccessBox").center(); 
				// setTimeout('$("#ajaxSuccessBox").hide(400);', 1500); 
				
			}
		
		}
		
	}); 
	
	/*
	$('<div id="ajaxLoader"></div>').appendTo('body'); 
	$('#ajaxLoader').hide(); 
	$('#ajaxLoader').ajaxStart(function(){ $(this).show(); }); 
	$('#ajaxLoader').ajaxStop(function(){ $(this).hide(); }); 
	*/
	
}); 


function returnTimeFormat ( unformatTime ) {
	
	startT = unformatTime.split(':'); 
	if ( startT[0].charAt(0)=='0' ) startT[0] = startT[0].charAt(1); 
			if ( parseInt(startT[0])>=12 ) {
				if ( parseInt(startT[0])>12 ) 
				startT[0] = parseInt(startT[0]) - 12; 
				
				amPM = ' PM'; 
			} else amPM = ' AM';
			
	return startT[0]+':'+startT[1]+amPM; 
	
}
