$(document).ready(function(){
	
	$(".buttonContainer").addClass('js');

	$(".buttonContainer a").hover(function()
		{
			var $buttonElements = $(this).closest(".buttonContainer").children();			
			jQuery.each($buttonElements, function() {
				if($.browser.msie)
				{
					$(this).css("background-position-y","-28px");
				}
				else
				{
					var position = $(this).css("background-position").replace("px 0px","px -28px");
					$(this).css("background-position",position);
				}
			});
		},
		function()
		{
			var $buttonElements = $(this).closest(".buttonContainer").children();			
			jQuery.each($buttonElements, function() {
				if($.browser.msie)
				{
					$(this).css("background-position-y","0px");
				}
				else
				{
					var position = $(this).css("background-position").replace("px -28px","px 0px");
					$(this).css("background-position",position);
				}
			});
		}
	);
	
	$(".buttonContainer a").focus(function()
		{
			var $buttonElements = $(this).closest(".buttonContainer").children();			
			jQuery.each($buttonElements, function() {
				if($.browser.msie)
				{
					$(this).css("background-position-y","-56px");
				}
				else
				{
					var position = $(this).css("background-position").replace("px -28px","px -56px");
					$(this).css("background-position",position);
				}
			});
		}
	);
	
	$(".buttonContainer a").blur(function()
		{
			var $buttonElements = $(this).closest(".buttonContainer").children();			
			jQuery.each($buttonElements, function() {
				if($.browser.msie)
				{
					$(this).css("background-position-y","0px");
				}
				else
				{
					var position = $(this).css("background-position").replace("px -56px","px 0px");
					$(this).css("background-position",position);
				}
			});
		}
	);
	
	$(".buttonContainer a").click(function()
		{
			var $buttonElements = $(this).closest(".buttonContainer").children();			
			jQuery.each($buttonElements, function() {
				if($.browser.msie)
				{
					$(this).css("background-position-y","-56px");
				}
				else
				{
					var position = $(this).css("background-position").replace("px -28px","px -56px");
					$(this).css("background-position",position);
				}
			});
		}
	);

	$('#Local').click(function()
	{
		//$('#q').removeClass('fullSearchBar').addClass('halfSearchBarLeft').attr('value','What for');
		//$('#near').removeClass('access').addClass('halfSearchBar').attr('value','Where');
		$('#q').removeClass('fullSearchBar').addClass('halfSearchBarLeft');
		$('#near').removeClass('access').addClass('halfSearchBar');
	});
	
	$('#Web, #UK').click(function()
	{
		//$('#q').addClass('fullSearchBar').removeClass('halfSearchBarLeft').attr('value','');
		//$('#near').addClass('access').removeClass('halfSearchBar').attr('value','');
		$('#q').addClass('fullSearchBar').removeClass('halfSearchBarLeft');
		$('#near').addClass('access').removeClass('halfSearchBar');
	});
	
	$('.promptText').focus(function()
	{
		if( ($(this).val()) == ($(this).attr("title")))
		{
			$(this).css("color","#555555");
			$(this).attr('value','');
		}
	});
	$('.promptText').blur(function()
	{
		if( ($(this).attr('value'))=='')
		{
			$(this).css("color","#cccccc");
			$(this).attr('value',$(this).attr("title"));
		}
	});
	
	
	/*$('#q').focus(function()
	{
		if( ($(this).attr('value'))=='What for')
		{
			$(this).css("color","#555555");
			$(this).attr('value','');
		}
	});
	$('#q').blur(function()
	{
		if( ($(this).attr('value'))=='')
		{
			$(this).css("color","#cccccc");
			$(this).attr('value','What for');
		}
	});
	$('#near').focus(function()
	{
		if( ($(this).attr('value'))=='Where')
		{
			$(this).css("color","#555555");
			$(this).attr('value','');
		}
	});
	$('#near').blur(function()
	{
		if( ($(this).attr('value'))=='')
		{
			$(this).css("color","#cccccc");
			$(this).attr('value','Where');
		}
	});*/
	
	$(".bigbuttonContainer").addClass('js');

	$(".bigbuttonContainer a").hover(function()
		{
			var $buttonElements = $(this).closest(".bigbuttonContainer").children();			
			jQuery.each($buttonElements, function() {
				if($.browser.msie)
				{
					$(this).css("background-position-y","-50px");
				}
				else
				{
					var position = $(this).css("background-position").replace("px 0px","px -50px");
					$(this).css("background-position",position);
				}
			});
		},
		function()
		{
			var $buttonElements = $(this).closest(".bigbuttonContainer").children();			
			jQuery.each($buttonElements, function() {
				if($.browser.msie)
				{
					$(this).css("background-position-y","0px");
				}
				else
				{
					var position = $(this).css("background-position").replace("px -50px","px 0px");
					$(this).css("background-position",position);
				}
			});
		}
	);
	
	$(".bigbuttonContainer a").focus(function()
		{
			var $buttonElements = $(this).closest(".bigbuttonContainer").children();			
			jQuery.each($buttonElements, function() {
				if($.browser.msie)
				{
					$(this).css("background-position-y","-100px");
				}
				else
				{
					var position = $(this).css("background-position").replace("px -50px","px -100px");
					$(this).css("background-position",position);
				}
			});
		}
	);
	
	$(".bigbuttonContainer a").blur(function()
		{
			var $buttonElements = $(this).closest(".bigbuttonContainer").children();			
			jQuery.each($buttonElements, function() {
				if($.browser.msie)
				{
					$(this).css("background-position-y","0px");
				}
				else
				{
					var position = $(this).css("background-position").replace("px -100px","px 0px");
					$(this).css("background-position",position);
				}
			});
		}
	);
	
	$(".bigbuttonContainer a").click(function()
		{
			var $buttonElements = $(this).closest(".bigbuttonContainer").children();			
			jQuery.each($buttonElements, function() {
				if($.browser.msie)
				{
					$(this).css("background-position-y","-100px");
				}
				else
				{
					var position = $(this).css("background-position").replace("px -50px","px -100px");
					$(this).css("background-position",position);
				}
			});
		}
	);
	
	$("input.rollover").hover(
		function(){
			var $imageName = $(this).attr("src");
			$(this).attr("src",$imageName.replace(".jpg","_roll.jpg"));
		},
		function(){
			var $imageName = $(this).attr("src");
			$(this).attr("src",$imageName.replace("_roll",""));
		}
	);
	$("input.rollover").focus(
		function(){
			var $imageName = $(this).attr("src");
			$imageName = $imageName.replace("_roll","");
			$(this).attr("src",$imageName.replace(".jpg","_click.jpg"));
		}
	);
	// for Safari only
	$("input.rollover").click(
		function(){
			var $imageName = $(this).attr("src");
			$imageName = $imageName.replace("_roll","");
			$(this).attr("src",$imageName.replace(".jpg","_click.jpg"));
		}
	);
	$("input.rollover").blur(
		function(){
			var $imageName = $(this).attr("src");
			$(this).attr("src",$imageName.replace("_click",""));
		}
	);

	
	
	
	
	
});
