<%@ Language="VBScript" %>
<!--#include file="../config.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Aurigma Image Uploader Demos &mdash; User Quota Demo</title>
	<meta http-equiv="MSThemeCompatible" content="yes" />
	
	<link href="../common.css" type="text/css" rel="stylesheet" />
	<link href="style.css" type="text/css" rel="stylesheet" />

	<script type="text/javascript" src="../Scripts/iuembed.js"></script>
	<script type="text/javascript" src="../Scripts/iuembed.InstallationProgress.js"></script>	
	<style type="text/css">
		.ScreenStyle {background-color:#ffffff;font-family:verdana;font-size:11px;padding:10px;text-align:center}
    </style>
	<script type="text/javascript">
//<![CDATA[
var imageUploader1 = null;

function formatFileSize(value) {
	if (value < 1024) {
		return value + " b";
	}
	else if (value < 1048576) {
		return Math.round(value / 1024) + " kb";
	}
	else {
		return Math.round(value / 10485.76) / 100 + " mb";
	}
}

function ImageUploader1_FullPageLoad() {
	imageUploader1 = getImageUploader('ImageUploader1');
	document.getElementById("spanMaxFileCount").innerHTML = imageUploader1.getMaxFileCount();
	document.getElementById("spanMaxTotalFileSize").innerHTML = formatFileSize(parseInt(imageUploader1.getMaxTotalFileSize()));

	imageUploader1.style.width = "100%";
	imageUploader1.parentNode.style.width = "100%";
	//Installation Progress for Java version of IU add 2 parent controls around ImageUploader object
	if (iu.getControlType() == "Java")
		imageUploader1.parentNode.parentNode.style.width = "100%";
}

function ImageUploader1_UploadFileCountChange() {
	if (imageUploader1) {	
		document.getElementById("spanUploadFileCount").innerHTML = parseInt(imageUploader1.getUploadFileCount());
		var imgWidth = parseInt(imageUploader1.getUploadFileCount()) / parseInt(imageUploader1.getMaxFileCount()) * 132;	
		document.getElementById("imgUploadFileCount").style.width = Math.round(imgWidth) + "px";

		document.getElementById("spanTotalFileSize").innerHTML = formatFileSize(parseInt(imageUploader1.getTotalFileSize()));
		imgWidth = parseInt(imageUploader1.getTotalFileSize()) / parseInt(imageUploader1.getMaxTotalFileSize()) * 132;
		document.getElementById("imgTotalFileSize").style.width = Math.round(imgWidth) + "px";
	}
}

function ImageUploader1_ViewChange(Pane) {
	if (imageUploader1) {
		document.getElementById("selectView").selectedIndex = parseInt(imageUploader1.getFolderView());
	}
}

function selectView_change() {
	if (imageUploader1) {
		var selectView = document.getElementById("selectView");
		imageUploader1.setFolderView(parseInt(selectView.options[selectView.selectedIndex].value));
	}
}
//]]>
	</script>

</head>
<body>
	<form>
		<h1><a href="../default.asp">Aurigma Image Uploader Demos</a> &rarr; User Quota Demo</h1>
		<p>
			This demo application illustrates how you can use extend functionality of Image
			Uploader through HTML and JavaScript. It demonstrates how to set and display upload
			restrictions (maximum file count and size). It does not allow to upload more than
			10 files and 5MB (can be configured in the code).
		</p>
		<p>
			Additionally, this application highlights the following features:
		</p>
		<ul>
			<li>Extended appearance customization.</li>
			<li>Automatic recovery of broken connection.</li>
			<li>Custom buttons in HTML.</li>
			<li>Upload thumbnail along with a source file.</li>
		</ul>
		<div class="note">
			<h4>Note</h4>
			<p>
				This demo application <strong>deletes all previously uploaded files</strong>.
				Keep in mind that it is a feature of this demo, not of Image Uploader itself. If
				you <strong>do not want to delete uploaded files</strong>, you should modify the
				upload processing page specified by the <strong>Action</strong> parameter.
			</p>
		</div>
		
		<div class="Ab">
			<div class="Ab-b">
				<h2>User&nbsp;Quota</h2>
							
				<div class="Info">
					Select up to <strong><span id="spanMaxFileCount">x</span></strong> files for upload.
					<br />
					<br />
					<strong><span id="spanUploadFileCount">0</span></strong>&nbsp;files are selected.
					<br />
					<table cellspacing="0" cellpadding="0" border="0" class="Progress">
						<tbody>
							<tr>
								<td class="Left">
								</td>
								<td class="Panel">
									<img id="imgUploadFileCount" src="../Images/ProgressGreen.gif" alt="" class="Value" /></td>
								<td class="Right">
								</td>
							</tr>
						</tbody>
					</table>
					<br />
					<br />
					The total file size should be smaller then <strong><span id="spanMaxTotalFileSize">x</span></strong>.
					<br />
					<br />
					Total size os selected files is <strong><span id="spanTotalFileSize">0</span></strong>.
					<br />
					<table cellspacing="0" cellpadding="0" border="0" class="Progress">
						<tbody>
							<tr>
								<td class="Left">
								</td>
								<td class="Panel">
									<img id="imgTotalFileSize" src="../Images/ProgressGreen.gif" alt="" class="Value" /></td>
								<td class="Right">
								</td>
							</tr>
						</tbody>
					</table>
				</div>
			</div>
			<div class="Ab-A">
				<ul class="Toolbar">
					<li><a class="selectAll" href="#" onclick="imageUploader1.SelectAll();return false;">Select All</a></li>
					<li><a class="selectNone" href="#" onclick="imageUploader1.DeselectAll();return false;">Deselect All</a></li>
					<li><a class="send" href="#" onclick="imageUploader1.Send();return false;">Upload</a></li>
					<li><a class="refresh" href="#" onclick="imageUploader1.Refresh();return false;">Refresh</a></li>
					<li>
						<select id="selectView" onchange="selectView_change();">
							<option value="0" selected="selected">Thumbnails</option>
							<option value="1">Icons</option>
							<option value="2">List</option>
							<option value="3">Details</option>
						</select>
					</li>
				</ul>
				<script type="text/javascript">
//<![CDATA[
//Create JavaScript object that will embed Image Uploader to the page.
var iu = new ImageUploaderWriter("ImageUploader1", 610, 490);

//For ActiveX control full path to CAB file (including file name) should be specified.
iu.activeXControlCodeBase = "../Scripts/ImageUploader6.cab";
iu.activeXControlVersion = "6,5,1,0";

//For Java applet only path to directory with JAR files should be specified (without file name).
iu.javaAppletJarFileName = "ImageUploader6.jar";
iu.javaAppletCodeBase = "../Scripts/";
iu.javaAppletCached = true;
iu.javaAppletVersion = "6.5.1.0";

iu.showNonemptyResponse = "off";

//Configure License Keys
iu.addParam("LicenseKey", "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX;XXXXX-XXXXX-XXXXX-XXXXX-XXXXX");

//Configure appearance and behaviour.
iu.addParam("PaneLayout", "TwoPanes");
iu.addParam("TreePaneWidth", "205");
iu.addParam("ShowButtons", "False");
iu.addParam("ShowDebugWindow", "true");

//Configure colors.
iu.addParam("BackgroundColor", "#ffffff");
iu.addParam("SplitterLineColor", "#0066cc");

//Configure border and splitter line style.
iu.addParam("FolderPaneBorderStyle", "None");
iu.addParam("UploadPaneBorderStyle", "None");
iu.addParam("TreePaneBorderStyle", "None");
iu.addParam("SplitterLineStyle", "Dot"); //NOT SUPPORTED IN JAVA

//Configure thumbnail settings.
iu.addParam("UploadThumbnail1FitMode", "Fit");
iu.addParam("UploadThumbnail1Width", "120");
iu.addParam("UploadThumbnail1Height", "120");
iu.addParam("UploadThumbnail1JpegQuality", "60");

//Configure user quota restriction. In real-life application these values should be 
//loaded from server.
iu.addParam("MaxFileCount", "10");
iu.addParam("MaxTotalFileSize", "5242880");

//Configure upload settings.
iu.addParam("FilesPerOnePackageCount", "1");
iu.addParam("AutoRecoverMaxTriesCount", "10");
iu.addParam("AutoRecoverTimeOut", "10000");

//Configure URL files are uploaded to.
iu.addParam("Action", "upload.asp");

//Configure URL where to redirect after upload.
iu.addParam("RedirectUrl", "gallery.asp");

//Add event handlers.
iu.addEventListener("UploadFileCountChange", "ImageUploader1_UploadFileCountChange");
iu.addEventListener("ViewChange", "ImageUploader1_ViewChange");
iu.addEventListener("FullPageLoad", "ImageUploader1_FullPageLoad");

//Create installation progress.
var ip = new InstallationProgressExtender(iu);
ip.setProgressImageUrl("../Scripts/InstallationProgress.gif");
ip.setProgressCssClass("ScreenStyle");
ip.setInstructionsCssClass("ScreenStyle");

//Tell Image Uploader writer object to generate all necessary HTML code to embed 
//Image Uploader to the page.
iu.writeHtml();
//]]>
					</script>
	</div>
		</div>
	</form>
</body>
</html>
<!--END-->