// Change class of clicked item and others in the set
	function changeClassSet(id,classDefault,classChange,setArray){
		if(document.getElementById) {
			var testObj = document.getElementById(id);
			// alert(testObj.className);
			
			if(testObj.className != classChange) { // Only change if not already changed
			
				var arrayLength;
				arrayLength = setArray.length;
		
				for (i=0;i<arrayLength;i++)
				{
					currentItem = setArray[i];
					var nodeObj = document.getElementById(currentItem);
		   			//alert(nodeObj.className+' '+classDefault+' '+classChange);
		  			var changeTo;
		   			changeTo = classDefault;
		   		
		   			if(currentItem !=null){
		   			if(currentItem != id) {
		   				//alert(currentItem);
		   				//if(nodeObj.className != classDefault) {
		    				nodeObj.className = classDefault;
		   				//} 
		   			} else { // CURRENT
		   				
		   				//if(nodeObj.className != classChange) {
		    				nodeObj.className = classChange;
		    			//}
		   			}
		   			}
		   			//alert("Classname="+document.getElementById(id).className);
		   		}
		   	}
		}
	} // END changeClassSet



// Change element class based on ID value
	function changeClass(id,classDefault,classChange){
		
		if (document.getElementById){
		   	var nodeObj = document.getElementById(id);
		   //alert(nodeObj.className+' '+classDefault+' '+classChange);
		  	var changeTo;
		   	changeTo = classDefault;
		   	if(nodeObj.className == classDefault) {
		    	changeTo = classChange;
		   	}
		   	nodeObj.className = changeTo;
		   	//alert("Classname="+document.getElementById(id).className);
		}
	} // END changeClass
	
	
	// Change element class based on ID value
	function hideAlert(id,classChange){
		
		if (document.getElementById){
		   	var nodeObj = document.getElementById(id);
		   //alert(nodeObj.className+' '+classDefault+' '+classChange);
		  	var changeTo;
		   	nodeObj.className = classChange;
		   	//alert("Classname="+document.getElementById(id).className);
		}
		return false;
	} // END changeClass
	
	
	
	
	// toggles up and down
	function foldDown(id,upClass,downClass)
	{
		 if (document.getElementById){
		   	// alert(id);
		   	var nodeObj = document.getElementById(id);
		
		 	if(nodeObj.className == upClass) {
			  nodeObj.className = downClass;
		 	} else {
				  nodeObj.className = upClass;
		 	}
		 }
	 }

	// build ID string for layer appropriate to browser DOM for changing display property
	function getElem(layerName) 
	{
		return document.all ? document.all(layerName).style :
		document.getElementById ? document.getElementById(layerName).style :
		document.layers ? document.layers[layerName] :
		null;
	}

// Show only (i.e. doesn't un-show on double-click)
function toggle(layerName, arrayName)
{
	
	// Get the correct id string
	currentLayer = layerName;
	var el = getElem(layerName);
	if (el.visibility == "visible" || el.visibility == "show") {
		// Already visible
		// alert('Already visible');
	} else {
		// alert('Make visible');
		el.position = "relative";
		el.visibility = "visible";
		el.left = 0;
		hideLayer(layerName, arrayName);
	}
}
 
// Hide other layers
function hideLayer(layerName, arrayName) 
{
	// array doesn't require quote marks in HTML onClick
	for (i=0;i<arrayName.length; i++){
		if (arrayName[i] != layerName) {
			var el = getElem(arrayName[i]);
			el.visibility = "hidden";
			el.position = "absolute";
			el.left = "-999px";
		}
	}
}


// TRANSPARENCY: SRC: http://brainerror.net/scripts/javascript/blendtrans/

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function addEvent(elm, evType, fn, useCapture) 
	{
		if (elm.addEventListener) {
			elm.addEventListener(evType, fn, useCapture);
			return true;
		} else if (elm.attachEvent) {
			var r = elm.attachEvent('on' + evType, fn);
			return r;
		} else {
			elm['on' + evType] = fn;
		}
		return undefined;
	} // End addEvent -----------------------------------------

	
	// parentID = ID of containing element
	// elementType = type of element to show/hide (selected by ID)
	// arrayName = the array to add elementType ID values to
	function jsBuildArrays(parentID,elementType,arrayName)
	{
		tempArray = new Array;
		
		var element = document.getElementById(parentID);
		tempArray = element.getElementsByTagName(elementType);
		
		count = tempArray.length;
		// alert(count);
		
		for(i=0;i<count;i++)
		{
			
			codeID = tempArray[i].id;
			if(codeID.length >= 2){
				//alert(codeID);
				arrayName[i] = codeID;
			}
		}
		return;
		
	} // END jsBuildArrays ------------------------------------------
	
	// Trigger when page has loaded
	addEvent(window,'load',jsBodyArrays,true);
	//addEvent(window,'load',testArrays,true);
	
	//alert('Java OK?');
	
	function subFeature(currentID,tabArray,featureArray)
	{
	
		//alert(currentID);
		
		if(currentID.indexOf("tab") >= 0) {
			trigger = currentID;
			feature = 'feature'+currentID.substring(3,currentID.length);
			// alert(trigger);
			// alert(feature);
		} 
		
		if(currentID.indexOf("feature") >= 0) {
			trigger = 'tab'+currentID.substring(7,currentID.length);
			feature = currentID;
		}
		
		if(currentID.indexOf("thumb") >= 0) {
			trigger = currentID;
			feature = 'view'+currentID.substring(5,currentID.length);
			//alert(trigger);
			//alert(feature);
		} 
		
		if(currentID.indexOf("pic") >= 0) {
			plusOne = currentID.substring(3,currentID.length);
			plusOne++;
			/*
			if(plusOne >= tabArray.length) {
				plusOne = 0;
			}
			*/
			trigger = 'tab'+plusOne
			feature = 'feature'+plusOne;
			// alert(trigger+' '+feature);
		}
		
		
		
		
		changeClassSet(trigger,'','current',tabArray);
		changeClassSet(feature,'','current',featureArray);
		// opacity(feature, 0, 99.999, 300);
	
	}
