function build_slide_show()
{
	$("#slideshow").cycle({
		fx        : "shuffle",
		next      : "#slide_nav",
		timeout   : 0,
		speed     : 500,
		easing    : "",
		slideExpr : ".slide"
	});
	
	$("#subscribe_submit").hover(
		function () { $(this).attr("src", "/images/footer/subscribe_submit_hover.gif") },
		function () { $(this).attr("src", "/images/footer/subscribe_submit.gif") }
	);
}

function show_contact_form()
{
	$('#current_page_arrow').hide();
	$('#contact_us').addClass('open');
	$('#contact_form').slideDown('fast');
}

$(function ()
{
	$('#products_nav').hover(
		function() { $('#products_submenu_header, #products_submenu').stop(true, true).fadeIn('fast') },
		function() { $('#products_submenu_header, #products_submenu').stop(true, true).fadeOut() }
	);
	
	$('#contact_us').click(function()
	{
		$('#current_page_arrow').toggle();
		$(this).toggleClass('open');
		$('#contact_form').slideToggle('fast');
	});
	
	
	// prevent form being submitted if email address field is blank
	// could be extended so submit button image is a sprite and includes 'disabled' version
	// to indicate status
	$('#footer #subscribe').submit(function()
	{
		var email = $('#footer #subscribe #subscribe_email_address').val();		
		if(email.length < 1)
		{
			return false;			
		}
		else
		{	
			return true;
		}				
	});
	

	
	if (current_menu_page)
	{
		var offset_x;
		
		switch (current_menu_page)
		{
			case 'what_we_do':
				offset_x = 150;
				break;
			
			case 'products':
				offset_x = 252;
				break;
			
			case 'our_work':
				offset_x = 355;
				break;
			
			case 'who_are_we':
				offset_x = 460;
				break;
			
			case 'home':
			default:
				offset_x = 45;
				break;
		}
		
		$('<img />')
			.load(function() {
				$('#top_nav ul.primary').append(this);
				$(this).show();
			})
			.css('left', offset_x)
			.attr('id', 'current_page_arrow')
			.attr('src', '/images/header/arrow.gif')
			;
	}
	
	$('a').filter(function() {
		return this.hostname && this.hostname !== location.hostname;
	})
	.attr('target', '_blank')
	.attr('rel', 'nofollow')
	;
	
	if($('#map').length > 0)
	{
		if (!GBrowserIsCompatible())
		{
			return;
		}			
		var map = new GMap2(document.getElementById("map"));
		var office_loc = new GLatLng(50.955291, -0.129519);
		map.setCenter(office_loc, 13);			
		var marker = new GMarker(office_loc);			
		GEvent.addListener(
			marker,
			"click",
			function()
			{
				marker.openInfoWindowHtml(
					'<img src="/images/who_are_we/cwt_icon.gif" alt="Click with technology" /><p style="margin-top: 1em;">Click with Technology Limited</p>'
					);
				}
			);			
		map.addOverlay(marker);
		map.setUIToDefault();		
	}
});