function restoreUserNameAAII(){ 
 // search coockie: 
  var userNameAAII=getCookie("userNameAAII");
    if (!userNameAAII) return; // the cookie doesn't exist... 
  document.forms.logon.AAIILogon__userName.value=userNameAAII;
 } 

 function saveUserNameAAII(){ 
 // store it as a cookie that will expire in 2 years
  var now=new Date(); 
  expdelay=1000*60*60*24*365*2; // persistence: 2 years
  var expdate=new Date(Date.parse(now)+expdelay); 
  if (document.forms.logon.checkbox.checked){ 
   setCookie("userNameAAII",document.forms.logon.AAIILogon__userName.value,expdate); 
   }    
 } 

 // 
 // setCookie and getCookie are from: Netscape's Javascript User Guide 
 // 
 function setCookie(name, value, expire) { 
    document.cookie = name + "=" + escape(value) 
    + ((expire == null) ? "" : ("; expires=" + expire.toGMTString())) 
 } 
 function getCookie(Name) { 
    var search = Name + "=" 
    if (document.cookie.length > 0) { // if there are any cookies 
       offset = document.cookie.indexOf(search) 
       if (offset != -1) { // if cookie exists 
          offset += search.length 
          // set index of beginning of value 
          end = document.cookie.indexOf(";", offset) 
          // set index of end of cookie value 
          if (end == -1) 
             end = document.cookie.length 
          return unescape(document.cookie.substring(offset, end)) 
       } 
    } 
 } 

function popupWin800x550(temp){
	url = temp;
	var leftX = screen.availWidth;
	var topY = screen.availHeight;
	var w = 800;
	var h = 550;
	var propStr = 'width=' + w + ',height=' + h + ',left=' + ((leftX - w - 10) * .5) + ',top=' + ((topY - h - 30) * .5) + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes';
	MyWindow=window.open(url,'PrivacyWindow',propStr); 
	MyWindow.focus();
}

function MM_reloadPage(init) {  
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);



if (document.getElementById){ 
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("zonal").getElementsByTagName("span"); 
		if(el.style.display != "block"){ 
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") 
				ar[i].style.display = "none";

				if (ar[i].className=="submenuactive") 
				ar[i].className = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function ClassNew(obj, new_style) { 
  obj.className=new_style;
}

function switchclass(id){ 
   if(document.getElementById(id)){    
       var ele = document.getElementById(id);   
 	   var ar = document.getElementById("zonal").getElementsByTagName("div"); 
	   for (var i=0; i<ar.length; i++){
		   if (ele.id == ar[i].id) {
               if(ele.className=="menutitle"){    
                  ele.className="menutitleexpanded";        
               }else{ 
                  ele.className="menutitle";      
               } 
		   } else {
		       ar[i].className="menutitle";
		   }
	   } 
   } 
} 


function activemenu(currobj, spanId){ 
    if(document.getElementById(currobj)){    
           var ele = document.getElementById(currobj);   
 	   var currspan = document.getElementById(spanId); 
 	   var ar = currspan.getElementsByTagName("span"); 
           
	   for (var i=0; i<ar.length; i++){
	       if (ele.id == ar[i].id) {
                     ele.className="submenuactive";      
	       } else {
		   ar[i].className="none";
	       }
	   } 
   } 
} 


function compInfomenu(currobj){ 
    if(document.getElementById(currobj)){    
         var ele = document.getElementById(currobj);   
 	   var ar = document.getElementById("zonal2").getElementsByTagName("div"); 
           
	   for (var i=0; i<ar.length; i++){
	       if (ele.id == ar[i].id) {
                 ele.className="secmenutitleexpanded";      
	       } else {
		     ar[i].className="secmenutitle";
	       }
	   } 
   } 
} 


sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

var cur_link;
function doLinkClass(lnk) {
  if (lnk && lnk.blur) lnk.blur();	// remove marquee
  if (!lnk || cur_link == lnk) return;
  if (cur_link) cur_link.className = "done";
  lnk.className = "on";
  cur_link = lnk;
}

var cur_lyr;	// holds id of currently visible layer
function swapLayers(lnk,id) {
  doLinkClass(lnk);
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "visible";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "hidden";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

// get reference to nested layer for ns4
function getLyrRef(lyr,doc) {
	if (document.layers) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0) 
	    	if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
					return theLyr;
	  }
		return null;
  }
}

function init(id,lyr) {
  var lnk = getElemRefs(id);
  swapLayers(lnk,lyr);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function popupWin(temp){
	url = temp;
	var leftX = screen.availWidth;
	var topY = screen.availHeight;
	var w = 665;
	var h = 475;
	var propStr = 'width=' + w + ',height=' + h + ',left=' + ((leftX - w - 10) * .5) + ',top=' + ((topY - h - 30) * .5) + ',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes';
	MyWindow=window.open(url,'MyWindow',propStr); 
	MyWindow.focus();
}

function popupWinPrivacy(temp){
	url = temp;
	var leftX = screen.availWidth;
	var topY = screen.availHeight;
	var w = 665;
	var h = 530;
	var propStr = 'width=' + w + ',height=' + h + ',left=' + ((leftX - w - 10) * .5) + ',top=' + ((topY - h - 30) * .5) + ',toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes';
	MyWindow=window.open(url,'PrivacyWindow',propStr); 
	MyWindow.focus();
}

function popupWinAddress(temp){
	url = temp;
	var leftX = screen.availWidth;
	var topY = screen.availHeight;
	var w = 665;
	var h = 350;
	var propStr = 'width=' + w + ',height=' + h + ',left=' + ((leftX - w - 10) * .5) + ',top=' + ((topY - h - 80) * .5) + ',toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes';
	MyWindow=window.open(url,'MyWindow',propStr); 
	MyWindow.focus();
}
function popupExtURLAddress(temp,exttemp){
  	url = temp+'?exturl='+exttemp;
  	var leftX = screen.availWidth;
  	var topY = screen.availHeight;
  	var w = 665;
  	var h = 350;
  	var propStr = 'width=' + w + ',height=' + h + ',left=' + ((leftX - w - 10) * .5) + ',top=' + ((topY - h - 80) * .5) + ',toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes';
  	MyWindow=window.open(url,'MyWindow',propStr);
	MyWindow.focus();
}
function popupExtURLWebPay(temp){
  	url = temp;
  	var leftX = screen.availWidth;
  	var topY = screen.availHeight;
  	var w = 760;
  	var h = 350;
  	var propStr = 'width=' + w + ',height=' + h + ',left=' + ((leftX - w - 10) * .5) + ',top=' + ((topY - h - 80) * .5) + ',toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes';
  	MyWindow=window.open(url,'MyWindow',propStr);
	MyWindow.focus();
}
//Glossary PopUp
function jump(url) {
	var leftX = screen.availWidth;
	var topY = screen.availHeight;
	var w = 438;
	var h = 438;
	var propStr = 'width=' + w + ',height=' + h + ',left=' + ((leftX - w - 10) * .5) + ',top=' + ((topY - h - 30) * .5) + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no';
	TheNewWin = window.open(url, 'Glossary', propStr);
	TheNewWin.focus();
}

/////////////////GLOSSARY//////////////////////////
function changeCategory(category) {
window.location="http://www.mazdacredit.com/glossary/glossary_main.jhtml?id=0&account=1&category=" + category;
}

/////////////////// BROWSER DETECT ///////////////////////////

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{	// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		}
	]
};
BrowserDetect.init();

function accepted()
{
	document.cookie="ABSVisited=true; path=/;";
	window.location = "http://www.mazdacredit.com/institutionalinvestments/index.jhtml";
}

function send()
{
	document.cookie="FIAVisited=true; path=/; expires=Wed, 01-Aug-2008 00:00:00 GMT";
	window.open('https://www3483.ntrs.com/nta/frd/public/login/SignOn.jsp');
}

function check_page_visit(cookiename) {
	if (cookiename == "ABSVisited")
	{
		if (!getCookie(cookiename))
		{
			window.location = "http://www.mazdacredit.com/institutionalinvestments/terms.jhtml";
		}
		else
		{
			window.location = "http://www.mazdacredit.com/institutionalinvestments/index.jhtml";
		}
	}
	if (cookiename == "FIAVisited")
	{
		if (!getCookie(cookiename))
		{
			window.location = "http://www.mazdacredit.com/interestadvantage/terms.jhtml";
		}
		else
		{
			window.open('https://www3483.ntrs.com/nta/frd/public/login/SignOn.jsp');
		}
	}

}
