// Common javascript functions
function goOnline(url) {
	// Added by Jim Huenergardt 04/15/04
	// This takes the value of the community dropdown listbox and 'jumps' to that page.
	// It's for the login of the online banking.
//		OpenScrollablePopUp('onlinebankingnotice.php',473,450);
	//window.open('https://peoples-onlinebank.com/cs70_banking/logon/user?a=defaultaffiliate');
	var winOnlineBanking = window.open(url, 'OnlineBanking', 'menubar=1, location=1, directories=1, toolbar=1, resizable=1, scrollbars=1');
}

function menuOn(sTabName) {
	if (document.getElementById(sTabName + '_container')) {
		dropdownDeactivate();
		dropdownActivate(sTabName);
	} else {
		dropdownDeactivate();
		
		if (document.getElementById(sTabName + '_cell')) document.getElementById(sTabName + '_cell').className = 'menulinkOn';
		if (document.getElementById(sTabName + '_link')) document.getElementById(sTabName + '_link').className = 'menulinkOn';
	}
}

function menuOff(sTabName) {
	if (!document.getElementById(sTabName + '_container')) {
		if (document.getElementById(sTabName + '_cell')) document.getElementById(sTabName + '_cell').className = 'menulinkOff';
		if (document.getElementById(sTabName + '_link')) document.getElementById(sTabName + '_link').className = 'menulinkOff';
	}
}

var strDropDownOn = '';
function dropdownActivate(sTabName) {
	if (document.getElementById(sTabName + '_cell')) document.getElementById(sTabName + '_cell').className = 'menulinkOn';
	if (document.getElementById(sTabName + '_link')) document.getElementById(sTabName + '_link').className = 'menulinkOn';

	if (document.getElementById(sTabName + '_container')) document.getElementById(sTabName + '_container').style.display = 'block';
	
	for (var r = 1; r < 10; r++) 
	{
		if (document.getElementById(sTabName + '_' + r.toString() + '_cell')) document.getElementById(sTabName + '_' + r.toString() + '_cell').className = 'dropdownOff';
		if (document.getElementById(sTabName + '_' + r.toString() + '_link')) document.getElementById(sTabName + '_' + r.toString() + '_link').className = 'dropdownOff';
		if (!document.getElementById(sTabName + '_' + r.toString() + '_cell') && 
			!document.getElementById(sTabName + '_' + r.toString() + '_link')) break;
	}
	strDropDownOn = sTabName;
}

function dropdownDeactivate() {
	if (strDropDownOn != '') {
		sTabName = strDropDownOn;

		if (document.getElementById(sTabName + '_container')) document.getElementById(sTabName + '_container').style.display = 'none';

		for (var r = 1; r < 10; r++) 
		{
			if (document.getElementById(sTabName + '_' + r + '_cell')) document.getElementById(sTabName + '_' + r + '_cell').className = 'dropdownRemove';
			if (document.getElementById(sTabName + '_' + r + '_link')) document.getElementById(sTabName + '_' + r + '_link').className = 'dropdownRemove';
			if (!document.getElementById(sTabName + '_' + r + '_cell') && 
				!document.getElementById(sTabName + '_' + r + '_link')) break;
		}
		if (document.getElementById(sTabName + '_cell')) document.getElementById(sTabName + '_cell').className = 'menulinkOff';
		if (document.getElementById(sTabName + '_link')) document.getElementById(sTabName + '_link').className = 'menulinkOff';
		strDropDownOn = '';
	}
}

function dropOn(sDropDownItem) {
	if (document.getElementById(sDropDownItem + '_cell')) document.getElementById(sDropDownItem + '_cell').className = 'dropdownOn';
	if (document.getElementById(sDropDownItem + '_link')) document.getElementById(sDropDownItem + '_link').className = 'dropdownOn';
}

function dropOff(sDropDownItem) {
	if (document.getElementById(sDropDownItem + '_cell')) document.getElementById(sDropDownItem + '_cell').className = 'dropdownOff';
	if (document.getElementById(sDropDownItem + '_link')) document.getElementById(sDropDownItem + '_link').className = 'dropdownOff';
}

var intDefaultPopUpWidth = 590;
var intDefaultPopUpHeight = 450;
function OpenPopUp(strURL, intPopUpWidth, intPopUpHeight) {
	var reURL = /^([^\.\/\\]*)\.[^\.]*$/;
	var strWinName
	if (reURL.test(strURL)) {
		aryURL = reURL.exec(strURL);
		strWinName = aryURL[1];
	} else {
		strWinName = 'newWin';
	}
	var intX = parseInt((screen.width - intPopUpWidth) / 2);
	var intY = parseInt((screen.height - intPopUpHeight) / 2);
	var strWinAttrib = 	'width=' + intPopUpWidth + ',height=' + intPopUpHeight + ',menubar=no,toolbar=no,scrollbars=no,resizable=no,top=' + intY + ',left=' + intX;
	window.open(strURL, strWinName, strWinAttrib);
}

function OpenScrollablePopUp(strURL, intPopUpWidth, intPopUpHeight) {
	var reURL = /^([^\.\/\\]*)\.[^\.]*$/;
	var strWinName
	if (reURL.test(strURL)) {
		aryURL = reURL.exec(strURL);
		strWinName = aryURL[1];
	} else {
		strWinName = 'newWin';
	}
	var intX = parseInt((screen.width - intPopUpWidth) / 2);
	var intY = parseInt((screen.height - intPopUpHeight) / 2);
	var strWinAttrib = 	'width=' + intPopUpWidth + ',height=' + intPopUpHeight + ',menubar=no,toolbar=no,scrollbars=yes,resizable=no,top=' + intY + ',left=' + intX;
	window.open(strURL, strWinName, strWinAttrib);
}

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);
}
