var submitcount=0;

function SubmitOnce() 
{
    if (submitcount == 0)
       {
       submitcount++;
       return true;
       }
    else
       {
       alert("This page has already been submitted.  Please wait while your request is being processed.");
       return false;
       }
 }

function newWindow(url,width,height)
{
	var newWindow;	
	newWindow = window.open(url,"infoWindow","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",screenX=40,screenY=40");
	newWindow.focus();
}

function newFunctionalWindow(url,width,height)
{
	var newWindow;	
	newWindow = window.open(url,"infoWindow","toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",screenX=40,screenY=40");
	newWindow.focus();
}

function newNamedWindow(url,name,width,height)
{
	var newWindow;
	newWindow = window.open(url,name,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",screenX=40,screenY=40");
	newWindow.focus();
}

function newNamedPrintWindow(url,name,width,height)
{
	var newWindow;
	newWindow = window.open(url,name,"toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",screenX=40,screenY=40");
	newWindow.focus();
}

function newNamedAddressWindow(url,name,width,height)
{
	var newWindow;
	newWindow = window.open(url,name,"toolbar=yes,location=yes,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",screenX=40,screenY=40");
	newWindow.focus();
}

function popitup(url)
{
	var newWindow;
	newWindow = window.open(url,'ReferNow','height=500,width=650,scrollbars=yes');
	newWindow.focus();
}
function popitupbig(url)
{
	var newWindow;
	newWindow = window.open(url,'ReferNow','height=700,width=1000,scrollbars=yes');
	newWindow.focus();
}

function IsNumeric(str) {
	var strValidChars = "0123456789.";
	var strChar;
	var blnResult = true;
	if (str.length == 0) return false;
	for (i = 0; i < str.length && blnResult == true; i++) {
		strChar = str.charAt(i);
		if (strValidChars.indexOf(strChar) == -1) {
			blnResult = false;
		}
	}
	return blnResult; 
}

// number formatting function
// copyright Stephen Chapman 24th March 2006, 10th February 2007
// permission to use this function is granted provided
// that this copyright notice is retained intact


function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) {
	var x = Math.round(num * Math.pow(10,dec));
	if (x >= 0) n1=n2='';
	var y = (''+Math.abs(x)).split('');
	var z = y.length - dec; 
	if (z<0) 
		z--; 
	for(var i = z; i < 0; i++) 
		y.unshift('0');
	y.splice(z, 0, pnt); 
	while (z > 3) {
		z-=3; 
		y.splice(z,0,thou);
	}
	var r = curr1+n1+y.join('')+n2+curr2;
	return r;
}


function left(str, n)
{
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}


function moveTo(field1, chars, field2) {
	if (field1.value.length == chars) {
		field2.select();
	}
}

// This function is called on the business pb pages to get rid of the IE7 flash bouncing problem
function clearContentFlash() {
	if (document.getElementById("contentFlash")) document.getElementById("contentFlash").style.display = "none";
}