/* ================================================================ 
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 TabFunction(GalleryName)
{
	var e, i = 0;
	while (e = document.getElementById(GalleryName).getElementsByTagName ('DIV') [i++]) 
	{
		if (e.className == 'on' || e.className == 'off') 
		{
			e.onclick = function () 
			{
			    var getEls = document.getElementsByTagName('DIV');
				for (var z=0; z<getEls.length; z++) {
					getEls[z].className=getEls[z].className.replace('tabshow', 'tabhide');
					getEls[z].className=getEls[z].className.replace('on', 'off');
				}
			    this.className = 'on';
			    var max = this.getAttribute('title');
			    document.getElementById(max).className = "tabshow";
			}
		}
	}
}
function addLoadEvent(func, GalleryName) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
		if (oldonload) {
			oldonload();
		}
		func(GalleryName);
	}
	}
}

function VariantDescriptionTabFunction(VariantID)
{
    ResetTabs();
	
	ActivateTab(VariantID);
	    
}

function ResetTabs()
{
    var e, i = 0;
	while (e = document.getElementsByTagName('DIV') [i++]) 
	{
		e.className = e.className.replace("on", "off");
		e.className = e.className.replace("tabshow", "tabhide");
	}
}

function ActivateTab(VariantID)
{
    var GalleryName = "gallery" + VariantID;
	var TabName = "tab1_" + VariantID;
	
	var e, i = 0;
	while (e = document.getElementById(GalleryName).getElementsByTagName ('DIV') [i++]) 
	{
		    var getEls = document.getElementsByTagName('DIV');
			for (var z=0; z<getEls.length; z++) 
			{
				if (getEls[z].getAttribute('title') == TabName)
				{
				    getEls[z].className= "on";
				}
				if (getEls[z].getAttribute('ID') == TabName)
				{
				    getEls[z].className= "tabshow";
				}
			}
	}
}