
function showTime(time, placeholder)
{
  var hours = time.getHours();
  var mins = time.getMinutes();
  var secs = time.getSeconds();
  
  if(hours >= 12)
  {
    ampm = 'pm';
    if(hours > 12) hours -= 12;
  }
  else
  {
    ampm = 'am';
    if(hours == 0) hours = 12;
  }
  
  if(hours < 10) hours = '0' + String(hours);
  if(mins < 10) mins = '0' + String(mins);
  if(secs < 10) secs = '0' + String(secs);
  placeholder.value = hours + ':' + mins + ':' + secs + ' ' + ampm;
}

function setTime()
{
  syd = new Date();
  
  var mon = syd.getMonth();
  var day = syd.getDate();
  var ds = ((mon < 3) || (mon == 9 && day > 21) || (mon > 9));

  with(document.ftime)
  {
    if(ds)
    {
      var tzo = syd.getTimezoneOffset() / 60;
      var hours = syd.getHours() + tzo + 11;
      if(hours > 23) hours -= 24;
      syd.setHours(hours);
      var mins = syd.getMinutes();
      var secs = syd.getSeconds();
  
      showTime(syd, time_syd);
   
      thours = (hours == 22) ? 0 : hours + 2; 
      auc = new Date(syd.getYear(), syd.getMonth(), syd.getDate(), thours, mins, secs);
      showTime(auc, time_auc);
	  
      thours = (hours == 0) ? 22 : hours - 2; 
      tok = new Date(syd.getYear(), syd.getMonth(), syd.getDate(), thours, mins, secs);
      showTime(tok, time_tok);
  
      thours = Number(hours) - 11;
      if(thours < 0) thours += 24;
      
      lon = new Date(syd.getYear(), syd.getMonth(), syd.getDate(), thours, mins, secs);
      showTime(lon, time_lon);
      
      thours = hours - 16;
      if(thours < 0) thours += 24;
      ny = new Date(syd.getYear(), syd.getMonth(), syd.getDate(), thours, mins, secs);
      showTime(ny, time_ny);
    }
    else
    {
      var tzo = syd.getTimezoneOffset() / 60;
      var hours = syd.getHours() + tzo + 10;
      if(hours > 23) hours -= 24;
      syd.setHours(hours);
      var mins = syd.getMinutes();
      var secs = syd.getSeconds();
  
      showTime(syd, time_syd);
	  
	  thours = (hours == 22) ? 0 : hours + 2; 
      auc = new Date(syd.getYear(), syd.getMonth(), syd.getDate(), thours, mins, secs);
      showTime(auc, time_auc);
   
      thours = (hours == 0) ? 23 : hours - 1; 
      tok = new Date(syd.getYear(), syd.getMonth(), syd.getDate(), thours, mins, secs);
      showTime(tok, time_tok);
  
      thours = Number(hours) - 9;
      if(thours < 0) thours += 24;
      
      lon = new Date(syd.getYear(), syd.getMonth(), syd.getDate(), thours, mins, secs);
      showTime(lon, time_lon);
      
      thours = hours - 14;
      if(thours < 0) thours += 24;
      ny = new Date(syd.getYear(), syd.getMonth(), syd.getDate(), thours, mins, secs);
      showTime(ny, time_ny);
    }
  }
  
}

function prepareClocks()
{
  setTime();
  window.setInterval('setTime()', 1000);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function PreloadImages()
{
	MM_preloadImages('images/nav-about_f2.gif','images/nav-trading_f2.gif','images/nav-workstation_f2.gif','images/nav-forum_f2.gif','images/nav-chat_f2.gif')
	MM_preloadImages('images/nav-default_f2.gif','images/nav-email_f2.gif','images/nav-risk_f2.gif','images/nav-privacy_f2.gif','images/nav-fxsites_f2.gif','images/nav-contact_f2.gif')
	ArrangeScreen();
}

/*function ArrangeScreen()
{
  if(document.getElementById)
  {
    var width = document.getElementById ?
  		document.documentElement.clientWidth : window.innerWidth;
    var height = document.getElementById ?
  		document.documentElement.clientHeight : window.innerHeight;
		
		var div = document.getElementById('divContent');
		div.style.pixelHeight = height - 162;
	
		var div = document.getElementById('divBottom');
		div.style.pixelLeft = 0;
		div.style.pixelTop = height - 28;
		
		document.getElementById('divMenu').style.left = (width / 2) - 400;
		document.getElementById('divSubmenu1').style.left = 
		document.getElementById('divSubmenu2').style.left = 
		document.getElementById('divSubmenu3').style.left = (width / 2) - 220;
		document.getElementById('divMenu2').style.left = (width / 2) - 263;
  }
	prepareClocks();
}*/

function ArrangeScreen()
{
  if(document.getElementById)
  {
    var width = document.getElementById ?
  		document.documentElement.clientWidth : window.innerWidth;
    var height = document.getElementById ?
  		document.documentElement.clientHeight : window.innerHeight;
		
		var div = document.getElementById('divContent');
		div.style.pixelHeight = height - 162;
	
		var div = document.getElementById('divBottom');
		div.style.pixelLeft = 0;
		div.style.pixelTop = height - 28;
		
		//document.getElementById('divMenu').style.left = (width / 2) - 400;
		//document.getElementById('divSubmenu1').style.left = 
		//document.getElementById('divSubmenu2').style.left = 
		//document.getElementById('divSubmenu3').style.left = (width / 2) - 220;
		//document.getElementById('divMenu2').style.left = (width / 2) - 263;
  }
	prepareClocks();
}

var onWindow = false;

function PopUp(id)
{
	HideSubmenus();
  var div = document.getElementById(id);
	div.style.visibility = 'visible';
  onWindow = true;
	window.setTimeout('CheckMenu("' + id + '")', 1000);
}

function CheckMenu(id)
{
	if(!onWindow)
	  HideMenu(id);
	else 	window.setTimeout('CheckMenu("' + id + '")', 1000);

}

function HideMenu(id)
{
	  var div = document.getElementById(id);
		div.style.visibility = 'hidden';

}

function PopDown()
{
	onWindow = false;
}

function Hilite(td)
{
	td.className = 'menuHilite';
	onWindow = true;
}

function UnHilite(td)
{
	td.className = 'menu';
	onWindow = false;
}

function HideSubmenus()
{
	HideMenu('divSubmenu1');
	HideMenu('divSubmenu2');
	HideMenu('divSubmenu3');
}

function openwin(url)
{
	window.open(url, 'win', 
  'width=600,height=400,menubar=no,directory=no,status=no,resizable=no,scrollbars=yes');
}
