	function getFullscreenDialogSize(){
		// Get Window size and size down some for border
		var width = $j(window).width()-15;
		var height = $j(window).height()-15;
		
		return [width,height];
	}
	
	function resizeDialog() {
		// Change dialog box size
		var size = getFullscreenDialogSize();
		$j("#simulateuser-content").dialog('option', 'width', size[0]);
		$j("#simulateuser-content").dialog('option', 'height', size[1]);

		// Change dialog content area size
		var lessHeight = ($j('.ui-dialog-title').height() + $j('.ui-dialog-buttonpane').height() + 45);
		$j("#simulateuser-content").css('height', size[1] - lessHeight);
	}
	
	$j(window).resize( function(){
		resizeDialog();
	});
	
	$j(document).ready(function(){

		var size = getFullscreenDialogSize();						
		// Dialog - open options							
		$j("#simulateuser-content").dialog({
				title: 'Simulate User',
				bgiframe: true,
				zIndex: 99999,
				position: [5,5],
				autoOpen: false,
				height: size[1],
				width: size[0],
				modal: true,
				closeOnEscape: false,
				draggable: false,
				resizable: false,
				dialogClass: 'dialog-fullscreen',
				open: function() {
					$j('html').css('overflow', 'hidden');

					// Only hide body overflow on IE, can messup Firefox
					if($j.support.leadingWhitespace == false)
					{			
						$j('body').css('overflow', 'hidden');		
					}
					
					$j('.ui-widget-overlay').css('width', $j(window).width());
					$j('.ui-widget-overlay').css('height', $j(window).height());
					resizeDialog();
					
					$j('.modal-dialog').css('display', 'block');
					$j('#content').hide(0);
					$j('#footNotes').hide(0);
					$j('.dialog-fullscreen').css('top', '5px');
				},
				buttons: {				
				    'Terminate Session': function() {				
				    	$j(this).dialog('close');				
				    }				
				},
				close: function() {
					$j('html').css('overflow', 'auto');
					if($j.support.leadingWhitespace == false)
					{			
						$j('body').css('overflow', 'auto');
					}
					$j('.modal-dialog').css('display', 'none');
					$j('#content').show(0);
					$j('#footNotes').show(0);
					// Call "OnClose" type of function here
					onEndOfSimulation();
				}
			});
			
		$j('a.dialog-link').click(function(){
		
			// Insert iFrame into dialog-content div
			$j('#simulateuser-content').html("<iframe id=\"dialog-iframe\" frameborder=\"0\" class=\"dialog-iframe\" src=\"/lfg/ho/simulateuser/apps/index.html\" width=\"100%\" height=\"100%\">Please visit: <a href=\"/lfg/ho/simulateuser/apps/index.html\">Blank HTML page</a></iframe>");
		
			var id = $j(this).attr('id');
			if (id == 'simulateuser-link') {
				$j('#simulateuser-content').dialog('open');
			}else if (id == 'terminatesimulation-link') {
				$j('#simulateuser-content').dialog('close');
			}
			else{ 
				alert('Unknown dialog requested.');
			}
		})
	});
