<html>
<head>
	<title>Preview</title>
    <link rel="stylesheet" type="text/css" href="static/css/theme.css"/>
	<link rel="stylesheet" type="text/css" href="static/css/reports.css"/>
	<link rel="stylesheet" type="text/css" href="static/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="static/css/jquery.alerts.css"/>
    <link rel="stylesheet" type="text/css" href="common/css/jquery-ui.custom.css"/>
    <link rel="stylesheet" type="text/css" href="common/css/jqueryslidemenu.css" />


	<script type="text/javascript" src="common/scripts/jquery.js"></script>
    <script type="text/javascript" src="common/scripts/jquery.ajaxqueue.js"></script>
	<script type="text/javascript" src="common/scripts/jqueryslidemenu.js"></script>
	<script type="text/javascript" src="common/scripts/jquery.metadata.js"></script>

	<script type="text/javascript" src="common/scripts/masks.js"></script>
	<script type="text/javascript" src="common/scripts/formatjson.js"></script>
	<script type="text/javascript" src="common/scripts/datatype.js"></script>

	<script type="text/javascript" src="common/scripts/template.js"></script>
	<script type="text/javascript" src="common/scripts/utils.js"></script>
    <script type="text/javascript" src="common/scripts/jquery.blockUI.js"></script>
   	<script type="text/javascript" src="common/scripts/jquery.tools.min.js"></script>
    <script type="text/javascript" src="common/scripts/jquery-ui.min.js"></script>
    <script type="text/javascript" src="common/scripts/jquery.ui.datetimepicker.min.js"></script>
    <script type="text/javascript" src="runtime/scripts/jquery.alerts.js"></script>
	<script type="text/javascript" src="common/scripts/orangescape.controller.js"></script>
	<script type="text/javascript" src="common/scripts/orangescape.portal.js"></script>
	<script type="text/javascript" src="runtime/scripts/orangescape.runtime.portal.js"></script>
	<script type="text/javascript" src="runtime/scripts/orangescape.runtime.controller.js"></script>
	<script type="text/javascript" src="portal/scripts/orangescape.preview.controller.js"></script>
	<script type="text/javascript" src="common/scripts/json2.js"></script>

	<script type="text/javascript" src="runtime/scripts/api.util.js"></script>
    <script type="text/javascript" src="runtime/scripts/jquery.osinit.api.js"></script>
    <script type="text/javascript" src="runtime/scripts/jquery.osinvoke.api.js"></script>
    <script type="text/javascript" src="runtime/scripts/orangescape.dataobject.js"></script>

	<script type="text/javascript" src="runtime/scripts/orangescape.report.controller.js"></script>
	<script type="text/javascript" src="runtime/scripts/orangescape.aggregatereport.controller.js"></script>
    <script type="text/javascript" src="common/scripts/FusionCharts.js"></script>
    <script type="text/javascript" src="common/scripts/jquery.tablegroup.js"></script>
	<script type="text/javascript" src="common/scripts/jquery.tablesorter.pack.js"></script>
	<script>
		var studioWindow = window.parent;
		var OrangeScapeCDNPath = "http://orangescape-release-builds.s3.amazonaws.com";
		#raw
		$(document).ready(function(){
			$(".portlet").osload();
			loadMenu();
			replaceHref();
		});
		#end raw
		function writeToDocument(url)
		{
			var htmlStr = eval("studioWindow.control.Content.slwsgi.dispatch(url,'','GET')");
			document.open();
		    document.write(htmlStr);
		    document.close();
		}

		function loadMenu()
		{
			#if $helper.getMetadataType() == '3'
			var url = "/$metadata.getApplication().getSheetId()/3/menu?mimetype=text/html";
			#raw
			var data = eval("studioWindow.control.Content.slwsgi.dispatch(url,'','GET')");
			var slideMenu =  $("#myslidemenu");
			var defaultHtml =slideMenu.html();
			slideMenu.html(data+defaultHtml);
			var arrowimages={down:['downarrowclass', '/runtime/images/down.gif', 23], right:['rightarrowclass', '/runtime/images/right.gif']};
			jqueryslidemenu.buildmenu("myslidemenu", arrowimages);
	        #end raw
	        #end if
		}

		function replaceHref()
		{
			#raw
			$("a[href]").each(function()
	        {
	        	var hrefValue = $(this).attr('href');
	        	if (hrefValue.indexOf("javascript") == -1)
	          		this.href = "javascript:writeToDocument('"+hrefValue+"')";
	        });
	        #end raw
		}

		var metadataId = $metadata.getMetadataId(['User','UserChanges','AppRole','RoleSubscription','UploadStats'])
	</script>
	<style>
	$css
	</style>
</head>
<body>
<table width="100%" height="100%" border="0" CELLSPACING="0" CELLPADDING="0">
	#if $helper.getMetadataType() == '3'
	<tr>
		<td height='30px' valign="top">
			#include source = $getFileContents($templatePath+"/header.html")
		</td>
	</tr>
	<tr>
		<td style="vertical-align:top;height: 100%;" align="center">
	        <table style="width:1260px;border-spacing: 0px;padding-left:2px;height:100%" cellpadding="0" cellspacing="0">
	            <tr style="line-height:3px;vertical-align:bottom;height:2px;">
	                <td style="width:12px;min-width:12px">&nbsp;</td>
	                <td><img border="0" src="/static/images/top_shadow.png"/></td>
	                <td style="width:13px;min-width:13px">&nbsp;</td>
	            </tr>
	            <tr>
	                <td style="vertical-align:top;text-align:right;padding-top:8px"><img src="/static/images/leftMenuWrap.png"></td>
	                <td style="background: transparent url(/static/images/topMenuBg.png) repeat-x;vertical-align:top;height: 100%;">
	                    <table width="1233px" cellspacing="0" cellpadding="0" align="left" style="padding-top:8px;height:100%">
	                    <tr>
		                    <td>
		                        #include source = $getFileContents($templatePath+"/menu.html")
		                    </td>
	                    </tr>
	#end if
	                    <tr>
	                    <td height="100%" class="content_background">
	                        <table width="100%" height="100%" border="0" CELLSPACING="0" CELLPADDING="0">
    						<tr valign="top">
    							#if $portlet.getTypeName() == 'Worktop':
						    		<td align="center">
						    			#include source = $getFileContents("static/jstl/worktop/worktop.jstl")
						    		</td>
						        #else
							        <td>
							        	<textarea id="layout" style="display: none;">
											<table>
											<tr>
												<td  class="content"></td>
											</tr>
										</table>
										</textarea>
										<textarea id="content" style="display: none;">
								    			#filter WebSafe
													$formJstl
												#end filter
										</textarea>
									</td>
							        <td id="$portlet.getPortletId()" class="portlet {type: '$portlet.getControllerType()', typeName: '$portlet.getTypeName()', form: '$portlet.getForm()', url: '$portlet.getUrl()', metadataType: '$helper.getMetadataType()'}">
							        </td>
						        #end if
    						</tr>
    						</table>
	                    </td>
	                    </tr>
	 #if $helper.getMetadataType() == '3'
	                    </table>
	                </td>
	                <td style="width:13px;min-width:13px;padding-top:8px;text-align:left;vertical-align:top"><img src="/static/images/rightMenuWrap.png"></td>
	            </tr>
	            <tr style="line-height:2px;height:1px;">
	                <td style="width:12px;min-width:12px">&nbsp;</td>
	                <td><img border="0" src="/static/images/bottom_shadow.png"/></td>
	                <td style="width:13px;min-width:13px">&nbsp;</td>
	            </tr>
	            <tr>
	                <td height='10px' colspan="3">
	                    #include source = $getFileContents($templatePath+"/footer.html")
	                </td>
	            </tr>
	        </table>
	    </td>
	</tr>
	#end if
</table>
</body>
</html>