// JavaScript Document
$(document).ready(function()
{
	$.cookie('mapclicked',null);
	var defaultimg = 'img/map/australia_map.jpg';
		
	$("#maptabs area").mouseover(function(){
		var mapimg = 'img/map/australia_map-'+$(this).attr('id')+'_over.jpg';
		$('#mainmap').attr('src',mapimg);
//		alert(mapimg);
	
	}).mouseout(function(){
//		alert($.cookie('mapclicked'));
		if ($.cookie('mapclicked') ==  null){
			$('#mainmap').attr('src',defaultimg);		
		}else{
			var mapimg = 'img/map/australia_map-'+$.cookie('mapclicked')+'_over.jpg';
			$('#mainmap').attr('src',mapimg);
		}
    });

	$('#maptabs area').click(function(){
		$.cookie('mapclicked', $(this).attr('id'));
//		alert($(this).attr('id'));
		var mapimg = 'img/map/australia_map-'+$(this).attr('id')+'_over.jpg';
//		alert(mapimg);
//		$(this).mouseout().attr('src',mapimg);
		$('#mainmap').attr('src',mapimg);
	});
	
	$('#msublist a').click(function(){
		$.cookie('mapclicked',null);
		$('#mainmap').attr('src',defaultimg);		
	});	

});

function newImage(arg) {
		if (document.images) {
			rslt = new Image();
			rslt.src = arg;
			return rslt;
		}
	}
	var preloadFlag = false;
	function preloadImages() {
		if (document.images) {
			australia_map_tas_over = newImage("australia_map-tas_over.jpg");
			australia_map_sa_over = newImage("australia_map-sa_over.jpg");
			australia_map_wa_over = newImage("australia_map-wa_over.jpg");
			australia_map_nsw_over = newImage("australia_map-nsw_over.jpg");
			australia_map_nt_over = newImage("australia_map-nt_over.jpg");
			australia_map_vic_over = newImage("australia_map-vic_over.jpg");
			australia_map_qld_over = newImage("australia_map-qld_over.jpg");
			preloadFlag = true;
		}
	}
	preloadImages();
	function changeImages() {
		if (document.images && (preloadFlag == true)) {
			for (var i=0; i<changeImages.arguments.length; i+=2) {
				document[changeImages.arguments[i]].src = "img/map/" + changeImages.arguments[i+1];
			}
		}
	}
$(document).ready(function(){
$('#maptabs div').hide(); // Hide all divs
$('#maptabs div:first').show(); // Show the first div
$('#maptabs ul li:first').addClass('active'); // Set the class of the first link to active
$('#maptabs ul#msublist a,area').click(function(){ //When any link is clicked
//$('#tabs ul li').removeClass('active'); // Remove active class from all links
$(this).parent().addClass('active'); //Set clicked link class to active
var currentTab = $(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
$('#maptabs div').hide(); // Hide all divs
$(currentTab).show(); // Show div with id equal to variable currentTab
return false;
});
});
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

