/*******************************************************************************
	filename:		stac.js
	author:         Brent Newton
					http://ghoststationdesign.com
	system:         STAC
	version:		2.0
	date:			2005-02-19     
	overview:      
		This class contains javascript functions needed for optimum user interface interaction.

		externalLinks()
		autotab(origin, destination

*******************************************************************************/

	/*--------------------------------------------------------------------------
		function:	  
			externalLinks()

		preconditions:
			none

		postconditions:      
			XHTML STRICT safe external window links.  Add rel='external' to links to be affected.

	--------------------------------------------------------------------------*/
	function externalLinks() {
		if (!document.getElementsByTagName) return;
		
		var anchors = document.getElementsByTagName("a");
		
		for (var i=0; i<anchors.length; i++) {
			var anchor = anchors[i];
			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
				anchor.target = "_blank";
			}
		}
	}


	/*--------------------------------------------------------------------------
		function:	  
			autotab(origin,destination)

		preconditions:
			origin is a form element name
			destination is a form element name

		postconditions:      
			XHTML STRICT compliant way to shift the cursor from one text element to another.

	--------------------------------------------------------------------------*/
	function autotab(origin,destination){
		if (origin.getAttribute&&origin.value.length==origin.getAttribute("maxlength")){
			destination.focus();
		}
	}


	//run externalLinks function
	window.onload = externalLinks;