var startspaces		= /^\s+/
var ExpSearchable	= /^[a-zA-Z0-9\.\-]*$/i
var ExpEmail		= /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i
var ExpDate			= /^(0?[1-9]|1[0-2])\/(0?[1-9]|[1-2][0-9]|3[0-1])\/[1,2][0-9]{3}$/i

String.prototype.trim = trim_spaces;

function isDigit (x_strChar)
{   
	return ((x_strChar >= "0") && (x_strChar <= "9"));
}

function IsNumericValue(objValue)
{
	if (objValue.length == 0) 
	{
		return false;
	}
	
	for (var intStringCounter = 0; intStringCounter < objValue.length; intStringCounter++)
	{
		if (!isDigit(objValue.substring(intStringCounter, intStringCounter + 1)))
		{
			return false;
		}
	}
	return true;
}

function trim_spaces(from_where) {
    // Store the string in a temporary variable    
    var temp_string = this;

    // If no argument, then trim from both sides
    if (arguments.length == 0) {
        from_where = "BOTH";
    }
    
    // Trim spaces from the left
    if (from_where.toUpperCase() == "LEFT" || from_where == "BOTH") {
        while (temp_string.left(1) == " ") {
            temp_string = temp_string.substring(1);
        }
    }
    
    // Trim spaces from the right
    if (from_where.toUpperCase() == "RIGHT" || from_where == "BOTH") {
        while (temp_string.right(1) == " ") {
            temp_string = temp_string.substring(0, temp_string.length - 1);
        }
    }
    return temp_string;   

}

function MakeDate(x_dteDate)
{
	var intYear;
	var intMonth;
	var intDay;
	
	var intYear = GetInputYear(x_dteDate) * 1;
	var intMonth = GetInputMonth(x_dteDate) * 1;
	var intDay = GetInputDay(x_dteDate) * 1;

	var dteDate = new Date(intYear, intMonth -1, intDay, 0, 0, 1);

	// return the new date object
	return dteDate;
}
		
function CompareDates(x_dteStart, x_dteEnd)
{
	//Test that the Start Date hasen't already past the End Date
	if(x_dteStart >= x_dteEnd)
	{
		return false;
	}
	return true;
}

function openPopUpWindow(linkURL, openWidth, openHeight, XPos, YPos) 
{
	var newWind = window.open(linkURL,'display','resizable,scrollbars=yes,width='+openWidth+',height='+openHeight+',screenX='+XPos+',screenY='+YPos);
	
	if (newWind.opener == null)
	{
		newWind.opener = window;
	}
	
	newWind.focus();
	
	return false;
}

function stripChars(x_strPattern, x_strString) 
{
	return x_strString.replace(x_strPattern, "");
}

function isEmptyValue(x_objValue)
{
 	x_objValue = stripChars(startspaces, x_objValue);
	
 	if (x_objValue.length < 1) 
	{
 		return true;
 	}
	else
	{
		return false;
	}
}

function isValid(pattern, str) 
{
	return pattern.test(str);
}

function openFileWindow(linkURL) 
{
	var newWind = window.open(linkURL,'display','toolbar=no,location=0,directories=0,menubar=yes,resizable=1,scrollbars=yes,');
	
	if (newWind.opener == null)
	{
		newWind.opener = window;
	}
	
	newWind.focus();
	
	return false;
}

function VersionNavigateur(Netscape, Explorer) 
{
	if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') || (navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
	{
		return true;
	}
	else
	{ 
		return false;
	}
}

function EditSection(x_strTargetPage, x_intSectionID, x_intLayoutID)
{
	document.frmEdit.hdnTargetPage.value = x_strTargetPage;
	document.frmEdit.hdnSectionID.value = x_intSectionID;
	document.frmEdit.hdnActionMode.value = 'Edit';
	document.frmEdit.hdnLayoutID.value = x_intLayoutID;
		
	document.frmEdit.submit();
}

function OpenLayoutWindow(linkURL, openWidth, openHeight) 
{
	var XPos = screen.availWidth/2;
	var YPos = screen.availHeight/2;
	
	var newWind = window.open('images/'+linkURL,'display','resizable=0,scrollbars=no,width='+(openWidth + 10)+',height='+(openHeight + 10)+',screenX='+XPos+',screenY='+YPos);
	
	if (newWind.opener == null)
	{
		newWind.opener = window;
	}
	
	newWind.focus();
}

function Preview(x_strTargetPage, x_intSectionID, x_intDestination)
{
	
	document.frmEdit.hdnTargetPage.value = x_strTargetPage;
	document.frmEdit.hdnSectionID.value = x_intSectionID;
	
	if (x_intDestination == 1)
	{
		document.frmEdit.hdnDestination.value = 'Preview.asp';
		document.frmEdit.action = 'admProcessImages.asp';
	}
	else
	{
		document.frmEdit.action = 'Preview.asp';
	}
	
	document.frmEdit.submit();
}

function PreviewTransaction(x_lngTransactionID)
{
	document.frmEdit.hdnTargetPage.value = '';
	document.frmEdit.hdnSectionID.value = x_lngTransactionID;
	document.frmEdit.action = 'Preview.asp';
	
	document.frmEdit.submit();
}

function AddSection(x_strTargetPage, x_intSectionID)
{
	
	for(var i = 0; i < window.document.frmEdit.elements.length; i++)
	{
		document.frmEdit.elements[i].value = '';
	}

	document.frmEdit.hdnTargetPage.value = x_strTargetPage;
	document.frmEdit.hdnSectionID.value = x_intSectionID;
	document.frmEdit.hdnActionMode.value = '';
	document.frmEdit.action = 'EditSections.asp';
		
	document.frmEdit.submit();
}

function InActivate(x_strTargetPage, x_intSectionID)
{
	document.frmEdit.hdnTargetPage.value = x_strTargetPage;
	document.frmEdit.hdnSectionID.value = x_intSectionID;
	document.frmEdit.hdnActionMode.value = 'Inactive';
	document.frmEdit.action = 'EditSections.asp';
		
	document.frmEdit.submit();
}

function Activate(x_strTargetPage, x_intSectionID)
{
	document.frmEdit.hdnTargetPage.value = x_strTargetPage;
	document.frmEdit.hdnSectionID.value = x_intSectionID;
	document.frmEdit.hdnActionMode.value = 'Active';
	document.frmEdit.action = 'EditSections.asp';
	
	document.frmEdit.submit();
}

function ChangeLayout()
{
	document.frmEdit.hdnActionMode.value = '';
	document.frmEdit.hdnLayoutID.value = document.frmEdit.selLayout[document.frmEdit.selLayout.selectedIndex].value;
	
	document.frmEdit.submit();
}

function SaveSection(x_strTargetPage, x_intSectionID)
{
	document.frmEdit.hdnTargetPage.value = x_strTargetPage;
	document.frmEdit.hdnSectionID.value = x_intSectionID;
	document.frmEdit.hdnActionMode.value = 'Save';
	
	if ((document.frmEdit.selLayout[document.frmEdit.selLayout.selectedIndex].value=='5') || (document.frmEdit.selLayout[document.frmEdit.selLayout.selectedIndex].value=='11'))
	{
		document.frmEdit.hdnLayoutID.value = document.frmEdit.selLayout[document.frmEdit.selLayout.selectedIndex].value;
		document.frmEdit.enctype = 'multipart/form-data';
		document.frmEdit.action = 'admProcessImages.asp';
		document.frmEdit.hdnDestination.value = 'EditSections.asp';
	}
	
	document.frmEdit.submit();
}

function Approve(x_lngTransactionID, x_strEffectiveDate)
{
	var strDate;
	var x;
	var blnValidEffectiveDate;
	var blnBreakLoop;
	
	blnValidEffectiveDate = false;
	
	if (confirm('Are you sure you would like to Approve transaction #' + x_lngTransactionID + ' ?'))
	{
		blnValidEffectiveDate = false;
		blnBreakLoop = false;
		
		document.frmEdit.hdnTransactionID.value = x_lngTransactionID;
		
		strDate = (prompt("Please confirm the effective date.", x_strEffectiveDate));
		x = 1;
		
		if (strDate != null)
		{
			while (!blnBreakLoop)
			{
				if (!isValidDate(strDate, "Effective Date"))
				{
					strDate = (prompt("Please confirm the effective date. [mm/dd/yyyy]", x_strEffectiveDate));
				
					if (strDate != null)
					{
						if (x == 4)
						{
							strDate = x_strEffectiveDate;
							blnValidEffectiveDate = true;
							blnBreakLoop = true;
						}
					}
					else
					{
						blnValidEffectiveDate = false;
						blnBreakLoop = true;
					}
					
					x++;
				}
				else
				{
					blnValidEffectiveDate = true;
					blnBreakLoop = true;
				}
			}
		}
		else
		{
			blnValidEffectiveDate = false;
		}
		
		if (blnValidEffectiveDate)
		{
			document.frmEdit.hdnEffectiveDate.value = strDate;
			document.frmEdit.hdnActionMode.value = 'Approved';
			document.frmEdit.action = 'PendingRequests.asp';
			
			document.frmEdit.submit();
		}
	}
}

function Decline(x_lngTransactionID)
{
	if (confirm('Are you sure you would like to Decline transaction #' + x_lngTransactionID + ' ?'))
	{
		document.frmEdit.hdnTransactionID.value = x_lngTransactionID;
		document.frmEdit.hdnActionMode.value = 'Declined';
		document.frmEdit.action = 'PendingRequests.asp';
		
		document.frmEdit.submit();
	}
}

function UndoTransaction (x_lngTransactionID)
{
	if (confirm('Are you sure you would like to Undo transaction #' + x_lngTransactionID + ' ?'))
	{
		document.frmEdit.hdnTransactionID.value = x_lngTransactionID;
		document.frmEdit.hdnActionMode.value = 'Reverse';
		document.frmEdit.action = 'PendingRequests.asp';
		
		document.frmEdit.submit();
	}
}

function AddEvent(x_strTargetPage, x_intSectionID)
{
	
	for(var i = 0; i < window.document.frmEdit.elements.length; i++)
	{
		document.frmEdit.elements[i].value = '';
	}

	document.frmEdit.hdnTargetPage.value = x_strTargetPage;
	document.frmEdit.hdnSectionID.value = x_intSectionID;
	document.frmEdit.hdnActionMode.value = '';
	document.frmEdit.action = 'EditEvents.asp';
	
	document.frmEdit.submit();
}

function SaveEvent(x_strTargetPage, x_intSectionID)
{
	document.frmEdit.hdnTargetPage.value = x_strTargetPage;
	document.frmEdit.hdnSectionID.value = x_intSectionID;
	document.frmEdit.hdnActionMode.value = 'Save';
	document.frmEdit.action = 'EditEvents.asp';
	
	document.frmEdit.submit();
}

function EditEvent(x_strTargetPage, x_intSectionID)
{
	document.frmEdit.hdnTargetPage.value = x_strTargetPage;
	document.frmEdit.hdnSectionID.value = x_intSectionID;
	document.frmEdit.hdnActionMode.value = 'Edit';
	document.frmEdit.action = 'EditEvents.asp';
	
	document.frmEdit.submit();
}

function RemoveEvent(x_strTargetPage, x_intSectionID)
{
	document.frmEdit.hdnTargetPage.value = x_strTargetPage;
	document.frmEdit.hdnSectionID.value = x_intSectionID;
	document.frmEdit.hdnActionMode.value = 'Inactive';
	document.frmEdit.action = 'EditEvents.asp';
		
	document.frmEdit.submit();
}

function EditCalEvent(x_intSectionID)
{
	document.frmEdit.hdnTargetPage.value = document.frmEdit.hdnCurrentPage.value;
	document.frmEdit.hdnSectionID.value = x_intSectionID;
	document.frmEdit.hdnActionMode.value = 'Edit';
	document.frmEdit.action = 'EditEvents.asp';
	
	document.frmEdit.submit();
}

function ViewAdminEvent(x_strTargetPage, x_intSectionID, x_lngEventID)
{
	document.frmEdit.hdnTargetPage.value = x_strTargetPage;
	document.frmEdit.hdnSectionID.value = x_intSectionID;
	document.frmEdit.hdnEventID.value = x_lngEventID;
	document.frmEdit.action = 'admEventDetails.asp';
		
	document.frmEdit.submit();
}

function ViewAdminCalEvent(x_intSectionID, x_lngEventID)
{
	document.frmEdit.hdnTargetPage.value = document.frmEdit.hdnCurrentPage.value;
	document.frmEdit.hdnSectionID.value = x_intSectionID;
	document.frmEdit.hdnEventID.value = x_lngEventID;
	document.frmEdit.action = 'admEventDetails.asp';
		
	document.frmEdit.submit();
}

function ViewEvent(x_strTargetPage, x_intSectionID, x_lngEventID)
{
	document.frmPage.hdnTargetPage.value = x_strTargetPage;
	document.frmPage.hdnSectionID.value = x_intSectionID;
	document.frmPage.hdnEventID.value = x_lngEventID;
	document.frmPage.action = 'EventDetails.asp';
		
	document.frmPage.submit();
}

function ToggleView(x_strTargetPage, x_blnViewType)
{
/*	for(var i = 0; i < window.document.frmPage.elements.length; i++)
	{
		document.frmPage.elements[i].value = '';
	} */

	document.frmPage.hdnViewType.value = x_blnViewType;
	document.frmPage.action = x_strTargetPage;
	
	document.frmPage.submit();
}

function ToggleAdminView(x_strTargetPage, x_blnViewType)
{
/*
	for(var i = 0; i < window.document.frmEdit.elements.length; i++)
	{
		document.frmEdit.elements[i].value = '';
	} */

	document.frmEdit.hdnViewType.value = x_blnViewType;
	document.frmEdit.action = x_strTargetPage;
	
	document.frmEdit.submit();
}

function ViewCalEvent(x_intSectionID, x_lngEventID)
{
	document.frmPage.hdnTargetPage.value = document.frmPage.hdnCurrentPage.value;
	document.frmPage.hdnSectionID.value = x_intSectionID;
	document.frmPage.hdnEventID.value = x_lngEventID;
	document.frmPage.action = 'EventDetails.asp';
		
	document.frmPage.submit();
}

function PendingRequests()
{
	document.frmEdit.CurrentPage.value = 1;
	document.frmEdit.action = 'PendingRequests.asp';	
	
	document.frmEdit.submit();
}

function RecentActivity()
{
	document.frmEdit.CurrentPage.value = 1;
	document.frmEdit.action = 'RecentActivity.asp';	
	
	document.frmEdit.submit();
}

function ApplicationActivity()
{
	document.frmAppActivity.hdnApplicationID.value = '';
	document.frmAppActivity.CurrentPage.value = 1;
	document.frmAppActivity.action = 'appApplicationActivity.asp';	
	
	document.frmAppActivity.submit();
}


//rwf1477 purging quotes
function PurgeQuotes()
{
	document.frmQuoteListPurge.hdnListQuoteID.value = '';
	//document.frmQuoteListPurge.selActivtyTypes.value = 0 ;
	//document.frmQuoteListPurge.CurrentPage.value = 1;
	document.frmQuoteListPurge.action = 'qqQuoteListPurge.asp';	
	document.frmQuoteListPurge.submit();	
}

//rwf1477 purging quotes
function ResetPurgeQuotes()
{
	document.frmQuoteListPurge.hdnListQuoteID.value = '';
	document.frmQuoteListPurge.selActivtyTypes.value = 0 ;
	//document.frmQuoteListPurge.CurrentPage.value = 1;
	document.frmQuoteListPurge.action = 'qqQuoteListPurge.asp';	
	document.frmQuoteListPurge.submit();
}



//rwf1477 purging quotes
function PurgeApplications()
{
	document.frmApplicationListPurge.hdnListApplicationID.value = '';
	document.frmApplicationListPurge.action = 'appApplicationListPurge.asp';	
	document.frmApplicationListPurge.submit();	
}

//rwf1477 purging quotes
function ResetPurgeApplications()
{
	document.frmApplicationListPurge.hdnListApplicationID.value = '';
	document.frmApplicationListPurge.selActivtyTypes.value = 0 ;
	document.frmApplicationListPurge.action = 'appApplicationListPurge.asp';	
	document.frmApplicationListPurge.submit();
}









//rwf2548 mgmt reports
function MgmtRptActivity()
{
	//'document.frmMgmtRpts.hdnApplicationID.value = '';
	document.frmMgmtRpts.CurrentPage.value = 1;
	document.frmMgmtRpts.action = 'nwdMgmtRpts.asp';		
	document.frmMgmtRpts.submit();
}


function ChangeExample()
{
	document.getElementById("example").style.color = document.frmEdit.selFontColor.value;
	document.getElementById("example").style.fontFamily = document.frmEdit.selFont.value;
	document.getElementById("example").style.fontSize = document.frmEdit.selFontSize.value + 'px';
	document.getElementById("example").style.fontWeight = document.frmEdit.selFontWeight.value;
	document.getElementById("example").style.fontStyle = document.frmEdit.selFontStyle.value;
}

function ReturnToEdit()
{
	document.frmEdit.history(-2);
}

// ****************************************************
// Date specific functions for validation
// ****************************************************
function isValidDate(x_dteDate, x_strMessageType) 
{
	var dteMonth = GetInputMonth(x_dteDate);
	var dteDay = GetInputDay(x_dteDate);
	var dteYear = GetInputYear(x_dteDate);

	// test to make sure the date is formatted correctly
	if(!isValid(ExpDate, x_dteDate)) 
	{
		alert('The ' + x_strMessageType + ' date you entered is not a valid format, use mm/dd/yyyy.');
		return false;
	}

	if (x_dteDate.length != 10)
	{
		alert('The ' + x_strMessageType + ' date you entered is not a valid format, use mm/dd/yyyy.');
		return false;
	}
	// test for leap year - IsLeapYear has its own alert boxes
	if(!IsLeapYear(dteMonth, dteDay, dteYear)) 
	{
		return false;
	}
	
	// only 30 days in April, June, September, and November - IsThirtyDay has its own alert boxes
	if(!IsThirtyDay(dteMonth, dteDay)) 
	{
		return false;
	}
	
	return true;
}

/* This group of functions are for date manipulation and comparison */
function GetInputMonth(x_strDate)
{
	var strInputMonth = new String(x_strDate);
	// return only the first part of the date (MM) of a date that's formatted MM/DD/YYYY
	return	strInputMonth.substr(0,strInputMonth.indexOf("/",0));
}

function GetInputDay(x_strDate)
{
	var strInputDay = new String(x_strDate);
	var intStartPosition = (strInputDay.indexOf("/",0) + 1);
			
	// return only the day (DD) of a date that's formatted MM/DD/YYYY
	return	strInputDay.substr(intStartPosition,(strInputDay.indexOf("/",intStartPosition) - intStartPosition));
}

function GetInputYear(x_strDate)
{
	var strInputYear = new String(x_strDate);
	var intStartPosition = (strInputYear.lastIndexOf("/",strInputYear.length) + 1);
			
	// return only the last part of the date (YYYY) of a date that's formatted MM/DD/YYYY
	return strInputYear.substr(intStartPosition,(strInputYear.length - 1));
}

function IsLeapYear(x_intMonth, x_intDay, x_intYear)
{
	//test for leap year for the starting date
	if(x_intYear % 4 == 0)
	{
		//Is it a century.
		if(x_intYear % 100 == 0)
		{
			//If a century, must be evenly divisible by 400.
			if(x_intYear % 400 == 0 )
			{
				//it's a leap year
				if((x_intMonth == 2) && (x_intDay > 29))
				{
					alert("There are only 29 days in February.");
					return false;
				}				
			}
			else
			{
				//it's not a leap year
				if((x_intMonth == 2) && (x_intDay > 28))
				{
					alert("There are only 28 days in February.");
					return false;
				}
			}
		}
		else
		{
			//it's a leap year
			if((x_intMonth == 2) && (x_intDay > 29))
			{
				alert("There are only 29 days in February.");
				return false;
			}
		}
	}
	else
	{
		//it's not a leap year, test for the number of days in february
		if((x_intMonth == 2) && (x_intDay > 28))
		{
			alert("There are only 28 days in February.");
			return false;
		}
	}
	return true;
}

function IsThirtyDay(x_intMonth, x_intDay)
{
	//there are only 30 days in April, June, September, and November
	if(((x_intMonth == 4) || (x_intMonth == 6) || (x_intMonth == 9) || (x_intMonth == 11)) && (x_intDay > 30))
	{
		alert("There are only 30 days in Month you entered.");
		return false;
	}
	
	return true;
}

function ExpandList(objList, objContainer, intSections)
{
	if (document.getElementById(objList).style.visibility != "visible")
	{
		document.getElementById('img_' + objList).src = "images/Collapse.jpg";
		document.getElementById(objList).style.visibility = "visible";
		document.getElementById(objList).style.display = "list-item";
	}
	else
	{
		document.getElementById('img_' + objList).src = "images/Expand.jpg";
		document.getElementById(objList).style.visibility = "hidden";
		document.getElementById(objList).style.display = "none";
	}
}

function openInternalWindow(x_strLinkURL) 
{
	var docWindow = window.open(x_strLinkURL,'HndlrWordDoc','toolbar=no,location=0,directories=0,menubar=no,status=no,resizable=1,scrollbars=yes,left=10,top=10');
	
	if (docWindow.opener == null)
	{
		docWindow.opener = window;
	}
	
	docWindow.focus();
}

function ChangeCalendar(x_intChangeMonths)
{
	document.frmPage.hdnChangeMonth.value = x_intChangeMonths;
	
	if(document.frmPage.CurrentPage)
	{ 
		document.frmPage.CurrentPage.value = 1;
	}
	
	document.frmPage.submit(); 

}

function AdminChangeCalendar(x_intChangeMonths)
{
	document.frmEdit.hdnChangeMonth.value = x_intChangeMonths;
	
	if(document.frmEdit.CurrentPage)
	{ 
		document.frmEdit.CurrentPage.value = 1;
	}
	
	document.frmEdit.action = 'admOfficeCalendar.asp';	
	document.frmEdit.submit(); 

}

function ChangeXCalendar(x_intChangeMonths)
{
	document.frmCalendar.hdnXChangeMonth.value = x_intChangeMonths;
	document.frmCalendar.submit(); 

}

function ArrivalBox(objDeparture, objArrival)
{
	if (objDeparture.length != null)
	{
		for(i=0; i < objDeparture.options.length; i++)
		{
			if(objDeparture.options[i].selected)
			{
				objArrival.add(new Option(objDeparture.options[i].text, objDeparture.options[i].value));
				objDeparture.remove(i);
				
				i--;
			}
		}
	}
}

function DepartureBox(objArrival, objDeparture)
{
	if (objArrival.length != null)
	{
		for(i=0; i < objArrival.options.length; i++)
		{
			if(objArrival.options[i].selected)
			{
				objDeparture.add(new Option(objArrival.options[i].text, objArrival.options[i].value));
				objArrival.remove(i);
				
				i--;
			}
		}
	}
}

function SelectAll(objDeparture, objArrival)
{
	if (objDeparture.length != null)
	{
		for(i=0; i < objDeparture.options.length; i++)
		{
			objDeparture.options[i].selected =true;
		}
	}
	
	if (objArrival.length != null)
	{
		for(i=0; i < objArrival.options.length; i++)
		{
			objArrival.options[i].selected = true;
		}
	}
}

function ValidateFloat(x_strValue)
{
    if (!x_strValue)
		return false;
		
    var Chars = ".0123456789";

    for (var i = 0; i < x_strValue.length; i++)
	{
       if (Chars.indexOf(x_strValue.charAt(i)) == -1)
          return false;
    }
    return true;
}

function ValidateNumber(x_strValue)
{
    if (!x_strValue)
		return false;
		
    var Chars = ",0123456789";

    for (var i = 0; i < x_strValue.length; i++)
	{
       if (Chars.indexOf(x_strValue.charAt(i)) == -1)
          return false;
    }
    return true;
}

function AddCommas(x_strNumber) 
{
	x_strNumber = '' + x_strNumber;

	if (x_strNumber.length > 3) 
	{
		var mod = x_strNumber.length % 3;
		var strOutput = (mod > 0 ? (x_strNumber.substring(0,mod)) : '');

		for (i=0 ; i < Math.floor(x_strNumber.length / 3); i++) 
		{
			if ((mod == 0) && (i == 0))
			{
				strOutput += x_strNumber.substring(mod+ 3 * i, mod + 3 * i + 3);
			}
			else
			{
				strOutput+= ',' + x_strNumber.substring(mod + 3 * i, mod + 3 * i + 3);
			}
		}
		
		return (strOutput);
	
	}
	else 
	{
		return x_strNumber;
	}
}

function GetCommas(x_objTextBox)
{
	x_objTextBox.value = x_objTextBox.value.replace(/,/g,"");
	x_objTextBox.value = AddCommas(x_objTextBox.value);
}




//rwf1430
function AddSlashes(x_strNumber) 
{
	// rwf20090428 stop dates from adding multiple slashes - remember starts at 0
	if (x_strNumber.substr(1,1) == '/' || x_strNumber.substr(2,1) == '/' || x_strNumber.substr(3,1) == '/' || x_strNumber.substr(4,1) == '/' )
	{
		return x_strNumber;
	}
	else
	{
		if (x_strNumber.length == 8) 
		{
			strOutput = (x_strNumber.substr(0,2)+ '/' + x_strNumber.substr(2,2) + '/' + x_strNumber.substr(4,4));	
			return (strOutput);
		}
		else 
		{
			return x_strNumber;
		}
	}	
}

function GetSlashes(x_objTextBox)
{
	x_objTextBox.value = AddSlashes(x_objTextBox.value);
}


//rwf1430
function PrefillExpDate(form) 
{
	if (form.txtEffectiveDate.value == "")
	{
	}
	else
	{
		//var x_strNumber = new String(form.txtEffectiveDate.value);
		//var numInputYear = new Number(x_strNumber.substr(6,4)) + 1;
		//form.txtExpirationDate.value = (x_strNumber.substr(0,5)+ '/' + (numInputYear.toString()));	
			
		var x_strMonth = GetInputMonth(form.txtEffectiveDate.value);
		var x_strDay = GetInputDay(form.txtEffectiveDate.value);
		var x_strYear = GetInputYear(form.txtEffectiveDate.value);
		var numInputYear = new Number(x_strYear) + 1;
		form.txtExpirationDate.value = (x_strMonth + '/' + x_strDay + '/' + (numInputYear.toString()));	
	
	}
}

//rwf2730
function ShowChangePasswordWarning()
{
	if (confirm("Changing your password will affect all users in your agency, do you want to proceed?"))
	{
		document.forms[0].action = "ChangePassword.asp";
		document.forms[0].submit();
	}
}


//rwf 2812
function LoadRiskGradeDetailPage(str_NAICSID)
{
		
	document.frmRiskGradeList.hdnNAICSInfo.value = str_NAICSID;
	document.frmRiskGradeList.submit();	
}





//rwf 4147 Policy Print - switch to inactive policies
function Switchactivesw()
{		
	document.frmPolicyPrint.hdnactivesw.value = 2;
	document.frmPolicyPrint.action = 'PolicyPrint.asp';	
	document.frmPolicyPrint.submit();	
}


//rwf 4147 Policy Print - switch to active
function Switchtoactivesw()
{
	document.frmPolicyPrint.hdnactivesw.value = 1;
	document.frmPolicyPrint.action = 'PolicyPrint.asp';	
	document.frmPolicyPrint.submit();
}