var rollOverImageList;
var rollOverTextList;
var currentArea;
var showDefault;
var lastOver;

google.setOnLoadCallback(function() {
	$(document).ready(function(){
		initRoller();
	});
});

function initRoller()
{	
	rollOverImageList = $(".rollOverImageList li");
	rollOverTextList = $(".rollOverTextList");
	
	$("area").mouseover(function(){mouseOverMap(this);});
	$("area").mouseout(function(){mouseOutMap(this);});
	$("area").click(function(){setCurrentArea(this);});
	
	$(rollOverImageList).not("li:first-child").fadeTo(1,0);
	
	$(".rollOverTextList li").hide();
	
	currentArea = 0;
	showFromIndex(currentArea,true);
}

function setCurrentArea(what)
{
	var areaIndex = what.id.split("_")[1];
	
	showTextFromIndex(currentArea, false);
	showTextFromIndex(areaIndex, true);
	
	currentArea = areaIndex;
}

function mouseOverMap(what)
{
	showFromObj(what,true);
	clearTimeout(showDefault);
}

function mouseOutMap(what)
{
	showFromObj(what,false);
	showDefault = setTimeout("showFromIndex(currentArea, true); lastOver=currentArea", 50);
}

function showFromObj(what, show)
{
	var areaIndex = what.id.split("_")[1];
	if (currentArea != areaIndex || lastOver != currentArea)
	{
		showFromIndex(currentArea, false);
		showFromIndex(areaIndex, show);
	
		if (show == true)
		{
			lastOver = areaIndex;
		}
	}
}

function showFromIndex(areaIndex, show)
{
	//if (areaIndex != 0)
	//{
		$(rollOverImageList[areaIndex]).stop();
		if (show == true)
		{
			$(rollOverImageList[areaIndex]).show();
			$(rollOverImageList[areaIndex]).fadeTo(250,1);
			showTextFromIndex(areaIndex, show);
		}
		else
		{
			if (areaIndex != 0)
			{
				$(rollOverImageList[areaIndex]).fadeTo(100,0);
			}
			showTextFromIndex(areaIndex, show);
		}
	//}
}

function showTextFromIndex(areaIndex, show)
{
	areaIndex = parseInt(areaIndex)+1;
	if (show == true)
	{
		$(".rollOverTextList li:nth-child("+areaIndex+")").show();
	}
	else
	{
		$(".rollOverTextList li:nth-child("+areaIndex+")").hide();
	}
}
