var Fabtabs = Class.create();
		Fabtabs.prototype = {
			initialize : function(element) {
				this.element = $(element);
				var options = Object.extend({}, arguments[1] || {});
				this.menu = $A(this.element.getElementsByTagName('a'));
				this.show(this.getInitialTab());
				this.menu.each(this.setupTab.bind(this));
			},
			setupTab : function(elm) {
				Event.observe(elm,'click',this.activate.bindAsEventListener(this),false)
			},
			activate :  function(ev) {
				var elm = Event.findElement(ev, "a");
				Event.stop(ev);
				this.show(elm);
				//alert(elm);
				this.menu.without(elm).each(this.hide.bind(this));
				this.show(elm);
				//this.menu.without(elm).each(function(s){s.hide.bind(this)});
				
			},
			hide : function(elm) {
				$(elm).removeClassName('active-tab');
				$(this.tabID(elm)).removeClassName('active-tab-body');
			},
			show : function(elm) {
				//alert(elm);
				$(elm).addClassName('active-tab');
				
				$(this.tabID(elm)).addClassName('active-tab-body');
				//$(this.tabID(elm)).setStyle({'display': 'block'});

			},
			forceShow : function(elm) {
			  //alert(elm);
				
				$(elm).addClassName('active-tab-body');
				this.menu.without(elm).each(this.hide.bind(this));
				
				$(elm).addClassName('active-tab-body');
				//$(this.tabID(elm)).setStyle({'display': 'block'});
			},
			tabID : function(elm) {
				return elm.href.match(/#(\w.+)/)[1];
			},
			getInitialTab : function() {
				if(document.location.href.match(/#(\w.+)/)) {
					var loc = RegExp.$1;
					var elm = this.menu.find(function(value) { return value.href.match(/#(\w.+)/)[1] == loc; });
					return elm || this.menu.first();
				} else {
					return this.menu.first();
				}
			}
		}
		
var Fabselect = Class.create();
Fabselect.prototype = {
 initialize : function(element,call) {
                this.callback = function() {};  
				this.callback = call;
				
				this.element = $(element);
				var options = Object.extend({}, arguments[1] || {});
				this.menu = $A(this.element.childElements());
				this.show(this.getInitialTab());
				
				Event.observe(this.element,'change',this.activate.bindAsEventListener(this),false);
				//this.menu.each(this.setupTab.bind(this));
				//console.dir(this.menu);
			},
		setupTab : function(elm) {
		
				Event.observe(elm,'click',this.activate.bindAsEventListener(this),false)
				
			},
	activate : function(ev){
	  var elm = Event.element(ev); 
	  //console.log(elm.selected);
	   Event.stop(ev);
	  //var x=document.getElementById("mySelect");
		//console.log(elm.options[elm.selectedIndex].title);
		var elid = elm.options[elm.selectedIndex].title.substring(1);
		if(elid == 'others'){
		 location.href = 'http://www.solusibangunanmu.com/index-mod-info-opt-vwQna.html';
		 return false;
		} 
		this.show($(elid));
	},
	/*activate :  function(ev) {
		console.log("bebek");
		//var elm = Event.findElement(ev, "a");
		var elm = Event.element(ev); 
		//Event.stop(ev);
		//console.log(elm.label);
		this.show($(elm.title.substring(1)));
		//console.dir(elm);
	},*/
  show : function(elm) {
			 
				if(!elm)return;
				$(elm).addClassName('active-tab-body');
				this.callback();
				this.menu.each(function(s){
				//console.log(s.title.substring(1));
											var sid = s.title.substring(1);
											if(sid != elm.identify() && sid != 'others'){
											 $(sid).removeClassName('active-tab-body');
											}
											if(sid == elm.identify()){
											   s.selected = true;
											}
										  });
				
				$(elm).addClassName('active-tab-body');
				//$(this.tabID(elm)).setStyle({'display': 'block'});
			},
	hide : function(elm) {
		//$(elm).removeClassName('active-tab');
		//console.log(elm);
		$(elm).removeClassName('active-tab-body');
	},
	getInitialTab : function() {
				
				if(document.location.href.match(/#(\w.+)/)) {
					var loc = RegExp.$1;
					var elm = this.menu.find(function(value) { return value.title.match(/#(\w.+)/)[1] == loc; });
					//console.dir(elm);
					return $(elm.title.substring(1));
				} 
			}
}		
