/*
	Restore an image that has been swapped - MM
*/
function MM_swapImgRestore() {
	var i,x,a=document.MM_sr;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/*
	Preload rollovers into memory for fast swapping MM
*/
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];}}
}

/*
	Locate an object in multiple browsers
*/
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;
}

/*
	Swap one image with another
*/
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];}
}

/*
	evaluate a JS piece of code.
*/
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

/*
	Image swapping, used in the main menu of template
*/
function imgswap(iname){
	MM_swapImage(iname,'','/LTtemplates/template_images/arrow.highlight.gif',1);
	return 1;
}

/*
	Change the color of a td cell
*/
function col_change( t,ina ){
	t.bgColor='#18558A';
	imgswap(ina);
}

/*
	Restore the image
*/
function restore(){
MM_swapImgRestore();
return 1;
}

/*
	Change the td cell color back to original color
*/
function col_back( t ){
t.bgColor='#437CB0';
restore();
}

/*
	Open a new window with the options
*/
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/*
	Change the display string at the bottom of the page
*/
function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

///// Following 3 functions added for use by date-popup - Ryan 2004-05-04
function WM_imageSwap(daImage, daSrc)
{
	var objStr,obj;
	if(document.images)
	{
		if (typeof(daImage) == 'string')
		{
			objStr = 'document.' + daImage;obj = eval(objStr);obj.src = daSrc;
		}
		else if ((typeof(daImage) == 'object') && daImage && daImage.src)
		{
			daImage.src = daSrc;
		}
	}
}

function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

// Used for chaining multiple onload events
function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			if (oldonload)
			{
				oldonload();
			}

			func();
		}
	}
}