function wDropdown(){
	
	/*#################################
	## Private Properties            ##
	#################################*/
	this.__container = null;
	this.__primaryLinks = new Array();
	
	this.__trackingIndex = null;
	this.__trackingInterval = null;

	this.__activateAnchorCallback = null;
	this.__deactivateAnchorCallback = null;
	
	/*#################################
	## Public Properties             ##
	#################################*/
	this.accents = false;
};
wDropdown.prototype = {

	/** -----------------------------------------------------------
	 * Constructor
	* -----------------------------------------------------------
	*/
	main: function(el) {
		this.__container = document.getElementById(el)
		if (this.__container){
			this.initData();
			this.initObjects();
		}else{
			this.calert("Must supply a valid id attribute.");
		}
	},
	
	
	initData: function(){
	
		//--------------------------------------------
		//Primary Links
		//--------------------------------------------
		var nodes = this.__container.childNodes;
		var nodeCount = nodes.length;
		
		for (var i=0; i<nodeCount; i++){
			if (nodes[i].nodeName.toLowerCase() == "li"){
				
				//--------------------------------------------
				//Secondary Links
				//--------------------------------------------
				var secondaryNodeCount = 0;
				nodes[i].childLinks = new Array();
				var secondaryNodes = nodes[i].getElementsByTagName('ul');
				
				//links found, lets delve deeper
				if (secondaryNodes.length>0){
					secondaryNodes = secondaryNodes[0].childNodes;
					secondaryNodeCount = secondaryNodes.length;
					
					for (var x=0; x<secondaryNodeCount; x++){
						if (secondaryNodes[x].nodeName.toLowerCase() == "li"){
							
							//--------------------------------------------
							//Triple Links
							//--------------------------------------------
							var tripleNodeCount = 0;
							secondaryNodes[x].childLinks = new Array();
							var tripleNodes = secondaryNodes[x].getElementsByTagName('ul');
							
							//links found, lets take note and wrap it up
							if (tripleNodes.length>0){
								tripleNodes = tripleNodes[0].childNodes;
								tripleNodeCount = tripleNodes.length;
								
								for (var y=0; y<tripleNodeCount; y++){
									if (tripleNodes[y].nodeName.toLowerCase() == "li"){
										
										secondaryNodes[x].childLinks.push( tripleNodes[y] );
										//console.info("i: "+i+" - x: "+x+" - y: "+y);
									}
								}
							}
							nodes[i].childLinks.push( secondaryNodes[x] );
						}//endif
					}//endfor
				}
				this.__primaryLinks.push( nodes[i] );
			}//endif
		}//endfor
	},
	
	initObjects: function(){
		
		//References
		var c = this.__container;
		
		//--------------------------------------------
		//Primary Links
		//--------------------------------------------
		var nodeCount = this.__primaryLinks.length;
		for (var i=0; i<nodeCount; i++)
		{
			
			var currLink = this.__primaryLinks[i];
			var currLinkTripleLinkFound = false; //Determines if we have found the first secondary link that has children.
			
			//Properties
			currLink._index = i;
			currLink._class = this;
			
			//Events
			currLink.onmouseover = this.onPrimaryLinkOver;
			currLink.onmouseout  = this.onPrimaryLinkOut;
			currLink.setChildLinkActive = this.onPrimary_setChildLinkActive;
			
			//--------------------------------------------
			//Secondary Links
			//--------------------------------------------
			var secondaryNodeCount = currLink.childLinks.length;
			for (var x=0; x<secondaryNodeCount; x++)
			{
				
				var currSecondaryLink = currLink.childLinks[x];
				
				//Properties
				currSecondaryLink._index = x;
				currSecondaryLink._class = this;
				currSecondaryLink._parentLink = currLink;
				
				//Events
				currSecondaryLink.onmouseover = this.onSecondaryLinkOver;
				currSecondaryLink.onmouseout  = this.onSecondaryLinkOut;
				currSecondaryLink.onmouseup   = this.onSecondaryLinkUp;
				
				if (currSecondaryLink.childLinks.length>0){ //nullify the link IF it has children
					currSecondaryLink.onclick = function(){ return false; };
					
					if (!currLinkTripleLinkFound){
						currLinkTripleLinkFound = true;
						//currSecondaryLink.getElementsByTagName('ul')[0].style.display = "block";
						//currSecondaryLink.getElementsByTagName('a')[0].className = "active";
					}
				}else{
					currSecondaryLink.getElementsByTagName('a')[0].style.backgroundImage = "none";
				}
				
				
				//--------------------------------------------
				//Triple Links
				//--------------------------------------------
				var tripleNodeCount = currSecondaryLink.childLinks.length;
				for (var y=0; y<tripleNodeCount; y++)
				{
					
					var currTripleLink = currSecondaryLink.childLinks[y];
					
					//Properties
					currTripleLink._index = y;
					currTripleLink._parentLink = currSecondaryLink;
					
					//Events
					currTripleLink.onmouseup = function(){ 
						var anchor = this.getElementsByTagName('a')[0];
						
						if (anchor.target=="_blank") window.open(anchor.href);
						else window.location = anchor.href;
					};
				}
			}
		}
	},
	
	/** -----------------------------------------------------------
	 * Private methods
	* -----------------------------------------------------------
	*/
	setPrimaryLinkListActive: function(index){
		
		
		var linkCount = this.__primaryLinks.length;
		for (var i=0; i<linkCount; i++)
		{
			var currLink = this.__primaryLinks[i];
			var currSecondaryList = currLink.getElementsByTagName('ul')[0];
			
			if (currSecondaryList) //only if it has a secondary list
			{
				if (i==index){
					addClassName(currLink, 'active', true);
					currSecondaryList.style.display = "block";
					
					if (this.accents)
					{
						//Visual Adjustments
						if (i<linkCount-1){
							//this.__primaryLinks[i+1].getElementsByTagName('a')[0].style.backgroundColor = "#CCC";/* = "-1px center";*/
						}
					}
					
				}else{
					removeClassName(currLink, 'active');
					currSecondaryList.style.display = "none";
					
					if (this.accents)
					{
						//Visual Adjustments
						//this.__primaryLinks[i+1].getElementsByTagName('a')[0].style.backgroundColor = "#900";/*"0px center";*/
					}
				}
			}
			
		}
	},
	/*#################################
	## Timer                         ##
	#################################*/
	checkTracking: function(scope){
		scope.stopTracking();
		scope.setPrimaryLinkListActive( null );
	},
	
	startTracking: function(index){
		this.stopTracking();
		this.__trackingIndex = index;
		
		//use closure to properly pass scope through all browsers ;)
		var localScope = this;
		var checkTracking = function(){
			localScope.checkTracking(localScope);
		};
		
		this.__trackingInterval = setInterval(checkTracking, 300);
	},
	stopTracking: function(){
		this.__trackingIndex = null;
		clearInterval( this.__trackingInterval );
	},
	resetTracking: function(index){
		this.stopTracking();
		this.startTracking(index);
	},
	
	/*#################################
	## Events                        ##
	#################################*/
	//Primary Links
	onPrimaryLinkOver: function(){
		this._class.stopTracking();
		this._class.setPrimaryLinkListActive( this._index );
	},
	onPrimaryLinkOut: function(){
		this._class.startTracking( this._index );
	},
	onPrimary_setChildLinkActive: function(index){
		//alert("primary link set"+index);
		
		//Only collapse a menu if the pressed button actually contains another level of links
		if (index==null || this.childLinks[index].childLinks.length>0)
		{
			var childCount = this.childLinks.length;
			for (var x=0; x<childCount; x++)
			{
				var currLink = this.childLinks[x];
				if (x==index){
					//Display list
					if (currLink.childLinks.length>0){
						currLink._active = true;
						currLink.getElementsByTagName('ul')[0].style.display = "block";
						currLink.getElementsByTagName('a')[0].className = "active";
					}
				}else{
					//Hide List if there is one
					if (currLink.childLinks.length>0){
						currLink._active = false;
						currLink.getElementsByTagName('ul')[0].style.display = "none";
						currLink.getElementsByTagName('a')[0].className = "";
					}
				}
			}
		}
	},
	
	//Secondary Links
	onSecondaryLinkOver: function(){
		//console.info("secondarylinkover");
		this._class.stopTracking();
		//console.info("parent: "+this._parentLink._index+" - index: "+this._index);
		
	},
	onSecondaryLinkOut: function(){
		this._class.startTracking( this._parentLink._index );
		//console.info("secondarylinkout");
	},
	onSecondaryLinkUp: function(){
		
		var targetIndex = (this._active==true) ? null : this._index;
		this._parentLink.setChildLinkActive( targetIndex );
	},
	
	/*#################################
	## Debugging / Error Reporting   ##
	#################################*/
	calert: function(str){
		alert("wDropdown:// "+str);
	},
	ctrace: function(str){
		console.info("wDropdown:// "+str);
	}
	
};



/** -----------------------------------------------------------
 * Initialization Functions
* -----------------------------------------------------------
*/

function mailHeader_init(){
	var mailDropdown = new wDropdown();
	mailDropdown.accents = true;
	mailDropdown.main('mailDropdownNavigation'); //Initialize Dropdown menu
	
	
};



/** -----------------------------------------------------------
 * Misc. Functions
* -----------------------------------------------------------
*/
function addClassName(objElement, strClass, blnMayAlreadyExist){
	
	// if there is a class
	if ( objElement.className ){

		// the classes are just a space separated list, so first get the list
		var arrList = objElement.className.split(' ');

		// if the new class name may already exist in list
		if ( blnMayAlreadyExist ){

		   // get uppercase class for comparison purposes
		   var strClassUpper = strClass.toUpperCase();

		   // find all instances and remove them
		   for ( var i = 0; i < arrList.length; i++ ){

		      // if class found
		      if ( arrList[i].toUpperCase() == strClassUpper )
		         {

		         // remove array item
		         arrList.splice(i, 1);

		         // decrement loop counter as we have adjusted the array's contents
		         i--;
		         }
		      }
		   }

		// add the new class to end of list
		arrList[arrList.length] = strClass;

		// add the new class to beginning of list
		//arrList.splice(0, 0, strClass);

		// assign modified class name attribute
		objElement.className = arrList.join(' ');

	}// if there was no class
	else{
		// assign modified class name attribute      
		objElement.className = strClass;
	}
};

function removeClassName(objElement, strClass){

	// if there is a class
	if ( objElement.className ){

    	// the classes are just a space separated list, so first get the list
    	var arrList = objElement.className.split(' ');

    	// get uppercase class for comparison purposes
    	var strClassUpper = strClass.toUpperCase();

    	// find all instances and remove them
    	for ( var i = 0; i < arrList.length; i++ ){

			// if class found
			if ( arrList[i].toUpperCase() == strClassUpper ){

			   // remove array item
			   arrList.splice(i, 1);

			   // decrement loop counter as we have adjusted the array's contents
			   i--;
		   }
		}

	    // assign modified class name attribute
	    objElement.className = arrList.join(' ');

    }
	// if there was no class
	// there is nothing to remove
};

// Site Search Validation Script
function mailHeader_valForm2()
{
	var searchfield = document.getElementById('mailSearchField');
	if(searchfield.value=='') 
	{
		alert('You must enter search criteria.\nPlease try again.');
		searchfield.focus();
		return false;
	}
	return true;
};


// Adds event to window.onload without overwriting currently 
// assigned onload functions.
function AddOnload(myfunc)
{
	if(window.addEventListener)
	window.addEventListener('load', myfunc, false);
	else if(window.attachEvent)
	window.attachEvent('onload', myfunc);
}
AddOnload( mailHeader_init );