var rate;
function toOther(f) {
	
	
	
var first = document.getElementById('first');
var second = document.getElementById('second');
var three = document.getElementById('three');
var currency = document.getElementById('currency');
var result = document.getElementById('res');

if(first.checked) {

  rate = first.value;
 
}
if(second.checked) {

  rate = second.value;
 
}
if(three.checked) {

  rate = three.value;
 
}



if(!rate) { alert("Please select a currency"); return; }



s=Math.round(currency.value * rate * 100) / 100;
result.value=format(s);
//a=format(s1);
//alert(a);
//result.value=a;
}
function format(str) {
	var str1=new String(str);
var index = str1.indexOf(".");

if (index < 0) str1 = str1 + ".00";
else {
str1 = str1.substring(0, index + 3);
if (str1.length < (index + 3)) str1 += "0";
}
return str1;
}