﻿/// <reference path="http://ajax.microsoft.com/ajax/jQuery/jquery-1.3.2-vsdoc.js" />

// Modal Dialog code and styling adapted from:
// http://www.queness.com/post/1696/create-a-beautiful-looking-custom-dialog-box-with-jquery-and-css3

$(document).ready(function() {
    var $linkTitle;
    // when user clicks on button, close the dialog	
    $('a.button').click(function() {
        //$('#dialog-overlay, #dialog-box').hide();
        $("#dialog-overlay").hide();
        $("#dialog-box").slideUp(500);
        return false;
    });

    $("a.dlg").hover(
      function() {
          $linkTitle = $(this).attr("title");
          $(this).attr("title", "");
      },
      function() {
          $(this).attr("title", $linkTitle);
      }
    );

    var $yOffset = 10;
    $('a.dlg').click(function($e) {
        var $title = $(this).siblings("input.hideTitle").val();
        var $y = $e.pageY + $yOffset;
//        var $values = $(this).siblings("input.time").val();
//        var $times = $values.split("|");
//        var $startTime = $times[0];
//        var $endTime = $times[1];
//        var $location = $(this).siblings("input.hideLocation").val();
//        if ($location != undefined) {
//            var $text = $title + "<br/><br/>Location: " + $location + "<br/><br/>Time: " + $startTime + " - " + $endTime;
//        }
//        else {
//            var $text = $title + "<br/><br/>Time: " + $startTime + " - " + $endTime;
        //        }

        popup($title, $y);
        $e.preventDefault();
    });

});

//Popup dialog
function popup(message,y) {

    // get the screen height and width  
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

    // calculate the values for center alignment
    //var dialogTop = (maskHeight / 3) - ($('#dialog-box').height());
    var dialogTop = y - ($('#dialog-box').height());
    var dialogLeft = (maskWidth / 2) - ($('#dialog-box').width() / 2);

    // assign values to the overlay and dialog box
    $('#dialog-overlay').css({ height: maskHeight, width: maskWidth }).show();

    var $dlg = $('#dialog-box');
    //$('#dialog-box').css({ top: dialogTop, left: dialogLeft }).show();
    $dlg.hide().css({ top: dialogTop, left: dialogLeft }).slideDown(500);

    // display the message
    $('#dialog-message').html(message);

}