var AmountContentArr = new Array();
AmountContentArr["en"] = new Array(
		{Parent: 5325, Amounts: new Array( 'Maximum of 1000K Kinah', 'Maximum of 5000K Kinah', 'Maximum of 10000K Kinah', 'Maximum of 15000K Kinah', 'Above 15000K Kinah')},
		{Parent: 5326, Amounts: new Array( 'Maximum of 1000K Kinah', 'Maximum of 5000K Kinah', 'Maximum of 10000K Kinah', 'Maximum of 15000K Kinah', 'Above 15000K Kinah')},
		{Parent: 248, Amounts: new Array( 'Maximum of 100 Platinum', 'Maximum of 500 Platinum', 'Maximum of 1000 Platinum', 'Maximum of 1500 Platinum', 'Above 1500 Platinum')},
		{Parent: 2, Amounts: new Array( 'Maximum of 100K Gil', 'Maximum of 500K Gil', 'Maximum of 1000K Gil', 'Maximum of 2000K Gil', 'Maximum of 3000K Gil', 'Maximum of 5000K Gil', 'Above 5000K Gil')},
		{Parent: 3, Amounts: new Array( 'Maximum of 1000M Adena', 'Maximum of 2000M Adena', 'Maximum of 3000M Adena', 'Maximum of 5000M Adena', 'Above 5000M Adena')},
		{Parent: 247, Amounts: new Array( 'Maximum of 5000 gold', 'Maximum of 10000 gold', 'Maximum of 15000 gold', 'Maximum of 20000 gold', 'Above 20000 gold')},
		{Parent: 853, Amounts: new Array(  'Maximum of 5000 gold', 'Maximum of 10000 gold', 'Maximum of 15000 gold', 'Maximum of 20000 gold', 'Above 20000 gold')},
		{Parent: 5423, Amounts: new Array(  'Maximum of 100 thousand energy credits', 'Maximum of 200 thousand energy credits', 'Maximum of 300 thousand energy credits', 'Maximum of 500 thousand energy credits', 'Maximum of 1000 thousand energy credits', 'Above 1000 thousand energy credits')},
		{Parent: 4615, Amounts: new Array(  '100 - 200 Gold', '200 - 400 Gold', '400 - 800 Gold', 'Greater than 800 Gold')},
		{Parent: 5308, Amounts: new Array(  '5M - 10M Kamas', '10M - 20M Kamas', '20M - 40M Kamas', 'Greater than 40M Kamas')},
		{Parent: 4625, Amounts: new Array(  '100 - 200 Gold', '200 - 400 Gold', '400 - 800 Gold', '800 Gold and up')},
		{Parent: 4, Amounts: new Array(  'Maximum of 100 Platinum', 'Maximum of 500 Platinum', 'Maximum of 1000 Platinum', 'Maximum of 1500 Platinum', 'Above 1500 Platinum')},
		{Parent: 80, Amounts: new Array(  '500 - 1000 Million ISK', '1000 - 3000 Million ISK', '3000 - 5000 Million ISK', '5000 - 10000 Million ISK', '10000 Million ISK and up')},
		{Parent: 4375, Amounts: new Array(  '30 - 100 Gold', '100 - 200 Gold', '200 - 500 Gold', '500 - 1000 Gold', '1000 Gold and up')},
		{Parent: 4387, Amounts: new Array(  '30 - 100 Gold', '100 - 200 Gold', '200 - 500 Gold', '500 - 1000 Gold', '1000 Gold and up')},
		{Parent: 5461, Amounts: new Array( 'Maximum of 100K Gil', 'Maximum of 500K Gil', 'Maximum of 1000K Gil', 'Maximum of 2000K Gil', 'Maximum of 3000K Gil', 'Maximum of 5000K Gil', 'Above 5000K Gil')}
		);
AmountContentArr["fr"] = new Array(
		{Parent: 5325, Amounts: new Array( 'Maximum de 1000K Kinah', 'Maximum de 5000K Kinah', 'Maximum de 10000K Kinah', 'Maximum de 15000K Kinah', 'Plus de 15000K Kinah')},
		{Parent: 5326, Amounts: new Array( 'Maximum de 1000K Kinah', 'Maximum de 5000K Kinah', 'Maximum de 10000K Kinah', 'Maximum de 15000K Kinah', 'Plus de 15000K Kinah')},
		{Parent: 248, Amounts: new Array( 'Maximum de 100 Platinum', 'Maximum de 500 Platinum', 'Maximum de 1000 Platinum', 'Maximum de 1500 Platinum', 'Au-delà de 1500 Platinum')},
		{Parent: 2, Amounts: new Array( 'Maximum de 100K Gil', 'Maximum de 500K Gil', 'Maximum de 1000K Gil', 'Maximum de 2000K Gil', 'Maximum de 3000K Gil', 'Maximum de 5000K Gil', 'Au-delà de 5000K Gil')},
		{Parent: 3, Amounts: new Array( 'Maximum de 1000M Adena', 'Maximum de 2000M Adena', 'Maximum de 3000M Adena', 'Maximum de 5000M Adena', 'Au-delà de 5000M Adena')},
		{Parent: 247, Amounts: new Array( 'Maximum de 5000 gold', 'Maximum de 10000 gold', 'Maximum de 15000 gold', 'Maximum de 20000 gold', 'Au-delà de 20000 gold')},
		{Parent: 853, Amounts: new Array(  'Maximum de 5000 gold', 'Maximum de 10000 gold', 'Maximum de 15000 gold', 'Maximum de 20000 gold', 'Au-delà de 20000 gold')},
		{Parent: 5423, Amounts: new Array(  'Maximum of 100 thousand energy credits', 'Maximum of 200 thousand energy credits', 'Maximum of 300 thousand energy credits', 'Maximum of 500 thousand energy credits', 'Maximum of 1000 thousand energy credits', 'Above 1000 thousand energy credits')},
		{Parent: 4615, Amounts: new Array(  '100 - 200 Gold', '200 - 400 Gold', '400 - 800 Gold', 'Greater than 800 Gold')},
		{Parent: 5308, Amounts: new Array(  '5M - 10M Kamas', '10M - 20M Kamas', '20M - 40M Kamas', 'Greater than 40M Kamas')},
		{Parent: 4625, Amounts: new Array(  '100 - 200 Gold', '200 - 400 Gold', '400 - 800 Gold', '800 Gold and up')},
		{Parent: 4, Amounts: new Array(  'Maximum of 100 Platinum', 'Maximum of 500 Platinum', 'Maximum of 1000 Platinum', 'Maximum of 1500 Platinum', 'Above 1500 Platinum')},
		{Parent: 80, Amounts: new Array(  '500 - 1000 Million ISK', '1000 - 3000 Million ISK', '3000 - 5000 Million ISK', '5000 - 10000 Million ISK', '10000 Million ISK and up')},
		{Parent: 4375, Amounts: new Array(  '30 - 100 Gold', '100 - 200 Gold', '200 - 500 Gold', '500 - 1000 Gold', '1000 Gold and up')},
		{Parent: 4387, Amounts: new Array(  '30 - 100 Gold', '100 - 200 Gold', '200 - 500 Gold', '500 - 1000 Gold', '1000 Gold and up')},
		{Parent: 5461, Amounts: new Array( 'Maximum de 100K Gil', 'Maximum de 500K Gil', 'Maximum de 1000K Gil', 'Maximum de 2000K Gil', 'Maximum de 3000K Gil', 'Maximum de 5000K Gil', 'Au-delà de 5000K Gil')}
		);
AmountContentArr["de"] = new Array(
		{Parent: 5325, Amounts: new Array( 'Maximal 1000K Kinah', 'Maximal 5000K Kinah', 'Maximal 10000K Kinah', 'Maximal 15000K Kinah', 'Mehr als 15000K Kinah')},
		{Parent: 5326, Amounts: new Array( 'Maximal 1000K Kinah', 'Maximal 5000K Kinah', 'Maximal 10000K Kinah', 'Maximal 15000K Kinah', 'Mehr als 15000K Kinah')},
		{Parent: 248, Amounts: new Array( 'Maximal 100 Platinum', 'Maximal 500 Platinum', 'Maximal 1000 Platinum', 'Maximal 1500 Platinum', 'Über 1500 Platinum')},
		{Parent: 2, Amounts: new Array( 'Maximal 100K Gil', 'Maximal 500K Gil', 'Maximal 1000K Gil', 'Maximal 2000K Gil', 'Maximal 3000K Gil', 'Maximal 5000K Gil', 'Über 5000K Gil')},
		{Parent: 3, Amounts: new Array( 'Maximal 1000M Adena', 'Maximal 2000M Adena', 'Maximal 3000M Adena', 'Maximal 5000M Adena', 'Über 5000M Adena')},
		{Parent: 247, Amounts: new Array( 'Maximal 5000 gold', 'Maximal 10000 gold', 'Maximal 15000 gold', 'Maximal 20000 gold', 'Über 20000 gold')},
		{Parent: 853, Amounts: new Array(  'Maximal 5000 gold', 'Maximal 10000 gold', 'Maximal 15000 gold', 'Maximal 20000 gold', 'Über 20000 gold')},
		{Parent: 5423, Amounts: new Array(  'Maximum of 100 thousand energy credits', 'Maximum of 200 thousand energy credits', 'Maximum of 300 thousand energy credits', 'Maximum of 500 thousand energy credits', 'Maximum of 1000 thousand energy credits', 'Above 1000 thousand energy credits')},
		{Parent: 4615, Amounts: new Array(  '100 - 200 Gold', '200 - 400 Gold', '400 - 800 Gold', 'Greater than 800 Gold')},
		{Parent: 5308, Amounts: new Array(  '5M - 10M Kamas', '10M - 20M Kamas', '20M - 40M Kamas', 'Greater than 40M Kamas')},
		{Parent: 4625, Amounts: new Array(  '100 - 200 Gold', '200 - 400 Gold', '400 - 800 Gold', '800 Gold and up')},
		{Parent: 4, Amounts: new Array(  'Maximum of 100 Platinum', 'Maximum of 500 Platinum', 'Maximum of 1000 Platinum', 'Maximum of 1500 Platinum', 'Above 1500 Platinum')},
		{Parent: 80, Amounts: new Array(  '500 - 1000 Million ISK', '1000 - 3000 Million ISK', '3000 - 5000 Million ISK', '5000 - 10000 Million ISK', '10000 Million ISK and up')},
		{Parent: 4375, Amounts: new Array(  '30 - 100 Gold', '100 - 200 Gold', '200 - 500 Gold', '500 - 1000 Gold', '1000 Gold and up')},
		{Parent: 4387, Amounts: new Array(  '30 - 100 Gold', '100 - 200 Gold', '200 - 500 Gold', '500 - 1000 Gold', '1000 Gold and up')},
		{Parent: 5461, Amounts: new Array( 'Maximal 100K Gil', 'Maximal 500K Gil', 'Maximal 1000K Gil', 'Maximal 2000K Gil', 'Maximal 3000K Gil', 'Maximal 5000K Gil', 'Über 5000K Gil')}
		);

function ChangeSelectedGame(language)
{
	var amountDropDown, l, option, i;
	var gameId = parseInt(document.getElementById('selectGame').value);
	
	if (gameId == 0)
		return;
				
	if (typeof(AmountContentArr[language]) == 'undefined')
		language = 'en';
	
	var amounts = AmountContentArr[language];
	var enAmounts = AmountContentArr['en'];
	var foundEntries = 0;
	amountDropDown = document.getElementById('selectAmount');
		
	for (key in amounts)
	{			
		if (amounts[key].Parent == gameId)
		{
			foundEntries += 1;			
			l = amounts[key].Amounts.length;
		
			if (l > (amountDropDown.options.length - 1))
			{
				for (i = (amountDropDown.options.length - 1); i < l; i++)
				{
					option = document.createElement("option");
					amountDropDown.options.add(option);
				}
			}
			else
			{
				if (l < (amountDropDown.options.length - 1))
					for (i = (l + 1); i < amountDropDown.options.length; i++)
					{							
						amountDropDown.options[i] = null;								
					}
			}		
			for (i = 1; i < amountDropDown.options.length; i++)
			{
				amountDropDown.options[i].text = amounts[key].Amounts[i - 1];
				amountDropDown.options[i].value = enAmounts[key].Amounts[i - 1];
			}
			
			break;
		}
	}
	
	if (foundEntries == 0)
	{
		amountDropDown.disabled = true;
		amountDropDown.selectedIndex = 0;
	}
	else
	{
		amountDropDown.disabled = false;
		amountDropDown.selectedIndex = 0;
	}
		
	preserveAmount();	
	GetServers(gameId);
}

function SetEmailFocus(defaultEmailText)
{
	var emailObj = document.getElementById('email');
	if (emailObj.value == defaultEmailText)
		emailObj.value = '';
}

function SetIMFocus(defaultIMText)
{
	var IMObj = document.getElementById('imContact');	
	if (IMObj.value == defaultIMText)
		IMObj.value = '';
}

function LoseEmailFocus(defaultEmailText)
{
	var emailObj = document.getElementById('email');
	if (emailObj.value == '')
		emailObj.value = defaultEmailText;
}

function LoseIMFocus(defaultIMText)
{
	var IMObj = document.getElementById('imContact');
	if (IMObj.value == '')
		IMObj.value = defaultIMText;
}

function GetServers(gameId)
{
	gameId = parseInt(gameId, 10);
	var serverSelect = document.getElementById('selectServer');
	for (var i = (serverSelect.options.length - 1); i > 0; i--)
	{				
		if (serverSelect.options[i].value != '0')
		{
			serverSelect.options[i] = null;
		}				
	}
				
	if (gameId > 0)
	{		
		StoreFront.StoreFront.SellCurrency.GetServers(gameId, GetServers_CallBack);	
	}
}

function GetServers_CallBack(response)
{		
	var serverSelect = document.getElementById('selectServer'), optionObj;
	if ((response.error != null) && (response.error.Message != null))
	{				
		var msg = document.getElementById('RequestStatusFailedMessage');
		if (msg != null)
			alert(msg.value);
	}
	else
	{
		if (response.value.length > 0)
		{
			for (var i = 0; i < response.value.length; i++)
			{
				optionObj = new Option(response.value[i].Name, response.value[i].Id);
				
				if ((typeof(selServer) != 'undefined') && (optionObj.text == selServer))
					optionObj.selected = true;
					
				serverSelect.options.add(optionObj);				
			}
		}
	}
	ServerSelectionChanged();
}
function preserveAmount()
{	
	var amountSelect = document.getElementById('selectAmount');
	var i = 0;

	if ((amountSelect != null) && (typeof(selAmount) != 'undefined'))
	{
		for(i = 0; i < amountSelect.options.length; i++)
		{			
			if (amountSelect.options[i].text == selAmount)
			{				
				amountSelect.options[i].selected = true;
				return;
			}
		}
		
		amountSelect.options[0].selected = true;		
	}
}
function ServerSelectionChanged()
{
	var serverSelectObj = document.getElementById('selectServer');	
	document.getElementById('selectedServerName').value = serverSelectObj.options[serverSelectObj.selectedIndex].text;	
}

