/**
 * @author tim@carpages.ca
 */
function show_image_uploader(postUrl, redirectUrl, options) {
	
	// Create JavaScript object that will embed Image Uploader to the page.
	var iu = new ImageUploaderWriter("ImageUploader1", '100%', 510);
	
	// For ActiveX control full path to CAB file (including file name) should be specified.
	iu.activeXControlCodeBase = "/js/aurigma/resources/ImageUploader5.cab";
	iu.activeXControlVersion = "5,0,15,0";
	
	// For Java applet only path to directory with JAR files should be specified (without file name).
	iu.javaAppletJarFileName = "ImageUploader5.jar";
	iu.javaAppletCodeBase = "/js/aurigma/resources/";
	iu.javaAppletCached = true;
	iu.javaAppletVersion = "5.0.15.0";
	
	iu.showNonemptyResponse = "off";
	
	// Configure appearance.
	iu.addParam("PaneLayout", "ThreePanes");
	iu.addParam("ShowDebugWindow", "true");
	iu.addParam("AllowRotate", "false");
	iu.addParam("BackgroundColor", "#ccccff");
	iu.addParam("MessageUploadCompleteText", "");
	
	// Configure behaviour
	iu.addParam("EnableFileViewer", "False");
	
	var max_images = options.max_images ? options.max_images : 6;
	var max_images_msg = options.max_images_msg ? options.max_images_msg : 'You may only upload [Limit] photos for this vehicle.';
	
	iu.addParam("MaxFileCount", max_images);
	iu.addParam("MessageMaxFileCountExceededText", max_images_msg);
	
	// second two are demos
	// Configure License Keys  
	iu.addParam("LicenseKey", "71050-10000-616C2-27D76-B7A80;72050-10000-E0B1F-9F03E-C67BF;71050-4338A-00000-09EC4-D2986;72050-4338A-00000-08333-86099");
	
	// Configure source mode
	iu.addParam("UploadSourceFile", "False");
	
	// Configure thumbnail settings.
	iu.addParam("UploadThumbnail1FitMode", "Fit");
	iu.addParam("UploadThumbnail1Width", "130");
	iu.addParam("UploadThumbnail1Height", "98");
	iu.addParam("UploadThumbnail1JpegQuality", "70");
	
	iu.addParam("UploadThumbnail2FitMode", "Fit");
	iu.addParam("UploadThumbnail2Width", "300");
	iu.addParam("UploadThumbnail2Height", "220");
	iu.addParam("UploadThumbnail2JpegQuality", "70");
	
	iu.addParam("UploadThumbnail3FitMode", "Fit");
	iu.addParam("UploadThumbnail3Width", "720");
	iu.addParam("UploadThumbnail3Height", "540");
	iu.addParam("UploadThumbnail3JpegQuality", "80");
	
	// Configure URL files are uploaded to.
	iu.addParam("Action", postUrl)
	
	if (redirectUrl) {
		
		// Configure URL where to redirect after upload.
		iu.addParam("RedirectUrl", redirectUrl)
		
	}
	
	iu.addParam("ButtonSendText", "");
	iu.addParam('FileMask', '*.jpg;*.jpe;*.jpeg;*.gif;*.tiff;*.tif;*.png;*.bmp;*.wbmp;*.psd;*.pcx');
	
	// Add some event listeners
	iu.addEventListener("AfterUpload", "show_photos");
	
	// Tell Image Uploader writer object to generate all necessary HTML code to embed 
	// Image Uploader to the page.
	iu.writeHtml();
}