/*
 * JQuery Ajax "lightbox" style functionality, which will pop-up a box and fill it with the specified content
 * v1 3/6/2008 Copyright (c) 2008 Intuit, Inc.
 * Author: Matthew Gisonno
 * Page must contain three elements:
 * <div id="ajaxOverlay"></div>
 * <div id="ajaxContainer"></div>
 * <a href="javascript:void(0);" class="fillContent" rel="/yourdirectory/yourpage.html">My Link Title</a>
 * Wrap content with <div id="clientContentArea"></div> to turn content off during print
 * The End
*/

// Jquery stuff...
$(document).ready(function(){
	// On page re-size, center and re-size
	$(window).wresize(content_center);
	// On page load, center and re-size
	content_center();
	// Turn off content if they click the #ajaxOverlay div
	$("#ajaxOverlay").click(function(){turnOff();});
});

// Get actual scrollable html document height
function maxHeight() {  var h=0;  if (window.document.innerHeight>h)   h=window.document.innerHeight;  if (window.document.documentElement.clientHeight>h)   h=window.document.documentElement.clientHeight;  if (window.document.body.clientHeight>h)   h=window.document.body.clientHeight;  return h; }
// Get actual html document width
function maxWidth() {  var w=0;  if (window.document.innerWidth>w)   w=window.document.innerWidth;  if (window.document.documentElement.clientWidth>w)   w=window.document.documentElement.clientWidth;  if (window.document.body.clientWidth>w)   w=window.document.body.clientWidth;  return w; }
// re-size the overlay
function content_center() {
	var zH = maxHeight();
	var zW = maxWidth();
	$('#ajaxOverlay').css('height',zH + 500).css('width',zW + 50);
}
// Turn off
function turnOff() {$('#ajaxOverlay').hide();$('#ajaxContainer').html('').hide();$('#clientContentArea').removeClass('noprint');$('.footnote').addClass('noprint');}
// Get Content
function fillContent(what) {
    var wPos = maxWidth() / 2 - 350;
	var sPos = document.documentElement.scrollTop + 30;
	$('#ajaxContainer').css('top',sPos);
	$('#ajaxContainer').css('left',wPos);
	
	$("#ajaxContainer").html('<center><div class="CPreloader"><br/>Loading Content... Please Wait.<br/><br/><br/><img src="images/loading.gif" alt="" border="0" /><br/><br/></div></center>');
	$('#ajaxOverlay').show();
	$('#ajaxContainer').show();
	$.ajax({url: what,cache: false,success: function(html){
		$("#ajaxContainer").html(html);		
	}});
}