/* ================================================================ 
This copyright notice must be untouched at all times.

The original version of this script and the associated (x)html
is available at http://www.stunicholls.com/various/tabbed_pages.html
Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
This script and the associated (x)html may be modified in any 
way to fit your requirements.
=================================================================== */


function dropdowntabbedpages()
{	
	var e, i = 0;
	//alert(document.getElementById('dropdown-wrapper'));
	if(document.getElementById('dropdown-wrapper') != null)
	{
	while (e = document.getElementById('dropdown-wrapper').getElementsByTagName ('DIV') [i++]) 
	{		
		if (e.className == 'on' || e.className == 'off') 
		{
			e.onclick = function () 
			{				
				if (document.getElementById('content-container') != null)
					var main = document.getElementById('content-container');
				if (document.getElementById('contentcontainer') != null)
					var main = document.getElementById('contentcontainer');
				var getEls = main.getElementsByTagName('div');
				max = this.getAttribute('title');
				if(document.getElementById(max) == null)
				{
					for (var z=0; z<getEls.length; z++) 
					{
						getEls[z].className=getEls[z].className.replace('on', 'off');
						getEls[z].className=getEls[z].className.replace('hide', 'show');
					}					
				} else {
					for (var z=0; z<getEls.length; z++) 
					{
						getEls[z].className=getEls[z].className.replace('show', 'hide');
						getEls[z].className=getEls[z].className.replace('on', 'off');
					}
					document.getElementById(max).className = "show";
				}
				this.className = 'on';		
				$(".viewby").text(max);
				var jp = $( ".viewby" );
				jp.css( "font-weight", 800 );					
			}
			if(window.location.href.indexOf("#")!= -1)
			{			
				var bookmark = window.location.href.substr(window.location.href.lastIndexOf("#")+1,window.location.href.length); 
				
				if(bookmark != "")
				{
					max = bookmark.replace(/%20/g, ' ');
				} else {
					max = "All";
				}
				if (document.getElementById('content-container') != null)
					var main = document.getElementById('content-container');
				if (document.getElementById('contentcontainer') != null)
					var main = document.getElementById('contentcontainer');
				var getEls = main.getElementsByTagName('div');
				for (var z=0; z<getEls.length; z++) 
				{
					getEls[z].className=getEls[z].className.replace('show', 'hide');
					getEls[z].className=getEls[z].className.replace('on', 'off');
				}
				this.className = 'on';
				if(document.getElementById(max) == null)
					max = "All";
					
				document.getElementById(max).className = "show";
				$(".viewby").text(max);
				var jp = $( ".viewby" );
				jp.css( "font-weight", 800 );							

			}					
		}
	}
	} else {
		if(window.location.href.indexOf("#")!= -1)
					{			
						var bookmark = window.location.href.substr(window.location.href.lastIndexOf("#")+1,window.location.href.length); 
						
						if(bookmark != "")
						{
							max = bookmark.replace(/%20/g, ' ');
						} else {
							max = "All";
						}
						if (document.getElementById('content-container') != null)
							var main = document.getElementById('content-container');
						if (document.getElementById('contentcontainer') != null)
							var main = document.getElementById('contentcontainer');
						var getEls = main.getElementsByTagName('div');
						for (var z=0; z<getEls.length; z++) 
						{
							getEls[z].className=getEls[z].className.replace('show', 'hide');
							getEls[z].className=getEls[z].className.replace('on', 'off');
						}
						this.className = 'on';
						if(document.getElementById(max) == null)
							max = "All";
							
						document.getElementById(max).className = "show";
						$(".viewby").text(max);
						var jp = $( ".viewby" );
						jp.css( "font-weight", 800 );				
				}	
	
	}
}

function redirect(h){
	window.location = h;
}