// JavaScript Document
$(function() {
		   	   
	$.preloadCssImages();
	
	/* NEWS PREVIEW STRIP - Setup automatic scroll at 10 seconds */
	$("#news-preview").serialScroll({
		items:'div',
		duration:400, // 0.4 seconds duration to switch
		force:true,
		axis:'y',
		easing:'linear',
		lazy:true,// NOTE: it's set to true, meaning you can add/remove/reorder items and the changes are taken into account.
		interval:10000, // yeah! I now added auto-scrolling
		step:1 // scroll 1 news each time
	});	

		
	/* SEARCH BOX 
	   On submit determine if FPC or WA Govt being searched.  
	   If WA Govt, send search query to WA Govt website (base url within form drop box)
	   Otherwise, Search FPC	*/
	$("#src_gov").css("display","inline");
	$("#search-form").submit(function() {
      if ($("#src_gov").val() == "index.htm") {
        return true; // Continue search via FPC web
      }
      
      // Search is for Government site
      govURL = $("#src_gov").val();
      govSearch = govURL+$("#terms").val();  // Add search terms to government search url
      document.location.href=govSearch;
      return false;
      
    });

	/* Adjust the heights of #features and #forestry-news to be equal */
	function adjustHeights() {		
		hFeatures = $('#features').outerHeight();
		hForestry = $('#forestry-news').outerHeight();
		mHeight = hFeatures > hForestry ? hFeatures : hForestry;
		$('#features, #forestry-news').height(mHeight);
	}
	
	/* On window resize:
	   1) Clear the height settings for #features and #forestry-news.
       2) Call adjustHeights to set height of each */
	$(window).resize(function() {
		$('#features, #forestry-news').css("height","auto");
		adjustHeights();
	});
	
	/* Set heights of #features and #forestry-news the first time */
	adjustHeights(); 
});
