﻿	// (1) browser vendor:
	//     is_nav, is_firefox, is_ie, is_opera, is_hotjava, is_webtv, is_TVNavigator, is_AOLTV
	// (2) browser version number:
	//     is_major (integer indicating major version number: 2, 3, 4 ...)
	//     is_minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
	// (3) browser vendor AND major version number
	//     is_nav2, is_nav3, is_nav4, is_nav4up, is_nav6, is_nav6up, is_gecko, is_firefox0, is_firefox1, is_firefox2, is_ie3,
	//     is_ie4, is_ie4up, is_ie5, is_ie5up, is_ie5_5, is_ie5_5up, is_ie6, is_ie6up, is_hotjava3, is_hotjava3up,
	//     is_opera2, is_opera3, is_opera4, is_opera5, is_opera5up

	// convert all characters to lowercase to simplify testing
	var agt=navigator.userAgent.toLowerCase();

	// *** BROWSER VERSION ***
	// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
	var is_major = parseInt(navigator.appVersion);
	var is_minor = parseFloat(navigator.appVersion);

	// Note: Opera and WebTV spoof Navigator.  We do strict client detection.
	// If you want to allow spoofing, take out the tests for opera and webtv.
	var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
							&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
							&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
	var is_nav2 = (is_nav && (is_major == 2));
	var is_nav3 = (is_nav && (is_major == 3));
	var is_nav4 = (is_nav && (is_major == 4));
	var is_nav4up = (is_nav && (is_major >= 4));
	var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
												(agt.indexOf("; nav") != -1)) );
	var is_nav6 = (is_nav && (is_major == 5));
	var is_nav6up = (is_nav && (is_major >= 5));
	var is_gecko = (agt.indexOf('gecko') != -1);

	var is_firefox = (agt.indexOf("firefox") != -1);
	var is_firefox0 = (agt.indexOf("firefox/0") != -1);
	var is_firefox1 = (agt.indexOf("firefox/1") != -1);
	var is_firefox2 = (agt.indexOf("firefox/2") != -1);

	var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	var is_ie3    = (is_ie && (is_major < 4));
	var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
	var is_ie4up  = (is_ie && (is_major >= 4));	
	var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
	var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
	var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
	var is_ie5down  = (is_ie && (is_ie3 || is_ie4 ));
	var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
	var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
	var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

	// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
	// or if this is the first browser window opened.  Thus the
	// variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
	var is_aol   = (agt.indexOf("aol") != -1);
	var is_aol3  = (is_aol && is_ie3);
	var is_aol4  = (is_aol && is_ie4);
	var is_aol5  = (agt.indexOf("aol 5") != -1);
	var is_aol6  = (agt.indexOf("aol 6") != -1);

	var is_opera = (agt.indexOf("opera") != -1);
	var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
	var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
	var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
	var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
	var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);

	var is_webtv = (agt.indexOf("webtv") != -1); 

	var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
	var is_AOLTV = is_TVNavigator;

	var is_hotjava = (agt.indexOf("hotjava") != -1);
	var is_hotjava3 = (is_hotjava && (is_major == 3));
	var is_hotjava3up = (is_hotjava && (is_major >= 3));
	var ctlID;
function init() 
	{
		//eraseCookie('rdccookie');
		var x = readCookie('rdccookie');
		var mainmode = document.getElementById? document.getElementById(ctlID): document.all? document.all[ctlID]: null;
		var xArrow = document.getElementById? document.getElementById("xlgnArrow"): document.all? document.all["xlgnArrow"]: null;
		if (mainmode.innerHTML == "1") 
		{
			showhide('globalLoginContent', 'globalLoginExpanded');
			xArrow.style.display = "none"; 
		}
		else if (x==1)
		{
			showhideExpand('globalLoginContent', 'globalLoginExpanded');
		}

		var oLB = document.getElementById? document.getElementById("globalLoginExpanded"): document.all? document.all["globalLoginExpanded"]: null;

		if (oLB.style.display == "none") {
			document.getElementById("OnlineID").select();
			document.getElementById("OnlineID").focus();
		}
	}		
	
	function isJavaEnabled(pnlJEnabled, pnlJDisabled)
	{
			{
			if (document.getElementById)
				{ 
				obj1 = document.getElementById(pnlJEnabled); 
				obj2 = document.getElementById(pnlJDisabled); 
				if (window.navigator.javaEnabled())
					{ 
					obj1.style.display = ""; 
					obj2.style.display = "none"; 
					}
				else 
					{
					obj1.style.display = "none;"; 
					obj2.style.display = ""; 
					} 
				} 
			}
	} 
			
		function showhide(eID1, eID2)
			{
			if (document.getElementById)
				{ 
				obj = document.getElementById(eID1); 
				obj1 = document.getElementById(eID2); 
				if (obj.style.display == "none")
					{ 
					obj.style.display = ""; 
					obj1.style.display = "none"; 
					}
				else 
					{
					obj.style.display = "none"; 
					obj1.style.display = ""; 
					} 
				} 
			} 

		function showhideExpand(eID1, eID2)
			{
        createCookie('rdccookie',1,365);
				showhide(eID1, eID2); 
			} 
			
		function showhideCollapce(eID1, eID2)
			{
        createCookie('rdccookie',0,365);
				showhide(eID1, eID2); 
			} 

		function showhideOS(eID)
			{
			if (document.getElementById)
				{ 
				obj = document.getElementById(eID); 
				if (obj.style.display == "none")
					{ 
					obj.style.display = ""; 
					}
				else 
					{
					obj.style.display = "none"; 
					} 
				} 
			} 
		
		function searchCK(btn,event) {
			if (event.keyCode == 13) {
				event.returnValue=false;
				event.cancel = true;
				googleSubmit();
			}
		}

		function loginCK(btn,event) 
			{
			if (event.keyCode == 13) 
				{
				event.returnValue=false;
				event.cancel = true;
        createCookie('rdccookie',0,365);
				loginSubmit();
				}
			}

		function loginXXCK(btn,event) 
			{
			if (event.keyCode == 13) 
				{
				event.returnValue=false;
				event.cancel = true;
        createCookie('rdccookie',1,365);
				loginXXSubmit();
				}
			}

		function branchCK(btn,event) {
			if (event.keyCode == 13) {
				event.returnValue=false;
				event.cancel = true;
				branchSubmit();
			}
		}
		/************************ Functions to display the appropriate fields for username/password entry ******************/
		var dom = document.getElementById && !document.all;
		var pwField;
		var dummyField;

		function getFields()
		{
			pwField = !dom ? document.all[ "Password" ] : document.getElementById( "Password" );
			dummyField = !dom ? document.all[ "dummyPassword" ] : document.getElementById("dummyPassword");
		}

		function focusPasswordField()
		{
			getFields();
			pwField.style.display = "";
			pwField.focus();
			pwField.select();
			dummyField.style.display = "none";
		}

		function showDummyField()
		{
			getFields();
			if( pwField.value == '' )
			{
				pwField.style.display = "none";
				dummyField.style.display = "";
			}
		}

function loadMedia(divID, width, height, medialoaderFilename, mediaFilename, mediaLoadDelay, altFilename, altURL, requestScheme)
{
	browsername=navigator.userAgent;
	//alert(browsername.indexOf("Safari")!=-1);
	if (browsername.indexOf("Safari")!=-1) {browsername="Safari"}
	else {browsername="other"};
	
	if (browsername!="Safari"){
	var d = document.getElementById(divID);
	objText = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+ requestScheme +'"://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + width + '" height="' + height +'">'
		+ '<param name="movie" value="' + medialoaderFilename + '" />'
		+ '<param name="quality" value="high" />'
		+ '<param name="wmode" value="transparent" />'
		+ '<param name="Flashvars" value="mainAd=' + mediaFilename + '&timer=' + mediaLoadDelay + '" />'
		+ '<embed src="' + medialoaderFilename + '" width="' + width + '" height="' + height + '" quality="high" pluginspage="'+ requestScheme +'://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" flashvars="mainAd=' + mediaFilename + '&timer=' + mediaLoadDelay + '" wmode="transparent"></embed>'
		+ '</object>';
		d.innerHTML = objText;
		} else {
		var d = document.getElementById(divID);
		title='';
		objText = '<a href="' + altURL +'" title="' + title + '"><img src="' + altFilename + '" alt="' + title + '" width="' + width + '" height="' + height + '" border="0" /></a>';
//		objText = '<a href="' + altURL +'"><img src="' + altFilename + '" width="' + width + '" height="' + height + '" border="0" /></a>';
		//alert(objText);
		d.innerHTML = objText;
		}
}
function loadMediaImg(divID, width, height, medialoaderFilename, mediaFilename, mediaLoadDelay, title)
{
	var d = document.getElementById(divID);

	objText = '<img src="' + mediaFilename + '" alt="' + title + '" width="' + width + '" height="' + height + '" border="0" />';

	d.innerHTML = objText;

}
function loadMediaImg_wHRef(divID, width, height, medialoaderFilename, mediaFilename, mediaLoadDelay, href, title, target)
{
	var d = document.getElementById(divID);

	objText = '<a href="' + href +'" title="' + title + '" target="' + target +'"><img src="' + mediaFilename + '" alt="' + title + '" width="' + width + '" height="' + height + '" border="0" /></a>';

	d.innerHTML = objText;

}
function disclosure(theURL,winName,features,disclosure) {
  window.open(theURL+'?dis='+disclosure,winName,features);
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {createCookie(name,"",-1);}

function resetLogin()
{
	var	userField = !dom ? document.all[ "OnlineID" ] : document.getElementById( "OnlineID" );
	if (userField.value == '') {
	userField.value = 'Enter Login ID'
	}
}
function loadContentMedia(divID, width, height, medialoaderFilename, mediaFilename, mediaLoadDelay, altFilename, title)
{
 var d = document.getElementById(divID);
 objText = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + width + '" height="' + height +'">'
  + '<param name="movie" value="' + medialoaderFilename + '" />'
  + '<param name="quality" value="high" />'
  + '<param name="wmode" value="transparent" />'
  + '<param name="Flashvars" value="mainAd=' + mediaFilename + '&timer=' + mediaLoadDelay + '" />'
  + '<embed src="' + medialoaderFilename + '" width="' + width + '" height="' + height + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" flashvars="mainAd=' + mediaFilename + '&timer=' + mediaLoadDelay + '" wmode="transparent"></embed>'
  + '</object>';
  d.innerHTML = objText;
}

	function loginSubmit()
	{
	var onlineID = document.forms[0].OnlineID.value
	var onlinePW = document.forms[0].Password.value
	if ((onlineID == "") || (onlinePW == "")){
		//alert("Please enter proper credentials to logon to Internet Banking");
		alert("Please enter proper credentials to logon to Internet Banking");
		document.forms[0].OnlineID.focus();
		return;
	}
	else {
		document.forms[0].action='https://securebank.regions.com/login.aspx?brand=regions';
		document.forms[0].elements['__VIEWSTATE'].value='';
		document.forms[0].elements['__VIEWSTATE'].name='ignore';

		if(is_nav2 || is_nav3 || is_nav4 || is_ie5down || is_firefox0) 
			{ 
				window.location = 'http://www.regions.com/system/unsupportedbrowser.rf';
			} 
			else 
			{
				document.forms[0].submit();
			}
		}
	}

function loginXXSubmit()
{
	var onlineID = document.forms[0].xOnlineID.value
	var onlinePW = document.forms[0].xPassword.value
	if ((onlineID == "") || (onlinePW == "")){
		alert("Please enter proper credentials to logon to Internet Banking");
		document.forms[0].OnlineID.focus();
		return;
	}
	else {
		document.forms[0].OnlineID.value = document.forms[0].xOnlineID.value;
		document.forms[0].Password.value = document.forms[0].xPassword.value;
		document.forms[0].action='https://securebank.regions.com/login.aspx?brand=regions';
		document.forms[0].elements['__VIEWSTATE'].value='';
		document.forms[0].elements['__VIEWSTATE'].name='ignore';
		
		if(is_nav2 || is_nav3 || is_nav4 || is_ie5down || is_firefox0) 
			{ 
				window.location = 'http://www.regions.com/system/unsupportedbrowser.rf';
		} 
		else 
		{
				document.forms[0].submit();
		}
	}
}
