	function MinMax(sString)
	{
		var myNum = 0;
		myNum = getValueOf(sString);
		if ( myNum > 100.0 )
		{
			myNum = 100.0;
		}
		if ( myNum < 0.0 )
		{
			myNum = 0.0;
		}
		return(myNum);	
	}
	
	function stripLeadZeros(stripString)
	{		
		var sChar = "";
		var breakCounter = 0;
		var retString = "";
		for(j=0; j <= stripString.length; j++)
		{
			sChar = stripString.substring(j, j+1);
			if( sChar == "0" )			
			{
				continue;
			}else{
				breakCounter = j;
				break;
			}
		}
		retString = stripString.substring(breakCounter, stripString.length);		
		return retString;
	}

	function getValueOf(sString)
	{
		var sStripped = "";
		var bDecimal = 0;
		var bChar = 0;
		var sChar = "";
		sString += "";
		for (i=0; i <= sString.length; i++)
		{
			sChar = sString.substring(i, i+1);
			if (sChar == "-")
			{
				sStripped += sChar;
			}
			if (sChar == ".")
			{
				bDecimal = 1;
				sStripped += sChar;
			}
			if ((sChar >= "0") & (sChar <= "9"))
			{
				sStripped += sChar;
			}
		}
		if (bDecimal)
		{
			return parseFloat(sStripped);
		}
		else if (sStripped.length > 0)
		{
			return parseInt(sStripped); 
		}else{
			return 0;
		}
	}
	
	function formatSave(sNumber,sDecimal)
	{
		var sTemp = "";
		var numDecs = 0;
		var isNegative = 0;
		var haveDecimal = 0;
		if ( sDecimal> 10 )
		{
			sDecimal = 10;
		}
		sNumber = getValueOf(sNumber);
		sNumber = ''+sNumber;
		if (sNumber.charAt(0) == "-")
		{
			isNegative = 1;
			sNumber = sNumber.substring(1, sNumber.length);
		}
		with (Math) sTemp = (round(sNumber * pow(10,sDecimal))) / pow(10,sDecimal); 
		sTemp = ''+sTemp;
		numDecs = sTemp.length - sTemp.indexOf(".") - 1;
		if ( sTemp.charAt(0) == '.' )
		{
			sTemp = "0" + sTemp;
		}
		if (sDecimal == 0)
		{
			if (sTemp.charAt( sTemp.length - 1 ) == ".")
			{
				sTemp = sTemp.substring( 0, sTemp.length - 1 );
			}
		}
		if ( isNegative == 1 ){sTemp = "-" + sTemp;}
		return sTemp;
	}
	
	function formatAsNumber23(sNumber,sDecimal)
	{
		var sTemp = "";
		var numDecs = 0;
		var isNegative = 0;
		iDec ="";
		var sZero = "00000000000";
		var haveDecimal = 0;
		if ( sDecimal> 10 )
		{
			sDecimal = 10;
		}
		sNumber = getValueOf(sNumber);
		sNumber = ''+sNumber;
		if (sNumber.charAt(0) == "-")
		{
			isNegative = 1;
			sNumber = sNumber.substring(1, sNumber.length);
		}
		with (Math) sTemp = (round(sNumber * pow(10,sDecimal))) / pow(10,sDecimal); 
		sTemp = ''+sTemp;
		if (sTemp.indexOf(".")<0)
		{
			sTemp = sTemp + ".";
		}
		numDecs = sTemp.length - sTemp.indexOf(".") - 1;
		if ( sDecimal > numDecs )
		{
			sTemp = sTemp + sZero.substring( 0, sDecimal - numDecs );
		}
		if ( sTemp.charAt(0) == '.' )
		{
			sTemp = "0" + sTemp;
		}
		if (sDecimal == 0)
		{
			if (sTemp.charAt( sTemp.length - 1 ) == ".")
			{
				sTemp = sTemp.substring( 0, sTemp.length - 1 );
			}
		}

		for ( i = 0; i < (sTemp.length); i++ )
		{
			sChar = sTemp.charAt(i);
			if ( sChar == "." )
			{
				iDec = sTemp.indexOf(".")
				haveDecimal=1;
			}
		}
		if ( haveDecimal == 1 )
		{
			sLeft = sTemp.substring( 0, iDec );
			sRight = sTemp.substring( iDec  + 1, sTemp.length );
		}else{
		 	sLeft = sTemp;
			sRight = "";
		}
		sTemp = "";
		iPosition = 0;
		i = sLeft.length;
		while ( i > 0 )
		{
			i = i - 1;
			sChar = sLeft.charAt(i);
			if ( (iPosition / 3 == Math.round(iPosition / 3) ) & (iPosition != 0) )
			{
				sTemp = "," + sTemp;
			}
			sTemp = sChar +  sTemp;
			iPosition=iPosition+1;
		}
		if ( haveDecimal == 1 )
		{
			sTemp = sTemp + "." + sRight;
		}
		if ( isNegative == 1 )
		{
			sTemp = "-" + sTemp;
		}
		return sTemp;
	}
	
	function formatPlusNumber(sNumber,sDecimal)
	{
		sNumber = formatNumber23(sNumber,sDecimal);
		if (sNumber.charAt(0) != "-")
		{
			sNumber = '+' + sNumber;
		}
		return(sNumber);
	}
	
	function formatMixPercent(sNumber,sDecimal)
	{
		sNumber = getValueOf(sNumber);
		if (sNumber < 1)
		{
			sNumber = sNumber * 100;
		}
		with (Math) sNumber = (round(sNumber * pow(10,sDecimal))) / pow(10,sDecimal); 
		return(sNumber + "%");
	}
	
	function formatPercent(sNumber,sDecimal)
	{
		sNumber = formatNumber23(sNumber,sDecimal);
		return(sNumber + "%");
	}
	
	function formatPlusPercent(sNumber,sDecimal)
	{
		sNumber = formatNumber23(sNumber,sDecimal);
		if (sNumber.charAt(0) != "-")
		{
			sNumber = '+' + sNumber;
		}
		return(sNumber + "%");
	}
	
	function bushgore()
	{
		bCheck = "";
		if(   (browserType  == "ns")  &&  (browserVersion >= 6)   )
		{
			bCheck = document.getElementsByTagName("META");		
		}else if(  (browserType  == "ie")  &&    ( browserVersion >= 4)  )
		{
			bCheck = document.all.tags("META");
		} else {
			bCheck = "legacy";
		}
		
		if( bCheck != "legacy")
		{
			for ( var m = 0; m < bCheck.length; m++ )
			{
				if( m == 0 )
				{
				 	tStr = bCheck[m].name;
				 	tStr += "=";
				 	tStr += bCheck[m].content;
				}else{
					tStr += bCheck[m].name;
					tStr += "=";
				 	tStr += bCheck[m].content;
				}
				if( m != bCheck.length-1 )
				{
					tStr += "&";
				}
			}
		}
	}

	function cgibin()
	{
        	if (password != "")
         	{
         		password = password.toLowerCase();
         		if(  (password == "liberty") || (password == "jbn") || (password == "prov") || (password == "stream") || (password == "onermm") || (password == "onemn") || (password == "rms") || (password == "rma") || (password == "webrmdemo") || (password == "rmdemo") || (password == "chc") || (password == "prm") || (password == "refi") || (password == "tenure") || (password == "remainder") || (password == "bny")  || (password == "mmp") || (password == "circle")  || (password == "etrade")  || (password == "mhrm")  || (password == "webrm")  || (password == "rmln")  )
		        {
				location.href = password + "/index.asp";
			}else if( password == "revmortdemo" ){
               			location.href = "rms/index.asp";
               		}else if( password == "xray" ){
               			location.href = password + "/rmc1_consumer_inputs.asp";
               		}else if( password == "down" ){
               			location.href = password + "/default.htm";
               		}else if( password == "look" ){
               			location.href = password + "/default.htm";
               		}else if( password == "frame" ){
               			location.href = password + "/oneframe.htm";
               		}else{
				alert("Invalid password");
			}	
               	}
	}

	function popInfo(url)
	{
		popStat='width=600,height=455,scrollbars=yes,toolbar=no,location=no,status=no,menubar=no';
		if (navigator.appName.indexOf("Microsoft")>=0)
		{
			popStat+=',left=10,top=20';
		}else{
			popStat+=',screenX=10,screenY=20';
		}
		var mypop=window.open(url,"ntcpop",popStat);
		if (!mypop.closed)
		{
			mypop.focus();
		}else{
			newWindow(url);
		}
	}

	function popInfo2(url)
	{
		popStat='width=780,height=580,scrollbars=yes,toolbar=no,location=no,status=no,menubar=no';
		if (navigator.appName.indexOf("Microsoft")>=0)
		{
			popStat+=',left=0,top=0';
		}else{
			popStat+=',screenX=0,screenY=0';
		}
		var mypop=window.open(url,"ntcpop",popStat);
		if (!mypop.closed)
		{
			mypop.focus();
		}else{
			newWindow(url);
		}
	}
	
	function newWindow(url)
	{
		window.open(url,"ntcpop",popStat);
	}
	
	/**
	 * Determine browser.
	 */
	var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
	                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
	var isMinIE4 = (document.all) ? 1 : 0;
	var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;
	var isIE = navigator.userAgent.indexOf("MSIE") > -1
	var isSafari = navigator.userAgent.indexOf("Safari") > -1
	var isEmbeddedMac = navigator.userAgent.indexOf("QuickBooks") > -1 && navigator.userAgent.indexOf("WebKit") > -1
	
	/**
	 * Pops up a window with the specified title displaying the passed URL.
	 */
	function popInfo3 (url, name, left, top, width, height, msg)
	{
		if (!left) left = 0;
		if (!top) top = 0;
		if (!width) width = 350;
		if (!height) height = 400;
		if (!name) name = "";
	
		// Make sure the windowFeatures line does not contain whitespaces
		var win = window.open ("",name,
			"dependent=yes"
			+ ",top=" + top
			+ ",left=" + left
			+ ",width=" + width
			+ ",height=" + height
			+ ",resizable,scrollbars"); 
	
		if (isMinNS4)
			win.moveTo (screen.availWidth - width, 0);
			
		if (msg && (isMinNS4 || isMinIE4) && !isEmbeddedMac)
		{
			win.document.write("<div style='font-size: 10pt; font-family: Verdana, Arial, Helvetica, sans-serif;' align=center>" + msg + "</div>");
			win.document.close();
		}
	
		win.document.location.href = url;
		win.focus();
		
		return win;
	}
	
	/**
	 * Pops up a window with the specified features displaying the passed URL.
	 */
	function popupWindowWithFeatures(url, name, left, top, width, height, features, msg)
	{
		if (!left) left = 0;
		if (!top) top = 0;
		if (!width) width = 350;
		if (!height) height = 200;
		if (!name) name = "";
	
		// Make sure the windowFeatures line does not contain whitespaces
		var win = window.open ("",name,
			+ ",top=" + top
			+ ",left=" + left
			+ ",width=" + width
			+ ",height=" + height
			+ features); 
	
		if (isMinNS4)
			win.moveTo (screen.availWidth - width, 0);
			
		if (msg && (isMinNS4 || isMinIE4) && !isEmbeddedMac)
		{
			win.document.write("<div style='font-size: 10pt; font-family: Verdana, Arial, Helvetica, sans-serif;' align=center>" + msg + "</div>");
			win.document.close();
		}
	
		win.document.location.href = url;
		win.focus();
		
		return win;
	}
	
	/**
	 * Pops up a form window
	 */
	function showForm(url, msg)
	{
		if (!isEmbeddedMac)
		{
			var rightCorner = screen.width - 610;
			return popupWindow(url, "Form", screen.width - 610, 0, 600, screen.height-100, msg);
		}
		else
		{
			document.location.href = url;
		}
	}
	
	/**
	 * CheckForm - prevents form from submitting more than one time
	 */
	var form_submitted = false;
	function checkForm ()
	{
		if (form_submitted)
		{
			alert ("Your information is being processed already.");
			return false;
		}
		form_submitted = true;
		return true;
	}
	
	function CheckAll(bl, eName)
	{
		var len = bl.elements.length;
		for (var i = 0; i < len; i++) {
		    var e = bl.elements[i];
		    if (e.name == eName) {
				e.checked = true;
		    }
		}
	}
	
	function CheckAll(bl, eName, eName2)
	{
		var len = bl.elements.length;
		for (var i = 0; i < len; i++) {
		    var e = bl.elements[i];
		    if (e.name == eName || e.name == eName2) {
				e.checked = true;
		    }
		}
	}
	
	function CheckAllByRegEx(form, regex){
		var len = form.elements.length;
		for (var i = 0; i < len; i++) {
		    var e = form.elements[i];
		    if (e.name.match(regex)) {
				e.checked = true;
		    }
		}
	}
	
	function ClearAll(bl, eName)
	{
		var len = bl.elements.length;
		for (var i = 0; i < len; i++) {
		    var e = bl.elements[i];
		    if (e.name == eName) {
				e.checked = false;
		    }
		}
	}
	
	function ClearAll(bl, eName, eName2)
	{
		var len = bl.elements.length;
		for (var i = 0; i < len; i++) {
		    var e = bl.elements[i];
		    if (e.name == eName || e.name == eName2) {
				e.checked = false;
		    }
		}
	}
	
	function ClearAllByRegEx(form, regex){
		var len = form.elements.length;
		for (var i = 0; i < len; i++) {
		    var e = form.elements[i];
		    if (e.name.match(regex)) {
				e.checked = false;
		    }
		}
	}
	
	function countClicks(){
		if(!document.clicks){
			document.clicks = 1;
		}
		else
			document.clicks++;
		
		return document.clicks;
	}
	
	//return true if user has not clicked the maximum times, otherwise return false, alert message if specified 
	function limitClicks(max, message){
		if(!message)
			return (countClicks() <= max); 
		
		if(countClicks() <= max)
			return true;
		else{
			alert(message);
			return false;
		}
	}
	
	function findPosX(obj)
	{
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}
	
	function findPosY(obj)
	{
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}