// JavaScript Document


$(document).ready(function() {

    $('#accordion').accordion({
        header: '.head',
        active: 0,
        alwaysOpen: false,
        autoheight: true
    });



    // Keep the word "search" in the search box when not in use		       
    $('input[type="text"]').addClass("idleField");
    $('input[type="text"]').focus(function() {
        $(this).removeClass("idleField").addClass("focusField");
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    $('input[type="text"]').blur(function() {
        $(this).removeClass("focusField").addClass("idleField");
        if ($.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });


    /*************************************************/


    // Set the standard style for beauty tip tooltip
    $('.tipX').bt({
        padding: 10,
        width: 320,
        spikeLength: 8,
        spikeGirth: 8,
        cornerRadius: 4,
        fill: 'rgba(239, 245, 250, 1)',
        strokeWidth: 2,
        strokeStyle: '#bcdcf1 ',
        cssStyles: { color: '#333333', fontWeight: 'normal', lineHeight: '1.25', fontSize: '12px' }
    });



    /*************************************************/



    /*************************************************/
    // Content Tabs


    var tabContainers = $('div.tab-content > div');
    tabContainers.hide();

    // original Eaton Golden script
    //
    //		$('ul.contentTabs a').click(function () {
    //			//hide all tab containers
    //			tabContainers.hide();
    //			//show the selected tab container
    //			tabContainers.filter(this.hash).show();
    //			// clear the 'current' tab class
    //			$('ul.contentTabs a').removeClass('current');	
    //			// set the the 'current' tab class for newly selected tab	
    //			$('ul.contentTabs a')
    //			$(this).addClass('current');
    //			return false;		
    //			}).filter(':first').click();

    // new script 8-3-09
    //    function selectTab(newTab) {
    //        if (!newTab) {
    //            newTab = $('ul.contentTabs li.first a');
    //        }
    //        alert(newTab.hash);
    //        //hide all tab containers
    //        tabContainers.hide();
    //        //show the selected tab container
    //        tabContainers.filter(newTab.hash).show();
    //        // clear the 'current' tab class
    //        $('ul.contentTabs a').removeClass('current');
    //        // set the the 'current' tab class for newly selected tab	
    //        $('ul.contentTabs a')
    //        $(newTab).addClass('current');
    //        return false;
    //    }
    //    
    function selectTab(newTab) {

        if (!newTab) {
            contentTab = '#first';
            newTab = 'ul.contentTabs li.first a';
        }
        else {
            contentTab = '#' + newTab;
            newTab = 'ul.contentTabs li.' + newTab + ' a';
        }
        //hide all tab containers
        tabContainers.hide();
        //show the selected tab container
        $(contentTab).show();
        // clear the 'current' tab class
        $('ul.contentTabs a').removeClass('current');
        // set the the 'current' tab class for newly selected tab
        $(newTab).addClass('current');
        return false;
    }


    //define tab click function: if hash is present, do selectTab, otherwise just follow the link
    $('ul.contentTabs a').click(function() {
        if (this.hash.indexOf('#') == -1) {
            return true;
        }
        else {
            tabHash = this.hash.replace('#', '');
            selectTab(tabHash);
            return false;
        }
    });

    function selectFocus(newFocus) {
        if (newFocus > '') {
            $(newFocus).focus();
        }
        return false;
    }
    // select a new default tab if defined by tabToLoad
    selectTab(tabToLoad);

    // select a new focus if defined by itemToFocus
    selectFocus(itemToFocus);

});



