function DisplayCurrentTime()
{
	var d = new Date()
	var t = d.getHours() + "." + d.getMinutes() + "." + d.getSeconds() + "." + d.getMilliseconds();
	alert(t);
}

function AppendMessage(s1, s2)
{
	if (s1 == null)
		return s2;

	if (s1.length == 0)
		return s1 + s2;
	else
		return s1 + ", "  + s2;
}

function AppendNewLine(s1, s2)
{
	if (s1 == null)
		return "\t\t" + s2;

	if (s1.length == 0)
		return s1 + "\t\t" +  s2;
	else
		return s1 + "\r" + "\t\t" + s2;
}

function Trim(s) 
{
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}

function isDate(s) 
{
	var datePattern = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)((\d{4})|(\d{2}))$/;	
	var matchArray = s.match(datePattern); // is the format ok?

	if (matchArray == null) 	
		return null;
	
	var month = matchArray[1]; // parse date into variables
	var day = matchArray[3];
	var year = matchArray[5];

	if (year.length == 2)
	{
		var now = new Date();
		year =  now.getFullYear().toString().substring(0,2) + year;
	}	
		
	if (month < 1 || month > 12)  // check month range
		return null;

	if (day < 1 || day > 31) 
		return null;

	if ((month==4 || month==6 || month==9 || month==11) && day==31) 
		return null;

	if (month == 2)  // check for february 29th
	{
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day > 29 || (day==29 && !isleap)) 
			return null;
	}
	
	return new Date(year, month-1, day); // date is valid
}

function isDateFullYear(s) 
{
	var datePattern = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)((\d{4}))$/;	
	var matchArray = s.match(datePattern); // is the format ok?

	if (matchArray == null) 	
		return null;
	
	var month = matchArray[1]; // parse date into variables
	var day = matchArray[3];
	var year = matchArray[5];
		
	if (month < 1 || month > 12)  // check month range
		return null;

	if (day < 1 || day > 31) 
		return null;

	if ((month==4 || month==6 || month==9 || month==11) && day==31) 
		return null;

	if (month == 2)  // check for february 29th
	{
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day > 29 || (day==29 && !isleap)) 
			return null;
	}
	
	return new Date(year, month-1, day); // date is valid
}

function IsSocial(s)
{	
	var socPattern = /^(\d{3})-?\d{2}-?\d{4}$/;
	var socArray = s.match(socPattern);
	var first;
	
	if (socArray == null)
		return false;
	
	first = socArray[1];
	//if (first < 100 || first > 899)
	//	return null;
		
	//return s;
	return true;
}

function CheckRange(value, lower, upper)
{
	var temp = removeChar(value, "-");
	
	if ((temp > lower) && (temp < upper))
		return true;

	return false;	
}

// TODO: replace all calls with IsPhone
function isPhone(s)
{
	return IsPhone(s);
}

function IsPhone(s)
{
	var phonePattern = /^(\d{3})-?\d{3}-?\d{4}$/;
	
	s = removeChar(s, ' ');
	s = removeChar(s, '(');
	s = removeChar(s, ')');
		
	var phoneArray = s.match(phonePattern);	
	if (phoneArray == null)
		return false;
		
	return true;
}

function isEmail(s)
{
	//var emailPattern =  /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;						
	var emailPattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var emailArray = s.match(emailPattern);
	
	if (emailArray == null)
		return false;
	
	return true;
}

function isZip(s)
{
	var zipPattern = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
	var zipArray = s.match(zipPattern);
	
	if (zipArray == null)
		return null;
		
	return s;
}

function isAlphaNumeric(s)
{
	// TODO: replace all calls with IsAlphaNumeric
	return IsAlphaNumeric(s);
}

function IsAlphaNumeric(s)
{
	var sPattern = (/^\w*$/);
	var sArray = s.match(sPattern);

	if (sArray == null)
		return false;
	else
		return true;	
}

function isOnlyAlpha(s)
{
	// TODO: Replace all calls to this function 
	// with call to IsAlpha
	return IsAlpha(s);
}

function IsAlpha(s)
{
	var sPattern = /^[A-Za-z]+$/;
	var sArray = s.match(sPattern);
	
	if (sArray == null)
		return false;
	else
		return true;	
}

function IsPassword(s)
{	
	var sPattern = /^\w*(?=\w*\d)(?=\w*[a-zA-Z])\w*$/;				
	var specialChars = "!@#$%^&*()-+=_{}/[]";	
	
	// Remove all special characters
	var temp = "";
	for (var i = 0; i < s.length; i++)
	{
		if (specialChars.indexOf(s.charAt(i)) == -1)
			temp += s.charAt(i);
	}
	
	// Check pattern
	var sArray = temp.match(sPattern);	
	if (sArray == null)
		return false;
	else
		return true;
}

function IsAddress(s)
{
	var temp;
	temp = removeChar(s, '.');
	temp = removeChar(temp, '\'');
	temp = removeChar(temp, '#');
	temp = removeChar(temp, ',');
	temp = removeChar(temp, '-');	
	temp = removeChar(temp, ' ');
	return IsAlphaNumeric(temp);
}

function IsCity(s)
{
	var temp;
	temp = removeChar(s, " ");
	temp = removeChar(temp, "-");
	return IsAlpha(temp);
}

function removeSpaces(sStr) 
{
	sStr = String(sStr);	// without this, fails if input type is numeric
    var s = '';
    for (var i = 0; i < sStr.length; i++) 
    {
        if (sStr.charAt(i) != ' ') s += sStr.charAt(i);
	} 
	return s;
}

function removeChar(sStr, c)
{
	sStr = String(sStr);	// without this, fails if input type is numeric
	var s = '';
	for (var i = 0; i < sStr.length; i++)
	{
		if (sStr.charAt(i) != c)
			s += sStr.charAt(i); 
	}
	return s;
}

function replaceChar(sStr, oldChar, newChar)
{
	sStr = String(sStr);	// without this, fails if input type is numeric
	var s = '';
	for (var i = 0; i < sStr.length; i++)
	{
		var thisChar = sStr.charAt(i);
		if (thisChar == oldChar)
			thisChar = newChar;
		s += thisChar;
	}
	return s;
}

function yearsOld(d)
{    
    today = new Date();
    temp = new Date();
    
    temp.setFullYear(d.getFullYear(), d.getMonth(), d.getDate());    
    years = today.getFullYear() - temp.getFullYear();
    temp.setYear( today.getFullYear() );
      
    if(today < temp)
    {
       years-- ;
    }
    
    return years;    
}

function FormatZip(obj)
{
	if (obj != null && obj.value != null)
	{
		var zip = "";
		for (var i = 0; i < obj.value.length; i++)
		{
			if (isNaN(obj.value.substr(i, 1)) == false && obj.value.substr(i, 1) != ' ')
			  zip += obj.value.substr(i, 1);
		}
		
		if (zip.length == 5)
			obj.value = zip;
		else if (zip.length == 9)
		{
			obj.value = zip.substr(0, 5) + "-" + zip.substr(5,4);
		}				
	}
}

// TODO: Replace all calls with FormatPhone
function formatPhone(obj)
{
	FormatPhone(obj);
}

function FormatPhone(obj)
{
	if (obj != null && obj.value != null)
	{	
		// first, strip off any characters other than digits
		var phone = "";
		for (var i = 0; i < obj.value.length; i++)
		{		
			if (isNaN(obj.value.substr(i, 1)) == false && obj.value.substr(i,1) != ' ')
				phone += obj.value.substr(i, 1);
		}
				
		if (phone.length == 10)
		{			
			obj.value="(" + phone.substr(0,3) +") " + phone.substr(3,3) + "-" + phone.substr(6,4)
		}		
	}
}

function formatSSN(obj)
{
	// TODO: replace all calls with FormatSSN
	FormatSSN(obj);
}

function FormatSSN(obj)
{
	if (obj != null && obj.value != null)
	{	
		var ssn = keepOnlyDigits(obj.value);
		if (ssn.length >= 9)
		{
			obj.value=ssn.substr(0,3) + "-" + ssn.substr(3,2) + "-" + ssn.substr(5,4)
		}
	}
}

function keepOnlyDigits( valu)		// parameter is a string
{
	var keep = "";
	for (var i = 0; i < valu.length; i++)
	{
		chr1 = valu.substr(i, 1);
		if (isNaN(chr1) == false && chr1 != ' ')
			keep += chr1;
	}
	return keep;
}

function CheckSSN(obj)
{
	var ssn = keepOnlyDigits(obj.value);
	if (ssn.length == 9)
	{	obj.value=ssn.substr(0,3) + "-" + ssn.substr(3,2) + "-" + ssn.substr(5,4)
		return true;
	}
	if (ssn.length == 0)
	{	obj.value = "";
		return true;
	}
	alert("Social Security Number must contain 9 numeric digits.");
	obj.focus();
	return false;
}

function formatDOB(obj)
{	
	FormatDate(obj);
}

var MONTH_NAMES = new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x) 
{
	return(x<0||x>9?"":"0")+x
}


function FormatDate(obj)
{
	if (obj != null && obj.value != null)
	{
		var dob = "";
		
		obj.value = replaceChar(obj.value, " ", "");
		var original = obj.value;
				
		dob = replaceChar(obj.value, ".", "/");
		dob = replaceChar(dob, "-", "/");
			
		// Format the date if it's inputted as ddmmyyyy
		if (original == dob)
		{			
			if (obj.value.length == 8)
			{
				dob = original.substr(0,2) + "/" + original.substr(2,2) + "/" + original.substr(4,8)
			}	
		}					
		
		
		var newDate = isDateFullYear(dob);
		if (newDate != null)
		{
			obj.value = FormatDateObject(newDate, "MM/dd/yyyy");
		}
	}
}

function isDateFormat(val,format) 
{
	var date=getDateFromFormat(val,format);
	if (date==0) { return false; }
	return true;
}

function FormatDateObject(date,format) 
{
	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
}

// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
function _isInteger(val) 
{
	var digits="1234567890";
	for (var i=0; i < val.length; i++) 
	{
		if (digits.indexOf(val.charAt(i))==-1) { return false; }
	}
	
	return true;	
}

function _getInt(str,i,minlength,maxlength) 
{
	for (var x=maxlength; x>=minlength; x--) 
	{
		var token=str.substring(i,i+x);
		if (token.length < minlength) { return null; }
		if (_isInteger(token)) { return token; }
	}
	
	return null;
}


function MultipleRequiredFieldValidatorEvaluateIsValid(val) 
{
	var result;	
	var ctrlsTemp = val.getAttribute('controlstovalidate');		
	var ctrls = ctrlsTemp.split(";");	
	var values = "";
	var valuesTemp = val.getAttribute('initialvalues');	
	if (valuesTemp != null)
		var values = valuesTemp.split(";");
			
	var i;
	for (i = 0; i < ctrls.length; i++)
	{
		result = (ValidatorTrim(ValidatorGetValue(ctrls[i])).length > 0)
		if (result == false)
			break;
		
		if (ValidatorTrim(ValidatorGetValue(ctrls[i])) == values[i])
			result = false;
		
		if (result == false)
			break;
    }
    
    return result;
}

function formatDecimals(c, decimalPositions)
{			
	if (isNaN(c)) 
	{
		return c;
	}
	else
	{
		var b = round( c, decimalPositions );
		c = b.toString();
		//errorCtrl.style.display = 'none';			
		var decimalPos = c.indexOf(".");			

		var ii = 3;
		if (decimalPos != -1)
			ii = (decimalPositions - (c.length - decimalPos - 1));
		else
			c += ".";
			
		
		for (var i = 1; i <= ii; i++)
			c += "0";	

		return c;		
	}			
}

function FormatDecimalsControl(ctrl, errorCtrl, decimalPositions)
{
	var value = "";		
	ctrl.value = ctrl.value.replace('%', '');

	for (var i = 0; i < ctrl.value.length; i++)
	{
		if (ctrl.value.substr(i, 1) == '.' || isNaN(ctrl.value.substr(i, 1)) == false)
			value += ctrl.value.substr(i, 1);
	}
	
	value = value.replace(' ', '');		
	ctrl.value = value;
	if (isNaN(ctrl.value))
	{		
		if (errorCtrl != null)
		{
			errorCtrl.innerText = "* Invalid entry*";
			errorCtrl.style.display = '';
		}
		
		if (ctrl != null)
		{
			ctrl.value = '0.00';
		}
	}
	else
	{
		if (errorCtrl != null)			
			errorCtrl.style.display = 'none';				
		
		value = formatDecimals(ctrl.value, decimalPositions);
		ctrl.value = value;
	}
	
}	

function FormatCurrency(c)
{
	//-- Returns passed number as string in $xxx,xxx.xx format.
	c = removeChar(c, ',');		// remove all commas
	c = c.replace('$', '');			
	if (isNaN(c))
	{		
		return '';			
	}
	workNum = Math.abs((Math.round(c*100)/100));		// round to cents (1/100)
	workStr = "" + workNum;
	if (workStr.indexOf(".") < 0)
	{
		workStr += ".00"
	}
	dStr = workStr.substr(0,workStr.indexOf("."));
	dNum = dStr - 0;
	pStr = workStr.substr(workStr.indexOf("."));
	while (pStr.length < 3)
		pStr += "0";

	//  Add comma in thousands place.
	if (dNum >= 1000) 
	{
		dLen = dStr.length;
		dStr = parseInt(""+(dNum/1000)) + "," + dStr.substring(dLen-3,dLen);
	}
	// Add comma in millions place.
	if (dNum >= 1000000) 
	{
		dLen = dStr.length;
		dStr = parseInt(""+(dNum/1000000)) + "," + dStr.substring(dLen-7,dLen);
	}
	retval = dStr + pStr;
	//-- Put numbers in parentheses if negative.
	if (c < 0) 
		retval = "(" + retval + ")";
	return retval;
}

function FormatCurrencyControl(ctrl, errorCtrl)
{	
	var value = "";
	ctrl.value = removeChar(ctrl.value, ",");		// remove all commas
	ctrl.value = ctrl.value.replace('$', '');
	
	for (var i = 0; i < ctrl.value.length; i++)
	{
		if (ctrl.value.substr(i, 1) == '.' || isNaN(ctrl.value.substr(i, 1)) == false)
			value += ctrl.value.substr(i, 1);
	}	
	
	ctrl.value = value;
	
	if (isNaN(ctrl.value))
	{
		if (errorCtrl != null)
		{
			errorCtrl.innerText = "* Invalid entry *";
			errorCtrl.style.display = '';
		}		
		
		if (ctrl != null)
		{		
				ctrl.value = '0.00';
		}
	}
	else
	{
		if (errorCtrl != null)			
			errorCtrl.style.display = 'none';				
			
		value = FormatCurrency(ctrl.value);
		ctrl.value = value;	
	}		
}

//returns the number of payment periods
function NPER(amountOfAnnualPaymentPeriods, rate, principle, paymentAmount)
{
	return -(
				Math.log(
						1-(principle/paymentAmount)*(rate/amountOfAnnualPaymentPeriods)
				)
			)/ Math.log(
						1+(rate/amountOfAnnualPaymentPeriods)
			);
} 

function PMT(Rate,NPer,PV) 
{
	return (PV * Rate)/(1-Math.pow(1+Rate,-NPer));
}

function round( a, b )
{
	return ( Math.round( a * Math.pow( 10, b ) ) / Math.pow( 10, b ) );
}

function ceiling( n1, n2 )
{
	return Math.floor((n1+n2 - 0.0000001)/n2)*n2;
}

function FV(Rate, NPer, Pmt, Amt )
{
	if ( Amt == null )
	{
		return Pmt * ( (Math.pow( (1 + Rate), NPer) - 1) / Rate );
	}
	{
		return (-Pmt + Math.pow(1+Rate,NPer) * Pmt + Rate * Math.pow(1+Rate,NPer) * Amt)/Rate;
	}
}

// TODO: replace all calls with properly named function (IsNumeric)
function isNumeric(element) 
{
	return IsNumeric(element);
}

function IsNumeric(element)
{
    if(element.value == "" || element.value == null || isNaN(element.value))
    {
		element.value = "";
		return false;
    }
    else 
    {
        return true;
    }
}

function toNumber( element )
{
	if ( isNumeric( element ) )
	{
		var result = new Number( element.value );
		return result;
	}
	else
	{
		return 0;
	}
}

function isIE()
{
	if ( document.all != null )
	{
		return true;
	}
	else
	{	
		return false;
	}
}    

function isNetscape()
{
	if ( document.layers )
	{
		return true;
	}
	else
	{
		return false;
	}
}
	
function setCtrlInvalid(obj)
{		
	obj.style.backgroundColor = 'red';
	obj.style.color = 'white';
}

function setCtrlValid(obj)
{		
	obj.style.backgroundColor = '';
	obj.style.color = '';
}

// TODO: Replace all calls with IsHint
function isHint(obj, str)
{		
	return IsHint(obj, str);
}

function IsHint(obj, str)
{
	if ((obj.value == str) && (obj.style.color == 'gray'))
		return true;	
					
	return false;
}

		
function SetHint(ctrl)
{	
	if ( (Trim(ctrl.value).length == 0) || (ctrl.value == ctrl.getAttribute('hint')) )
	{	
		ctrl.style.color = 'gray';
		ctrl.value = ctrl.getAttribute('hint');
		ctrl.style.backgroundColor = '';
	}
	//else
	//{				
	//	ctrl.style.color = 'black';
	//}
}

function RemoveHint(ctrl)
{
	if (isHint(ctrl, ctrl.getAttribute('hint')))	
		ctrl.value = "";	
	
	ctrl.style.color = 'black';
	
	//ctrl.focus();
	ctrl.select();
}

function ValidateHint(ctrl)
{
	SetHint(ctrl);
	DoClientValidate();
}

function DoClientValidate()
{	
	if (typeof(Page_ClientValidate) == 'function')
	{
		Page_ClientValidate();	
		CustomValidationSummaryOnSubmit(document.getElementById('SummaryValidator'), null);
	}	
}

function CustomValidationSummaryOnSubmit(val, args) 
{
	var result = true;
	
    var requiredFieldsFilled = true;
    var s;
           
    val.style.display = "";
    if (typeof(val.displaymode) != "string") 
    {
        val.displaymode = "BulletList";
    }
    switch (val.displaymode) 
    {
        case "List":
            headerSep = "<br>";
            first = "";
            pre = "";
            post = "<br>";
            tail = "";
            break;
        case "BulletList":
        default: 
            headerSep = "";
            first = "<ul>";
            pre = "<li>";
            post = "</li>";
            tail = "</ul>";
            break;
        case "SingleParagraph":
            headerSep = " ";
            first = "";
            pre = "";
            post = " ";
            tail = "<br>";
            break;
    }
    
    s = "";
    if (typeof(val.headertext) == "string") 
    {
        s += val.headertext + headerSep;
    }
    s += first;
            
	var nextVal;
	var reqFieldValFunc1 = "function RequiredFieldValidatorEvaluateIsValid";
	var reqFieldValFunc2 = "function MultipleRequiredFieldValidatorEvaluateIsValid";
	
    for (i=0; i<Page_Validators.length; i++) 
    {
		nextVal = Page_Validators[i];
		
		if (nextVal.id != val.id)
		{
			if (typeof(nextVal.evaluationfunction) == "function" && (nextVal.enabled == true || nextVal.enabled == null))
			{
				nextVal.isvalid = nextVal.evaluationfunction(nextVal); 
    
				if (!nextVal.isvalid) 
				{
					result = false;
										
					if ((nextVal.evaluationfunction.toString().substring(0, reqFieldValFunc1.length) == reqFieldValFunc1) || (nextVal.evaluationfunction.toString().substring(0, reqFieldValFunc2.length) == reqFieldValFunc2))
					{
						if (requiredFieldsFilled == true)
						{
							// first time -- keep the validator, but change the text
							s += pre + val.RequiredFieldErrorMessage + post;
							requiredFieldsFilled = false;
						}						
					}
					else 	
					{
						s += pre + nextVal.ErrorMessage + post;
					}						
				}
			}
		}
	}
    s += tail;
        
    if (result == true)
		val.innerHTML = "";
	else
		val.innerHTML = s;
		
    window.scrollTo(0,0);        
    
    if (args != null)
		args.IsValid = result;
		
	if (result == false)
		document.getElementById('Attention').style.display = 'inline';
	else
		document.getElementById('Attention').style.display = 'none';
    return result; 
}

function EnableValidatorCtrl(ctrl, enable)
{
	// NOTE: Let's keep it simple, if ValidatorEnable is supported then
	// call it otherwise don't do anything else since it might not
	// be supported by other browsers anyway
	if (typeof(ValidatorEnable) == 'function')		
		ValidatorEnable(ctrl, enable);
	/*else
	{
		if (enable == false)		
			ctrl.style.display = 'none';	// not supported in firefox, netscape
		else
			ctrl.style.display = '';		// not supported in firefox, netscape
			
		ctrl.enabled = enable;		
	}*/	
}


function ValidateName(source, args, ctrl, msg, maxLength, isLastName)
{
	var flag = true;
	
	if (isHint(ctrl, ctrl.getAttribute('hint')) == false)
	{
		if (Trim(ctrl.value).length != 0)
		{
			// Handle special case for last name
			if (isLastName == true)
			{
				// Remove special chars in last name and validate
				var temp = removeChar(ctrl.value, " ");
				temp = removeChar(temp, ".");
				temp = removeChar(temp, "-");
				temp = removeChar(temp, "'");
				temp = removeChar(temp, ",");
				
				if (IsAlphaNumeric(temp) == false)
					flag = false;
					
				if (temp.length <= 2)
					flag = false;
			}
			else	// All other name fields
			{
				if (isOnlyAlpha(removeSpaces(ctrl.value)) == false)
					flag = false;
				else if (ctrl.value.length > maxLength)
					flag = false;
			}
		}
		
		if (flag == true) setCtrlValid(ctrl);
		else setCtrlInvalid(ctrl);
	}
	
	if (source != null)
		if (flag == false) source.ErrorMessage = msg;
		
	if (args != null)
	{
		args.IsValid = flag;
		return args.IsValid;
	}
}

function FormatInvalidFirstName(s)
{
	return (s + " is invalid. Only letters are allowed.");
}

function FormatInvalidMiddleName(s)
{
	return (s + " is invalid. Only one letter is allowed.");
}

function FormatInvalidLastName(s)
{
	return (s + " is invalid. Must contain at least two characters with only letters, numbers and special characters ( .,'- ) allowed.");
}

function FormatInvalidFormerNames(s)
{
	return (s + " is invalid. Must contain at least two characters with only letters, numbers and special characters ( .,'- ) allowed.");
}

function FormatInvalidPhoneNumber(s)
{
	return (s + " is invalid. Only numbers are allowed in the following format: (###) ###-####.");
}

function FormatInvalidZipCode(s)
{
	return (s + " is invalid. Only numbers are allowed in the following format: #####-#### or #####.");
}

function FormatInvalidSSN(s)
{
	return (s + " is invalid. Only numbers are allowed and must be between the ranges of 001-01-0001 and 799-99-9999.");
}

function FormatInvalidDate(s)
{
	return (s + " is invalid. Date must be in mm/dd/yyyy format.");
}

function FormatInvalidEMail(s)
{
	return (s + " is invalid. It must include the @ symbol and the domain. Only letters, numbers and special characters ( ._@ ) are allowed.");
}

function FormatInvalidDriverLicense(s)
{
	return (s + " is invalid. Only numbers and letters are allowed.");
}

function FormatInvalidAddress(s)
{
	return (s + " is invald. Only letters, numbers and special characters ( #,.'- ) are allowed.");
}

function FormatInvalidCity(s)
{
	return (s + " is invalid. Only letters and ( - ) are allowed.");
}

function FormatInvalidEmployerName(s)
{
	return (s + " is invalid. Only letters, numbers and special characters ( .- ) are allowed.");
}

function FormatInvalidAccountNumber(s)
{
	return (s + " is invalid. Only letters, numbers and special characters ( - ) are allowed.");
}

function FormatInvalidLenderName(s)
{
	return (s + " is invalid. Only letters, numbers and special characters ( .- ) are allowed.");
}

function FormatInvalidUserID(s)
{
	return (s +  " is invalid. Must contain at least 8 alpha-numeric characters with at least 1 letter.");
}

function FormatInvalidPassword(s)
{
	return (s + " is invalid. Must be at least 8 characters and contain one letter and number. Special characters !@#$%^&*()-+=_/[]{} are allowed.");
}

function FormatInvalidEmployerName(s)
{
	return (s + " is invalid. Only letters, numbers and special characters ( .- ) are allowed.");
}

function FormatInvalidBalance(s)
{
	return (s + " is invalid. Only positive numbers and special characters ( ,. ) are allowed.");
}

function FormatInvalidCreditorName(s)
{
	return (s + " is invalid. Only letters, numbers and special characters ( ./)(-,\ ) are allowed.");
}

function NavImageSwap(strItem, bolOnOff, intImgPath)
{	
	// Set path to images folder
	var imgPath;	
	imgPath = '/images/';

	// Mouseout / mouseover for image
	if (bolOnOff == 0)
	{
		document.getElementById(strItem).src = imgPath + strItem + '-Off.jpg';
	}	
	else
	{
		document.getElementById(strItem).src = imgPath + strItem + '-On.jpg';
	}
}

function LeftNavBulletSwap(strItem, bolOnOff, intImgPath)
{	
	// Set path to images folder
	var imgPath;
	if (intImgPath == 0)
	{
		imgPath = 'images/';
	}
	else
	{
		imgPath = '../images/';
	}
	// Mouseout / mouseover for bullet
	if (bolOnOff == 0)
	{
		document.getElementById(strItem).src = imgPath + 'DkGrBullet-Off.gif';
	}	
	else
	{
		document.getElementById(strItem).src = imgPath + 'DkGrBullet-On.gif';
	}
}

// Chat Window Popup

function openWindowChat() {
		chatWindow = window.open
		('http://www.whitepajama.net/scholarpoint/SC/sc_center.php?function=sc_chat_list_queue&tenant=scholarpoint&channel=106&channel_name=Customer%20Support', 'chatWin', 'width=445, height=600, scrollbars=yes')
		chatWindow.focus()
}

// Payment Schedule Window Popup

function openWindowSchedule() {
		scheduleWindow = window.open
		('/Consolidation/PaymentSchedule.aspx', 'scheduleWin', 'width=570, height=350, scrollbars=yes')
		scheduleWindow.focus()
}

// HelpMe Window Popup

function openWindowHelpMe() {
		helpmeWindow = window.open
		('/Consolidation/HelpMeChoose.aspx', 'helpmeWin', 'width=282, height=490, scrollbars=yes')
		helpmeWindow.focus()
}

// New Nav Rollovers

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

