// Aurigma Image Uploader Dual 6.x - IUEmbed Script Library
// Version 6.0 Feb 21, 2009
// Copyright(c) Aurigma Inc. 2002-2009

/// <reference path="iuembed.js" />
/// <reference path="iuembed.Intellisense.js" />

//--------------------------------------------------------------------------
//InstallationProgressExtender class
//--------------------------------------------------------------------------

function InstallationProgressExtender(writer) {
	/// <summary>Extends Image Uploader with loading progress for ActiveX.</summary>
	/// <param name="writer" type="ImageUploaderWriter">An instance of ImageUploaderWriter object.</param>
	
	BaseExtender.call(this, writer);

	if (writer == undefined) {
		return;
	}
	
	if (new String(writer.width).indexOf("%") != -1 || new String(writer.height).indexOf("%") != -1) {
		IUCommon.showWarning("Current version of InstallationProgressExtender class supports ImageUploaderWriter object  "
			+ "which width and height are specified in pixels only (not in percents)", 1);
		this._compatible = false;
	}
	else {
		this._compatible = true;
	}

	//CSS classes
	this._progressCssClass = "";
	this._instructionsCssClass = "";	
	
	//Common description
	this._commonHtml = "<p>Aurigma Image Uploader ActiveX control is necessary to upload "
		+ "your files quickly and easily. You will be able to select multiple images "
		+ "in user-friendly interface instead of clumsy input fields with <strong>Browse</strong> button.</p>";
	
	//Installation progress
	this._progressHtml = "<p><img src=\"{0}\" />"
		+ "<br />"
		+ "Loading Aurigma Image Uploader ActiveX...</p>";
	this._progressImageUrl = "Scripts/InstallationProgress.gif";

	//Before IE 6 Windows XP SP2
	this._beforeIE6XPSP2ProgressHtml = "<p>To install Image Uploader, please wait until the control will be loaded and click "
		+ "the <strong>Yes</strong> button when you see the installation dialog.</p>";
	this._beforeIE6XPSP2InstructionsHtml = "<p>To install Image Uploader, please reload the page and click "
		+ "the <strong>Yes</strong> button when you see the control installation dialog. "
		+ "If you don't see installation dialog, please check your security settings.</p>";

	//IE 6 Windows XP SP2
	this._IE6XPSP2ProgressHtml = "<p>Please wait until the control will be loaded.</p>"
	this._IE6XPSP2InstructionsHtml = "<p>To install Image Uploader, please click on the <strong>Information Bar</strong> and select " 
		+ "<strong>Install ActiveX Control</strong> from the dropdown menu. After page reload click <strong>Install</strong> when "
		+ "you see the control installation dialog. If you don't see Information Bar, please try to reload the page and/or check your security settings.</p>";	
	
	//IE 7
	this._IE7ProgressHtml = this._IE6XPSP2ProgressHtml;
	this._IE7InstructionsHtml = "<p>To install Image Uploader, please click on the <strong>Information Bar</strong> "
		+ "and select <strong>Install ActiveX Control</strong> or <strong>Run ActiveX Control</strong> from the dropdown menu.</p>"
		+ "<p>Then either click <strong>Run</strong> or after the page reload click <strong>Install</strong> "
		+ "when you see the control installation dialog. If you don't see Information Bar, please try to reload the page and/or check your security settings.</p>";

	//IE 8
	this._IE8ProgressHtml = this._IE6XPSP2ProgressHtml;	
	this._IE8InstructionsHtml = "<p>To install Image Uploader, please click on the <strong>Information Bar</strong> "
		+ "and select <strong>Install This Add-on</strong> or <strong>Run Add-on</strong> from the dropdown menu.</p>"
		+ "<p>Then either click <strong>Run</strong> or after the page reload click <strong>Install</strong> "
		+ "when you see the control installation dialog. If you don't see Information Bar, please try to reload the page and/or check your security settings.</p>";
	
	//Alternative standalone installer
	this._altInstallerEnabled = false;
	this._altInstallerHtml = "<p>You can also download <a href=\"{0}\">standalone installator</a>.</p>";
	this._altInstallerUrl = "ImageUploaderStandalone.zip";
}

InstallationProgressExtender.prototype = new BaseExtender;
InstallationProgressExtender.prototype.constructor = InstallationProgressExtender;

//Override BaseExtender methods

InstallationProgressExtender.prototype._beforeRender = function() {	
	if (this._writer.getControlType() == "ActiveX" && this._compatible) {
		this._writer.instructionsEnabled = true;
		this._writer.instructionsVista = "";
		this._writer.instructionsXPSP2 = "";
		this._writer.instructionsNotXPSP2 = "";
		this._writer.instructionsCommon2 = ""	

		var sb = new IUCommon.StringBuilder();
		
		sb.add("<div style=\"position:absolute;");
		sb.addCssAttr("width", this._writer.width + "px");
		sb.addCssAttr("height", this._writer.height + "px");
		var bc = this._writer.getParam("BackgroundColor");
		sb.addCssAttr("background-color", bc == undefined ? "#c3daf9" : bc);		
		sb.add("z-index:1001;\">");
        sb.add("<div style=\"position:absolute;top:0;left:0;height:100%;width:100%;\" ");
		sb.addCssClass(this._instructionsCssClass);		
		sb.add(">");
		sb.add(this._commonHtml);
		
		if (IUCommon.browser.isBeforeIE6XPSP2) {
			sb.add(this._beforeIE6XPSP2InstructionsHtml)
		}
		else if (IUCommon.browser.isIE6XPSP2) {
			sb.add(this._IE6XPSP2InstructionsHtml)
		}
		else if (IUCommon.browser.isIE7) {
			sb.add(this._IE7InstructionsHtml)
		}
		else { //IUCommon.browser.isIE8 - for future compatibility
			sb.add(this._IE8InstructionsHtml)
		}
		
		if (this._altInstallerEnabled) {
			sb.add(IUCommon.formatString(this._altInstallerHtml, this._altInstallerUrl));				
		}
		
		sb.add("</div>");
		
		sb.add("</div>");
		
		this._writer.instructionsCommon = sb.toString();
	}
}

InstallationProgressExtender.prototype._getBeforeHtml = function() {
	var sb = new IUCommon.StringBuilder();

	sb.add("<div style=\"position:relative;")
	sb.addCssAttr("width", this._writer.width + "px");
	sb.addCssAttr("height", this._writer.height + "px");	
	sb.add("\">");

	if (this._writer.getControlType() == "ActiveX" && this._compatible) {
		sb.add("<div style=\"position:absolute;");		
		sb.addCssAttr("width", (this._writer.width - 1) + "px");
		sb.addCssAttr("height", (this._writer.height - 1) + "px");
        var bc = this._writer.getParam("BackgroundColor");
        sb.addCssAttr("background-color", bc == undefined ? "#c3daf9" : bc);
		sb.add("overflow:hidden;top:1px;left:1px;z-index:1000;\">");
        sb.add("<div style=\"position:absolute;top:0;left:0;height:100%;width:100%;\" ");
		sb.addCssClass(this._progressCssClass);
		sb.add(">");
		sb.add(IUCommon.formatString(this._progressHtml, this._progressImageUrl));
		sb.add(this._commonHtml);
		
		if (IUCommon.browser.isBeforeIE6XPSP2) {
			sb.add(this._beforeIE6XPSP2ProgressHtml)
		}
		else if (IUCommon.browser.isIE6XPSP2) {
			sb.add(this._IE6XPSP2ProgressHtml)
		}
		else if (IUCommon.browser.isIE7) {
			sb.add(this._IE7ProgressHtml)
		}
		else { //IUCommon.browser.isIE8 - for future compatibility
			sb.add(this._IE8ProgressHtml)
		}		
		
		sb.add("</div>");
		sb.add("</div>");
	}
		
	return sb.toString();
}

InstallationProgressExtender.prototype._getAfterHtml = function() {
	var sb = new IUCommon.StringBuilder();

	sb.add("</div>");
	
	return sb.toString();
}


//Public

//CSS classes

//ProgressCssClass property
InstallationProgressExtender.prototype.getProgressCssClass = function() {
	/// <summary>Installation progress CSS class name.</summary>
	/// <returns type="String"></returns>

	return this._progressCssClass;
}

InstallationProgressExtender.prototype.setProgressCssClass = function(value) {
	/// <summary>Installation progress CSS class name.</summary>
	/// <param name="value" type="String">A value of property.</param>

	this._progressCssClass = value;
}

//InstructionsCssClass property
InstallationProgressExtender.prototype.getInstructionsCssClass = function() {
	/// <summary>User instructions CSS class name.</summary>
	/// <returns type="String"></returns>

	return this._instructionsCssClass;
}

InstallationProgressExtender.prototype.setInstructionsCssClass = function(value) {
	/// <summary>User instructions CSS class name.</summary>
	/// <param name="value" type="String">A value of property.</param>

	this._instructionsCssClass = value;
}

//Common description
	
//CommonHtml property
InstallationProgressExtender.prototype.getCommonHtml = function() {
	/// <summary>Common Image Uploader description.</summary>
	/// <returns type="String"></returns>
	
	return this._commonHtml;
}

InstallationProgressExtender.prototype.setCommonHtml = function(value) {
	/// <summary>Common Image Uploader description.</summary>
	/// <param name="value" type="String">A value of property.</param>

	this._commonHtml = value;
}	
	
//Installation progress

//ProgressHtml property
InstallationProgressExtender.prototype.getProgressHtml = function() {
	/// <summary>Installation progress HTML.</summary>
	/// <returns type="String"></returns>
	
	return this._progressHtml;
}

InstallationProgressExtender.prototype.setProgressHtml = function(value) {
	/// <summary>Installation progress HTML.</summary>
	/// <param name="value" type="String">A value of property.</param>

	this._progressHtml = value;
}

//ProgressImageUrl  property
InstallationProgressExtender.prototype.getProgressImageUrl = function() {
	/// <summary>Progress image URL.</summary>
	/// <returns type="String"></returns>

	return this._progressImageUrl;
}

InstallationProgressExtender.prototype.setProgressImageUrl = function(value) {
	/// <summary>Progress image URL.</summary>
	/// <param name="value" type="String">A value of property.</param>

	this._progressImageUrl = value;
}

//Before IE 6 Windows XP SP2

//BeforeIE6XPSP2ProgressHtml property
InstallationProgressExtender.prototype.getBeforeIE6XPSP2ProgressHtml = function() {
	/// <summary>Before Internet Explorer 6 Windows XP SP 2 installation progress HTML.</summary>
	/// <returns type="String"></returns>

	return this._beforeIE6XPSP2ProgressHtml;
}

InstallationProgressExtender.prototype.setBeforeIE6XPSP2ProgressHtml = function(value) {
	/// <summary>Before Internet Explorer 6 Windows XP SP 2 installation progress HTML.</summary>
	/// <param name="value" type="String">A value of property.</param>

	this._beforeIE6XPSP2ProgressHtml = value;
}

//BeforeIE6XPSP2InstructionsHtml property
InstallationProgressExtender.prototype.getBeforeIE6XPSP2InstructionsHtml = function() {
	/// <summary>Before Internet Explorer 6 Windows XP SP user instructions HTML.</summary>
	/// <returns type="String"></returns>

	return this._beforeIE6XPSP2InstructionsHtml;
}

InstallationProgressExtender.prototype.setBeforeIE6XPSP2InstructionsHtml = function(value) {
	/// <summary>Before Internet Explorer 6 Windows XP SP user instructions HTML.</summary>
	/// <param name="value" type="String">A value of property.</param>

	this._beforeIE6XPSP2InstructionsHtml = value;
}

//IE 6 Windows XP SP2

//IE6XPSP2ProgressHtml property
InstallationProgressExtender.prototype.getIE6XPSP2ProgressHtml = function() {
	/// <summary>Internet Explorer 6 Windows XP SP 2 installation progress HTML.</summary>
	/// <returns type="String"></returns>

	return this._IE6XPSP2ProgressHtml;
}

InstallationProgressExtender.prototype.setIE6XPSP2ProgressHtml = function(value) {
	/// <summary>Internet Explorer 6 Windows XP SP 2 installation progress HTML.</summary>
	/// <returns type="String"></returns>

	this._IE6XPSP2ProgressHtml = value;
}

//IE6XPSP2InstructionsHtml property
InstallationProgressExtender.prototype.getIE6XPSP2InstructionsHtml = function() {
	/// <summary>Internet Explorer 6 Windows XP SP user instructions HTML.</summary>
	/// <returns type="String"></returns>

	return this._IE6XPSP2InstructionsHtml;
}

InstallationProgressExtender.prototype.setIE6XPSP2InstructionsHtml = function(value) {
	/// <summary>Internet Explorer 6 Windows XP SP user instructions HTML.</summary>
	/// <returns type="String"></returns>

	this._IE6XPSP2InstructionsHtml = value;
}

//IE 7

//IE7ProgressHtml property
InstallationProgressExtender.prototype.getIE7ProgressHtml = function() {
	/// <summary>Internet Explorer 7 installation progress HTML.</summary>
	/// <returns type="String"></returns>

	return this._IE7ProgressHtml;
}

InstallationProgressExtender.prototype.setIE7ProgressHtml = function(value) {
	/// <summary>Internet Explorer 7 installation progress HTML.</summary>
	/// <param name="value" type="String">A value of property.</param>

	this._IE7ProgressHtml = value;
}


//IE7InstructionsHtml property
InstallationProgressExtender.prototype.getIE7InstructionsHtml = function() {
	/// <summary>Internet Explorer 7 user instructions HTML.</summary>
	/// <returns type="String"></returns>

	return this._IE7InstructionsHtml;
}

InstallationProgressExtender.prototype.setIE7InstructionsHtml = function(value) {
	/// <summary>Internet Explorer 7 user instructions HTML.</summary>
	/// <param name="value" type="String">A value of property.</param>

	this._IE7InstructionsHtml = value;
}


//IE 8

//IE8ProgressHtml property
InstallationProgressExtender.prototype.getIE8ProgressHtml = function() {
	/// <summary>Internet Explorer 8 installation progress HTML.</summary>
	/// <returns type="String"></returns>

	return this._IE8ProgressHtml;
}

InstallationProgressExtender.prototype.setIE8ProgressHtml = function(value) {
	/// <summary>Internet Explorer 8 installation progress HTML.</summary>
	/// <param name="value" type="String">A value of property.</param>

	this._IE8ProgressHtml = value;
}


//IE8InstructionsHtml property
InstallationProgressExtender.prototype.getIE8InstructionsHtml = function() {
	/// <summary>Internet Explorer 8 user instructions HTML.</summary>
	/// <returns type="String"></returns>

	return this._IE8InstructionsHtml;
}

InstallationProgressExtender.prototype.setIE8InstructionsHtml = function(value) {
	/// <summary>Internet Explorer 8 user instructions HTML.</summary>
	/// <param name="value" type="String">A value of property.</param>

	this._IE8InstructionsHtml = value;
}

//Alternative standalone installer

//AltInstallerEnabled property
InstallationProgressExtender.prototype.getAltInstallerEnabled = function() {
	/// <summary>Specifies whether to display alternative standalone installer user instructions.</summary>
	/// <returns type="Boolean"></returns>

	return this._altInstallerEnabled;
}

InstallationProgressExtender.prototype.setAltInstallerEnabled = function(value) {
	/// <summary>Specifies whether to display alternative standalone installer user instructions.</summary>
	/// <param name="value" type="Boolean">A value of property.</param>

	this._altInstallerEnabled = value;
}

//AltInstallerHtml property
InstallationProgressExtender.prototype.getAltInstallerHtml = function() {
	/// <summary>Alternative standalone installer user instructions HTML.</summary>
	/// <returns type="String"></returns>

	return this._altInstallerHtml;
}

InstallationProgressExtender.prototype.setAltInstallerHtml = function(value) {
	/// <summary>Alternative standalone installer user instructions HTML.</summary>
	/// <param name="value" type="String">A value of property.</param>

	this._altInstallerHtml = value;
}

//AltInstallerUrl property
InstallationProgressExtender.prototype.getAltInstallerUrl = function() {
	/// <summary>Alternative standalone installer URL.</summary>
	/// <returns type="String"></returns>

	return this._altInstallerUrl;
}

InstallationProgressExtender.prototype.setAltInstallerUrl = function(value) {
	/// <summary>Alternative standalone installer URL.</summary>
	/// <param name="value" type="String">A value of property.</param>
		
	this._altInstallerUrl = value;
}
