
/////////////////////////////////////////////////////////////////////////////
// Nav Functions

var strTopNavOn = '';
var strSubNavOn = '';
var intMouseOn = 0;

function topNavOn (objNav, intSwap) {
	intMouseOn = 1;

	// Swap out Top Nav image if required
	if (strTopNavOn != '') document.images[strTopNavOn].src = 'Cobrander/DFCUFinancial/Custom/' + strTopNavOn + ".gif";
	if (intSwap == 1) {
		strTopNavOn = String(objNav.id);
		document.images[strTopNavOn].src = 'Cobrander/DFCUFinancial/Custom/' + strTopNavOn + '_ro.gif';
	}
	else
		strTopNavOn = '';

	// Swap out visible Sub Nav if required
	if (strSubNavOn != '')	document.getElementById(strSubNavOn).style.visibility = 'hidden';
	strSubNavOn = 'sub' + String(objNav.id);
	if (document.getElementById(strSubNavOn)) {
		document.getElementById(strSubNavOn).style.visibility = 'visible';
	}
	else
		strSubNavOn = '';

}

function topNavOff (strID) {
	intMouseOn = 0;
	setTimeout('checkOff()', 250);
}


function subNavOn () {
	intMouseOn = 1;
}


function subNavOff () {
	intMouseOn = 0;
	setTimeout('checkOff()', 250);
}


function checkOff () {
	if (!intMouseOn) {
		if (strTopNavOn != '') document.images[strTopNavOn].src = 'Cobrander/DFCUFinancial/Custom/' + strTopNavOn + ".gif";
		if (strSubNavOn != '') {
			document.getElementById(strSubNavOn).style.visibility = 'hidden';
		}
	}
}


/////////////////////////////////////////////////////////////////////////////
// Search Functions

function searchClick()
{
	var strTerms = document.getElementById('textSearch').value;

	if (strTerms != '')
		window.location = 'http://www.dfcufinancial.com/site/search_results.asp?terms=' + escape(strTerms);
	else
		alert('Please enter your search terms');
}

function searchKeyPress(e, objText)
{
	var strTerms = objText.value;

	if (getKey(e) == 13) {
		stopBubbling(e);
		if (strTerms != '') {
			window.location = 'http://www.dfcufinancial.com/site/search_results.asp?terms=' + escape(strTerms);
			return false;
		}
		else {
			alert('Please enter your search terms');
			return false;
		}
	}
	else
		return true;
}

function searchClickCMS()
{
	var strTerms = document.getElementById('textSearch').value;

	if (strTerms != '')
		window.location = 'http://www.dfcufinancial.com/site/search.htm?terms=' + escape(strTerms);
	else
		alert('Please enter your search terms');
}

function searchKeyPressCMS(e, objText)
{
	var strTerms = objText.value;

	if (getKey(e) == 13) {
		stopBubbling(e);
		if (strTerms != '') {
			window.location = 'http://www.dfcufinancial.com/site/search.htm?terms=' + escape(strTerms);
			return false;
		}
		else {
			alert('Please enter your search terms');
			return false;
		}
	}
	else
		return true;
}

function getKey(e)
{
	if (window.event)
		return window.event.keyCode;
	else if (e)
		return e.which;
	else
		return null;
}

function stopBubbling(e)
{
	if(window.event && window.event.cancelBubble != null)
		window.event.cancelBubble = true;
	else if(e && e.stopPropogation)
		e.stopPropogation();
}	


/////////////////////////////////////////////////////////////////////////////
// Ugly hack to get IE to make bottom cell fill 100% of the left column 
// below the left nav area (Mozilla and Opera work fine without this)

function setHeight()
{
     ht1 = document.getElementById('main').offsetHeight - document.getElementById('left').offsetHeight;
     ht2 = document.getElementById('hack').offsetHeight;
     if (ht2 < ht1)
	     document.getElementById('hack').style.height = ht1 +'px';
}


/////////////////////////////////////////////////////////////////////////////
// Link Functions

function linkOut(strURL)
{
	if (strURL.length < 5)
		return;
	if (strURL.indexOf('http://') == -1 && strURL.indexOf('https://'))
		strURL = 'http://' + strURL;
	if (confirm('You are about to open a window to a third party web site.\r\n\r\nDFCU Financial is not responsible for the content of the third party web site.\r\nDFCU does not represent either the third party or the user if the two parties enter into a transaction.\r\nPrivacy and security policies may differ from those practiced by DFCU Financial.\r\n\r\nDo you wish to continue?'))
		window.open(strURL, 'PrintWindow', 'height=600,width=800,location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes');
}

function linkTools(strURL)
{
	window.open(strURL);
}


/////////////////////////////////////////////////////////////////////////////
// Print Functions

function printWindow()
{
	window.open('http://www.dfcufinancial.com/DFCU/includes/html/print.htm', 'PrintWindow', 'height=650,width=775,location=yes,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=no');
}


/////////////////////////////////////////////////////////////////////////////
// Learn More Functions

function selectLearnMore(objList)
{
	if (objList.selectedIndex > 0)
		window.location = objList.options[objList.selectedIndex].value;
}


/////////////////////////////////////////////////////////////////////////////
// Validation Functions

function isNumberKey(evt)
{
    var charCode = (evt.which) ? evt.which : event.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57))
	    return false;

    return true;
}
  

/////////////////////////////////////////////////////////////////////////////
// Contact Form Functions

function sendToContactHandler()
{
	document.forms[0].method = "post";
	document.forms[0].action = "http://www.dfcufinancial.com/site/contact_handler.asp";
	document.forms[0].submit();
}


/////////////////////////////////////////////////////////////////////////////
// DFCU Online Functions

function dfcuOnlineLogin()
{
	if (document.getElementById('UserName').value.trim() == '') {
		alert('Please enter your DFCU Member Number');
		return;
	}
	document.forms["HomePage"].method = "post";
	document.forms["HomePage"].action = "https://www.epersonal-banking.com/bharosauio/login2.do";
	document.forms["HomePage"].submit();
}

function dfcuOnlineEnterSubmit(evt) 
{
    var charCode = (evt.which) ? evt.which : event.keyCode;
	if (charCode == 13)
		dfcuOnlineLogin();
	else
		return true;
}

String.prototype.trim = function() {
	var x = this;

	x=x.replace(/^\s*(.*)/, "$1");
	x=x.replace(/(.*?)\s*$/, "$1");
	return x;
}

