var current_page = 0;
var next_page = 1;
var prev_page = -1;
var page_content = [];
var lead_pages = '';
var play = 'play';

$(document).ready(function()
{
	flash_animation('.lead_unit .lead_right', 'play');
	highlight_menu();
	
	$('.slideshowContainer').cycle({
		fx: 'fade',
		timeout: 6000,
		pause: 1,
		pager:  '#pager'
	});

	$('.columns').columnize({
		lastNeverTallest : true
	});
	
	$("a.blank").attr('target', '_blank');
	
	$(".search_box").each(function()
	{
		document['def_'+$(this).attr('name')] = $(this).attr('value');
		$(this).focus(function()
		{
			if($(this).attr('value') == document['def_'+$(this).attr('name')]) $(this).attr('value','');
		});
		$(this).blur(function()
		{
			if($(this).attr('value') == '') $(this).attr('value',document['def_'+$(this).attr('name')]);
		});
	});
	
	// get hold of  homepage for later
	page_content[0] = $('.lead_body').html();
	
	// if there is more than one page
	if(next_page < lead_pages.length) {
		// preload the next page
		preload_page(next_page, lead_pages[next_page].link);
	} else {
		// remove the right bar
		$('.lead_right').css('opacity',0);
	}
	
	$('.lead_unit .lead_right').click(function(){
		navigation_change(next_page);
	});
	
	$('.lead_unit .lead_left').click(function(){
		navigation_change(prev_page);
	});
	
	reorganise();
	set_pagination();

	// set the output of the type field
	$('#id_recipient').change(function(){
		var t = $(this).find('option:selected').text();
		$('#id_type').attr('value', t);
	});
		
}); /* end $(document).ready() */
