// JavaScript Document
var adiSlideAtas = new Class({
	initialize:function(a){
		this.currentIndex=0;
		this.menu = $$('#content-main1-1-right li');
		this.tampil = $$('#content-main1-1-left li');
		this.nav = $$('#content-main1-2-left li');
		this.txt = $$('#content-main1-1-left p');
		this.duration = 10000;
		for(var i=0;i<this.menu.length;i++){
			if(i>0){
				this.menu[i].set('class', 'inactive');
				this.nav[i].set('class', 'inactive');
				this.tampil[i].fade('out');
				this.txt[i].fade('out');
			}else{
				this.menu[i].set('class', 'active');
				this.nav[i].set('class', 'active');
				this.tampil[i].fade('in');
				this.txt[i].fade('in');
			}
		}
		this.timer = this.show.delay(this.duration, this, this.currentIndex + 1);
	},
	show: function(a){
		$clear(this.timer);
		if(a!=this.currentIndex){
			this.menu[this.currentIndex].set('class', 'inactive');
			this.nav[this.currentIndex].set('class', 'inactive');
			this.tampil[this.currentIndex].fade('out');
			this.txt[this.currentIndex].fade('out');
			this.currentIndex = a;
			this.menu[this.currentIndex].set('class', 'active');
			this.nav[this.currentIndex].set('class', 'active');
			this.tampil[this.currentIndex].fade('in');
			this.txt[this.currentIndex].fade('in');
		}
		var b = a + 1 > this.menu.length - 1 ? 0 : a + 1;
		this.timer = this.show.delay(this.duration, this, b);
	}
});

window.addEvent('domready',function() {	
	var items = $$('#header3-2 img');
	var handle = $('header3-2');
	items.each(function(img,i){
		var asli = img.get('src');
		var ho = img.get('alt');
		img.addEvent('mouseover',function() {
			img.set('src',ho);
			/*var myElement = new Element('div', {id: 'myElement'});
			var myElementImg = new Element('img', {id: 'myElementImg'});
			myElementImg.set('src',img.get('src'));
			myElement.grab(myElementImg);
			var left = 10 + (52 * i)
			myElement.set('style','position:absolute;top:15px;width:100px;height:80px;left:'+ left +'px;');
			$('header3-2').grab(myElement);
			img.addEvent('mouseout',function(){
				$$('#header3-2 div').dispose();
			});*/
		});
		img.addEvent('mouseout',function() {
			img.set('src',asli);
		});
	});
});
var adiSlide = new Class({
	initialize:function(a){
		this.currentIndex=0;
		this.items = $$('#boxkiri1-kiri img');
		this.handle = $$('#paketnumber li');
		this.duration = 5000;
		for(var i=0;i<this.items.length;i++){
			this.items[i].set('style','position:absolute;width:375px;height:77px;');
			if(i>0){
				/*this.items[i].fade('out');*/
				this.items[i].tween('left', [0, -375]);
				this.handle[i].set('class','');
			}else{
				/*this.items[i].fade('in');*/
				this.items[i].tween('left', [375, 0]);
				this.handle[i].set('class','active');
			}
			this.handle[i].addEvent('click',this.show.bind(this,[i]))
		}
		this.timer = this.show.delay(this.duration, this, this.currentIndex + 1);
	},
	show: function(a){
		$clear(this.timer);
		if(a!=this.currentIndex){
			/*this.items[this.currentIndex].fade('out');*/
			this.items[this.currentIndex].tween('left', [0, -375]);
			this.handle[this.currentIndex].set('class','');
			this.currentIndex = a;
			/*this.items[this.currentIndex].fade('in');*/
			this.items[this.currentIndex].tween('left', [375, 0]);
			this.handle[this.currentIndex].set('class','active');
		}
		var b = a + 1 > this.items.length - 1 ? 0 : a + 1;
		this.timer = this.show.delay(this.duration, this, b);
	}
});

var adiSlide2 = new Class({
	initialize:function(a){
		this.currentIndex=0;
		this.items = $$('#community-kecil li');
		this.handle = $$('#community-besar li');
		this.duration = 4000;
		for(var i=0;i<this.items.length;i++){
			this.items[i].set('style','position:absolute;width:184px;height:84px;');
			if(i>0){
				this.items[i].tween('bottom', [0, -84]);
			}else{
				this.items[i].tween('bottom', [84, 0]);
			}
			this.items[i].addEvent('mouseover',this.showMO.bind(this,[i]));
			this.handle[i].addEvent('mouseleave',this.showML.bind(this,[i]));
		}
		this.timer = this.show.delay(this.duration, this, this.currentIndex + 1);
	},
	showMO: function(a){
		$clear(this.timer);
		this.items[a].set('opacity',0);
		this.handle[a].set('class','active');
	},
	showML: function(a){
		this.items[a].set('opacity',100);
		this.handle[a].set('class','nonactive');
		var b = a + 1 > this.items.length - 1 ? 0 : a + 1;
		this.timer = this.show.delay(this.duration, this, b);
	},
	show: function(a){
		$clear(this.timer);
		if(a!=this.currentIndex){
			this.items[this.currentIndex].tween('bottom', [0, -84]);
			this.currentIndex = a;
			this.items[this.currentIndex].tween('bottom', [84, 0]);
		}
		var b = a + 1 > this.items.length - 1 ? 0 : a + 1;
		this.timer = this.show.delay(this.duration, this, b);
	}
});

var adiSlidezZoom = new Class({
	initialize:function(a){
		this.currentIndex=0;
		this.items = $$('#comunity-kecil li');
		this.handle = $$('#comunity-besar li');
		this.next = $$('#boxkiri1-kanan div.arrow-right');
		this.prev = $$('#boxkiri1-kanan div.arrow-left');
		this.duration = 4000;
		for(var i=0;i<this.items.length;i++){
			if(i>0){
				this.items[i].set('opacity',0);
			}else{
				this.items[i].set('opacity',100);
			}
			this.items[i].addEvent('mouseover',this.showMO.bind(this,[i]));
			this.handle[i].addEvent('mouseleave',this.showML.bind(this,[i]));
		}
		this.timer = this.show.delay(this.duration, this, this.currentIndex + 1);
		this.next.addEvent('click',this.show.bind(this,[this.currentIndex + 1]))
		this.prev.addEvent('click',this.show.bind(this,[this.items.length - 1]))
	},
	showMO: function(a){
		$clear(this.timer);
		this.items[a].set('opacity',0);
		this.handle[a].set('class','active');
	},
	showML: function(a){
		this.items[a].set('opacity',100);
		this.handle[a].set('class','nonactive');
		var b = a + 1 > this.items.length - 1 ? 0 : a + 1;
		this.timer = this.show.delay(this.duration, this, b);
	},
	show: function(a){
		$clear(this.timer);
		if(a!=this.currentIndex){
			this.items[this.currentIndex].set('opacity', 0);
			this.currentIndex = a;
			this.items[this.currentIndex].set('opacity', 100);
		}
		var b = a + 1 > this.items.length - 1 ? 0 : a + 1;
		var p = a - 1 < 0 ? this.items.length - 1 : a - 1 ;
		this.next.addEvent('click',this.show.bind(this,[b]))
		this.prev.addEvent('click',this.show.bind(this,[p]))
		this.timer = this.show.delay(this.duration, this, b);
	}
});
var adiTab=new Class({
	initialize:function(a){
		this.currentIndex=0;
		this.header=$$('#tab-header div');
		this.handles = $$('#tab-isi div');
		this.handles.each(function(img,i){ 
			if(i > 0) {
				img.set('opacity',0);
			}
		});
		this.addHandleButtons(this.header);
	},
	addHandleButtons:function(a){
		for(var i=0;i<a.length;i++){
			a[i].addEvent('click',this.walk.bind(this, [i]))
		}
	},
	walk:function(a){
		if(a!=this.currentIndex){
			this.header[this.currentIndex].set('class', 'tab-header');
			this.handles[this.currentIndex].set('opacity',0);
			this.currentIndex=a;
			this.handles[a].set('opacity',100);
			this.header[a].set('class', 'tab-header tab-header-active');
		}
	}
});
var adiAccordion=new Class({
	initialize:function(a){
		this.currentIndex=0;
		this.header = $$('#boxkiri1 #ganti div.header');
		this.content = $$('#boxkiri1 #ganti div.content');
		this.addHandleAwal(this.header);
	},
	addHandleAwal:function(a){
		for(var i=0;i<a.length;i++){
			a[i].addEvent('click',this.walk.bind(this, [i]))
			if(i>0){
				this.header[i].set('class','header');
				this.content[i].set('class','mati');
			}else{
				this.header[i].set('class','mati');
				this.content[i].set('class','content');
			}
		}
	},
	walk:function(a){
		if(a!=this.currentIndex){
			this.header[this.currentIndex].set('class','header');
			this.content[this.currentIndex].set('class','mati');
			this.currentIndex=a;
			this.header[this.currentIndex].set('class','mati');
			this.content[this.currentIndex].set('class','content');	
		}
	}
});


var ScrollSidebar = new Class({
			
			Implements: [Options],
			
			options: {
				offsets: { x:0, y:0 },
				mode: 'vertical',
				positionVertical: 'top',
				positionHorizontal: 'right',
				speed: 400
			},
			
			initialize: function(menu,options) {
				this.setOptions(options);
				this.menu = $(menu);
				this.move = this.options.mode == 'vertical' ? 'y' : 'x';
				this.property = this.move == 'y' ? 'positionVertical' : 'positionHorizontal';
				var css = { position: 'absolute', display:'block' };
				css[this.options.positionVertical] = this.options.offsets.y;
				css[this.options.positionHorizontal] = this.options.offsets.x;
				this.menu.setStyles(css).set('tween',{ duration: this.options.speed });
				this.startListeners();
			},
			
			startListeners: function() {
				var action = function() {
					this.setPosition($(document.body).getScroll()[this.move] + this.options.offsets[this.move]);
				}.bind(this);
				window.addEvent('scroll',action);
				window.addEvent('load',action);
			},
			
			setPosition: function(move) {
				this.menu.tween(this.options[this.property],move);
				return this;
			}
		});
