
function changeArea(serverarea)
{
    var thefrom;
    theform = document.sellgold;
	theform.servername.length = 0;
	theform.servername.options[0] = new Option("Choose your Realm (Server)", "");
    for (i=0; i<areaArray[serverarea].length; i++)
    {
		theform.servername.options[theform.servername.length] = new Option(areaArray[serverarea][i][1],areaArray[serverarea][i][0]);
    }
}

function changeprice()
{
	var theform = document.sellgold;
	var server = theform.servername.options[theform.servername.selectedIndex].value;
	var gold=theform.goldnum.options[theform.goldnum.selectedIndex].value;
	theform.server_text.value=theform.servername.options[theform.servername.selectedIndex].text;

	setgoldprice(server,gold);
}

function setgoldprice(server,gold)
{
	var theform = document.sellgold;
	if(theform.servername.selectedIndex!=0){
		price1_1=getPrice(server,gold);
		price2_2=(price1_1/gold).toFixed(4);
		theform.txt_goldprice.value = rate[rate['default']][0]+" "+price2_2+" "+rate['default'].toUpperCase()+"/gold";
		theform.txt_allgoldprice.value=rate[rate['default']][0]+" "+price1_1+" "+rate['default'].toUpperCase();
		if (typeof(theform.currency_amount)!="undefined"){
			var other_amount = "";
			for(var e in rate){
				if(e.toUpperCase() == "DEFAULT" || e.toUpperCase() == rate['default'].toUpperCase())continue;
				other_amount += rate[e][0]+" "+(price1_1/rate[rate['default']][1]*rate[e][1]).toFixed(2)+" "+e.toUpperCase()+"; ";
			}
			if(other_amount!="")other_amount = other_amount.substr(0,other_amount.length-2);
			theform.currency_amount.value = "( "+other_amount+" )";
		}
	
		try{
			theform.txt_goldprice5000.value=getPrice(server,5000);
			theform.txt_goldprice3000.value=getPrice(server,3000);
			theform.txt_goldprice2000.value=getPrice(server,2000);
			theform.txt_goldprice1500.value=getPrice(server,1500);
			theform.txt_goldprice1000.value=getPrice(server,1000);
			theform.txt_goldprice500.value=getPrice(server,500);
		}catch(e){}

	}else{
		theform.txt_goldprice.value = "Choose your realm and faction";
		theform.txt_allgoldprice.value="Choose your realm and faction";
	
		try{
			theform.txt_goldprice5000.value="0.0000";
			theform.txt_goldprice3000.value="0.0000";
			theform.txt_goldprice2000.value="0.0000";
			theform.txt_goldprice1500.value="0.0000";
			theform.txt_goldprice1000.value="0.0000";
			theform.txt_goldprice500.value="0.0000";
		}catch(e){}
	
	}
}

