﻿$(window).bind("load", function () {
 
  var footerHeight = 0,
      footerTop = 0,
      $footer = $("#afooter");

  positionFooter();

  function positionFooter() {

    footerHeight = $footer.height() + 15;
    footerTop = ($(window).scrollTop() + $(window).height() - footerHeight) + "px";

    if (($(document.body).height() + footerHeight) < $(window).height()) {
      $footer.stop(true, true);
      $footer.hide();
      $footer.css({ position: "absolute" })
        .animate({top: footerTop})
      $footer.fadeIn();
    } else {
      $footer.css({position: "static"})
    }
  }

  $(window).scroll(positionFooter).resize(positionFooter)

  $('a[type=popup]').click(function () { return popup(this.href) }); // add handler for popup windows

});
// Confirmation Message for interfaces that edit in a view and then return to a different view displaying different content.
$(function () {
	var $alert = $('#confirmMsg');
	$alert.prepend('<span class=\'ui-icon ui-icon-circle-close\' style=\'float:left;\'></span>');
	if ($alert.length) {
		var alerttimer = window.setTimeout(function () {
			$alert.trigger('click');
		}, 6000);
		$alert.animate({ height: $alert.css('line-height') || '50px' }, 200)
				.click(function () {
					window.clearTimeout(alerttimer);
					$alert.animate({ height: '0' }, 500)
				});
	}

	var path = (location.pathname).replace(/default.aspx/i, '');
	if (path == '/')
		$("#navlist a[href='/']").parents("li").each(function () {
			$(this).addClass("active");
		});
	
	$("#navlist a[href $='" + path + "']").parents("li").each(function () {
		if (path != '/') $(this).addClass("active");
	});
});

function getconfirm() {
  if (confirm("Click \"OK\" to delete this record."))
    return true;
  else
    return false;
}

  function popup(url) {
  	name = 'examples';
  	args = 'height=451,width=721,left=20,top=43,directories=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0';
	newwindow=window.open(url, name, args);
	if (window.focus) {newwindow.focus()}
	return false;
}
  



