//if (!document.all) document.constructor.prototype.__defineGetter__('all', function() { return document.getElementsByTagName('*'); });   
//if (!document.all.tags) document.all.tags = function(tagname){ return document.getElementsByTagName(tagname) }
    
function formatNumber(n, d) 
{
  n = n.toString().replace(/,/g,'');
  n = round (n, d);
  var start = n.indexOf('.') == -1 ? n.length : n.indexOf('.');
  for (var i = start-3; i > 0; i -= 3)
  {
    n = n.substring(0, i) + ',' + n.substring(i);
  }
  return n;
}

function getNumber(n, d)
{
  n = n.toString().replace(/,/g,'');
  if(isNaN(n))
	{
		n = "0";
	}
  n = round (n, d);
  return n;
}

function round (n, d) 
{
  n = n - 0;
  d = d || 0;
  var f = Math.pow(10, d);
  n = Math.round(n * f) / f;
  n += Math.pow(10, - (d + 1));
  n += '';
  return d == 0 ? n.substring(0, n.indexOf('.')) :
      n.substring(0, n.indexOf('.') + d + 1);
}

function formatCurrency(n, d) 
{
	n = n.toString().replace(/\$|\,/g,'');
	if(isNaN(n))
	{
		n = "0";
	}
	var rc = formatNumber(n, d);
	return ('$' + rc);
}

function ShowHelp()
{
	var helpUrl = window.event.srcElement.value;
	window.open(helpUrl,'helpcontent','width=600,height=425,status,resizable=1,scrollbars=1',true);
}

function printIt() 
{
	window.print(); 
}

function printItLandscape() 
{ 
	//grab the div in the html w/o the header & footer text 
	var content=document.getElementById('thecontent'); 
	//open a blank window 
	w=window.open('about:blank'); 
	//write content var html to the window 
	w.document.open(); 
	//w.document.write("<html>"); 
	w.document.write("<html><HEAD>"); 
	w.document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"Common/SiteStyles.css\" />"); 
	w.document.write("</HEAD>"); 	
	w.document.write("<div class=\"page\">"); 
	w.document.write(content.innerHTML);
	w.document.write("</div>"); 
	//write some javascript to make the newly opened window print itself. 
	w.document.writeln("<script>window.print();</"+"script>"); 
	w.document.writeln("</html>"); 
	w.document.close(); 
	w.close();
}

var lastColorUsed;
function changeBackColor(row, highlight)
{
  if (highlight)
  {
    lastColorUsed = row.style.backgroundColor;
    row.style.backgroundColor = '#CCCCFF';
  }
  else
    row.style.backgroundColor = lastColorUsed;
}


function displayGraphicLoader()
{
	var gl = document.getElementById('graphicLoader')
	//alert(gl.src);
	if (gl != null)
	{
		gl.src="images/loader.gif";
	}
	var glb = document.getElementById('graphicLoaderBottom')
	//alert(glb.src);
	if (glb != null)
	{
		glb.src="images/loader.gif";
	}
}



function doOnClickBody() 
{ 
	var hdn = document.getElementById("hdnScrollTop");
	if (hdn != null)
	{
		hdn.value = document.body.scrollTop; 
	}
	var gb = document.getElementById("gridBorder");
	if (hdn != null && gb != null)
	{
		hdn.value = gb.scrollTop; 
	}	
} 


function doOnLoadBody() 
{ 
	var hdn = document.getElementById("hdnScrollTop");
	if (hdn != null)
	{
		//document.body.scrollTop = hdn.value
	}
}


 
 function showImage(imgName, origName)
 {
   if (document.images)
    {
      imgOff=eval(imgName + ".src");
      origName.src = imgOff;
      //document[origName].src= imgOff;
    }
}

Function.prototype.bind = function (object) {
    var __method = this;
    return function () {
        return __method.apply(object, arguments);
    }
};

 /*
 function preloadImages() {
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
   
}*/
