

<!--
function putcomma(aString)
{
decinput=" ";
var  aStr = "";
var  aLength = aString.length;
if (aString.indexOf(".") != -1) //to take out string after decimal point
{
aLength=aString.substring(0,aString.indexOf(".")).length;//length before decimal point
decinput=aString.substring(aLength,aString.length);
}
 	for (var i = aLength ; i > 0 ; i--) // to read reversely
	{
	aStr += aString.charAt(i-1);	
	}
	theAString=aStr;
 
 
 var  bStr = "";
 var  bLength = theAString.length;
 var count=1;
	 for (var j = 0 ; j < bLength ; j++)
	 {
	 if(count%3==0)
	  {
		bStr += theAString.charAt(j)+",";
	  }
	 else if (count%3!=0)
	  {
	  	bStr += theAString.charAt(j);
	  }
	  	count++;
	  }
 theBString=bStr;

	
var cStr = "";
var cLength=theBString.length;
	for (var i = cLength ; i > 0 ; i--)
	{
		cStr += theBString.charAt(i-1);	
	}
 	if(cStr.charAt(0)==",")
 	{
 		theCString=cStr.replace(",","");
		return theCString+decinput;
	}
	else
	{
		return cStr+decinput;
	}
 }
 
function result()
{

var Request = new Displaypage();  //to use the parameter from url
		  with(document)
amount= Request.Displaypage('amount');
from= Request.Displaypage('from');
to= Request.Displaypage('to');
service= Request.Displaypage('service');

if(from==" ")  //to set default value
{
from="Malaysian Ringgit";
}
if(to==" ")  //to set default value
{
to="Malaysian Ringgit";
}

var toabbr;
var fromabbr;

	switch (from)
	{
	case 'Malaysian Ringgit' : fromarr="Malaysian Ringgit"; fromabbr="MYR"; break;
 	case 'US Dollar' : fromarr=usd; fromabbr="USD"; break;
	case 'Australian Dollar' : fromarr=aust; fromabbr="AUD"; break;
	case 'Brunei Dollar' : fromarr=bru; fromabbr="BND"; break;
	case 'Canadian Dollar' : fromarr=can ; fromabbr="CAD"; break;
	case 'Euro' : fromarr=euro; fromabbr="EUR"; break;
	case 'New Zealand Dollar' : fromarr=nz; fromabbr="NZD";  break;
	case 'Papua N Guinea Kina' : fromarr=pap; fromabbr="PGK"; break;
	case 'Singapore Dollar' : fromarr=sing; fromabbr="SGD"; break;
	case 'Sterling Pound' : fromarr=ster; fromabbr="GBP"; break;
	case 'Swiss Franc' : fromarr=sws; fromabbr="CHF"; break;
	case 'Arab Emirates Dirham' : fromarr=uae; fromabbr="AED"; break;
	case 'Bangladesh Taka' : fromarr=bang; fromabbr="BDT"; break;
	case 'Chinese Renminbi' : fromarr=chi; fromabbr="CNY"; break;
	case 'Danish Krone' : fromarr=dan; fromabbr="DKK"; break;
	case 'Hongkong Dollar' : fromarr=hk; fromabbr="HKD"; break;
	case 'Indian Rupee' : fromarr=ind; fromabbr="INR"; break;
	case 'Indonesian Rupiah' : fromarr=indo; fromabbr="IDR"; break;
	case 'Japanese Yen' : fromarr=jpn; fromabbr="JPY"; break;
	case 'New Taiwan Dollar' : fromarr=twn; fromabbr="TWD"; break;
	case 'Norwegian Krone' : fromarr=norw; fromabbr="NOK"; break;
	case 'Pakistan Rupee' : fromarr=pkt; fromabbr="PKR"; break;
	case 'Philippine Peso' : fromarr=phl; fromabbr="PHP"; break;
	case 'Qatar Riyal' : fromarr=qtr; fromabbr="QAR"; break;
	case 'Saudi Riyal' : fromarr=saud; fromabbr="SAR"; break;
	case 'South African Rand' : fromarr=afr; fromabbr="ZAR";  break;
	case 'Sri Lanka Rupee' : fromarr=sril; fromabbr="LKR"; break;
	case 'Swedish Krona' : fromarr=swed; fromabbr="SEK"; break;
	case 'Thai Baht' : fromarr=thai; fromabbr="THB"; break;
	default : fromarr = "Malaysian Ringgit"; fromabbr="MYR";
	}

	switch (to)
	{
	case 'Malaysian Ringgit' : toarr="Malaysian Ringgit"; toabbr="MYR"; break;
 	case 'US Dollar' : toarr=usd; toabbr="USD"; break;
	case 'Australian Dollar' : toarr=aust; toabbr="AUD"; break;
	case 'Brunei Dollar' : toarr=bru; toabbr="BND"; break;
	case 'Canadian Dollar' : toarr=can ; toabbr="CAD"; break;
	case 'Euro' : toarr=euro; toabbr="EUR"; break;
	case 'New Zealand Dollar' : toarr=nz; toabbr="NZD";  break;
	case 'Papua N Guinea Kina' : toarr=pap; toabbr="PGK"; break;
	case 'Singapore Dollar' : toarr=sing; toabbr="SGD"; break;
	case 'Sterling Pound' : toarr=ster; toabbr="GBP"; break;
	case 'Swiss Franc' : toarr=sws; toabbr="CHF"; break;
	case 'Arab Emirates Dirham' : toarr=uae; toabbr="AED"; break;
	case 'Bangladesh Taka' : toarr=bang; toabbr="BDT"; break;
	case 'Chinese Renminbi' : toarr=chi; toabbr="CNY"; break;
	case 'Danish Krone' : toarr=dan; toabbr="DKK"; break;
	case 'Hongkong Dollar' : toarr=hk; toabbr="HD"; break;
	case 'Indian Rupee' : toarr=ind; toabbr="INR"; break;
	case 'Indonesian Rupiah' : toarr=indo; toabbr="IDR"; break;
	case 'Japanese Yen' : toarr=jpn; toabbr="JPY"; break;
	case 'New Taiwan Dollar' : toarr=twn; toabbr="TWD"; break;
	case 'Norwegian Krone' : toarr=norw; toabbr="NOK"; break;
	case 'Pakistan Rupee' : toarr=pkt; toabbr="PKR"; break;
	case 'Philippine Peso' : toarr=phl; toabbr="PHP"; break;
	case 'Qatar Riyal' : toarr=qtr; toabbr="QAR"; break;
	case 'Saudi Riyal' : toarr=saud; toabbr="SAR"; break;
	case 'South African Rand' : toarr=afr; toabbr="ZAR";  break;
	case 'Sri Lanka Rupee' : toarr=sril; toabbr="LKR"; break;
	case 'Swedish Krona' : toarr=swed; toabbr="SEK"; break;
	case 'Thai Baht' : toarr=thai; toabbr="THB"; break;
	default : toarr = "Malaysian Ringgit"; toabbr="MYR";
	}

var servicetype=5;
	if (from == "Malaysian Ringgit" && service == "Telegraphic Transfer")
	{
	servicetype=0;
	}
	if (from == "Malaysian Ringgit" && service == "Currency Notes")
	{
	servicetype=3;
	}
	if (to == "Malaysian Ringgit" && service == "Telegraphic Transfer")
	{
	servicetype=1;
	}
	if (to == "Malaysian Ringgit" && service == "Currency Notes")
	{
	servicetype=4;
	}
	if (to == "Malaysian Ringgit" && service == "On Demand")
	{
	servicetype=2;
	}


if (servicetype != 5)
{
	
/*
     if (document.layers)
		window.resizeTo(420,436);
	else
		window.resizeTo(432,485);
*/
fromrate=fromarr.split("|");
torate=toarr.split("|");

fromval=fromrate[servicetype]; //to extract value according to selected service
toval=torate[servicetype]; //to extract value according to selected service

//to get value for one unit instead of 100 for belowmention currencies

if (from == "Arab Emirates Dirham" || from == "Bangladesh Taka" || from == "Chinese Renminbi" || from == "Danish Krone"|| from == "Hongkong Dollar" || from == "Indian Rupee" || from == "Indonesian Rupiah" || from == "Japanese Yen" || from == "New Taiwan Dollar" || from == "Norwegian Krone" || from == "Pakistan Rupee" || from == "Philippine Peso" || from == "Qatar Riyal" || from == "Saudi Riyal" || from == "South African Rand" || from == "Sri Lanka Rupee" || from == "Swedish Krona" || from == "Thai Baht")
{
fromvalue=fromrate[servicetype]/100;
fromval=Math.round(10000*fromvalue)/10000; //round to 4 decimal places
}

if (to == "Arab Emirates Dirham" || to == "Bangladesh Taka" || to == "Chinese Renminbi" || to == "Danish Krone"|| to == "Hongkong Dollar" || to == "Indian Rupee" || to == "Indonesian Rupiah" || to == "Japanese Yen" || to == "New Taiwan Dollar" || to == "Norwegian Krone" || to == "Pakistan Rupee" || to == "Philippine Peso" || to == "Qatar Riyal" || to == "Saudi Riyal" || to == "South African Rand" || to == "Sri Lanka Rupee" || to == "Swedish Krona" || to == "Thai Baht")
{
tovalue=torate[servicetype]/100;
toval=Math.round(10000*tovalue)/10000; //round to 4 decimal places
}

document.write("<table class='calculator' border=0>");

if ((from == "Malaysian Ringgit") && (!(isNaN(fromval)  && isNaN(toval)))) //BUYING
{
fromval="Malaysian Ringgit";
total=amount/toval;
totalround=Math.round(100*total)/100; //round to 2 decimal places

if (toval.toString().charAt(0)==".")
{
toval="0"+toval;	
}
if (totalround.toString().charAt(0)==".")
{
totalround="0"+totalround;	
}

document.write("<tr><td class=calculator>Rate:</td><td class=calculator colspan=2>&nbsp;<B>"+toabbr+" 1 =  MYR "+toval+"</B></td></tr>");
document.write("<tr><td class=calculator>For </td><td class=calculator>&nbsp;<B>" +from+" </B></td><td class=calculator><B>"+putcomma(amount.toString())+"</B><br></td></tr>");
document.write("<tr><td class=calculator>You will receive </td><td class=calculator>&nbsp;<B>" +to+"</B></td><td class=calculator><B> "+putcomma(totalround.toString())+"</B><br></td></tr>");
}

if ((to == "Malaysian Ringgit") && (!(isNaN(fromval)  && isNaN(toval)))) //SELLING
{
toval="Malaysian Ringgit";
total=fromval*amount;
totalround=Math.round(100*total)/100; //round to 2 decimal places

if (fromval.toString().charAt(0)==".")
{
fromval="0"+fromval;	
}
if (totalround.toString().charAt(0)==".")
{
totalround="0"+totalround;	
}

document.write("<tr><td class=calculator>Rate:</td><td class=calculator colspan=2>&nbsp;<B>"+fromabbr+" 1 = MYR "+fromval+"</B></td></tr>");
document.write("<tr><td class=calculator>For </td><td class=calculator>&nbsp;<B>" +from+" </B></td><td class=calculator><B>"+putcomma(amount.toString())+"</B><br></td></tr>");
document.write("<tr><td class=calculator>You will receive </td><td class=calculator>&nbsp;<B>" +to+" </B></td><td class=calculator><B>"+putcomma(totalround.toString())+"</B><br></td></tr>");
}
else if(isNaN(fromval) && isNaN(toval))
{
//window.resizeTo(425,435);	
initform();
document.write("<tr><td class=calculator>Sorry, currency rate not available<br><br></td></tr>");
}
document.write('</table>');    
    
    if(!(isNaN(fromval) && isNaN(toval)))
    {
    document.write('<tr><td colspan=4 class=calculator>');
    document.write('<span class=italic>* The value of conversion is rounded to the nearest figure.</span>');
    document.write('<BR><BR>');
    document.write('</td>');
    document.write('</tr>');
    } 
}

}
//-->
