function currasnumber(snum)
{

num = snum.replace('$','');
num = num.replace(/,/g,'');

return (num);
}
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
num = Math.floor(num/100).toString();
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 (num );
}
	
function checkfornums(inthisstring)
{
var sNums = "0123456789";
var sChar = "";
var bFound = false;

for (x=0;x<=sNums.length-1;x++)
   {
   sChar = sNums.charAt(x);
   bFound = bFound || (inthisstring.indexOf(sChar) > -1)
   }
if (bFound)
   alert('You have entered a numeric value in your text. Not all fonts support numeric values. If the text does not render properly on your bill preview (after saving changes) please choose another font.');
   


}
function getQS()
{

var que = unescape(location.search);
var que = que.substring(1, que.length);
var que = que.split("&amp;");
var querystring = new Array();
var loop = 0;

while (loop < que.length)
 {
   var inter = que[loop].split("=");
   var inter2 = inter[1];
   var inter3 = inter[0]
   que[loop] = inter2;
   querystring[inter3] = inter2
   loop = loop + 1;
 }

return querystring; 
 
}

function doresize()
{
if (getObject('dirtyFlag').value == 1)
   alert('Please save your changes to this bill before entering the crop tool');
else
   {
   getObject('dirtyFlag').value=2;
   window.location = 'resizeTool.aspx?rso='+getObject('RowSaveOn').value;
   }

}
var popWin = null;

function closePopUs()
{
if ((popWin != null) && (!popWin.closed)) {popWin.close();} 
}

function openPopUp(sUrl)
{

popWin = window.open( sUrl, "__Information", "status='no',fullscreen=no,scrollbars=yes,resizable=yes" );
popWin.focus();
}

function openPopUpsZ(sUrl,w,h)
{
var y = Math.floor((screen.height - h) / 2);
var x = Math.floor((screen.width - w) / 2);
popWin = window.open( sUrl, "__Information", "status='no',fullscreen=no,top=" + y + ",left=" + x + ",width=" + w + ",height=" + h + ",scrollbars=no,resizable=no" );
popWin.focus();
}
function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function checkSaveAllBills(iPageOn)
{
var bRet = true;

if (iPageOn == 1 && getObject('dirtyFlag').value == "1")
   {

   
   if (false && (! getObject('cbApplyToAllBills').checked))
      if (confirm('Would you like to apply any changes to All Denominations of Bills? WARNING, selecting ok will overwrite settings for all of your bills. (ok = YES, cancel = NO) ') == true)
          getObject('cbApplyToAllBills').checked = true;
   }
   
return bRet;   
}
function showPageLoading(bShow)
{
var sShow;
if (bShow)
  sShow='visible';
else
  sShow='hidden';
  
getObject('pageloading').style.visibility=sShow;

return true;

}
function getObject(id) {
	v_obj = document.getElementById(id);
	if ( v_obj ) {
		return v_obj;
	} else {
		return false;
	}
}


function nb_numeralsOnly(evt) 
{ 

evt = (evt) ? evt : event; 

var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0)); 
if (charCode > 31 && (charCode < 48 || charCode > 57)) 
   {return false;} 
return true; 
}
function displayInformation(thiss,title,info)
{
   var bOpenNew = true;
   var timeout = 1000*60*5; // 5 minute timeout
   var height=500;
   var xoff,yoff;
   var infoWin;
   
   findPosX(thiss);
   findPosY(thiss);
   xoff = 100; //getPosX()+20;
   yoff=100; //getPosY()+200;
   
   if (infoWin == null)
      bOpenNew = true;
   else          
      bOpenNew = infoWin.closed;


   if (bOpenNew)
      infoWin = window.open( "", "__Information", "status='no',width=650,height=" + height + ",top=" + yoff + ",left=" + xoff + ",scrollbars=yes,resizable=yes" );
   else
      infoWin.moveTo(xoff,yoff);
    
      
   infoWin.document.open( "text/html" );
   infoWin.document.write( "<head>\n" );
   infoWin.document.write( "<title>" + title + "</title>\n" );
   infoWin.document.write( "</head>\n" );
   infoWin.document.write( "<html>\n" );
   infoWin.document.write( "<body onBlur=\"window.focus();\"onload = \"window.status='" + title + "';setTimeout('window.close();'," + timeout + ")\">\n" );    
   infoWin.document.write( "<fieldset><table width=100%>\n");
   infoWin.document.write("<tr ><td align=\"center\"><span style=\"font-family: Arial; font-weight: 800; font-size: 12 pt; color: #6677DD;\">" + title + "</span></tr></td>\n");
   infoWin.document.write("<tr><td><IFRAME SCROLLING=YES FRAMEBORDER=0 HEIGHT=400 WIDTH=100% SRC='" + info + "'></IFRAME></tr></td>\n");
   infoWin.document.write( "</table></fieldset>\n");
   infoWin.document.write( "<table width=100%>\n");   
   infoWin.document.write("<tr><td align='center'><br><input type='button' value='close' onclick='self.close();'></td></tr>\n");
   infoWin.document.write( "</table>\n");   
   infoWin.document.write( "<\/body>\n" );
   infoWin.document.write( "<\/html>\n" );
   infoWin.document.write("<script>\n");
   infoWin.document.write("setInterval('window.focus();', 100);\n");
   infoWin.document.write("</script>\n");
   infoWin.document.close();
   infoWin.focus();   
   
}

var curleft = 0;
function getPosX()
{
   return curleft-findScrollLeft();
}

function findPosX(obj)
{
var isIE = false, isN4 = false, isN6 = false; 
 
  if (document.all) isIE = true; 
  else if (document.layers)  isN4 = true; 
  else if (document.getElementById) isN6 = true; 
  
	curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	if (isN4 || isN6) 
  	   curleft += window.screenX;		
  	if (isIE)
  	   curleft += window.screenLeft;
}

var curtop = 0;
function getPosY()
{
   return curtop-findScrollTop();
}
function findPosY(obj)
{
var isIE = false, isN4 = false, isN6 = false; 
 
  if (document.all) isIE = true; 
  else if (document.layers)  isN4 = true; 
  else if (document.getElementById) isN6 = true; 
  
	curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
		
	if (isN4 || isN6) 
  	   curtop += window.screenY;		
  	if (isIE)
  	   curtop += window.screenTop;	
  	   
  	curtop -= 100;	
}

function findScrollLeft() {
	if (document.body.scrollLeft)
		return document.body.scrollLeft;
	return (0);
}

function findScrollTop() {
	if (document.body.scrollTop)
		return document.body.scrollTop;
	return (0);
}
function Is() {
    var agent   = navigator.userAgent.toLowerCase();
    this.major  = parseInt(navigator.appVersion);
    this.minor  = parseFloat(navigator.appVersion);
    this.ns     = ((agent.indexOf('mozilla')   != -1) &&
                  (agent.indexOf('spoofer')    == -1) &&
                  (agent.indexOf('compatible') == -1) &&
                  (agent.indexOf('opera')      == -1) &&
                  (agent.indexOf('webtv')      == -1));
    this.ns4    = (this.ns && (this.major      ==  4));
    this.ns6    = (this.ns && (this.major      >=  5));
    this.ie     = (agent.indexOf("msie")       != -1);
    this.ie3    = (this.ie && (this.major      <   4));
    this.ie4  	= (this.ie && (this.major >= 4));
    this.ie5    = (this.ie && (this.major      ==  4) &&
                  (agent.indexOf("msie 5.0")   != -1));
    this.ieX    = (this.ie && !this.ie3 && !this.ie4);
}


var is = new Is();
	
	function layerObject(id,left,top) {
	
		if (is.ns6){
		this.obj = getObject(id).style;
		this.obj.left = left + "px";
		this.obj.top = top + "px";
		return this.obj;
		} else if(is.ie4) {
		this.obj = document.all[id].style;
		this.obj.left = left;
		this.obj.top = top;
		return this.obj;
		} else if(is.ns4) {
		this.obj = document.layers[id];
		this.obj.left = left;
		this.obj.top = top;
		return this.obj;
		}  
}

function layerSetup(available_width,available_height) {
		centerLyr = new layerObject('RenderMsgLayer', available_width/2-100,available_height/2-100);
		
}
function resizeRenderMsgLayer()
{
 
 if(is.ns4 ||is.ns6) {
          available_width=innerWidth;
          available_height=innerHeight;
          layerSetup(available_width,available_height);
	     } else  {
          available_width=document.body.clientWidth;
          available_height=document.body.clientHeight;
          layerSetup(available_width,available_height);
	     }
}
function initRenderMsgLayer()
{
 
   resizeRenderMsgLayer()
   getObject('RenderMsgLayer').innerHTML = '<p><b>Please wait while we perform this operation.</b></p><IMG SRC="IMAGES/dollar.gif">' + getObject('RenderMsgLayer').innerHTML;
   
}

function showRenderMsgLayer()
{
initRenderMsgLayer();
opacity('layerContent', 100, 30, 1000);
//for (x=1;x<document.forms[0].elements.length-1;x++) 
	//document.forms[0].elements[x].style.visibility='hidden';

opacity('RenderMsgLayer', 50, 0, 100);
getObject('RenderMsgLayer').style.visibility='visible';
opacity('RenderMsgLayer', 0, 100, 1000);


}
function opacity(id, opacStart, opacEnd, millisec) 
{ 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) 
    { 
        for(i = opacStart; i >= opacEnd; i--) 
         { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
         } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 
function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function




