function offsite(theURL, theWidth, theHeight, theX, theY){
	// Only the first parameter is required.
	
	if (confirm("Selecting this link will take you away from the SunTrust website.  Since you will be leaving the SunTrust site, we encourage you to review the privacy policy and security offered on that site before providing any personal financial information.  SunTrust does not guaranty or assume liability for any third-party products or services. Click OK to continue. \n\nNote: If you have a pop-up  blocker installed you may need to hold down the CTRL key when clicking OK.")){
		var xpos ;
		var ypos ;
		
		var height;
		var width;
		
		if (!theWidth){
			width = 800;
		}else{
			width = theWidth;
		}
		
		if (!theHeight){	
			height=600;
		}else{
			height= theHeight;
		}
		
		if (!theX){	
			xpos=0;
		}else{
			xpos= theX;
		}
		
		if (!theY){	
			ypos=0;
		}else{
			ypos= theY;
		}
		
				
		winOptions = 'toolbar=1,location=1,menubar=1,directories=1,screenx=' +  xpos + ',screeny='+ ypos + ',top='+ ypos +',left=' + xpos + ',status=1,menubar=1,scrollbars=1,resizable=1,width=' + width + ',height=' + height;
		var temp = window.open(theURL, '', winOptions);
		temp.focus();
	}

}

function mastGoTo(){

    var myindex=document.mast.go.selectedIndex;
    if(!myindex=="")
      {
        window.location.href=document.mast.go.options[myindex].value;
      }
}


function aa_loan_limit_calculator(){
	var xpos = 0;
	var ypos = 0;
	var width=580;
	var height=660;
	winOptions = 'toolbar=0,location=0,menubar=0,directories=0,screenx=' +  xpos + ',screeny='+ ypos + ',top='+ ypos +',left=' + xpos + ',status=0,menubar=0,scrollbars=1,resizable=0,width=' + width + ',height=' + height;
	var temp = window.open("http://academicanswer.suntrusteducation.com/calculator.html", '', winOptions);
	temp.focus();
}

function repayment_examples_aa(){
	var xpos = 0;
	var ypos = 0;
	var width=580;
	var height=760;
	winOptions = 'toolbar=0,location=0,menubar=0,directories=0,screenx=' +  xpos + ',screeny='+ ypos + ',top='+ ypos +',left=' + xpos + ',status=0,menubar=0,scrollbars=1,resizable=0,width=' + width + ',height=' + height;
	var temp = window.open("http://academicanswer.suntrusteducation.com/repayment_examples.html", '', winOptions);
	temp.focus();
}

function repayment_examples_cc(){
	var xpos = 0;
	var ypos = 0;
	var width=580;
	var height=760;
	winOptions = 'toolbar=0,location=0,menubar=0,directories=0,screenx=' +  xpos + ',screeny='+ ypos + ',top='+ ypos +',left=' + xpos + ',status=0,menubar=0,scrollbars=1,resizable=0,width=' + width + ',height=' + height;
	var temp = window.open("http://customchoice.suntrusteducation.com/repayment_examples.html", '', winOptions);
	temp.focus();
}

function PopWindow1(){ 
	gwin=window.open('/glossary.htm','New_Window','width=482,height=400,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
	gwin.focus();
}

/*
function PopWindow2(){ 
	gwin=window.open('glossary.htm#f-fafsa','New_Window','width=482,height=400,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
	gwin.focus();
}
*/

function PopWindow2(){ 
	gwin=window.open('toolbox/colleges.htm','New_Window','width=737,height=535,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
	gwin.focus();
}

function PopWindow3(){ 
	gwin=window.open('glossary.htm#s-sar','New_Window','width=482,height=400,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 	
	gwin.focus();
}

/*
function PopWindow3(){ 
	gwin=window.open('/glossary.htm#p-podcast','New_Window','width=482,height=300,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
	gwin.focus();
}
*/

function PopWindow4(){ 
	gwin=window.open('glossary.htm#f-fap','New_Window','width=482,height=400,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
	gwin.focus();
}

function PopWindow6(){ 
	gwin=window.open('glossary.htm#m-mpn','New_Window','width=482,height=400,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
	gwin.focus();
}


function PopWindow15(){ 	
	gwin=window.open('https://internetbanking.suntrust.com/studentloan','New_Window','location,menubar,resizable,scrollbars,status,titlebar,toolbar'); 
	gwin.focus();
}

function PopWindow20(){ 
	gwin=window.open('toolbox/colleges.htm','New_Window','width=737,height=535,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
	gwin.focus();
}


function PopWindow100(){ 
	gwin=window.open('/glossary.htm#p-pr','New_Window','width=482,height=400,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
	gwin.focus();
}

function PopWindow101(){ 
	gwin=window.open('/glossary.htm#l-libor','New_Window','width=482,height=400,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
	gwin.focus();
}



function submitCounselingForm() {
	if (confirm("Selecting this link will take you away from the SunTrust website.  Since you will be leaving the SunTrust site, we encourage you to review the privacy policy and security offered on that site before providing any personal financial information.  SunTrust does not guaranty or assume liability for any third-party products or services. Click OK to continue. \n\nNote: If you have a pop-up  blocker installed you may need to hold down the CTRL key when clicking OK.")){
		window.open ("http://mappingyourfuture.org/se", "NewWindow","menubar=0,resizable=1,width=775,height=500,scrollbars=1");
		document.myform.submit();
	}
}	

function submitCounselingForm2() {
	if (confirm("Selecting this link will take you away from the SunTrust website.  Since you will be leaving the SunTrust site, we encourage you to review the privacy policy and security offered on that site before providing any personal financial information.  SunTrust does not guaranty or assume liability for any third-party products or services. Click OK to continue. \n\nNote: If you have a pop-up  blocker installed you may need to hold down the CTRL key when clicking OK.")){
		window.open ("http://mappingyourfuture.org/sx", "NewWindow2","menubar=0,resizable=1,width=775,height=500,scrollbars=1");
		document.myform2.submit();
	}
}	

function PopWindow4()
{ 
gwin=window.open('podcast_1.htm','New_Window','width=482,height=225,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
gwin.focus();
}
function PopWindow5()
{ 
gwin=window.open('podcast_2.htm','New_Window','width=482,height=225,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
gwin.focus();
}
function PopWindow6()
{ 
gwin=window.open('podcast_3.htm','New_Window','width=482,height=225,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
gwin.focus();
}
function PopWindow7()
{ 
gwin=window.open('podcast_4.htm','New_Window','width=482,height=225,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
gwin.focus();
}
function PopWindow8()
{ 
gwin=window.open('podcast_5.htm','New_Window','width=482,height=225,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
gwin.focus();
}
function PopWindow9()
{ 
gwin=window.open('podcast_6.htm','New_Window','width=482,height=225,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
gwin.focus();
}

function checkMax(){
	var value = null;
	var myindex=document.applyForm.school.selectedIndex;
	if (document.applyForm.school.options[myindex].value != ""){      	 
		value = document.applyForm.school.options[myindex].value;
		location = "plapps.asp?schoolState=" + document.applyForm.schoolState.value + "&school=" + value + "&stateLive=" + document.applyForm.stateLive.value + "#2";
	}
		
}

// METHOD BELOW REPLACES ALL OF THE ONES ABOVE. 

function popWin(theURL){
	gwin=window.open(theURL,'New_Window','width=482,height=225,history=no,resizable=yes,status=no,scrollbars=yes,scrolling,menubar=no'); 
	gwin.focus();
}

function recalculate_budget(){
	var income_net = 0;
	var income_total = 0;
	var expense_total = 0;
	
	income_total = (income_total*1) + (cleanNum(document.calcform.income_jobs.value)*1) ;
	income_total = (income_total*1) + (cleanNum(document.calcform.income_family.value)*1) ;
	income_total = (income_total*1) + (cleanNum(document.calcform.income_grants.value)*1) ;
	income_total = (income_total*1) + (cleanNum(document.calcform.income_loans.value)*1) ;
	income_total = (income_total*1) + (cleanNum(document.calcform.income_other.value)*1) ;

	expense_total = (expense_total*1) + (cleanNum(document.calcform.expenses_rent.value)*1) ;
	expense_total = (expense_total*1) + (cleanNum(document.calcform.expenses_utilities.value)*1) ;
	expense_total = (expense_total*1) + (cleanNum(document.calcform.expenses_phone.value)*1) ;
	expense_total = (expense_total*1) + (cleanNum(document.calcform.expenses_food.value)*1) ;
	expense_total = (expense_total*1) + (cleanNum(document.calcform.expenses_car.value)*1) ;
	expense_total = (expense_total*1) + (cleanNum(document.calcform.expenses_tolls.value)*1) ;
	expense_total = (expense_total*1) + (cleanNum(document.calcform.expenses_gas.value)*1) ;
	expense_total = (expense_total*1) + (cleanNum(document.calcform.expenses_fun.value)*1) ;
	expense_total = (expense_total*1) + (cleanNum(document.calcform.expenses_tuition.value)*1) ;
	expense_total = (expense_total*1) + (cleanNum(document.calcform.expenses_fees.value)*1) ;
	expense_total = (expense_total*1) + (cleanNum(document.calcform.expenses_cards.value)*1) ;
	expense_total = (expense_total*1) + (cleanNum(document.calcform.expenses_misc.value)*1) ;
	
	income_net =  (income_total*1) - (expense_total*1); 
			
	setHotSpot("income_subtotal", formatCurrency(income_total));
	setHotSpot("expenses_subtotal", formatCurrency(expense_total));
	setHotSpot("income_net", formatCurrency(income_net));
}	

function cleanNum(num){
	
	num = num.toString().replace(/\$|\,/g,'');
	
	if(isNaN(num)){
		num = "0";
	}	

	return num;
}

function formatCurrency(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 (((sign)?'':'-') + '$' + num + '.' + cents);
}

function setHotSpot(theName, theText){

	if (document.getElementById(theName)){
		document.getElementById(theName).innerHTML =  theText;
	}	

}	

function changeRepState(TheItem,applyForm){
	page= applyForm[TheItem].value;
	location= page;
}


function checkMax(){
	var value = null;
	var myindex=document.applyForm.school.selectedIndex;
	if (document.applyForm.school.options[myindex].value != ""){      	 
		value = document.applyForm.school.options[myindex].value;
		//location = "ploans.asp?schoolState=" + document.applyForm.schoolState.value + "&school=" + value + "&stateLive=" + document.applyForm.stateLive.value + "#2";
	}
		
}

function checkResidency(){
	var theState = document.applyForm.stateLive[document.applyForm.stateLive.selectedIndex].value; 
	
	if (theState == 'IA' ||  theState == 'WI' || theState ==  'TX'|| theState ==  'IL'){
		//document.location.href = 'stateResidence.html';
		document.applyForm.mode.value = 'stateresidence';
		document.applyForm.submit();
	}	
}


function BuildSchools(){

	if ($('#schoolState').val() != ""){      	 
		location = "/apply.asp?schoolState=" + $('#schoolState').val() + "&stateLive=" + $('#stateLive').val() + "&l=" + $('#l').val(); 
	}
}

function offsiteRedirect(theURL){

	if (confirm("Selecting this link will take you away from the SunTrust website.  Since you will be leaving the SunTrust site, we encourage you to review the privacy policy and security offered on that site before providing any personal financial information.  SunTrust does not guaranty or assume liability for any third-party products or services. Click OK to continue.")){
		document.location.href = theURL;
	}

}

function applyAA(theURL){

	var theTerm = $('#term_aa').val();

	if (theTerm==""){
		alert("You must enter a school term first.");
	}else{	

		if (parseInt(theTerm) > 2){
			document.location.href = '/schoolTerm.asp';
		}else{
	
			if (confirm("SunTrust Bank has partnered with American Education Services (AES) to originate and service our Academic Answer Loan. You will be leaving the SunTrust site to complete your application on the AES website.  Please review AES's privacy policy on their website. Click O.K. to continue.")){
				document.location.href = theURL;
			}
		}
	}
}

function applyCC(theURL){

	var theTerm = $('#term_cc').val();

	if (theTerm==""){
		alert("You must enter a school term first.");
	}else{	

		if (parseInt(theTerm) > 2){
			document.location.href = '/schoolTerm2.asp';
		}else{

			if (confirm("SunTrust Bank has partnered with The First Marblehead Corporation (FMC) to originate and service our Custom Choice Loan. You will be leaving the SunTrust site to complete your application on the FMC website.  Please review FMC's privacy policy on their website. Click O.K. to continue.")){
				document.location.href = theURL;
			}
		}
	}
}

function checkForm(){

	isOK = true;
	theMessage = "";
	theMessage2 = "";

	//if (document.applyForm.term[document.applyForm.term.selectedIndex].value != ''){
		
		//if (document.applyForm.term[document.applyForm.term.selectedIndex].value > 5){
		//	document.location.href = '/schoolTerm.asp';
		//	return false;
		//}
	//}
	
	if (document.applyForm.stateLive[document.applyForm.stateLive.selectedIndex].value == '' || document.applyForm.schoolState[document.applyForm.schoolState.selectedIndex].value == '' || document.applyForm.school[document.applyForm.school.selectedIndex].value == '' || document.applyForm.term[document.applyForm.term.selectedIndex].value == ''){
		theMessage =  "<p class='error'>Please enter your state of residence and your school's state and name.</p>";
		isOK = false;
	}

	
	//if (document.applyForm.email.value != '' &&  ( !isValidEmail(document.applyForm.email.value)) ){
	//	theMessage2 = theMessage2 + "<p class='error'>Please enter a valid email address.</p>";
	//	isOK = false;
	//}
	
	//if (document.applyForm.email.value == '' && document.applyForm.contact_me.checked ){
	//	theMessage2 = theMessage2 + "<p class='error'>Since you have requested to be contacted, please enter your email address.</p>";
	//	isOK = false;
	//}

	if (!isOK){
			setHotSpot('errMsg', theMessage);
	}	


	//if (theMessage2!=""){
	//		setHotSpot('errMsg2', theMessage2);
	//}	

	// alert(theMessage);

	return isOK;	
}


$(document).ready(function(){

	$($(".slider > a")).click(function () {
		$(this).next("div").slideToggle("fast");
	});

});


















