(function(document){
	if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) {
		var viewportmeta = document.querySelectorAll('meta[name="viewport"]')[0];
			if (viewportmeta) {
				viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0';
					document.body.addEventListener('gesturestart', function() {
					viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
				}, false);
			}
		}
})(document);

;(function($) {
	$(document).ready(function() {

	$('#navTools ul').prepend('<li><a onkeypress="window.print();return false;" onclick="window.print();return false;" title="Print this page" class="print-preview">Print</a></li><li><a title="High contrast" class="high-contrast">Contrast</a></li>');
		// $('a.print-preview').printPreview();
	
	$('.flexslider').flexslider({
			animation: "slide",
			slideshowSpeed: 8000,
			animationDuration: 100,
			directionNav: false,
			controlsContainer: ".flexslider"
		});
	$('#pubSec').liteAccordion({
			containerWidth : 680,
			containerHeight : 250,
			headerWidth : 40,
			theme : 'basic',
			rounded : false,
			enumerateSlides : false,				
			slideSpeed : 200
	});
	$('#gallery a.lightbox').lightBox({
			overlayBgColor: '#000',
			overlayOpacity: 0.6,         
			imageLoading: 'http://www.dpc.nsw.gov.au/__data/assets/image/0016/131326/lightbox-ico-loading.gif',
			imageBtnClose: 'http://www.dpc.nsw.gov.au/__data/assets/image/0017/131327/lightbox-btn-close.gif',
			imageBtnPrev: 'http://www.dpc.nsw.gov.au/__data/assets/image/0015/131325/lightbox-btn-prev.gif',
			imageBtnNext: 'http://www.dpc.nsw.gov.au/__data/assets/image/0015/131325/lightbox-btn-prev.gif',
			containerResizeSpeed: 150
		});  

	$(function() {
		//check if cookie then do high contrast.
		isCookieSet();
		
		$('a.high-contrast').click(function() {
			if(isCookieSet()){
				$('body').removeClass('highContrast');
				$.cookie('color',null);
			} else {
				$.cookie('color','highContrast', { expires: 7 });
				$('body').addClass('highContrast');
			}
		
			return false;
			});
		
		function isCookieSet(){
			if ($.cookie('color')=='highContrast') {
				$('body').addClass('highContrast');
				return true;
				} else {return false;}
			}
	});
});

})(jQuery);
