function jumpATAC()
{
	var sURL="/do/PtoATAC.asp?fromPage="+escape(window.location.pathname);
	var atacWin = window.open(sURL,"","");

	atacWin.focus();
}

function isNumeric(strIn)
{
	var validChars = "0123456789.";
	var chr;

	if (strIn.length==0)
		return false;
	else
		for (i=0;i<strIn.length;i++) 
		{ 
			chr = strIn.charAt(i); 
			if (validChars.indexOf(chr) == -1) 
				return false;
		}

	return true;
}

function formatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/**********************************************************************
	IN:
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for
										numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.
 
	RETVAL:
		The formatted number!
 **********************************************************************/
{ 
        if (!isNumeric(num)) return num + " NaN";

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number
	
	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign
	
	
	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);
	
	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
		
	// See if we need to put in the commas
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

	var decPointPos=tmpNumStr.indexOf('.',0);
	
	if (decPointPos==-1)
	{
		// alert("tmpNumStr=" + tmpNumStr + "\r\n adding point");
		tmpNumStr+=".";
		decPointPos=tmpNumStr.indexOf('.',0);
	}
	
	/*
	alert("start loop\r\ntmpNumStr=" + tmpNumStr + 
		"\r\ndecimalNum=" + decimalNum + 
		"\r\ndecPointPos=" + decPointPos + 
		"\r\ntmpNumStr.length=" + tmpNumStr.length +
		"\r\n(decimalNum-(tmpNumStr.length-decPointPos))=" + (decimalNum-(tmpNumStr.length-decPointPos))
	);
	*/
	
	while ((decimalNum-(tmpNumStr.length-decPointPos))>-1)
	{
		// alert("in loop; x=" + (decimalNum-(tmpNumStr.length-decPointPos)));
		tmpNumStr+="0";
	}

	return tmpNumStr;		// Return our formatted string!
}

function addCasetaTools()
{
	window.location.href="/do/PaddKZTools.asp?start=yes";
}

function popFeeConfirmation(sURI, sInputID, sFunctionAfter) {
	var uri=sURI + "?inputID=" + escape(sInputID) + "&functionAfter=" + escape(sFunctionAfter);
	properties="menubar=no";
	properties+=",scrollbars=yes";
	properties+=",toolbar=no";
	properties+=",statusbar=no";
	properties+=",height="+250;
	properties+=",width="+250;
	properties+=",titlebar=no";
	infoWin = window.open(uri,"_popUpFeeConfirmation",properties);
	infoWin.focus();
}

function openInfoPopUp(sWhat, iID, sExtra)
{
	var uri="/do/help/PinfoPopUp.asp?typ=" +sWhat + "&id=" + iID + "&extra=" + sExtra;
	properties="menubar=no";
	properties+=",scrollbars=yes";
	properties+=",toolbar=no";
	properties+=",statusbar=no";
	properties+=",height="+300;
	properties+=",width="+300;
	properties+=",titlebar=no";
	infoWin = window.open(uri,"_infoPopUp",properties);
	infoWin.focus();
}
function openCompanyDirectoryPopUp()
{
    uri="/do/pcompanydirectory.asp?start=yes"
    properties="menubar=no";
	properties+=",scrollbars=yes";
	properties+=",toolbar=no";
	properties+=",statusbar=yes";
	properties+=",resizable=yes";
	properties+=",width=800";
	properties+=",height=800";
	infoWin = window.open(uri,"_companyDirectory",properties);
	infoWin.focus();
}

function addPhoneNumber(sFromPage)
{
	var uri="/do/Padd_number.asp?start=YES&fromPage=" + escape(sFromPage);
	window.location.href=uri;
}

function addSoftPhone()
{
	window.location.href="/do/PaddSoftphone.asp?start=yes";
}

function downloadSoftphone(sMsg)
{
	alert(sMsg);
	
	window.location.href="http://atac.alianza.com/tools/downloads/files/alianzaPhone.exe";
}