window.addEvent('domready', function(){

	var	tabsElements = $$('.tabs');
	tabsElements.each(function(tabElement,index){
		var tabsMenu = tabElement.getElement('.tabsMenu');
		var lis = tabsMenu.getChildren();
		var tabs = [];
		var tabContents = [];
		var currentActiveTab = null;
		var currentActiveTabContent = null;							
		lis.each(function(li, index) {
			var a = li.getFirst('a');
			if(currentActiveTab)
				a.removeClass('active');
			if( a.hasClass('active'))
				currentActiveTab = a;
			tabs.include(li.getFirst('a'));
			tabContents.include($(a.get('id')+'_content'));							
		});
		if(!currentActiveTab)
			currentActiveTab = tabs.getFirst();																	
		var currentActiveArray = [currentActiveTab]; //To work around the Element.match issue
		currentActiveTabContent = $(currentActiveTab.get('id')+'_content');
		
		tabs.each(function(a, index){ 
			a.addEvents({
		    'mouseover': function(e){
		    	e.stop();
		        if(!currentActiveArray.contains(this)) //To work around the Element.match issue
		        {
		        	currentActiveTab.removeClass('active');
		        	currentActiveTabContent.removeClass('active');							        	
		        	currentActiveTab = this;
					currentActiveTabContent = $(this.get('id')+'_content');							    
					currentActiveTab.addClass('active');
					currentActiveTabContent.addClass('active');    	
		        	currentActiveArray = [this];
		        }
		    }
		    ,
		    'click': function(e){	
		    	e.stop();	
		    }							    
		});});
	}); //End Tab
});