var browser_type=navigator.appName;
var browser_version=parseInt(navigator.appVersion);
var isAOL = navigator.userAgent.indexOf("AOL") > 0;
var isMac = navigator.userAgent.indexOf("Mac") > 0; 
var total;

total = 0;


//if Netscape 4 and above
if (browser_type=="Netscape")
{
	if (browser_version>=4 && browser_version<5)
	{
		total = total + 1;
	}	
}


//or if IE 4 and above
else if (browser_type=="Microsoft Internet Explorer"&&browser_version>=4)
{ 
    
	total = total + 1;
}


if ((isMac) && (!isAOL) && (browser_type=="Microsoft Internet Explorer") && ((browser_version>=4) && (browser_version<5)))
{
	window.open("/error/macupgrade.asp", "Upgrade Browser", "left=500,top=500,height=400,width=600,menu=no,scrollbars=no");
}


if ((isMac) && (isAOL))
{
	total = 0;
}


if (total == 0)
{
	//turned this off for now
	//window.location.replace("/error/errorbrowser.asp");
}

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 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=482,height=400,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=482,height=400,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 BuildSchools(){
	var value = null;
	var myindex=document.applyForm.schoolState.selectedIndex;
	
	if (document.applyForm.schoolState.options[myindex].value != ""){      	 
		value = document.applyForm.schoolState.options[myindex].value
		location = "plapps.asp?schoolState=" + value + "&stateLive=" + document.applyForm.stateLive.value + "#1";
	}
}

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 == 'WA' || theState == 'WI' || theState ==  'TX'|| theState ==  'IL'){
		//document.location.href = 'stateResidence.html';
		document.applyForm.mode.value = 'stateresidence';
		document.applyForm.submit();
	}	
}


function BuildSchools(){
	var value = null;
	var myindex=document.applyForm.schoolState.selectedIndex;
	
	if (document.applyForm.schoolState.options[myindex].value != ""){      	 
		value = document.applyForm.schoolState.options[myindex].value;
		location = "/apply.asp?schoolState=" + value + "&stateLive=" + document.applyForm.stateLive.value; // + "#1";
	}
}

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 checkForm(){

	isOK = true;
	theMessage = "";
	theMessage2 = "";

	if (document.applyForm.term[document.applyForm.term.selectedIndex].value != ''){
		
		if (document.applyForm.term[document.applyForm.term.selectedIndex].value > 6){
			document.location.href = '/schoolTerm.html';
			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, the school's state and name, and your school term.</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;	
}




















