//alert("Beginning of file");

// Ask the user if they are sure that they want to delete a record
// the parameter, tierId, is a variable which holds an INT so it does not need quotes
function deleteCheck() {
	//var name = document.getElementById(tierId).innerHTML;
	var deleteOK = confirm("Are you sure you want to DELETE this item from the database?");
	if (deleteOK == true) {
		return true;
	}
	else {
		return false;
	}
}


/* Dustin Diaz's getElementByClass function
** and his $() function to capture an ID and a class 
********************************************************/
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
/*******************************************************/


/*	
********************************************************/

this.blankwin = function() {
	var emaillink = false;
	var hostname = window.location.hostname;
	//alert("Hostname: "+hostname);
	hostname = hostname.replace("www.", "").toLowerCase();
	var a = document.getElementsByTagName("a");
	this.check = function(obj) {
		var href = obj.href.toLowerCase();
		//alert(href.indexOf("server"));
		if (href.indexOf("kids") == 30 || href.indexOf("dyob") == 33 || href.indexOf("trivia") == 45 || href.indexOf("learn") == 26 || href.indexOf("usmint") == 11 || href.indexOf("cowboy") == 32 || href.indexOf("disney") == 7 || href.indexOf("usfa") == 11 || href.indexOf("whitehouse") == 11 || href.indexOf("pbskids") == 7 || href.indexOf("nga") == 11 || href.indexOf("students") == 36) {
			//alert("HTTP Kids Page: "+href);
			return false;
		}				
		else if (href.indexOf("http://") == 0 && href.indexOf(hostname) == -1) {
			//alert("Normal external site and not test.fabtn.com: "+href);
			return true;
		}		
		else if (href.indexOf("server29") == 8 || href.indexOf("server14") == 8 || href.indexOf("xpressdeposit") == 8) {
			//alert("HTTPS BANK LOGIN site: "+href);
			return false;
		}
		else if (href.indexOf("https://") == 0) {
			//alert("HTTPS external non-bank site: "+href);
			return true;			
		}
		
		// determine if email link is present
		else if (href.indexOf("mailto") == 0) {
			//alert("HTTPS external non-bank site: "+href);
			emaillink = true;
			return true;			
		}
		
		else {
			return false;
		}		
		//return ((href.indexOf("http://") != -1/* || href.indexOf("https://") != -1*/) && href.indexOf(hostname) == -1 ? true : false);
	};
	this.set = function(obj) {
		//var href = obj.href;
		//YAHOO.util.Event.addListener(href, "click", thisexitNotice);
		if (emaillink == true && obj.className == "mailto") {
			obj.onclick = function() {return emailNotice()};
		}
		else {
			obj.onclick = function() {return exitNotice()};
		}
		//obj.target = "_blank";
		obj.className = obj.className + " blank";
	};
	for (var i=0; i < a.length; i++) {
		if (check(a[i])) {
			set(a[i]);
		}
	};
};

//window.onload = blankwin;
YAHOO.util.Event.addListener(window, "load", blankwin);

// onclick external link notice
function exitNotice() {
	if(confirm(
	//"You are now leaving the Bank's web site.  \n\n" +
	"To leave our site for the link selected, click \'OK\'.  \n\n" +
	"To remain at our site, click \'Cancel\'.  \n\n" +
	"Thank you for visiting fabtn.com."))
	{
		return true;
	}
	history.go(0);
	return false;	
}

// onclick email notice
function emailNotice() {
	var link = "<a href=\"\">Internet Banking.</a>";
	if(confirm(
	//"You are now leaving the Bank's web site.  \n\n" +
	"Please do not include personal or financial information in this email.  \n\n" +
	"To send a secure message to First Alliance Bank, log in to Internet Banking.  \n\n"))
	{
		return true;
	}
	history.go(0);
	return false;	
}

//First Alliance Bank does not control, " +
//	"guarantee or endorse other web sites or their privacy policies.

/*	window.history.go() - browser back button functionality
********************************************************/

var findBackbtn = {
	
	init : function() {
		YAHOO.util.Event.addListener(['backbtn1', 'backbtn2'], "click", this.goBack);
	},

	goBack : function(e) {
		window.history.go(-1);
		YAHOO.util.Event.stopEvent(e);	// stop the default behavior of following the link
	}
}


function nowFindBackbtn() {
	findBackbtn.init();
}


YAHOO.util.Event.addListener(window, "load", nowFindBackbtn);


/*	search input box text
********************************************************/

var searchPlay = {
	s : Object,
	orig : '',
	init : function() {
		this.s = $('s');
		this.orig = this.s.defaultValue;
		YAHOO.util.Event.addListener(this.s,'focus',this.focus);
		YAHOO.util.Event.addListener(this.s,'blur',this.blur);
	},
	focus : function() {
		if ( this.value == searchPlay.orig ) {
			this.value = '';
			//this.className = 'focus';
		}
	},
	blur : function() {
		if ( this.value == '' ) {
			this.value = searchPlay.orig;
		}
	}
};

/*
var searchPlay = {
	s : Object,
	orig : '',
	init : function() {
		this.s = $('s');
		this.orig = this.s.style.backgroundImage;
		if (this.value != '') {
			this.s.style.backgrounImage = 'none';
		}
		//alert("page loaded");
		//this.orig = this.s.defaultValue;
		YAHOO.util.Event.addListener(this.s,'focus',this.focus);
		YAHOO.util.Event.addListener(this.s,'blur',this.blur);
	},
	focus : function() {
		if ( this.style.backgroundImage == searchPlay.orig ) {
		//if ( this.style.backgroundImage == searchPlay.orig ) {

			this.style.backgroundImage = 'none';
			
		}
	},
	blur : function() {
		if (this.value == '') {
			this.style.backgroundImage = searchPlay.orig;
		}
		//else {
		//	this.style.backgroundImage = 'none';
		//}
	}
};
*/

function pageListen() {
  searchPlay.init();
}
//addEvent(window,'load',pageListen);
YAHOO.util.Event.addListener(window,"load",pageListen);


// Clear the text in an input box by selecting it (focus)
// Restore the text by clicking somewhere else (blur)

//function clearText(el) {
//	if (el.defaultValue == el.value) {
//		el.value = "";
//	}
//}

//function restoreText(el) {
//	if (el.value == "") {
//		el.value = el.defaultValue;		
//	}		
//}

//function init() {	
//	var searchbox = document.getElementById('searchbox');
//	YAHOO.util.Event.addListener(searchbox, 'click', clearText);
//}

//searchbox.innerHTML = "Search www.fabtn.com";

//YAHOO.util.Event.addListener(window, "load", init);



//var hideShowText = {
//	clearText : function(el) {
//		if (el.value == "") {
//			el.value = el.defaultValue;		
//		}
//	},
//	init : function() {
//		YAHOO.util.Event.addListener("searchbox", "click", clearText);
//	}

//}


//function nowToggleText() {
//	hideShowText.init();
//}


//YAHOO.util.Event.addListener(window, "load", nowToggleText);

