 /*
 * Customized based on Thickbox 3 - One Box To Rule Them All. By Cody Lindley (http://www.codylindley.com) Copyright (c) 2007 cody lindley Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/

/*
 * contentDivId - the ID of the div containing the popup content
 * hideOverlay - true if the window should NOT be greyed out
 * dynamicHeight - true if the window should be vertically resized based on content
 * vertAdj - the number of pixels used to calculate the amount by which to vertically adjust a dynamic sized popup
 */
function showPopup(contentDivId, hideOverlay, dynamicHeight, vertAdj){
	if($(".TB_window").size() > 0){
		tb_remove(true);
	}
	$('#' + contentDivId).css({display: 'block'});
	if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
		$("body","html").css({height: "100%", width: "100%"});
		$("html").css("overflow","hidden");
		$(".TB_HideSelect").remove();
		$("body").append("<iframe id='" + contentDivId + "_hide' class='TB_HideSelect' src='blank.jsp'></iframe>");
		if(dynamicHeight){
			$('#' + contentDivId + '_hide').css({height: $('#' + contentDivId).height()});
		}
	}else{//all others
		if(dynamicHeight && vertAdj){
			vertAdj = vertAdj - 10;
		}
	}
	if(!hideOverlay){
		if(document.getElementById("TB_overlay") === null){
			$("body").append("<div id='TB_overlay'></div>");
		}
	}
	
	if(dynamicHeight && vertAdj){
		$('#' + contentDivId).css({top: Math.max(0, vertAdj - $('#' + contentDivId).height())});
	}
	$('#' + contentDivId).addClass("TB_window");
	 return false;
}

function hidePopup(id) {
	$("#" + id).hide();
	tb_remove();
}

function tb_remove(skipFade) {
	if(skipFade){
		$(".TB_window").hide();
		$('#TB_overlay,.TB_HideSelect').remove();
		$(".TB_window").removeClass("TB_window");
	} else {
		$(".TB_window").fadeOut("fast",function(){$('#TB_overlay,.TB_HideSelect').remove();$(".TB_window").removeClass("TB_window");});
	}
	
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
		$("body","html").css({height: "auto", width: "auto"});
		$("html").css("overflow","");
	}
	document.onkeydown = "";
	return false;
}

function editToAddress(edit){
	
	var toAdd = document.getElementById("toAdd");
	if(edit=='false')
	toAdd.style.display='none';
	else
	{
		try 
		{
			toAdd.style.display='table-row';
		}
		catch (e) 
		{
			toAdd.style.display='block';
		}
	}
}