dojo.provide("msos.tab");
dojo.require("msos.common");
dojo.require("dojo.cookie");
msos.tab.tool=function(_1){
this.tab_div_el=_1;
this.tab_set_active=1;
this.act_tab_style="tab_active";
this.pas_tab_style="tab_passive";
this.com_tab_style="tab_common";
this.tab_cookie_name="tab_index_"+_1.id;
this.tab_height_px=250;
this.tab_onclick=null;
this.tabs=new Array;
var _2=this;
this.add_tab=function(_3){
_3.container.style.height=_2.tab_height_px+"px";
var _4=document.createElement("span");
var _5=_2.tabs.length+1;
_4.id="tab_span_"+_5;
_4.title=_3.tab_title;
_4.unselectable="on";
_4.container=_3.container;
dojo.connect(_4,"onclick",null,_2.go_to_tab);
var _6=document.createTextNode(_3.caption);
_4.appendChild(_6);
_2.tabs.push(_4);
};
this.generate_tabs=function(){
for(var i=0;i<_2.tabs.length;i++){
_2.tab_div_el.appendChild(_2.tabs[i]);
}
_2.set_tab();
};
this.get_tab_by_cookie=function(){
var _8=dojo.cookie(_2.tab_cookie_name);
console.debug("get_tab_by_cookie -> index: "+_8+" for cookie: "+_2.tab_cookie_name);
if(_8){
_2.tab_set_active=_8;
}
};
this.set_tab=function(){
var _9=_2.tab_set_active||1;
if(_9=="na"){
_9=1;
}
if(isNaN(parseInt(_9))){
_9=1;
}
if(_9<1){
_9=1;
}
if(_9>_2.tabs.length){
_9=_2.tabs.length;
}
for(var i=0;i<_2.tabs.length;i++){
if(_9==i+1){
_2.tabs[i].className=_2.act_tab_style+" "+_2.com_tab_style;
_2.tabs[i].container.style.display="block";
_2.tab_set_active=i+1;
dojo.cookie(_2.tab_cookie_name,i+1,{expires:1});
console.debug("set_tab -> index: "+(i+1)+" for cookie: "+_2.tab_cookie_name);
}else{
_2.tabs[i].className=_2.pas_tab_style+" "+_2.com_tab_style;
_2.tabs[i].container.style.display="none";
}
}
};
this.go_to_tab=function(_b){
_b.preventDefault();
_b.stopPropagation();
var _c=_b.target;
var _d=_2.tab_set_active;
var _e=_c.id.replace(/tab_span_/,"");
if(_c){
_d=parseInt(_e)||_d;
}
msos.common.event_debug(_b,"\nTab go_to_tab - index: "+_d);
_2.tab_set_active=_d;
_2.set_tab();
if(typeof (_2.tab_onclick)=="function"){
_2.tab_onclick();
}
};
};

