$(document).ready(function() {

    //Tabs...
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content

    //On Click Event
    $("ul.tabs li").click(function() {

        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content

        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    });

    //Accordion
    $('.acc_container').hide(); //Hide/close all containers
    $('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container

    //On Click
    $('.acc_trigger').click(function() {
        if ($(this).next().is(':hidden')) { //If immediate next container is closed...
            $('.acc_trigger').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
            $(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
        }
        return false; //Prevent the browser jump to the link anchor
    });
    $("tr:even").addClass("even");

    // Closing Divs - used on Notification Boxes
    $(".canhide").click(function() {

        $(this).fadeOut(700);
    });
    $(".tinymce").wysiwyg({
        rmUnusedControls: true,
        controls: {
            bold: { visible: true },
            italic: { visible: true },
            underline: { visible: true },
            strikeThrough: { visible: true }, // separator: true },
            justifyLeft: { visible: true },
            justifyCenter: { visible: true },
            justifyRight: { visible: true },
            justifyFull: { visible: true },
            indent: { visible: true },
            outdent: { visible: true }, // separator: true },
            increaseFontSize: { visible: true },
            decreaseFontSize: { visible: true }, // separator: true },
            removeFormat: { visible: true }
        },
        initialContent: "<p>Type your chapter here.</p>"
    });

    $("#icondock li a").tipsy({ gravity: 'n' });

    // Load Facebox - simple add "rel="facebook" to any link to activate Modal Dialog
    $('a[rel*=facebox]').facebox({
        loadingImage: '/Content/Images/loading.gif',
        closeImage: '/Content/Images/closelabel.png'
    });

    // Check all the checkboxes when the head one is selected:
    $('.checkall').click(
		function() {
		    $(this).parent().parent().parent().parent().find("input[type='checkbox']").attr('checked', $(this).is(':checked'));
		}
	);
    Cufon.set('fontFamily', 'Colaborate-Thin');
    Cufon.replace('h1, h2, h3');
    Cufon.set('fontFamily', 'Colaborate-Medium');
    Cufon.replace('h1 span, h2 span, h4');
    $("input.replyTo").click(function() {
        $("#inReplyTo").val($(this).attr('rel'));
        $("#comment").focus();
    });
});

