var Creation_Month = 5;
var Creation_Year = 2009;
var Region = "World";
var Option = "All";
var NavigationMemory = new Array();
var NavigationMemory_Count = 1;
var NavigationMemory_Index = 0;
var Max_NavigationMemory_Index = 50;

NavigationMemory[0] = "World#All";

//Change the image
function ChangeImage(Rgn, Opn)
{
	var Change = false;

	if(Rgn != "Keep" && Rgn != Region)
	{
		Change = true;
		Region = Rgn;
	} //if

	if(Opn != "Keep" && Opn != Option)
	{
		Change = true;
		Option = Opn;
	} //if

	if(Change == true) {
		if(NavigationMemory_Count == Max_NavigationMemory_Index)
		{
			if(NavigationMemory_Index < Max_NavigationMemory_Index / 2)
			{
				for(Index = NavigationMemory_Index + 1; Index < NavigationMemory_Count - 1; Index++)
				{
					NavigationMemory[Index + 1] = NavigationMemory[Index];
				} //for				
			} //if
			else 
			{
				for(Index = 0; Index < NavigationMemory_Index; Index++)
				{
					NavigationMemory[Index] = NavigationMemory[Index + 1];
				} //for				
			} //if
			NavigationMemory[NavigationMemory_Index] = Region + "#" + Option;
		} //if
		else
		{
			if(NavigationMemory_Index < NavigationMemory_Count - 1)
			{
				for(Index = NavigationMemory_Index + 1; Index < NavigationMemory_Count; Index++)
				{
					NavigationMemory[Index + 1] = NavigationMemory[Index];
				} //for				
			} //if
			NavigationMemory[++NavigationMemory_Index] = Region + "#" + Option;
			NavigationMemory_Count++;
		} //else

		Ajax_ShowSelection();
		Ajax_ShowMap();
	} //if
} //ChangeImage

//Show ToolTip
function ShowToolTip(Rgn)
{
	if(Region != "World") return;
	Tip(Rgn);
} //ShowToolTip

//Hide ToolTip
function HideToolTip()
{
	//if(Region != "World") return;
	UnTip();
} //HideToolTip


//Previous or Next: PrevNext = false for previous and true for Next
function Change_PrevNext(PrevNext)
{
	var Change = false;

	if(PrevNext == true)
	{
		if(NavigationMemory_Index == NavigationMemory_Count - 1) return;
		NavigationMemory_Index++;		
	} //if
	else
	{
		if(NavigationMemory_Index == 0) return;
		NavigationMemory_Index--;
	} //else

	var RegionOption = NavigationMemory[NavigationMemory_Index].split('#');
	Region = RegionOption[0];
	Option = RegionOption[1];	
	Ajax_ShowSelection();
	Ajax_ShowMap();
} //ChangeImage

//Show map
function Ajax_ShowMap()
{
	var Return_Str = "<TABLE><TR><TD><A HREF=\"javascript:Change_PrevNext(false)\"><IMG SRC=\"Buttons/Prev_Button.png\" BORDER=0px STYLE=\"visibility:" + ((NavigationMemory_Index == 0) ? "hidden" : "visible") + ";\"></A></TD><TD>"+
			 "<IMG SRC=\"" + Option + "/" + Region + "Map.png\" ALT=\"World map\" BORDER=0 WIDTH=1024 HEIGHT=512" +
			 ((Region == "World") ? " USEMAP=\"#map\"></TD>" : "></TD>") +
			 "<TD><A HREF=\"javascript:Change_PrevNext(true)\"><IMG SRC=\"Buttons/Next_Button.png\" BORDER=0px STYLE=\"visibility:" + ((NavigationMemory_Index == NavigationMemory_Count - 1) ? "hidden" : "visible") + ";\"></A></TD></TR></TABLE>";

	document.getElementById('ShowMap').innerHTML = Return_Str;
} //Ajax_ShowMap

//Show Title
function Ajax_ShowSelection()
{	
	var OptionStr = "Malware in ";

	switch(Option)
	{
		case "CW": OptionStr += "Current Week"; break;
		case "PW": OptionStr += "Previous Week"; break;
		case "CM": OptionStr += Get_Month_Name(Creation_Month); break;
		case "PM": OptionStr += Get_Month_Name(Creation_Month == 1 ? 12 : Creation_Month - 1); break;
		case "CY": OptionStr += Creation_Year; break;
		case "PY": OptionStr += Creation_Year - 1; break;
		default  : OptionStr = "All Malware";
	} //switch

	document.getElementById('RegionOptionSelected').innerHTML = Region + " Map (" + OptionStr + ")";
} //Ajax_ShowSelection

//Get Month's Name
function Get_Month_Name(Month)
{
	switch(Month) {
	       case 1: Str = "January"; break;
	       case 2: Str = "February"; break;
	       case 3: Str = "March"; break;
	       case 4: Str = "April"; break;
	       case 5: Str = "May"; break;
	       case 6: Str = "June"; break;
	       case 7: Str = "July"; break;
	       case 8: Str = "August"; break;
	       case 9: Str = "September"; break;
	       case 10: Str = "October"; break;
	       case 11: Str = "November"; break;
	       case 12: Str = "December"; break;
	       default: Str = "Unknownmonth"
       } //switch
       return Str;
} //Get_Month_Name