jQuery(document).ready(function(){


getForex();

function getForex()
{ 

  $url = "http://"+top.location.host+"/forex/IFRates.xml";

	$.ajax({
		type: "GET",
		url: $url,
		dataType: "xml",
		success: function(xml) {
			
			$update = jQuery(xml).find('update').text();
			$updatetime = jQuery(xml).find('updatetime').text();
			$update = $updatetime + " on " +$update;
			$output = '<strong class="title">Rates</strong>';
		    $output += '<p>Rates are quoted against Malaysian Ringgit.<br /><em>Updated at '+$update+'</em><br /></p>';
			$output += '<table width="520" border="0" cellpadding="0" cellspacing="1">';
			$output += '<tr><td width="70" height="25" align="center" valign="middle" bgcolor="#005aac" style="background-image:url(../../img/tl_corner.gif); background-repeat:no-repeat;" rowspan="2"><strong style="color:#FFFFFF;">CURRENCY</strong></td><td width="160" height="25" align="center" valign="middle" bgcolor="#005aac" colspan="2"><strong style="color:#FFFFFF;">SPOT</strong></td><td height="25" align="center" valign="middle" bgcolor="#005aac" style="background-image:url(../../img/tr_corner.gif); background-repeat:no-repeat; background-position:top right" colspan="8"><strong style="color:#FFFFFF;">FORWARDS</strong></td></tr><tr><td width="80" height="25" align="center" valign="middle" bgcolor="#005aac"><strong style="color:#FFFFFF;">BUY</strong></td><td width="80" height="25" align="center" valign="middle" bgcolor="#005aac"><strong style="color:#FFFFFF;">SELL</strong></td><td height="25" align="center" valign="middle" bgcolor="#005aac" colspan="2"><strong style="color:#FFFFFF;">1 MTH</strong></td><td height="25" align="center" valign="middle" bgcolor="#005aac" colspan="2"><strong style="color:#FFFFFF;">2 MTHS</strong></td><td height="25" align="center" valign="middle" bgcolor="#005aac" colspan="2"><strong style="color:#FFFFFF;">3 MTHS</strong></td><td height="25" align="center" valign="middle" bgcolor="#005aac" colspan="2"><strong style="color:#FFFFFF;">6 MTHS</strong></td></tr>';
			
	jQuery(xml).find('currency').each(function(){				
				  $short = jQuery(this).find('short').text();
				  $buy = jQuery(this).find('buy').text();
				  $sell = jQuery(this).find('sell').text();
				  $onemonth1 = jQuery(this).find('onemonth1').text();
				  $onemonth2= jQuery(this).find('onemonth2').text();
				  $twomonth1 = jQuery(this).find('twomonth1').text();
				  $twomonth2= jQuery(this).find('twomonth2').text();
				  $threemonth1 = jQuery(this).find('threemonth1').text();
				  $threemonth2= jQuery(this).find('threemonth2').text();
				  $sixmonth1 = jQuery(this).find('sixmonth1').text();
				  $sixmonth2= jQuery(this).find('sixmonth2').text();
				  
				  
	$output +='<tr><td width="70" height="25" align="center" valign="middle" bgcolor="#b4dff1">'+$short+'</td><td width="80" height="25" align="center" valign="middle" bgcolor="#b4dff1">'+$buy+'</td><td width="80" height="25" align="center" valign="middle" bgcolor="#b4dff1">'+$sell+'</td><td width="35" height="25" align="center" valign="middle" bgcolor="#b4dff1">'+$onemonth1+'</td><td width="35" height="25" align="center" valign="middle" bgcolor="#b4dff1">'+$onemonth2+'</td><td width="35" height="25" align="center" valign="middle" bgcolor="#b4dff1">'+$twomonth1+'</td><td width="35" height="25" align="center" valign="middle" bgcolor="#b4dff1">'+$twomonth2+'</td><td width="35" height="25" align="center" valign="middle" bgcolor="#b4dff1">'+$threemonth1+'</td><td width="35" height="25" align="center" valign="middle" bgcolor="#b4dff1">'+$threemonth2+'</td><td width="35" height="25" align="center" valign="middle" bgcolor="#b4dff1">'+$sixmonth1+'</td><td width="35" height="25" align="center" valign="middle" bgcolor="#b4dff1">'+$sixmonth2+'</td>';				  	  				
				 // $link = '<a href = "'+$url+'">'+$title+'</a>';
				}); // end each
			
			$output += '</table><br /><em>The rates quoted herein are indicative only, and subject to change without notice at our sole discretion. For more information, please contact our Treasury Dealing Hotline at +603 9207 2666 / 2777 / 2888 / 2999. </em>';
			
			
			 $("#content_body").hide(1);
			 $("#content_body").html($output);
			 $("#content_body").fadeIn(2000);
				
		}
		

	});
		
}

function addJavascript(jsname,pos) {

var th = document.getElementsByTagName(pos)[0];
var s = document.createElement('script');
s.setAttribute('type','text/javascript');
s.setAttribute('src',jsname);
th.appendChild(s);

} 

});
