var acc = Class.create();
acc.prototype = {
	initialize: function() {
		this.animoption1 = {duration:.3,queue: {position:'end', scope: 'anim1',limit: 10 }};
		this.animoption2 = {duration:.3,queue: {position:'end', scope: 'anim2',limit: 10 }};
		this.allAccordeons=new Array();
		this.currentOpen=null;
		$$('.acc_lvl1').each(this.initBtn.bindAsEventListener(this));
	},
	start:function(){
		if(this.allAccordeons[0].next(0))
			this.allAccordeons[0].next(0).show();
		this.currentOpen=this.allAccordeons[0];
		if($$("#"+this.currentOpen.id+" img")[0])
			$$("#"+this.currentOpen.id+" img")[0].src="skins/images/long_tabbotton.jpg";
	},
	initBtn:function(o){
		var offset=this.allAccordeons.length;
		o.id="btnacclevel1_"+offset;
		o.style.cursor="pointer";
		o.observe('click', this.openacc.bindAsEventListener(this,offset));
		if(o.next(0)){
			o.next(0).id="btnacclevel2_"+offset;
			o.next(0).hide();
		}
		
		if($$("#btnacclevel1_"+offset+" img")[0])
			$$("#btnacclevel1_"+offset+" img")[0].src="skins/images/long_tabbotton1.jpg";
			
		this.allAccordeons.push(o);
		this.initLevel2(offset);
	
	},
	
	openacc:function(o,offset){
		this.closeacc();
		if(this.currentOpen!=this.allAccordeons[offset]){
			this.currentOpen=this.allAccordeons[offset];
			if($$("#"+this.currentOpen.id+" img")[0])
				$$("#"+this.currentOpen.id+" img")[0].src="skins/images/long_tabbotton.jpg";
			if(this.currentOpen.next(0))
				new Effect.BlindDown(this.currentOpen.next(0),this.animoption1);
		}else{
			this.currentOpen=null;
		}
	},
	closeacc:function(){
		if(this.currentOpen!=null){
			if($$("#"+this.currentOpen.id+" img")[0])
				$$("#"+this.currentOpen.id+" img")[0].src="skins/images/long_tabbotton1.jpg";
			if(this.currentOpen.next(0))
				new Effect.BlindUp(this.currentOpen.next(0),this.animoption1);
		}
	},
	
	//-----------------------------------------------------
	initLevel2:function(offset){
		this.allAccordeons[offset].subacc=new Array();
		$$("#btnacclevel2_"+offset+" .acc_lvl2").each(this.initBtnlvl2.bindAsEventListener(this,offset));
	},
	initBtnlvl2:function(o,offset){
		o.style.cursor="pointer";
 		var _offset=this.allAccordeons[offset].subacc.length;
  		o.id="btnacclevel2_"+offset+"_"+_offset;
 		o.observe('click', this.openacclvl2.bindAsEventListener(this,offset,_offset));
 		if(o.next(0)){
	 		o.next(0).id="btnacclevel2_"+offset+"_"+_offset;
	 		o.next(0).hide();
		}
 		if($$("#btnacclevel2_"+offset+"_"+_offset+" img")[0])
 			$$("#btnacclevel2_"+offset+"_"+_offset+" img")[0].src="skins/images/big_summenu.gif";
  		this.allAccordeons[offset].subacc.push(o);
	},
	openacclvl2:function(o,offset,_offset){
		var queue = Effect.Queues.get('anim1');
		this.closeacclvl2(offset);
		if(this.allAccordeons[offset].currentOpen!=this.allAccordeons[offset].subacc[_offset]){
			this.allAccordeons[offset].currentOpen=this.allAccordeons[offset].subacc[_offset];
			if($$("#"+this.allAccordeons[offset].currentOpen.id+" img")[0])
				$$("#"+this.allAccordeons[offset].currentOpen.id+" img")[0].src="skins/images/big_summenu2.gif";
			if(this.allAccordeons[offset].currentOpen.next(0))
				new Effect.BlindDown(this.allAccordeons[offset].currentOpen.next(0),this.animoption2);
		}else{
			this.allAccordeons[offset].currentOpen=null;
		}
	},
	closeacclvl2:function(offset){
		if(this.allAccordeons[offset].currentOpen!=null){
			if($$("#"+this.allAccordeons[offset].currentOpen.id+" img")[0])
				$$("#"+this.allAccordeons[offset].currentOpen.id+" img")[0].src="skins/images/big_summenu.gif";
			if(this.allAccordeons[offset].currentOpen.next(0))
				new Effect.BlindUp(this.allAccordeons[offset].currentOpen.next(0),this.animoption2);
			
		}
	}
}