function gebi(id)
{
	return document.getElementById(id);
}

function addEvent(obj, evt, fn)
{
	if (obj.addEventListener)
		obj.addEventListener(evt, fn, false);
	else if (obj.attachEvent)
		obj.attachEvent('on'+evt, fn);
	else
		obj['on'+evt] = fn;
}

function removeEvent(obj, evt, fn)
{
	if (obj.removeEventListener)
		obj.removeEventListener(evt, fn, false);
	else if (obj.detachEvent)
		obj.detachEvent('on'+evt, fn);
	else
		obj['on'+evt] = null;
}

Function.prototype.partial = function(/* 0..n args */)
{
	var func=this;
	var args = Array.prototype.slice.call(arguments);
	return function()
	{
		var allArguments = args.concat(Array.prototype.slice.call(arguments));
		return func.apply(this, allArguments);
	};
}

Function.prototype.bind = function(object /*, 0..n args */)
{
	var method = this;
	var args = Array.prototype.slice.apply(arguments).slice.apply(arguments, [1]); 
	return function()
	{
		return method.apply(object, args);
	}; 
}

Array.prototype.in_array = function(p_val)
{
	for(var i=0, l=this.length; i < l; i++)
	{
		if(this[i] == p_val)
			return true;
	}
	return false;
}

document.getElementsByClassName = function(className)
{
	var classes = className.split(' ');
	var classesToCheck = '';
	var returnElements = [];
	var match, node, elements;
	
	if (document.evaluate)
	{    
		var xhtmlNamespace = 'http://www.w3.org/1999/xhtml';
		var namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace:null;
		
		for(var j=0, jl=classes.length; j<jl;j+=1)
			classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]"; 
		
		try
		{
			elements = document.evaluate(".//*" + classesToCheck, document, namespaceResolver, 0, null);
		}
		catch(err)
		{
			elements = document.evaluate(".//*" + classesToCheck, document, null, 0, null);
		}

		while((match = elements.iterateNext()))
			returnElements.push(match);
	}
	else
	{
		classesToCheck = [];
		elements = (document.all) ? document.all : document.getElementsByTagName("*");

		for (var k=0, kl=classes.length; k<kl; k+=1)
			classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));

		for (var l=0, ll=elements.length; l<ll;l+=1)
		{
			node = elements[l];
			match = false;
			for (var m=0, ml=classesToCheck.length; m<ml; m+=1)
			{
				match = classesToCheck[m].test(node.className);
				if (!match) break;
			}
			if (match) returnElements.push(node);
		} 
	}
	return returnElements;
}

function getAvailWidthHeight()
{
	var w = 0, h = 0;
	if(typeof(window.innerWidth) == 'number') //Non-IE
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	else if(window.document.documentElement && (window.document.documentElement.clientWidth || window.document.documentElement.clientHeight)) //IE 6+ in strict mode
	{
		w = window.document.documentElement.clientWidth;
		h = window.document.documentElement.clientHeight;
	}
	else if(window.document.body && (window.document.body.clientWidth || window.document.body.clientHeight)) //IE 4 compatible
	{
		w = window.document.body.clientWidth;
		h = window.document.body.clientHeight;
	}
	
	return {
		'w': parseInt(w),
		'h': parseInt(h)
	};
}

function setCookie(cookieName, value, expireminutes)
{
	var expDate=new Date();
	expDate.setMinutes(expDate.getMinutes()+expireminutes);
	document.cookie=cookieName+'='+escape(value)+((expireminutes==null) ? '' : ';expires='+expDate.toGMTString());
}

function getCookie(cookieName, defaultVal)
{
	if(document.cookie.length > 0)
	{
		start=document.cookie.indexOf(cookieName+'=');
		if(start != -1)
		{
			start+=(cookieName.length+1); 
			end=document.cookie.indexOf(";",start);
			if(end == -1)
				end=document.cookie.length;
			return unescape(document.cookie.substring(start, end));
		}
	}
	return defaultVal;
}

function confirmSecureConnect()
{
	return confirm("This will connect you to another secure site.  Would you like to continue?");
}

function confirmThirdPartySite() {
    return confirm("By accessing the selected link you will be leaving First Guaranty Bank's website and entering a website hosted by another party.\n\nPlease be advised that you will no longer be subject to, or under the protection of, the privacy and security policies of the First Guaranty Bank website. We encourage you to read and evaluate the privacy and security policies on the site you are entering, which may be different than those of First Guaranty Bank.\n\nWould you like to continue?");
}
