// JavaScript Document

/* Please note - this code is not meant to be clever; it is meant to be easy to understand. Those who enjoy writing a program in one line - well done! */
	
		//attach an event listener, with a specified function, to an element 
		function jsfAttachEvent(obj,evt,fnc)
		{
			if(window.addEventListener)
			{
				obj.addEventListener(evt, fnc, false);
			}
			else if(window.attachEvent)
			{
				obj.attachEvent('on'+evt, fnc);
			}
			else if (obj.getElementById && evt=='load')
			{
				obj.onload = fnc;
			}
		}
		//add the onload event
		//jsfAttachEvent(window,'load',jsfOnLoad);
		
		function dropDownToggle(event)
		{
			if( myObjDropDownMenu.eleToShow.className == myObjDropDownMenu.cssClassHide )
			{
				setShowState();
				if( event.preventDefault )
				{
					event.preventDefault();//need this for Firefox. Without it the input element will not get focus.
				}
			}
			else
			{
				setHideState();
			}
			return false;
		}
		function setShowState()
		{
			//show the appropriate element
			myObjDropDownMenu.eleToShow.className = myObjDropDownMenu.cssClassShow;
			myObjDropDownMenu.eleToGainFocus.focus();//give the input field the focus			
			myObjDropDownMenu.eleMainLink.className = myObjDropDownMenu.cssClassAnchorSelected;
			myObjDropDownMenu.eleMainLink.title = myObjDropDownMenu.toolTipHide;
			myObjDropDownMenu.eleControlContainer.style.width = myObjDropDownMenu.cssWidthHackShow;
		}
		function setHideState()
		{
			myObjDropDownMenu.eleToShow.className = myObjDropDownMenu.cssClassHide;
			myObjDropDownMenu.eleMainLink.className = myObjDropDownMenu.cssClassAnchor;
			myObjDropDownMenu.eleMainLink.title = myObjDropDownMenu.toolTipShow;	
			myObjDropDownMenu.eleControlContainer.style.width = myObjDropDownMenu.cssWidthHackHide;
		}
		function ObjDropDownMenu( eleIdControlContainer, eleIdToShow, eleIdToGainFocus, cssClassShow, cssClassHide, toolTipShow, toolTipHide, cssClassAnchor, cssClassAnchorSelected, cssWidthHackShow, cssWidthHackHide )
		{
			//assign attributes
			this.eleIdControlContainer = eleIdControlContainer;
			this.eleIdToShow = eleIdToShow;
			this.eleIdToGainFocus = eleIdToGainFocus;
			this.cssClassShow = cssClassShow;
			this.cssClassHide = cssClassHide;
			this.toolTipShow = toolTipShow;
			this.toolTipHide = toolTipHide;
			this.cssClassAnchor = cssClassAnchor;
			this.cssClassAnchorSelected = cssClassAnchorSelected;
			this.cssWidthHackShow = cssWidthHackShow;/* Required for Safari and IE 5.01 */
			this.cssWidthHackHide = cssWidthHackHide;/* Required for Safari and IE 5.01 */
			
			//initialise some more attributes
			this.eleControlContainer = document.getElementById( this.eleIdControlContainer );
			this.eleMainLink = this.eleControlContainer.getElementsByTagName( "A" )[0];
			this.eleToShow = document.getElementById( this.eleIdToShow );
			this.eleToGainFocus = document.getElementById( this.eleIdToGainFocus );
			
			//configure the elements we now have a reference to
			jsfAttachEvent( this.eleMainLink, "click", dropDownToggle );
			this.eleMainLink.href = "#" + this.eleIdControlContainer;
		}
		
		//global variables
		var myObjDropDownMenu;

		function jsfOnLoad()
		{
			if( document.getElementById )//only start the process if the browser supports the DOM
			{
				if( document.getElementById( "loginToggle" ) )//make sure the right element is within the document to start with!
				{
					//create a new drop down
					myObjDropDownMenu = new ObjDropDownMenu( "loginToggle", "loginPanel", "tbUsername", "loginPanel", "offScreenDisplay", "Shows the login panel", "Hides the login panel", "clientLogin", "clientLoginSelected", "148px", "86px" );
				}
			}
		}


document.getElementsByClassName = function(className,nodeToSearch,tagName)
{
	var arrMatchedElements = [];
		 
	if(nodeToSearch==null || nodeToSearch=="")
		nodeToSearch=document;	
		
	arrElementsToSearchWithin = nodeToSearch.getElementsByTagName(tagName);
	
	for(var nElementCount=0; nElementCount < arrElementsToSearchWithin.length; nElementCount++)
	{
		if(arrElementsToSearchWithin[nElementCount].className.match("(^|\\s)"+className+"(\\s|$)"))
			arrMatchedElements.push(arrElementsToSearchWithin[nElementCount]);	
	}
	return arrMatchedElements;
};

/* finds all tags of "targetBlank" class and adds target='blank' behvaiour - maintins XHTML validity */
function targetBlankXHTMLFix()
{
	 
	var arrAnchors = document.getElementsByClassName("targetBlank",document,"a")
	
	for(var anchorCount=0; anchorCount < arrAnchors.length; anchorCount++)
	{
		arrAnchors[anchorCount].target='_blank';
	}
}

function omniTrack(obj)
{
	var s=s_gi('hwallprod');
	s.linkTrackEvents='event1';
	s.events='event1';
	s.tl(this,'o');

}