// preload images function
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

// preload images
$.preloadImages("btn_go_over.gif","images/info_enews_signup_over.gif","images/teaser_tab_current_last.gif","images/teaser_tab_current.gif","images/teaser_tab_first.gif");

$(function() {

	$("#main_nav > li:has(ul)").children("ul").css({display:"none"}).end().hoverIntent( showMenu, hideMenu );
	$("#main_nav > li").hover( menuOver, menuOut );
								  
	function showMenu(){
		$(this).children("ul").slideDown("normal");
	};
	function hideMenu(){
		$(this).children("ul").css({display:"block"}).slideUp("fast");
	};
	function menuOver(){
		thisColour = $(this).children("a").css("color");
		$(this).children("a").css({"color":"#bbb"});
	};
	function menuOut(){
		$(this).children("a").css({"color":thisColour});
	};

	$('#keywords, .info_box input').focus(function() {
		value=$(this).val();
		$(this).attr("value","");
	});
	$('#keywords, .info_box input').blur(function() {
		if($(this).val()=="") {
			$(this).val(value);
		}
	});
	// submit button hover state
	$('.btn_submit').hover( btnOver, btnOut );
	function btnOver(){
		$(this).css({"background-position":"left bottom"});
	};
	function btnOut(){
		$(this).css({"background-position":"left top"});
	};
	//
	$('.std_select select').selectbox({debug: false});
	
	// search button rollover
	$('#go').hover(
		function(){
			$(this).attr('src','images/btn_go_over.gif');
		},
		function(){
			$(this).attr('src','images/btn_go.gif');
		}
	);
	// signup button rollover
	$('#sign_up').hover(
		function(){
			$(this).attr('src','images/info_enews_signup_over.gif');
		},
		function(){
			$(this).attr('src','images/info_enews_signup.gif');
		}
	);

});