﻿$(function ()
{


  //  //Prevent forms from being submitted twice
  //  $('form').submit(function (evt)
  //  {
  //    var jqClickOnceButton = $(this).find('.click-once');
  //    jqClickOnceButton.find('.img').unbind('click'); //remove click handler for the image

  //    jqClickOnceButton.find('input')
  //    .attr('disabled', 'disabled') //disable the submit button
  //    .val('Wait...');              //Change text to "Wait..."

  //    jqClickOnceButton.addClass('submitting'); //Apply the submitting class
  //  });




  /******* 
  To conform to HTML strict declaration there is no target=blank
  Instead we give the class blank and then set the target using javascript
  ******/
  $('a.blank').attr('target', 'blank');




  /********** Hint icon and popup **********/
  var hintHoverTimer = null;

  $('.hint .content, ').each(function ()
  {
    var height = $(this).height();
    var width = $(this).width();
    $(this).css('margin-top', (height + 15) * -1).css('margin-left', (-1 * width / 2) + 50);
  });

  $('.hint.open-left .content').each(function ()
  {
    var width = $(this).width();
    $(this).css('margin-top', 0).css('margin-left', (width + 10) * -1);
  });

  $('.hint').hover(function (evt)
  {
    clearTimeout(hintHoverTimer);
    var jqHintContent = $(this).find('.content');
    var showHint = function () { jqHintContent.show(); $('.hint .content').not(jqHintContent).hide(); /*Hide all other hints*/ }
    hintHoverTimer = setTimeout(showHint, 800);


    evt.preventDefault();
  },
  function (evt)
  {
    clearTimeout(hintHoverTimer);
    var jqHintContent = $(this).find('.content');
    var hideHint = function () { jqHintContent.hide(); }
    hintHoverTimer = setTimeout(hideHint, 200);
    evt.preventDefault();
  }
  ).click(function ()
  {
    clearTimeout(hintHoverTimer);
    var jqHintContent = $(this).find('.content');
    jqHintContent.show();
    $('.hint .content').not(jqHintContent).hide();  //Hide all other hints
  });



  /********** Modal Divs **********/

  //initialize the modal dialog boxes at correct widths
  $('.modal.nine-hundred').dialog({ autoOpen: false, modal: true, width: 920 });
  $('.modal.six-hundred').dialog({ autoOpen: false, modal: true, width: 619 });
  $('.modal.four-hundred').dialog({ autoOpen: false, modal: true, width: 419 });
  $('.modal.seven-hundred').dialog({ autoOpen: false, modal: true, width: 719 });

  //Allow clicking outside dialog box to close the modal dialog
  $('.ui-widget-overlay').live('click', function ()
  {
    //Iterate through each modal box that is classed with 'click-away' and close it if it's open
    $('.modal.click-away').each(function ()
    {
      if ($(this).dialog("isOpen")) $(this).dialog('close');
    });
  });

  //Close modal dialog when .close is clicked
  $('.modal .close').click(function (evt) { $(this).parent().dialog('close'); evt.preventDefault(); });




});
