//onload
document.observe("dom:loaded", function() {
	tab_load();
});

function tab_load(){
	
	// check if tab exists
	var c_product_tablist = $('c_product_tablist');
	var c_tabs = $$('.c_tab');
	var activeTab = 'c_tab_content_active';
	if(c_product_tablist != null){
		
		// Show first tab
		$$('.c_tab_content').each(function(tab_item){
			tab_item.show();
		});
		
		for(i=0;i<c_tabs.length;++i){
	   		c_tabs[i].observe('click', function(event){
				Event.stop(event);
				
				$$('.c_tab_content').each(function(tab_item){
					tab_item.removeClassName("c_tab_content_dotted");
				});
				
				var a_link = $(this.firstChild);
				var a_link_id = a_link.href.split('#');
				
				
				if(activeTab != a_link_id[1]){
					// Remove All Active tabs
					$$('.c_tab_active').each(function(tab_active){
						tab_active.removeClassName("c_tab_active");
					});
					
					// Hide all tabs
					$$('.c_tab_content').each(function(tab_item){
						tab_item.hide();
					});	
					
					// Show clicked Tab+
					if(a_link_id[1] != null){
						$(this).addClassName("c_tab_active");
						$(a_link_id[1]).show();	
					}
				}
			});
		}
	}	
}
