/**
 * @author C809907
 */
$(document).ready(function(){
    var title = document.title
    var $bnsfSubtabs;
    function callback(hash){
        $bnsfSubtabs.subtabs('select', hash);
    };
    $(function(){
        $bnsfSubtabs = $("#subtabs" + " ").subtabs();
        //load hash into browser when tab is changed
        $('li.ui-state-default > a').click(function(){
            hashString = this.hash;
            $.history.load(hashString);
            $('form[name=emailer] textarea[name=ReferringURL]').text(location.href);
            var sub_title = $(this).text()
            //alert(sub_title)
            
            document.title = title + " #" + sub_title
			add_history()
            
        });
        //load hash into history on a text link that goes to another subtab
        $(".subtabs-5-internal").click(function(){
            var selected = $("#subtabs" + " ").subtabs("option", "selected");
            var realLink = selected + 1 //div id starts at 1, but the tab array starts at zero
            var anchorString = 'subtabs-' + realLink;
            $.history.load(encodeURIComponent(anchorString));
            
            return false;
        });
    });
    $.history.init(callback);
    //scroll the window to display correctly when the page loads
    window.scrollTo(0, 0);
});
