/*** Site Wide JQuery Scripts ***/
// Note: Months start from 0
var d1 = new Date();
//d1.setFullYear(2011, 3, 3); //daylight savings ends
d1.setFullYear(2012, 3, 1); //daylight savings ends
//d1.setFullYear(2013, 3, 7); //daylight savings ends
//d1.setFullYear(2014, 3, 6); //daylight savings ends


var d2 = new Date();
//d2.setFullYear(2011, 8, 25); //daylight savings starts
d2.setFullYear(2012, 8, 30); //daylight savings starts
//d2.setFullYear(2013, 8, 29); //daylight savings starts
//d2.setFullYear(2014, 8, 28); //daylight savings starts

function checkTime(i){ return (i<10) ? "0"+i : i; }

function start_clock(){
    var today=new Date();
    nztz = ((d1 < today) && (today < d2)) ? 12 : 13;
    today.setMinutes(today.getMinutes() + today.getTimezoneOffset());
    today.setHours(today.getHours() + nztz);
    var h=today.getHours(); var m=today.getMinutes(); var s=today.getSeconds();
    m=checkTime(m); s=checkTime(s);
    document.getElementById('clock').innerHTML=today.toDateString() + ', ' +h+":"+m+":"+s;
    t=setTimeout('start_clock()',1000);
}

$(document).ready (function() {
    //$('#content a:has(img):not(.top)').nyroModal();
    $('#date').css('visibility', 'visible');
    start_clock();
    
    /* Place a site menu in the footer */
    //$('#footer').prepend( $('#menu ul').clone(true) );
    //$('#footer li span, #footer li a').prepend("<").append(">");
    
    /* Needed to correct menu hover issue with IE6 */
    if ((jQuery.browser.msie) && (parseInt(jQuery.browser.version)==6)) {
        $('#menu li').hover(function(){$(this).addClass('over');},function(){$(this).removeClass('over');});
    };
    
    //$("#tabs").css('display','block');
    //$("#tab").tabs();
    //$("body.facilities #content *").addClass("tabbed");
	$("body.facilities #content").tabs("#content div.pane", {tabs: 'h2', effect: 'slide', initialIndex: null});
	$("body.attractions #content").tabs("#content div.pane", {tabs: 'h3', effect: 'slide', initialIndex: null});
	
	
	// if the function argument is given to overlay,
	// it is assumed to be the onBeforeLoad event listener
	$(".images a").overlay({

		mask: 'white',
		effect: 'apple',
		target: '#overlay',
		
		onBeforeLoad: function() {

			// grab wrapper element inside content
			//var wrap = this.getOverlay().find(".contentWrap");

			// load the page specified in the trigger
			//wrap.load(this.getTrigger().attr("href"));
			
			// calclulate large image's URL based on the thumbnail URL (flickr specific)
			var url = this.getTrigger().attr("href");//$(this).attr("src").replace("_t", "");

			// get handle to element that wraps the image and make it semi-transparent
			var wrap = this.getOverlay().find(".contentWrap").fadeTo("medium", 0.5);
			//$("#image_wrap").fadeTo("medium", 0.5);

			// the large image from www.flickr.com
			var img = new Image();

			// call this function after it's loaded
			img.onload = function() {

				// make wrapper fully visible
				wrap.fadeTo("fast", 1);

				// change the image
				wrap.find("img").attr("src", url);

			};

			// begin loading the image from www.flickr.com
			img.src = url;

		},
		
		onClose : function() {
			this.getOverlay().find(".contentWrap").find("img").attr("src", '');
		}

	});

	
});


