function newWindow(mypage,myname,w,h,features) {
 try
 {
	  if(screen.width){
	  var winl = (screen.width-w)/2;
	  var wint = (screen.height-h)/2;
  		}else{winl = 0;wint =0;}
 	 if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;
	var settings = 'height=' + h + ',';
	settings += 'width=' + w + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl + ',';
	settings += features;
	win = window.open(mypage,myname,settings);
	win.window.focus();
}
catch(e)
{
	//window.status = e.message
}
}

function isInteger(s) {
return (s.toString().search(/^-?[0-9]+$/) == 0);
}

function printPage()
{
	try
	{
		//This function hides anything that we dont want to print.
		//all that is required is a variable is added to the 
		for(i=0;i<document.all.length;i++)
		{
			if(document.all[i].displayWhenPrint =="false")
			{
				document.all[i].style.visibility='hidden';
			}
		}
		window.print();
		for(i=0;i<document.all.length;i++)
		{
			if(document.all[i].displayWhenPrint =="false")
			{
				document.all[i].style.visibility='visible';
			}
		}
	}
	catch(e)
	{
		window.status = e.message
	}
}

function hideObjectsForPrint()
{
	try
	{
		for(i=0;i<document.all.length;i++)
		{
			if(document.all[i].displayWhenPrint =="false")
			{
				document.all[i].style.visibility='hidden';
			}
		}
	}
	catch(e)
	{
		window.status = e.message
	}
}


function formatCurrency(num) 
{
	try
	{
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
			num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
			cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
			num = num.substring(0,num.length-(4*i+3))+
		num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + num + '.' + cents);
	}
	catch(e)
	{
		window.status = e.message
	}
}

function formatDecimal(argvalue, addzero, decimaln) {
  try
  {
	  var numOfDecimal = (decimaln == null) ? 2 : decimaln;
	  var number = 1;

	  number = Math.pow(10, numOfDecimal);

	  argvalue = Math.round(parseFloat(argvalue) * number) / number;
	  try
	  { 
	  	argvalue = argvalue.toString();	
	  }
	  catch(e) 
 	 {
	  	argvalue = "" + argvalue;
 	 }
  
 	 if (argvalue.indexOf(".") == 0)
    	argvalue = "0" + argvalue;
	 if (addzero == true) {
	    if (argvalue.indexOf(".") == -1)
	  	    argvalue = argvalue + ".";

	    while ((argvalue.indexOf(".") + 1) > (argvalue.length - numOfDecimal))
   		   argvalue = argvalue + "0";
  	}

  	return argvalue;
  	}
	catch(e)
	{
		window.status = e.message
	}
  }
