var reSpace=/\s/;
var reChar=/\w/;
var reDigit=/\d/;
function IsDigits(cltr,msg)
{
	if(isNaN(cltr.value)==true||reSpace.test(cltr.value)==true)
	{
		alert(msg);
		cltr.focus();
		cltr.select();
		return false;
	}
return true;
}
function IsChars(cltr,msg)
{
	if(reDigit.test(cltr.value)==true || reSpace.test(cltr.value)==true)
	{
		alert(msg);
		cltr.focus();
		cltr.select();
		return false;
	}
return true;
}

function ContainSpace(cltr,msg)
{

	if (reSpace.test(cltr.value)==true)
	{
		alert(msg);
		cltr.focus();
		cltr.select();
		return true;
	}
return false;
}
function ContainChar(cltr,msg)
{

	if (isNaN(cltr.value)==true)
	{
		alert(msg);
		cltr.focus();
		cltr.select();
		return true;
	}
return false;
}
function ContainDigit(cltr,msg)
{

	if (reDigit.test(cltr.value)==true)
	{
		alert(msg);
		cltr.focus();
		cltr.select();
		return true;
	}
return false;
}

function ConMinDigits(cltr,fSize,msg)
{
	
	if (cltr.value=="")
	{
		alert(msg+" Not Entered");
		cltr.value="";
		cltr.focus();
		return false;
	}
	else
	{
		if (isNaN(cltr.value)||reSpace.test(cltr.value)==true)
		{ 
			alert("Enter "+msg+" in Digit only");
			cltr.focus();
			cltr.select();
			return false;
		}
		if (cltr.value.length < fSize )
		{ 
			alert("Enter "+msg+" in "+fSize+" Digit ");
			cltr.focus();
			cltr.select();
			return false;
		}
	}
return true;
}	

function EnabledNexttxt(str,cltr)
{
	if(str=="")
	{ cltr.disabled=true;
	  cltr.value="";}
	else
	{ cltr.disabled=false;}
}

function EnableOthertxt(cmb,txt)
{
	if (cmb.value=="Other")
	{	txt.readOnly=false;
		txt.focus();
	}
	else
	{	txt.value="";
		txt.readOnly="yes";	}
}
		
		
function IsEmail(cltr,msg)
{
		var str=cltr.value;
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if(reSpace.test(str)==true)
		{
			alert(msg);
			cltr.focus();
			cltr.select();
			return false;
		}
		if (str.indexOf(at)==-1){
		   alert(msg)
			cltr.focus();
			cltr.select();
			return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			alert(msg)
			cltr.focus();
			cltr.select();
			return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert(msg)
			cltr.focus();
			cltr.select();
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert(msg)
			cltr.focus();
			cltr.select();
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert(msg)
			cltr.focus();
			cltr.select();
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert(msg)
			cltr.focus();
			cltr.select();
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert(msg)
			cltr.focus();
			cltr.select();
		    return false
		 }

return true					
}
function IsMoreSelected(cltr,MaxCount,msg)
{
	var r = 0;
	for(i=0;i<cltr.length;i++)
	{
		if(cltr[i].selected)
		{
			r+=1;
		}
	}
	if(r > MaxCount)
	{
		alert (msg);
		cltr.focus();
		return true;
	}
return false;
}
function IsSelected(cltr,DeselectValue,msg)
{

	if (cltr.value==DeselectValue)
	{
		alert(msg);
		cltr.focus();
		return true;
	}
return false;
}		
function IsBlank(cltr,msg)
{
	if (cltr.value=="")
	{
		alert(msg);
		cltr.value="";
		cltr.focus();
		return true;
	}
	if ((cltr.value).substring(0,1)==" ")
	{
		alert("Spaces not allowed in the beginning");
		cltr.focus();
		cltr.select();
		return true;
	}

return false;
}
function IsDate(dtStr)
{
	var dtCh= "/";
	var minYear=1900;
	var maxYear=2100;

	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) 
	{
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1)
	{
		//alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12)
	{
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month])
	{
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear)
	{
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false)
	{
		alert("Please enter a valid date")
		return false
	}
return true;
}	
function stripCharsInBag(s, bag)
	{
		var i;
		var returnString = "";
		// Search through string's characters one by one.
		// If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
	{   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
function isInteger(s)
{
	var i;
    for (i = 0; i < s.length; i++)
	{   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function daysInFebruary (year)
	{
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}


function DaysArray(n) 	
	{
	for (var i = 1; i <= n; i++) 
	{
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   	} 
   return this
}
/*----------------------------------------------------------------------------------------
	Function Name		: RestoreFieldsOfFilterAndSortWindows
	Parameters			: objParentSortStatus - Object Of Parent Windows Txt Field
						: objCurrForm - Current Pages form  name
	Purpose				: this will reproduce the earlier filter criteria using the string build by method - GetFieldsStatusOfFilterOrSortWindows
	-------------------------------------------------------------------------------------------*/
/* Code for Controlling Browser Back button 
if (window.history.length >= 0)	
{
	history.forward();
	window.history.go(+1);
	
}
*/

function RestoreFieldsOfFilterAndSortWindows(objParentSortStatus, objCurrForm)
{
	var allElementStatus = ''
	var singleElement, arrElementCols;

	// if the parent window exists then get the previous search String.
	if ( objParentSortStatus)
		allElementStatus = objParentSortStatus.value;

	// split the string with "$$$" to get each element information into Array in the form of 1###CH###true
	var arrElements = allElementStatus.split("$$$")
	
	// for each element stored in the string, i.e. for the length of the Array after splitting with $$$
	for ( var lintLoopCntr = 0; lintLoopCntr < arrElements.length; lintLoopCntr++)
	{
		// get the single element information into the variable.
		singleElement = arrElements[lintLoopCntr];
		
		// if this element contains "###" the mail delemeter,
		if (singleElement.indexOf("###" > 0 ) )
		{
			// split the total element information with "###" to get each of the columns.
			arrElementCols = singleElement.split("###")
			// if there exists three columns (ID, TYPE, VALUE)
			if ( arrElementCols.length == 3)
			{
				// if element is of type CheckBox Or Radio, and the value is "TRUE" then make the element CHECKED
				if (arrElementCols[1] == 'CH' || arrElementCols[1] == 'RD' )
				{
					if (arrElementCols[2] == 'true')
						objCurrForm.elements[arrElementCols[0]].checked = arrElementCols[2]
				}
				// if element is of type TextBox, then put the value into the TextBox
				else if (arrElementCols[1] == 'TX' )
					objCurrForm.elements[arrElementCols[0]].value = arrElementCols[2]
				else if (arrElementCols[1] == 'SL' )
				{
					objSelect = objCurrForm.elements[arrElementCols[0]];
					objSelect.selectedIndex = arrElementCols[2]
				}
			} // END of Three Elements Check
		} // END of Checking whether element has "###"
	} // END of FOR LOOP
} // END of Function

/*----------------------------------------------------------------------------------------
	Function Name		: GetFieldsStatusOfFilterOrSortWindows
	Parameters			: objParentSortStatus - Object Of Parent Windows Txt Field
						: objCurrForm - Current Pages form  name
	Purpose				: this will build a string for all the Radio/Text/CheckBox type elements in the page.
						: for each element it stores --- Element_Index###TYPE(RD/TX/CH)###Value, 
						: with ### being delementer for the element props.
						: And simlarly all these elements are clubbed with Delemeter $$$
	-------------------------------------------------------------------------------------------*/
function GetFieldsStatusOfFilterOrSortWindows(objParentSortStatus, objCurrForm)
{
	var intFilterItemsSelected = 0
	// Get the Length of elements available
	var maxElements = eval(objCurrForm + '.elements' ).length
	var allElementStatus = '';

	// loop thru all the elements
	for ( var lintLoopCntr = 0; lintLoopCntr < maxElements ; lintLoopCntr ++)
	{
		// example template			1###CH###true
		// this means first check box is checked.
		var objSelect

		// if the element is of type Check Box -- put the code "CH" in the string to indicated the Check box, and put the element number  and the value in the ### separated String
		if ( eval(objCurrForm).elements[lintLoopCntr].type == 'checkbox' && eval(objCurrForm).elements[lintLoopCntr].checked == true )
		{
			intFilterItemsSelected++;
			allElementStatus += lintLoopCntr + '###CH###' + eval(objCurrForm).elements[lintLoopCntr].checked + '$$$'
		}
		// if the element is of type text Box -- put the code "TX" in the string to indicated the text box, and put the element number  and the value in the ### separated String
		else if ( eval(objCurrForm).elements[lintLoopCntr].type == 'text' && eval(objCurrForm).elements[lintLoopCntr].value != '')
		{
			intFilterItemsSelected++;
			allElementStatus += lintLoopCntr + '###TX###' + eval(objCurrForm).elements[lintLoopCntr].value + '$$$'
		}
		// if the element is of type radio -- put the code "RD" in the string to indicated the Radio box, and put the element number  and the value in the ### separated String
		else if ( eval(objCurrForm).elements[lintLoopCntr].type == 'radio' && eval(objCurrForm).elements[lintLoopCntr].checked == true )
		{
			intFilterItemsSelected++;
			allElementStatus += lintLoopCntr + '###RD###' + eval(objCurrForm).elements[lintLoopCntr].checked + '$$$'
		}
		else if (eval(objCurrForm).elements[lintLoopCntr].type == 'select-one')
		{
			objSelect = eval(objCurrForm).elements[lintLoopCntr];
			allElementStatus += lintLoopCntr + '###SL###' + objSelect.selectedIndex + '$$$'
		}
	} // END of For LOOP

	// write the total form status into the Parent windows hidden field
	objParentSortStatus.value = allElementStatus;
	
	return intFilterItemsSelected
} // END of Function


/*----------------------------------------------------------------------------------------
	Function Name		: CloseTheCurrentWindow
	Parameters			: 
	Purpose				: Function to close the window in wizards
	-------------------------------------------------------------------------------------------*/
function CloseTheCurrentWindow() {
	window.close()
}

/*----------------------------------------------------------------------------------------
	Function Name		: CloseWindowAndRedirectParentToIndex
	Parameters			: 
	Purpose				: Function to close the window in wizards when the session is expired and redirect the parent to index page.
	-------------------------------------------------------------------------------------------*/
function CloseWindowAndRedirectParentToIndex(indexPageURL) {
	if ( window.opener )
		window.opener.location.href = indexPageURL
	window.close()
}
/*----------------------------------------------------------------------------------------
	Function Name		: formatCurrency 
	Parameters			: Number
	Purpose				: This script accepts a number or string and formats it like U.S.
	 currency. Adds the dollar sign, rounds to two places past the decimal,
	 adds place holding zeros, and commas where appropriate.  
	-------------------------------------------------------------------------------------------*/
function formatCurrency(num)
{
	var orgNum = num
	var afternumber = 0;
	var negitiveValue = 0;
	num = num.toString().replace(/\$|\,/g,'');

	if (num.indexOf(".") > 0)
	{
		numberAfterDecimal = num.substring( 0, num.indexOf( ".") + 3)
		afternumber = num.substring( num.indexOf( ".") + 3, num.indexOf( ".") + 7)
		if ( afternumber == 4999 )
			num = parseFloat( numberAfterDecimal ) + 0.01;
	}
//num  = Math.abs(num );
	if ( num < 0 )
	{
		negitiveValue = 1
		num = num * -1
	}

	num = (Math.round ( num  * 1000 / 10) / 100 )

	if(isNaN(num))
		num = "0";
	sign = (num == (num = Math.abs(num)));

	num = Math.floor(num*100 + 0.50000000001);
	//num = Math.floor(num*100 );

	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;

	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));

	num = (((sign)?'':'-') + '$' + num + '.' + cents)

	if ( negitiveValue == 1 )
		num = "-" + num 

	return num 
}


/*----------------------------------------------------------------------------------------
	Function Name		: formatCurrencyWithoutDollar 
	Parameters			: Number
	Purpose				: This script accepts a number or string and rounds to two places past the decimal,
	 adds place holding zeros, and commas where appropriate.  

	-------------------------------------------------------------------------------------------*/
function formatCurrencyWithoutDollar(num)
{
	var WithDollar = formatCurrency(num);
	var WithoutDollar = WithDollar.substring(1, WithDollar.length);
	return WithoutDollar
}

/*----------------------------------------------------------------------------------------
	Function Name		: RedirecToPage
	Parameters			: pageToRedirect
	Purpose				: Function to redirect to the given Page
	-------------------------------------------------------------------------------------------*/
function RedirecToPage(pageToRedirect) {
	document.location.href = pageToRedirect;
}

/*----------------------------------------------------------------------------------------
	Function Name		: PrintTheForm
	Parameters			: 
	Purpose				: One function which is called from wherever the print button is given.
	-------------------------------------------------------------------------------------------*/
function PrintTheForm() {
	var usertype=navigator.userAgent.toLowerCase();
	if (usertype.indexOf("mac") != -1) {
        alert("Please Press 'Cmd+p'  to print this Page.");
    }
    else if(window.print)
    {
		window.print();
    }   
    else {
        alert("Please Press 'Ctrl+p' to print this page.")
    }
}

/*----------------------------------------------------------------------------------------
	Function Name		: DefaultOnSubmitNullify
	Parameters			:  
	Purpose				: One function which is called from wherever the Enter Key is pressed in the Mac system.
	                      It should not Post the data to the Server. 
	-------------------------------------------------------------------------------------------*/
function DefaultOnSubmitNullify() {
	//alert(" Please use the buttons on the page to sumbit" );
	return false;
}

/*----------------------------------------------------------------------------------------
	Function Name		: TrimTheString 
	Parameters			: pszStringtoTrim
	Purpose				: Trims the string
	-------------------------------------------------------------------------------------------*/

function TrimTheString ( pszStringtoTrim )
{
	var bflag = true;
	var i = 0;
	if ( IsWhitespace ( pszStringtoTrim ) == true )
		return "";
	while ( ( i < pszStringtoTrim.length ) && ( bflag ) )
	{
		retChar = pszStringtoTrim.charAt ( i++ );
		if ( retChar != " " ) bflag = false;
	}
	if ( bflag ) return "";
	var j = pszStringtoTrim.length-1;
	bflag = true;
	while ( ( j >= 0 ) && ( bflag ) ) 
	{
		retChar = pszStringtoTrim.charAt ( j-- );
		if ( retChar != " " ) bflag = false;
	}
	if ( bflag ) return "";
	pszStringtoTrim = pszStringtoTrim.substring ( i-1 ,j+2 );
	return pszStringtoTrim;
}

/*----------------------------------------------------------------------------------------
	Function Name		: IsWhitespace 
	Parameters			: pszStringtoCheck
	Purpose				: Checks for white spaces
	-------------------------------------------------------------------------------------------*/
function IsWhitespace ( pszStringtoCheck )
{
	var reWhitespace = /^\s+$/
	return ( IsEmpty ( pszStringtoCheck ) || reWhitespace.test ( pszStringtoCheck ) );
}
	
/*----------------------------------------------------------------------------------------
	Function Name		: IsEmpty 
	Parameters			: pszStringtoCheck
	Purpose				: Checks for empty string
	-------------------------------------------------------------------------------------------*/

function IsEmpty ( pszStringtoCheck ) {
	return ( ( pszStringtoCheck == null ) || ( pszStringtoCheck.length == 0 ) )
}

/*----------------------------------------------------------------------------------------
	Function Name		: IsSmallLongInt 
	Parameters			: pszFieldObj, pszMaxValue
	Purpose				: Validates the Numeric field
	-------------------------------------------------------------------------------------------*/
			
function IsSmallLongInt ( pszFieldObj, pszMaxValue, pszFieldNameToAppend )
{
	if ( TrimTheString( pszMaxValue ) == "" )
	{
		pszMaxValue = "SMALLINT";
	}
	var pnMaxValue;
	var szFieldValue = eval( pszFieldObj ).value
	szFieldValue = szFieldValue.replace(/\$|\,/g,'');  //Replaces the commas with empty
	if ( isNaN( TrimTheString( szFieldValue ) ) )
	{
				return false;
	}
	else
	{
		if ( TrimTheString( pszMaxValue ).toUpperCase() == "SMALLINT")
			pnMaxValue = 32767;
		else if ( TrimTheString( pszMaxValue ).toUpperCase() == "INT")
			pnMaxValue = 2147483647;
		else
			pnMaxValue = parseInt(pszMaxValue);
	
		if ( szFieldValue > pnMaxValue )
		{			
			return false;
		}
		else
		{
			return true;
		}
	}
}

/*----------------------------------------------------------------------------------------
	Author				: Shashidhar Rao. L
	Function Name		: IsPositiveInt
	Parameters			: fieldObject
	Purpose				: Validate wheather the data is a Positive Integer
	Comments			: Returns true if the field value is Positive.
	-------------------------------------------------------------------------------------------*/
function IsPositiveInt(FieldName){
	FieldName = eval(FieldName);
	if (isNaN(FieldName.value))	{
		return false;
	}
	else if(FieldName.value <=0){
			return false
		 }
	else
	return true;
	}
	
function IsPositiveIntValue(appendMessage, checkValue){
	if (isNaN(checkValue))	{
		alert(appendMessage + " should be a positive number ( -ve and 0 are not allowed )")
		return false;
	}
	else if(checkValue <=0){
			alert(appendMessage + " should be a positive number ( -ve and 0 are not allowed )")
			return false
		 }
	else
	return true;
	}
	

 /*----------------------------------------------------------------------------------------
	Function Name		: FormatPhone
	Parameters			: phoneField
	Purpose				: Format the inputed phone number directly at the time of entry...
	-------------------------------------------------------------------------------------------*/
function FormatPhone(phoneField){
	p = TrimTheString(phoneField.value)
	var isIE = document.all?true:false;
	if (isIE){
	if (event.keyCode == 32) {
		phoneField.value = p.substr(0,p.length)
		}
	}
	
	if(p.length==3){
			pp=p;
			d4=p.indexOf('(')
			d5=p.indexOf(')')
			if(d4==-1){
					pp="("+pp;
			}
			if(d5==-1){
					pp=pp+") ";
			}
			phoneField.value="";
			phoneField.value=pp;
	}
	if(p.length>3){
			d1=p.indexOf('(')
			d2=p.indexOf(')')
			if (d2==-1){
					l30=p.length;
					p30=p.substring(0,4);
					p30=p30+") "
					p31=p.substring(4,l30);
					pp=p30+p31;
					phoneField.value="";
					phoneField.value=pp;
			}
	}
	if(p.length>6){
			p11=p.substring(d1+1,d2);
			if(p11.length>3){
				p12=p11;
				l12=p12.length;
				l15=p.length
				p13=p11.substring(0,3);
				p14=p11.substring(3,l12);
				p15=p.substring(d2+1,l15);
				phoneField.value="";
				pp="("+p13+") "+p14+p15;
				phoneField.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);
					pp=p19+p17+"-"+p18;
					phoneField.value="";
					phoneField.value=pp;
			}
	}
}

 
 /*----------------------------------------------------------------------------------------
	Function Name       : IsValidPhoneNo
	Parameters			: fieldName - The field to be validated. Eg. "document.frmTest.txtTheField"
	Purpose				: Validates Phone No
	-------------------------------------------------------------------------------------------*/
	
function IsValidPhoneNo ( fieldName )
{
	var szStripped = fieldName.replace(/[\(\)\.\-\ ]/g, '');
	if (isNaN(szStripped))
	{
		alert("Telephone number format should be specified as  ###-###-####")
		return false;
	}else if ( ( szStripped.length != 10)) 
	{
		alert("Telephone number format should be specified as  ###-###-####")
		return false;
	}
	else
		return true;
}

/*----------------------------------------------------------------------------------------
	Author				: Upendra
	Function Name       : ValidateTaxPercentage
	Parameters			: pszFieldObj - The field to be validated. Eg. "document.frmTest.txtTheField"
	Purpose				: Validates the Percentages. Range is 0 to 100
	-------------------------------------------------------------------------------------------*/
function ValidateTaxPercentage(pszFieldObj)
{
	var  pbAllowSign = true;   // use True to Allow the signature(-) and false to Doesn't allow
	var Percentage= eval( pszFieldObj ).value.replace(/\$|\,/g,'');

    var IsValidate=IsCurrencyFloatSign(pszFieldObj,pbAllowSign);
    if(IsValidate)
    {
		if(Percentage > 1000 || Percentage  < -1000 )
		{
			alert("Invalid Percentage. Percentage Range is -1000% to 1000%");
			eval( pszFieldObj ).focus();
			return false;
		}
    } 
      return IsValidate;
}

	/*----------------------------------------------------------------------------------------
	Function Name       : ValidatePercentage
	Parameters			: pszFieldObj - The field to be validated. Eg. "document.frmTest.txtTheField"
						  pnPrecision - An integer for the precision of the decimal digits.
	Purpose				: Validates the Percentages. Range is -100 to 100
	-------------------------------------------------------------------------------------------*/
function ValidatePercentage(pszFieldObj,pAllowNegativePercentage)
{
	var  pbAllowSign = true;   // use True to Allow the signature(-) and false to Doesn't allow
	var Percentage= eval( pszFieldObj ).value.replace(/,/g,"");
	if (Percentage.indexOf(",") >= 0 )
	{
			alert("Field should not contain comma in percentage");
			eval( pszFieldObj ).focus();
			return false;
	}
    var IsValidate=IsCurrencyFloatSign(pszFieldObj,pbAllowSign);
/*    if(IsValidate)
    {
		if(Percentage > 1000 || Percentage  < -1000 )
		{
			alert("Invalid Percentage. Percentage Range is -1000% to 1000%");
			eval( pszFieldObj ).focus();
			return false;
		}
    } 
*/      return IsValidate;
}


	/*----------------------------------------------------------------------------------------
	Function Name       : IsCurrencyFloatSign
	Parameters			:	1. pszFieldObj		- The field to be validated. Eg. "document.frmTest.txtTheField"
						:	2. pbAllowSign		- true / false
						:	3. pnPrecision		- An integer for the precision of the decimal digits.
	Purpose				: Purpose Checks for numeric value and allows decimal depending on the 'nPrecision' parameter. 
							Also allows + or - sign at the beginning depending on the second parameter, 'pbAllowSign'.
							Range is -100.00 to 100.00
	-------------------------------------------------------------------------------------------*/
function IsCurrencyFloatSign ( pszFieldObj, pbAllowSign )
{
	var nPrecision = 2;   //Default precision is 2
	var szFieldValue = eval( pszFieldObj ).value
	var intNextDollerSign = szFieldValue.lastIndexOf( '$')

	if ( intNextDollerSign >= 0)
	{
		if ( pbAllowSign )
			alert("Please enter a valid numeric value ( +/-NNNNNNN.NN )");
		else
			alert("Please enter a valid numeric value ( NNNNNNN.NN )");
		eval( pszFieldObj ).focus();
		return false;
	}

	szFieldValue = szFieldValue.replace(/\$|\,/g,'');  //Replaces the commas with empty

	if ( TrimTheString(szFieldValue) == "")
	{    
		if ( pbAllowSign )
			alert("Field should not be empty. please enter a valid numeric value ( +/- NNNNNNN.NN )");
		else
			alert("Field should not be empty. please enter a valid numeric value ( NNNNNNN.NN )");
		eval( pszFieldObj ).focus();
		return false;
	}
	
	if ( pbAllowSign )
		reTheRegExp = /^(((\+|-)?\$?\d+(\.\d*)?)|((\+|-)?\$?(\d*\.)?\d+))$/
	else
		reTheRegExp = /^((\$?\d+(\.\d*)?)|((\$?\d*\.)?\d+))$/

	if ( reTheRegExp.test( TrimTheString ( szFieldValue ) ) == false )
	{
		if ( pbAllowSign )
			alert("Field should contain a valid numeric value ( +/- NNNNNNN.NN )");
		else
			alert("Field should contain a valid numeric value ( NNNNNNN.NN )");
		eval( pszFieldObj ).focus();
		return false;
	}

	if ( ( nPrecision >= ( ( TrimTheString ( szFieldValue ).length - 1 ) - TrimTheString ( szFieldValue ).indexOf ( "." ) ) ) || ( TrimTheString ( szFieldValue ).indexOf ( "." ) == -1 ) )
	{
		var valBeforeDecimal = TrimTheString ( szFieldValue )
		if ( valBeforeDecimal.indexOf(".") >= 0)	 valBeforeDecimal  = valBeforeDecimal.substr(0, valBeforeDecimal.indexOf("."))
		if ( valBeforeDecimal > 999999999999 )
		{
			alert("Value in the field should not be greater than '999,999,999,999.99'");
			eval( pszFieldObj ).focus();
			return false;
		}
		else
			return true;
	}
	else
	{
		alert( "Field should contain only " + nPrecision + " decimal place(s)." );
		eval( pszFieldObj ).focus();
		return false;
	}
}

function IsValidDateDiff ( pszLaterDate, pszEarlierDate, pszDiffPrecision, pnDiffAllowed ) 
{
//	alert(pszLaterDate + '===' +  pszEarlierDate  + '===' +  pszDiffPrecision  + '===' + pnDiffAllowed)

	var aDateArr, nMonth, nDay, nYear
	aDateArr = pszLaterDate.split ( "/" )
	nMonth = aDateArr [ 0 ]
	nDay = aDateArr [ 1 ]
	nYear = aDateArr [ 2 ]
	pszLaterDate = new Date ( nYear, nMonth-1, nDay )

	aDateArr = pszEarlierDate.split ( "/" )
	nMonth = aDateArr [ 0 ]
	nDay = aDateArr [ 1 ]
	nYear = aDateArr [ 2 ]
	pszEarlierDate = new Date ( nYear, nMonth-1, nDay )

	var nThedifference = pszLaterDate.getTime() - pszEarlierDate.getTime();
	var nDaysDifference = Math.floor(nThedifference/1000/60/60/24);

	nThedifference -= nDaysDifference*1000*60*60*24
	var nHoursDifference = Math.floor(nThedifference/1000/60/60);

	nThedifference -= nHoursDifference*1000*60*60
	var nMinutesDifference = Math.floor(nThedifference/1000/60);

	nThedifference -= nMinutesDifference*1000*60
	var nSecondsDifference = Math.floor(nThedifference/1000);

	var nMonthsDifference = Math.round ( parseInt ( nDaysDifference) * 12 / 365.24219878 )
	var nYearsDifference = Math.round ( parseInt ( nDaysDifference) / 365.24219878 )

	pnDiffAllowed = "" + pnDiffAllowed
	pszDiffPrecision = pszDiffPrecision.toUpperCase();
	if ( TrimTheString ( pszDiffPrecision ) == "YEARS" )
	{
		if ( nYearsDifference >= parseInt ( TrimTheString ( pnDiffAllowed ) ) )
			return false;
		else
			return true;
	}
	else if ( TrimTheString ( pszDiffPrecision ) == "MONTHS" )
	{
		if ( nMonthsDifference >= parseInt ( TrimTheString ( pnDiffAllowed ) ) )
			return false;
		else
			return true;
	}
	else if ( TrimTheString ( pszDiffPrecision ) == "DAYS" )
	{
		if ( nDaysDifference >= parseInt ( TrimTheString ( pnDiffAllowed ) ) )
			return false;
		else
			return true;
	}
	else if ( TrimTheString ( pszDiffPrecision ) == "MINUTES" )
	{
		if ( nMinutesDifference >= parseInt ( TrimTheString ( pnDiffAllowed ) ) )
			return false;
		else
			return true;
	}	
}

function GetNewDate(OldDate, ChnageIn, ExtraValue ) 
{
//	alert(pszLaterDate + '===' +  pszEarlierDate  + '===' +  pszDiffPrecision  + '===' + pnDiffAllowed)

	

	aDateArr = OldDate.split ( "/" )
	nMonth = aDateArr [ 0 ]
	nDay = aDateArr [ 1 ]
	nYear = aDateArr [ 2 ]
	OldDate = new Date ( nYear, nMonth-1, nDay )

	var nThedifference = OldDate.getTime();
	var nDaysDifference = Math.floor(nThedifference/1000/60/60/24);

	nThedifference -= nDaysDifference*1000*60*60*24
	var nHoursDifference = Math.floor(nThedifference/1000/60/60);

	nThedifference -= nHoursDifference*1000*60*60
	var nMinutesDifference = Math.floor(nThedifference/1000/60);

	nThedifference -= nMinutesDifference*1000*60
	var nSecondsDifference = Math.floor(nThedifference/1000);

	var nMonthsDifference = Math.round ( parseInt ( nDaysDifference) * 12 / 365.24219878 )
	var nYearsDifference = Math.round ( parseInt ( nDaysDifference) / 365.24219878 )

	pnDiffAllowed = "" + pnDiffAllowed
	pszDiffPrecision = pszDiffPrecision.toUpperCase();
	if ( TrimTheString ( ChnageIn ) == "YEARS" )
	{
		if ( nYearsDifference >= parseInt ( TrimTheString ( pnDiffAllowed ) ) )
			return false;
		else
			return true;
	}
	else if ( TrimTheString ( ChnageIn ) == "MONTHS" )
	{
		if ( nMonthsDifference >= parseInt ( TrimTheString ( pnDiffAllowed ) ) )
			return false;
		else
			return true;
	}
	else if ( TrimTheString ( ChnageIn ) == "DAYS" )
	{
		if ( nDaysDifference >= parseInt ( TrimTheString ( pnDiffAllowed ) ) )
			return false;
		else
			return true;
	}
}

function GetAge( pszEarlierDate ) 
{

	var aDateArr, nMonth, nDay, nYear
	nMonth = new Date().getMonth();
	nDay = new Date().getDay();
	nYear = new Date().getFullYear();
	pszLaterDate = new Date ( nYear, nMonth-1, nDay )

	aDateArr = pszEarlierDate.split ( "/" )
	nMonth = aDateArr [ 0 ]
	nDay = aDateArr [ 1 ]
	nYear = aDateArr [ 2 ]
	pszEarlierDate = new Date ( nYear, nMonth-1, nDay )

	var nThedifference = pszLaterDate.getTime() - pszEarlierDate.getTime();
	var nDaysDifference = Math.floor(nThedifference/1000/60/60/24);

	var nMonthsDifference = Math.round ( parseInt ( nDaysDifference) * 12 / 365.24219878 )
	var nYearsDifference = Math.round ( parseInt ( nDaysDifference) / 365.24219878 )

	return nYearsDifference;
}

// Check whether string s is empty.
// returns true if the string is empty
function IsEmpty(StringToCheck)
{   
	return ((StringToCheck == null) || (StringToCheck.length == 0))
}

// Returns true if string s is empty or 
// whitespace characters only.
function IsWhitespace (StringToCheck)
{
	var reWhitespace = /^\s+$/
    return (IsEmpty(StringToCheck) || reWhitespace.test(StringToCheck));
}

// This function is used so that no internal messages are returned
// Used in ValidateZip function.
function isIntegerNoMsg (StringToCheck)
{
   	var valid = true;
	var reInteger = /^\d+$/
	
	if (valid == true && IsWhitespace(StringToCheck)) 
    {
		valid = false;
		return false;
	}
    if ( valid == true  && reInteger.test(StringToCheck) == false)
	{
		valid = false
		return false;
	}
	return true;
}

function ValidateZip(ObjZipCode, pszFieldNameToAppend )
{
	var FirstFive, LastFour, Dash, TempFieldValue;
	var reInteger = /^\d+$/
	var FieldValue = TrimTheString(ObjZipCode.value);

	TempFieldValue = new String(FieldValue);

	if (TempFieldValue.length != 5 && TempFieldValue.length != 9 && TempFieldValue.length != 10)
	{
		alert(pszFieldNameToAppend + " format should be specified as NNNNN-NNNN (or) NNNNN");
		ObjZipCode.select();
		ObjZipCode.focus();
		return false;
	}

	if (FieldValue.length==5)
	{
		if (reInteger.test(TempFieldValue) == false)
		{
			alert(pszFieldNameToAppend + " format should be specified as NNNNN-NNNN (or) NNNNN format.");
			ObjZipCode.select();
			ObjZipCode.focus();
			return false;
		}
	}

	// added
	if(TempFieldValue.length==9)
	{
		if (reInteger.test(TempFieldValue) == false)
		{
			alert(pszFieldNameToAppend + " should be specified as NNNNN-NNNN (or) NNNNN format.");
			ObjZipCode.select();
			ObjZipCode.focus();
			return false;
		}
		else
		{
			FirstFive=TempFieldValue.substr(0,5);
			LastFour=TempFieldValue.substr(5,4);
			if (isNaN(FirstFive)==true || isNaN(LastFour)==true)
			{
				alert(pszFieldNameToAppend + " should be specified as NNNNN-NNNN (or) NNNNN format.");
				ObjZipCode.select();
				ObjZipCode.focus();
				return false;
			}
			else //if(isInteger(FirstFive)==true && isInteger(LastFour)==true)(
				TempFieldValue = FirstFive + "-" + LastFour;
		}
	}
	// end of add

	if (TempFieldValue.length==10)
	{
		FirstFive=TempFieldValue.substr(0,5);
		LastFour=TempFieldValue.substr(6,4);
		Dash=TempFieldValue.substr(5,1);
		if (isIntegerNoMsg(FirstFive)==false || isIntegerNoMsg(LastFour)==false)
		{
			alert(pszFieldNameToAppend + " should be specified as NNNNN-NNNN (or) NNNNN format.");
			ObjZipCode.select();
			ObjZipCode.focus();
			return false;
		}
		if(Dash!="-")
		{
			alert(pszFieldNameToAppend + " should be specified as NNNNN-NNNN (or) NNNNN format.");
			ObjZipCode.select();
			ObjZipCode.focus();
			return false;
		}
	}
	//Modified by Vikas (Since the control on the Page after formatting should contain 10 Chars and not 9 Chars)
	ObjZipCode.maxLength = 10;
	ObjZipCode.value = TempFieldValue;

	return true;
}

/*----------------------------------------------------------------------------------------
	Author				: Shashidhar Rao. L
	Function Name		: FindStringInArray
	Parameters			: 1. StringArray :  It is A comma seperated string.
						: 2. FindVal :	It is the value to be searched.
	Purpose				: To find the String in the StringArray;
	Comments			: Returns true if the match is found.
------------------------------------------------------------------------------------------*/
function FindStringInArray(ArrayString, FindVal){
	var arraySplitData = ArrayString.split(",");
	var Counter = 0;
	for (Counter =0 ; Counter < arraySplitData.length ; Counter ++){
	if (arraySplitData[Counter]== FindVal){
		return true;
		}
	}
	return false;
}

/*----------------------------------------------------------------------------------------
	Author				: Shashidhar Rao. L
	Function Name		: ExceedsMaxLength
	Parameters			: ObjField
						: 
	Purpose				: To Get the string length
	Comments			: Returns true length exceeds
------------------------------------------------------------------------------------------*/
function ExceedsMaxLength(FieldObj, length){
	var MaxLength = length
	if ( TrimTheString(FieldObj.value).length > MaxLength ){
		return true;
	}
	return false;
}
 /*----------------------------------------------------------------------------------------
	Function Name		: IsEmail 
	Parameters			: pszFieldObj
	Purpose				: Validates the Email ID 
	-------------------------------------------------------------------------------------------*/
/*function IsEmail ( pszFieldObj, pszFieldNameToAppend )
{
	//var reEmail = /^.+\@.+\..+$/	
	var reEmail = /^[_a-z0-9A-Z-]+(\.[_a-z0-9A-Z-]+)*@[a-z0-9A-Z-]+(\.[a-z0-9A-Z-]+)*(\.([a-zA-Z]){2,4})$/
	var szBadStrings = " ~`!#$%^&*()+=[{]}|\<>?,:';";
	var szCurrChar;

	szFieldValue = TrimTheString( eval ( pszFieldObj ).value );
	for ( var i=0 ; i < szFieldValue.length ; i++)
	{
		j = i + 1;
		szCurrChar = szFieldValue.substring ( i , j );
		if ( szBadStrings.indexOf ( szCurrChar ) != -1 )
		{
			//eval ( pszFieldObj ).focus();
			alert(pszFieldNameToAppend + " contains invalid letters.");
			return false;		// contains badchar.
		}
	}

	if ( reEmail.test ( szFieldValue ) == false )
	{
		//eval ( pszFieldObj ).focus();
		alert("Invalid email ID.");
		return false;		// invalid email.
	}
	return true;
}
*/
 /*----------------------------------------------------------------------------------------
	Function Name		: CheckCreditobjCardNumber
	Parameters			: objCrediCard
	Purpose				: To check the Credit Card Number
	-------------------------------------------------------------------------------------------*/
	function CheckCreditCard(objCardNumber)
	{
		var loopCounter;
		var FirstDigitsSub = 0;
		var SecondDigitsSum = 0;
		var TempSecondSum = "";
		var LoopValue = 0;
		var CurrentNumber = 0;
		var TotalLengthODD = 0;

		// Only if the number passed is numeric and is more than 14 chars length
		if ( IsSmallLongInt (objCardNumber, '9999999999999999') && objCardNumber.value.length >= 14) 
		{
			// Implementation of LUHN Formula.
			if ( (objCardNumber.value.length % 2) == 0)
				TotalLengthODD = 1
			else
				TotalLengthODD = 0

			var objCardNumbervalue = objCardNumber.value;
			for(loopCounter = objCardNumbervalue.length-1; loopCounter >= 0; loopCounter--)
			{
				CurrentNumber = parseInt( objCardNumbervalue.substr(loopCounter, 1))
				if ( ( loopCounter % 2) == TotalLengthODD)
					FirstDigitsSub += CurrentNumber 
				else
				{
					CurrentNumber *= 2;
					if ( CurrentNumber > 9)
					{
						TempSecondSum = "" + CurrentNumber
						CurrentNumber = parseInt( TempSecondSum.substr(0, 1)) + parseInt( TempSecondSum.substr(1, 1))
					}
					CurrentNumber 
					SecondDigitsSum += CurrentNumber;
				}
				LoopValue = CurrentNumber 
			}
			if ( ( (SecondDigitsSum + FirstDigitsSub ) % 10 ) == 0 )
				return true
			else
			{
				alert("Invalid credit card number. Please enter valid credit card number")
				return false
			}
		}
		else
		{
			alert("Invalid credit card number. Please enter valid credit card number")
			return false
		}
	}

function ShowErrorMessageAndFocus(varErrorMsg, objFieldtoFocus)
{
	alert(varErrorMsg);
	if (objFieldtoFocus.disabled == false)
	{
		objFieldtoFocus.focus()
		objFieldtoFocus.select()
	}
}

 /*----------------------------------------------------------------------------------------
	Function Name		: IsDateValid
	Parameters			: strDateField
	Purpose				: To check the Credit Card Number
	-------------------------------------------------------------------------------------------*/
	function IsDateValid(objDateField)
	{
		return IsValidDateWithMessagePassed( objDateField, "date")
	}

	function IsValidDateWithMessagePassed(objDateField, strFieldDescription)
	{
		var varErrorMsg = "The " + strFieldDescription + " should be specified as (MM/DD/YYYY) or (M/D/YYYY)";
	   	var strDateField = objDateField.value;

		if (strDateField == "")
		{
			ShowErrorMessageAndFocus ( "Please enter the " + strFieldDescription  + " before proceeding.", objDateField)
			return false;
		}
		if (strDateField.length > 10)
		{
			ShowErrorMessageAndFocus ( varErrorMsg, objDateField)
			return false;
		}
		if(strDateField.length!=10 && strDateField.length!=9 && strDateField.length!=8)
		{
			ShowErrorMessageAndFocus ( varErrorMsg , objDateField)
			return false;
		}
		if(strDateField.length==10)
		{
			if ((strDateField.charAt(2) != "/") || (strDateField.charAt(5) != "/"))
			{
				ShowErrorMessageAndFocus ( varErrorMsg, objDateField)
				return false;
			}
			nummonth = strDateField.charAt(0)+strDateField.charAt(1)
			numday = strDateField.charAt(3)+strDateField.charAt(4)
			numyear = strDateField.charAt(6)+strDateField.charAt(7) + strDateField.charAt(8)+strDateField.charAt(9)
		}
		if(strDateField.length==8)
		{
			if ((strDateField.charAt(1) != "/") || (strDateField.charAt(3) != "/"))
			{
				ShowErrorMessageAndFocus ( varErrorMsg, objDateField)
				return false;
			}
			nummonth = strDateField.charAt(0)
			numday = strDateField.charAt(2)
			numyear = strDateField.charAt(4)+strDateField.charAt(5) + strDateField.charAt(6)+strDateField.charAt(7)
		}
		if(strDateField.length==9)
		{
			if (((strDateField.charAt(1) != "/") || (strDateField.charAt(4) != "/")) &&((strDateField.charAt(2) != "/") || (strDateField.charAt(4) != "/")))
			{
				ShowErrorMessageAndFocus ( varErrorMsg, objDateField)
				return false;
			}
			if (strDateField.charAt(1)== "/")
			{
				nummonth = strDateField.charAt(0)
				numday = strDateField.charAt(2)+strDateField.charAt(3)
				numyear =strDateField.charAt(5) + strDateField.charAt(6)+strDateField.charAt(7)+ strDateField.charAt(8)
			}
			else
			{
				nummonth = strDateField.charAt(0)+strDateField.charAt(1)
				numday = strDateField.charAt(3)
				numyear =strDateField.charAt(5) + strDateField.charAt(6)+strDateField.charAt(7)+ strDateField.charAt(8)
			}
		}

		if (numyear.length < 4)
		{
			ShowErrorMessageAndFocus ( "Year should is YYYY", objDateField)
			return false;
		}
		if (!IsPositiveIntValue("Month value in date",nummonth))
			return false;
		if (!IsPositiveIntValue("Day value in date",numday))
			return false;
		if (!IsPositiveIntValue("Year value in date",numyear))
			return false;

		day = parseInt(numday,10)
		month = parseInt(nummonth,10)
		year = parseInt(numyear,10)

		if (isNaN(day) || isNaN(month) || isNaN(year))
		{
			ShowErrorMessageAndFocus ( "Invalid Date", objDateField)
			return false;
		}
		if ((day < 0) || (month < 0) || (year < 0))
		{
			ShowErrorMessageAndFocus ( "Invalid character in " + strFieldDescription, objDateField)
			return false;
		}
		if ((day == 0) || (month == 0) || (year == 0))
		{
			ShowErrorMessageAndFocus ( "Invalid" + strFieldDescription, objDateField)
			return false;
		}
		if (month > 12)
		{
			ShowErrorMessageAndFocus ( "Month cannot be greater than 12", objDateField)
			return false;
		}
		if (day > 31 )
		{
			ShowErrorMessageAndFocus ( "Day cannot be greater than 31 for the given month", objDateField)
			return false;
		}
		if ((month==4)||(month==6)||(month==9)||(month==11))
		{
				if (day > 30 )
				{
					ShowErrorMessageAndFocus ( "Day cannot be greater than 30 for this month", objDateField)
					return false;
				}
		}
		if (month==2)
		{
			if  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) )
			{
				if (day > 29)
			    {
					ShowErrorMessageAndFocus ("Day cannot be greater than 29 for 'Feb' in the given year", objDateField)
			        return false;
				}
			}
			else
			{
				if (day > 28)
				{
					ShowErrorMessageAndFocus ("Day cannot be greater than 28 for 'Feb' in the given year", objDateField)
					return false;
				}
		    }
		}

		if (numyear < 1900)
		{
			ShowErrorMessageAndFocus ("Year cannot be less than 1900.", objDateField)
			return false;
		}

		return true
	}

/*
Author : Upendra
Date: 21 apr 2004
Purpose: The calculates the financials current year totals, next year totals
next three year totals for Income. 
*/
function CalculateIncomeTotals(currentIncomeID, calledFrom)
{
	// All Variables
	var intGrossIncomeID, intGrossIncomeCurrent, intGrossIncomeNextYear, intGrossIncomeThirdYear, isGrossIncomeMonthly, intGrossIncomeNextPerc, intGrossIncomeThirdPerc, GrossIncome
	var intFederalTaxID, intFederalTaxPerc, intFederalTaxCurrent, intFederalTaxNextYear, intFederalTaxThirdYear, isFederalTaxMonthly, intFederalTaxNextPerc, intFederalTaxThirdPerc, FederalTax
	var intStateTaxID, intStateTaxPerc, intStateTaxCurrent, intStateTaxNextYear, intStateTaxThirdYear, isStateTaxMonthly, intStateTaxNextPerc, intStateTaxThirdPerc, StateTax
	var intFICATaxID, intFICATaxPerc, intFICATaxCurrent, intFICATaxNextYear, intFICATaxThirdYear, isFICATaxMonthly, intFICATaxNextPerc, intFICATaxThirdPerc, FICATax
	var intRetirementContributionID, intRetirementContributionCurrent, intRetirementContributionNextYear, intRetirementContributionThirdYear, isRetirementContributionMonthly, intRetirementContributionNextPerc, intRetirementContributionThirdPerc, RetirementContribution
	var intEmployeeBenfitID, intEmployeeBenfitCurrent, intEmployeeBenfitNextYear, intEmployeeBenfitThirdYear, isEmployeeBenfitMonthly, intEmployeeBenfitNextPerc, intEmployeeBenfitThirdPerc, EmployeeBenfit
	var intNetIncomeID, intNetIncomeCurrent, intNetIncomeNextYear, intNetIncomeThirdYear, isNetIncomeMonthly, intNetIncomeNextPerc, intNetIncomeThirdPerc, NetIncome
	var intAfterTaxIncomeID, intAfterTaxIncomeCurrent, intAfterTaxIncomeNextYear, intAfterTaxIncomeThirdYear, isAfterTaxIncomeMonthly, intAfterTaxIncomeNextPerc, intAfterTaxIncomeThirdPerc, AfterTaxIncome
	var intMonthlyTotalsCurrent, intYearlyTotalsCurrent, intMonthlyTotalsNextYear, intYearlyTotalsNextYear, intMonthlyTotalsThirdYear, intYearlyTotalsThirdYear

	// Get the respective IDs for in the Income Page.
	intGrossIncomeID = document.frmMyIncome.hidIncomeID1.value;
	intFederalTaxID = document.frmMyIncome.hidIncomeID2.value;
	intStateTaxID = document.frmMyIncome.hidIncomeID3.value;
	intFICATaxID = document.frmMyIncome.hidIncomeID4.value;
	intRetirementContributionID = document.frmMyIncome.hidIncomeID5.value;
	intEmployeeBenfitID = document.frmMyIncome.hidIncomeID6.value;
	intNetIncomeID = document.frmMyIncome.hidIncomeID7.value;
	intAfterTaxIncomeID = document.frmMyIncome.hidIncomeID8.value;

	// Get the status of Monthly
	isGrossIncomeMonthly = eval("document.frmMyIncome.radMonthYear" + intGrossIncomeID + "[0].checked")
	isFederalTaxMonthly = eval("document.frmMyIncome.radMonthYear" + intFederalTaxID + "[0].checked")
	isStateTaxMonthly = eval("document.frmMyIncome.radMonthYear" + intStateTaxID + "[0].checked")
	isFICATaxMonthly = eval("document.frmMyIncome.radMonthYear" + intFICATaxID + "[0].checked")
	isRetirementContributionMonthly = eval("document.frmMyIncome.radMonthYear" + intRetirementContributionID + "[0].checked")
	isEmployeeBenfitMonthly = eval("document.frmMyIncome.radMonthYear" + intEmployeeBenfitID + "[0].checked")
	isNetIncomeMonthly = eval("document.frmMyIncome.radNetIncomeMonthYear[0].checked")
	isAfterTaxIncomeMonthly = eval("document.frmMyIncome.radMonthYear" + intAfterTaxIncomeID + "[0].checked")

	// when there is some change in Gross Income Monthly / Yearly then the NetIncome also has to change.
	if ( intGrossIncomeID == currentIncomeID )
	{
		document.frmMyIncome.radNetIncomeMonthYear[0].checked = isGrossIncomeMonthly;
		document.frmMyIncome.radNetIncomeMonthYear[1].checked = !isGrossIncomeMonthly;
		isNetIncomeMonthly = isGrossIncomeMonthly
	}

// If the textbox is starting with invalid value then it will make the field into 0
	if( isNaN ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intGrossIncomeID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intGrossIncomeID).value.replace(/\$|\,/g,'') ) ) )		eval("document.frmMyIncome.txtYearAmount" + intGrossIncomeID).value = 0
	if( isNaN ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intRetirementContributionID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intRetirementContributionID).value.replace(/\$|\,/g,'') ) ) )		eval("document.frmMyIncome.txtYearAmount" + intRetirementContributionID).value = 0
	if( isNaN ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intEmployeeBenfitID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intEmployeeBenfitID).value.replace(/\$|\,/g,'') ) ) )		eval("document.frmMyIncome.txtYearAmount" + intEmployeeBenfitID).value = 0
	if( isNaN ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intAfterTaxIncomeID).value.replace(/\$|\,/g,'') ) ) || IsEmpty( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intAfterTaxIncomeID).value.replace(/\$|\,/g,'') ) ) )		eval("document.frmMyIncome.txtYearAmount" + intAfterTaxIncomeID).value = 0
// If the textbox is starting with invalid value then it will make the field into 0
	if( isNaN ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intGrossIncomeID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intGrossIncomeID).value.replace(/\$|\,/g,'') ) ) )		eval("document.frmMyIncome.txtYearAmount" + intGrossIncomeID).value = 0
	if( isNaN ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intRetirementContributionID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intRetirementContributionID).value.replace(/\$|\,/g,'') ) ) )		eval("document.frmMyIncome.txtYearAmount" + intRetirementContributionID).value = 0
	if( isNaN ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intEmployeeBenfitID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intEmployeeBenfitID).value.replace(/\$|\,/g,'') ) ) )		eval("document.frmMyIncome.txtYearAmount" + intEmployeeBenfitID).value = 0
	if( isNaN ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intAfterTaxIncomeID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat(eval("document.frmMyIncome.txtYearAmount" + intAfterTaxIncomeID).value.replace(/\$|\,/g,'') ) ) )		eval("document.frmMyIncome.txtYearAmount" + intAfterTaxIncomeID).value = 0

// If the textbox is starting with invalid value then it will make the field into 0
	if( isNaN ( parseFloat( eval("document.frmMyIncome.txtIncomeNextYear" + intGrossIncomeID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval("document.frmMyIncome.txtIncomeNextYear" + intGrossIncomeID).value.replace(/\$|\,/g,'') ) ) )				eval("document.frmMyIncome.txtIncomeNextYear" + intGrossIncomeID).value = 0.00;
	if( isNaN ( parseFloat( eval("document.frmMyIncome.txtIncomeNextYear" + intFederalTaxID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval("document.frmMyIncome.txtIncomeNextYear" + intFederalTaxID).value.replace(/\$|\,/g,'') ) ) )				eval("document.frmMyIncome.txtIncomeNextYear" + intFederalTaxID).value = 0.00;
	if( isNaN ( parseFloat( eval("document.frmMyIncome.txtIncomeNextYear" + intStateTaxID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval("document.frmMyIncome.txtIncomeNextYear" + intStateTaxID).value.replace(/\$|\,/g,'') ) ) )				eval("document.frmMyIncome.txtIncomeNextYear" + intStateTaxID).value = 0.00;
	if( isNaN ( parseFloat( eval("document.frmMyIncome.txtIncomeNextYear" + intFICATaxID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval("document.frmMyIncome.txtIncomeNextYear" + intFICATaxID).value.replace(/\$|\,/g,'') ) ) )					eval("document.frmMyIncome.txtIncomeNextYear" + intFICATaxID).value = 0.00;
	if( isNaN ( parseFloat( eval("document.frmMyIncome.txtIncomeNextYear" + intRetirementContributionID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval("document.frmMyIncome.txtIncomeNextYear" + intRetirementContributionID).value.replace(/\$|\,/g,'') ) ) )	eval("document.frmMyIncome.txtIncomeNextYear" + intRetirementContributionID).value = 0.00;
	if( isNaN ( parseFloat( eval("document.frmMyIncome.txtIncomeNextYear" + intEmployeeBenfitID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval("document.frmMyIncome.txtIncomeNextYear" + intEmployeeBenfitID).value.replace(/\$|\,/g,'') ) ) )			eval("document.frmMyIncome.txtIncomeNextYear" + intEmployeeBenfitID).value = 0.00;
	if( isNaN ( parseFloat( eval("document.frmMyIncome.txtIncomeNextYear" + intAfterTaxIncomeID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval("document.frmMyIncome.txtIncomeNextYear" + intAfterTaxIncomeID).value.replace(/\$|\,/g,'') ) ) )			eval("document.frmMyIncome.txtIncomeNextYear" + intAfterTaxIncomeID).value = 0.00;

// If the textbox is starting with invalid value then it will make the field into 0
	if( isNaN ( parseFloat( eval("document.frmMyIncome.txtIncomeNext3Year" + intGrossIncomeID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval("document.frmMyIncome.txtIncomeNext3Year" + intGrossIncomeID).value.replace(/\$|\,/g,'') ) ) )				eval("document.frmMyIncome.txtIncomeNext3Year" + intGrossIncomeID).value = 0.00;
	if( isNaN ( parseFloat( eval("document.frmMyIncome.txtIncomeNext3Year" + intFederalTaxID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval("document.frmMyIncome.txtIncomeNext3Year" + intFederalTaxID).value.replace(/\$|\,/g,'') ) ) )				eval("document.frmMyIncome.txtIncomeNext3Year" + intFederalTaxID).value = 0.00;
	if( isNaN ( parseFloat( eval("document.frmMyIncome.txtIncomeNext3Year" + intStateTaxID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval("document.frmMyIncome.txtIncomeNext3Year" + intStateTaxID).value.replace(/\$|\,/g,'') ) ) )				eval("document.frmMyIncome.txtIncomeNext3Year" + intStateTaxID).value = 0.00;
	if( isNaN ( parseFloat( eval("document.frmMyIncome.txtIncomeNext3Year" + intFICATaxID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval("document.frmMyIncome.txtIncomeNext3Year" + intFICATaxID).value.replace(/\$|\,/g,'') ) ) )					eval("document.frmMyIncome.txtIncomeNext3Year" + intFICATaxID).value = 0.00;
	if( isNaN ( parseFloat( eval("document.frmMyIncome.txtIncomeNext3Year" + intRetirementContributionID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval("document.frmMyIncome.txtIncomeNext3Year" + intRetirementContributionID).value.replace(/\$|\,/g,'') ) ) )	eval("document.frmMyIncome.txtIncomeNext3Year" + intRetirementContributionID).value = 0.00;
	if( isNaN ( parseFloat( eval("document.frmMyIncome.txtIncomeNext3Year" + intEmployeeBenfitID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval("document.frmMyIncome.txtIncomeNext3Year" + intEmployeeBenfitID).value.replace(/\$|\,/g,'') ) ) )			eval("document.frmMyIncome.txtIncomeNext3Year" + intEmployeeBenfitID).value = 0.00;
	if( isNaN ( parseFloat( eval("document.frmMyIncome.txtIncomeNext3Year" + intAfterTaxIncomeID).value.replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval("document.frmMyIncome.txtIncomeNext3Year" + intAfterTaxIncomeID).value.replace(/\$|\,/g,'') ) ) )			eval("document.frmMyIncome.txtIncomeNext3Year" + intAfterTaxIncomeID).value = 0.00;

	// these fields have common name.
	intGrossIncomeCurrent = parseFloat((eval("document.frmMyIncome.txtYearAmount" + intGrossIncomeID).value).replace(/\$|\,/g,''));
	intRetirementContributionCurrent = parseFloat((eval("document.frmMyIncome.txtYearAmount" + intRetirementContributionID).value).replace(/\$|\,/g,''));
	intEmployeeBenfitCurrent = parseFloat((eval("document.frmMyIncome.txtYearAmount" + intEmployeeBenfitID).value).replace(/\$|\,/g,''));
	intAfterTaxIncomeCurrent = parseFloat((eval("document.frmMyIncome.txtYearAmount" + intAfterTaxIncomeID).value).replace(/\$|\,/g,''));

	// Get TAX percentages of each which are inputted in MyTaxes Page.
	intFederalTaxPerc = parseFloat((document.frmMyIncome.ArrTax[0].value).replace(/\$|\,/g,''));
	intStateTaxPerc = parseFloat((document.frmMyIncome.ArrTax[1].value).replace(/\$|\,/g,''));
	intFICATaxPerc = parseFloat((document.frmMyIncome.ArrTax[2].value).replace(/\$|\,/g,''));

	// Get the yearly values if the respective Monthly Radio Button is clicked.
	if ( isGrossIncomeMonthly )				intGrossIncomeCurrent = intGrossIncomeCurrent * 12
	if ( isRetirementContributionMonthly )	intRetirementContributionCurrent = intRetirementContributionCurrent * 12
	if ( isEmployeeBenfitMonthly )			intEmployeeBenfitCurrent = intEmployeeBenfitCurrent * 12
	if ( isAfterTaxIncomeMonthly )			intAfterTaxIncomeCurrent = intAfterTaxIncomeCurrent * 12

	// these field values has to be got from the hidden values.
	if ( ( intGrossIncomeCurrent - intRetirementContributionCurrent - intEmployeeBenfitCurrent) > 0 )
	{
		intFederalTaxCurrent = (intGrossIncomeCurrent - intRetirementContributionCurrent - intEmployeeBenfitCurrent) * intFederalTaxPerc /100
		intStateTaxCurrent = (intGrossIncomeCurrent - intRetirementContributionCurrent - intEmployeeBenfitCurrent) * intStateTaxPerc /100
		intFICATaxCurrent = (intGrossIncomeCurrent - intRetirementContributionCurrent - intEmployeeBenfitCurrent) * intFICATaxPerc /100
	}
	else
	{
		intFederalTaxCurrent = 0
		intStateTaxCurrent = 0
		intFICATaxCurrent = 0
	}

	// Get the actual Percentage. the calculation is slightly different. as the previous value also has to be retined.
	// 1 + (Percent/100) -- adding 1 because the current income has to be added to the percent value of the current.
	intGrossIncomeNextPerc = 1.00 + ( parseFloat((eval("document.frmMyIncome.txtIncomeNextYear" + intGrossIncomeID).value).replace(/\$|\,/g,'')) / 100);
	intFederalTaxNextPerc = 1.00 + ( parseFloat((eval("document.frmMyIncome.txtIncomeNextYear" + intFederalTaxID).value).replace(/\$|\,/g,'')) / 100);
	intStateTaxNextPerc = 1.00 + ( parseFloat((eval("document.frmMyIncome.txtIncomeNextYear" + intStateTaxID).value).replace(/\$|\,/g,'')) / 100);
	intFICATaxNextPerc = 1.00 + ( parseFloat((eval("document.frmMyIncome.txtIncomeNextYear" + intFICATaxID).value).replace(/\$|\,/g,'')) / 100);
	intRetirementContributionNextPerc = 1.00 + ( parseFloat((eval("document.frmMyIncome.txtIncomeNextYear" + intRetirementContributionID).value).replace(/\$|\,/g,'')) / 100);
	intEmployeeBenfitNextPerc = 1.00 + ( parseFloat((eval("document.frmMyIncome.txtIncomeNextYear" + intEmployeeBenfitID).value).replace(/\$|\,/g,'')) / 100);
	intAfterTaxIncomeNextPerc = 1.00 + ( parseFloat((eval("document.frmMyIncome.txtIncomeNextYear" + intAfterTaxIncomeID).value).replace(/\$|\,/g,'')) / 100);

	// Calculate the Next Years amount with percent. CurrentAmount + ( (CurrentAmount * Percent)/100)
	intGrossIncomeNextYear = intGrossIncomeCurrent * intGrossIncomeNextPerc
	intFederalTaxNextYear = intFederalTaxCurrent * intFederalTaxNextPerc
	intStateTaxNextYear = intStateTaxCurrent * intStateTaxNextPerc
	intFICATaxNextYear = intFICATaxCurrent * intFICATaxNextPerc
	intRetirementContributionNextYear = intRetirementContributionCurrent * intRetirementContributionNextPerc
	intEmployeeBenfitNextYear = intEmployeeBenfitCurrent * intEmployeeBenfitNextPerc
	intAfterTaxIncomeNextYear = intAfterTaxIncomeCurrent * intAfterTaxIncomeNextPerc

	// Get the actual Third Years Percentage. the calculation is slightly different. as the previous value also has to be retined.
	// 1 + (Percent/100) -- adding 1 because the NextYear income has to be added to the percent value of the NextYear.
	intGrossIncomeThirdPerc = 1.00 + ( parseFloat((eval("document.frmMyIncome.txtIncomeNext3Year" + intGrossIncomeID).value).replace(/\$|\,/g,'')) / 100);
	intFederalTaxThirdPerc = 1.00 + ( parseFloat((eval("document.frmMyIncome.txtIncomeNext3Year" + intFederalTaxID).value).replace(/\$|\,/g,'')) / 100);
	intStateTaxThirdPerc = 1.00 + ( parseFloat((eval("document.frmMyIncome.txtIncomeNext3Year" + intStateTaxID).value).replace(/\$|\,/g,'')) / 100);
	intFICATaxThirdPerc = 1.00 + ( parseFloat((eval("document.frmMyIncome.txtIncomeNext3Year" + intFICATaxID).value).replace(/\$|\,/g,'')) / 100);
	intRetirementContributionThirdPerc = 1.00 + ( parseFloat((eval("document.frmMyIncome.txtIncomeNext3Year" + intRetirementContributionID).value).replace(/\$|\,/g,'')) / 100);
	intEmployeeBenfitThirdPerc = 1.00 + ( parseFloat((eval("document.frmMyIncome.txtIncomeNext3Year" + intEmployeeBenfitID).value).replace(/\$|\,/g,'')) / 100);
	intAfterTaxIncomeThirdPerc = 1.00 + ( parseFloat((eval("document.frmMyIncome.txtIncomeNext3Year" + intAfterTaxIncomeID).value).replace(/\$|\,/g,'')) / 100);

	// Calculate the Next Years amount with percent. NextYear + ( (NextYear * Percent)/100)
	intGrossIncomeThirdYear  = intGrossIncomeNextYear * intGrossIncomeThirdPerc
	intFederalTaxThirdYear = intFederalTaxNextYear * intFederalTaxThirdPerc
	intStateTaxThirdYear = intStateTaxNextYear * intStateTaxThirdPerc
	intFICATaxThirdYear = intFICATaxNextYear * intFICATaxThirdPerc
	intRetirementContributionThirdYear = intRetirementContributionNextYear * intRetirementContributionThirdPerc
	intEmployeeBenfitThirdYear = intEmployeeBenfitNextYear * intEmployeeBenfitThirdPerc
	intAfterTaxIncomeThirdYear = intAfterTaxIncomeNextYear * intAfterTaxIncomeThirdPerc

	// Calculate Net Income 
	intNetIncomeCurrent = intGrossIncomeCurrent - intRetirementContributionCurrent - intEmployeeBenfitCurrent - intFederalTaxCurrent - intStateTaxCurrent - intFICATaxCurrent
	intNetIncomeNextYear = intGrossIncomeNextYear - intRetirementContributionNextYear - intEmployeeBenfitNextYear - intFederalTaxNextYear - intStateTaxNextYear - intFICATaxNextYear
	intNetIncomeThirdYear = intGrossIncomeThirdYear - intRetirementContributionThirdYear - intEmployeeBenfitThirdYear - intFederalTaxThirdYear - intStateTaxThirdYear - intFICATaxThirdYear

	// Calculate Yearly Totals to show in the bottom
	intYearlyTotalsCurrent = intNetIncomeCurrent + intAfterTaxIncomeCurrent
	intYearlyTotalsNextYear = intNetIncomeNextYear + intAfterTaxIncomeNextYear
	intYearlyTotalsThirdYear = intNetIncomeThirdYear + intAfterTaxIncomeThirdYear
	
	// Calculate Monthly Totals to show in the bottom
	intMonthlyTotalsCurrent = intYearlyTotalsCurrent / 12
	intMonthlyTotalsNextYear = intYearlyTotalsNextYear / 12
	intMonthlyTotalsThirdYear = intYearlyTotalsThirdYear / 12

	// Make the Next Year and Third Year Values into Monthly if they corrosponding Radio button is Monthly
	// Gross Income
	if ( isGrossIncomeMonthly )					intGrossIncomeNextYear = intGrossIncomeNextYear /12
	if ( isGrossIncomeMonthly )					intGrossIncomeThirdYear = intGrossIncomeThirdYear /12
	//Federal Tax
	if ( isFederalTaxMonthly )					intFederalTaxCurrent = intFederalTaxCurrent / 12
	if ( isFederalTaxMonthly )					intFederalTaxNextYear = intFederalTaxNextYear /12
	if ( isFederalTaxMonthly )					intFederalTaxThirdYear = intFederalTaxThirdYear /12
	//State Tax
	if ( isStateTaxMonthly)						intStateTaxCurrent = intStateTaxCurrent /12
	if ( isStateTaxMonthly)						intStateTaxNextYear = intStateTaxNextYear /12
	if ( isStateTaxMonthly)						intStateTaxThirdYear = intStateTaxThirdYear /12
	// FICA Tax
	if ( isFICATaxMonthly)						intFICATaxCurrent = intFICATaxCurrent /12
	if ( isFICATaxMonthly)						intFICATaxNextYear = intFICATaxNextYear /12
	if ( isFICATaxMonthly)						intFICATaxThirdYear = intFICATaxThirdYear /12
	// Retirement Contribution
	if ( isRetirementContributionMonthly)		intRetirementContributionNextYear = intRetirementContributionNextYear /12
	if ( isRetirementContributionMonthly)		intRetirementContributionThirdYear = intRetirementContributionThirdYear /12
	// Employee Beneift
	if ( isEmployeeBenfitMonthly)				intEmployeeBenfitNextYear = intEmployeeBenfitNextYear /12
	if ( isEmployeeBenfitMonthly)				intEmployeeBenfitThirdYear = intEmployeeBenfitThirdYear /12
	// After Tax Income
	if ( isAfterTaxIncomeMonthly)				intAfterTaxIncomeNextYear = intAfterTaxIncomeNextYear /12
	if ( isAfterTaxIncomeMonthly)				intAfterTaxIncomeThirdYear = intAfterTaxIncomeThirdYear /12
	// Net Income
	if ( isNetIncomeMonthly)					intNetIncomeCurrent = intNetIncomeCurrent /12
	if ( isNetIncomeMonthly)					intNetIncomeNextYear = intNetIncomeNextYear /12
	if ( isNetIncomeMonthly)					intNetIncomeThirdYear = intNetIncomeThirdYear /12

	// assgin Gross Income	Hidden
	eval("document.frmMyIncome.hidIncomeNextYear" + intGrossIncomeID).value = intGrossIncomeNextYear 
	eval("document.frmMyIncome.hidIncomeNext3rdYear" + intGrossIncomeID).value = intGrossIncomeThirdYear 
	// assgin Gross Income	Spans
	document.getElementById('spnIncomeNextYear' + intGrossIncomeID).innerHTML = formatCurrency( intGrossIncomeNextYear )
	document.getElementById('spnIncomeNext3Year' + intGrossIncomeID).innerHTML = formatCurrency( intGrossIncomeThirdYear )

	// assgin Federal Tax	Hidden
	document.frmMyIncome.hidCurrentYearTax[0].value = intFederalTaxCurrent
	document.frmMyIncome.hidIncomeCurrentYear1.value = intFederalTaxCurrent
	eval("document.frmMyIncome.hidIncomeNextYear" + intFederalTaxID).value = intFederalTaxNextYear 
	eval("document.frmMyIncome.hidIncomeNext3rdYear" + intFederalTaxID).value = intFederalTaxThirdYear 
	// assgin Federal Tax	Spans
	document.getElementById('spnIncomeCurrentYear1').innerHTML = formatCurrency( intFederalTaxCurrent )
	document.getElementById('spnIncomeNextYear' + intFederalTaxID).innerHTML = formatCurrency( intFederalTaxNextYear )
	document.getElementById('spnIncomeNext3Year' + intFederalTaxID).innerHTML = formatCurrency( intFederalTaxThirdYear ) 

	// assgin State Tax		Hidden
	document.frmMyIncome.hidCurrentYearTax[1].value = intStateTaxCurrent
	document.frmMyIncome.hidIncomeCurrentYear2.value = intStateTaxCurrent
	eval("document.frmMyIncome.hidIncomeNextYear" + intStateTaxID).value = intStateTaxNextYear 
	eval("document.frmMyIncome.hidIncomeNext3rdYear" + intStateTaxID).value = intStateTaxThirdYear 
	
	// assgin State Tax		Spans
	document.getElementById('spnIncomeCurrentYear2').innerHTML = formatCurrency( intStateTaxCurrent )
	document.getElementById('spnIncomeNextYear' + intStateTaxID).innerHTML = formatCurrency( intStateTaxNextYear )
	document.getElementById('spnIncomeNext3Year' + intStateTaxID).innerHTML = formatCurrency( intStateTaxThirdYear )

	// assgin FICA Tax		Hidden
	document.frmMyIncome.hidCurrentYearTax[2].value = intFICATaxCurrent
	document.frmMyIncome.hidIncomeCurrentYear3.value = intFICATaxCurrent
	eval("document.frmMyIncome.hidIncomeNextYear" + intFICATaxID).value = intFICATaxNextYear 
	eval("document.frmMyIncome.hidIncomeNext3rdYear" + intFICATaxID).value = intFICATaxThirdYear 
	
	// assgin FICA Tax		Spans
	document.getElementById('spnIncomeCurrentYear3').innerHTML = formatCurrency( intFICATaxCurrent )
	document.getElementById('spnIncomeNextYear' + intFICATaxID).innerHTML = formatCurrency( intFICATaxNextYear )
	document.getElementById('spnIncomeNext3Year' + intFICATaxID).innerHTML = formatCurrency( intFICATaxThirdYear )

	// assgin RetirementContribution Hidden
	eval("document.frmMyIncome.hidIncomeNextYear" + intRetirementContributionID).value = intRetirementContributionNextYear 
	eval("document.frmMyIncome.hidIncomeNext3rdYear" + intRetirementContributionID).value = intRetirementContributionThirdYear 
	// assgin RetirementContribution Spans
	document.getElementById('spnIncomeNextYear' + intRetirementContributionID).innerHTML = formatCurrency( intRetirementContributionNextYear )
	document.getElementById('spnIncomeNext3Year' + intRetirementContributionID).innerHTML = formatCurrency( intRetirementContributionThirdYear )

	// assgin EmployeeBenfit Hidden
	eval("document.frmMyIncome.hidIncomeNextYear" + intEmployeeBenfitID).value = intEmployeeBenfitNextYear 
	eval("document.frmMyIncome.hidIncomeNext3rdYear" + intEmployeeBenfitID).value = intEmployeeBenfitThirdYear 

	// assgin EmployeeBenfit Spans
	document.getElementById('spnIncomeNextYear' + intEmployeeBenfitID).innerHTML = formatCurrency( intEmployeeBenfitNextYear )
	document.getElementById('spnIncomeNext3Year' + intEmployeeBenfitID).innerHTML = formatCurrency( intEmployeeBenfitThirdYear )

	// assgin AfterTaxIncome Hidden
	eval("document.frmMyIncome.hidIncomeNextYear" + intAfterTaxIncomeID).value = intAfterTaxIncomeNextYear 
	eval("document.frmMyIncome.hidIncomeNext3rdYear" + intAfterTaxIncomeID).value = intAfterTaxIncomeThirdYear 
	// assgin AfterTaxIncome Spans
	document.getElementById('spnIncomeNextYear' + intAfterTaxIncomeID).innerHTML = formatCurrency( intAfterTaxIncomeNextYear )
	document.getElementById('spnIncomeNext3Year' + intAfterTaxIncomeID).innerHTML = formatCurrency( intAfterTaxIncomeThirdYear )

	// assgin NetIncome Hidden
	document.frmMyIncome.hidYearspnNetCurrentYear.value = intNetIncomeCurrent
	document.frmMyIncome.hidYearspnNetNextYear.value = intNetIncomeNextYear 
	document.frmMyIncome.hidYearspnNetNext3Year.value = intNetIncomeThirdYear 
	// assgin NetIncome Spans
	document.getElementById('spnNetCurrentYear').innerHTML = formatCurrency( intNetIncomeCurrent )
	document.getElementById('spnNetNextYear').innerHTML = formatCurrency( intNetIncomeNextYear )
	document.getElementById('spnNetNext3Year').innerHTML = formatCurrency( intNetIncomeThirdYear )

	// assgin Monthly Income Details Spans
	document.getElementById('lblMonthlyTotal').innerHTML = formatCurrency( intMonthlyTotalsCurrent )
	document.getElementById('lblMonthlyTotalNextYear').innerHTML = formatCurrency( intMonthlyTotalsNextYear )
	document.getElementById('lblMonthlyTotalNext3Year').innerHTML = formatCurrency( intMonthlyTotalsThirdYear )

	// assgin Yearly Income Details Spans
	document.getElementById('lblYearlyTotal').innerHTML = formatCurrency( intYearlyTotalsCurrent )
	document.getElementById('lblTotalNextYear').innerHTML = formatCurrency( intYearlyTotalsNextYear )
	document.getElementById('lblTotalNext3Year').innerHTML = formatCurrency( intYearlyTotalsThirdYear )

	document.frmMyIncome.hidTotalIncomeCurrentYear.value = intYearlyTotalsCurrent
	document.frmMyIncome.hidTotalIncomeNextYear.value = intYearlyTotalsNextYear 
	document.frmMyIncome.hidTotalIncomeNext3Year.value = intYearlyTotalsThirdYear 
}
/*End of Financial CalculateIncomeTotals function*/
/*
Author : Upendra
Date: 21 Apr2004
Purpose: Validates all income amounts.
*/
function validateIncomeForm(action)
{
    var IsValidate=true; 
	var TotalCount=document.frmMyIncome.hidCount.value; 
	var editPermission = document.frmMyIncome.EditPermission.value;
 	if(editPermission=="NO")
 	{
 		ErrorMessageOneMonth();
 		document.frmMyIncome.reset();
 		var incomeID=eval("document.frmMyIncome.hidIncomeID1.value"); 
		CalculateIncomeTotals(incomeID ,true);
 		IsValidate=false;
 		return false;
 	}  
 	//contains the Non-tax items amounts and ids
 	var arrAmount = new Array();
 	var arrIDs = new Array();
 	var arrCount =0;
 	
 	//Store the Current year value into textbox
 	for(var loopcounter=1; loopcounter <= TotalCount; loopcounter++)
	{
		var isTaxItem=eval("document.frmMyIncome.hidIsTaxItem"+loopcounter+".value"); 
		var incomeID=eval("document.frmMyIncome.hidIncomeID"+loopcounter+".value"); 
		if(isTaxItem=="N")
		{   
		     arrAmount[arrCount]=parseFloat((eval("document.frmMyIncome.txtYearAmount"+incomeID+".value")).replace(/\$|\,/g,''));
		     arrIDs[arrCount]=parseInt(incomeID);
		     arrCount++;
		}    
	}
	//Validate the gross income should be greater than 401k,employee benefit,Other Income
	for(var loopcounter=1; loopcounter < arrAmount.length; loopcounter++)
	{
		if(arrAmount[0] < arrAmount[loopcounter])
		{
			switch(loopcounter)
			{
				case 1: alert("401k/403b Retirement Contributions should be less than Gross Income");
						break;
				case 2: alert("Employee Benefit Payroll Deductions should be less than Gross Income");
						break;
				case 3: alert("After-Tax Income from other sources should be less than Gross Income");
						break;
			}
			eval("document.frmMyIncome.txtYearAmount"+arrIDs[loopcounter]+".focus();");
			IsValidate=false;
			return false;
		}
	}
	
	//Validate all forms variable
	for(var loopcounter=1; loopcounter <= TotalCount; loopcounter++)
	{
	    var pbAllowSign = false; 
		var isTaxItem=eval("document.frmMyIncome.hidIsTaxItem"+loopcounter+".value"); 
		//if net Income, donot valid   
		if(isTaxItem=="E") continue;
	    var incomeID=eval("document.frmMyIncome.hidIncomeID"+loopcounter+".value"); 
		if(isTaxItem=="N")
		{   
		    var objcurrentYearValue=eval("document.frmMyIncome.txtYearAmount"+incomeID);
		    if ( TrimTheString(objcurrentYearValue.value) == "" )	objcurrentYearValue.value = 0.00;

			if(!(IsCurrencyFloatSign(objcurrentYearValue,pbAllowSign)))
			{
				IsValidate=false;
				return false;
			} 
			
			//Validating the next percentage value
			var objpercentSecondYear=eval("document.frmMyIncome.txtIncomeNextYear"+incomeID); 
		    if ( TrimTheString(objpercentSecondYear.value) == "" )	objpercentSecondYear.value = 0.00;
			
			if(!ValidateTaxPercentage(objpercentSecondYear,"")) 
			{
				eval("document.frmMyIncome.txtIncomeNextYear"+incomeID+".focus();");
				IsValidate=false;
				return false;
			}   
			
			//Validating third year percentage value   
			var objpercentThirdYear=eval("document.frmMyIncome.txtIncomeNext3Year"+incomeID); 
		    if ( TrimTheString(objpercentThirdYear.value) == "" )	objpercentThirdYear.value = 0.00;

			if(!ValidateTaxPercentage(objpercentThirdYear,""))
			{
				eval("document.frmMyIncome.txtIncomeNext3Year"+incomeID+".focus();");
				IsValidate=false;
				return false;
			}  
		}  
		else if(isTaxItem=="Y")
		{   //if taxtems then only validate the Percentage next year and next third year
		   	//Validating the next percentage value
			var objpercentSecondYear=eval("document.frmMyIncome.txtIncomeNextYear"+incomeID); 
		    if ( TrimTheString(objpercentSecondYear.value) == "" )	objpercentSecondYear.value = 0.00;

			if(!ValidateTaxPercentage(objpercentSecondYear,"")) 
			{
				eval("document.frmMyIncome.txtIncomeNextYear"+incomeID+".focus();");
				IsValidate=false;
				return false;
			}   
			
			//Validating third year percentage value   
			var objpercentThirdYear=eval("document.frmMyIncome.txtIncomeNext3Year"+incomeID); 
		    if ( TrimTheString(objpercentThirdYear.value) == "" )	objpercentThirdYear.value = 0.00;
			if(!ValidateTaxPercentage(objpercentThirdYear,""))
			{
				eval("document.frmMyIncome.txtIncomeNext3Year"+incomeID+".focus();");
				IsValidate=false;
				return false;
			}  
		}  
	} // end of for loop

		
	if(IsValidate && action!=0)
	{
		var hidFederalTax = parseFloat (document.frmMyIncome.hidIncomeCurrentYear1.value)
		var hidStateTax = parseFloat(document.frmMyIncome.hidIncomeCurrentYear2.value)
		var hidSocialSecurityTax = parseFloat(document.frmMyIncome.hidIncomeCurrentYear3.value)

		document.frmMyIncome.hidCurrentYearTax[0].value = hidFederalTax;
		document.frmMyIncome.hidCurrentYearTax[1].value = hidStateTax;
		document.frmMyIncome.hidCurrentYearTax[2].value = hidSocialSecurityTax;
			
		document.frmMyIncome.hidAction.value = action; 
		document.frmMyIncome.submit();  //submits the form
	}
	else
	    return false;
}
/*End of Financial ValidateIncomeForm function*/	
/*
Author : Upendra
Date: 23 Feb 2004
Purpose: In financials Expense Pages, calculates the current year totals, next year totals
next three year totals. 
*/
function CalculateYearTotal(currentExpenceID, objfrm)
{
	var intMaxRows = eval(objfrm +'.hidCount').value;  
	var intCurrentTotal = 0, intNextYearTotal = 0, intThirdYearTotal = 0;

	for (var intLoopCounter = 1; intLoopCounter <= intMaxRows; intLoopCounter++ )
	{
		var intExpenseID = -1, intItemCurrentAmount = 0, intNextYearPercent = 0, intThirdYearPercent = 0, IsItemMonthly = ''
		var intNextYearAmount = 0, intThirdYearAmount = 0

		intExpenseID = parseInt(eval(objfrm+".hidExpenseID" + intLoopCounter + ".value"));

		if ( isNaN ( parseFloat( eval (objfrm+".txtYearAmount" + intExpenseID + ".value").replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval (objfrm+".txtYearAmount" + intExpenseID + ".value").replace(/\$|\,/g,'') ) ) )			eval(objfrm+".txtYearAmount" + intExpenseID).value = 0
		if ( isNaN ( parseFloat( eval (objfrm+".txtExpenseNextYear" + intExpenseID + ".value").replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval (objfrm+".txtExpenseNextYear" + intExpenseID + ".value").replace(/\$|\,/g,'') ) ) )			eval(objfrm+".txtExpenseNextYear" + intExpenseID).value = 0
		if ( isNaN ( parseFloat( eval (objfrm+".txtExpenseNext3Year" + intExpenseID + ".value").replace(/\$|\,/g,'') ) ) || "0" == ( parseFloat( eval (objfrm+".txtExpenseNext3Year" + intExpenseID + ".value").replace(/\$|\,/g,'') ) ) )			eval(objfrm+".txtExpenseNext3Year" + intExpenseID).value = 0

		intItemCurrentAmount = parseFloat(eval (objfrm+".txtYearAmount" + intExpenseID + ".value").replace(/\$|\,/g,'') ) ;

		IsItemMonthly = eval (objfrm+".radMonthYear" + intExpenseID + "[0].checked")
	
		if ( IsItemMonthly ) intItemCurrentAmount  = intItemCurrentAmount * 12

		var KristyExcelCalc = false;
		var intNextYearAmount = 0;
		var intThirdYearAmount = 0;

		if ( KristyExcelCalc == true )
		{
			intNextYearPercent = 1.00 + ( parseFloat(eval (objfrm+".txtExpenseNextYear" + intExpenseID + ".value").replace(/\$|\,/g,'') ) ) / 100 ;
			intThirdYearPercent = 1.00 + ( parseFloat(eval (objfrm+".txtExpenseNext3Year" + intExpenseID + ".value").replace(/\$|\,/g,'') ) ) / 100 ;

			intNextYearAmount = intItemCurrentAmount * intNextYearPercent
			intThirdYearAmount = intNextYearAmount * intThirdYearPercent
		}
		else
		{
			intNextYearPercent = ( parseFloat(eval (objfrm+".txtExpenseNextYear" + intExpenseID + ".value").replace(/\$|\,/g,'') ) ) ;
			intThirdYearPercent = ( parseFloat(eval (objfrm+".txtExpenseNext3Year" + intExpenseID + ".value").replace(/\$|\,/g,'') ) ) ;

			intNextYearAmount = intItemCurrentAmount  + ( intItemCurrentAmount * intNextYearPercent )/ 100
			intThirdYearAmount = intNextYearAmount + ( intNextYearAmount * intThirdYearPercent )/ 100
		}

		intCurrentTotal += intItemCurrentAmount;
		intNextYearTotal += intNextYearAmount;
		intThirdYearTotal += intThirdYearAmount;

		if ( IsItemMonthly ) 
		{
			intItemCurrentAmount  = intItemCurrentAmount / 12
			intNextYearAmount  = intNextYearAmount / 12
			intThirdYearAmount  = intThirdYearAmount / 12
		}
/*
		if ( intThirdYearAmount >= 930.364 && intThirdYearAmount <= 930.365  )
			intThirdYearAmount  = 930.365
*/
		eval(objfrm + ".txtYearAmount" + intExpenseID ).value = formatCurrency(intItemCurrentAmount).replace("$", "");
		eval(objfrm + ".hidExpenseNextYear" + intExpenseID ).value = intNextYearAmount;
		eval(objfrm + ".hidExpenseNext3Year" + intExpenseID ).value = intThirdYearAmount;

		if ( KristyExcelCalc == true )
		{
			document.getElementById("spnExpenseNextYear" + intExpenseID).innerHTML = formatCurrency(intNextYearAmount)
			document.getElementById("spnExpenseNext3Year" + intExpenseID).innerHTML = formatCurrency(intThirdYearAmount)
		}
		else
		{
			document.getElementById("spnExpenseNextYear" + intExpenseID).innerHTML = formatCurrency(intNextYearAmount)
			document.getElementById("spnExpenseNext3Year" + intExpenseID).innerHTML = formatCurrency(intThirdYearAmount)
		}
	}

	if ( true == true)
	{
		document.getElementById("lblMonthlyTotal").innerHTML = formatCurrency( intCurrentTotal / 12 )
		document.getElementById("lblMonthlyTotalNextYear").innerHTML = formatCurrency( intNextYearTotal / 12 )
		document.getElementById("lblMonthlyTotalNext3Year").innerHTML = formatCurrency( intThirdYearTotal / 12 )

		document.getElementById("lblYearlyTotal").innerHTML = formatCurrency( intCurrentTotal )
		document.getElementById("lblTotalNextYear").innerHTML = formatCurrency( intNextYearTotal )
		document.getElementById("lblTotalNext3Year").innerHTML = formatCurrency( intThirdYearTotal )

		eval(objfrm + ".hidCurrentYearlyTotal").value = intCurrentTotal 
		eval(objfrm + ".hidNextYearlyTotal").value = intNextYearTotal 
		eval(objfrm + ".hidNext3rdYearlyTotal").value = intThirdYearTotal 
	}
	else
	{
		document.getElementById("lblMonthlyTotal").innerHTML = intCurrentTotal / 12 
		document.getElementById("lblMonthlyTotalNextYear").innerHTML = intNextYearTotal / 12 
		document.getElementById("lblMonthlyTotalNext3Year").innerHTML = intThirdYearTotal / 12 

		document.getElementById("lblYearlyTotal").innerHTML = intCurrentTotal 
		document.getElementById("lblTotalNextYear").innerHTML = intNextYearTotal 
		document.getElementById("lblTotalNext3Year").innerHTML = intThirdYearTotal 

		eval(objfrm + ".hidCurrentYearlyTotal").value = intCurrentTotal;
		eval(objfrm + ".hidNextYearlyTotal").value = intNextYearTotal;
		eval(objfrm + ".hidNext3rdYearlyTotal").value = intThirdYearTotal;
	}

//alert(intCurrentTotal)
/*
	var sumMonthly=0.00,sumYearly=0.00,NextYearAmount,Next3YearAmount;
	var TotalCount=eval(objfrm +'.hidCount').value;    //contains the no.of Rows
	
	//percentage calculation
	var ThisYearAmount=parseFloat((eval(objfrm+".txtYearAmount" + currentExpenceID).value).replace(/\$|\,/g,''));
	var NextYearPercentage=parseFloat((eval(objfrm+".txtExpenseNextYear" + currentExpenceID).value).replace(/\$|\,/g,''));
	var Next3YearPercentage=parseFloat((eval(objfrm+".txtExpenseNext3Year" + currentExpenceID).value).replace(/\$|\,/g,'')); 
	if(isNaN(ThisYearAmount))
	{
		eval(objfrm+".txtYearAmount" + currentExpenceID).value = 0.00;
		ThisYearAmount =0.00;
	}
	if(isNaN(NextYearPercentage))
	{
		eval(objfrm+".txtExpenseNextYear" + currentExpenceID).value= 0.00;
		NextYearPercentage = 0.00; 
	}					
	if(isNaN(Next3YearPercentage))
	{
		eval(objfrm+".txtExpenseNext3Year" + currentExpenceID).value= 0.00;
		Next3YearPercentage = 0.00; 
	}
	
	NextYearAmount=ThisYearAmount + ((ThisYearAmount*NextYearPercentage)/100);
	eval(objfrm+".hidExpenseNextYear" + currentExpenceID).value=NextYearAmount;
	
//upendra document.getElementById('spnExpenseNextYear' + currentExpenceID).innerHTML=formatCurrency(NextYearAmount);
	
	document.getElementById('spnExpenseNextYear' + currentExpenceID).innerHTML=NextYearAmount;
	//percentage next 3 year calculation
//	Next3YearAmount=NextYearAmount + round(((NextYearAmount *Next3YearPercentage)/100),2);

	Next3YearAmount=(ThisYearAmount + ((ThisYearAmount*NextYearPercentage)/100)) + (((ThisYearAmount + ((ThisYearAmount*NextYearPercentage)/100)) *Next3YearPercentage)/100);

	eval(objfrm+".hidExpenseNext3Year" + currentExpenceID).value=Next3YearAmount;
//upendra document.getElementById('spnExpenseNext3Year' + currentExpenceID).innerHTML=formatCurrency(Next3YearAmount);

	document.getElementById('spnExpenseNext3Year' + currentExpenceID).innerHTML=Next3YearAmount;
	//Sum code (Monthly Total/Yearly Total)
	for( var loopCounter=1; loopCounter <= TotalCount; loopCounter++)
	{ 
		var expenseID=parseInt(eval(objfrm+".hidExpenseID"+loopCounter+".value"));
		var amount=parseFloat((eval(objfrm+".txtYearAmount"+expenseID).value).replace(/\$|\,/g,''));
		if( isNaN(amount) )
		{
			eval(objfrm+".txtYearAmount"+expenseID).value= 0.00;
			amount = 0.00;
		}
		if(!isNaN(amount)&& !IsWhitespace(amount) )
		{
			if(eval(objfrm+".radMonthYear"+expenseID+"[0].checked"))  
					sumYearly += parseFloat(12*amount); 
			if(eval(objfrm+".radMonthYear"+expenseID+"[1].checked"))        
					sumYearly += parseFloat(amount);  
		} 
	}
	//sumMonthly=round(sumYearly/12,2);
	eval(objfrm+".hidCurrentYearlyTotal").value=sumYearly;
	sumMonthly=(sumYearly/12);
	
	//upendra
	/ *document.getElementById("lblMonthlyTotal").innerHTML= formatCurrency(sumMonthly);  //formats the number
	document.getElementById("lblYearlyTotal").innerHTML = formatCurrency(sumYearly);
	* /	
	
	document.getElementById("lblMonthlyTotal").innerHTML= sumMonthly;  //formats the number
	document.getElementById("lblYearlyTotal").innerHTML = sumYearly;
	
	
	//Sum of Next years
	var sumNextYear=0.0;
	for(loopCounter=1; loopCounter <= TotalCount; loopCounter++)
	{ 
		var expenseID=parseInt(eval(objfrm+".hidExpenseID"+loopCounter+".value"));
		//Remove $ symbol and commas from the Expense Next Year
		var amount=parseFloat((document.getElementById('spnExpenseNextYear'+expenseID).innerHTML).replace(/\$|\,/g,''));
	    //var amount=parseFloat((eval(objfrm+".hidExpenseNextYear"+expenseID).value));
	    if(!isNaN(amount) &&  !IsWhitespace(amount))
			if(eval(objfrm+".radMonthYear"+expenseID+"[0].checked"))   
				{sumNextYear += parseFloat(12*amount);  }   //if monthly total
			else
				{sumNextYear += parseFloat(amount);  }   //if monthly total		
	}
	
	//Sum of next 3 Years 
	//var sumMonthlyNextYear = round(sumNextYear/12,2);
	eval(objfrm+".hidNextYearlyTotal").value=sumNextYear;
	var sumMonthlyNextYear = (sumNextYear/12);
	//upendra
	/ *document.getElementById("lblMonthlyTotalNextYear").innerHTML = formatCurrency(sumMonthlyNextYear);	//Sum Next Year
	document.getElementById("lblTotalNextYear").innerHTML = formatCurrency(sumNextYear);	//Sum Next Year
	* /
	document.getElementById("lblMonthlyTotalNextYear").innerHTML = sumMonthlyNextYear;	//Sum Next Year
	document.getElementById("lblTotalNextYear").innerHTML = sumNextYear;	//Sum Next Year
	
	var sumNext3Year=0.0;
	for( loopCounter=1; loopCounter <= TotalCount; loopCounter++)
		{ 
			var expenseID=parseInt(eval(objfrm+".hidExpenseID"+loopCounter+".value"));
			//Remove $ symbol and commas from the Expense Next Three Year
			var amount=parseFloat((document.getElementById('spnExpenseNext3Year'+expenseID).innerHTML).replace(/\$|\,/g,''));
			//var amount=parseFloat((eval(objfrm+".hidExpenseNext3Year"+expenseID).value));
			if(eval(objfrm+".radMonthYear"+expenseID+"[0].checked"))   
					sumNext3Year += parseFloat(12*amount);     //if monthly total then multiply 12
				else
					sumNext3Year += parseFloat(amount);     //if monthly total	
		}
	
	//var sumMonthlyNext3Year = round(sumNext3Year/12,2);
	eval(objfrm+".hidNext3rdYearlyTotal").value=sumNext3Year;
	var sumMonthlyNext3Year = (sumNext3Year/12);
	
	//upendra
/ *	document.getElementById("lblMonthlyTotalNext3Year").innerHTML=formatCurrency(sumMonthlyNext3Year);	//Sum Next Year
	document.getElementById("lblTotalNext3Year").innerHTML=formatCurrency(sumNext3Year); //Sum 3rd Year
* /
	document.getElementById("lblMonthlyTotalNext3Year").innerHTML = sumMonthlyNext3Year;	//Sum Next Year
	document.getElementById("lblTotalNext3Year").innerHTML = sumNext3Year; //Sum 3rd Year

	/ **apply the format currency current year,next year, third year amounts* /
	for( loopCounter=1; loopCounter <= TotalCount; loopCounter++)
	{
		var expenseID = parseInt(eval(objfrm+".hidExpenseID"+loopCounter+".value"));
		var spnNextYear = document.getElementById('spnExpenseNextYear'+expenseID).innerHTML;
		var spnNext3rdYear = document.getElementById('spnExpenseNext3Year'+expenseID).innerHTML;

		document.getElementById('spnExpenseNextYear'+expenseID).innerHTML = formatCurrency(spnNextYear);
		document.getElementById('spnExpenseNext3Year'+expenseID).innerHTML = formatCurrency(spnNext3rdYear);
	}

	document.getElementById("lblMonthlyTotal").innerHTML = formatCurrency(document.getElementById("lblMonthlyTotal").innerHTML);  
	document.getElementById("lblYearlyTotal").innerHTML  = formatCurrency(document.getElementById("lblYearlyTotal").innerHTML);  

	document.getElementById("lblMonthlyTotalNextYear").innerHTML = formatCurrency(document.getElementById("lblMonthlyTotalNextYear").innerHTML);
	document.getElementById("lblTotalNextYear").innerHTML = formatCurrency(document.getElementById("lblTotalNextYear").innerHTML); 

	document.getElementById("lblMonthlyTotalNext3Year").innerHTML = formatCurrency(document.getElementById("lblMonthlyTotalNext3Year").innerHTML);
	document.getElementById("lblTotalNext3Year").innerHTML = formatCurrency(document.getElementById("lblTotalNext3Year").innerHTML);
*/
}
/*End of CalculateYearTotal */



/*----------------------------------------------------------------------------------------
	Author				: Upendra
	Function Name		: validateExpenseForm
	Parameters			: action,formName
	Purpose				: Common Validation code for Expenses (personal,household,transportation,leisure)
						  This function is called when the Member clicks on Save & Exit, Save & Continue
						  and Add More Expense Items	
	-------------------------------------------------------------------------------------------*/
function validateExpenseForm(action, objfrm, frmName)
{
	if ( eval(objfrm+".hidAction").value != "0" )
	{
		eval(objfrm+".hidAction").value = "0"
		var IsValidate = true;
		var pbAllowSign = false; 
		var HeadNameCounter=0,expenseType="";
		var arrTxtHeadNames = new Array();  //contains the all Other textbox values
		var arrTxtExpenseIDs = new Array();  //contains the all Other textbox values
		var editPermission = eval(objfrm +'.EditPermission').value;
		var blndeletevalue = false;
		var deleteID;
		if (action != 4)
			eval(objfrm +'.hidDeleteExpenseID').value = -1	 // if delete link is not clicked
		
		deleteID =parseInt(eval(objfrm +'.hidDeleteExpenseID').value);
		if(editPermission=="NO")
 		{
 			ErrorMessageOneMonth();
 			eval(objfrm).reset(); 
 			CalculateYearTotal(0,objfrm);
 			IsValidate=false;
 		}
 		if(IsValidate)
		{
			var TotalCount=eval(objfrm +'.hidCount').value;    //contains the no.of Rows
			for(var loopCounter=1; loopCounter <= TotalCount; loopCounter++)
			{
				//Validating the Current Year Amounts
				var expenseID=parseInt(eval(objfrm+".hidExpenseID"+loopCounter+".value"));
				if(expenseID!=deleteID)
				{
					var objcurrentYearValue=eval(objfrm+".txtYearAmount"+expenseID); 
					if ( TrimTheString(objcurrentYearValue.value) == "" )	objcurrentYearValue.value = 0.00;
					if(!IsCurrencyFloatSign(objcurrentYearValue,pbAllowSign)) 
					{
						IsValidate=false;
						eval(objfrm+".hidAction").value = ""
						return false;
					}

					//Validating the Next Year Amounts		
					var objpercentSecondYear=eval(objfrm+".txtExpenseNextYear"+expenseID); 
					if ( TrimTheString(objpercentSecondYear.value) == "" )	objpercentSecondYear.value = 0.00;
					if(!ValidateTaxPercentage(objpercentSecondYear,""))  // checking for emptyness of  percentSecondYear 
					{
						eval(objfrm+".txtExpenseNextYear"+expenseID+".focus()");
						IsValidate=false;
						eval(objfrm+".hidAction").value = ""
						return false;
					}
					  
					var objpercentThirdYear=eval(objfrm+".txtExpenseNext3Year"+expenseID); 
					if ( TrimTheString(objpercentThirdYear.value) == "" )	objpercentThirdYear.value = 0.00;
					if(!ValidateTaxPercentage(objpercentThirdYear,"")) // checking for emptyness of  percentThirdYear 
					{
						eval(objfrm+".txtExpenseNext3Year"+expenseID+".focus()");
						IsValidate=false;
						eval(objfrm+".hidAction").value = ""
						return false;
					}
					//Storing into the Hidden variables

					var expenseName=eval(objfrm+".hidExpenseHeadName"+loopCounter+".value"); 
					var isExpenseOthers=eval(objfrm+".hidExpenseOthers"+loopCounter+".value"); 
					if(isExpenseOthers=='Y')   //if Others then store the Header Name into the Hidden Variable
					{
						var HeaderName=eval(objfrm+".txtHeadName"+expenseID+".value");
						//Check whether Others contains the Double quotes or not
						if(HeaderName.indexOf('"') >= 0)
						{
							alert("Double Quotes are Invalid in the Others Expenses");
							eval(objfrm+".txtHeadName"+expenseID+".focus()");
							IsValidate=false;
							eval(objfrm+".hidAction").value = ""
							return false;
						}
						if(!IsWhitespace(HeaderName))  //check if it Null or not
						{		
							arrTxtHeadNames[HeadNameCounter] = HeaderName.toLowerCase();
							arrTxtExpenseIDs[HeadNameCounter]= expenseID;
							eval(objfrm+".hidExpenseHeadName" + loopCounter).value = HeaderName;
							HeadNameCounter++;
						}	
						else 
						{	//if Expense Others is not entered.
							alert("Please label the additional expense added before proceeding.");
							eval(objfrm+".txtHeadName"+expenseID+".focus()");
							IsValidate=false;
							eval(objfrm+".hidAction").value = ""
							return false;
						}    	
					}
				} //end of if condition comparing the deleteID
				else
				blndeletevalue = true;
			} // End of for Loop
			
			//Compares the All Expenses Names with Text Box Values
			if(!blndeletevalue)
			{
				for(loopCounter=0;loopCounter <arrTxtHeadNames.length; loopCounter++)
				{
					for(var innerCounter=0;innerCounter <arrExpenseNames.length;innerCounter++)
					{
						if((arrTxtHeadNames[loopCounter]==(arrExpenseNames[innerCounter]).toLowerCase()) && (arrTxtExpenseIDs[loopCounter]!=arrExpenseIDs[innerCounter]))
						{
							switch(arrExpenseTypes[innerCounter])
							{
							case 'P': expenseType="Personal";break;
							case 'H': expenseType="Household";break;
							case 'T': expenseType="Transportation";break;
							case 'L': expenseType="Leisure";break;
							}
							//Display where Expense Others is Existing
							if(frmName==arrExpenseTypes[innerCounter])
							{
								alert("The expense you have added already exists in the list above");
							}
							else
							{
								alert("The expense you have added already exists on the "+ expenseType + " expenses page.  Please use the entry field given there.");
							}
							eval(objfrm+".txtHeadName"+arrTxtExpenseIDs[loopCounter]+".focus()");
							IsValidate=false;
							eval(objfrm+".hidAction").value = ""
							return false;
						}
					}
				} 
				//Compares TextBox value with each other
				for(loopCounter=0;loopCounter < arrTxtHeadNames.length; loopCounter++)
				{
					for(var innerCounter=loopCounter+1;innerCounter < arrTxtHeadNames.length;innerCounter++)
					{
						if(TrimTheString(arrTxtHeadNames[loopCounter])==TrimTheString(arrTxtHeadNames[innerCounter]))
						{
							alert("The expense you have added already exists in the list above");
							eval(objfrm+".txtHeadName"+arrTxtExpenseIDs[innerCounter]+".focus()");
							IsValidate=false;
							eval(objfrm+".hidAction").value = ""
							return false;
						}
					}
				}
			} 
			
			if(IsValidate && action == 3)
			{
				if (confirm ("Before adding another row, all information you have entered in the table will be saved. Do you want to continue?"))
					IsValidate = true
				else
					IsValidate = false
			}

			if(IsValidate)
			{
				eval(objfrm+".hidAction").value = action; 
				eval(objfrm).submit();  //submits the form
			}
			else
			{
				eval(objfrm+".hidAction").value = ""
				return false;
			}
		}
	}
	else
	{
		eval(objfrm+".hidAction").value = ""
		return false;
	}
		
}

function ErrorMessageOneMonthBalanceSheet()
{
alert("The one month time limit for changing any Balance Sheet values is over. Please change the Balance Sheet Date in Assets page and click the update button in order to modify/insert any values.");
}
	
function ErrorMessageOneMonth()
{
alert("The one month time limit for changing any financial values is over. Please change the Budget Date in My Taxes page and click the update button in order to modify/insert any values.");
}

function ErrorMessagePercentage()
{
alert("Invalid Percentage. Should be -100 to 100");
}

/*----------------------------------------------------------------------------------------
	Author				: K.Krishna Varma
	Function Name		: ConfirmDelete
	Parameters			: objForm
	Purpose				: To confirm the deletion of any record.
	-------------------------------------------------------------------------------------------*/
	function ConfirmDelete(strMessage)
	{
		var returnConfirm;
		
		if (TrimTheString(strMessage)=="")
			returnConfirm=confirm("Are you sure you want to delete this record?")
		else
			returnConfirm=confirm(strMessage)
		return returnConfirm;
		
	}

/*----------------------------------------------------------------------------------------
	Author				: Upendra
	Function Name		: openGoalElementTypeSelector
	Parameters			: formName
	Purpose				: Opens the Set/ View Element Type
	-------------------------------------------------------------------------------------------*/
function openGoalElementTypeSelector(fileName)
{
	newWind = window.open(fileName, "SetViewGoalElementType", "left=367,top=300,height=200,width=263, statusbar=no");
}

/*----------------------------------------------------------------------------------------
	Author				: Upendra
	Function Name		: openGoalElementTypeSelector
	Parameters			: formName
	Purpose				: Opens the Set/ View Element Type - NOT USED this function 
	-------------------------------------------------------------------------------------------*/
function openGettingStarted(fileName)
{
    var wd=750;
	var ht=550;
	var winl = 0;
	var wint = 0;
	var w=screen.width - 150;
	var h=screen.height - 150;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=1,location=0,resizable'
	
	newWind = window.open(fileName, "GettingStarted", "left=150,top=100, height=" + ht + ", width=" + wd +", scrollbars=yes,status=yes");
}

/*----------------------------------------------------------------------------------------
	Author				: K.Krishna Varma
	Function Name		: ValidateURL
	Parameters			: url string
	Purpose				: To validate a given url
	-------------------------------------------------------------------------------------------*/
function ValidateURL(strURLString)
{
	var retVal='';
	strURLString = strURLString.toLowerCase();
	var msg = "Invalid URL, Please specify the URL as(e.g.): www.myguidewire.com"
    var part1 = strURLString.indexOf("http")
    var part2 = strURLString.indexOf(":")
    var part3 = strURLString.indexOf("//")
    var part4 = strURLString.indexOf("www.")
    
    //check for part1 and its subparts
    if (part1>=0) 
    {
		if (part2>=0)
		{
			if (part3<0)
			{
				alert(msg)
				return false;				
			}
		}
		else
		{
			alert(msg)
			return false;
		}
    }
    
    //check for part2 and its subparts
    if (part2>=0) 
    {
		if (part1>=0)
		{
			if (part3<0)
			{
				alert(msg)
				return false;				
			}
		}
		else
		{
			alert(msg)
			return false;
		}
    }
    
    //check for part3 and its subparts
    if (part3>=0) 
    {
		if (part1>=0)
		{
			if (part2<0)
			{
				alert(msg)
				return false;				
			}
		}
		else
		{
			alert(msg)
			return false;
		}
    }
    
    if (part4<0) 
    {
    	alert(msg)
    	return false
    }
   
	return true;
}

/*----------------------------------------------------------------------------------------
	Author				: Venkatesh Kovvuri
	Function Name		: IsNumeric
	Parameters			: strText
	Purpose				: To validate a numeric value
	-------------------------------------------------------------------------------------------*/
function IsNumeric(strText)
{
	var ValidChars = "0123456789.,";
	var IsNumber=true;
	var Char;

	for (i = 0; i < strText.length && IsNumber == true; i++) 
	{ 
		Char = strText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
		}
	}
	return IsNumber;
}

function MarkRadioCheckedWhenClickedOnLabel( objRadioToBeChecked )
{
	objRadioToBeChecked.checked = true;
}

/***********************************************************
All the methods of PGS
************************************************************/
var objExampleWindow, objGoalWindow, objActivityWindow, objStrategyWindow, objPeopleResourceWindow, objRewardBenefitWindow
var objObstacleWindow, objFinancialWindow, objSortWindow, objFilterWindow

function openGoalsPopupWindow(fileName){
	var height = 460
	var width = 750

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=no,statusbar=no,resizable=no";
	}
	objGoalWindow = window.open(fileName,"GoalsWizard",strAttributes);
	objGoalWindow.focus();
}

function openNewMessageWindow(fileName){
	
	var height = 414
	var width = 420

	var strAttributes = "height=" + height;// + ",innerHeight=" + height;
	strAttributes += ",width=" + width ;//+ ",innerWidth=" + width;
	/*if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=yes,statusbar=no,resizable=no";
	}*/
	//alert(strAttributes);
	objActivityWindow = window.open(fileName,"ss",strAttributes);
	objActivityWindow.focus();
}


function openStrategyWindow(fileName){
	var height = 400
	var width = 650

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=no,statusbar=no,resizable=no";
		//Disabled Scrollbars - Upendra - 23/7/2004
		//strAttributes += ",scrollbars=yes,statusbar=no,resizable=no";
	}
	objStrategyWindow = window.open(fileName,"AddEditStrategy",strAttributes);
	objStrategyWindow.focus();
}

function openPeopleResourcesWindow(fileName){
	var height = 430
	var width = 750

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=yes,statusbar=no,resizable=no";
	}
	objPeopleResourceWindow = window.open(fileName,"AddEditPeopleResources", strAttributes);
	objPeopleResourceWindow.focus();
}

function openRewardsBenefitsWindow(fileName){
	var height = 490
	var width = 750

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=yes,statusbar=no,resizable=no";
	}
	objRewardBenefitWindow = window.open(fileName,"AddEditRewardsBenefits", strAttributes)
	objRewardBenefitWindow.focus();
}

function openObstaclesWindow(fileName){
	var height = 490
	var width = 750

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=yes,statusbar=no,resizable=no";
	}
	objObstacleWindow = window.open(fileName,"AddEditObstacles", strAttributes)
	objObstacleWindow.focus();
}

function OpenExampleWindow(pszFileName, plMemberID) {
	var height = 200
	var width = 300

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=no,statusbar=no,resizable=no";
	}
	if(plMemberID != -1)
		pszFileName = pszFileName + "?hidMemberID=" + plMemberID;
		
	objExampleWindow = window.open(pszFileName,"ExampleWindow", strAttributes)
	objExampleWindow.focus();
}
/*Author:Upendra*/
function OpenGoalExampleWindow(pszFileName) {
	var height = 250
	var width = 600

var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=yes,statusbar=no,resizable=no";
	}
	//pszFileName = pszFileName + "?hidMemberID=" + plMemberID;
	objExampleWindow = window.open(pszFileName,"GoalExampleWindow", strAttributes)
	objExampleWindow.focus();
}
function OpenHelpWindow(pszFileName, plMemberID) {
	var height = 460
	var width = 750

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=yes,statusbar=no,resizable=no";
	}
	pszFileName = pszFileName + "?hidMemberID=" + plMemberID;
	objExampleWindow = window.open(pszFileName,"HelpWindow", strAttributes)
	objExampleWindow.focus();
}

function OpenCoachMoreDetailsWindow(pszFileName) {
//This function is used in the LCM - Select Coach
	var height = 460
	var width = 750

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=yes,statusbar=no,resizable=no";
	}	
	objExampleWindow = window.open(pszFileName,"CoachMoreDetails", strAttributes)
	objExampleWindow.focus();
}

function OpenGoalFilterWindow(pszFileName) {
	var height = 455
	var width = 600

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=yes,statusbar=no,resizable=no";
	}
	objFilterWindow = window.open(pszFileName,"GoalFilterWindow", strAttributes)
	objFilterWindow.focus();
}

function OpenSortWindow(pszFileName, pszCallingFrom) {
	var height = 195
	var width = 500

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=no,statusbar=no,resizable=no";
	}
	objSortWindow = window.open(pszFileName,"SortWindow", strAttributes)
	objSortWindow.focus();
}

function OpenFinancialWindows(pszFileName) {
	var height = 550
	var width = 830

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=yes,statusbar=no,resizable=no";
	}
	objFinancialWindow = window.open(pszFileName,"FinancialWizard", strAttributes)
	objFinancialWindow.focus();
}

function ShowAllActivitiesWindow(pszURL)
{
	var height = 450
	var width = 600

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=yes,statusbar=no,resizable=no";
	}
	objShowAllActivitiesWindow = window.open(pszURL,"ShowAllActivities",strAttributes);
	objShowAllActivitiesWindow.focus();
}

/***********************************************************
All the methods of PGS
************************************************************/

/*Author :Upendra */
function round(number,X)
 {
	
        // rounds number to X decimal places, defaults to 2
        X = (!X ? 2 : X);
		return Math.round( number*Math.pow(10,X)) / Math.pow(10,X);

}

/*----------------------------------------------------------------------------------------
	Author				: Venkatesh Kovvuri
	Function Name		: launchCenter
	Parameters			: url,name,width,height
	Purpose				: To center the new window to the screen
	-------------------------------------------------------------------------------------------*/
	function launchCenter(url, name, height, width) 
	{
		var str = "height=" + height + ",innerHeight=" + height;
		str += ",width=" + width + ",innerWidth=" + width;
		if (window.screen) {
			var ah = screen.availHeight - 30;
			var aw = screen.availWidth - 10;

			var xc = (aw - width) / 2;
			var yc = (ah - height) / 2;

			str += ",left=" + xc + ",screenX=" + xc;
			str += ",top=" + yc + ",screenY=" + yc;
			str += ",scrollbars=yes";
		}
		return window.open(url, name, str);
	}
	
	
function CancelWithCaution() {
	var usertype=navigator.userAgent.toLowerCase();
	if (usertype.indexOf("windows") > 0 || usertype.indexOf("safari") > 0)
    {
       if ( confirm("Do you want to close the window without saving the values?") )
			window.close()
    }
    else {
       // window.close()
       if ( confirm("Do you want to close the window without saving the values?") )
			window.close()
    }
}

function BackWithCaution() {
	var usertype=navigator.userAgent.toLowerCase();
	if (usertype.indexOf("windows") > 0 || usertype.indexOf("safari") > 0)
    {
		if ( confirm("Do you want to go to the previous page without saving the values?") )
			var IsConfirmed = true;
		else 
			var IsConfirmed = false;
    }
    else {
		//alert("Test in IE");
		var IsConfirmed = confirm("Do you want to go to the previous page without saving the values?")
    	
    }
    return IsConfirmed;
   	
}

/*Comprehensive Plan - Upendra - 5/7/2004*/
function OpenPlanFilterWindow(pszFileName) {
	var height = 400;
	var width = 600;

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=no,statusbar=no,resizable=no";
	}
	objFilterWindow = window.open(pszFileName,"ComprehensivePlanFilter", strAttributes)
	objFilterWindow.focus();
}
function OpenPlanWindow(pszFileName) {
	var height = 600;
	var width = 800;

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight  - 10;
		var aw = screen.availWidth  - 10;
		/*var xc = 0
		var yc = 0*/
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",scrollbars=yes,statusbar=yes,resizable=yes";
	}
	objFilterWindow = window.open(pszFileName,"Plan", strAttributes)
	objFilterWindow.focus();	
}

//theBirthdate should be of [mm/dd/yyyy]
/*Author :K.Venkatesh*/
function validOver20(theBirthdate) 
{ 
  var result = true; 
  // Create date object using birth date str 
  var birthDate = new Date(theBirthdate); 
  // Create todays date 
  var today = new Date(); 
  // getTime returns date in milliseconds, so need 
  // to divide by number of milliseconds in year 
  var age = (today.getTime() - birthDate.getTime()) /(365*24*60*60*1000)   	 
  age = Math.round(age)
  //alert(HowOld("05/22/1986","05/22/2004"));
  if (Math.round(age) < 18)
  {     
    result = false; 
  } 

  return result; 
}

function HowOld(txtDate,currDate) 
{
//var today = new Date(); 		
var todaydate = new Date(currDate);
//var splittoday = todaydate.split("/");
var splitstring = txtDate.split("/");
var dd = parseInt(splitstring[1]);
//alert("dd is :" + dd)
var mm = parseInt(splitstring[0]);
//alert("mm is :" + mm)
var yy = parseInt(splitstring[2]);
/*var gdate = splittoday[1];
var gmonth = splittoday[0];
var gyear = splittoday[2];*/
var gdate = todaydate.getDate();
var gmonth = todaydate.getMonth();
var gyear = todaydate.getFullYear();
/*
with (document.agecalc) {
dd = parseInt(day.selectedIndex) + 1;
mm = parseInt(month.selectedIndex) + 1;
yy = year.value;
if (yy.length != 4 || isNaN(yy)) {
document.agecalc.timealive.value = "Please enter a 4-digit year.";
document.agecalc.year.select();
document.agecalc.year.focus();
return;
   }
}*/
/*days = new Date();
gdate = days.getDate();
gmonth = days.getMonth();
gyear = days.getFullYear();*/
if (gyear < 2000) gyear += 1900;
age = gyear - yy;
if ((mm == (gmonth + 1)) && (dd <= parseInt(gdate))) 
	{
	age = age; 
	} 
else 
	{
	if (mm <= (gmonth)) 
		{
		age = age;
		} 
	else 
		{
		age = age - 1; 
   		}
	}
if (age == 0) age = age;
//document.agecalc.timealive.value = "You are " + age+ " years old . . .\n\n";
var ActualAge = age;
if (mm <= (gmonth + 1)) age = age - 1;
if ((mm == (gmonth + 1)) && (dd > parseInt(gdate))) age = age + 1;
var m;
var n; 
var p;                                                                                                    ////////ADDED VAR p //////////
if (mm == 12) n = 31 - dd;                                                               ///////////n is days to end year///
if (mm == 11) n = 61 - dd;                                                               //////////mm is birthday month///////////////////
if (mm == 10) n = 92 - dd;
if (mm == 9) n = 122 - dd;
if (mm == 8) n = 153 - dd;
if (mm == 7) n = 184 - dd;
if (mm == 6) n = 214 - dd;
if (mm == 5) n = 245 - dd;
if (mm == 4) n = 275 - dd;
if (mm == 3) n = 306 - dd;
if (mm == 2) { n = 334 - dd; if (leapyear(yy)) n++; }
if (mm == 1) { n = 365 - dd; if (leapyear(yy)) n++; }                                   //////m is birthday days from new year/////////////////

if (gmonth == 0) m = 0;																				//////////Added this: m=0/////////////////////////////////////		  
if (gmonth == 1) m = 31;                                                             
if (gmonth == 2) {m = 59; if (leapyear(gyear)) m++;}              
if (gmonth == 3)  { m = 90;  if (leapyear(gyear)) m++; }          
if (gmonth == 4)  { m = 120; if (leapyear(gyear)) m++; }         
if (gmonth == 5)  { m = 151; if (leapyear(gyear)) m++; }         
if (gmonth == 6)  { m = 181; if (leapyear(gyear)) m++; }         
if (gmonth == 7)  { m = 212; if (leapyear(gyear)) m++; }         
if (gmonth == 8)  { m = 243; if (leapyear(gyear)) m++; }         
if (gmonth == 9)  { m = 273; if (leapyear(gyear)) m++; }         
if (gmonth == 10) { m = 304; if (leapyear(gyear)) m++; }        
if (gmonth == 11) { m = 334; if (leapyear(gyear)) m++; }        
if (gmonth == 12) { m = 365; if (leapyear(gyear)) m++; }                      /////////////////////////This line is not useful//////////////////////

months = age * 12;
months += 13 - parseInt(mm);                                                                 
months += gmonth; 
totdays = (parseInt(age) * 365);
totdays += age / 4;
totdays = parseInt(totdays) + gdate + m + n;                                           //////////////////////correction for leap years!//////////////

if (gmonth == 0) {p=gdate;}                                                                        ////////////////////Added this//////////////////////////////
if (gmonth == 1) {p = 31 + gdate; if (leapyear(gyear)) m = m+1;}              ////////////////////February///////////////////////////////

if (gmonth == 2) {p = 59 + gdate; if (leapyear(gyear)) m = m+1; p++;}      //////////////////added p++////////////////////////////////
if (gmonth == 3)  { p = 90 + gdate;  if (leapyear(gyear)) p++; }       
if (gmonth == 4)  { p = 120 + gdate; if (leapyear(gyear)) p++; }      
if (gmonth == 5)  { p = 151 + gdate; if (leapyear(gyear)) p++; }      
if (gmonth == 6)  { p = 181 + gdate; if (leapyear(gyear)) p++; }      
if (gmonth == 7)  { p = 212 + gdate; if (leapyear(gyear)) p++; }      
if (gmonth == 8)  { p = 243 + gdate; if (leapyear(gyear)) p++; }      
if (gmonth == 9)  { p = 273 + gdate; if (leapyear(gyear)) p++; }      
if (gmonth == 10) { p = 304 + gdate; if (leapyear(gyear)) p++; }     
if (gmonth == 11) { p = 334 + gdate; if (leapyear(gyear)) p++; }     
if (gmonth == 12) { p = 365 + gdate; if (leapyear(gyear)) p++; }             //////////////////this line is not useful gmonth is never 12//////
weeks = (age * 365) + n + p; 
/////////////age*365 + days to end year(birth year) + p (days from new year to today)////////

weeks = weeks / 7;
etcdays = parseFloat(weeks) - parseInt(weeks);
etcdays = Math.round(etcdays * 7);
weeks = parseInt(weeks);
etcdays += parseInt(age / 4);           
if (etcdays > 7) weeks += parseInt(etcdays / 7);      
/*document.agecalc.timealive.value += "     or " + months + " months old\n";
document.agecalc.timealive.value += "     or " + weeks + " weeks old\n";
document.agecalc.timealive.value += "     or " + totdays + " days old\n";*/
var time = new Date();
ghour = time.getHours();
gmin = time.getMinutes();
gsec = time.getSeconds(); 
hour = ((age * 365) + n + p) * 24;
hour += (parseInt(age / 4) * 24);                                                        /////////////////////////correction for leap years: //////////////////
/*document.agecalc.timealive.value += "     or " + hour + " hours old\n";*/
var min = (hour * 60) + gmin;
//document.agecalc.timealive.value += "     or " + min + " minutes old\n";
sec = (min * 60) + gsec;
//document.agecalc.timealive.value += "     or " + sec + " seconds old";
mm = mm - 1;                                                                                                /////////////////////mm was the birthday month//////////////////
var r;
if (mm == 0) r = 0;                                                                                         ////////////////////// r is days from new year to birthday//////////
if (mm == 1) r = 31;
if (mm == 2) { r = 59; if (leapyear(gyear)) m++; }
if (mm == 3)  { r = 90;  if (leapyear(gyear)) r++; }
if (mm == 4)  { r = 120; if (leapyear(gyear)) r++; }
if (mm == 5)  { r = 151; if (leapyear(gyear)) r++; }
if (mm == 6)  { r = 181; if (leapyear(gyear)) r++; }
if (mm == 7)  { r = 212; if (leapyear(gyear)) r++; }
if (mm == 8)  { r = 243; if (leapyear(gyear)) r++; }
if (mm == 9)  { r = 273; if (leapyear(gyear)) r++; }
if (mm == 10) { r = 304; if (leapyear(gyear)) r++; }
if (mm == 11) { r = 334; if (leapyear(gyear)) r++; }
mm = mm + 1;
r = parseInt(r) + parseInt(dd);                                                                     ////////////////////////dd was birthday day of month/////////// 

if ((mm >= (gmonth + 1)) && (dd > gdate)) 
	{
	bday = r - m - gdate; 
	}
else 
	{
	if ((leapyear(gyear)) && ((mm > 2) && (dd < 29))) 
		{
		a = 366;
		}
	 else 
	 	{
		a = 365;
		}
	bday = a + (r - m - gdate);                                            
	/////////a is size days of year///////////////////// 
	}
nhour = 24 - parseInt(ghour);
nmin = 60 - parseInt(gmin);
nsec = 60 - parseInt(gsec);
while (bday > 366) bday -= 365;
if (((bday == 366) && (leapyear(gyear)) || ((bday == 365) && (!leapyear(gyear))))) {
//document.agecalc.timealive.value += "\n\nAnd, today is your birthday!";
} else {
//document.agecalc.timealive.value += "\n\nAnd, your next birthday is in:\n"
//+ bday + " days " + nhour + " hrs " + nmin + " mins " + nsec + " secs";
//setTimeout("run()", 1000);
   }
   //alert(ActualAge)
    if (ActualAge < 18 )
	 return false;
	 else
	 return true;
}
function leapyear(a) {
if (((a%4 == 0) && (a%100 != 0)) || (a%400 == 0))
return true;
else
return false;
}

//This function is used to check length of input field
//author: Pinna Nageshwar Rao
function publicValidateLen(frm, fld, displayname, criteria) {
	tt = eval(frm + "." + fld);
	if ((tt.value != '') && (tt.value.length > criteria)) {
		//alert(displayname + " should not be more " + criteria + " charactors.");
		alert(displayname + " number of characters should not exceed " + criteria);
		tt.focus();
		tt.select();
		return false;
	} 

}

// This function is used for Positive integer checking
function KeyPressInteger() {
        if ((event.keyCode < 48 || event.keyCode > 57)&&
                  event.keyCode != 13) {
                event.returnValue = false;
        }
}

//Upendra -23/7/2004
function OpenNewWindow(fileName)
{
	window.open(fileName);    //open the Third party sites links and documents in lcm control panel
}
//Upendra - 20/8/2004
function OpenThirdPartySiteinNewWindow(pszFileName)
{
	var height = 500
	var width = 830
	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 100;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",menubar=yes,scrollbars=yes,location=yes,status=yes,resizable=yes,toolbar=yes";
	}
	objThirdPartySite = window.open(pszFileName,"", strAttributes)
	objThirdPartySite.focus();	
}

/***********************************************************
For Sample Reports -- PGS
************************************************************/
var objExampleWindow, objGoalWindow, objActivityWindow, objStrategyWindow, objPeopleResourceWindow, objRewardBenefitWindow
var objObstacleWindow, objFinancialWindow, objSortWindow, objFilterWindow

function openSampleReports(fileName){
	var height = 460
	var width = 800

	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",menubar=yes,toolbar=yes,scrollbars=yes,location=yes,status=yes,resizable=yes";
	}
	objGoalWindow = window.open(fileName,"SampleReports",strAttributes);
	objGoalWindow.focus();
}
/*The following function is used in  marketing View Sample Report*/
function openPopUpMarketing(fileName)
{
	window.open(fileName,"SampleUserInfo","left=100, top=20, width=800, height=690, resizable=no, scrollbars=no");
}

function OpenGenericWindow(pszFileName,WindowTitle)
{
	var height = 500
	var width = 830
	var strAttributes = "height=" + height + ",innerHeight=" + height;
	strAttributes += ",width=" + width + ",innerWidth=" + width;
	if (window.screen) {
		var ah = screen.availHeight - 100;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		strAttributes += ",left=" + xc + ",screenX=" + xc;
		strAttributes += ",top=" + yc + ",screenY=" + yc;
		strAttributes += ",menubar=yes,scrollbars=yes,location=yes,status=yes,resizable=yes,toolbar=yes";
	}
	objThirdPartySite = window.open(pszFileName,WindowTitle, strAttributes)
	objThirdPartySite.focus();	
}