﻿$(document).ready(function () {

    var pathName = window.location.toString();

    if (pathName.indexOf("launch_scorm_course.php") < 1) {        
        $(document).idleTimeout({
            inactivity: 1200000,
            noconfirm: 900000,
            sessionAlive: 90000,
            alive_url: '/heartbeat.php',
            /*click_reset:true,*/
            logout_url: '/logout.php',
            redirect_url: '/logout.php'
        });
    }

    /* Course offerings */
    $(".courseName").click(function (i) {

        $(".courseDesc").hide('slow');
        var id = $(this).attr("id");
        var temp = id.split("_");

        id = temp[1];
        id = "desc_" + id;
        /*var height = $("#"+id).height();
        
        if (height > 600)
        height = 600;*/
        height = 250;

        tb_show($(this).text(), "#TB_inline?height=" + height + "&width=600&inlineId=" + id);
        return false;
    });

    /* FAQ System */
    $(".faqGroup").toggle(function () {
        $(".faqListItems").slideUp('fast');
        $(this).next("ul.faqListItems").slideDown('slow');
        $(".faqGroup").css({ 'font-weight': 'normal', 'color': '#333333' });
        $(this).css({ 'font-weight': 'bold', 'color': '#003399' });


        return false;
    }, function () {
        $(this).css({ 'font-weight': 'normal', 'color': '#333333' });
        $(this).next("ul.faqListItems").slideUp('slow');
        return false;
    });

    $("a.faqItem").mouseup(function () {
        id = $(this).next('.faqBody').attr('id');
        var height = $(this).next('div.faqBody').height();

        if (height > 600)
            height = 600;

        tb_show($(this).text(), "#TB_inline?height=" + height + "&width=600&inlineId=" + id);
    }
    );

    /* document height, width properties */
    doc = function () {
        if (self.innerHeight) {
            doc.pageYOffset = self.pageYOffset;
            doc.pageXOffset = self.pageXOffset;
            doc.innerHeight = self.innerHeight;
            doc.innerWidth = self.innerWidth;
        } else if (document.documentElement &&
    document.documentElement.clientHeight) {
            doc.pageYOffset = document.documentElement.scrollTop;
            doc.pageXOffset = document.documentElement.scrollLeft;
            doc.innerHeight = document.documentElement.clientHeight;
            doc.innerWidth = document.documentElement.clientWidth;
        } else if (document.body) {
            doc.pageYOffset = document.body.scrollTop;
            doc.pageXOffset = document.body.scrollLeft;
            doc.innerHeight = document.body.clientHeight;
            doc.innerWidth = document.body.clientWidth;
        }
        return doc;
    }

    /* Show the review details */
    $(".review_link a").mouseup(
    function () {
        //$(".reviewBody").hide('slow');
        var id = $(this).attr("id");

        var reviewId = id.replace("link_", "review_");

        tb_show($(this).text(), "#TB_inline?height=400&width=600&inlineId=" + reviewId);
        $('#TB_ajaxContent').css('overflow', 'auto');
        // $(this).after("<div class='reviewBody' style='display: none'>"+ html +"</div>");  
        //$(this).next(".reviewBody").show('slow'); 
    }
   );


    $("#tagline-more-link").hover(function () {

        $(".tagline").fadeTo("slow", 0.5, function () { $(this).fadeTo("slow", 0.99) });

    }, function () { });

    /* control the tagline functionality */


    $("#tagline-more-link").toggle(function () {
        var tagline = $("#tagline_hidden").html();
        $.leftcontent = { content: $(".leftcontent").html() };

        var lContent = $(".leftcontent");
        var tag = $(".tagline");

        lContent.slideUp('slow',
            function () {
                $(this).empty();
                $(this).append(tagline);

                $(".leftcontent .hidden").css("display", "block");
                $(this).slideDown('slow');
            }
        );

    }, function () { showContent() }

   );


    /* Bledsoe corner */
    $(".menu-link").mouseup(function () {

        var id = $(this).attr("rel");

        // get the container element and hide all the content divs
        var parent = $("#" + id).parent();
        parent.children("div").hide('slow');
        $("#" + id).show('slow');
    });

});


/*
 * show the content from a fade out
 * $.leftcontent is an object which contains the html in $.leftcontent.content
 */ 
function showContent(){

    $(".leftcontent").slideUp('slow', function(){
       $(".leftcontent").empty(); 
       $(".leftcontent").append($.leftcontent.content);
       $(".leftcontent").slideDown('slow');
        
       
    });
    return false;
};

function getMouseCoord(e){
   (!e) ? e = window.event : e = e;
   objDoc = new doc();
   (e.pageX) ? objDoc.pageX = e.pageX : objDoc.pageX = e.clientX +
objDoc.scrollLeft;
   (e.pageY) ? objDoc.pageY = e.pageY : objDoc.pageY = e.clientY +
objDoc.scrollTop;
   return [e.pageX,e.pageY];
}

function showReview(id)
{
   
   var html = $("#"+id).html();
   $("#"+id).css("left", "300px");
}