
/*                    <SCRIPT language=javascript>*/
var forex ={
	computeF : function(){
		var bsv = document.compuforex.bs.value;
		if (isNaN(bsv))
		{
			alert("金额必须为数字.");
			return false;
		}
		document.compuforex.res.value = "正在计算..";

		var x = document.compuforex.c1[document.compuforex.c1.selectedIndex].value;
		var y = document.compuforex.c2[document.compuforex.c2.selectedIndex].value;
		var url = "http://hq.sinajs.cn/list=" + x + "," + y;
		var scriptLoader = new IO.Script();
		scriptLoader.load( url , this.deal.Bind(this , x ,y , bsv) );

	},
	deal : function( x , y , bsv){
		var forex1 = this.dealSpe(x , eval("hq_str_" + x).split(",")[8]);
		var forex2 = this.dealSpe(y , eval("hq_str_" + y).split(",")[8]);
		var result = ( forex2 / forex1 ) * bsv;
		result = result.toFixed(4);
		document.compuforex.res.value = result;
	},

	dealSpe : function(type , val){
		switch(type)
		{
			case 'US':
				return 1;
				break;
			case 'GBP':
			case 'EUR':
			case 'AUD':
				return (1/val).toFixed(4);
				break;
			default :
				return val;
				break;
		}
	}
	
}
/*<!--      </SCRIPT>-->*/
