// newtabs.js
//
// generic tab script
//
// Written by Jeff Parker - jeffreyp(at)codero.com
//
// Props to the jQuery community for guidance and support
//

$(document).ready(function()
{
    var tabs = $('.tab-tabs li a');
    var clickedtab = 0;
		
		

    function switchTab(clicked)
    {
        var tab = $(".tab-active");
        $(".tab-active").removeClass("tab-active");
        $(".tab-main").hide();
        $("li.tab0" + clicked).addClass("tab-active");
        $(".tab-main.tab0" + clicked).show();

        return false;
    }

    $(".tab-tabs li a").click(function()
    {
        var tab = this.href.split('#');
        tab = tab[tab.length-1];
			 
        $(".tab-active").removeClass("tab-active");
        $(".tab-main").hide();
			
			
        $(this).parent().addClass("tab-active");
        $('.'+tab).show();
    /*temp = (tabs.index(this)+1);
             if(temp != clickedtab)
                 {
                     clickedtab = parseInt(temp);
                     switchTab(clickedtab);
                 }*/
    //return false;
    });
    if(document.location.href.indexOf("#")!==-1){
        var url = document.location.href.split("#");
        url = url[url.length -1];
        for (var i =0;i < tabs.length;i++){
            var tab = tabs[i].href.split('#');
            tab = tab[tab.length-1];
            if( tab === url){
                clickedtab= i;
                break;
            }
        }
    }
			 
    if(clickedtab > 0) $(tabs[clickedtab]).click();
		 
    return false;
});
