// JavaScript Document
// Select-Box Navigation v1.0

var parentCats = document.getElementById('parentCats');
var tempArray = new Array();
for(var i=0; i<parentCats.length; i++)
{
	tempArray[i] = new Array();
	tempArray[i] = parentCats.options[i].text + ',' + parentCats.options[i].value;
}

tempArray.sort();

for(var i=0; i<parentCats.length; i++)
{
	parentCats.options[i] = new Option(tempArray[i].split(',')[0], tempArray[i].split(',')[1]);
}

var activeSubSel  		= null;

for(var i=0; i<parentCats.options.length; i++)
{
	if(document.getElementById('childof').innerHTML == parentCats.options[i].value)
	{
		document.getElementById('dummySelect').style.display = 'none';
		parentCats.options[i].selected = true;
		var tag	= 'cats-lvl-' + i;
		activeSubSel  	= document.getElementById(tag);
		activeSubSel.onchange = function()
		{
 if(this.options[this.selectedIndex].value != 'void')
 {
 document.getElementById('jumpAnchor').href = '/c-' + this.options[this.selectedIndex].value; + '.html'
 document.getElementById('jumpAnchor').style.cursor		= 'pointer';
 }
 else
 {
 document.getElementById('jumpAnchor').href = '/c-' + parentCats.options[parentCats.selectedIndex].value; + '.html'
 }
		}
		activeSubSel.className = 'show';
		for(var x=0; x<activeSubSel.options.length; x++)
		{
 if(document.getElementById('currentCategory').innerHTML == activeSubSel.options[x].value)
 {
 activeSubSel.options[x].selected = true;
 document.getElementById('jumpAnchor').href = '/c-' + activeSubSel.options[activeSubSel.selectedIndex].value; + '.html'
 document.getElementById('jumpAnchor').style.cursor		= 'pointer';
 }
		}
		document.getElementById('jumpAnchor').href = '/c-' + activeSubSel.options[activeSubSel.selectedIndex].value; + '.html'
		document.getElementById('jumpAnchor').style.cursor = 'pointer';
	}
	else if(document.getElementById('currentCategory').innerHTML == parentCats.options[i].value)
	{
		document.getElementById('dummySelect').style.display = 'none';
		parentCats.options[i].selected = true;
		var tag = 'cats-lvl-' + i;
		activeSubSel  	= document.getElementById(tag);
		activeSubSel.onchange = function()
		{
 if(this.options[this.selectedIndex].value != 'void')
 {
 document.getElementById('jumpAnchor').href = '/c-' + this.options[this.selectedIndex].value; + '.html'
 document.getElementById('jumpAnchor').style.cursor = 'pointer';
 }
 else
 {
 document.getElementById('jumpAnchor').href = '/c-' + parentCats.options[parentCats.selectedIndex].value; + '.html'
 }
		}
		activeSubSel.className = 'show';
		for(var x=0; x<activeSubSel.options.length; x++)
		{
 if(document.getElementById('currentCategory').innerHTML == activeSubSel.options[x].value)
 {
 activeSubSel.options[x].selected = true;
 }
		}
		document.getElementById('jumpAnchor').href = '/c-' + parentCats.options[parentCats.selectedIndex].value; + '.html'
		document.getElementById('jumpAnchor').style.cursor = 'pointer';
	}
}

parentCats.onchange = function()
{
	if(this.selectedIndex != 0)
	{

		if(activeSubSel)
		{
 activeSubSel.className = 'hidden_cat';
 activeSubSel = null;
		}

		if(this.options[this.selectedIndex].value != 'void')
		{
 document.getElementById('jumpAnchor').href = '/c-' + this.options[this.selectedIndex].value; + '.html'
 document.getElementById('jumpAnchor').style.cursor = 'pointer';
		}
		else
		{
 document.getElementById('jumpAnchor').href = 'javascript:void(0);';
 document.getElementById('jumpAnchor').style.cursor = 'default';
		}

		var tag2 = 'cats-lvl-' + this.selectedIndex;
		activeSubSel = document.getElementById(tag2);

		activeSubSel.onchange = function()
		{
 if(this.options[this.selectedIndex].value != 'void')
 {
 document.getElementById('jumpAnchor').href = '/c-' + this.options[this.selectedIndex].value; + '.html'
 document.getElementById('jumpAnchor').style.cursor = 'pointer';
 }
 else
 {
 document.getElementById('jumpAnchor').href = '/c-' + parentCats.options[parentCats.selectedIndex].value; + '.html'
 }
		}
		document.getElementById('dummySelect').style.display = 'none';
		activeSubSel.className = 'show';
	}
	else
	{
		if(activeSubSel)
		{
 activeSubSel.className = 'hidden';
 activeSubSel = null;
		}
		document.getElementById('dummySelect').style.display = 'inline';
	}
}

