var TabHack = {};

TabHack.tabs_open = [];

TabHack.container_selector = "#container";

/**
 * tabs.bind('click', function(e) {
 *		var trueClick = e.clientX;
 *		if(trueClick)TabHack.clickCallback(this.hash); <- insert this line into tabs
 *         
 * @param {String} id of clicked section 
 */      
TabHack.clickCallback = function (id){
	var num = this.section_id_to_num(id);
	TabHack.click(jQuery(this.container_selector+num+' '+id));
	if(!this.tabs_open[num]){
		jQuery(this.container_selector+num+' '+id).show();
		jQuery(this.container_selector+num+' .content').show();
		this.tabs_open[num]=true;
	}
};

/**
 * add code here.... 
 * @param {Object} jQuery container that was opened
 */
TabHack.click=function(container){
	
}

/**
 * alle ids die mit id beginnen und durch nummer 0-x ergänzt werden in tabs() umwandeln
 * #hase -> #hase0 - #hase999
 * 
 * @exception will not work with different containers (#hase1... + #mix1...) at the same time
 * @param {Object} container_selector
 */
TabHack.tabsOnAll = function (container_selector){
	this.container_selector = container_selector;
	var temp;
	for(var i=0;;i++){
		temp = this.container_selector+i;
		if(!jQuery(temp).size())break;
		
		jQuery(temp).tabs();
		this.closeRow(i);
	}
};

TabHack.section_id_to_num = function(id){
	//s1-2
	var parts = id.split('-');//s1 & 2
	var parts = parts[0].split('s');//s & 1
	if(!parts[1])alert("ID net gut.."+id);
	return parts[1];
};

TabHack.closeRow = function (num){
	jQuery(this.container_selector+num+'>div').hide();
	jQuery(this.container_selector+num+' .content').hide();
	jQuery(this.container_selector+num+' li').removeClass('tabs-selected');
	this.tabs_open[num]=false;
};

