var categories = null;
var sections = null;

var MultipleOpenAccordion=Fx.Elements.extend({options:{openAll:true,allowMultipleOpen:true,firstElementsOpen:[0],start:'open-first',fixedHeight:false,fixedWidth:false,alwaysHide:true,wait:false,onActive:Class.empty,onBackground:Class.empty,height:true,opacity:true,width:false},initialize:function(togglers,elements,options){this.parent(elements,options);this.setOptions(options);this.previousClick=null;this.elementsVisible=[];togglers.each(function(tog,i){$(tog).addEvent('click',function(){this.toggleSection(i)}.bind(this))},this);this.togglers=togglers;this.h={};this.w={};this.o={};this.now=[];this.elements.each(function(el,i){el=$(el);this.now[i]={};el.setStyle('overflow','hidden');if(!(this.options.openAll&&this.options.allowMultipleOpen))el.setStyle('height',0)},this);if(!this.options.openAll||!this.options.allowMultipleOpen){switch(this.options.start){case'first-open':this.showSection(this.options.firstElementsOpen[0]);break;case'open-first':this.toggleSection(this.options.firstElementsOpen[0]);break}}if(this.options.openAll&&this.options.allowMultipleOpen)this.showAll();else if(this.options.allowMultipleOpen)this.openSections(this.options.firstElementsOpen)},hideThis:function(i){this.elementsVisible[i]=false;if(this.options.height)this.h={'height':[this.elements[i].offsetHeight,0]};if(this.options.width)this.w={'width':[this.elements[i].offsetWidth,0]};if(this.options.opacity)this.o={'opacity':[this.now[i]['opacity']||1,0]};this.fireEvent("onBackground",[this.togglers[i],this.elements[i]])},showThis:function(i){this.elementsVisible[i]=true;if(this.options.height)this.h={'height':[this.elements[i].offsetHeight,this.options.fixedHeight||this.elements[i].scrollHeight]};if(this.options.width)this.w={'width':[this.elements[i].offsetWidth,this.options.fixedWidth||this.elements[i].scrollWidth]};if(this.options.opacity)this.o={'opacity':[this.now[i]['opacity']||0,1]};this.fireEvent("onActive",[this.togglers[i],this.elements[i]])},toggleSection:function(iToToggle){if(iToToggle!=this.previousClick||this.options.alwaysHide||this.options.allowMultipleOpen){this.previousClick=iToToggle;var objObjs={};var err=false;this.elements.each(function(el,i){var update=false;this.now[i]=this.now[i]||{};if(i==iToToggle){if(this.elementsVisible[i]&&(this.options.allowMultipleOpen||this.options.alwaysHide)){if(!(this.options.wait&&this.timer)){update=true;this.hideThis(i)}else{this.previousClick=null;err=true}}else if(!this.elementsVisible[i]){if(!(this.options.wait&&this.timer)){update=true;this.showThis(i)}else{this.previousClick=null;err=true}}}else if(this.elementsVisible[i]&&!this.options.allowMultipleOpen){if(!(this.options.wait&&this.timer)){update=true;this.hideThis(i)}else{this.previousClick=null;err=true}}if(update)objObjs[i]=$merge(this.h,$merge(this.o,this.w))},this);if(err)return false;return this.custom(objObjs)}return false},showSection:function(i,useFx){if($pick(useFx,false)){if(!this.elementsVisible[i])this.toggleSection(i)}else{this.setSectionStyle(i,$(this.elements[i]).scrollWidth,$(this.elements[i]).scrollHeight,1);this.elementsVisible[i]=true;this.fireEvent("onActive",[this.togglers[i],this.elements[i]])}},hideSection:function(i,useFx){if($pick(useFx,false)){if(this.elementsVisible[i])this.toggleSection(i)}else{this.setSectionStyle(i,0,0,0);this.elementsVisible[i]=false;this.fireEvent("onBackground",[this.togglers[i],this.elements[i]])}},setSectionStyle:function(i,w,h,o){if(this.options.opacity)$(this.elements[i]).setOpacity(o);if(this.options.height)$(this.elements[i]).setStyle('height',h+'px');if(this.options.width)$(this.elements[i]).setStyle('width',w+'px')},showAll:function(){if(this.options.allowMultipleOpen){this.elements.each(function(el,idx){this.showSection(idx,false)},this)}},hideAll:function(){if(this.options.allowMultipleOpen){this.elements.each(function(el,idx){this.hideSection(idx,false)},this)}},openSections:function(sections){if(this.options.allowMultipleOpen){this.elements.each(function(el,idx){if(sections.test(idx))this.showSection(idx,false);else this.hideSection(idx,false)},this)}}});MultipleOpenAccordion.implement(new Options);MultipleOpenAccordion.implement(new Events);

function getVar(get){
	v=location.search.substring(1, location.search.length).split('&');
	getVars = new Array();

	v.each(function(x){
	 var temp = x.split('=');
	 getVars[temp[0]] = temp[1];
	});
	return getVars[get];
}

function WA80X(){
	$$('.tx-rgslideshow-pi1 img')[0].onclick = function(){ window.location = 'index.php?id=760&L='+getVar('L'); }	
	$$('.tx-rgslideshow-pi1 img')[0].style.cursor = 'pointer';		
}

function showroom(){
	categories=new Accordion($$('h1.categoryTitle'),$$('div.categoryContent'),{opacity:0,alwaysHide:true,start:'all-close',onActive:function(toggler){toggler.addClass('active')},onBackground:function(toggler){toggler.removeClass('active')},onComplete:function(){var el=$(this.elements[this.previous]);if(el.offsetHeight>0)el.setStyle('height','')}});

	
	sections=new MultipleOpenAccordion($$('h2.sectionTitle'),$$('div.sectionContent'),{opacity:0,alwaysHide:true,openAll:false,start:'all-close',firstElementsOpen:new Array(),onActive:function(toggler){toggler.addClass('active')},onBackground:function(toggler){toggler.removeClass('active')}});var Tips1=new Tips($$('.tooltip'));

if($('more')){
var myFx = new Fx.Slide('more', {
    duration: 1000,
    transition: Fx.Transitions.Pow.easeOut
});
myFx.hide(); 
$('showless').style.display = 'none'; 
//Toggles between slideIn and slideOut twice:
$('showmore').onclick = function(){ myFx.slideIn(); this.style.display = 'none'; $('showless').style.display = 'inline'; } 
$('showless').onclick = function(){ myFx.slideOut(); this.style.display = 'none'; $('showmore').style.display = 'inline'; } 
}

} 
window.addEvent('domready', showroom);