$(document).ready(function(){
/* table of contents ------------------------------------------------------------*/

/* 
 	jsEnabled
  	focus
 	footerCarousel
 	ie6StyleSheet
	print friendly button
*/

/* jsEnabled ------------------------------------------------------------*/

	$('body').removeClass('js-disabled').addClass('js-enabled');
	
/* focus ------------------------------------------------------------*/

	$('input').focus(function(){
		$(this).addClass('focus');
	});
	
	$('input').blur(function(){
		$(this).removeClass('focus');
	});
		
/* footerCarousel ------------------------------------------------------------*/	
	
	// if not ie6 
	
	if ( !($.browser.msie && $.browser.version.substr(0, 1) < 7) && ($('.js-enabled').length) && !($('#EditingContents').length)) {
	
		// load jquery.jcarousel plugin
		$.getScript("http://surveyors-mini.clients.squiz.net/__designs/isnsw/jquery.jcarousel.min.js", function(){
			$('#logo-gallery').jcarousel({
				scroll: 1,
				auto: 3,
				wrap: 'circular',
				initCallback: mycarousel_initCallback
			});
			
			function mycarousel_initCallback(carousel){
				
				// Disable autoscrolling if the user clicks the prev or next button.
				carousel.buttonNext.bind('click', function(){
					carousel.startAuto(0);
				});
				
				carousel.buttonPrev.bind('click', function(){
					carousel.startAuto(0);
				});
				
				// Pause autoscrolling if the user moves with the cursor over the clip.
				carousel.clip.hover(function(){
					carousel.stopAuto();
				}, function(){
					carousel.startAuto();
				});
			};
		});
	}

/* ie6StyleSheet ------------------------------------------------------------*/

	if ($.browser.msie && $.browser.version.substr(0, 1) < 7){
		if($('link[href$="stylesheet=1"]').length){
			$('link[href$="stylesheet=1"]').attr('href', 'http://surveyors.org.au/__designs/isnsw/ie6.css');
		}
	}
	
/* print friendly button ----------------------------------------------------*/
	// Initialise print preview plugin
	$('a#link-print-preview').printPreview();
});
