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_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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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 MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function findLayer(l,base)
{
	if(document.all) return document.all[l];
	else if(document.getElementById) return document.getElementById(l);
	return null;
}

function findLayerStyle(l)
{
	var t=findLayer(l)
	if( t )
	{
		if( t.style ) return t.style
		return t
	}
	return null
}

function hideLayer(name) { l=findLayerStyle(name);if(l)l.visibility='hidden' }
function showLayer(name) { l=findLayerStyle(name);if(l)l.visibility='visible' }

function getLayerContents( layerName )
{
	var t = findLayer( layerName );
	if(t&&t.innerHTML) return t.innerHTML;
	return '';
}

function rewriteLayer(l,s)
{
	var t=findLayer(l);
	if(t&&t.innerHTML) t.innerHTML = s;
}
function BasicPopup(URL,name,p){var WindowName;if((!name)||(name==''))name='_blank';w=window.open(URL,WindowName,p);if(w.window.focus)w.window.focus();return false;}
function Center(w,h){this.l=((window.screen)&&(screen.availWidth))?(screen.availWidth-w)/2:((window.screen)&&(screen.width))?(screen.width-w)/2:0;this.t=((window.screen)&&(screen.availHeight))?(screen.availHeight-h)/2:((window.screen)&&(screen.height))?(screen.height-h)/2:0}
function Popup(URL,name,w,h,s){var c=new Center(w,h);return BasicPopup(URL,name,'height='+h+',width='+w+',top='+c.t+',left='+c.l+',scrollbars='+((s)?'yes':'no')+',noresize')}
function NewWindow(URL,name,w,h){var c=new Center(w,h);return BasicPopup(URL,name,'height='+h+',width='+w+',top='+c.t+',left='+c.l+',location=yes,statusbar=yes,status=yes,scrollbars=yes,personalbar=yes,toolbar=yes,menubar=yes,resizable=yes')}

function startClock()
{
	rewriteLayer('clock','<table border="0" cellspacing="0" cellpadding="0"><tr><td><img name="clock_h1" src="images/clear.gif" width="5" height="9"></td><td><img src="images/clear.gif" width="1" height="9"></td><td><img name="clock_h2" src="images/clear.gif" width="5" height="9"></td><td><img name="clock_colon" src="images/digits/colon.gif" width="5" height="9"></td><td><img name="clock_m1" src="images/clear.gif" width="5" height="9"></td><td><img src="images/clear.gif" width="1" height="9"></td><td><img name="clock_m2" src="images/clear.gif" width="5" height="9"></td></tr></table>');
	if(!(document.images&&document.images.clock_colon))return;
	window.clockFlashing=true;
	updateClock();
}

function updateClock()
{
	var d = new Date();
	setTimeout( "updateClock()",250 );
	var h2 = d.getHours() % 10;
	var h1 = ((d.getHours()-h2)/10) % 10;
	var m2 = d.getMinutes() % 10;
	var m1 = ((d.getMinutes()-m2)/10) % 10;
	if( window.clockFlashing )
	{
		if(d.getMilliseconds()>=500) document.images.clock_colon.src = 'images/digits/colon.gif';
		else document.images.clock_colon.src = 'images/clear.gif';
	}
	if(!h1) document.images.clock_h1.src = 'images/clear.gif';
	else document.images.clock_h1.src = 'images/digits/'+h1+'.gif';
	document.images.clock_h2.src = 'images/digits/'+h2+'.gif';
	document.images.clock_m1.src = 'images/digits/'+m1+'.gif';
	document.images.clock_m2.src = 'images/digits/'+m2+'.gif';
}

function delayedUpdateLayer()
{
	if( window.__layerToHide ) hideLayer( window.__layerToHide );
	if( window.hideImage )
	{
		if( window._lastImage ) document.images.dial.src = window._lastImage;
		window._lastImage = 0;
	}
}

function overLayer(id)
{
	window._lastLayer=id;
	if( id==window.__layerToHide )
	{
		window.__layerToHide=0;
		return;
	}
	if( window.__layerToHide ) hideLayer( window.__layerToHide );
	window.__layerToHide = 0;
	showLayer(id);
}

function navEnter(i,id)
{
	overLayer(id);
	var nextImage = 'images/dial'+i+'.gif';
	window.hideImage = false;
	if( ! window._lastImage ) window._lastImage = document.images.dial.src;
	document.images.dial.src = nextImage;
}

function navLeave()
{
	if( window.timeout ) clearTimeout( window.timeout );
	window.timeout = setTimeout( 'delayedUpdateLayer();', 250 );
	window.hideImage = true;

	if( window._lastLayer )
	{
		window.__layerToHide = window._lastLayer;
		window._lastLayer = 0;
	}
}

