function initTabs(params) 
{
    // shows/hides tabs/tabareas
    lastTab = null;
    openTab = null;
    
    var tabGroups = params.tabGroups.split(",");
    
    var max = tabGroups.length;

    for ( var i = 0; i < max; i++ ) {
    
        var tg = "." + tabGroups[i].split("_")[0] + " ";

    	$(tg + ".tabarea").hide();

        $(tg + ".tabs a").click(function(e)
        {
            
            if(lastTab == this) return false;
            
            openTab = this;

            //location.hash = "#"+this.href.split("#")[1];
            
            //window.scrollTo(0,0);
            
            e.preventDefault();
            
        });
        
        
        $(".tabck").click(function(e)
        {
        
            if (!openTab) return;

            $(tg + ".tabs a").removeClass("tabActive");
            
            $(tg + ".tabarea").hide();
            
            $("#"+openTab.href.split("#")[1].split(tg+"_")[0]).show();
            
            $(openTab).addClass("tabActive");
            
            lastTab = openTab;

            
        });
        
        
        if(location.hash != ""){
            
            var tabId = location.hash.split("#")[1];
            
            var tabLinkId = tabId.split("_")[1]+"tab";
            
            if (!document.getElementById(tabLinkId)) return;            

            $(tg + ".tabs a").removeClass("tabActive");
            
            $(tg + ".tabarea").hide();
            
            $(tg + "#"+tabLinkId + " a").click();

        }else{

            $(tg + ".tabs a:first").click();

        }
    }
    //window.scrollTo(0,0);
}


$(document).ready(function() {
    initTabs({tabGroups: 'tg0'});  
    $('.tabarea h2').hide();
});



