
/*
	// Installation //

	To install this script, just reference it somewhere in the head of the
	document. That's it -- no need for "onload" calls or anything.

	// Description and Syntax for Use //

	This automagically applies a disclaimer-triggering onclick event
	handler to links that have their "rel" attribute set to "external" or "email". Links
	which don't have a "rel" attribute or which have a "rel" attribute that's
	set to something other than "external" or "email" aren't affected.

	For example:

		<a rel="external" href="http://en.wikipedia.org/wiki/Mos_Eisley">Mos Eisley</a> or
		<a rel="email" href="mailto:leader@moseisley.com">leader@moseisley.com</a>

	// Current Version //
	
	2006-10-30 / JA - Added logic for handling email links

	// Previous Version //

	2006-10-25 / AB - original script
*/


var ExternalLinks =
{
	// (Be sure to put "\n\n" between paragraphs. Either way, this needs to remain as one long string.)
	disclaimerText : "Links to non-American State Bank Sites are provided solely as pointers to information on topics that may be useful to users of the American State Bank Sites, and American State Bank has no control over the content on such non-American State Bank Sites.\n\nIf you choose to link to a website not controlled by American State Bank, American State Bank makes no warranties, either express or implied, concerning the content of such site, including the accuracy, completeness, reliability or suitability thereof for any particular purpose, nor does American State Bank warrant that such site or content is free from any claims of copyright, trademark or other infringement of the rights of third parties or that such site or content is devoid of viruses or other contamination. \n\nAmerican State Bank does not guarantee the authenticity of documents on the Internet. Links to non-American State Bank sites do not imply any endorsement of or responsibility for the opinions, ideas, products, information or services offered at such sites, or any representation regarding the content at such sites.",
	
	emailDisclaimerText : "This email system is not on a secured Internet connection. It could be possible for others to view the information you send. Please do not send any confidential information via email such as your account number, social security number, or passwords, etc. The sender will not hold the bank liable for unauthorized interception or misuse of the e-mail.\n\nRemember, always question suspicious emails requesting personal information. Although American State Bank has not been specifically targeted, scams involving several other financial entities have occurred where an official-looking email is sent requesting personal or confidential information (account number, social security number, username, password, etc.) from the recipient or directs them to a website where users are encourage to enter personal or confidential information. Unless initiated by you, American State Bank will not request your personal information through email, U.S. mail, or by phone. And you should never share your password with anyone. Please use extreme caution when approached by anyone requesting personal and sensitive information.\n\nIf you have any concerns or questions or would prefer to conduct your business via phone, please contact our Servicio a Clientes Center at 806-767-7272 or 800-687-7272.",
	
	englishDisclaimerText : "La informaci\xF3n que se encuentra en esta pagina est\xE1 disponsible solamente en ingl\xE9s. Antes de escoger un producto o servicio, aseg\xFArese de haber le\xEDdo y entendido todos los t\xE9rminos y condiciones. Para continuar en ingl\xE9s, seleccione  aqui.",
	
	spanishExternal : "Los acoplamientos a los sitios que no son parte de ASB proporcionan solamente como indicadores a la informaci\xF3n en los asuntos que pueden ser \xFAtiles a los usuarios de los sitios de ASB, y ASB no tiene ningu\xEDn control sobre el contenido en tales sitios.\n\nSi usted elige conectar un sitio no controlado por ASB, ASB no hace ninguna garant\xEDa, expresa o implicada, referente el contenido de tal sitio, incluyendo la exactitud, lo completo, la confiabilidad o la conveniencia de eso para ningu\xEDn prop\xF3sito particular, ni hace la autorizaci\xF3n de ASB que tal sitio o contenido est\xE1 libre de cualquier demanda de los derechos reservados, marca registrada o a otra infracci\xF3n de los derechos de los terceros o que tal sitio o contenido es libre de virus o otra contaminaci\xF3n.\n\nASB no garantiza la autenticidad de documentos en el Internet. Los acoplamientos a los sitios que no son parte de ASB no implican ningu\xEDn endoso de o responsabilidad de las opiniones, las ideas, los productos, informaci\xF3n o los servicios ofrecidos en tales sitios, o ninguna representaci\xF3n con respecto al contenido de tales sitios.\n\nLa informaci\xF3n que se encuentra en esta pagina est\xE1 disponsible solamente en ingl\xE9s. Antes de escoger un producto o servicio, aseg\xFArese de haber le\xEDdo y entendido todos los t\xE9rminos y condiciones. Para continuar en ingl\xE9s, seleccione  aqui.",

	overloadedLinks : new Object,

	// Initialize
	initialize : function()
	{
		var _this = this; // Closure
		this.addEvent(window, "load", function() {
			_this.onload();
		});
	},

	// The initialize function sets this to run once the page has loaded
	onload : function()
	{
		this.applyLinkEventHandlers(document.getElementsByTagName("a"));
	},

	/* This applies link event handlers to anchors
		which are sent in that also have their "rel" attribute set to
		"external" */
	applyLinkEventHandlers : function(anchorElements)
	{
		for (var i = 0, len=anchorElements.length; i < len; i++)
		{
			var currentAnchor = anchorElements[i];

			/* If it doesn't have the "rel" attribute or if
				it has a blank "rel" attribute, skip it */
			if ((!currentAnchor.rel) || (!currentAnchor.rel.length))
			{
				currentAnchor = null; // avoid memory leaks
				continue;
			}

			if (currentAnchor.rel.toLowerCase() == "external" || currentAnchor.rel.toLowerCase() == "email" || currentAnchor.rel.toLowerCase() == "english" || currentAnchor.rel.toLowerCase() == "spexternal")
			{
				/* Check if an onclick event handler has already been
					assigned to the link and, if so, chain that together
					with the disclaimer function */

				if (typeof currentAnchor.onclick != 'function')
				{
					if (currentAnchor.rel.toLowerCase() == "email")
					{
						currentAnchor.onclick = function()
						{
							return (confirm(ExternalLinks.emailDisclaimerText));
						} // end of onclick-function
					}
					else
					if (currentAnchor.rel.toLowerCase() == "english")
					{
						currentAnchor.onclick = function()
						{
							return (confirm(ExternalLinks.englishDisclaimerText));
						} // end of onclick-function
					}
					else
					if (currentAnchor.rel.toLowerCase() == "spexternal")
					{
						currentAnchor.onclick = function()
						{
							return (confirm(ExternalLinks.spanishExternal));
						} // end of onclick-function
					}
					else
					{
						currentAnchor.onclick = function()
						{
							return (confirm(ExternalLinks.disclaimerText));
						} // end of onclick-function
					}
				}			
				else
				{
					ExternalLinks.overloadedLinks[currentAnchor.href] = currentAnchor.onclick;

					currentAnchor.onclick = function()
					{
						if (confirm(ExternalLinks.disclaimerText))
						{
							if (ExternalLinks.overloadedLinks[this.href])
							{
								return ExternalLinks.overloadedLinks[this.href](this);
							}
							return true;
						}
						else
						{
							return false;
						}
					} // end of onclick-function
				}

				// avoid memory leaks
				currentAnchor = null;
			}

		
			
		} // end of for loop

	},

	// Flexible JavaScript Events - John Resig
	// http://ejohn.org/projects/flexible-javascript-events/
	// ===========================================================================

	addEvent : function( obj, type, fn )
	{
		if (obj.addEventListener)
			obj.addEventListener( type, fn, false );
		else if (obj.attachEvent)
		{
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
			obj.attachEvent( "on"+type, obj[type+fn] );
		}
	},

	removeEvent : function( obj, type, fn )
	{
		if (obj.removeEventListener)
			obj.removeEventListener( type, fn, false );
		else if (obj.detachEvent)
		{
			obj.detachEvent( "on"+type, obj[type+fn] );
			obj[type+fn] = null;
			obj["e"+type+fn] = null;
		}
	}
}

// Kick off
ExternalLinks.initialize();