document.write(CalendarPopup_getStyles());

ns4 = (document.layers) ? true:false;
ng5 = (document.getElementById) ? true:false;
if(document.all && !document.getElementById) {
	ng5 = true;
    document.getElementById = function(id) {
         return document.all[id];
    }
}

if (ns4){
	alert ("This site will not function properly with the current browser you are using.  Please use a newer browser");
}

function TogVis(layerid){
	var sec=document.getElementById(layerid);
	if (sec.style.visibility == 'hidden'){
		sec.style.visibility = 'visible';
		sec.style.position = 'relative';
	}else{
		sec.style.visibility = 'hidden';
		sec.style.position = 'absolute';
	}
}

function EnableIt(form){
	var bcolor = "#FFFFFF";
	form.disabled=false;
	form.style.backgroundColor = bcolor;
}

function DisableIt(form){
	var bcolor = "#EBE6DE";
	form.disabled=true;
	form.style.backgroundColor = bcolor;
}

function OpenWin(win) {
	var largewin=window.open(win,'large','scrollbars=yes,height=421,width=650,left=20,top=30');
	largewin.focus();
}


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;
}

function y2k(number) { return (number < 1000) ? number + 1900 : number; }

function isValidDate (field) {
	if (field.value==""){
		return;
	}
	var d=parseDate(field.value);

	if (d == null){
		alert("Invalid Date");
		field.focus();
		return;
	}

	d=formatDate(d, "MM/dd/yyyy");

	if (d == null){
		alert("Invalid Date");
		field.focus();
		return;
	}

	count = 0;
	pos = d.indexOf("/");
	while ( pos != -1 ) {
	   count++;
	   pos = d.indexOf("/",pos+1);
	}
	if (count != 2){
		alert("Invalid Date");
		field.focus();
	}

	var date_array=d.split("/");

	var month = date_array[0];
	var day = date_array[1];
	var year = date_array[2];

	// checks if date passed is valid
	// will accept dates in following format:
	// isDate(dd,mm,ccyy), or
	// isDate(dd,mm) - which defaults to the current year, or
	// isDate(dd) - which defaults to the current month and year.
	// Note, if passed the month must be between 1 and 12, and the
	// year in ccyy format.

    var today = new Date();
    year = ((!year) ? y2k(today.getYear()):year);
    month = ((!month) ? today.getMonth():month-1);
    if (!day) return false
    var test = new Date(year,month,day);
    if ( (y2k(test.getYear()) == year) &&
         (month == test.getMonth()) &&
         (day == test.getDate()) ){
		field.value=d;
        return true;
	}else{
		alert("Invalid Date");
		field.focus();
	}
}


function parseDate(val) {
	var preferEuro=(arguments.length==2)?arguments[1]:false;
	generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
	monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
	dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
	var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
	var d=null;
	for (var i=0; i<checkList.length; i++) {
		var l=window[checkList[i]];
		for (var j=0; j<l.length; j++) {
			d=getDateFromFormat(val,l[j]);
			if (d!=0) { return new Date(d); }
			}
		}
	return null;
	}

function getDateFromFormat(val,format) {
	val=val+"";
	format=format+"";
	var i_val=0;
	var i_format=0;
	var c="";
	var token="";
	var token2="";
	var x,y;
	var now=new Date();
	var year=now.getYear();
	var month=now.getMonth()+1;
	var date=1;
	var hh=now.getHours();
	var mm=now.getMinutes();
	var ss=now.getSeconds();
	var ampm="";
	
	while (i_format < format.length) {
		// Get next token from format string
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		// Extract contents of value based on format token
		if (token=="yyyy" || token=="yy" || token=="y") {
			if (token=="yyyy") { x=4;y=4; }
			if (token=="yy")   { x=2;y=2; }
			if (token=="y")    { x=2;y=4; }
			year=_getInt(val,i_val,x,y);
			if (year==null) { return 0; }
			i_val += year.length;
			if (year.length==2) {
				if (year > 70) { year=1900+(year-0); }
				else { year=2000+(year-0); }
				}
			}
		else if (token=="MMM"||token=="NNN"){
			month=0;
			for (var i=0; i<MONTH_NAMES.length; i++) {
				var month_name=MONTH_NAMES[i];
				if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
					if (token=="MMM"||(token=="NNN"&&i>11)) {
						month=i+1;
						if (month>12) { month -= 12; }
						i_val += month_name.length;
						break;
						}
					}
				}
			if ((month < 1)||(month>12)){return 0;}
			}
		else if (token=="EE"||token=="E"){
			for (var i=0; i<DAY_NAMES.length; i++) {
				var day_name=DAY_NAMES[i];
				if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
					i_val += day_name.length;
					break;
					}
				}
			}
		else if (token=="MM"||token=="M") {
			month=_getInt(val,i_val,token.length,2);
			if(month==null||(month<1)||(month>12)){return 0;}
			i_val+=month.length;}
		else if (token=="dd"||token=="d") {
			date=_getInt(val,i_val,token.length,2);
			if(date==null||(date<1)||(date>31)){return 0;}
			i_val+=date.length;}
		else if (token=="hh"||token=="h") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>12)){return 0;}
			i_val+=hh.length;}
		else if (token=="HH"||token=="H") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>23)){return 0;}
			i_val+=hh.length;}
		else if (token=="KK"||token=="K") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>11)){return 0;}
			i_val+=hh.length;}
		else if (token=="kk"||token=="k") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>24)){return 0;}
			i_val+=hh.length;hh--;}
		else if (token=="mm"||token=="m") {
			mm=_getInt(val,i_val,token.length,2);
			if(mm==null||(mm<0)||(mm>59)){return 0;}
			i_val+=mm.length;}
		else if (token=="ss"||token=="s") {
			ss=_getInt(val,i_val,token.length,2);
			if(ss==null||(ss<0)||(ss>59)){return 0;}
			i_val+=ss.length;}
		else if (token=="a") {
			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
			else {return 0;}
			i_val+=2;}
		else {
			if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
			else {i_val+=token.length;}
			}
		}
	// If there are any trailing characters left in the value, it doesn't match
	if (i_val != val.length) { return 0; }
	// Is date valid for month?
	if (month==2) {
		// Check for leap year
		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
			if (date > 29){ return 0; }
			}
		else { if (date > 28) { return 0; } }
		}
	if ((month==4)||(month==6)||(month==9)||(month==11)) {
		if (date > 30) { return 0; }
		}
	// Correct hours value
	if (hh<12 && ampm=="PM") { hh=hh-0+12; }
	else if (hh>11 && ampm=="AM") { hh-=12; }
	var newdate=new Date(year,month-1,date,hh,mm,ss);
	return newdate.getTime();
	}

function fn(form,field)
{

var next=0, found=false
var f=form
if(event.keyCode!=13) return;
for(var i=0;i<f.length;i++)
	{
	if(field.name==f.item(i).name) 
	{
		next=i+1;
		found=true
		break;
	}
	}
if (f.item(next)){
while(found)  //Infinite loop 
	{
	if(f.item(next).disabled==false && f.item(next).type!='hidden')
//	if(field.name==f.item(i).name) 
		{
		f.item(next).focus();
		break;
		}
	else
		{
		if(next<f.length-1)
			next=next+1;
		else
			break;		
		}
	}
}else{
doyou = confirm("Would you like to submit the form?");

if (doyou == true){

	f.submit();
}
}
}
function disableEnterKey(e)
{
		if (window.event.keyCode == 13) window.event.keyCode = 0;
}



function ValidatePhone(form, e){

	if(window.event) {
		// for IE, e.keyCode or window.event.keyCode can be used
		k = e.keyCode; 
	}
	else if(e.which) {
		// netscape
		k = e.which; 
	}

	if (k == 13){
		fn(form.form, form);
	}
	if (k == 8 || k == 46 || k == 37  || k == 39 || k == 9 || k == 16){
		return;
	}

	p = form.value.replace(/[\(\)\.\-\ ]/g, '');

	var a=p.substring(0,3);
	var b=p.substring(3,6);
	var c=p.substring(6,10);

	if (p.length >= 3 && p.length < 4){
		form.value = "("+a+") ";
	}
	if (p.length >= 6 && p.length < 7){
		form.value = "("+a+") "+ b + "-";
	}
	if (p.length > 9){
		form.value = "("+a+") " + b + "-" + c;
	}

}

function ValidatePhoneold(p1){
var n;
var p;

if (event.keyCode == 8 || event.keyCode == 46){
	return;
}

p=p1.value;
if(p.length==3 || p.length==4){
	pp=p;
	d4=p.indexOf('(')
	d5=p.indexOf(')')
	if(d4==-1){
		pp="("+pp;
	}
	if(d5==-1 && d4==-1){
		pp=pp+") ";
	}
	//pp="("+pp+")";
	p1.value="";
	p1.value=pp;
}
if(p.length>3){
	d1=p.indexOf('(')
	d2=p.indexOf(') ')
	if (d2==-1){
		l30=p.length;
		p30=p.substring(0,4);
		//alert(p30);
		p30=p30+") "
		p31=p.substring(5,l30);
		pp=p30+p31;
		//alert(p31);
		p1.value="";
		p1.value=pp;
	}
	}
if(p.length>6){
	p11=p.substring(d1+1,d2);
	if(p11.length>3){
	p12=p11;
	l12=p12.length;
	l15=p.length
	//l12=l12-3
	p13=p11.substring(0,5);
	p14=p11.substring(3,l12);
	p15=p.substring(d2+1,l15);
	p1.value="";
	pp="("+p13+") "+p14+p15;
	p1.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
	l16=p.length;
	p16=p.substring(d2+1,l16);
	l17=p16.length;
	if(l17>3&&p16.indexOf('-')==-1){
		p17=p.substring(d2+1,d2+5);
		p18=p.substring(d2+5,l16);
		p19=p.substring(0,d2+1);
		//alert(p19);
	pp=p19+p17+"-"+p18;
	p1.value="";
	p1.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
}
//}
}

function testphone(obj1){
	p=obj1.value
	p=p.replace("(","")
	p=p.replace(") ","")
	p=p.replace("-","")
	p=p.replace("-","")
	if (isNaN(p)==true || (p.length >=1 && p.length != 10)){
		alert("Please check phone number");
		obj1.focus();
		return false;
	}
}

function jsFunc(form) {
if (form.g.length < 5){return;}
 for (var i=0; i < jsArray1.length; i++)
 {
   if (form.g.value == jsArray1[i]) {
	 form.h.value = jsArray2[i]; 
    }
 }
}

function formatSocial(objFormField){
 intFieldLength = objFormField.value.length;
 if(intFieldLength==3 || intFieldLength == 6){
      objFormField.value = objFormField.value + "-";
           return false;
 }
}
//====================================================================
/* Allow only numbers in the SSN field.
  HOWEVER, it will allow the " - " in the formatSocial() script.
*/
function checkIt(evt) { 
     evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
         alert("This field accepts numbers only."); //You can Comment this line out if you do not want to alert the user.
         status = "This field accepts numbers only."
         return false
    }
    status = ""
    return true
}


function isCurrency(f)
{
	var nNum = 0;			// Total numbers for currency value.
	var nDollarSign = 0;	// Total times a dollar sign occurs.
	var nDecimal = 0;		// Total times a decimal point occurs.
	var nCommas = 0;		// Total times a comma occurs.
	var txtLen;				// Length of string passed.
	var xTxt;				// Assigned object passed.
	var sDollarVal;			// Assigned dollar amount with or without commas.
	var bComma;				
	var decPos;				// Assigned value of numbers or positions after decimal point.
	var nNumCount = 0;		// Total number between commas.
	var i;					// For forloop indexing.
	var x;					// Assigned each indivual character in string.
	
	// Set the xTxt variable to the object passed to this function.
	// Assign the length of the string to txtLen.
	xTxt = f;
	txtLen = xTxt.value.length

	for(i = 0; i < txtLen; i++)
	{
		// Assign charater in substring to x.
		x = xTxt.value.substr(i, 1);
		
		
//		if(x == "$")
//			nDollarSign = nDollarSign + 1; // Sum total times dollar sign occurs.
		if(x == ".")
			nDecimal = nDecimal + 1; // Sum total times decimal point occurs.
//		else if(x == ",")
//			nCommas = nCommas + 1; // Sum total times comma occurs.
		else if(parseInt(x) >= 0 || parseInt(x) <= 9)
			nNum = nNum + 1; // If the character is a number sum total times a number occurs.
		else
		{
			// Error occurs if any other character value is in the string
			// othere then the valid characters.
			alert("ERROR! \n\nYou have entered an illegal value!\nPlease enter only: " +
				  " Decimal Points, and numbers between 0...9!");
			return false;
		} // end else
	} // end for

	if(nDollarSign > 1)
	{
		alert("ERROR! \n\nYou have entered more then one dollar sign!\nPlease only enter one!");
		return false;
	} // end if
		
	if(nDecimal > 1)
	{
		alert("ERROR! \n\nYou have entered more then one decimal point!\nPlease only enter one!");
		return false;
	} // end if
		
	if(nDollarSign == 1)
	{
		// Make sure dollar sign in the first character in string
		// if there is a dollar sign present.
		if(xTxt.value.indexOf("$") != 0)
		{
			alert("ERROR!  \n\nThe dollar sign you entered is not in the correct position!");
			return false;
		} // end if
	}// end if
	
	if(nDecimal == 1)
	{
		// Get the number of numbers after the decimal point in
		// the string if there is a decimal point present
		decPos = (txtLen - 1) - xTxt.value.indexOf(".");
		
		// Floating point cannot be more then two.
		// Valid format after decimal point.
		/**********************************/
		/*   $#.##, $#.#, $.#, $#., $.##  */
		/**********************************/
		if(decPos > 2)
		{
			alert("ERROR! \n\nThe decimal point you entered is not in the correct position!");
			return false;
		} // end if
	} // end if
	
	if(nCommas == 0)
	{
		// If no commas are present value is a valid US
		// currency.
		return true;
	}
	else
	{
		// Get total number of dollar number(s), removing
		// floating point numbers or cents.
		nNum = nNum - decPos;
		
		// Determine if dollar sign is in string so to be 
		// removed.
		// After determining dollar sign, assign sDollarVal
		// numbers and comma(s)
		if(xTxt.value.indexOf("$", 0) == 0)
			sDollarVal = xTxt.value.substr(1, (nNum + nCommas));
		else
			sDollarVal = xTxt.value.substr(0, (nNum + nCommas));
		
		
		// Determine if a zero is the first number or if a
		// comma is the first or last character in the string.
		if(sDollarVal.lastIndexOf("0", 0) == 0 )
		{
			alert("ERROR! \n\nYou cannot start the dollar amount out with a zero!");
			return false;
		}
		else if(sDollarVal.lastIndexOf(",", 0) == 0)
		{
			alert("ERROR! \n\nYou cannot start the dollar amount out with a comma!");
			return false;
		}
		else if(sDollarVal.indexOf(",", (sDollarVal.length - 1)) == (sDollarVal.length - 1))
		{
			alert("ERROR! \n\nYou cannot end the dollar amount with a comma!");
			return false;
		}
		else
		{
			// Initialize bComma indicating a comma has not been
			// occured yet.
			bComma = false;
			for(i = 0; i < sDollarVal.length; i++)
			{
				// Assign charater in substring to x.
				x = sDollarVal.substr(i, 1);
				
				if(parseInt(x) >= 0 || parseInt(x) <= 9)
				{
					// If x is a number add one to the number counter.
					nNumCount = nNumCount + 1;
					
					// Sense comma(s) are present number counter cannot
					// be more then three before the first or next comma.
					if(nNumCount > 3)
					{
						alert("ERROR! \n\nYou have a mis-placed comma!");
						return false;
					} // end if
				}
				else
				{
					// If the number counter is less then three and
					// the comma indicator is true the comma is either
					// mis-placed or there are not enough values.
					if(nNumCount != 3 && bComma)
					{
						alert("ERROR! \n\nYou have a mis-placed comma!");
						return false;
					} // end if
					
					// Reset the number counter back to zero.
					nNumCount = 0;
					
					// Set the comma indicator to true indicating
					// that the first comma has been found and that
					// there now MUST be three numbers after each
					// comma until the loop hits the end.
					bComma = true;
				} // end if
			} // end for
			
			// Determine if after the loop ended that there
			// was a total of three final numbers after the
			// last comma.
			if(nNumCount != 3 && bComma)
			{
				alert("ERROR! \n\nYou have a mis-placed comma!");
				return false;
			} // end if
		} // end if
	} // end if
	
	// Return true indicating that the value is a valid
	// currency.
	return true;
}


