window.addEvent('domready', function() {
	var minHeight = 190;	
	var maxHeight = 350;								 
	var p1 = new Object;
	p1.num = 1;
	p1.slide = $('p1');
	p1.lnk1 = $('listing1').getElements('a.lnk1');
	p1.lnk2 = $('listing1').getElements('a.lnk2');
	p1.lnk3 = $('listing1').getElements('a.lnk3');
	p1.status = false;	

	var p2 = new Object;
	p2.num = 2;
	p2.slide = $('p2');
	p2.lnk1 = $('listing2').getElements('a.lnk1');
	p2.lnk2 = $('listing2').getElements('a.lnk2');
	p2.lnk3 = $('listing2').getElements('a.lnk3');
	p2.status = false;
/*		
	var p3 = new Object;
	p3.num = 3;
	p3.slide = $('p3');
	p3.lnk1 = $('listing3').getElements('a.lnk1');
	p3.lnk2 = $('listing3').getElements('a.lnk2');
	p3.lnk3 = $('listing3').getElements('a.lnk3');
	p3.status = false;
	
	var p4 = new Object;
	p4.num = 4;
	p4.slide = $('p4');
	p4.lnk1 = $('listing4').getElements('a.lnk1');
	p4.lnk2 = $('listing4').getElements('a.lnk2');
	p4.lnk3 = $('listing4').getElements('a.lnk3');
	p4.status = false;
							 
	var p5 = new Object;
	p5.num = 5;
	p5.slide = $('p5');
	p5.lnk1 = $('listing5').getElements('a.lnk1');
	p5.lnk2 = $('listing5').getElements('a.lnk2');
	p5.lnk3 = $('listing5').getElements('a.lnk3');
	p5.status = false;	
	
	var p6 = new Object;
	p6.num = 6;
	p6.slide = $('p6');
	p6.lnk1 = $('listing6').getElements('a.lnk1');
	p6.lnk2 = $('listing6').getElements('a.lnk2');
	p6.lnk3 = $('listing6').getElements('a.lnk3');
	p6.status = false;
	
	var p7 = new Object;
	p7.num = 7;
	p7.slide = $('p7');
	p7.lnk1 = $('listing7').getElements('a.lnk1');
	p7.lnk2 = $('listing7').getElements('a.lnk2');
	p7.lnk3 = $('listing7').getElements('a.lnk3');
	p7.status = false;
*/			
	function toggler(p){
		if(p.status==false){
			p.status = true;
		} 
		else{
			p.status = false;	
		}
		tweenIt(p.status, p);
	}
	
	function tweenIt(status, p){
		var switchHeight;
		var switchArrow;
		var switchSlideBtns;
		
		if(status){
			switchHeight = maxHeight;
			switchArrow = 'toggleShow';
			switchSlideBtns = 'block';
		}
		else{
			switchHeight = minHeight;	
			switchArrow = 'toggleHide';
			switchSlideBtns = 'none';
		}		
		p.slide.tween('height', switchHeight);
		p.slide.getElements('div.mask').tween('height', switchHeight);
		$('toggleArrow'+p.num).className = switchArrow;
		$('sliderBtns'+p.num).style.display = switchSlideBtns;
	}

	//smooooooth scrolling enabled
	new SmoothScroll({ duration:700 }, window); 
	
	
	p1.lnk1.addEvent('click', function(){ toggler(p1); return false; });
	p1.lnk2.addEvent('click', function(){ toggler(p1); return false; });
	p1.lnk3.addEvent('click', function(){ toggler(p1); return false; });
	//
	p2.lnk1.addEvent('click', function(){ toggler(p2); return false; });
	p2.lnk2.addEvent('click', function(){ toggler(p2); return false; });
	p2.lnk3.addEvent('click', function(){ toggler(p2); return false; });
/*
	p3.lnk1.addEvent('click', function(){ toggler(p3); return false; });
	p3.lnk2.addEvent('click', function(){ toggler(p3); return false; });
	p3.lnk3.addEvent('click', function(){ toggler(p3); return false; });
	//
	p4.lnk1.addEvent('click', function(){ toggler(p4); return false; });
	p4.lnk2.addEvent('click', function(){ toggler(p4); return false; });
	p4.lnk3.addEvent('click', function(){ toggler(p4); return false; });
	//
	p5.lnk1.addEvent('click', function(){ toggler(p5); return false; });
	p5.lnk2.addEvent('click', function(){ toggler(p5); return false; });
	p5.lnk3.addEvent('click', function(){ toggler(p5); return false; });
	//
	p6.lnk1.addEvent('click', function(){ toggler(p6); return false; });
	p6.lnk2.addEvent('click', function(){ toggler(p6); return false; });
	p6.lnk3.addEvent('click', function(){ toggler(p6); return false; });
	//
	p7.lnk1.addEvent('click', function(){ toggler(p7); return false; });
	p7.lnk2.addEvent('click', function(){ toggler(p7); return false; });
	p7.lnk3.addEvent('click', function(){ toggler(p7); return false; });
*/

// Create Slider Vars
//P1
	var handles1_more = $$('#handles1_more span');
	var nS1 = new noobSlide({
		box: $('box1'),
		items: $$('#box1 img'),
		size: 500,
		handles: $$('#handles1 span'),
		addButtons: {previous: $('prev1'), next: $('next1') },
		onWalk: function(currentItem,currentHandle){
			//style for handles
			$$(this.handles,handles1_more).removeClass('active');
			$$(currentHandle,handles1_more[this.currentIndex]).addClass('active');
		}
	});
	//more "previous" and "next" buttons
	nS1.addActionButtons('previous',$$('#box1 .prev'));
	nS1.addActionButtons('next',$$('#box1 .next'));
	//more handle buttons
	nS1.addHandleButtons(handles1_more);
	//walk to item 3 witouth fx
	nS1.walk(0,false,true);


//P2
	var handles2_more = $$('#handles2_more span');
	var nS2 = new noobSlide({
		box: $('box2'),
		items: $$('#box2 img'),
		size: 500,
		handles: $$('#handles2 span'),
		addButtons: {previous: $('prev2'), next: $('next2') },
		onWalk: function(currentItem,currentHandle){
			//style for handles
			$$(this.handles,handles2_more).removeClass('active');
			$$(currentHandle,handles2_more[this.currentIndex]).addClass('active');
		}
	});
	//more "previous" and "next" buttons
	nS2.addActionButtons('previous',$$('#box2 .prev'));
	nS2.addActionButtons('next',$$('#box2 .next'));
	//more handle buttons
	nS2.addHandleButtons(handles2_more);
	//walk to item 3 witouth fx
	nS2.walk(0,false,true);
/*	
//P3
	var handles3_more = $$('#handles3_more span');
	var nS3 = new noobSlide({
		box: $('box3'),
		items: $$('#box3 img'),
		size: 500,
		handles: $$('#handles3 span'),
		addButtons: {previous: $('prev3'), next: $('next3') },
		onWalk: function(currentItem,currentHandle){
			//style for handles
			$$(this.handles,handles3_more).removeClass('active');
			$$(currentHandle,handles3_more[this.currentIndex]).addClass('active');
		}
	});
	//more "previous" and "next" buttons
	nS3.addActionButtons('previous',$$('#box3 .prev'));
	nS3.addActionButtons('next',$$('#box3 .next'));
	//more handle buttons
	nS3.addHandleButtons(handles3_more);
	//walk to item 3 witouth fx
	nS3.walk(0,false,true);
	
//P4
	var handles4_more = $$('#handles4_more span');
	var nS4 = new noobSlide({
		box: $('box4'),
		items: $$('#box4 img'),
		size: 500,
		handles: $$('#handles4 span'),
		addButtons: {previous: $('prev4'), next: $('next4') },
		onWalk: function(currentItem,currentHandle){
			//style for handles
			$$(this.handles,handles4_more).removeClass('active');
			$$(currentHandle,handles4_more[this.currentIndex]).addClass('active');
		}
	});
	//more "previous" and "next" buttons
	nS4.addActionButtons('previous',$$('#box4 .prev'));
	nS4.addActionButtons('next',$$('#box4 .next'));
	//more handle buttons
	nS4.addHandleButtons(handles4_more);
	//walk to item 3 witouth fx
	nS4.walk(0,false,true);
	
//P5
	var handles5_more = $$('#handles5_more span');
	var nS5 = new noobSlide({
		box: $('box5'),
		items: $$('#box5 img'),
		size: 500,
		handles: $$('#handles5 span'),
		addButtons: {previous: $('prev5'), next: $('next5') },
		onWalk: function(currentItem,currentHandle){
			//style for handles
			$$(this.handles,handles5_more).removeClass('active');
			$$(currentHandle,handles5_more[this.currentIndex]).addClass('active');
		}
	});
	//more "previous" and "next" buttons
	nS5.addActionButtons('previous',$$('#box5 .prev'));
	nS5.addActionButtons('next',$$('#box5 .next'));
	//more handle buttons
	nS5.addHandleButtons(handles5_more);
	//walk to item 3 witouth fx
	nS5.walk(0,false,true);
	
//P6
	var handles6_more = $$('#handles6_more span');
	var nS6 = new noobSlide({
		box: $('box6'),
		items: $$('#box6 img'),
		size: 500,
		handles: $$('#handles6 span'),
		addButtons: {previous: $('prev6'), next: $('next6') },
		onWalk: function(currentItem,currentHandle){
			//style for handles
			$$(this.handles,handles6_more).removeClass('active');
			$$(currentHandle,handles6_more[this.currentIndex]).addClass('active');
		}
	});
	//more "previous" and "next" buttons
	nS6.addActionButtons('previous',$$('#box6 .prev'));
	nS6.addActionButtons('next',$$('#box6 .next'));
	//more handle buttons
	nS6.addHandleButtons(handles6_more);
	//walk to item 3 witouth fx
	nS6.walk(0,false,true);
	
//P7
	var handles7_more = $$('#handles7_more span');
	var nS7 = new noobSlide({
		box: $('box7'),
		items: $$('#box7 img'),
		size: 500,
		handles: $$('#handles7 span'),
		addButtons: {previous: $('prev7'), next: $('next7') },
		onWalk: function(currentItem,currentHandle){
			//style for handles
			$$(this.handles,handles7_more).removeClass('active');
			$$(currentHandle,handles7_more[this.currentIndex]).addClass('active');
		}
	});
	//more "previous" and "next" buttons
	nS7.addActionButtons('previous',$$('#box7 .prev'));
	nS7.addActionButtons('next',$$('#box7 .next'));
	//more handle buttons
	nS7.addHandleButtons(handles7_more);
	//walk to item 3 witouth fx
	nS7.walk(0,false,true);
*/

});


// ==== SLIDER JS ==== //
var noobSlide=new Class({initialize:function(a){this.items=a.items;this.mode=a.mode||'horizontal';this.modes={horizontal:['left','width'],vertical:['top','height']};this.size=a.size||240;this.box=a.box.setStyle(this.modes[this.mode][1],(this.size*this.items.length)+'px');this.button_event=a.button_event||'click';this.handle_event=a.handle_event||'click';this.onWalk=a.onWalk||null;this.currentIndex=null;this.previousIndex=null;this.nextIndex=null;this.interval=a.interval||5000;this.autoPlay=a.autoPlay||false;this._play=null;this.handles=a.handles||null;if(this.handles){this.addHandleButtons(this.handles)}this.buttons={previous:[],next:[],play:[],playback:[],stop:[]};if(a.addButtons){for(var b in a.addButtons){this.addActionButtons(b,$type(a.addButtons[b])=='array'?a.addButtons[b]:[a.addButtons[b]])}}this.fx=new Fx.Tween(this.box,$extend((a.fxOptions||{duration:500,wait:false}),{property:this.modes[this.mode][0]}));this.walk((a.startItem||0),true,true)},addHandleButtons:function(a){for(var i=0;i<a.length;i++){a[i].addEvent(this.handle_event,this.walk.bind(this,[i,true]))}},addActionButtons:function(a,b){for(var i=0;i<b.length;i++){switch(a){case'previous':b[i].addEvent(this.button_event,this.previous.bind(this,[true]));break;case'next':b[i].addEvent(this.button_event,this.next.bind(this,[true]));break;case'play':b[i].addEvent(this.button_event,this.play.bind(this,[this.interval,'next',false]));break;case'playback':b[i].addEvent(this.button_event,this.play.bind(this,[this.interval,'previous',false]));break;case'stop':b[i].addEvent(this.button_event,this.stop.bind(this));break}this.buttons[a].push(b[i])}},previous:function(a){this.walk((this.currentIndex>0?this.currentIndex-1:this.items.length-1),a)},next:function(a){this.walk((this.currentIndex<this.items.length-1?this.currentIndex+1:0),a)},play:function(a,b,c){this.stop();if(!c){this[b](false)}this._play=this[b].periodical(a,this,[false])},stop:function(){$clear(this._play)},walk:function(a,b,c){if(a!=this.currentIndex){this.currentIndex=a;this.previousIndex=this.currentIndex+(this.currentIndex>0?-1:this.items.length-1);this.nextIndex=this.currentIndex+(this.currentIndex<this.items.length-1?1:1-this.items.length);if(b){this.stop()}if(c){this.fx.cancel().set((this.size*-this.currentIndex)+'px')}else{this.fx.start(this.size*-this.currentIndex)}if(b&&this.autoPlay){this.play(this.interval,'next',true)}if(this.onWalk){this.onWalk((this.items[this.currentIndex]||null),(this.handles&&this.handles[this.currentIndex]?this.handles[this.currentIndex]:null))}}}});
