var p_image = new Image();
p_image.onload = img_load_callback;

// uses global variables sub_sections and section_name
function nav_handler(s)
{
	change_main_image();
	var d = document;
	for (var i = 0; i < sub_sections.length; ++i)
		d.getElementById('sub_nav' + i).src = '../images/' + section_name + '/sub_' + sub_sections[i] + '.gif';

	d.getElementById('sub_nav' + s).src = '../images/' + section_name + '/sub_' + sub_sections[s] + '_on.gif';
	d.getElementById('section_head_tag').src = '../images/' + section_name + '/head_' + sub_sections[s] + '.gif';
	d.getElementById('main_body').src = '../' + section_name + '/' + sub_sections[s] + '.html';
}

function change_main_image(new_src)
{
	if(new_src) document.getElementById('mainimage').src = '../images/who_we_are/' + new_src;
	//else if(section_name) document.getElementById('mainimage').src = '../images/'+section_name+'.jpg';
	else document.getElementById('mainimage').src = '../images/who_we_are_2.jpg';
}

function prop_handler(index)
{
	var s = index.toString(10);
	var first_alpha = s.search(/\D/i);
	var d = document;
	
	if(first_alpha == -1)
	{
		// not a sub image
		d.getElementById('main_body').src = '../our_portfolio/props/' + sub_section + index + '.html';
		d.getElementById('prop_image').src = '../images/our_portfolio/props/' + sub_section + index + '.jpg';
	}
	else
	{
		// is a sub image
		var index_num = s.substr(0,first_alpha);
		d.getElementById('main_body').src = '../our_portfolio/props/' + sub_section + index_num + '.html';
		d.getElementById('prop_image').src = '../images/our_portfolio/props/' + sub_section + index + '.jpg';
		d.getElementById('prop_image').useMap = '#map_' + index_num;
	}
}

function map_handler(index)
{
	var s = index.toString(10);
	var first_alpha = s.search(/\D/i);
	index_num = s.substr(0,first_alpha);
	p_image.src = '../images/our_portfolio/props/' + sub_section + index + '.jpg';
}

function img_load_callback()
{
	var d = document;
	d.getElementById('prop_image').src = p_image.src;
	d.getElementById('prop_image').useMap = '#map_' + index_num;
}


// uses global variables sub_sections and section_name
function preloadImages()
{
	var d = document;
	if (d.images)
	{
		if(!d.MM_p) d.MM_p = new Array();
		var i, j = d.MM_p.length;

		for (i = 0; i < sub_sections.length; i++)
		{
			if (sub_sections[i].indexOf("#") != 0)
			{
				d.MM_p[j] = new Image;
				d.MM_p[j++].src = '../images/' + section_name + '/sub_' + sub_sections[i] + '.gif';

				d.MM_p[j] = new Image;
				d.MM_p[j++].src = '../images/' + section_name + '/sub_' + sub_sections[i] + '_on.gif';

				d.MM_p[j] = new Image;
				d.MM_p[j++].src = '../images/' + section_name + '/head_' + sub_sections[i] + '.gif';
			}
		}
	}
}

