//initialize jquery
$(document).ready(function(){
	
	//main gallery images		
	var newsoption1 = {
	firstname: "mynews",
	secondname: "showhere",
	thirdname:"news_display",
	fourthname:"news_button",
	playingtitle:"",
	nexttitle:"",
	prevtitle:"",
	newsspeed:'8000',
	effectis:'0',
	mouseover:false,
	newscountname:"test",
	disablenewscount:false,
	imagedir:'/images/'
	}

	$.init_news(newsoption1);
		
	//setup highlights section
	$("#highlights").wslide({
		width:235,
		height:60,
		horiz:true
	});
	$("#highlights-menu").hide();
	var currentnews = 0;
	var totalitems = $("#highlights-menu > a").length - 1;
	
	function movenews(item)
	{
		if (item == -1)
		{
			currentnews--;		
			if (currentnews < 0)
			{
				currentnews = totalitems;
			}
		
		}
		else
		{
			currentnews++;
			if (currentnews > totalitems)
			{
				currentnews = 0;
			}
		}
		$("#highlights-menu > a:eq(" + currentnews + ")").click();
		
	}
	
	$("#nextnews").click(function(){
		movenews(1);
	});
	
	$("#prevnews").click(function(){
		movenews(-1);
	});
	
	//setup preloading of gallery images	
	$.preloadImages("/new/images/mainpict_red_pour.jpg",
			"/new/images/mainpict_map.jpg",
			"/new/images/mainpict_product_array.jpg",
			"/new/images/mainpict_quality_environmental.jpg",
			"/new/images/mainpict_gaas_class.jpg",
			"/new/images/mainpict_product_selection_guides.jpg"
			);
		
	//fix css issues with ie for caption positioning
	if ( $.browser.msie )
	{
		$("#news_display").css("top", "590px");
		$("#news_display").css("width", "497px");
	}	
		
});

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
	jQuery("<img>").attr("src", arguments[i]);
  }
}