<?php
include($O__libPath . "/functions/server/O__launchProgram.php");

// START: Load settings
$O__fileData = O__XMLdata($O__DBpath . "/configs/pageTypes/" . $O__pageType . ".xml", 0, 0);
$O__launchMethod = O__XMLxDataGet($O__fileData,"/settings/setting","launchMethod",0,"value");
$O__launchUser = O__XMLxDataGet($O__fileData,"/settings/setting","launchUser",0,"value");
$O__launchPW = O__XMLxDataGet($O__fileData,"/settings/setting","launchPW",0,"value");
$O__launchDisplay = O__XMLxDataGet($O__fileData,"/settings/setting","launchDisplay",0,"value");
unset($O__fileData);
// END: Load settings

$O__appName = $_POST["O__appName"];
$O__appPathStart = stripslashes($_POST["O__appPathStart"]);
$O__appBin = stripslashes($_POST["O__appBin"]);
$O__appParameters = stripslashes($_POST["O__appParameters"]);
$O__appWaitTime = stripslashes($_POST["O__appWaitTime"]);
$O__appImage = stripslashes($_POST["O__appImage"]);
?>

<script>
	var countDown = 1000 * <?php echo($O__appWaitTime); ?>;
	setTimeout("history.go(-1)", countDown);
	
	// Swap visuals on load
	var	O__menuImgArea = "O__menuImageDisplay";
	var	O__menuInfoArea = "O__menuItemDesc";
	
	window.addEventListener("load", function(){
		document.getElementById(O__menuImgArea).src =  "<?php echo($O__appImage); ?>";
			document.getElementById(O__menuImgArea).height = document.getElementById(O__menuImgArea).width; // match img height with width
		document.getElementById(O__menuInfoArea).innerHTML = "Now launching '<?php echo($O__appName); ?>'";
	});
</script>

<?php
$O__logNotes = "Starting '" . $O__appName . "' with " . $O__appPathStart . $O__appBin;
	if(trim($O__appParameters) != "") { $O__logNotes .= " using the parameters '" . $O__appParameters . "'."; }

O__launchProgram($O__appPathStart,$O__appBin,$O__appParameters);
?>
