/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var Tabber = Class.create({
  initialize: function(){},
  overTab: function (tabId, tabs, type) {
    if ($F('tab_' + tabs + '_selected_tab') == tabId)
            return;
    var element = $(tabId);
    element.addClassName('over');
    if (type == true) {
        if(Object.isUndefined($('sub_tabs_' + $F('tab_' + tabs + '_selected_tab')))) {
            $('sub_tabs_' + $F('tab_' + tabs + '_selected_tab')).addClassName('hide');
            $('sub_tabs_' + tabId).removeClassName('hide');
            $('sub_tab_' + tabId).addClassName('hide');
            $('sub_tab_comment_' + tabId).removeClassName('hide');
        }
    }
  },
  outTab: function (tabId, tabs, type) {
    var element = $(tabId);
    element.removeClassName('over');
    if ($('tab_' + tabs + '_selected_tab') && $F('tab_' + tabs + '_selected_tab') == tabId)
            return;
    if (type == true) {
        if(Object.isUndefined($('sub_tabs_' + $F('tab_' + tabs + '_selected_tab')))) {
            $('sub_tabs_' + $F('tab_' + tabs + '_selected_tab')).removeClassName('hide');
            $('sub_tab_' + tabId).addClassName('hide');
            $('sub_tab_comment_' + tabId).addClassName('hide');
            $('sub_tabs_' + tabId).addClassName('hide');
        }
    }
  },
  clickMainTab: function (tabId, tabs, type) {
    var element = $(tabId);
    $$('div#' + tabs + ' div.main_tabs a.item').each(function (item) {
        item.removeClassName('selected');
    });
    element.addClassName('selected');
    if (type == true) {
        if(Object.isUndefined($('sub_tabs_' + $F('tab_' + tabs + '_selected_tab')))) {
            $('sub_tabs_' + $F('tab_' + tabs + '_selected_tab')).addClassName('hide');
            $('sub_tab_' + $F('tab_' + tabs + '_selected_tab')).addClassName('hide');
            $('sub_tab_comment_' + $F('tab_' + tabs + '_selected_tab')).addClassName('hide');
            $('tab_' + tabs + '_selected_tab').removeClassName("selected");
            $('sub_tabs_' + tabId).removeClassName('hide');
            $('sub_tab_comment_' + tabId).addClassName('hide');
            $('sub_tab_' + tabId).removeClassName('hide');
            $('tab_' + tabs + '_selected_tab').value = tabId;
        }
    }
  },
  clickSubTab: function (tabId, tabs) {
    var element = $(tabId);
    $$('div#' + tabs + ' div.sub_tabs a.item').each(function (item) {
        item.removeClassName('selected');
    });
    element.addClassName('selected');
  }
});

var tabs = new Tabber();