<?ggf
/*
	Create the form in the HTML dialog box
*/
	form.addColorButton("textcolor","Text Color","#000000");
	form.addColorButton("bgcolor","Background Color","#ffffff");
	form.addCheckBox("fullscreen","Fullscreen",false);
	form.addLine();
	form.addFileNameInput("swf","Flash Object Movie","Flash Object","Flash (*.swf)");
	form.addLine();
	form.addCheckBox("showuserdata","Show User Data Table",true);
	form.addColorButton("tablebordercolor","Table Border Color","#777777");
	form.addColorButton("tabletextcolor","Table Text Color","#000000");
	form.addColorButton("tablebgcolor","Table Background Color","#dddddd");
	form.addLine();
	form.addCheckBox("manifest","Create HTML5 Cache Manifest",false);
	// define possible output formats
	form.addOutputFormat("HTML (.html)","html");
	form.addOutputFormat("HTML (.htm)","htm");
	
?>
<?ggs
	var windowWidth=output.windowWidth;
	if (formvalue["_gg_margin_left"]) windowWidth+=formvalue["_gg_margin_left"];
	if (formvalue["_gg_margin_right"]) windowWidth+=formvalue["_gg_margin_right"];
	var windowHeight=output.windowHeight;
	if (formvalue["_gg_margin_top"]) windowHeight+=formvalue["_gg_margin_top"];
	if (formvalue["_gg_margin_bottom"]) windowHeight+=formvalue["_gg_margin_bottom"];
	
// Functions to write out HTML5 and Flash code
	function addHtml5Code() {
?>	
			// create the object player with the container
			obj=new object2vrPlayer("container");
<?ggs if (output.skinFile!="") { ?>
			// add the skin object
			skin=new object2vrSkin(obj);
			// load the configuration
<?ggs } ?>
<?ggs
	if (formvalue["_gg_object"]) {
			objstr=formvalue["_gg_object"].toString();
			arr=objstr.split("\n");
			objstr=arr.join("';\n\t\t\t\tstr+='");
?>
			str='<?ggs document.write(objstr); ?>';
			obj.readConfigString(str);
<?ggs
	} else {
?>
			obj.readConfigUrl("<?ggs document.write(outputfile); ?>");
<?ggs
	}
?>
			// hide the URL bar on the iPhone
			hideUrlBar();
<?ggs
	}
	function addFlashCode() {
?>
			var flashvars = {};
			var params = {};
			params.quality = "high";
			params.bgcolor = "<?ggs document.write(formvalue["bgcolor"]); ?>";
			params.allowscriptaccess = "sameDomain";
			params.allowfullscreen = "true";
			var attributes = {};
			attributes.id = "pano";
			attributes.name = "pano";
			attributes.align = "middle";
			swfobject.embedSWF(
				"<?ggs document.write(document.encodeUrl(document.expandVariables(formvalue['swf']))); ?>", "container", 
<?ggs if (formvalue["fullscreen"]=="false") {  ?>
				"<?ggs document.write(windowWidth); ?>", "<?ggs document.write(windowHeight); ?>",
<?ggs } else {  ?>
				"100%", "100%",
<?ggs }  ?>
				"9.0.0", "expressInstall.swf", 
				flashvars, params, attributes);
<?ggs
	}
?>
<!DOCTYPE html>
<?ggs 
var manifest;
if (formvalue["manifest"]=="true") {
	// create a HTML5 Offline Application Cache
	manifestfile=document.expandVariables("$n.manifest");
	d=new Date();
	manifest="CACHE MANIFEST\n";
	manifest+="# created with Object2VR, " + d.toLocaleString() + "\n"; // make sure the file updates
	for(var key in formvalue["_gg_filelist"]) {
		manifest+=formvalue["_gg_filelist"][key] + "\n";
	}
	document.writeln('<html manifest="' + manifestfile + '">');	
} else {  ?>
<html>
<?ggs }  ?>
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
		<title><?ggs document.writeEncoded(document.expandVariables(config.userdata.title)); ?></title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<?ggs
	addFlashFallback=(formvalue['swf']!='');
	if (addFlashFallback) {
		document.addfile("../3rdparty/swfobject/swfobject.js","swfobject.js");
		manifest+="swfobject.js\n";
		document.writeln('\t\t<script type="text/javascript" src="swfobject.js">');
		document.writeln('\t\t</script>');
	}
	if (output.skinFile!="") {
			manifest+="skin.js\n";
	}
?>
		<script type="text/javascript">
			// hide URL field on the iPhone/iPod touch
			function hideUrlBar() {
<?ggs if (formvalue["fullscreen"]=="true") {  ?>
				if (((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))) {
					container = document.getElementById("container");
					if (container) {
						var cheight;
						switch(window.innerHeight) {
							case 208:cheight=268; break; // landscape
							case 336:cheight=396; break; // portrait, in call status bar
							case 356:cheight=416; break; // portrait 
							default:
								cheight=window.innerHeight;
						}
						if ((container.offsetHeight!=cheight) || (window.innerHeight!=cheight)) {
							container.style.height=cheight + "px";
							setTimeout(function() { hideUrlBar(); }, 1000);
						}
					}
				}
<?ggs }  ?>				
				if (window.pageYOffset==0) {
					window.scrollTo(0, 1);
<?ggs if (formvalue["fullscreen"]=="false") {  ?>
					// repeat every second for slow rendering pages
					setTimeout(function() { hideUrlBar(); }, 3000);
<?ggs }  ?>				
				}
			}
		</script>
		<style type="text/css" title="Default">
			body, div, h1, h2, h3, span, p {
				font-family: Verdana,Arial,Helvetica,sans-serif;
				color: <?ggs document.write(formvalue["textcolor"]); ?>; 
			}
<?ggs if (formvalue["fullscreen"]=="true") {  ?>
			/* fullscreen */
			html {
				height:100%;
			}
			body {
				height:100%;
				margin: 0px;
				overflow:hidden; /* disable scrollbars */
			}
<?ggs }  ?>
			body {
			  font-size: 10pt;
			  background : <?ggs document.write(formvalue["bgcolor"]); ?>; 
			}
			table,tr,td {
				font-size: 10pt;
				border-color : <?ggs document.write(formvalue["tablebordercolor"]); ?>;
				background : <?ggs document.write(formvalue["tablebgcolor"]); ?>; 
				color: <?ggs document.write(formvalue["tabletextcolor"]); ?>; 
				border-style : solid;
				border-width : 2px;
				padding: 5px;
				border-collapse:collapse;
			}
			h1 {
				font-size: 18pt;
			}
			h2 {
				font-size: 14pt;
			}
			.warning { 
				font-weight: bold;
			} 
		</style>	
	</head>
	<body onorientationchange="hideUrlBar();">
<?ggs if (formvalue["fullscreen"]=="false") {  ?>
		<h1><?ggs document.writeEncoded(document.expandVariables(config.userdata.title)); ?></h1>
		<br>
<?ggs }  ?>
		<script type="text/javascript" src="object2vr_player.js">
		</script>
<?ggs if (output.skinFile!="") { ?>
		<script type="text/javascript" src="skin.js">
		</script>
<?ggs } ?>
<?ggs if (formvalue["fullscreen"]=="false") {  ?>
		<div id="container" style="width:<?ggs document.write(windowWidth); ?>px;height:<?ggs document.write(windowHeight); ?>px;">
<?ggs } else {  ?>
		<div id="container" style="width:100%;height:100%;">
<?ggs }  ?>
		This content requires HTML5 &amp; Javascript or Adobe Flash Player Version 9 or higher.
		</div>

		<script type="text/javascript">
<?ggs if (addFlashFallback) { 
?>
		if (swfobject.hasFlashPlayerVersion("9.0.0")) {
<?ggs addFlashCode(); ?>			
		} else {
<?ggs addHtml5Code(); ?>
		}
<?ggs 
	} else { 		
		addHtml5Code(); 
	}  
?>		
		</script>
		<noscript>
			<p><b>Please enable Javascript!</b></p>
		</noscript>
<?ggs
	if ((formvalue["showuserdata"]=="true") && (formvalue["fullscreen"]=="false")) { 
?>		
		<p>
		<table>
			<tr>
				<td><b>Description</b></td>
				<td><?ggs document.writeEncoded(document.expandVariables(config.userdata.description)); ?></td>
			</tr>
			<tr>
				<td><b>Author</b></td>
				<td><?ggs document.writeEncoded(document.expandVariables(config.userdata.author)); ?></td>
			</tr>
			<tr>
				<td><b>Date/Time</b></td>
				<td><?ggs document.writeEncoded(document.expandVariables(config.userdata.dateTime)); ?></td>
			</tr>
			<tr>
				<td><b>Copyright</b></td>
				<td><?ggs document.writeEncoded(document.expandVariables(config.userdata.copyright)); ?></td>
			</tr>
		</table>
<?ggs
}
if (formvalue["manifest"]=="true") {
	document.createfile(manifestfile,manifest);	
}	
?>
	</body>
</html>
