var genericOverlayTimer
var genericOverlayText

function showGenericOverlay(content){
	var autoClose = (typeof arguments[1] == "undefined") ? true : arguments[1];
	// must use a global variable for the content as the overlay "content" is created initially and doesn't update
	// even though the events fire again
	genericOverlayText = content;
	if(jQuery("#generic_overlay").data("overlay") === null){
		jQuery("#generic_overlay").overlay({
			// some mask tweaks suitable for modal dialogs
			mask: {
				color: '#ffffff',
				loadSpeed: 200,
				opacity: 0.7
			}
			,closeOnClick: false
			,top: '15%'
			,load: true
			,onBeforeLoad: function() {
				// grab wrapper element inside content
				var wrap = this.getOverlay().find(".contentWrap");
				wrap.html(genericOverlayText);
			}
			,onLoad: function() {
				if(autoClose) {
					genericOverlayTimer = setTimeout(function(){ 
						jQuery("#generic_overlay").data("overlay").close(); },5000);
				}
			}
			// clear the timer so that a new one starts if the overlay is shown again
			,onClose: function() {
				clearTimeout(genericOverlayTimer);
			}
		});
	} else {
		// on subsequent calls to the overlay, it exists, it just needs to be loaded
		jQuery("#generic_overlay").data("overlay").load();
	}
	
}

