var aspnm_hideSelectElems = true;     // whether to hide HTML select elements 
var newWindow ;
var vURL = window.document.URL;
var nDX = vURL.indexOf("://");
var vProtocol = vURL.substring(0,nDX);
var DateDisbFlag=1;
var ViewMsg=1;
var ViewMsg2=1;
var RunFunction=0;
var xx=1;
var yy=0


function macDetection(title)
{
	var isMac = navigator.userAgent.indexOf("Mac") != -1
	if (isMac)
	{
		var i, a, main;
		for(i=0; (a = document.getElementsByTagName("link")[i]); i++) 
			{
				if(a.getAttribute("rel").indexOf("style") != -1	&& a.getAttribute("title")) 
					{
						a.disabled = true;
						if(a.getAttribute("title") == title) a.disabled = false;
					}
			}
	}
 
}


function CountryChanged(selectedCountry)
{
	if (selectedCountry == 'US')
	{				
		for (i = 0; i < window.document.forms[0].elements.length; i++)
		{
			var stname = new String(window.document.forms[0].elements[i].name);
			if (stname == '//Page1/BorrowerInfo/TestState')
			{			
				sInnerHtml = stname.innerHTML;
				sInnerHtml += "<option value=\"NA\">Not Applicable</option>";
			}
		}
	}
}

// to switch SSL ON and OFF , i.e SwitchSSL('ON')
function SwitchSSL(vSwitch)
{ 
	if ( vSwitch != null && vSwitch.toUpperCase() == 'ON')
		vProtocol = "https";
	else
		vProtocol = "http";
}
 
function UnderConstruction()
{
 alert("This part is still under construction");
 return false;
}
function RefreshDMPTemplateDynamicFields(id1)
{
	var strRegularPayment, strCurrentBalance;
	var nStringLength;
	var strStmtAging,strLateFee, strOverlimitFee,strRegularInterestRate;

	//Adjusted_Payment_Percent	
	if(id1 == "//DMP_Template_Detail/Adjusted_Payment_Percent")
	{
		strRegularPayment = window.document.forms[0].elements['//DMP_Template_Detail/Regular_Payment'].value;
		strCurrentBalance = window.document.forms[0].elements['//DMP_Template_Detail/Current_Balance'].value;
				
		nStringLength = strRegularPayment.length;
		if (strRegularPayment.substring(0, 1) =="$")
			strRegularPayment = strRegularPayment.substring(1, nStringLength);
			
		nStringLength = strCurrentBalance.length;
		if (strCurrentBalance.substring(0, 1) =="$")
			strCurrentBalance = strCurrentBalance.substring(1, nStringLength);
		
		if (parseFloat(strCurrentBalance) > 0.0)
		{
			window.document.forms[0].elements[id1].value = Math.round((
			parseFloat(strRegularPayment) / parseFloat(strCurrentBalance)) * 100) /100;
			if( isNaN(window.document.forms[0].elements[id1].value)  || (window.document.forms[0].elements[id1].value == 'NaN') )
			{
				 window.document.forms[0].elements[id1].value="0";
			}
		}
	}
	else
	if(id1 == "//DMP_Template_Detail/Adjusted_Balance")
	{
		strStmtAging = window.document.forms[0].elements['//DMP_Template_Detail/Month_Statement_Aging'].value;
		strCurrentBalance = window.document.forms[0].elements['//DMP_Template_Detail/Current_Balance'].value;
		strLateFee = window.document.forms[0].elements['//DMP_Template_Detail/Late_Fee'].value;
		strOverlimitFee = window.document.forms[0].elements['//DMP_Template_Detail/Overlimit_Fee'].value;
		strRegularInterestRate = window.document.forms[0].elements['//DMP_Template_Detail/Regular_Interest_Rate'].value;
				
		nStringLength = strStmtAging.length;
		if (strStmtAging.substring(0, 1) =="$")
			strStmtAging = strStmtAging.substring(1, nStringLength);
			
		nStringLength = strLateFee.length;
		if (strLateFee.substring(0, 1) =="$")
			strLateFee = strLateFee.substring(1, nStringLength);
		
		nStringLength = strOverlimitFee.length;
		if (strOverlimitFee.substring(0, 1) =="$")
			strOverlimitFee = strOverlimitFee.substring(1, nStringLength);
		
		nStringLength = strRegularInterestRate.length;
		if (strRegularInterestRate.substring(0, 1) =="$")
			strRegularInterestRate = strRegularInterestRate.substring(1, nStringLength);
				
		nStringLength = strCurrentBalance.length;
		if (strCurrentBalance.substring(0, 1) =="$")
			strCurrentBalance = strCurrentBalance.substring(1, nStringLength);
				
		/*(parseFloat("1.0") * parseFloat("1.0")) +		
					(parseFloat("1.0") * parseFloat("1.0")) + 
					( ( parseFloat("1.0")* parseFloat("1.0") ) / 12) * parseFloat("1.0") + parseFloat("1.0");*/
					
		window.document.forms[0].elements[id1].value = Math.round((
		(parseFloat(strLateFee) * parseInt(strStmtAging)) + 
					(parseFloat(strOverlimitFee) * parseInt(strStmtAging)) + 
					( (parseFloat(strRegularInterestRate)* parseFloat(strCurrentBalance) ) / 12) * parseFloat(strStmtAging)+ parseFloat(strCurrentBalance)) * 100) / 100;

		if( isNaN(window.document.forms[0].elements[id1].value)  || (window.document.forms[0].elements[id1].value == 'NaN') )
		{
			 window.document.forms[0].elements[id1].value="0";
		}
					
	}
	else 
	if(id1 == "//DMP_Template_Detail/DMP_Proposed_Payment")
	{
	    var strDMPInterestRate,strDMPPaymentPercent,strPercentType,strAdjustedBalance,strRegularPayment,nStrLength; 
        var nPBIndex=0; 
        var nPPIndex=0;
		strDMPInterestRate = window.document.forms[0].elements['//DMP_Template_Detail/DMP_Interest_Rate'].value;
		strDMPPaymentPercent = window.document.forms[0].elements['//DMP_Template_Detail/DMP_Payment_Percent'].value;
//		strPercentType = document.forms[0].elements['//DMP_Template_Detail/DMP_Percent_CD'].value;
		strAdjustedBalance = window.document.forms[0].elements['//DMP_Template_Detail/Adjusted_Balance'].value;
		strRegularPayment = window.document.forms[0].elements['//DMP_Template_Detail/Regular_Payment'].value;

		nStrLength = strAdjustedBalance.length;
		if (strAdjustedBalance.substring(0, 1) =="$")
			strAdjustedBalance = strAdjustedBalance.substring(1, nStrLength);

		nStrLength = strRegularPayment.length;
		if (strRegularPayment.substring(0, 1) =="$")
			strRegularPayment = strRegularPayment.substring(1, nStrLength);

        for (i = 0; i < window.document.forms[0].elements.length; i++)
 	    {	           
              if (window.document.forms[0].elements[i].type == 'radio' )
              {              
                   if( window.document.forms[0].elements[i].value == 'PB' && window.document.forms[0].elements[i].checked)
                   {
                      strPercentType = 'PB'
                   }
                   else
                   if( window.document.forms[0].elements[i].value == 'PP' && window.document.forms[0].elements[i].checked)
                   {
					  strPercentType = 'PP'
                   }
              }
        }
        if( strDMPInterestRate != '' && strDMPPaymentPercent != '' 
            && strAdjustedBalance != '' && strRegularPayment != '' )
          {
                if(  strPercentType == 'PB' )
                {
					window.document.forms[0].elements[id1].value = 
					Math.round((parseFloat(strAdjustedBalance) * parseFloat(strDMPPaymentPercent)) * 100)/ 100;				

				}
				else
				if(	strPercentType == 'PP' )
				{
					window.document.forms[0].elements[id1].value = 
					Math.round((parseFloat(strRegularPayment) * parseFloat(strDMPPaymentPercent)) * 100)/ 100;				
				}
				
				if( isNaN(window.document.forms[0].elements[id1].value)  || (window.document.forms[0].elements[id1].value == 'NaN') )
				{
					 window.document.forms[0].elements[id1].value="0";
				}                
          }       
	}
	
	//else
	//Added other similar cases here..
}


//=============================
// Menu Action
//=============================
function ShowSaveMessageBox(sMsg)
{	
	if (top.frames.length != 2)
		alert(sMsg);		
}

function CheckAction(Action, id1, id2, id3,id4,id5,id6,id7)
{
	if (!checkData()) return;
	menuAction(Action, id1, id2, id3,id4,id5,id6,id7);
}


/// This is a special version of MenuAction for the popup marketing site.
/// Requests are sent to ConsilidateYourLoans.aspx rather than Main.aspx.
///
function menuActionPopup(Action, id1, id2, id3,id4,id5,id6,id7)
{
	var sEmptyFields = "";
	var sErrorMsg = "";		
	var bInvalidZip = false;
	var bInvalidEmail = false;
	var oFirstInvalidField = null;
	var sPhone, sSSN;		
	var bInvalidSSN = false;	

	
	if (!zipcodeValid(document.getElementById("//ConsolidateYourLoanFinal/Zip"), true))		
		return false;
		
	if (!emailCheck(document.getElementById("//ConsolidateYourLoanFinal/Email"), true))
		return false;		
			
	//if (!ssnValid(document.getElementById("//ConsolidateYourLoanFinal/SSN"), true))
	//{
	//	bInvalidSSN = true;
	//}
					
	
	// SSN value
	sSSN = document.getElementById("//ConsolidateYourLoanFinal/SSN1").value +
		   document.getElementById("//ConsolidateYourLoanFinal/SSN2").value+
		   document.getElementById("//ConsolidateYourLoanFinal/SSN3").value;		  	
	
	// Phone value
	sPhone = document.getElementById("//ConsolidateYourLoanFinal/Phone1").value +
			 document.getElementById("//ConsolidateYourLoanFinal/Phone2").value +
			 document.getElementById("//ConsolidateYourLoanFinal/Phone3").value;
		
			
	// Do the validation here (client side)
	for (i = 0; i < window.document.forms[0].elements.length; i++)
    {
		var stname = new String(window.document.forms[0].elements[i].name);
				
		if (stname.substring(0,26) == '//ConsolidateYourLoanFinal' &&
		rtrim(ltrim(window.document.forms[0].elements[i].value)) == '' &&
		stname != '//ConsolidateYourLoanFinal/SSN' &&
		stname != '//ConsolidateYourLoanFinal/Phone')
		{			
			sEmptyFields += window.document.forms[0].elements[i].name;
			if (oFirstInvalidField == null)
				oFirstInvalidField = window.document.forms[0].elements[i];
		}
		else if (stname == '//ConsolidateYourLoanFinal/State_ID' && window.document.forms[0].elements[i].value == '0')
		{
			sEmptyFields += window.document.forms[0].elements[i].name;
			if (oFirstInvalidField == null)
				oFirstInvalidField = window.document.forms[0].elements[i];
		}
    } //For loop
                              
    if (sEmptyFields.length > 0)
    {   
		if (sEmptyFields.indexOf("FirstName") != -1)
		{
			sErrorMsg += "\tFirst Name\n";
		}    		
		if (sEmptyFields.indexOf("LastName") != -1)
		{
			sErrorMsg += "\tLast Name\n";
			
		}		
		if (sEmptyFields.indexOf("Address") != -1)
		{
			sErrorMsg += "\tPermanent Address\n";
		}
		if (sEmptyFields.indexOf("City") != -1)
		{
			sErrorMsg += "\tCity\n";
		}
		
		if (sEmptyFields.indexOf("State") != -1)
		{
			sErrorMsg += "\tState\n";
		}
		if (sEmptyFields.indexOf("Zip") != -1)
		{
			sErrorMsg += "\tZip\n";
		}
		if (sPhone.length == 0 /*sEmptyFields.indexOf("Phone") != -1*/)
		{
			sErrorMsg += "\tPhone\n";
		}				
		
		if (sEmptyFields.indexOf("Email") != -1)
		{
			sErrorMsg += "\tEmail Address\n";
		}
		if (sSSN.length == 0 /*sEmptyFields.indexOf("SSN") != -1*/)
		{
			sErrorMsg += "\tSocial Security #\n";
		}
	}
	
	
	if (sErrorMsg.length > 0)
	{
		sErrorMsg = "The following fields must be populated: \n" + sErrorMsg;
	}
	
	//Phone check		
	if (sPhone.length > 0 && sPhone.length < 10)
	{		
		
		if (oFirstInvalidField == null)
			oFirstInvalidField = document.getElementById("//ConsolidateYourLoanFinal/Phone1");
				
		sErrorMsg += "\nInvalid Phone #. You must provide a ten digit Phone #\n";		
	}
	
		
	//SSN check.	
	if (sSSN.length > 0 && sSSN.length < 9)
	{
		if (oFirstInvalidField == null)
			oFirstInvalidField = document.getElementById("//ConsolidateYourLoanFinal/SSN1");
		sErrorMsg += "\nInvalid SSN. You must provide a nine digit SSN number\n";
	}
	
	if (sErrorMsg.length > 0)
	{
		alert(sErrorMsg)
		if (oFirstInvalidField != null)
			oFirstInvalidField.focus();
		return false;
	}
	
        
	// Enter key cause the SSN to not have the right value. Cause the jscript function
	// is only called when any of the 2 portions of the SSN looses focus.
	// The followin line fixes that.        
	document.getElementById("//ConsolidateYourLoanFinal/SSN").value = sSSN;
	menuAction(Action, id1, id2, id3,id4,id5,id6,id7, "ConsolidateYourLoans");
}


function menuActionMain(Action, id1, id2, id3,id4,id5,id6,id7)
{
	menuAction(Action, id1, id2, id3,id4,id5,id6,id7)	
}

function menuAction(Action, id1, id2, id3,id4,id5,id6,id7, sActionPage)
{

	if (Action == 'OpenPage' && id1 != null && id1 == 'RequestApplication')
		{	SwitchSSL('ON');
		};
	if (Action == 'OpenPage' && id1 != null && id1 == 'ScholarshipApp')
		{	SwitchSSL('ON');
		};
	if (Action == 'DeleteRecord' || Action == 'DeleteInlineRecord')
		if (!confirm("Are you sure you want to delete ?")) return;

	if (Action == 'LoanWizard_StartLoanApplication' && id2 == 'DiscardChanges')
		if (!confirm("Are you sure you want to discard the loan application you entered?" )) return;
		
	if (Action == 'Borrower_FinishCounselingApp')
		if (isRadioSelected('//CounselingWrapUp/Answer','2') == true )
		{
			if (!confirm("Are you sure you want to discard the exam results?" )) return;
		}		
		
	if (Action == 'School_SaveCertificationInfo' && id1 == 'Certified')
		if (!confirm("Once certified this loan will continue in the process towards funding and may not be uncertified although changes may be made to the certification data. Are you sure you wish to certify this loan?" )) return;
		
	if (Action == 'ExecuteKey' && id5 != null && id5 == 'CopyRoleFrom' )
	{
		if (window.document.forms[0].elements['//Role_Detail/From/Role_ID'].value =='0')
		{
			alert("Please select role to copy from ");
			return ;
		}
		else
		{
			if (!confirm("Are you sure you want to copy ?")) return;
		}
	}
	if (Action == 'CopyAppFrom' && id5 != null && id5 == 'CopyAppFrom' )
	{
		if (window.document.forms[0].elements['//Online_App_Profiles_Detail/oldapplication'].value =='')
		{
			alert("Please select an Application to copy from ");
			return ;
		}
		else
		{
			if (!confirm("Are you sure you want to copy ?")) return;
		}
	}
	if (Action == 'CopyBlockFrom' && id5 != null && id5 == 'CopyBlockFrom' )
	{
		if (window.document.forms[0].elements['//Exam_Page_Options_Detail/CopyBlockInfo'].value =='')
		{
			alert("Please select a Block to copy from ");
			return ;
		}
		else
		{
			if (!confirm("Are you sure you want to copy ?")) return;
		}
	}
		
	
	if (Action == 'ExecuteKey' && id5 != null && id5 == 'Reset_Batch_Schedule_Update' )
	{
		if (window.document.forms[0].elements['//Batch_Schedule_Detail/Reset/Document_Template_Id'].value =='')
		{
			alert("Please select Document to reset ");
			return ;
		}
		if (window.document.forms[0].elements['//Batch_Schedule_Detail/Reset/Date'].value =='')
		{
			alert("Please enter Date to reset ");
			return ;
		}		
	}
	
	if (Action == 'CopySeminarFrom' && id5 != null && id5 == 'CopySeminarFrom' )
	{
		if (window.document.forms[0].elements['//Seminar_Detail/From/Seminar_ID'].value =='0')
		{
			alert("Please select seminar to copy from ");
			return ;
		}
		else
		{
			if (!confirm("Are you sure you want to copy ?")) return;
		}
	}
	
	if (Action == 'RefreshValue')
	{	
		RefreshDMPTemplateDynamicFields(id1);
		if (id2 != null)
			RefreshDMPTemplateDynamicFields(id2);
		return;
	}

	/*if (Action.substring(0,9) == 'Borrower_')
	{
		//Action = Action.substr(9);
		addFormElement('SubSystem', 'Borrower');
	}*/
	
	if (id1=='AwardLetterCalculator')//1210
	{
		 
		/*for School names , solve issue of commas*/
		var iControlsCount=0;
		if (id3=='Col')
			iControlsCount=parseInt(id2);
		else if (id3=='Row')
			iControlsCount=parseInt(document.getElementById("//Award_Letter_Calculator/n_Column_Order").value);
		var sSchoolName;
		sSchoolName="//Award_Letter_Calculator/School_Names/SchoolName";
		for (iCounter=0;iCounter<document.getElementsByTagName("input").length;iCounter++)
		{
			if (document.getElementsByTagName("input")[iCounter].id==sSchoolName)
			{
				document.getElementsByTagName("input")[iCounter].value=replace(document.getElementsByTagName("input")[iCounter].value,",","&#44;");	
				document.getElementsByTagName("input")[iCounter].value=replace(document.getElementsByTagName("input")[iCounter].value,"$","&#36;");	
			}
		}	
	}	
	//Thaer 20061016 : special case to hide or display Other School Name text box
	if (Action == 'LoanWizard_StartLoanApplication')
	{	
		checkOtherSchoolFilledFromBorrowerInitiatedPublic();
		hide_show_OtherSchoolName_In_Borr_Initialted_InPublic();
	}
	addFormElement('Action', Action);	
	addFormElement('ID1', id1);
	addFormElement('ID2', id2);
	addFormElement('ID3', id3);
	addFormElement('ID4', id4);
	addFormElement('ID5', id5);
	addFormElement('ID6', id6);
	addFormElement('ID7', id7);
		
	 
	//[Phase5] turn all the fields into read only. So that
	// no chnage is alowed while submitting the event to the middle tier.
		if (Action=='GoHome')
			{
			submitForm('');			
			}
		else
			if (id1==null )
				submitForm('');		
			else 			
				if (id1.match("Home.htm")!=null)
				{
					submitForm('');			
				}
				else		
					if (id1.match(".htm")!=null)
					{ 
						submitFormHtm(id1);
					}
					else  
					{ 
						if (Action=='OpenPage')
						{											
							submitFormHtm(id1+'.htm');
						}
						else
							{ 
								
								submitForm(id1);			
							}
					}
			
	//submitForm(sActionPage);
	
}
function checkData(){ 
	//document.all.BFName.style.class ="ErrorText";
	var vDataOk = true;
    for (i = 0; i < window.document.forms[0].elements.length; i++)
    {
		var elName = window.document.forms[0].elements[i].name;
		var elValue = window.document.forms[0].elements[i].value;
		var elEmpty = window.document.forms[0].elements[i].AllowEmpty;
        if(elName.indexOf("//") != -1 )
        {
	        if (elEmpty == 'False' && elValue == '' ) //, 0) + 1;  window.document.forms[0].elements[i].type == 'text')
	        {
				errorField(elName);
				vDataOk = false;
			}
        }
    } 
    if (!vDataOk)
		addError("Please fill in empty fields","DataCheck")
    return vDataOk; 
}


// The hidden field (userdefinedfield) that is sent to NCS is string consist of
// values separated by 'A'.
function AddCreditCheckAuthToNCSRequest(radioObjectName, varValue)
{
	var sFldValue;
	
	// If the credit authorization field does not exist, assume that 
	// credit check is not required (NRe).
	if (window.document.forms[0].elements[radioObjectName] == null)
		{
			window.document.forms[0].elements['userdefinedfield'].value += "XNRe";
			return;
		}
	sFldValue = window.document.forms[0].elements[radioObjectName].value;
	if (isRadioSelected(radioObjectName,varValue))
	{
		window.document.forms[0].elements['userdefinedfield'].value += "XYes";
		
	}
	else
	{
		window.document.forms[0].elements['userdefinedfield'].value += "XNo";
		//document.forms[0].elements['userdefinedfield'].value += varValue;
	}
	
}


function isRadioSelected(radioObjectName, varValue)
{
	for (i = 0; i < window.document.forms[0].elements.length; i++)
    {
		var stname = new String(window.document.forms[0].elements[i].name);
		if (stname == radioObjectName &&
		window.document.forms[0].elements[i].type == 'radio')
		{			
			if (window.document.forms[0].elements[i].checked == true && 
				window.document.forms[0].elements[i].value == varValue)
				return true;
		}
    }
    return false;
}
function radioSelect(radioObjectName, varPos)
{
	for (i = 0; i < window.document.forms[0].elements.length; i++)
    {
		var stname = new String(window.document.forms[0].elements[i].name);
		if (stname == radioObjectName &&
		window.document.forms[0].elements[i].type == 'radio')
		{			
			if (window.document.forms[0].elements[i].position == varPos)
			{
				window.document.forms[0].elements[i].checked == true;
			}
			else
				window.document.forms[0].elements[i].checked == false;
				
		}
    }
}


function isCheckBoxSelected(radioObjectName, varValue)
{
	for (i = 0; i < window.document.forms[0].elements.length; i++)
    {
		var stname = new String(window.document.forms[0].elements[i].name);
		if (stname == radioObjectName &&
		window.document.forms[0].elements[i].type == 'checkbox')
		{			
			if (window.document.forms[0].elements[i].checked == true && 
				window.document.forms[0].elements[i].value == varValue)
				return true;
		}
    }
    return false;
}


function CounselingWrapup_EnableLicenceInfo()
{	
	if (isCheckBoxSelected('//CounselingWrapUp/No_License', 1))
	{
		window.document.forms[0].elements['//CounselingWrapUp/Driver_License_State'].disabled = true;
		window.document.forms[0].elements['//CounselingWrapUp/Driver_License_Num'].disabled = true;
	}
	else
	{
		window.document.forms[0].elements['//CounselingWrapUp/Driver_License_State'].disabled = false;
		window.document.forms[0].elements['//CounselingWrapUp/Driver_License_Num'].disabled = false;
	}
}

function EnableFAFSA()
{
	if (isRadioSelected('//Verification/Method_Verification', 1))
		{			
			if (window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'] != null)
			{
				if (window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'].length != 2)
					window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'].disabled = false;
				else
				{
					window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'][0].disabled = false;
					window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'][1].disabled = false;
				}
			}
			window.document.getElementById("PrintPDF").style.visibility ="hidden";
			window.document.getElementById("PrintPDF").style.display ="none";
			window.document.getElementById("PrintPDF_D").style.visibility ="visible";
			window.document.getElementById("PrintPDF_D").style.display ="inline";
		}
		else
			{
			if (isRadioSelected('//Verification/Method_Verification', 4))
				{				
				if (window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'] != null)
				{
					if (window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'].length != 2)
						window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'].disabled = true;				
					else
					{				
						window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'][0].disabled = true;				
						window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'][1].disabled = true;
					}
				}
				window.document.getElementById("PrintPDF_D").style.visibility ="hidden";
				window.document.getElementById("PrintPDF_D").style.display ="none";
				window.document.getElementById("PrintPDF").style.visibility ="visible";
				window.document.getElementById("PrintPDF").style.display ="inline";
				}
			else
				{
				if (window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'] != null)
				{
					if (window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'].length != 2)
						window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'].disabled = true;
					else				
					{
						window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'][0].disabled = true;				
						window.document.forms[0].elements['//Verification/FAFSAPIN_EXISTENCE'][1].disabled = true;
					}
				}
				window.document.getElementById("PrintPDF").style.visibility ="hidden";
				window.document.getElementById("PrintPDF").style.display ="none";
				window.document.getElementById("PrintPDF_D").style.visibility ="visible";
				window.document.getElementById("PrintPDF_D").style.display ="inline";
				}
		}	

}


function SubmitToNCS (vURL)
{
	window.document.forms[0].target  = "";
	window.document.forms[0].method = "post";
	window.document.forms[0].action = vURL;
	window.document.forms[0].submit();
}


// Connects to the NCS site for E-Sign.
function SubmitRequestToNCS (sUserDefinedData)
{					
	var vASL_URL = window.document.URL;			
	var nDX = vASL_URL.lastIndexOf("/");
		
	var vNCSConnectPath = vASL_URL.substring(0,nDX+1)+"NCSConnect.html";	
		
	var userData = sUserDefinedData;
	window.document.forms[0].target  = "";
	window.document.forms[0].method = "post";
	window.document.forms[0].action = vASL_URL.substring(0,nDX+1)+'external_link.asp?refURL=' + rtrim(ltrim(vNCSConnectPath))+"&userData="+userData;	
	window.document.forms[0].submit();		
}


function SubmitBackToASL ()
{
	vURL= "http://localhost/aslweb/public/main.aspx";
	top.frames[0].navigate(vURL);
}


function submitForm(sActionPage)
{
	 
	var vURL = window.document.URL;
	var nDX = vURL.indexOf("://");
	vURL = vProtocol +"://"+vURL.substring(nDX+3);
	
	submitAllCheckboxs();
	window.document.forms[0].target  = "";
	window.document.forms[0].method = "post";
	
	// When the NCS redirects to either success or fail page,
	// when need to change the url to point back to main.aspx.
//	if (vURL.indexOf("NCSSuccess.aspx") != -1 )
//	{
//		nDX = vURL.indexOf("NCSSuccess.aspx");
//		vURL = vURL.substring(0,nDX)+"Main.aspx";	
//	}
//	else if (vURL.indexOf("NCSFail.aspx") != -1 )
//	{
//		nDX = vURL.indexOf("NCSFail.aspx");
//		vURL = vURL.substring(0,nDX)+"Main.aspx";
//	}
	// always should submit to main.aspx
	nDX = vURL.lastIndexOf("/");
	vURL = vURL.substring(0,nDX+1);
	
	if (sActionPage != null && sActionPage == 'ConsolidateYourLoans')
		vURL += "ConsolidateYourLoans.aspx";		
	else
		vURL += "Main.aspx";
		
	
	window.document.forms[0].action = vURL; 	
	window.document.forms[0].submit();			
		
}

function submitFormHtm(sActionPage)
{
	 
	var vURL = window.document.URL;
	var nDX = vURL.indexOf("://");
	vURL = vProtocol +"://"+vURL.substring(nDX+3);
	
	submitAllCheckboxs();
	window.document.forms[0].target  = "";
	window.document.forms[0].method = "post";
	
	// When the NCS redirects to either success or fail page,
	// when need to change the url to point back to main.aspx.
//	if (vURL.indexOf("NCSSuccess.aspx") != -1 )
//	{
//		nDX = vURL.indexOf("NCSSuccess.aspx");
//		vURL = vURL.substring(0,nDX)+"Main.aspx";	
//	}
//	else if (vURL.indexOf("NCSFail.aspx") != -1 )
//	{
//		nDX = vURL.indexOf("NCSFail.aspx");
//		vURL = vURL.substring(0,nDX)+"Main.aspx";
//	}
	// always should submit to main.aspx
	//alert (vURL.lastIndexOf("?"));	
	var mainstr= "main.aspx";
	nDX = vURL.lastIndexOf("?")- mainstr.length - 1;
	vURL = vURL.substring(0,nDX+1);
	//alert(vURL);
	
	
	
	
	if (sActionPage != null && sActionPage == 'ConsolidateYourLoans')
		vURL += "ConsolidateYourLoans.aspx";		
	else
		vURL += "Main.aspx";
		
	
	window.document.forms[0].action = vURL; 	
	window.document.forms[0].submit();			
		
}

function submitAllCheckboxs()
{
	
	// to prevent multipple submition
    for (i = 0; i < window.document.forms[0].elements.length; i++)
    {
      if (window.document.forms[0].elements[i].type == 'checkbox')
      {
         if (window.document.forms[0].elements[i].checked == false)
         {
				if (window.document.forms[0].elements[i].value != -1)
				{
					var element=window.document.createElement('INPUT'); 
					//element.type='hidden'; 
					element.style.visibility='hidden'
					element.name=window.document.forms[0].elements[i].name;
					element.value=0;
					window.document.forms[0].appendChild(element);
				}
				window.document.forms[0].elements[i].value=-1;
			
		 }
      }
      else
      {
		if (window.document.forms[0].elements[i].name == 'SELECTEDLIST')
		{
			SubmitSelected('SELECTEDLIST');
			
		}
      }
    }
	
}
function setFocus()
{	
	if ((window.document.forms[0].elements['FirstErrField'] != null) && (window.document.forms[0].elements['FirstErrField'].value != '') )
	  {
		if (window.document.forms[0].elements[window.document.forms[0].elements['FirstErrField'].value] != null)
		{						
			var sName =window.document.forms[0].elements['FirstErrField'].value;
			if ( sName.indexOf("Eligibility_Question/AnswerCode") == -1)
			{
				//[ Phase 5.3] : if disabled, focus can NOT be set.
				if (window.document.forms[0].elements[window.document.forms[0].elements['FirstErrField'].value].disabled)
				   return;
				   
				if (window.document.forms[0].elements['FirstErrField'].style.visibility == "visible")
					window.document.forms[0].elements[window.document.forms[0].elements['FirstErrField'].value].focus();
			}
			if (window.document.forms[0].elements[window.document.forms[0].elements['FirstErrField'].value].type =='text')			
				window.document.forms[0].elements[window.document.forms[0].elements['FirstErrField'].value].select();
		}
	}
	else 
	if ((window.document.forms[0].elements['FocusField'] != null) && (window.document.forms[0].elements['FocusField'].value != '') )
	  {
		if (window.document.forms[0].elements[window.document.forms[0].elements['FocusField'].value] != null)
		{
			//alert(document.forms[0].elements[document.forms[0].elements['FocusField'].value]);
			window.document.forms[0].elements[window.document.forms[0].elements['FocusField'].value].focus();
			if (window.document.forms[0].elements[window.document.forms[0].elements['FocusField'].value].type =='text')			
				window.document.forms[0].elements[window.document.forms[0].elements['FocusField'].value].select();
		}
	}
	else 
		{   
		var vFocusSet = 0;
		if ((window.document.forms[0].elements['EntryField'] != null) && (window.document.forms[0].elements['EntryField'].value != '') )
		  {
			if (window.document.forms[0].elements[window.document.forms[0].elements['EntryField'].value] != null)
			{
				if (window.document.forms[0].elements[window.document.forms[0].elements['EntryField'].value] != null && window.document.forms[0].elements[window.document.forms[0].elements['EntryField'].value].type != 'hidden' )
				{
					window.document.forms[0].elements[window.document.forms[0].elements['EntryField'].value].focus();
					vFocusSet = 1;
					if (window.document.forms[0].elements[window.document.forms[0].elements['EntryField'].value].type =='text')			
						window.document.forms[0].elements[window.document.forms[0].elements['EntryField'].value].select();
				}
			}
		}
		if (vFocusSet == 0)
		{
			if (window.document.forms[0].elements.length > 1)
			{
				for (i = 0; i < window.document.forms[0].elements.length; i++)
					{
						
						if (window.document.forms[0].elements[i].name == '//Borrower/Password_Question' || window.document.forms[0].elements[i].name == '//School_User/Password_Question')
							{
								window.document.forms[0].elements[i+1].focus();
								return;
							}
						if (window.document.forms[0].elements[i].type == 'checkbox' || window.document.forms[0].elements[i].type == 'text' || window.document.forms[0].elements[i].type == 'select-one' || window.document.forms[0].elements[i].type == 'radio' || window.document.forms[0].elements[i].type == 'textarea')
						{
							if ((window.document.forms[0].elements[i].disabled != true) && (window.document.forms[0].elements[i].name != 'textsearch'))
								{
									//MIsmail in [09 - Nov - 2006, 15:09]
									//I just added the if statement below
									//Handle the invisible elements
									//window.document.forms[0].elements[i].focus();
									if (window.document.forms[0].elements[i].style.visibility == "visible")
										window.document.forms[0].elements[i].focus();
									return;
								}
								
						}
					}
			}
			
			if (window.document.getElementById("textsearch") != null)
			{
				window.document.getElementById("textsearch").focus();
				return;
			}
		}
	}
 }
// Calculates the absolute page x coordinate of a relatively positioned element
function aspnm_pageX(element)
{
  var x = 0;
  do 
    x += element.offsetLeft;
  while ((element = element.offsetParent));
  return x; 
}

// Calculates the absolute page x coordinate of a relatively positioned element
function aspnm_pageY(element)
{
  var y = 0;
  do 
    y += element.offsetTop; 
  while ((element = element.offsetParent));
  return y; 
}

// Hides HTML select elements that are overlapping the given menu group 
function aspnm_hideSelectElements(group)
{
  if (window.document.getElementsByTagName) 
  {
  
    var arrElements = window.document.getElementsByTagName('select'); 
    if (aspnm_hideSelectElems) 
      for (var i = 0; i < arrElements.length; i++) 
        if (aspnm_objectsOverlapping(group, arrElements[i]))
          arrElements[i].style.visibility = 'hidden'; 
  }
}

// Whether the given objects are overlapping 
function aspnm_objectsOverlapping(obj1, obj2)
{
	
  var result = true; 
  var obj1Left = aspnm_pageX(obj1) - window.document.body.scrollLeft; 
  var obj1Top = aspnm_pageY(obj1) - window.document.body.scrollTop; 
  var obj1Right = obj1Left + obj1.offsetWidth; 
  var obj1Bottom = obj1Top + obj1.offsetHeight;
  var obj2Left = aspnm_pageX(obj2) - window.document.body.scrollLeft; 
  var obj2Top = aspnm_pageY(obj2) - window.document.body.scrollTop; 
  var obj2Right = obj2Left + obj2.offsetWidth; 
  var obj2Bottom = obj2Top + obj2.offsetHeight;
  
  if (obj1Right <= obj2Left || obj1Bottom <= obj2Top || 
      obj1Left >= obj2Right || obj1Top >= obj2Bottom) 
    result = false; 
  return result; 
}

function hideComboLists()
{
    for (i = 0; i < window.document.forms[0].elements.length; i++)
    {
		if (window.document.forms[0].elements[i].type == 'select-one')
		{
			//alert(document.forms[0].elements[i].offsetTop);
			window.document.forms[0].elements[i].style.visibility = "hidden";
		}
    }
}
function showComboLists()
{
    for (i = 0; i < window.document.forms[0].elements.length; i++)
    {
		if (window.document.forms[0].elements[i].type == 'select-one')
			window.document.forms[0].elements[i].style.visibility = "visible";
    }
}


function setSelectedTopic(vTopicIndex, vItemIndex)
{
	addFormElement('SelectedTopic', vTopicIndex);
	addFormElement('SelectedItem', vItemIndex);
	return true;
}

function addFormElement(key, value)
{
    if ( window.document.forms[0].elements[key] == null )
    {
		var element=window.document.createElement('INPUT'); 	
		//element.type='hidden'; 
		element.style.visibility='hidden'
		element.name=key;
		element.id=key;
		element.value=value;
		window.document.forms[0].appendChild(element);
    }
    else
		window.document.forms[0].elements[key].value = value;
}

function SubmitSelected(selectedList)
{
  var  oOption ;
  var vXpathName ;
  if (window.document.forms[0].elements['hiddenSelectedXPath'] != null)
	vXpathName = window.document.forms[0].elements['hiddenSelectedXPath'].value;
	
  var c = window.document.forms[0].elements[selectedList].length; //document.frmMain.SelectedResources.length;

  for(k=0; k<c; k++)
  {
			var element=window.document.createElement('INPUT'); 
			//element.type='hidden'; 
			element.style.visibility='hidden'
			element.name= vXpathName + "[" + (k+1) +"]"+ "/Value";
			element.value=window.document.forms[0].elements[selectedList].options[k].value;
			window.document.forms[0].appendChild(element);
			
			element=window.document.createElement('INPUT'); 
			//element.type='hidden'; 
			element.style.visibility='hidden'
			element.name= vXpathName + "[" + (k+1) +"]"+ "/Text";
			element.value=window.document.forms[0].elements[selectedList].options[k].text;
			window.document.forms[0].appendChild(element);
  }
}
//=============================
// Menu Rollover Action
//=============================
	

function submenuover(subid)
{	
	window.document.getElementById(subid).style.visibility= "visible";
	window.document.getElementById(subid).style.position= "relative";
}

function submenuout(subid)
{	
	window.document.getElementById(subid).style.visibility= "hidden";
	window.document.getElementById(subid).style.position= "absolute";
}
	
//function submenuHover(subid,shid)
//{	
//	document.all[subid].style.visibility= "visible";
//	aspnm_hideSelectElements(document.all[subid]);
//}

//function submenuHout(subid,shid)
//{	
//	document.all[subid].style.visibility= "hidden";
//	showComboLists();
//}
	
function Add_onClick(allList,selectedList)
{
	var  oOption ;
	var c = window.document.forms[0].elements[allList].length ;// document.frmMain.Resources.length;
	var my_array = new Array();
	k=0;

	for(i=0; i<c; i++)
	{
	    oOption = new Option();
	    if (window.document.forms[0].elements[allList][i].selected) //document.frmMain.Resources[i]
	    {
			oOption.value= window.document.forms[0].elements[allList].options[i].value; //document.frmMain.Resources.options[i].value;
			oOption.text= window.document.forms[0].elements[allList].options[i].text; //document.frmMain.Resources.options[i].text;
			//document.frmMain.SelectedResources.options[document.frmMain.SelectedResources.length]=oOption;
			window.document.forms[0].elements[selectedList].options[window.document.forms[0].elements[selectedList].length]=oOption;
			oOption=null;
			my_array[k]=i;
			k=k+1;
	    }
	}
	for(i=0; i<k; i++)
	{
		window.document.forms[0].elements[allList].options[my_array[i]-i].selected=false;
		window.document.forms[0].elements[allList].options[my_array[i]-i]=null;
	}
}

function Remove_onClick(allList,selectedList)
{
  var  oOption ;
  var c = window.document.forms[0].elements[selectedList].length; //document.frmMain.SelectedResources.length;
  var my_array = new Array();
  k=0;
  for(i=0; i<c; i++)
  {
    oOption = new Option();
    if (window.document.forms[0].elements[selectedList][i].selected)
    {
	oOption.value= window.document.forms[0].elements[selectedList].options[i].value;
	oOption.text=window.document.forms[0].elements[selectedList].options[i].text;
	window.document.forms[0].elements[allList].options[window.document.forms[0].elements[allList].length]=oOption;
	oOption=null;
	my_array[k]=i;
	k=k+1;
    }
  }
  for(i=0; i<k; i++)
  {
    window.document.forms[0].elements[selectedList].options[my_array[i]-i].selected=false;
    window.document.forms[0].elements[selectedList].options[my_array[i]-i]=null;
  }
}

function popupPDF(Action,Application_Data_ID){
	
	addFormElement('Action', Action);
	if ( Application_Data_ID != null) // if the parameter is provided then add it to the Form
		addFormElement('Application_Data_ID', Application_Data_ID);
	
	addFormElement('ID1', '');
	
	if (window.document.getElementById("School_Product_Profile_ID") != null )
		addFormElement('ID2', window.document.getElementById("School_Product_Profile_ID").value);
	
	
	window.document.forms[0].target  = "_blank";
	window.document.forms[0].method = "post";
	window.document.forms[0].action = "GeneratePDF.aspx";
	window.document.forms[0].submit();
}
function PrintBlankApp(Action,ID1,ID2){
	
	addFormElement('Action', Action);
	
	addFormElement('ID1', ID1);
	addFormElement('ID2', ID2);
	
	window.document.forms[0].target  = "_blank";
	window.document.forms[0].method = "post";
	window.document.forms[0].action = "GeneratePDF.aspx";
	window.document.forms[0].submit();
}

function popupCounselingPDF(Action,ExamBorrowerID){
	
	addFormElement('Action', Action);
	
	addFormElement('Exam_Borrower_ID', ExamBorrowerID);
			
	window.document.forms[0].target  = "_blank";
	window.document.forms[0].method = "post";
	window.document.forms[0].action = "GeneratePDF.aspx";
	window.document.forms[0].submit();
}

function popupCounselingPDFByXML(Action){
	
	addFormElement('Action', Action);
	
	//addFormElement('Exam_XML', Exam_XML);
			
	window.document.forms[0].target  = "_blank";
	window.document.forms[0].method = "post";
	window.document.forms[0].action = "GeneratePDF.aspx";
	window.document.forms[0].submit();
}


function popupStaticPreview(Action, ID1)
{
	addFormElement('Action', Action);
	addFormElement('ID1', ID1);
	window.document.forms[0].target  = "_blank";
	window.document.forms[0].method = "post";
	window.document.forms[0].action = "staticPopupWindow.aspx";
	window.document.forms[0].submit();
}

function popupPreview(Action){

reorderList();

	addFormElement('Action', Action);
	//submitAllCheckboxs();
	window.document.forms[0].target  = "_blank";
	window.document.forms[0].method = "post";
	window.document.forms[0].action = "popupPreview.aspx";
	window.document.forms[0].submit();
}
function popupModalWindow(vAction){
	//Create a Modal window for client feedback
	var WIDTH = 350;								// set width of window 
	var HEIGHT = 200;								// set height of window 
	var LEFT_POS = screen.width/2 - WIDTH/2;		// Center the window
	var TOP_POS = screen.height/2 - HEIGHT/2;		// Center the window
	
	newWindow = window.open('popupPreview.aspx','Modal','toolbar=no,location=no,scrollbars=no,resizable=no,width='+WIDTH+',height=' + HEIGHT + ',left=' + LEFT_POS + ',top=' + TOP_POS);
	newWindow.focus();
}

function refreshScreen(fname)
{	
	alert(fname);
}

function ClearSearch()
{
	var bStatusRadioIsChecked = false;
	 for (i = 0; i < window.document.forms[0].elements.length; i++)
    {
		var stname = new String(window.document.forms[0].elements[i].name);
		if (stname.substring(0,9) == '//Search/')
		{			
			if (window.document.forms[0].elements[i].type == 'select-one')
				window.document.forms[0].elements[i].options[0].selected=true;
			else if(window.document.forms[0].elements[i].type == 'radio')
			{
				if (!bStatusRadioIsChecked)
					window.document.forms[0].elements[i].checked=true;						
				bStatusRadioIsChecked = true;
			}
			else if(window.document.forms[0].elements[i].type == 'checkbox' && 
				((stname.indexOf("Status1") != -1) ||
					(stname.indexOf("Status2") != -1) || 
					(stname.indexOf("Status3") != -1) || 
					(stname.indexOf("Status4") != -1) ||
					(stname.indexOf("AW_Loan_Type_Combo") != -1) ||
					(stname.indexOf("AW_Loan_Status_Combo") != -1 )
				))
			{
				window.document.forms[0].elements[i].checked=true;
			}	
			else	
			{		
				if(stname.indexOf("//Search/AW_Loan_Type_Combo") == -1   &&
					stname.indexOf("//Search/AW_Loan_Status_Combo") == -1)
				{
					window.document.forms[0].elements[i].value = "";
				}
			}
		}
    }
    
	setFocus();
}

function ClearForm(strPrfix)
{
	var nPrefixLen;
		
	nPrefixLen = strPrfix.length;
		
	 for (i = 0; i < window.document.forms[0].elements.length; i++)
    {
		var stname = new String(window.document.forms[0].elements[i].name);
		if (stname.substring(0,nPrefixLen) == strPrfix)
		{
			if (window.document.forms[0].elements[i].type == 'select-one')
				window.document.forms[0].elements[i].options[0].selected=true;
			else
				window.document.forms[0].elements[i].value = "";
		}
    }
	setFocus();
}

function LockForm(sFldName)
{								
	for (i = 0; i < window.document.forms[0].elements.length; i++)
    {
		var stname = new String(window.document.forms[0].elements[i].name);
		if (stname.substring(0,2) == "//" && stname != sFldName)
		{	
			if (window.document.forms[0].elements[i].type == 'select-one')		
				window.document.forms[0].elements[i].disabled = true;	
			else
				window.document.forms[0].elements[i].readOnly = true;	
		}
    }
    setFocus();
}


function OpenAdmin(){
	//Create a Modal window for client feedback
	//var WIDTH = 350;								// set width of window 
	//var HEIGHT = 200;								// set height of window 
	//var LEFT_POS = screen.width/2 - WIDTH/2;		// Center the window
	//var TOP_POS = screen.height/2 - HEIGHT/2;		// Center the window

//	var WinId = null;
//	newWindow = window.open('','AdminInterface');

//	alert(newWindow.closed);

	if (newWindow == null || newWindow.closed)
		 newWindow = window.open('Admin.aspx','AdminInterface');

if (newWindow != null && newWindow.document.forms[0] != null)
	{
		var element=newWindow.document.createElement('INPUT'); 
		//element.type='hidden'; 
		element.style.visibility='hidden'
		element.name='Action';
		element.id='Action';
		element.value='GetList';
		newWindow.document.forms[0].appendChild(element);
		var element2=newWindow.document.createElement('INPUT'); 
		element2.type='hidden'; 
		element2.name='ID1';
		element2.id='ID1';
		element2.value='Role_List';
	
		newWindow.document.forms[0].appendChild(element2);

		newWindow.document.forms[0].target  = "";
		newWindow.document.forms[0].method = "post";
		newWindow.document.forms[0].action = "Admin.aspx";
		newWindow.document.forms[0].submit();
	}
	newWindow.focus();
}
function MoveUp(obj)
{
	var vr = obj.parentNode.rowIndex;
	var n = 1;
	if (oTable!= null && oTable.rows!=null)
		n=oTable.rows.length;
	// do not move the first row	
	if (eval(vr) > 1)
	{
		oTable.moveRow(eval(vr),eval(vr)-1);
		obj.position = eval(vr)-1;
	}

}
function MoveDown(obj)
{
	var vr = obj.parentNode.rowIndex;
	var n = 1;
	if (oTable!= null && oTable.rows!=null)
		n=oTable.rows.length - 1;
	// do not move the last row
	if (eval(vr) < n)
		oTable.moveRow(eval(vr),eval(vr)+1);

}

function MoveUp2(obj)
{
	var vr = obj.parentNode.rowIndex;
	var n = 1;
	if (oTable2!= null && oTable2.rows!=null)
		n=oTable2.rows.length;
	// do not move the first row	
	if (eval(vr) > 1)
	{
		oTable2.moveRow(eval(vr),eval(vr)-1);
		obj.position = eval(vr)-1;
	}

}
function MoveDown2(obj)
{
	var vr = obj.parentNode.rowIndex;
	var n = 1;
	if (oTable2!= null && oTable2.rows!=null)
		n=oTable2.rows.length - 1;
	// do not move the last row
	if (eval(vr) < n)
		oTable2.moveRow(eval(vr),eval(vr)+1);

}

function fixListOrder(vPageKey,vOrderField)
{
	var n = 0;
	if (oTable!= null && oTable.rows!=null)
		n=oTable.rows.length;

	for (nC=1;nC<n;nC++)
	{
		vInnerHTML = oTable.rows[nC].cells[0].innerHTML ;
		//if (vInnerHTML.indexOf(vPageKey) == -1 && vInnerHTML.indexOf(vOrderField) == -1) 
			vInnerHTML = vInnerHTML + "<Input type='hidden' name='//"+vPageKey+"["+nC+"]/"+vOrderField+"' value='"+nC+"'>";
		oTable.rows[nC].cells[0].innerHTML = vInnerHTML ;
	}
}

function reorderList()
{
	var n = 0;
	if (oTable2!= null && oTable2.rows!=null)
		n=oTable2.rows.length;

	for (nC=1;nC<n;nC++)
	{
		var vInnerHTML = oTable2.rows[nC].cells[2].innerHTML ;
		var nDx = vInnerHTML.indexOf("]/TestOrder");
		vInnerHTML = vInnerHTML.substring(nDx-3,nDx);
		nDx = vInnerHTML.indexOf("[");
		var nF = vInnerHTML.substring(nDx+1);

		var Fname = "//Interface2TestTable2["+nF+"]/TestOrder";

		window.document.forms[0].elements[Fname].value = nC;
			
	}
}
function addRow()
{
	var n = 1;
	if (oTable!= null && oTable.rows!=null)
		n=oTable.rows.length;

	var oRow, oCell;
	var i, j;

	oRow = oTBody0.insertRow();
	var vIndex = oRow.rowIndex ;// - 1;
	
	if ((vIndex%2) == 0)
	{
	oRow.style.background = "#CCDDFF";
	}
	else 
	{
	oRow.style.background = "#E8E8FF";
	}
	
	var nCels=oTable.rows[n-1].cells.length;

	for (nn=0;nn<nCels;nn++)
	{
		oCell = oRow.insertCell();
		oCell.align = oTable.rows[1].cells[nn].align; //"center";
		var vHTML = "";
		if (nn == 0)
			vHTML = setValue(oTable.rows[1].cells[nn].innerHTML);
		else
			vHTML = setValue(oTable.rows[1].cells[nn].innerHTML);
		oCell.innerHTML = vHTML;
	}
	
}
function addCol()
{
	var n = 1;
	if (oTable!= null && oTable.rows!=null)
		n=oTable.rows.length;

	var oRow, oCell;
	var i, j;
	
	var nCels=oTable.rows[1].cells.length;

	for (nc=0;nc<n;nc++)
	{	
		oRow  = oTable.rows[nc];
		oCell = oRow.insertCell();
		var vHtml="";
		oCell.align = oTable.rows[nc].cells[1].align;
		oCell.className = oTable.rows[nc].cells[1].className;
		oCell.setAttribute("width", oTable.rows[nc].cells[1].getAttribute("width"));
	
		if (nc == 0) // for header only
		{
			 vHtml = oTable.rows[nc].cells[1].innerHTML;
		}
		else	
			 vHtml = "<input value='' name='//Interface2TestTable1/Col"+nCels+"' maxLength='10' style='width:86;' type='text' class='fieldstext' onkeydown='numMask(this);' align='center' onchange='sumField(this);'>"; //oTable.rows[nc].cells[nCels-1].innerHTML;
		
		//var iVal = vHtml.indexOf("Value=");
		//var iName = vHtml.indexOf("Name=");

		
		oCell.innerHTML = vHtml;
	}
	
		var nSCels=oSumTable.rows[0].cells.length;
		oRow  = oSumTable.rows[0];
		oCell = oRow.insertCell();
		oCell.align = oSumTable.rows[0].cells[nSCels-1].align;
		oCell.setAttribute("width", oSumTable.rows[0].cells[nSCels-1].getAttribute("width"));
		oCell.innerHTML = "<input value='' readonly='1' name='//Interface2TestTable1/Col"+nSCels+"/Sum' type='text' style='width:86;'>";
}
function sumField(vField)
{
    var vFName =  vField.name ;
    var vSum = 0;
    for (i = 0; i < window.document.forms[0].elements.length; i++)
    {
      if (window.document.forms[0].elements[i].name == vFName )
      {
	if (window.document.forms[0].elements[i] != null && window.document.forms[0].elements[i].value != '')
        vSum =  vSum + eval(window.document.forms[0].elements[i].value);
      }
    }
    var vSumName = vFName+'/Sum';
//	alert(vSumName);
    if (window.document.forms[0].elements[vSumName] != null)
    	window.document.forms[0].elements[vSumName].value = vSum;
}
function setValue(vHTML)
{
	//alert("vHTML:"+vHTML);
	var vResult = vHTML;
		var nStart = vHTML.indexOf("value=", 0) ;
		if (nStart == -1)
		{
			vResult = vHTML ; //.substring(0,vHTML.length-2) +" value='' >";
		}
		else
		{
			var vFirst = vHTML.substring(0,nStart);
			var vNext = vHTML.substring(nStart,vHTML.length);
			var nEnd = vNext.indexOf(" ");
			vResult = vFirst + " value='' " + vNext.substring(nEnd);
			
		}		
	//alert("vResult:"+vResult);
	return vResult;	
}
function changeRadioMessage(sMessage_Field,vField_Source,vField_PaperID,vField_OnlineID,vField_FAid_URL,vField_Campus_URL,vField_App_Prod_Prof_ID)
{
	if (window.document.getElementById(vField_Source)!= null)
		window.document.getElementById(vField_Source).innerHTML = window.document.getElementById(sMessage_Field).value;
	
	if (window.document.getElementById("School_Product_Profile_ID") != null)
		window.document.getElementById("School_Product_Profile_ID").value=vField_App_Prod_Prof_ID;
		
	if (window.document.getElementById("//StartLoanQWizard/School_Product_Profile_ID") != null)
		window.document.getElementById("//StartLoanQWizard/School_Product_Profile_ID").value = vField_App_Prod_Prof_ID;
    
    if (window.document.getElementById("FAID_URL") != null)
		window.document.getElementById("FAID_URL").value=vField_FAid_URL;
		
    if (window.document.getElementById("Campus_Door_URL") != null)
		window.document.getElementById("Campus_Door_URL").value=vField_Campus_URL;
	
	sOnlineID=vField_OnlineID;
    sPaperID=vField_PaperID;
    sFAid_URL=vField_FAid_URL;
    sCampus_URL=vField_Campus_URL;
	//alert(sOnlineID);
	//alert(sPaperID);
	//alert(sFAid_URL);
	//if ((rtrim(ltrim(sOnlineID))=="" || rtrim(ltrim(sOnlineID))=="0") && (rtrim(ltrim(sFAid_URL))=="" || rtrim(ltrim(sFAid_URL))=="0")&&(rtrim(ltrim(sCampus_URL))=="" || rtrim(ltrim(sCampus_URL))=="0"))
	//	{
	//	window.document.getElementById("Continue").style.visibility ="hidden";
	//	window.document.getElementById("Continue").style.display ="none";
		//document.getElementById("Continue").style.width=0;
	//	window.document.getElementById("Continue_D").style.visibility ="visible";
	//	window.document.getElementById("Continue_D").style.display ="inline";
		//document.getElementById("Continue_D").style.width=108;
	//	}
	//else	
	//	{
	//	window.document.getElementById("Continue").style.visibility ="visible";
	//	window.document.getElementById("Continue").style.display ="inline";
		//document.getElementById("Continue").style.width=108;
	//	window.document.getElementById("Continue_D").style.visibility ="hidden";
	//	window.document.getElementById("Continue_D").style.display ="none";
		//document.getElementById("Continue_D").style.width=0;
	//	}
	//if (rtrim(ltrim(sPaperID))=="" || rtrim(ltrim(sPaperID))=="0")
	//	{
	//	window.document.getElementById("PrintApplication").style.visibility ="hidden";
	//	window.document.getElementById("PrintApplication").style.display ="none";
	//	//document.getElementById("PrintApplication").style.width=1;
	//	window.document.getElementById("PrintApplication_D").style.visibility ="visible";
	//	window.document.getElementById("PrintApplication_D").style.display ="inline";
	//	//document.getElementById("PrintApplication_D").style.width=162;
		
	//	}
	//else	
	//	{
	//	window.document.getElementById("PrintApplication").style.visibility ="visible";
	//	window.document.getElementById("PrintApplication").style.display ="inline";
		//document.getElementById("PrintApplication").style.width=162;
	//	window.document.getElementById("PrintApplication_D").style.visibility ="hidden";
	//	window.document.getElementById("PrintApplication_D").style.display ="none";
		//document.getElementById("PrintApplication_D").style.width=0;
		
	//	}	     
}

function changeButton_LoanDisclaimer(vIAgree)
{
	
	
	if (window.document.forms[0].elements[vIAgree].checked == false)
		{
		document.getElementById("Continue").style.visibility ="hidden";
		document.getElementById("Continue").style.display ="none";
		document.getElementById("Continue_D").style.visibility ="visible";
		document.getElementById("Continue_D").style.display ="inline";
		}
	else	
		{
		document.getElementById("Continue").style.visibility ="visible";
		document.getElementById("Continue").style.display ="inline";
		document.getElementById("Continue_D").style.visibility ="hidden";
		document.getElementById("Continue_D").style.display ="none";
		}
	    
}

function changeButton_RegisterUser(vRegisterUser)
{
	
	
	if (window.document.forms[0].elements[vRegisterUser].checked == false)
		{
		 
		 window.document.forms[0].elements['//Borrower/Login'].disabled = true;
		 window.document.forms[0].elements['//Borrower/Pswd'].disabled = true;
	
		 document.getElementById("Login").style.visibility ="hidden";
		 document.getElementById("Login").style.display ="none";
		 document.getElementById("Login_D").style.visibility ="visible";
		 document.getElementById("Login_D").style.display ="inline";
		
		
		}
	else	
		{
		 window.document.forms[0].elements['//Borrower/Login'].disabled = false;
		 window.document.forms[0].elements['//Borrower/Pswd'].disabled = false;
		
		  	document.getElementById("Login").style.visibility ="visible";
			document.getElementById("Login").style.display ="inline";
			document.getElementById("Login_D").style.visibility ="hidden";
			document.getElementById("Login_D").style.display ="none";
		
		
		}
	    
}


function OpenExternalURL(sExternalSchoolURL)
{
	window.open("http://"+sExternalSchoolURL,TARGET="_self");
}



var newMacwindow=''
function OpenExternalURLInMac(url)
{	
	
	newMacwindow=window.open(url,'',"toolbar=yes,titlebar=yes,location=yes,status=yes");
	
	if (newMacwindow.opener)
	newMacwindow.opener.close(); 
	
	if (window.focus) {newMacwindow.focus()}
	return false;
}


function LoanWizardmenuAction(sExternalCallingSchool)
{
	
		menuAction('LoanWizard_GetWizardWelcome','WizardInstructions',document.getElementById("School_Product_Profile_ID").value,sExternalCallingSchool);
/*	if ((rtrim(ltrim(document.getElementById("FAID_URL").value))=="" && rtrim(ltrim(document.getElementById("Campus_Door_URL").value))=="")
	||(rtrim(ltrim(document.getElementById("FAID_URL").value))=="0" && rtrim(ltrim(document.getElementById("Campus_Door_URL").value))=="0"))
		menuAction('LoanWizard_GetWizardWelcome','WizardInstructions',document.getElementById("School_Product_Profile_ID").value,sExternalCallingSchool);
		else
		{
			if (rtrim(ltrim(document.getElementById("FAID_URL").value))!=""&&rtrim(ltrim(document.getElementById("FAID_URL").value))!="0")
				if ((rtrim(ltrim(document.getElementById("FAID_URL").value)).indexOf("http://")!=-1)||(rtrim(ltrim(document.getElementById("FAID_URL").value)).indexOf("https://")!=-1)||(rtrim(ltrim(document.getElementById("FAID_URL").value)).indexOf("ftp://")!=-1))
				
				{
					if ((navigator.appVersion.indexOf("Mac") != -1))
						OpenExternalURLInMac(rtrim(ltrim(document.getElementById("FAID_URL").value)))				
					else	
						window.open(rtrim(ltrim(document.getElementById("FAID_URL").value)),TARGET="_self");
				}
				else
				{
					if ((navigator.appVersion.indexOf("Mac") != -1))
						OpenExternalURLInMac("http://" + rtrim(ltrim(document.getElementById("FAID_URL").value)))					
					else
						window.open("http://"+rtrim(ltrim(document.getElementById("FAID_URL").value)),TARGET="_self");
				}
			if (rtrim(ltrim(document.getElementById("Campus_Door_URL").value))!=""&&rtrim(ltrim(document.getElementById("Campus_Door_URL").value))!="0")
				if ((rtrim(ltrim(document.getElementById("Campus_Door_URL").value)).indexOf("http://")!=-1)||(rtrim(ltrim(document.getElementById("Campus_Door_URL").value)).indexOf("https://")!=-1)||(rtrim(ltrim(document.getElementById("Campus_Door_URL").value)).indexOf("ftp://")!=-1))
				{
					if ((navigator.appVersion.indexOf("Mac") != -1))
						OpenExternalURLInMac(rtrim(ltrim(document.getElementById("Campus_Door_URL").value)))
					else
						window.open(rtrim(ltrim(document.getElementById("Campus_Door_URL").value)),TARGET="_self");
				}
				else
				{
					if ((navigator.appVersion.indexOf("Mac") != -1))
						OpenExternalURLInMac("http://"+rtrim(ltrim(document.getElementById("Campus_Door_URL").value)))
					else
						window.open("http://"+rtrim(ltrim(document.getElementById("Campus_Door_URL").value)),TARGET="_self");
				}
					
		} */
		
}

function ltrim ( s )
{
	return s.replace( /^\s*/, "" );
}
function rtrim ( s )
{
	return s.replace( /\s*$/, "" );
}
function changeButtonStatus_LoanWizard(vField_PaperID,vField_OnlineID,vField_FAid_URL,vField_CampusDoor_URL)
{
	//sMessage_Field,vField_Source,
	//document.getElementById(vField_Source).innerHTML = document.getElementById(sMessage_Field).value;
	sOnlineID=vField_OnlineID;
    sPaperID=vField_PaperID;
    sFAid_URL=vField_FAid_URL;
    sCampusDoor_URL=vField_CampusDoor_URL;
	
	//alert(sOnlineID);
	//alert(sPaperID);
	//alert(sFAid_URL);
	if ((rtrim(ltrim(sOnlineID))=="" || rtrim(ltrim(sOnlineID))=="0") && (rtrim(ltrim(sFAid_URL))=="" || rtrim(ltrim(sFAid_URL))=="0") &&(rtrim(ltrim(sCampusDoor_URL))=="" || rtrim(ltrim(sCampusDoor_URL))=="0"))
		{
		document.getElementById("Continue").style.visibility ="hidden";
		document.getElementById("Continue").style.display ="none";
		//document.getElementById("Continue").style.width=0;
		document.getElementById("Continue_D").style.visibility ="visible";
		document.getElementById("Continue_D").style.display ="inline";
		//document.getElementById("Continue_D").style.width=108;
		}
	else	
		{
		document.getElementById("Continue").style.visibility ="visible";
		document.getElementById("Continue").style.display ="inline";
		//document.getElementById("Continue").style.width=108;
		document.getElementById("Continue_D").style.visibility ="hidden";
		document.getElementById("Continue_D").style.display ="none";
		//document.getElementById("Continue_D").style.width=0;
		}
	if (rtrim(ltrim(sPaperID))=="" || rtrim(ltrim(sPaperID))=="0")
		{
		document.getElementById("PrintApplication").style.visibility ="hidden";
		document.getElementById("PrintApplication").style.display ="none";
		//document.getElementById("PrintApplication").style.width=1;
		document.getElementById("PrintApplication_D").style.visibility ="visible";
		document.getElementById("PrintApplication_D").style.display ="inline";
		//document.getElementById("PrintApplication_D").style.width=162;
		
		}
	else	
		{
		document.getElementById("PrintApplication").style.visibility ="visible";
		document.getElementById("PrintApplication").style.display ="inline";
		//document.getElementById("PrintApplication").style.width=162;
		document.getElementById("PrintApplication_D").style.visibility ="hidden";
		document.getElementById("PrintApplication_D").style.display ="none";
		//document.getElementById("PrintApplication_D").style.width=0;
		
		}	    
}


function resetforms()
{
	window.document.forms[0].reset();		
}

function changeRadio_PassValue(hidden_Field_ID_Selected,hidden_Field_ID_NONSelected)
{
	
	
	window.document.getElementById(hidden_Field_ID_Selected).value="1";
	window.document.getElementById(hidden_Field_ID_NONSelected).value="0";
	if(hidden_Field_ID_Selected=="//Award_Letter_Calculator/Financial_Status_Dependent" )
		{
			window.document.getElementById("Changed_Field").innerHTML="PLUS Loan Eligibility";
			window.document.getElementById("//Award_Letter_Calculator/Changed_Field_Contribution").value="PLUS Loan Eligibility";
		}
		else if (hidden_Field_ID_Selected=="//Award_Letter_Calculator/Financial_Status_Independent" )	
			{
				window.document.getElementById("Changed_Field").innerHTML="Your Total Contribution";
				window.document.getElementById("//Award_Letter_Calculator/Changed_Field_Contribution").value="Your Total Contribution";
			}
		
}
// New function written by Steven Galfano
// to wrap ASL frame around external page
// Original function follows this one...
function external_Link(vLink)
{
	//alert("external_Link");
	if (rtrim(ltrim(vLink)).indexOf("http://")!=-1||rtrim(ltrim(vLink)).indexOf("https://")!=-1||rtrim(ltrim(vLink)).indexOf("FTP://")!=-1||rtrim(ltrim(vLink)).indexOf("HTTP://")!=-1||rtrim(ltrim(vLink)).indexOf("HTTPS://")!=-1||rtrim(ltrim(vLink)).indexOf("FTP://")!=-1)
			popupWinTools('https://www.allstudentloan.org/public/external_link.asp?refURL=' + rtrim(ltrim(vLink)),'_blank',775,460,'yes');
			else
				popupWinTools('https://www.allstudentloan.org/public/external_link.asp?refURL=http://' + rtrim(ltrim(vLink)),'_blank',775,460,'yes');
	
}

function internal_link(vLink)
{
	//alert("internal_link");
	if (rtrim(ltrim(vLink)).indexOf("http://")!=-1||rtrim(ltrim(vLink)).indexOf("https://")!=-1||rtrim(ltrim(vLink)).indexOf("FTP://")!=-1||rtrim(ltrim(vLink)).indexOf("HTTP://")!=-1||rtrim(ltrim(vLink)).indexOf("HTTPS://")!=-1||rtrim(ltrim(vLink)).indexOf("FTP://")!=-1)
		popupWinTools(rtrim(ltrim(vLink)),'_blank',775,460,'yes');
	else
		popupWinTools("https://"+rtrim(ltrim(vLink)),'_blank',775,460,'yes');
	
}

function RedirectLink(vLink)
{
	window.location = vLink;
}


// Original external_link function
function external_Link_old(vLink)
{
	if (rtrim(ltrim(vLink)).indexOf("http://")!=-1||rtrim(ltrim(vLink)).indexOf("https://")!=-1||rtrim(ltrim(vLink)).indexOf("FTP://")!=-1||rtrim(ltrim(vLink)).indexOf("HTTP://")!=-1||rtrim(ltrim(vLink)).indexOf("HTTPS://")!=-1||rtrim(ltrim(vLink)).indexOf("FTP://")!=-1)
			window.open(rtrim(ltrim(vLink)),TARGET="_self");	
			else
				window.open("http://"+rtrim(ltrim(vLink)),TARGET="_self");
				
}
//for links to pages 1600-1610
//1500-1510
//1700
//1210
//1220-1230
//1260
//1250
//1252
//1240
//1300
function OpenEmploymentList()
{
	//setSelectedTopic(5,5);
	SwitchSSL('OFF');
	menuAction('OpenPage','EmploymentList');
}
function OpenEmploymentPage(vID)
{
	//setSelectedTopic(5,5);
	SwitchSSL('OFF');
	menuAction('OpenPage','EmploymentListDetail',vID);
}
function OpenPressReleaseList(NewsItemType)
{
	//setSelectedTopic(5,6);
	SwitchSSL('OFF');
	menuAction('OpenPage','PressReleaseList',NewsItemType);
}
function OpenPressReleasePage(vID)
{
	//setSelectedTopic(5,6);
	SwitchSSL('OFF');
	menuAction('OpenPage','PressReleaseDetail',vID);
}
function OpenProductInformation(ProductID)
{
	//setSelectedTopic(1,4);
	SwitchSSL('OFF');
	menuAction('OpenPage','ProductInformation',ProductID);
}
function OpenAwardLetterCalculator()
{
	//setSelectedTopic(2,4);
	SwitchSSL('OFF');
	menuAction('OpenPage','AwardLetterCalculator');
}
function OpenGeneralCalculatorPage(vID)
{
	//setSelectedTopic(2,1);
	SwitchSSL('OFF');
	menuAction('OpenPage','General_Calculator',vID);
}
function OpenLoanPaymentCalculatorPage(vID)
{
	//setSelectedTopic(2,1);
	SwitchSSL('OFF');
	menuAction('OpenPage','Loan_Payment_Caculator',vID);
}
function OpenScholarship()
{
	//SSN ON
	//setSelectedTopic(4,2);
	menuAction('OpenPage','ScholarshipApp');
}
function OpenLoanStatus()
{
	//setSelectedTopic(3,3);
	SwitchSSL('OFF');
	menuAction('OpenPage','Loan_Services');
}
function OpenRequestApplication_Consolidation()
{
	///No SSN, No default selected menu item
	menuAction('OpenPage','RequestApplication','C');
}

function ShowErrorMessage(pageIdx)
{	
	//window.document.forms[0].elements['ErrorMsg'].style.visibility = "visible";
	//window.document.forms[0].elements['ErrorMsg'].style.display ="inline";
	
	window.document.getElementById("ErrorMsg").style.visibility ="visible";
	window.document.getElementById("ErrorMsg").style.display ="inline";
}


function OpenConsolidateYourLoansPage(pageIdx)		 
{	
	var sExternalLogID = window.document.getElementById("//ConsolidateYourLoans/ExternalLogID").value;
	var sPublicURL = window.document.getElementById("//ConsolidateYourLoans/PublicURL").value;
		
	window.open(sPublicURL + 'ConsolidateYourLoans.aspx?PageIdx=' + pageIdx + '_' + sExternalLogID,'_self');
	
	//,'toolbar=no,width=800,height=600,status=no,menubar=no,resizable=no'
	setFocus();
	return false;
}


function OpenConsolidateYourLoans()
{	
	SwitchSSL('OFF');
	menuAction('OpenPage','ConsolidateYourLoans');		
}

function OpenRequestApplication_Non_Consolidation()
{
	///No SSN, No default selected menu item
	menuAction('OpenPage','RequestApplication','N');
}

function OpenRequestApplicationConsolidationLight()
{
	///No SSN, No default selected menu item
	menuAction('OpenPage','RequestApplicationLight','CL');
}
function OpenLoanApplication()
{
	menuAction('LoanWizard_StartLoanApplication','StartLoanApplication','','ApplyForLoan');
}
//end linking methods(1600.....)
function GeneratePDF(Action){

	//reorderList();

	addFormElement('Action', Action);
	//submitAllCheckboxs();
	window.document.forms[0].target  = "_blank";
	window.document.forms[0].method = "post";
	window.document.forms[0].action = "GeneratePDF.aspx";
	window.document.forms[0].submit();
}
function showHelp_Window(vHelp_Element,vContainer_Cell_Element)
{
	richToolTip(window.document.getElementById(vHelp_Element).value,vContainer_Cell_Element);
	//alert(document.getElementById(vHelp_Element).value);
	//alert(vContainer_Cell_Element);
} 
function help_desc_changed(vSelect_Object_ID,vNill_Value,vMain_Desc_ID)
{
	var oDesc_Obj_ID=document.getElementById(vSelect_Object_ID);
	var oMain_desc_ID=oDesc_Obj_ID[oDesc_Obj_ID.selectedIndex].value;
	document.getElementById(vMain_Desc_ID).value="";
	if (vNill_Value==oMain_desc_ID)
		document.getElementById(vMain_Desc_ID).value="";
		else
			document.getElementById(vMain_Desc_ID).value=document.getElementById(oMain_desc_ID).value;
}

function General_Award_Calculator_Calculate(vNOrder,vNRowOrderGrant,vNRowOrderLoan,vNRowOrderWork)
{

	RunFunction=RunFunction+1
	if (RunFunction > 1)
	return;
		
	var iFirstGrantIndex=-1,iFirstLoanIndex=-1,iFirstWorkOppIndex=-1;
	var iFirstTotalGrantIndex=-1,iFirstTotalLoanIndex=-1,iFirstTotalworkOppIndex=-1;
	var iRowCounterGrant=1,iRowCounterLoan=1,iRowCounterWorkOpper=1;
	
	var sTotal_Grant,iTotalGrant=0,iGrant_Counter=0,iTotal_Grant_Total=0;
	var iTotal_Grant_Arral=new Array();
	sTotal_Grant="//Award_Letter_Calculator/TotalGrants/TotalGrant";
	var sGrant_ID;
	var sGrant_Combo_ID;
	var sTotal_Loan,iTotal_Loan=0,iLoan_Counter=0,iTotal_Loan_Total=0;
	var iTotal_Loan_Arral=new Array();;
	sTotal_Loan="//Award_Letter_Calculator/TotalLoans/TotalLoan";
	var sLoan_ID;
	var sLoan_Combo_ID;
	var sTotalWork,iTotalWork=0,iWork_Counter=0,iTotal_Work_Total=0;
	var itotal_Work_Arral=new Array();;
	sTotalWork="//Award_Letter_Calculator/TotalWorks/TotalWork";
	var sWork_ID;
	var sWork_Combo_ID;
	
	var iAttendence_Arral=new Array();;
	var iAttendence_Count=0;
	var sAttendance;
	var sAttendance_ID;	
	var iFinancial_Arral=new Array();;
	var iFinancial_Count=0;
	var sFinancial;
	var sTotalFinancial_ID;
	var iTotalContribution_Arral=new Array();;
	var iTotalContribution_Count=0;
	var sTotalContribution;
	var sTotalContribution_ID;
	sAttendance_ID="//Award_Letter_Calculator/Attendance_Costs/Attendance_Cost";
	sTotalFinancial_ID="//Award_Letter_Calculator/TotalFinancialAids/TotalFinancialAid";
	sTotalContribution_ID="//Award_Letter_Calculator/TotalContributions/TotalContribution";
	
	var igrantElem_Offset=5;
	var iLoanElem_Offset=5;
	var iWorkElem_Offset=5;
	for (i=0;i<document.getElementsByTagName("input").length;i++)
	{
		sGrant_ID="//Award_Letter_Calculator/Grant_Amounts"+iRowCounterGrant+"/Grant_Amount"+iRowCounterGrant;
		sGrant_Combo_ID="//Award_Letter_Calculator/Grant_Name_ID"+iRowCounterGrant;
		sLoan_ID="//Award_Letter_Calculator/Loan_Amounts"+iRowCounterLoan+"/Loan_Amount"+iRowCounterLoan;
		sLoan_Combo_ID="//Award_Letter_Calculator/Loan_Name_ID"+iRowCounterLoan;
		sWork_ID="//Award_Letter_Calculator/Work_Amounts"+iRowCounterWorkOpper+"/Work_Amount"+iRowCounterWorkOpper;
		sWork_Combo_ID="//Award_Letter_Calculator/Work_Name_ID"+iRowCounterWorkOpper;
		if (document.getElementsByTagName("input")[i].id==sGrant_ID)
		{
			var sGrant=replace(document.getElementsByTagName("input")[i].value.replace('$',''),',','');
			if (sGrant=="")
				sGrant="0";
			if (document.getElementById(sGrant_Combo_ID)[document.getElementById(sGrant_Combo_ID).selectedIndex].value==""&&(sGrant!="0.00"&&ltrim(rtrim(sGrant))!="0"))
				{
					document.forms[0].elements[sGrant_Combo_ID].focus();
					alert("Please select an item from the Grants and Scholarships drop down list for this line");
				}
			if (iFirstGrantIndex==-1)
			{
				iFirstGrantIndex=i;
				iGrant_Counter=iGrant_Counter+1;
			}	
			if (iTotal_Grant_Arral[iGrant_Counter]==null)
				iTotal_Grant_Arral[iGrant_Counter]=parseFloat(sGrant);
				else
					iTotal_Grant_Arral[iGrant_Counter]=parseFloat(iTotal_Grant_Arral[iGrant_Counter])+parseFloat(sGrant);		
			if (i==((parseInt(vNOrder)+parseInt(iFirstGrantIndex))-1))	
			{
				iRowCounterGrant=iRowCounterGrant+1;
				sGrant_ID="//Award_Letter_Calculator/Grant_Amounts"+iRowCounterGrant+"/Grant_Amount"+iRowCounterGrant;
				sGrant_Combo_ID="//Award_Letter_Calculator/Grant_Name_ID"+iRowCounterGrant;
				iFirstGrantIndex=-1;
				iGrant_Counter=0;
			}
			else if (i!=((parseInt(vNOrder)+parseInt(iFirstGrantIndex)+parseInt(igrantElem_Offset))-1))
			{
				iGrant_Counter=iGrant_Counter+1;
			}
			
			
		}
		
		else if (document.getElementsByTagName("input")[i].id==sLoan_ID)
		{
			var sLoan=replace(document.getElementsByTagName("input")[i].value.replace("$",""),",","");
			if (sLoan=="")
				sLoan="0";
			if (document.getElementById(sLoan_Combo_ID)[document.getElementById(sLoan_Combo_ID).selectedIndex].value==""&&(sLoan!="0.00"&&ltrim(rtrim(sLoan))!="0"))
				{
					document.getElementById(sLoan_Combo_ID).focus();
					alert("Please select an item from the Loans drop down list for this line");
				}	
			if (iFirstLoanIndex==-1)
			{
				iFirstLoanIndex=i;
				iLoan_Counter=iLoan_Counter+1;
			}	
			if (iTotal_Loan_Arral[iLoan_Counter]==null)
				iTotal_Loan_Arral[iLoan_Counter]=parseFloat(sLoan);
				else
					iTotal_Loan_Arral[iLoan_Counter]=parseFloat(iTotal_Loan_Arral[iLoan_Counter])+parseFloat(sLoan);
			//alert(iLoan_Counter+"]Loan "+iLoan_Counter+" "+iTotal_Loan_Arral[iLoan_Counter]);
			if (i==((parseInt(vNOrder)+parseInt(iFirstLoanIndex))-1))	
			{
				iRowCounterLoan=iRowCounterLoan+1;
				sLoan_ID="//Award_Letter_Calculator/Loan_Amounts"+iRowCounterLoan+"/Loan_Amount"+iRowCounterLoan;
				sLoan_Combo_ID="//Award_Letter_Calculator/Loan_Name_ID"+iRowCounterLoan;		
				iFirstLoanIndex=-1;
				iLoan_Counter=0;
			}
			else if (i!=((parseInt(vNOrder)+parseInt(iFirstLoanIndex)+parseInt(iLoanElem_Offset))-1))
			{
				iLoan_Counter=iLoan_Counter+1;
			}
			
			
		}
		
		else if (document.getElementsByTagName("input")[i].id==sWork_ID)
		{
			var sWork=replace(document.getElementsByTagName("input")[i].value.replace("$",""),",","");
			if (sWork=="")
				sWork="0";
			if (document.getElementById(sWork_Combo_ID)[document.getElementById(sWork_Combo_ID).selectedIndex].value==""&&(sWork!="0.00"&&ltrim(rtrim(sWork))!="0"))
				{
					document.getElementById(sWork_Combo_ID).focus();
					alert("Please select an item from the Work Opportunities drop down list for this line");	
				}		
			if (iFirstWorkOppIndex==-1)
			{
				iFirstWorkOppIndex=i;
				iWork_Counter=iWork_Counter+1;
			}	
			if (itotal_Work_Arral[iWork_Counter]==null)
				itotal_Work_Arral[iWork_Counter]=parseFloat(sWork);
				else
					itotal_Work_Arral[iWork_Counter]=parseFloat(itotal_Work_Arral[iWork_Counter])+parseFloat(sWork);
			//alert(iWork_Counter+"]Work Oppertunity "+iWork_Counter+" "+itotal_Work_Arral[iWork_Counter]);
			if (i==((parseInt(vNOrder)+parseInt(iFirstWorkOppIndex))-1))	
			{
				iRowCounterWorkOpper=iRowCounterWorkOpper+1;
				sWork_ID="//Award_Letter_Calculator/Work_Amounts"+iRowCounterWorkOpper+"/Work_Amount"+iRowCounterWorkOpper;
				sWork_Combo_ID="//Award_Letter_Calculator/Work_Name_ID"+iRowCounterWorkOpper;	
				iFirstWorkOppIndex=-1;
				iWork_Counter=0;
			}
			else if (i!=((parseInt(vNOrder)+parseInt(iFirstWorkOppIndex)+parseInt(iWorkElem_Offset))-1))
			{
				iWork_Counter=iWork_Counter+1;
			}
		}
		else if (document.getElementsByTagName("input")[i].id==sAttendance_ID)
		{
			var sAttendance=replace(document.getElementsByTagName("input")[i].value.replace("$",""),",","");
			if (sAttendance=="")
				sAttendance="0";
				
			iAttendence_Count=iAttendence_Count+1;
			iAttendence_Arral[iAttendence_Count]=parseFloat(sAttendance);
			//alert(iAttendence_Count+"]Attendence Coast "+iAttendence_Count+" "+iAttendence_Arral[iAttendence_Count]);
		}
		else if (document.getElementsByTagName("input")[i].id==sTotal_Grant+"Hidden")
		{
			iTotal_Grant_Total=iTotal_Grant_Total+1;
			document.getElementsByTagName("input")[i].value=formatCurrency(iTotal_Grant_Arral[iTotal_Grant_Total]);
			//alert(iTotal_Grant_Total+"]Total Grant "+iTotal_Grant_Total+" "+document.getElementsByTagName("input")[i].value);
		}
		else if (document.getElementsByTagName("input")[i].id==sTotal_Loan+"Hidden")
		{
			iTotal_Loan_Total=iTotal_Loan_Total+1;
			document.getElementsByTagName("input")[i].value=formatCurrency(iTotal_Loan_Arral[iTotal_Loan_Total]);
			//alert(iTotal_Loan_Total+"]Total Loan "+iTotal_Loan_Total+" "+document.getElementsByTagName("input")[i].value);
		}
		else if (document.getElementsByTagName("input")[i].id==sTotalWork+"Hidden")
		{
			iTotal_Work_Total=iTotal_Work_Total+1;
			document.getElementsByTagName("input")[i].value=formatCurrency(itotal_Work_Arral[iTotal_Work_Total]);
		}
		else if (document.getElementsByTagName("input")[i].id==sTotalFinancial_ID+"Hidden")
		{
			var sFinancial=replace(document.getElementsByTagName("input")[i].value.replace("$",""),",","");
			if (sFinancial=="")
				sFinancial="0";
				
			iFinancial_Count=iFinancial_Count+1;
			iFinancial_Arral[iFinancial_Count]=formatCurrency(parseFloat(iTotal_Grant_Arral[iFinancial_Count])+parseFloat(iTotal_Loan_Arral[iFinancial_Count])+parseFloat(itotal_Work_Arral[iFinancial_Count]));
			document.getElementsByTagName("input")[i].value=iFinancial_Arral[iFinancial_Count];			
		}
		else if (document.getElementsByTagName("input")[i].id==sTotalContribution_ID+"Hidden")
		{
			var sTotalContribution=replace(document.getElementsByTagName("input")[i].value.replace("$",""),",","");
			if (sTotalContribution=="")
				sTotalContribution="0";
				
			iTotalContribution_Count=iTotalContribution_Count+1;
			iTotalContribution_Arral[iTotalContribution_Count]=formatCurrency(parseFloat(iAttendence_Arral[iTotalContribution_Count])-(parseFloat(iTotal_Grant_Arral[iTotalContribution_Count])+parseFloat(iTotal_Loan_Arral[iTotalContribution_Count]))-parseFloat(itotal_Work_Arral[iTotalContribution_Count]));
			document.getElementsByTagName("input")[i].value=iTotalContribution_Arral[iTotalContribution_Count];
		}
	}
	var iTotalGrant_DivCounter=1,iTotalLoan_DivCounter=1,iTotalWorkOpp_DivCounter=1;
	var iTotalFinancial_DivCounter=1,iTotalContribution_DivCounter=1;
	for (j=0;j<document.getElementsByTagName("div").length;j++)
		{
			//alert(document.getElementsByTagName("div")[j].id);
			if (document.getElementsByTagName("div")[j].id==sTotal_Grant)
				{
					//alert(rtrim(ltrim(formatCurrency(parseFloat(iTotal_Grant_Arral[iTotalGrant_DivCounter])))));
					document.getElementsByTagName("div")[j].innerHTML=rtrim(ltrim(formatCurrency(parseFloat(iTotal_Grant_Arral[iTotalGrant_DivCounter]))));
					iTotalGrant_DivCounter++;
				}
			else if (document.getElementsByTagName("div")[j].id==sTotal_Loan)
				{
					document.getElementsByTagName("div")[j].innerHTML=rtrim(ltrim(formatCurrency(parseFloat(iTotal_Loan_Arral[iTotalLoan_DivCounter]))));	
					iTotalLoan_DivCounter++;
				}
		else if (document.getElementsByTagName("div")[j].id==sTotalWork)
				{
					document.getElementsByTagName("div")[j].innerHTML=rtrim(ltrim(formatCurrency(parseFloat(itotal_Work_Arral[iTotalWorkOpp_DivCounter]))));		
					iTotalWorkOpp_DivCounter++;
				}
			else if (document.getElementsByTagName("div")[j].id==sTotalFinancial_ID)
				{
					document.getElementsByTagName("div")[j].innerHTML=formatCurrency(iFinancial_Arral[iTotalFinancial_DivCounter]);
					iTotalFinancial_DivCounter++;
				}
			else if (document.getElementsByTagName("div")[j].id==sTotalContribution_ID)
				{
					document.getElementsByTagName("div")[j].innerHTML=formatCurrency(iTotalContribution_Arral[iTotalContribution_DivCounter]);	
					iTotalContribution_DivCounter++;
				}
		}	
		
	RunFunction=0;		
	
}

function replace(str,find,repl)
{
	while(1 == 1) 
	{
		if(str.indexOf(find)==-1) 
			return str;
		str =str.replace(find,repl);
	}
}
/*[basel]this fuinction is the same as the one in the _ValidateScripts.js 
	for formatting the currency......it is used to transform the integer value
	of fileds back to currency
*/
function formatCurrency(num) 
{
	if (num == null || num.length == 0)
	{
		return num;
	}
	num = num.toString().replace(/\$|\,/g,'');

	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	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));
	return rtrim(ltrim((((sign)?'':'-') + '$' + num + '.' + cents)));
}

	// url: name of the url
	// winName: name of the popup window
	// w: width of the popup window
	// h: height of the popup window
	// s: scrollbars of the popup window
	function popupWin(url,winName,w,h,s) {
		var l, t;
		if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4) {
			l = (window.outerWidth / 2) - (w / 2);
			t = (window.outerHeight / 2) - (h / 2);
		}
		else {
			l = (window.screen.availWidth / 2) - (w / 2);
			t = (window.screen.availHeight / 2) - (h / 2);
		}
		var framewin = window.open(url,winName,"width="+w+",height="+h+",toolbar=no,menubar=no,scrollbars="+s+",resizable=no,top="+t+",left="+l);
		if (framewin.focus) framewin.focus();
	}
	
	//next function same as above, but with toolbar & menubar added, & resizable
	//used for new windows displaying external sites
	function popupWinTools(url,winName,w,h,s) {
		var l, t;
		if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4) {
			l = (window.outerWidth / 2) - (w / 2);
			t = (window.outerHeight / 2) - (h / 2);
		}
		else {
			l = (window.screen.availWidth / 2) - (w / 2);
			t = (window.screen.availHeight / 2) - (h / 2);
		}
		var framewin = window.open(url,winName,"width="+w+",height="+h+",toolbar=yes,menubar=yes,scrollbars="+s+",resizable=yes,top="+t+",left="+l);
		if (framewin.focus) framewin.focus();
	}
	function CheckCertificationDisbDatesExist(PreID,Order,DateFrom,DateTo)
	{
		var bResult = true;
		var iVisibleCurrentFields = 0;
		
		//See where we should start the validation.	
		for (iCounter=11;iCounter>=1;iCounter--)
		{								
			CurrentName=PreID+(parseInt(iCounter+1));
			
			if (document.getElementById(CurrentName)!= null &&
			document.getElementById(CurrentName).value != '')
			{
				iVisibleCurrentFields = iCounter;
				break;
			}
		}
		
		//Checking Period From and To:
		objDateFrom=document.getElementById(DateFrom)
		objDateTo=document.getElementById(DateTo)
		if (objDateFrom.value.length > 0 && objDateTo.value.length > 0)
		{
			if (Date.parse(objDateFrom.value) >= Date.parse(objDateTo.value))
			{
				alert('Loan Period To should be greater than Loan Period From.')
				objDateFrom.focus();
				return false;
			}
		}		
		
		
		//No disbursements dates are enetered yet.
		if (iVisibleCurrentFields == 0)
			return true;
		ViewMsg=1;
		ViewMsg2 = 1;				
		bResult = CheckDisbDatesExist(PreID,Order,iVisibleCurrentFields)
		if (bResult != false)
			return true;
		else
			return false;
	}	

	
	function CheckDisbDatesExist(PreID,Order,iFldsCount)
	{
	var sPreDate="",LastName="",DestName="",Result=0;
	//Removing Gaps
		xx=0
		iCounter=1
		while (iCounter >=1 && iCounter <=iFldsCount)		
		{
			LastName=PreID+iCounter;
			sPreDate=document.getElementById(LastName).value;
			sPreDate=sPreDate.replace(" ","")
			zz=PreID+(iCounter+1)
			sNDate=document.getElementById(zz).value;
			sNDate=sNDate.replace(" ","")
			if (sPreDate.length==0)
			{		
				if (xx == 0)
				{					
					xx=iCounter;	
					DestName=PreID+xx;			
				}
				if 	(sNDate.length > 0)	
				{	
					document.getElementById(DestName).value=sNDate	
					document.getElementById(zz).value=""
					iCounter=xx+1
					xx=0																
				}	
				else
				iCounter+=1;							
			}
			else
			iCounter+=1;	
		}	
		
//Checking Ascending Order Dates.			
			
			
	for (iCounter=iFldsCount;iCounter>=1;iCounter--)
	{
		CurrentName=PreID+(parseInt(iCounter)+1);
		LastName=PreID+(parseInt(iCounter));						
		sPreDate=document.getElementById(LastName).value;
		sDate=document.getElementById(CurrentName).value;						
						
		if (sDate.length > 0 && sPreDate.length > 0)
		{
				if (Date.parse(sDate)<Date.parse(sPreDate))
				{
					alert("Disbursement dates have to be entered in ascending way.");										
					document.getElementById(CurrentName).focus();																																													
					return false;	
				}								
		}	
					
	}		
									
				
					
	}
	///////////////////////////////


function SaveAcademicYear(PreID,v2,v3,v4,DateFrom,DateTo)
{		
	var objDateFrom,objDateTo
	var sPreDate="",LastName="",DestName="",Result=0,sNDate="";
	//Removing Gaps
		xx=0
		iCounter=1
		while (iCounter >=1 && iCounter <=11)		
		{
			LastName=PreID+iCounter;
			sPreDate=document.getElementById(LastName).value;
			sPreDate=sPreDate.replace(" ","")
			zz=PreID+(iCounter+1)
			sNDate=document.getElementById(zz).value
			sNDate=sNDate.replace(" ","")
			if (sPreDate.length==0)
			{		
				if (xx == 0)
				{					
					xx=iCounter;	
					DestName=PreID+xx;			
				}
				if 	(sNDate.length > 0)	
				{						
					document.getElementById(DestName).value=sNDate.toString()						
					document.getElementById(zz).value=""
					iCounter=xx+1
					xx=0																
				}	
				else
				iCounter+=1;							
			}
			else
			iCounter+=1;	
		}		
		
		
	//Checking Period From and To:
	objDateFrom=document.getElementById(DateFrom)
	objDateTo=document.getElementById(DateTo)
	if (objDateFrom.value.length > 0 && objDateTo.value.length > 0)
	{
		if (Date.parse(objDateFrom.value) >= Date.parse(objDateTo.value))
		{
			alert('Loan Period To should be greater than Loan Period From.')
			objDateFrom.focus();
			return false;
		}
	}
		
			
//Checking Ascending Order Dates.			
	for (iCounter=11;iCounter>=1;iCounter--)
	{
		CurrentName=PreID+(parseInt(iCounter)+1);
		LastName=PreID+(parseInt(iCounter));						
		sPreDate=document.getElementById(LastName).value;
		sDate=document.getElementById(CurrentName).value;						
						
		if (sDate.length > 0 && sPreDate.length > 0)
		{
				if (Date.parse(sDate)<Date.parse(sPreDate))
				{
					alert("Disbursement dates have to be entered in ascending way.");										
					document.getElementById(CurrentName).focus();																																													
					return false;	
				}								
		}	
					
	}

	//////////////////////

	
	menuAction('School_AddAcademicProfile',v2,v3,v4)

}

function popupLoanwizardWindow(){
	var WIDTH = 500;								// set width of window
	var HEIGHT = 380;								// set height of window
	var LEFT_POS = screen.width/2 - WIDTH/2;		// Center the window
	var TOP_POS = screen.height/2 - HEIGHT/2;		// Center the window

	var Toolbars = "directories=no, location=no, menubar=no, status=no, status=no, titlebar=no, toolbar=no";
	var Options = "scrollbars=yes, width=" + WIDTH + ", height=" + HEIGHT + ", resizable=yes, left=" + LEFT_POS + ",top=" + TOP_POS;
	var Features =  Toolbars + ", " + Options;
	var newWin = window.open('', 'Report', Features);
	newWin.document.open();
	newWin.document.write("<html>");
	newWin.document.write("<title>Loan Types</title>");
	newWin.document.write('<LINK href="Styles/default.css" type="text/css" rel="stylesheet">');
	newWin.document.write("<body>");
	newWin.document.write("<br/>");
	newWin.document.write('<table cellspacing="0" cellpadding="2"><tr><td width="10"></td><td width="50" class="normalQtext" valign="top">SS</td><td class="fieldstext">Subsidized Federal Stafford Loans, formerly Guaranteed Student Loans (GSL)</td></tr><tr><td width="10"></td><td width="50" class="normalQtext" valign="top">DSS</td><td class="fieldstext">Direct Subsidized Stafford/Ford Loans</td></tr><tr><td width="10"></td><td width="50" class="normalQtext" valign="top">US</td><td class="fieldstext">Unsubsidized & Nonsubsidized Federal Stafford Loans</td></tr><tr><td width="10"></td><td width="50" class="normalQtext" valign="top">DUS</td><td class="fieldstext">Direct Unsubsidized Stafford/Ford Loans</td></tr><tr><td width="10"></td><td width="50" class="normalQtext" valign="top">SLS</td><td class="fieldstext">Federal Supplemental Loans for Students (formerly Auxiliary Loans to Assist Students (ALAS) and Student PLUS Loans)</td></tr><tr><td></td><td class="normalQtext" valign="top">PERK</td><td class="fieldstext">Federal Perkins Loans, formerly National Defense/National Direct Student Loans (NDSL)</td></tr><tr><td></td><td class="normalQtext" valign="top">HPSL</td><td class="fieldstext">Health Professions Student Loans, including Loans for Disadvantaged Students</td></tr><tr><td></td><td class="normalQtext" valign="top">FISL</td><td class="fieldstext">Federal Insured Student Loans</td></tr><tr><td></td><td class="normalQtext" valign="top">PLUS</td><td class="fieldstext">Federal PLUS (Parent) Loans</td></tr><tr><td></td><td class="normalQtext" valign="top">DPLUS</td><td class="fieldstext">Direct PLUS Loans</td></tr><tr><td></td><td class="normalQtext" valign="top">SCON</td><td class="fieldstext">Subsidized Federal Consolidation Loans</td></tr><tr><td></td><td class="normalQtext" valign="top">DSCON</td><td class="fieldstext">Direct Subsidized Consolidation Loans</td></tr><tr><td></td><td class="normalQtext" valign="top">UCON</td><td class="fieldstext">Unsubsidized Federal Consolidation Loans</td></tr><tr><td></td><td class="normalQtext" valign="top">DUCON</td><td class="fieldstext">Direct Unsubsidized Consolidation Loans, including Direct PLUS Consolidation Loans</td></tr><tr><td></td><td class="normalQtext" valign="top">NSL</td><td class="fieldstext">Federal Nursing Loans</td></tr><tr><td></td><td class="normaltext" valign="top">OTHER</td><td class="fieldstext">Other education loans not eligible for consolidation that you want used to calculate the maximum repayment period</td></tr></table>');
	newWin.document.write("</body>");
	newWin.document.write("</html>");
	newWin.document.close()
	//newWin.focus();
}

function MessagetoUser(message){
	var WIDTH = 340;								// set width of window
	var HEIGHT = 100;								// set height of window
	var LEFT_POS = screen.width/2 - WIDTH/2;		// Center the window
	var TOP_POS = screen.height/2 - HEIGHT/2;		// Center the window

	var Toolbars = "directories=no, location=no, menubar=no, status=no, titlebar=no, toolbar=no";
	var Options = "scrollbars=yes, width=" + WIDTH + ", height=" + HEIGHT + ", resizable=no, left=" + LEFT_POS + ",top=" + TOP_POS;
	var Features =  Toolbars + ", " + Options;
	var newWin = window.open('', 'Report', Features);
	newWin.document.open();
	newWin.document.write("<html>");
	newWin.document.write("<title>Help Message</title>");
	newWin.document.write('<LINK href="Styles/default.css" type="text/css" rel="stylesheet">');
	newWin.document.write("<body bgcolor='#FFFFE1'>");
	//newWin.document.write("<br/>");
	newWin.document.write('<center><table cellspacing="0" cellpadding="0" width="95%" height="80" style="border:1px solid black; font:normal arial; background-color: #FFFFE1; margin-top:5;"><tr><td width="5"></td><td valign="top"><font size="2" face="arial" color="#003366">'+message+'</font></td></tr></table></center>');
	newWin.document.write("</body>");
	newWin.document.write("</html>");
	newWin.document.close()
	//newWin.focus();
}

function ChangeImageMouseOver(imgid,imgdown)
{
	window.document.getElementById(imgid).src ="../public/images/"+imgdown;

}

function ChangeImageMouseOut(imgid,imgup)
{
	window.document.getElementById(imgid).src ="../public/images/"+imgup;

}
//-------------------------------------------
//[Basel]:For Backoffice Preview Pages (Disabling all links)
//------------------------------------------
function disableLink (link)
{
	if ((link.tagName=="a"||link.tagName=="A")&&link.onclick && link.name!="PreviewClosePage")
		{
			link.oldOnClick = link.onclick;
			link.onclick = cancelLink;
			if (link.href)
				link.href="#";
			if (link.target)
				link.target="";
		}
	else if ((link.tagName=="a"||link.tagName=="A")&&link.name!="PreviewClosePage")
		{
			link.oldOnClick = link.onclick;
			link.onclick = cancelLink;
			if (link.href)
				link.href="#";
			if (link.target)
				link.target="";
		}		
}
function cancelLink ()
{
	return false;
}
function DisableLinks()
{
	for (i=0;i<parseInt(window.document.all.length);i++)
		{
		disableLink(window.document.all.item(i));}
}		
function changeRadio(val)
{
		for (i = 0; i < window.document.forms[0].elements.length; i++)
		{
			var stname = new String(window.document.forms[0].elements[i].name);
			if (stname == '//StartLoanQWizard/Product_Name')
			{		
			   alert(window.document.forms[0].elements[i].value);	
			}
		}
//alert(document.getElementsByTagName("//StartLoanQWizard/Product_Name").value);

}
//-----------------------------------------------	

/*function replace(str,find,repl) 
{
	while(1 == 1) 
	{
		if(str.indexOf(find)==-1) 
			return str;
		str = str.replace(find,repl);
	}
}*/
		
	/// this function is used to force mutual selection for 2 check boxes
	function mutualSelectionForCheckBox(source , other)
	{
		var src = document.getElementById(source)
		var dest = document.getElementById(other)
		if(src.checked == "true" || src.checked == true)
		{
			dest.checked = false;
		}
		/*	
			Up-on client request they wants the user be able to continue with the next step even if he did not 
		select 'Yes' option from the 2 options [Bo and Pub].
			
		if (document.getElementById('//MultiYearAuthorization/Yes')!= null &&
			document.getElementById('//MultiYearAuthorization/Yes').checked == true)
		{ 
			 document.getElementById("Continue").style.visibility ="visible";
			document.getElementById("Continue").style.display ="inline";
			
			document.getElementById("Continue_D").style.visibility ="hidden";
			document.getElementById("Continue_D").style.display ="none";
		}
		else 
		{  
			document.getElementById("Continue_D").style.visibility ="visible";
			document.getElementById("Continue_D").style.display ="inline";
			
			document.getElementById("Continue").style.visibility ="hidden";
			document.getElementById("Continue").style.display ="none";
		}
		 */
			
	}
	// This function move data from Permanant Address to Mailing Address
	function MoveDataBetweenAddresses()
	{
		//Copy Address
		if( document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_Address1') != null && 
				document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_Address2') != null  &&
			(document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_Address1').value == "" ||
			 (	document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_Address1').value ==
					document.getElementById( 'Page1/Cons_Borrower/Borrower_Perm_Address2').value &&	
				document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_Address2').value != "")
				))
		{
		
			document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_Address1').value = 
					document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_Address2').value;
		}
		
		//Copy City
		if( document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_City') != null && 
				document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_City') != null  &&
			(document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_City').value == "" ||
				(document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_City').value ==
					document.getElementById( 'Page1/Cons_Borrower/Cons_Borrower_Perm_City').value &&
					document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_City').value != ""
					))
			)
		{
		
			document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_City').value = 
					document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_City').value;
		}
		//Copy State
		if( document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_State') != null && 
				document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_State') != null  &&
			( document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_State').value == ""	 ||
				(document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_State').value ==
					document.getElementById( 'Page1/Cons_Borrower/Cons_Borrower_Perm_State').value &&
					document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_State').value != ""))
			)
		{
		
			document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_State').value = 
					document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_State').value;
		}
		//Copy Zip
		if( document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_ZipCode') != null && 
				document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_ZipCode') != null  &&
			(document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_ZipCode').value == "" ||
				(document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_ZipCode').value ==
					document.getElementById( 'Page1/Cons_Borrower/Cons_Borrower_Perm_ZipCode').value &&
					document.getElementById( 'Page1/Cons_Borrower/Cons_Borrower_Perm_ZipCode').value != ""))
			)
		{
			if (document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_ZipCode').value.length >= 5)
				document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_ZipCode').value = 
		 				document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_ZipCode').value;
		}
		
		// Update hidden values
		if (document.getElementById( 'Page1/Cons_Borrower/Borrower_Perm_Address2' ) != null &&
				document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_Address2') != null)
			document.getElementById( 'Page1/Cons_Borrower/Borrower_Perm_Address2').value = 
				document.getElementById( '//Page1/Cons_Borrower/Borrower_Perm_Address2').value;
		
		if (document.getElementById( 'Page1/Cons_Borrower/Cons_Borrower_Perm_City') != null &&
			document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_City') != null )		
			document.getElementById( 'Page1/Cons_Borrower/Cons_Borrower_Perm_City').value =
				document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_City').value;
		
		if (document.getElementById( 'Page1/Cons_Borrower/Cons_Borrower_Perm_State') != null &&
				document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_State') != null)
			document.getElementById( 'Page1/Cons_Borrower/Cons_Borrower_Perm_State').value =
				document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_State').value ;
		
		if (document.getElementById( 'Page1/Cons_Borrower/Cons_Borrower_Perm_ZipCode') != null &&
			document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_ZipCode')!= null)			
			document.getElementById( 'Page1/Cons_Borrower/Cons_Borrower_Perm_ZipCode').value =
				document.getElementById( '//Page1/Cons_Borrower/Cons_Borrower_Perm_ZipCode').value;
	}
	
	// this function control the enable status of compute button in indebtness page
	function EnableDisableComputeButton()
	{	
		
		var YesRadiosCount=0
		for(i=1;i<document.forms[0].elements.length;i++)
		{
			if(document.forms[0].elements[i].type=='radio')
			{
				if(document.forms[0].elements[i].id=='YES' && document.forms[0].elements[i].checked==true)
					YesRadiosCount++;
			}
		}
		if(YesRadiosCount>0)
		{
			document.getElementById("Compute").style.visibility ="visible";
			document.getElementById("Compute").style.display ="inline";
			document.getElementById("Compute_d").style.visibility ="hidden";
			document.getElementById("Compute_d").style.display ="none";	
		}
		else
		{
			document.getElementById("Compute").style.visibility ="hidden";
			document.getElementById("Compute").style.display ="none";
			document.getElementById("Compute_d").style.visibility ="visible";
			document.getElementById("Compute_d").style.display ="inline";
			
			// hide the computation text
			document.getElementById("Computetext").style.visibility ="hidden";
			document.getElementById("Computetext").style.display ="none";
		}
		
		return true;
	}
	
	
	function HandleNoPhoneNoDL(NoChk,FieldCaption) 
	{
		//get Last index of '/' 
	    var LastIndexOfSlash = NoChk.name.lastIndexOf("/");
	    //get the pageName and Block Name for checkBox
		var strNamePrefix = NoChk.name.substring(0,LastIndexOfSlash);
				 
		if(FieldCaption.indexOf('driver')>=0 || FieldCaption.indexOf('No DL')>=0)
		{
			if (document.getElementById(strNamePrefix + "/Borrower_Driver_License_State") != null)
			{
				document.getElementById(strNamePrefix + "/Borrower_Driver_License_State").disabled = NoChk.checked; 
				document.getElementById(strNamePrefix + "/Borrower_Driver_License_Num").disabled = NoChk.checked; 
				
				//clear Values
				if(NoChk.checked)
				{
					document.getElementById(strNamePrefix + "/Borrower_Driver_License_State").value="";
					document.getElementById(strNamePrefix + "/Borrower_Driver_License_Num").value="";
					
				}
			}
			
			if (document.getElementById(strNamePrefix + "/Endorser_Driver_License_State") != null)
			{
				document.getElementById(strNamePrefix + "/Endorser_Driver_License_State").disabled = NoChk.checked; 
				document.getElementById(strNamePrefix + "/Endorser_Driver_License_Num").disabled = NoChk.checked; 
								
				//clear Values
				if(NoChk.checked)
				{
					document.getElementById(strNamePrefix + "/Endorser_Driver_License_State").value="";
					document.getElementById(strNamePrefix + "/Endorser_Driver_License_Num").value="";
				}
			}
		}
		if(FieldCaption.indexOf('Phone')>=0)
		{
			// Disable only the visible controls [there is no need to disable the hidden field-- it will help in updating]
			if (strNamePrefix.indexOf("MPN_Stafford_Borrower") >= 0 ||
				strNamePrefix.indexOf("MPN_PLUS_Borrower") >= 0 ||
				strNamePrefix.indexOf("Cons_Borrower") >= 0 ||
				strNamePrefix.indexOf("BorrowerInformation") >= 0 )
			{
				document.getElementById(strNamePrefix + "/Borrower_Home_Phone1_P00NST3").disabled = NoChk.checked; 
				document.getElementById(strNamePrefix + "/Borrower_Home_Phone2_P00NST3").disabled = NoChk.checked; 
				document.getElementById(strNamePrefix + "/Borrower_Home_Phone3_P00NST3").disabled = NoChk.checked;
				// Clear Values 
				if(NoChk.checked)
				{
					document.getElementById(strNamePrefix + "/Borrower_Home_Phone1_P00NST3").value="";
					document.getElementById(strNamePrefix + "/Borrower_Home_Phone2_P00NST3").value="";
					document.getElementById(strNamePrefix + "/Borrower_Home_Phone3_P00NST3").value="";
					document.getElementById(strNamePrefix + "/Borrower_Home_Phone").value="";
				}
			}
			else if (strNamePrefix.indexOf("MPN_Stafford_Reference1") >= 0 ||
					 strNamePrefix.indexOf("MPN_PLUS_Reference1") >= 0  ) 
			{
				document.getElementById(strNamePrefix + "/Reference1_Phone1_P00NST3").disabled = NoChk.checked; 
				document.getElementById(strNamePrefix + "/Reference1_Phone2_P00NST3").disabled = NoChk.checked; 
				document.getElementById(strNamePrefix + "/Reference1_Phone3_P00NST3").disabled = NoChk.checked;
				// Clear Values 
				if(NoChk.checked)
				{
					document.getElementById(strNamePrefix + "/Reference1_Phone1_P00NST3").value="";
					document.getElementById(strNamePrefix + "/Reference1_Phone2_P00NST3").value="";
					document.getElementById(strNamePrefix + "/Reference1_Phone3_P00NST3").value="";
					document.getElementById(strNamePrefix + "/Reference1_Phone").value="";
				}
			}
			else if (strNamePrefix.indexOf("MPN_Stafford_Reference2") >= 0||
					 strNamePrefix.indexOf("MPN_PLUS_Reference2") >= 0 )
			{
				document.getElementById(strNamePrefix + "/Reference2_Phone1_P00NST3").disabled = NoChk.checked; 
				document.getElementById(strNamePrefix + "/Reference2_Phone2_P00NST3").disabled = NoChk.checked; 
				document.getElementById(strNamePrefix + "/Reference2_Phone3_P00NST3").disabled = NoChk.checked;
				// Clear Values 
				if(NoChk.checked)
				{
					document.getElementById(strNamePrefix + "/Reference2_Phone1_P00NST3").value="";
					document.getElementById(strNamePrefix + "/Reference2_Phone2_P00NST3").value="";
					document.getElementById(strNamePrefix + "/Reference2_Phone3_P00NST3").value="";
					document.getElementById(strNamePrefix + "/Reference2_Phone").value="";
				}
			}
			else  if (strNamePrefix.indexOf("MPN_PLUS_Employer") >= 0)
			{ 
				document.getElementById(strNamePrefix + "/Employer_Phone1_P00NST3").disabled = NoChk.checked; 
				document.getElementById(strNamePrefix + "/Employer_Phone2_P00NST3").disabled = NoChk.checked; 
				document.getElementById(strNamePrefix + "/Employer_Phone3_P00NST3").disabled = NoChk.checked;
				// Clear Values 
				if(NoChk.checked)
				{
					document.getElementById(strNamePrefix + "/Employer_Phone1_P00NST3").value="";
					document.getElementById(strNamePrefix + "/Employer_Phone2_P00NST3").value="";
					document.getElementById(strNamePrefix + "/Employer_Phone3_P00NST3").value="";
					document.getElementById(strNamePrefix + "/Employer_Phone").value="";
				}
			}
			
		}
	}
	function CheckAllIndebtednessConsolidateFilled()
	{
		var YesRadiosCount=0
		var NoRadiosCount=0
		var RadiosCount=0
		var firstControl
		for(i=1;i<document.forms[0].elements.length;i++)
		{
			if(document.forms[0].elements[i].type=='radio')
			{
				RadiosCount++;
				if(document.forms[0].elements[i].id=='YES' && document.forms[0].elements[i].checked==true)				
					YesRadiosCount++;
				else if(document.forms[0].elements[i].checked==true)
					NoRadiosCount++;
				 
			}
		}
		if((RadiosCount/2)>NoRadiosCount+YesRadiosCount)
		{
			alert('Please select "Yes" or "No" for whether you would like each loan to be consolidated.');
			return false;
		}
		return true;
		
	}
	function Indebtedness_AddToInlineList(p1,p2,p3,p4)
	{
		if(!CheckAllIndebtednessConsolidateFilled())
			return false;
		menuAction('AddToInlineList',p1,p2,p3,p4)
	}
	
	function GeneralLoad()
	{	
		
/*		2006-10-05 we removed this fragment of code because in case the the triton link do not use
		http then the form will be submitted again but without any data :(

		//Switch SSL for UCSD
		var parameterStartingIndex = vURL.lastIndexOf("=");
		var parameterValue = vURL.substring((parameterStartingIndex+1),1000); 
		if (parameterValue == 'LoanWizard_StartLoanApplicationForUCSD')
		{
			if (vProtocol != 'https')
			{
				SwitchSSL('ON');
				document.getElementById('FocusField').value='CompleteMPN_btn'
				menuAction ('LoanWizard_StartLoanApplicationForUCSD','','','','','','','','');
			}
			// return;
		}
*/
		
		try{
			if(document.getElementById('DivScroll')!=null)
			{
				showgridscroll();	
			}
			if(document.getElementById('//Page1/MPN_Stafford_Borrower/No_License')!=null)
			{
				HandleNoPhoneNoDL(document.getElementById('//Page1/MPN_Stafford_Borrower/No_License'),'No DL');
				HandleNoPhoneNoDL(document.getElementById('//Page1/MPN_Stafford_Borrower/Flag_CheckBoxType'),'No Phone');
				HandleNoPhoneNoDL(document.getElementById('//Page1/MPN_Stafford_Reference1/Flag_CheckBoxType'),'No Phone');
				HandleNoPhoneNoDL(document.getElementById('//Page1/MPN_Stafford_Reference2/Flag_CheckBoxType'),'No Phone');
			}
			if(document.getElementById('//Page1/MPN_PLUS_Borrower/No_License')!=null)
			{
				HandleNoPhoneNoDL(document.getElementById('//Page1/MPN_PLUS_Borrower/No_License'),'No DL');
				HandleNoPhoneNoDL(document.getElementById('//Page1/MPN_PLUS_Borrower/Flag_CheckBoxType'),'No Phone');
				HandleNoPhoneNoDL(document.getElementById('//Page1/MPN_PLUS_Borrower/Flag_CheckBoxType'),'No Phone');
				HandleNoPhoneNoDL(document.getElementById('//Page1/MPN_PLUS_Borrower/Flag_CheckBoxType'),'No Phone');
			}
			if(document.getElementById('//Page1/Cons_Borrower/No_License')!=null) 
			{
				HandleNoPhoneNoDL(document.getElementById('//Page1/Cons_Borrower/No_License'),'I do not have a driver');
			}
			var i;
			//get Last index of '/' 
			var LastIndexOfSlash ;
			//get the pageName and Block Name for checkBox
			var strNamePrefix;
			for(i=1 ; i< document.forms[0].elements.length ;i++)
			{
				LastIndexOfSlash =document.forms[0].elements[i].name.lastIndexOf("/");
				strNamePrefix = document.forms[0].elements[i].name.substring(0,LastIndexOfSlash);
				
				if ( document.forms[0].elements	[i].name == (strNamePrefix + '/No_License') )
				{	
					HandleNoPhoneNoDL(document.forms[0].elements[i],'I do not have a driver');
				}				
			}
			
			if(document.getElementById('LoanWizardLoanType')!=null)
			{
				
				if(document.getElementById('LoanWizardLoanType').value=='GRAD_PLUS')
				{
					for (i = 0; i < window.document.forms[0].elements.length; i++)
					{
						if(	window.document.forms[0].elements[i].name.indexOf('/MPN_PLUS_STUDENTINFO')>-1 ||
							window.document.forms[0].elements[i].name.indexOf('/StudentInformation')>-1 ||
							window.document.forms[0].elements[i].name.indexOf('/EndorserStudentInformation')>-1
						
						)
						{
							window.document.forms[0].elements[i].style.border=0;						
							window.document.forms[0].elements[i].readOnly=true;								
						}
					}					 
				}
				//alert(document.getElementById('LoanWizardLoanType').value);
			}
			
			if ( (document.getElementById('Employer_Status1')!= null &&
				document.getElementById('Employer_Status1').checked == true) ||
				(document.getElementById('Employer_Status2')!= null &&
				document.getElementById('Employer_Status2').checked == true))
			{
				if (document.getElementById('Employer_Status1').checked)
					CheckEmployerStatus(document.getElementById('Employer_Status1'));
				else if (document.getElementById('Employer_Status2').checked)
					CheckEmployerStatus(document.getElementById('Employer_Status2'));
			}
			
		}
		catch(e)
		{
			//alert(e.message);
		}	
		
		if( document.forms[0].elements['IAgreedBtnClicked'] != null &&
				document.forms[0].elements['IAgreedBtnClicked'].value == "1")
		{
				HideOnClick('Agreebtn','Agreebtn_D');
		}
		
	}	
	
	function CopyMPNBorrowerDataToStudentInfo(fieldName)
	{
		if(fieldName=='//Page1/MPN_PLUS_Borrower/Current_Last_Name')
		{
			if(document.forms[0].elements['//Page1/MPN_PLUS_STUDENTINFO/Student_Last_Name']!=null)
				document.forms[0].elements['//Page1/MPN_PLUS_STUDENTINFO/Student_Last_Name'].value=
					document.forms[0].elements['//Page1/MPN_PLUS_Borrower/Current_Last_Name'].value;
			
		}
		if(fieldName=='//Page1/MPN_PLUS_Borrower/Borrower_First_Name')
		{
			if(document.forms[0].elements['//Page1/MPN_PLUS_STUDENTINFO/Student_First_Name']!=null)
				document.forms[0].elements['//Page1/MPN_PLUS_STUDENTINFO/Student_First_Name'].value=
					document.forms[0].elements['//Page1/MPN_PLUS_Borrower/Borrower_First_Name'].value;
			
		}
		if(fieldName=='//Page1/MPN_PLUS_Borrower/Borrower_Middle_Initial')
		{
			if(document.forms[0].elements['//Page1/MPN_PLUS_STUDENTINFO/Student_Middle_Initial']!=null)
				document.forms[0].elements['//Page1/MPN_PLUS_STUDENTINFO/Student_Middle_Initial'].value=
					document.forms[0].elements['//Page1/MPN_PLUS_Borrower/Borrower_Middle_Initial'].value;
			
		}
		if(fieldName=='//Page1/MPN_PLUS_Borrower/Borrower_DOB')
		{
			if(document.forms[0].elements['//Page1/MPN_PLUS_STUDENTINFO/Student_DOB']!=null)
				document.forms[0].elements['//Page1/MPN_PLUS_STUDENTINFO/Student_DOB'].value=
					document.forms[0].elements['//Page1/MPN_PLUS_Borrower/Borrower_DOB'].value;
			
		}
		
		
		
		
	}
	function CopySPBorrowerDataToStudentInfo(fieldName,postfix)
	{
	
		var pageNum=fieldName.substring(fieldName.indexOf('Page')+'Page'.length,fieldName.indexOf('Page')+'Page'.length+1)
		
		if(fieldName=='//Page' + pageNum + '/BorrowerInformation/Borrower_First_Name')
		{
			if(document.forms[0].elements['//Page' + pageNum + '/StudentInformation/Student_First_Name']!=null)
				document.forms[0].elements['//Page' + pageNum + '/StudentInformation/Student_First_Name'].value=
					document.forms[0].elements['//Page' + pageNum + '/BorrowerInformation/Borrower_First_Name'].value;
			
		}
		if(fieldName=='//Page' + pageNum + '/BorrowerInformation/Current_Last_Name')
		{
			if(document.forms[0].elements['//Page' + pageNum + '/StudentInformation/Student_Last_Name']!=null)
				document.forms[0].elements['//Page' + pageNum + '/StudentInformation/Student_Last_Name'].value=
					document.forms[0].elements['//Page' + pageNum + '/BorrowerInformation/Current_Last_Name'].value;
			
		}
		if(fieldName=='//Page' + pageNum + '/BorrowerInformation/Borrower_Middle_Initial')
		{
			if(document.forms[0].elements['//Page' + pageNum + '/StudentInformation/Student_Middle_Initial']!=null)
				document.forms[0].elements['//Page' + pageNum + '/StudentInformation/Student_Middle_Initial'].value=
					document.forms[0].elements['//Page' + pageNum + '/BorrowerInformation/Borrower_Middle_Initial'].value;
			
		}
		
		if(fieldName=='//Page' + pageNum + '/BorrowerInformation/Current_DOB_Display')
		{								   
			if(document.forms[0].elements['//Page' + pageNum + '/StudentInformation/Student_DOB']!=null)
				document.forms[0].elements['//Page' + pageNum + '/StudentInformation/Student_DOB'].value=
					document.forms[0].elements['//Page' + pageNum + '/BorrowerInformation/Current_DOB_Display'].value;
			
		}
		
		//Start:For Endorsement GB
		if(fieldName=='//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_First_Name')
		{
			if(document.forms[0].elements['//Page' + pageNum + '/EndorserStudentInformation/Student_First_Name']!=null)
				document.forms[0].elements['//Page' + pageNum + '/EndorserStudentInformation/Student_First_Name'].value=
					document.forms[0].elements['//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_First_Name'].value;
			
		}
		
		if(fieldName=='//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_Last_Name')
		{
			if(document.forms[0].elements['//Page' + pageNum + '/EndorserStudentInformation/Student_Last_Name']!=null)
				document.forms[0].elements['//Page' + pageNum + '/EndorserStudentInformation/Student_Last_Name'].value=
					document.forms[0].elements['//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_Last_Name'].value;
			
		}
		if(fieldName=='//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_Middle_Initial')
		{
			if(document.forms[0].elements['//Page' + pageNum + '/EndorserStudentInformation/Student_Middle_Initial']!=null)
				document.forms[0].elements['//Page' + pageNum + '/EndorserStudentInformation/Student_Middle_Initial'].value=
					document.forms[0].elements['//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_Middle_Initial'].value;
			
		}
		
		if(fieldName=='//Page' + pageNum + '/ParentBorrowerInformation/Current_DOB_Display')
		{								   
			if(document.forms[0].elements['//Page' + pageNum + '/EndorserStudentInformation/Student_DOB']!=null)
				document.forms[0].elements['//Page' + pageNum + '/EndorserStudentInformation/Student_DOB'].value=
					document.forms[0].elements['//Page' + pageNum + '/ParentBorrowerInformation/Current_DOB_Display'].value;
			
		}
		//End:For Endorsement GB
			
		if (postfix != null) 
		{
			var objLoanWizardLoanType = document.getElementById("LoanWizardLoanType"); 
			if (objLoanWizardLoanType != null && objLoanWizardLoanType.value == "GRAD_PLUS") 
			{
				if(fieldName=='//Page' + pageNum + '/BorrowerInformation/Current_SSN_Display')
				{
					if(document.forms[0].elements['//Page' + pageNum + '/StudentInformation/Student_SSN']!=null)
					{  
						document.forms[0].elements['//Page' + pageNum + '/StudentInformation/Student_SSN'].value=
							document.forms[0].elements['//Page' + pageNum + '/BorrowerInformation/Current_SSN_Display'].value;
							
					}
				}	
					
				if(fieldName=='//Page' + pageNum + '/BorrowerInformation/Current_SSN_DisplayAgain')
				{
					if(document.forms[0].elements['//Page' + pageNum + '/StudentInformation/Student_SSNAgain']!=null)
						document.forms[0].elements['//Page' + pageNum + '/StudentInformation/Student_SSNAgain'].value=
							document.forms[0].elements['//Page' + pageNum + '/BorrowerInformation/Current_SSN_DisplayAgain'].value;
				
				}
				
				if (document.getElementById('//Page' + pageNum + '/StudentInformation/Student_SSN1' + postfix) != null 
						&& document.getElementById('//Page' + pageNum + '/BorrowerInformation/Current_SSN_Display1' + postfix) != null) 
						{
							document.getElementById('//Page' + pageNum + '/StudentInformation/Student_SSN1' + postfix).value = 
										document.getElementById('//Page' + pageNum + '/BorrowerInformation/Current_SSN_Display1' + postfix).value
						}
						
				if (document.getElementById('//Page' + pageNum + '/StudentInformation/Student_SSN2' + postfix) != null 
						&& document.getElementById('//Page' + pageNum + '/BorrowerInformation/Current_SSN_Display2' + postfix) != null) 
						{
							document.getElementById('//Page' + pageNum + '/StudentInformation/Student_SSN2' + postfix).value = 
										document.getElementById('//Page' + pageNum + '/BorrowerInformation/Current_SSN_Display2' + postfix).value
						}
				
				if (document.getElementById('//Page' + pageNum + '/StudentInformation/Student_SSN3' + postfix) != null 
						&& document.getElementById('//Page' + pageNum + '/BorrowerInformation/Current_SSN_Display3' + postfix) != null) 
						{
							document.getElementById('//Page' + pageNum + '/StudentInformation/Student_SSN3' + postfix).value = 
										document.getElementById('//Page' + pageNum + '/BorrowerInformation/Current_SSN_Display3' + postfix).value
						}
				
				if (document.getElementById('//Page' + pageNum + '/StudentInformation/Student_SSNAgain1' + postfix) != null 
						&& document.getElementById('//Page' + pageNum + '/BorrowerInformation/Current_SSN_DisplayAgain1' + postfix) != null) 
						{
							document.getElementById('//Page' + pageNum + '/StudentInformation/Student_SSNAgain1' + postfix).value = 
										document.getElementById('//Page' + pageNum + '/BorrowerInformation/Current_SSN_DisplayAgain1' + postfix).value
						}
				
				if (document.getElementById('//Page' + pageNum + '/StudentInformation/Student_SSNAgain2' + postfix) != null 
						&& document.getElementById('//Page' + pageNum + '/BorrowerInformation/Current_SSN_DisplayAgain2' + postfix) != null) 
						{
							document.getElementById('//Page' + pageNum + '/StudentInformation/Student_SSNAgain2' + postfix).value = 
										document.getElementById('//Page' + pageNum + '/BorrowerInformation/Current_SSN_DisplayAgain2' + postfix).value
						}
				
				if (document.getElementById('//Page' + pageNum + '/StudentInformation/Student_SSNAgain3' + postfix) != null 
						&& document.getElementById('//Page' + pageNum + '/BorrowerInformation/Current_SSN_DisplayAgain3' + postfix) != null) 
						{
							document.getElementById('//Page' + pageNum + '/StudentInformation/Student_SSNAgain3' + postfix).value = 
										document.getElementById('//Page' + pageNum + '/BorrowerInformation/Current_SSN_DisplayAgain3' + postfix).value
						}
						
				//Start:For Endorsement GB
				if(fieldName=='//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSN')
				{
					if(document.forms[0].elements['//Page' + pageNum + '/EndorserStudentInformation/Student_SSN']!=null)
					{  
						document.forms[0].elements['//Page' + pageNum + '/EndorserStudentInformation/Student_SSN'].value=
							document.forms[0].elements['//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSN'].value;
							
					}
				}	
					
				if(fieldName=='//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSNAgain')
				{
					if(document.forms[0].elements['//Page' + pageNum + '/EndorserStudentInformation/Student_SSNAgain']!=null)
						document.forms[0].elements['//Page' + pageNum + '/EndorserStudentInformation/Student_SSNAgain'].value=
							document.forms[0].elements['//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSNAgain'].value;
				
				}
				
				if (document.getElementById('//Page' + pageNum + '/EndorserStudentInformation/Student_SSN1' + postfix) != null 
						&& document.getElementById('//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSN1' + postfix) != null) 
						{
							document.getElementById('//Page' + pageNum + '/EndorserStudentInformation/Student_SSN1' + postfix).value = 
										document.getElementById('//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSN1' + postfix).value
						}
						
				if (document.getElementById('//Page' + pageNum + '/EndorserStudentInformation/Student_SSN2' + postfix) != null 
						&& document.getElementById('//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSN2' + postfix) != null) 
						{
							document.getElementById('//Page' + pageNum + '/EndorserStudentInformation/Student_SSN2' + postfix).value = 
										document.getElementById('//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSN2' + postfix).value
						}
				
				if (document.getElementById('//Page' + pageNum + '/EndorserStudentInformation/Student_SSN3' + postfix) != null 
						&& document.getElementById('//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSN3' + postfix) != null) 
						{
							document.getElementById('//Page' + pageNum + '/EndorserStudentInformation/Student_SSN3' + postfix).value = 
										document.getElementById('//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSN3' + postfix).value
						}
				
				if (document.getElementById('//Page' + pageNum + '/EndorserStudentInformation/Student_SSNAgain1' + postfix) != null 
						&& document.getElementById('//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSNAgain1' + postfix) != null) 
						{
							document.getElementById('//Page' + pageNum + '/EndorserStudentInformation/Student_SSNAgain1' + postfix).value = 
										document.getElementById('//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSNAgain1' + postfix).value
						}
				
				if (document.getElementById('//Page' + pageNum + '/EndorserStudentInformation/Student_SSNAgain2' + postfix) != null 
						&& document.getElementById('//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSNAgain2' + postfix) != null) 
						{
							document.getElementById('//Page' + pageNum + '/EndorserStudentInformation/Student_SSNAgain2' + postfix).value = 
										document.getElementById('//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSNAgain2' + postfix).value
						}
				
				if (document.getElementById('//Page' + pageNum + '/EndorserStudentInformation/Student_SSNAgain3' + postfix) != null 
						&& document.getElementById('//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSNAgain3' + postfix) != null) 
						{
							document.getElementById('//Page' + pageNum + '/EndorserStudentInformation/Student_SSNAgain3' + postfix).value = 
										document.getElementById('//Page' + pageNum + '/ParentBorrowerInformation/Parent_Borrower_SSNAgain3' + postfix).value
						}
				//End:For Endorsement GB		
					
			}
					
		}
		
	}	
	
	
	
function HideOnClick(EnabledDivName,DisabledDivName)
{
	document.getElementById(EnabledDivName).style.visibility ="hidden";
	document.getElementById(EnabledDivName).style.display ="none";
	
	document.getElementById(DisabledDivName).style.visibility ="visible";
	document.getElementById(DisabledDivName).style.display ="inline";
	
	document.forms[0].elements['IAgreedBtnClicked'].value = "1";
	
}

    function  hide_show_OtherSchoolName_In_Borr_Initialted_InPublic()
    {
		// get School Name so as to decide if we need o display Other text box or not.
		if( document.getElementById( '//StartLoanQWizard/School_ID') != null )
		{
			//get items count for School codes
			var c = document.forms[0].elements['//StartLoanQWizard/School_ID'].length ;
			oOption = new Option();			
			for(i=0; i<c; i++)
			{// loop through the combo items till we find the selected one
				if (document.forms[0].elements['//StartLoanQWizard/School_ID'][i].selected)
				{ // keep value(ID)  and text (displayed string)
					oOption.value= document.forms[0].elements['//StartLoanQWizard/School_ID'].options[i].value;
					oOption.text= document.forms[0].elements['//StartLoanQWizard/School_ID'].options[i].text;
					break;
				}
			}
			if(oOption != null )
			{
				if( (oOption.text.indexOf('Any ') != -1 
					&& 	oOption.text.indexOf(' School') != -1 )
					|| (oOption.text == 'Other'))
					{
						document.getElementById("OtherSchoolNameDiv").style.visibility ="visible";
						document.getElementById("OtherSchoolNameDiv").style.display ="inline";					
					}
					else
					{
						document.getElementById("OtherSchoolNameDiv").style.visibility ="hidden";
						document.getElementById("OtherSchoolNameDiv").style.display ="none";									
					}				
			}	
		}    
    }	 

function UnCheck_All_General_List(PageName)
{
    for (i = 0; i < document.forms[0].elements.length; i++)
    {
      if (document.forms[0].elements[i].type == 'checkbox' 
		 && document.forms[0].elements[i].name.indexOf(PageName) != -1
       )
      {
			document.forms[0].elements[i].checked = false;
      }
    }        
}
function IsCheckBoxListSelected(PageName,sButtonMark)
{
    for (i = 0; i < document.forms[0].elements.length; i++)
    {
      if (document.forms[0].elements[i].type == 'checkbox' 
      && document.forms[0].elements[i].name.indexOf(PageName) != -1
      )
      {
          if( document.forms[0].elements[i].checked )
          {
             return true;
          }		
      }
    }      
	alert("At least one record needs to be selected to perform the " + sButtonMark + " operation.");
    return false;  
}
function ApplyWithdraw(pageName)
{
	if (IsCheckBoxListSelected(pageName,'withdraw'))
	{
		if (!confirm ("Are you sure you want to Withdraw the selected applications?"))
		{
			return false;
		}
		else
		{
			menuAction('LoanWizard_DoBulkWithdraw','BorrowerAccess');
		}
	}
	else
	{
		return false;
	}
}						

	function CheckEmployerStatus(EmpSTChk)
	{
		var prefix = document.getElementById("BlockNameForEmpStatus").value;
		var lastSplashIndex = prefix.lastIndexOf("/");
		prefix = prefix.substring(0,lastSplashIndex +1 );
		//alert(prefix);
		
		var zaki=EmpSTChk.checked;


		document.getElementById("Employer_Status1").checked=false;
		document.getElementById("Employer_Status2").checked=false;
		document.getElementById("Employer_Status3").checked=false;
		EmpSTChk.checked=zaki;
		
		// isReadOnly variable determine if the Employer block is readony or not, depending on the CheckBox that is checked 
		var isReadOnly = 
			document.getElementById("Employer_Status1").checked || document.getElementById("Employer_Status2").checked;
		
		
		
		document.getElementById("//Employer_Status").value=EmpSTChk.name.substring(EmpSTChk.name.length-1,EmpSTChk.name.length);	
		//lock unloack the employer block in MPN applications
		document.getElementById(prefix + "Employer_Name").readOnly=isReadOnly;
		document.getElementById(prefix + "Employer_Address").readOnly=isReadOnly;
		document.getElementById(prefix + "Employer_City").readOnly=isReadOnly;
		document.getElementById(prefix + "Employer_Zip").readOnly=isReadOnly;
		document.getElementById(prefix + "Employer_Phone1_P00NST3").readOnly=isReadOnly;
		document.getElementById(prefix + "Employer_Phone2_P00NST3").readOnly=isReadOnly;
		document.getElementById(prefix + "Employer_Phone3_P00NST3").readOnly=isReadOnly;
		document.getElementById(prefix + "Employer_Phone").readOnly=isReadOnly;
		if(document.getElementById(prefix + "Flag_CheckBoxType")!= null)
			document.getElementById(prefix + "Flag_CheckBoxType").readOnly=isReadOnly;
		
		
		
		document.getElementById(prefix + "Employer_State").disabled=isReadOnly;
		
		if(isReadOnly == true)
		{	
			document.getElementById(prefix + "Employer_Name").value=""
			document.getElementById(prefix + "Employer_Address").value=""
			document.getElementById(prefix + "Employer_City").value=""
			document.getElementById(prefix + "Employer_State").value=""
			document.getElementById(prefix + "Employer_Zip").value=""
			document.getElementById(prefix + "Employer_Phone3_P00NST3").value=""
			document.getElementById(prefix + "Employer_Phone2_P00NST3").value=""
			document.getElementById(prefix + "Employer_Phone1_P00NST3").value=""
			document.getElementById(prefix + "Employer_Phone").value=""
			if(document.getElementById(prefix + "Flag_CheckBoxType")!= null)
				document.getElementById(prefix + "Flag_CheckBoxType").value="0"
				
		}
		
		if(	 EmpSTChk.checked == false )
		{
			document.getElementById("//Employer_Status").value = "";
		}
	}


    function OpenSLSSContactUSASPX()
    {
    
       var DestPageUrl = document.getElementById('uxdistenationUrl_original').value;    
       DestPageUrl = DestPageUrl+"/Info/ContactUS.aspx";
		document.getElementById('uxdistenationUrl').value = DestPageUrl;
		
       var clientUrl = document.getElementById('uxSlssServiceUrl').value;
       window.document.forms[0].method = "post";
       window.document.forms[0].action = clientUrl;
       window.document.forms[0].submit();                           
    }


    function OpenSLSSHelpASPX()
    {
    
       var DestPageUrl = document.getElementById('uxdistenationUrl_original').value;    
       DestPageUrl = DestPageUrl+"/Info/Help.aspx";
		document.getElementById('uxdistenationUrl').value = DestPageUrl;
		
       var clientUrl = document.getElementById('uxSlssServiceUrl').value;
       window.document.forms[0].method = "post";
       window.document.forms[0].action = clientUrl;
       window.document.forms[0].submit();                           
    }


	
	 function navigateToServicingClient()
    {
    
       var DestPageUrl = document.getElementById('uxdistenationUrl_original').value;    
       DestPageUrl = DestPageUrl+"/Forms/NewServicing.aspx";
		document.getElementById('uxdistenationUrl').value = DestPageUrl;
		
       var clientUrl = document.getElementById('uxSlssServiceUrl').value;
       window.document.forms[0].method = "post";
       window.document.forms[0].action = clientUrl;
       window.document.forms[0].submit();                           
    }
	
		 function navigateToDownloadFormsClient()
    {
    
       var DestPageUrl = document.getElementById('uxdistenationUrl_original').value;    
       DestPageUrl = DestPageUrl+"/Info/DownloadForms.aspx";
		document.getElementById('uxdistenationUrl').value = DestPageUrl;
		
       var clientUrl = document.getElementById('uxSlssServiceUrl').value;
       window.document.forms[0].method = "post";
       window.document.forms[0].action = clientUrl;
       window.document.forms[0].submit();                           
    }
    
    
    		 function navigateToViewOtherLoansClient()
    {
    
       var DestPageUrl = document.getElementById('uxdistenationUrl_original').value;    
       DestPageUrl = DestPageUrl+"/Info/ViewOtherLoans.aspx";
		document.getElementById('uxdistenationUrl').value = DestPageUrl;
		
       var clientUrl = document.getElementById('uxSlssServiceUrl').value;
       window.document.forms[0].method = "post";
       window.document.forms[0].action = clientUrl;
       window.document.forms[0].submit();                           
    }
    
    function navigateToManageMyAccountClient()
    {
    
       var DestPageUrl = document.getElementById('uxdistenationUrl_original').value;    
       DestPageUrl = DestPageUrl+"/Info/ManageMyAccount.aspx";
		document.getElementById('uxdistenationUrl').value = DestPageUrl;
		
       var clientUrl = document.getElementById('uxSlssServiceUrl').value;
       window.document.forms[0].method = "post";
       window.document.forms[0].action = clientUrl;
       window.document.forms[0].submit();                           
    }
    
    function navigateToDefermentClient()
    {
    
       var DestPageUrl = document.getElementById('uxdistenationUrl_original').value;    
       DestPageUrl = DestPageUrl+"/Deferment/Deferment.aspx";
		document.getElementById('uxdistenationUrl').value = DestPageUrl;
		
       var clientUrl = document.getElementById('uxSlssServiceUrl').value;
       window.document.forms[0].method = "post";
       window.document.forms[0].action = clientUrl;
       window.document.forms[0].submit();                           
    }

    function navigateToForbearanceClient()
    {

       var DestPageUrl = document.getElementById('uxdistenationUrl_original').value;    
       DestPageUrl = DestPageUrl+"/Forbearance/Forbearance.aspx";

		document.getElementById('uxdistenationUrl').value = DestPageUrl;
       var clientUrl = document.getElementById('uxSlssServiceUrl').value;
       window.document.forms[0].method = "post";
       window.document.forms[0].action = clientUrl;
       window.document.forms[0].submit();                           
    }
    
    function navigateToPaymentClient()
    {
    
       var DestPageUrl = document.getElementById('uxdistenationUrl_original').value;    
       DestPageUrl = DestPageUrl+"/Payments/Payments.aspx";
		document.getElementById('uxdistenationUrl').value = DestPageUrl;
       var clientUrl = document.getElementById('uxSlssServiceUrl').value;
       window.document.forms[0].method = "post";
       window.document.forms[0].action = clientUrl;
       window.document.forms[0].submit();                           
    }    
    
      function navigateToRepaymentOptionsClient()
    {
    
       var DestPageUrl = document.getElementById('uxdistenationUrl_original').value;    
       DestPageUrl = DestPageUrl+"/Payments/RepaymentOptions.aspx";
		document.getElementById('uxdistenationUrl').value = DestPageUrl;
       var clientUrl = document.getElementById('uxSlssServiceUrl').value;
       window.document.forms[0].method = "post";
       window.document.forms[0].action = clientUrl;
       window.document.forms[0].submit();                           
    }  
//Closing windows
function CloseWindow ()
{
	if(	   isValidPhone(document.getElementById('//Feedback/Phone').value) 
		&& emailCheck(document.getElementById('//Feedback/Email'),false)
		&& document.getElementById('//Feedback/FName') != null && document.getElementById('//Feedback/FName').value.length >0 
		&& document.getElementById('//Feedback/Message') != null && document.getElementById('//Feedback/Message').value.length >0 )
	{
		this.focus();
		self.opener = this;
		self.close();
	}
}

//Validate phone number
 function isValidPhone(phoneNO,PhoneOwner)
 {
	//var phoneNO = window.document.getElementById(vphone).value ;
	
	
	if (phoneNO.length < 10)
		return false;
		
	for(var i=0;i< phoneNO.length;i++)
	{
		var c=phoneNO.charAt(i);
		if(c==' '||isdigit(c)) 
			continue;
		else 
			return false;
	}
	
	if (phoneNO.substring(0,3) == "900" || phoneNO.substring(0,3) == "976" || phoneNO.substring(0,4) == "1900" ||
		phoneNO.substring(0,4)  == "1976")
	{
		return false;
	}
	
	if (phoneNO.substring(0,3)=="000" || phoneNO.substring(3,6)=="000" || phoneNO.substring(6,10)=="0000" )
	{
		return false;
	}
	
	// Not allowed except for employee 
	if (PhoneOwner != "Employer" &&
		(phoneNO.substring(0,3) == "800" || phoneNO.substring(0,3) == "888" || phoneNO.substring(0,3) == "877" ||
		phoneNO.substring(0,3)  == "866" || phoneNO.substring(0,4) == "1800" || phoneNO.substring(0,4) == "1888"
		|| phoneNO.substring(0,4) == "1877" || phoneNO.substring(0,4) == "1866"))
	{
		return false;
	}
	return true;
 }
 
 
 function Check_All_Statuses(sStatusesList)
{
	for (i = 0; i < document.forms[0].elements.length; i++)
    {
      if (document.forms[0].elements[i].type == 'checkbox' 
      && document.forms[0].elements[i].name.indexOf(sStatusesList) != -1)
      {
			document.forms[0].elements[i].checked = true;
      }
    }
}

function UnCheck_All_Statuses(sStatusesList)
{
	for (i = 0; i < document.forms[0].elements.length; i++)
    {
      if (document.forms[0].elements[i].type == 'checkbox' 
      && document.forms[0].elements[i].name.indexOf(sStatusesList) != -1)
      {
			document.forms[0].elements[i].checked = false;
      }
    }
}