// JavaScript Document

function popUp(theURL) {
  window.open(theURL,'popUp','width=400,height=400,scrollbars=yes');
}

function popUpDemo(theURL) {
  window.open(theURL,'demo','width=640,height=480,toolbar=no,location=no,scrollbars=no,resizable=no');
}

function popUpOutgoing(theURL) {
  window.open(theURL,'outgoing','width=750,height=500,toolbar=yes,location=yes,scrollbars=yes,resizable=yes');
}

function popUpSurvey(theURL) {
  window.open(theURL,'survey','width=800,height=600,toolbar=no,location=no,scrollbars=yes,resizable=yes');
}

function jumpMenu(targ,selObj,restore) {
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

function breakFrames() {
	if (top != self.parent) {top.location = self.parent.location;}
}

// Start onlyAlpha function
function onlyAlpha(t) {
  t.value = t.value.replace(/[^A-Z- ]/gi,'');
}
// End onlyAlpha Function

// Start onlyEMailChars function
function onlyEMailChars(t) {
  t.value = t.value.replace(/[^A-Z0-9-.@]/gi,'');
}
// End onlyEMailChars function

// Start onlyNumeric function
function onlyNumeric(t) {
  if (t.value.match(/[^\d]/gi)) t.value = t.value.replace(/[^\d]/gi,'');
}
// End onlyNumeric function

// Start onlyAlphaNumeric function
function onlyAlphaNumeric(t) {
  t.value = t.value.replace(/[^A-Z0-9 ]/gi,'');
}
// End onlyAlphaNumeric function

// Start onlyNumericDecimal function
function onlyNumericDecimal(t) {
  t.value = t.value.replace(/[^0-9.]/gi,'');
}
// End onlyNumericDecimal function

// Start getPageName function
function getPageName() {
	var pageName = document.title;
	if (pageName == "America First Credit Union :: Mortgage Loans, Home Equity Loans, Checking, Savings, Credit Cards") {pageName = "Home Page";}
	else {pageName = pageName.slice(30);}
	return pageName;
}
// End getPageName function

// Start getPageName function
function getCalcPageName() {
	var calcPageName = document.title;
	calcPageName = calcPageName.slice(52);
	return calcPageName;
}
// End getPageName function

function redirectAddress(address){
		window.location.href="" + address;
}

//if 1 is passed it is shown, if 0 is passed it is hidden
function showHide(a, passedID) {
	if (!document.getElementById) return;
		obj=document.getElementById(passedID);
	if (a) obj.style.display="";
	else obj.style.display="none";
}

function setTimeOfDay(){
 	var today = new Date();
 	//0-23
 	var hour = today.getHours();
	var defaultText = "noscript";
	if(!hour){
		return defaultText;
	}
	else{
		return hour;
	}
}

function getCookie(Name)
{
	var Argument;
	var ArgumetLength;
	var CookieLength;
	var EndString;
	var i;
	var j;
	
	Argument = Name + "=";
	ArgumentLength = Argument.length;
	CookieLength = document.cookie.length;
	i = 0;
	while (i < CookieLength)
	{
		j = i + ArgumentLength;
		if (document.cookie.substring(i, j) == Argument)
		{
			EndString = document.cookie.indexOf (";", j);
			if (EndString == -1)
			EndString = document.cookie.length;
			return unescape(document.cookie.substring(j, EndString));
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
			break;
	}
	return "";
}