/*
 * 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
*/
// Styles to make it purty... these can be overridden at the page level
document.write('<style type="text/css" media="screen">' + 
	'html,body {margin:0;padding:0;}' + 
	'#ajaxOverlay{text-align:center;background-color:black;filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3;padding:0;margin:0;position:absolute;width:100%;height:100%;left:0;top:0;z-index:10000;overflow:hidden;display:none;}' + 
	'#ajaxContainer{border: 1px #666 solid;text-align:center;display:none;width:600px;background:#fff;padding:10px;margin:auto;z-index:1000000;position:absolute;}' + 
	'</style>');
document.write('<style type="text/css" media="print">' + 
	'html,body {margin:0;padding:0;}' + 
	'#ajaxOverlay,#ajaxPrintClose,.fillContent,.noprint,#devmodeProAdvisorWrap{display:none;}' + 
	'#ajaxContainer{border-width: 0;background:#fff;position:statoc}' + 
	'div {height: auto !important;}' + 
	'</style>');

// 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 + 28).css('width',zW);
}
// Turn off
function turnOff() {$('#ajaxOverlay').hide();$('#ajaxContainer').html('').hide();$('#clientContentArea').removeClass('noprint');$('.footnote').addClass('noprint');}
// Get Content
function fillContent(what) {
	var sPos = document.documentElement.scrollTop + 20;
	$('#ajaxContainer').css('top',sPos);
	$("#ajaxContainer").html('Loading Data... Please Hang On.<br/><br/><img src="/images/icons/loading.gif" alt="" border="0" />');
	$('#ajaxOverlay').show();
	$('#ajaxContainer').show();
	$.ajax({url: what,cache: false,success: function(html){
		$("#ajaxContainer").html(html);
		$('#ajaxContainer').prepend('<div id="ajaxPrintClose" style="height: 24px; border-bottom: 1px solid #ddd; margin: 0 0 15px 0;">' + '<div style="float:left;"><a href="#" onclick="window.print(); sendClickEvent(pageTitle + \'_AJAX_PRINT\'); return false;"><img src="/images/icons/print_blue.gif" alt="Print this Chart" border="0" align="absmiddle"/><strong>Print this page</strong></a></div>' + '<div style="float:right;">' + '<a href="javascript:void(0);" onclick="turnOff(); return false;"><img src="/images/icons/close_blue.gif" width="20" height="20" alt="Close this page" onmouseover="this.src=\'/images/icons/close_red.gif\'; return false;" onmouseout="this.src=\'/images/icons/close_blue.gif\'; return false;" /></a>' + '</div>' + '</div>');
	}});
	$('#clientContentArea').addClass('noprint');
	$('.footnote').removeClass('noprint');
}