$(document).ready(function() {
	// Site Tracking
	$('<img src="https://ct.eid.co.nz/IEBTKCYVSMK,11I1953/sm.gif?eid='+ Math.ceil(10000*Math.random()) +'" alt="" width="1" height="1" border="0" />').appendTo('body');


	$(".print-link").click(function() {
        if (window.print) {
            window.print();
        }
   	});
	$(".btn-email").click(function() {
			// Within the body use "%0A" for a new line,
			// use "%0A%0A" for a new line preceded by a blank line (paragraph),
		var newHref = $(this).attr('href');
		newHref += '&body=I found the following link helpful:%0A%0a' + document.title + ' - ' + document.location.href;
			$(this).attr('href',newHref);
	});
	var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
	if (!badBrowser) {
		// Fix mid column background-image bug in ie 6
		$(".main-content .colmid").css('background','#EEEEEE url(/images/countdown/bg-links-col2.gif) repeat-x bottom right');
	}else{
	}
	function onBefore() { 
		var n = this.id;
		i = n.replace('panel-','');
		$("#navIndicator").css('left',((i-1)*53)-11); 
	};
	 
	var $slide = $('#slidePanels').cycle({ 
		fx:     'fade',
		speed:   1000, 
		timeout: 10000,
		pause:1,
		before:onBefore
	}); 
	
	$("#carousel-menu .navButton").each(function(i) {
		$(this).click(function() {
			$slide.cycle(i); 
			return false; 
		});
	}); 
	
	$(".help-icon").each(function(i) {
		$(this).hover(function() {
			$(".link-help").hide();
			$(this).parent().find(".link-help").show();
		},function() {
			$(".link-help").hide();
		});
	});
	
	try{

		$("a.googlemap").fancybox({
			padding: 0,
			callbackOnStart: function(){$(".fancy_title_storefinder").css("background","transparent url(/images/countdown/fancybox/store_filder_title.png) no-repeat 0 0 scroll");},
		  imageScale: true,
			zoomOpacity: true,
			zoomSpeedIn: 300,
			zoomSpeedOut: 300,
			zoomSpeedChange: 600,
			frameWidth: 918,
			frameHeight: 542,
			overlayShow: true,
			overlayOpacity: 0.8,
			centerOnScroll: false
		});
		
		
		$("a#southspecials").fancybox({
			padding: 0,
		  callbackOnStart: function(){$(".fancy_title_storefinder").css("background","transparent url(/images/countdown/fancybox/south_island_specials.png) no-repeat 0 0 scroll");},
			imageScale: true,
			zoomOpacity: true,
			zoomSpeedIn: 300,
			zoomSpeedOut: 300,
			zoomSpeedChange: 600,
			frameWidth: 918,
			frameHeight: 528,
			overlayShow: true,
			overlayOpacity: 0.8,
			centerOnScroll: false
		});


		$("a#uppernorthspecials").fancybox({
			padding: 0,
		  callbackOnStart: function(){$(".fancy_title_storefinder").css("background","transparent url(/images/countdown/fancybox/uppernorth_island_specials.png) no-repeat 0 0 scroll");},
			imageScale: true,
			zoomOpacity: true,
			zoomSpeedIn: 300,
			zoomSpeedOut: 300,
			zoomSpeedChange: 600,
			frameWidth: 918,
			frameHeight: 528,
			overlayShow: true,
			overlayOpacity: 0.8,
			centerOnScroll: false
		});

		$("a#lowernorthspecials").fancybox({
			padding: 0,
		  callbackOnShow: function(){$(".fancy_title_storefinder").css("background","transparent url(/images/countdown/fancybox/lowernorth_island_specials.png) no-repeat 0 0 scroll");},
			imageScale: true,
			zoomOpacity: true,
			zoomSpeedIn: 300,
			zoomSpeedOut: 300,
			zoomSpeedChange: 600,
			frameWidth: 918,
			frameHeight: 528,
			overlayShow: true,
			overlayOpacity: 0.8,
			centerOnScroll: false
        });
        
        $("a#indulgemagazine").fancybox({
            padding: 0,
            callbackOnShow: function() { $(".fancy_title_storefinder").css("background", "transparent url(/images/countdown/fancybox/indugle_magazine.png) no-repeat 0 0 scroll"); },
            imageScale: true,
            zoomOpacity: true,
            zoomSpeedIn: 300,
            zoomSpeedOut: 300,
            zoomSpeedChange: 600,
            frameWidth: 918,
            frameHeight: 528,
            overlayShow: true,
            overlayOpacity: 0.8,
            centerOnScroll: false
        });
	}catch(err){}
});

