function rate (name, desc, rate) {
	this.name = name
	this.desc = desc
	this.rate = rate
}


var rates = new Array()
rates["au"] = new rate ("Australia (Dollar)", "Dollars(Aus)", 1)
rates["ca"] = new rate ("Canada (Dollar)", "Dollars(Can)", 0.91)
rates["ch"] = new rate ("China (Yuan)", "Yuan", 5.57)
rates["eu"] = new rate ("Europe (Euro)", "Euros", 0.59)
rates["ja"] = new rate ("Japan (Yen)", "Yen", 79.39)
rates["in"] = new rate ("India (Rupee)", "Rupees", 30.9)
rates["is"] = new rate ("Isreal (Shekel)", "Shekels", 3.01)
rates["nz"] = new rate ("New Zealand (Dollar)", "Dollars(NZ)", 1.06)
rates["sa"] = new rate ("South Africa (Rand)", "Rand", 4.95)
rates["sw"] = new rate ("Switzerland (Franc)", "Francs", 0.92)
rates["uk"] = new rate ("UK (Pound)", "Pounds", 0.41)
rates["us"] = new rate ("USA (Dollar)", "Dollars(US)", 0.80)

function currency (code) {
	this.code = code
}

var currencies = new Array()
currencies["Australia (Dollar)"] = new currency ("au")
currencies["Canada (Dollar)"] = new currency ("ca")
currencies["China (Yuan)"] = new currency ("ch")
currencies["Europe (Euro)"] = new currency ("eu")
currencies["Japan (Yen)"] = new currency ("ja")
currencies["India (Rupee)"] = new currency ("in")
currencies["Isreal (Shekel)"] = new currency ("is")
currencies["New Zealand (Dollar)"] = new currency ("nz")
currencies["South Africa (Rand)"] = new currency ("sa")
currencies["Switzerland (Franc)"] = new currency ("sw")
currencies["UK (Pound)"] = new currency ("uk")
currencies["USA (Dollar)"] = new currency ("us")

function PrintConverter() {
	var def_code = GetPreference ('curr_code')
	document.write ('<form name="form_converter" method="post" action="">')
	document.write ('<select name="list_converter" onchange="UpdateCurrency()">')
		for (var i in rates) {
			document.write ('<option ' + (def_code == i ? " selected " : "") + 'value="' + i + '">' + rates[i].desc +  '</option>')
		}
	document.write ('</select> </form>')
}

function SetCurrency(curr_code, ref) {
	SetPreference ("curr_code", curr_code)
	if (ref == "refresh")
		location.reload()
}

function SetCurrencyDesc(description) {
//alert (description)
//alert (currencies[description].code)
	SetCurrency(currencies[description].code, "")
}


function GetCurrencyRate(code) {
	if (code == "")	 {
		return rates["au"].rate
	}
	
	if (code == "cu") {
		var r = parseFloat(GetPreference("curr_rate"))
		return r * rates["us"].rate
	} else
		return rates[code].rate
}

function GetCurrencyAbrev(code) {
//alert (code)
	if (code == "")	 {
		return rates["au"].desc
	}

	if (code == "cu") {
		return GetPreference("curr_name")
	} else
		return rates[code].desc
}

function GetUsersValue (ausvalue) {
	return (parseInt(ausvalue * GetCurrencyRate(GetPreference('curr_code')), 10))
}

function PrintUsersValue(value) {
	var x = GetPreference('curr_code')
	if (x != 'au') {
		document.write (GetUsersValue(value) + '  ' + GetCurrencyAbrev(x))
	document.write('.')
	} else {
		document.write ('A$' + value)
	}
}

function PrintOrAbout(value) {
	// "or about xx"
	var x = GetPreference('curr_code')
	if (x != "au") {
		document.write (" or about " + GetUsersValue(value) + " " + GetCurrencyAbrev(x))
	}
}

function PrintOrAbout_1(value) {

	var x = GetPreference('curr_code')
	if (x != "au") {
		document.write ("(" + GetUsersValue(value) + " " + GetCurrencyAbrev(x) + ")")
	}
}