function MM_preloadImages() //v3.0

{

	var d = document;



	if (d.images)

	{

		if (!d.MM_p)

		{

			d.MM_p = new Array();

		}



		var i, j = d.MM_p.length, a = MM_preloadImages.arguments;



		for (i = 0; i < a.length; i++)

		{

			if (a[i].indexOf("#") != 0)

			{

				d.MM_p[j] = new Image;

				d.MM_p[j++].src = a[i];

			}

		}

	}

}



// I re-wrote these as they were pretty convoluted, 

// and didn't need to be - Rob

function restoreImage(divID)

{

	var x = document.getElementById(divID);

	x.src = x.oSrc;

}



function swapImage(divID, imgURI)

{

	var x = document.getElementById(divID);

	x.oSrc = x.src;

	x.src = imgURI;

}



function clickState(stateName)

{

	var image = document.getElementById(stateName);

	var input = document.getElementById('state_' + stateName);

	if (image.style.visibility == 'hidden')

	{

		image.style.visibility = 'visible';

		input.checked = true;

	}

	else

	{

		image.style.visibility = 'hidden';

		input.checked = false;

	}

	return false;

}



// ----------------------------------------function setMapActions

function setMapActions()

{

	var locale = new Array(

		URL_CMSROOT+'images/map/map_WA.png',

		URL_CMSROOT+'images/map/map_SA.png',

		URL_CMSROOT+'images/map/map_NSW.png',

		URL_CMSROOT+'images/map/map_QLD.png',

		URL_CMSROOT+'images/map/map_VIC.png',

		URL_CMSROOT+'images/map/map_NT.png',

		URL_CMSROOT+'images/map/map_TAS.png');



	var state = new Array('WA', 'SA', 'NSW', 'QLD', 'VIC', 'NT', 'TAS');



	var area = document.getElementById('MAPMap').getElementsByTagName('area');

	var check = null, label = null;

	for (var i = 0; i < 7; i++)

	{

		// stick iterator on tag so its accessible inside anonymous function

		area[i].iterator = i;

		

		area[i].onmouseover = function()

		{

			swapImage('MAP', locale[this.iterator]);

		}

		area[i].onmouseout = function()

		{

			restoreImage('MAP');

		}

		area[i].onclick = function()

		{

			return clickState(state[this.iterator]);

		}



		check = document.getElementById('state_'+state[i]);

		check.iterator = i;

		check.onclick = function()

		{

			clickState(state[this.iterator]);

			return true;

		}

	}

}// end function



function setTermsPop()

{

	document.getElementById('termsPop').onclick = function()

	{

		return !window.open(this.href, 'terms', 'scrollbars=yes, resizable=yes, width=430, height=400');

	}

}



function setEvents()

{

	setMapActions();

	setTermsPop();

	MM_preloadImages(

		URL_CMSROOT+'images/map/map_WA.png',

		URL_CMSROOT+'images/map/map_WA_sel.gif',

		URL_CMSROOT+'images/map/map_NT.png',

		URL_CMSROOT+'images/map/map_NT_sel.gif',

		URL_CMSROOT+'images/map/map_QLD.png',

		URL_CMSROOT+'images/map/map_QLD_sel.gif',

		URL_CMSROOT+'images/map/map_NSW.png',

		URL_CMSROOT+'images/map/map_NSW_sel.gif',

		URL_CMSROOT+'images/map/map_VIC.png',

		URL_CMSROOT+'images/map/map_VIC_sel.gif',

		URL_CMSROOT+'images/map/map_TAS.png',

		URL_CMSROOT+'images/map/map_TAS_sel.gif',

		URL_CMSROOT+'images/map/map_SA.png',

		URL_CMSROOT+'images/map/map_SA_sel.gif');
	
	if (document.all)
	{
		if (document.getElementById('MAP'))
		{
			window.onresize = function()
			{
				window.location.reload(false);
			}
		}
	}

}



window.onload = function()

{

	setEvents();

}


