/*******************************
*   NTABS functions
********************************/

function NTabs(obj, style_pref, defaulttab){
	this.obj = null;
	this.defaulttab = 0;
	this.height = 0;
	this.style_pref = 'ui-accordion-';
	this.activetab = 0;
	this.count_tabs = 0;
	
	this.constructor = function(obj, style_pref, defaulttab){
		if(typeof(obj) == 'undefined'){
			alert('bad tab_object!');
			return false;
		}
		this.obj = obj;
		if(typeof(style_pref) == 'string'){
			this.style_pref = style_pref;
		}
		$("#"+this.obj).accordion({header : 'div.'+this.style_pref + 'link'});//, fillSpace: true
		$('#'+this.obj).show();
		this.count_tabs = $('#'+this.obj+' li div.' + this.style_pref + 'link').size();
		if(typeof(defaulttab) == 'number' && this.count_tabs>=defaulttab && defaulttab>=0){
			this.defaulttab = defaulttab;
			this.activate(this.defaulttab);
		}
	};
	
	this.activate = function(n){
		$('#'+this.obj).activate(n);
		this.activetab = n;
	};

	this.setHeight = function(height){
		this.height = height;
	};

	this.setStylePref = function(style_pref){
		this.style_pref = style_pref;
	};

	this.onResize = function(){
		$("#"+this.obj+" li div." + this.style_pref + "cont").css('height', this.height - this.count_tabs*22);
	};

	this.constructor(obj, style_pref, defaulttab);
}// end of NTabs

