//This requires the mootools.js classes in order to function

//for code cleanliness, this class that handle the accordion tabs are in this file
//make sure to always keep the include line to this file at the bottom of the .php file
//TD
	
	accordionInit = function(){ //safari cannot get style if window isnt fully loaded
		var stretchers = getElementsByClassName(document, 'accordion', "");
			stretchers.each(function(item){
				item.setStyles({'height': '0', 'overflow': 'hidden'});
			});
		
		var togglers = getElementsByClassName(document, 'toggler', "");
		
		var bgFx = [];
		
		togglers.each(function(toggler, i){
			toggler.defaultColor = toggler.getStyle('background-color');
			
			//fx creation
			bgFx[i] = new Fx.Color(toggler, 'background-color', {wait: false});
		});
	
		var myAccordion = new Fx.Accordion(togglers, stretchers, { opacity: false, start: false, transition: Fx.Transitions.quadOut,
			
			onActive: function(toggler, i){
				bgFx[i].toColor('#d8d8d8');
				toggler.getFirst().setStyles({'color':'#666666', 'font-size': '1.1em', 'font-weight': 'bold', 'background': 'url(/i/products/orange_on.jpg) repeat-y top left', 'padding': '7px 0 0 15px', 'text-decoration': 'none', 'display': 'block', 'height': '30px', '_height': '25px'});
			},
		
			onBackground: function(toggler, i){
				bgFx[i].clearTimer();
				toggler.setStyle('background', toggler.defaultColor);
				toggler.getFirst().setStyles({'color': '#4d8abe', 'font-size': '1.1em', 'font-weight': 'normal', 'display': 'block', 'text-decoration': 'none', 'height': '30px', '_height': '25px', 'padding': '7px 0 0 15px', '-moz-outline-style': 'none', 'background': 'transparent'});
			}
		});
		
		//anchors
		function checkHash(){
			var found = false;
			var toggler = getElementsByClassName(document, 'toggler', "a");
			toggler.each(function(link, i){
				if (window.location.hash.test(link.hash)){
					myAccordion.showThisHideOpen(i);
					found = true;
				}
			});
			return found;
		}

		if (!checkHash()) myAccordion.showThisHideOpen(0);

	};
	
	try {
		Window.disableImageCache();
	}catch(e){}
	
	function getElementsByClassName(node, classname, tag)
	{
	    var a = [];
	    var re = new RegExp('\\b' + classname + '\\b');
	    var els = node.getElementsByTagName("*");
	    for(var i=0,j=els.length; i<j; i++)
	        if(re.test(els[i].className)) {
				if(tag != "") temp = els[i].getElementsByTagName(tag)[0];
				else temp = els[i];
				temp.extend = Object.extend;
				temp.extend(Element.prototype);
				a.push(temp);
			}
	    return a;
	}