﻿$(document).ready(function() {
  
  //  Fade Out Responses
  function fadeOutResponses()
  {
    $("div.notification").animate({ opacity: 0 }, 500).slideUp(500);
  } 
  setTimeout(fadeOutResponses, 4000);

});

// Controls the admin menu

$(document).ready(function() {
$('#adminMenuToggle').click(function() { $('.adminMenu ul').slideToggle(250); $('#adminMenuToggle').toggleClass("adminMenu-open"); return false; });
});

// Controls the new page drop downs
$(document).ready(function() {
$('#YearDD a.fancyLink').click(function() { $('#YearDD ul').slideToggle(250); return false; });
});

// Controls the new page drop downs
$(document).ready(function() {
$('#MonthDD a.fancyLink').click(function() { $('#MonthDD ul').slideToggle(250); return false; });
});


$(function() {
  $('a.closePopup').click(function() {
    window.close();
    return false;
  });
});


/*
  popups with jquery
*/

$(function() { // Run this code when the document's done loading      

  // Apply this code to each link with class="popup"  
  $("a.popup").each(function(i) {

    // Add an onClick behavior to this link  
    $(this).click(function(event) {

      // Prevent the browser's default onClick handler  
      event.preventDefault();

      // Grab parameters using jQuery's data() method  
      var params = $(this).data("popup") || {};

      // Use the target attribute as the window name  
      if ($(this).attr("target")) {
        params.windowName = $(this).attr("target");
      }

      // Pop up the window  
      var windowObject = UTIL.popup.open(this.href, params);

      // Save the window object for other code to use  
      $(this).data("windowObject", windowObject);
    });
  });
});


/*
 popups
*/

var UTIL = UTIL || {};
UTIL.popup = UTIL.popup || {};

/** 
* Open popup window 
* 
* Opens a popup window using as little as a URL. An optional params object can 
* be passed. 
* 
* @param {String} href 
* @param {Object} params 
* @return {WindowObjectReference} 
*/
UTIL.popup.open = function(href, params) {
  // Defaults (don't leave it to the browser)  
  var defaultParams = {
    "width": "800",   // Window width  
    "height": "800",   // Window height  
    "top": "30",     // Y offset (in pixels) from top of screen  
    "left": "30",     // X offset (in pixels) from left side of screen  
    "directories": "no",    // Show directories/Links bar?  
    "location": "no",    // Show location/address bar?  
    "resizeable": "yes",   // Make the window resizable?  
    "menubar": "no",    // Show the menu bar?  
    "toolbar": "no",    // Show the tool (Back button etc.) bar?  
    "scrollbars": "yes",   // Show scrollbars?  
    "status": "no"     // Show the status bar?  
  };

  var windowName = params["windowName"] || "new_window";

  var i, useParams = "";

  // Override defaults with custom values while we construct the params string  
  for (i in defaultParams) {
    useParams += (useParams === "") ? "" : ",";
    useParams += i + "=";
    useParams += params[i] || defaultParams[i];
  }

  return window.open(href, windowName, useParams);
};


/*
Correctly handle PNG transparency in Win IE 5.5 & 6.
http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.
*/

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (document.body.filters)) {
  for (var i = 0; i < document.images.length; i++) {
    var img = document.images[i]
    var imgName = img.src.toUpperCase()
    if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
      var imgID = (img.id) ? "id='" + img.id + "' " : ""
      var imgClass = (img.className) ? "class='" + img.className + "' " : ""
      var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
      var imgStyle = "display:inline-block;" + img.style.cssText
      if (img.align == "left") imgStyle = "float:left;" + imgStyle
      if (img.align == "right") imgStyle = "float:right;" + imgStyle
      if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
      var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
      img.outerHTML = strNewHTML
      i = i - 1
    }
  }
}

