//<!-- TOPIC Javascript Libraries -->
// Functions for Index pages
// Inlcuce this file after fsa.js, amessages.js, and agen.js

var clHandleHelp;
var clHandleCust;

// Override Help in agen.js
function Help(szHelp, szLocale) {
	var szFile;
	
	if (szHelp) {
		szFile = "/help/" + szHelp   // open with a given file
	} else {
		szFile = "/help/fftoc00.htm"  // by default, open the help content file
	}

	if (szLocale && szLocale.indexOf("es_ES") > -1) {
		szFile = "/es_ES" + szFile ;
	}

	openWindow(clHandleHelp, szFile, "help", szHelpWinFeatures);
}

// redirect to previous cycle helps
function PrevHelp(szHelp, szLocale) {
	var szFile;

	if (szHelp) {
		if (szLocale && szLocale.indexOf("es_ES") > -1) {
			szFile = "/es_ES/fotw0809/help/" + szHelp   // open with a given file
		} else {
			szFile = "/fotw0809/help/" + szHelp   // open with a given file
		}
	} else {
		if (szLocale && szLocale.indexOf("es_ES") > -1) {
			szFile = "/es_ES/fotw0809/help/fftoc00.htm"  // by default, open the help content file
		} else {
			szFile = "/fotw0809/help/fftoc00.htm"  // by default, open the help content file
		}
	}

	openWindow(clHandleHelp, szFile, "help", szHelpWinFeatures);
}

// redirect to 0405 site for the help for R2T4
function R2T4Help(szHelp) {
	var szFile;

	if (szHelp) {
		szFile = "/fotw0405/help/" + szHelp   // open with a given file
	} else {
		szFile = "/fotw0405/help/fftoc00.htm"  // by default, open the help content file
	}

	openWindow(clHandleHelp, szFile, "help", szHelpWinFeatures);
}

function PrevCycle(szFile) {
	if (!szFile) {
		return;
	}

    // redirect to previous cycle
	location.href = "/FOTWWebApp/fotw0708/" + szFile;
}

function JSP(szFile, szLocale) {
	if (!szFile) {
		return;
	}
	
	// redirect index JSP page to application server
	if (szLocale && szLocale.indexOf("es_ES") > -1) {
    	location.href = "/FOTWWebApp/es_ES/" + szFile;
    } else {
    	location.href = "/FOTWWebApp/" + szFile;
    }
}

function ConfirmKey(szValue ) {
    var bRet = true
	if (szValue < "128" && szValue != "") {
		bRet = confirm(szUse128Msg)
    }
	if (bRet == false) {
		FafsaHome()
	}
    return bRet
}

function CloseHelp() {
	if (clHandleHelp) {
		clHandleHelp.close()
		clHandleHelp = null
	}
}

function CustServ(szLocale) {
	var szHelp;

	if (szLocale && szLocale.indexOf("es_ES") > -1) {
		szHelp = "/es_ES/help/cs.htm";
	} else { 
		szHelp = "/help/cs.htm";
	}
	
	openWindow(clHandleCust, szHelp, "CustomerService", szHelpWinFeatures);	
}

//open PIN site with requested page
function PIN(szFile, szLocale)
{
	var szContext="";
	if (szLocale && szLocale.indexOf("es_ES") > -1) {
		if(szFile.indexOf("?") > -1)
		{
			szFile=szFile+"&locale=es_ES";
		}
		else
		{
			szFile=szFile+"?locale=es_ES";
		}

	} 
	openWindow(clHandleExternal, szFile, "pin", szExternalWinFeatures);	
}

function FSLookup(szLocale)
{
	if (szLocale && szLocale.indexOf("es_ES") > -1) {
		location.href ="/FOTWWebApp/FSLookupServlet?locale=es_ES";
	} else {
		location.href ="/FOTWWebApp/FSLookupServlet";
	}
}

function WindowPopUp(szFile) {
    popWindow(szFile,550,600,1);
}

// function to open external website and PDF in new browser window
function openExternal(szFileName) {
	popWindow(szFileName, 800,600, 1);
}


///////////////////////////////////////////////////////
//  FOR GOOGLE
///////////////////////////////////////////////////////

// Used by Google search navigation bar
function search_nav(iStart)
{
	with(document.FAFSA) {
		start.value = iStart;
		Search();
	}
}

// Used by Google
function spelling_suggestion(newQuery)
{
	with(document.FAFSA) {
		q.value = newQuery;
		Search();
	}
}

///////////////////////////////////////////////////////
//  FOR GOOGLE - END
///////////////////////////////////////////////////////
