//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

   

   
        var Sys = {};    
        var ua = navigator.userAgent.toLowerCase();    
        var s;    
        (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :    
        (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :    
        (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :    
        (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :    
        (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;    
   

 
    if (Sys.ie){
		if(Sys.ie == '6.0'){
			$("#highlights").wslide({
				width:235,
				height:87,
				horiz:true
			});

		}else if(Sys.ie == '7.0'){
			$("#highlights").wslide({
				width:235,
				height:87,
				horiz:true
			});

		}else{
			$("#highlights").wslide({
				width:235,
				height:87,
				horiz:true
			});
		}

	}else if (Sys.firefox) {

		$("#highlights").wslide({
			width:235,
			height:92,
			horiz:true
		});
	}else{

		$("#highlights").wslide({
			width:235,
			height:78,
			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();
		
	//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]);
  }
}

