﻿
function OpenWindow(PageName) {
    window.open(PageName, "PopUpCalendar", "width=900,height=700,toolbars=no,scrollbars=no,status=no,resizable=yes"); 
}

function CheckWindow() {
    ChildWindow.close(); 
}

function SetPosition(seconds) {
   
    //Get Player
    var oPlayer = top.frames['Video'].window.document.getElementById("MediaPlayer1");

    //Set Position based on HTML5 Video, SilverLight or Windows Media Player
    if (oPlayer.tagName.toLowerCase() == "video") {

        //HTML5 Video
        oPlayer.currentTime = seconds;

    } else if (oPlayer.tagName.toLowerCase() == "object" && oPlayer.type.toLowerCase() == "application/x-silverlight") {

        //SilverLight Player
        oPlayer.content.Player.SeekToTime(seconds);

    } 
    else {

        //Windows Media Player
        // some browsers require that you access the EMBED tag inside the OBJECT tag 
        if (oPlayer.controls != undefined)
            oPlayer.controls.currentPosition = seconds;
        else 
        {
            var oEmbed = $(oPlayer).find("embed");
            if (oEmbed.length == 0) return;
            if (oEmbed[0].controls == undefined) return;
            oEmbed[0].controls.currentPosition = seconds;
        }
    }
}

function lnkAddComment_click(sLinkID, sTextboxID, sCheckboxID) 
{
    var oLink = $(sLinkID);
    var oText = $(sTextboxID);
    var sPublic;
    if ($(sCheckboxID)[0].checked)
        sPublic = "False";
    else
        sPublic = "True";

    //if link already contains &Public then the user has tried to click it twice
    if (oLink.attr("href").indexOf("&Public") != -1) {
        oLink.attr("href", "#");
        return false;
    }

    var sLink = oLink.attr("href") + "&Public=" + sPublic + "&Comment=" + escape(oText.val());

    var fSplitView = false;
    try
    {
         if (HandleSplitViewAddComment != undefined)
            fSplitView = true;
    }
    catch(ex)
    {
        fSplitView = false;    
    }
    
    if (fSplitView) {
        oLink.attr("href", "#");
        HandleSplitViewAddComment(sLink);
        return false;
    }
    else 
    {
        oLink.attr("href", sLink);

        oText.val("");
        return true;
    }
}

// resizable text area
$(function() {

    $(".resizableText").live("keyup", function() {

        var iScrollHeight = $(this)[0].scrollHeight;
        var iHeight = $(this).height();

        if (iScrollHeight > 80)
            iScrollHeight = 80;


        if (iScrollHeight > (iHeight + 8))
            $(this).height(iScrollHeight);

        if ($(this).val().indexOf("Type in your comments here") == -1)
            return;

        var newTxt = $(this).val();
        newTxt = newTxt.replace("Type in your comments here", "");
        $(this).html(newTxt);
        $(this).css("color", "Black");
    });

    $(".resizableText").live("click", function() {

        if ($(this).val() != "Type in your comments here")
            return;

        $(this).html("");
        $(this).css("color", "Black");
    });
});

