/*
 * RADactive I-Load 2008.R1
 * Copyright © 2005-2008 RADactive srl - All Rights Reserved.
 * <www.RADactive.com>
 */

function Radactive_WebControls_ILoad()
{
}

Radactive_WebControls_ILoad.prototype.GetControl = function(controlId)
{
	if (!controlId)
	{
		return null;
	}
		
	for(var i=0;i<ILoadControls.length;i++)
	{
		var control = ILoadControls[i];
		if (control)
		{
			if (control.ControlId == controlId)
			{
				return control;
			}
		}
	}
	
	return null;
}

Radactive_WebControls_ILoad.prototype.GetControl2 = function(controlId)
{
	return document.getElementById(controlId);
}

Radactive_WebControls_ILoad.prototype.CreateControl = function(controlId)
{
	var control = new ILoadControl(controlId);

	var oldIndex = -1;
	for(var i=0;i<ILoadControls.length;i++)
	{
		var oldControl = ILoadControls[i];
		if (oldControl.ControlId == controlId)
		{
			oldIndex = i;
			break;
		}
	}

	if (oldIndex >= 0)
	{
		ILoadControls[i] = control;
	}
	else
	{
		if (ILoadControls.push)
		{
			ILoadControls.push(control);
		}
		else
		{
			ILoadControls[ILoadControls.length] = control;
		}
	}
	return control;
}

Radactive_WebControls_ILoad.prototype.GetAddImagePopupUrl = function(controlId, edit)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	var editParam = "0";
	if (edit)
	{
		editParam = "1";
	}

	var controlKey = control.ControlKey;
	var url = "WebCoreModule.ashx?__ac=1&__ac_wcmid=RAWCIL&__ac_lib=Radactive.WebControls.ILoad&__ac_key=RAWCCIL_201&__ac_sid=34egxszquew1yy45zqtvsb45&__ac_ssid=&__ac_ssid2=1&__ControlKey=" + URLEncode(controlKey) + "&___controlId=" + URLEncode(controlId) + "&___edit=" + URLEncode(editParam) + "&fr=" + URLEncode(Date()) + "&pageUrl=" + URLEncode(document.location.href)
	url += "&__ac_cn=" + URLEncode(control.Culture);

	return url;
}

Radactive_WebControls_ILoad.prototype.Last_AddImage_Id = null;
Radactive_WebControls_ILoad.prototype.Last_AddImage_Edit = false;
Radactive_WebControls_ILoad.prototype.Last_AddImage_Config = null;
Radactive_WebControls_ILoad.prototype.AddImage = function(controlId, edit)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	if (edit)
	{
		var webImage = this.GetValue(controlId);
		if (!webImage)
		{
			alert(this.GetLRMText(controlId, "ILoad_Error_NoImageToEdit", "Error: No image to edit."));
			return;
		}
		if (!webImage.SourceImage())
		{
			alert(this.GetLRMText(controlId, "ILoad_Error_SourceImageNotFound", "I-Load configuration error:\r\nSource image not found. Please enable [KeepSourceImage]."));
			return;
		}
	}	
	
	this.Last_AddImage_Id = controlId;
	this.Last_AddImage_Edit = edit;

	var url = this.GetAddImagePopupUrl(controlId, edit);

	var iload_result = Radactive.WebControls.ShowDialog(url, 600, 430, true, true, false);
	if (Radactive.WebControls.ShowDialog_window_isModal)
	{
		if (iload_result)
		{
			iload_result.controlId = controlId;
		}
		this.AddImage_Return(iload_result);
	}
	return iload_result;
}

Radactive_WebControls_ILoad.prototype.AddImageAutoEdit = function(controlId)
{
	var webImage = this.GetValue(controlId);
	if (webImage)
	{
		var allowEdit = this.GetAllowEditImage(controlId);
		this.AddImage(controlId, allowEdit);
	}
	else
	{
		this.AddImage(controlId, false);
	}
}

Radactive_WebControls_ILoad.prototype.AddImage_Return = function(iload_result)
{
	if (!iload_result)
	{
		return;
	}
	if (this.GetAutomaticallyClearTemporaryFiles(iload_result.controlId))
	{
		this.ClearTemporaryFiles(iload_result.subSessionId, !iload_result.completed);
	}
	if (iload_result.completed)
	{
		if (this.Last_AddImage_Edit)
		{
			var oldValue = this.GetValue(iload_result.controlId);
			if (oldValue)
			{
				if (oldValue.IsTemporary())
				{
					if (this.GetAutomaticallyClearTemporaryFiles(iload_result.controlId))
					{
						this.ClearTemporaryFiles(oldValue.Id, true);
					}
				}
				else
				{
					if (this.GetAutomaticallyDeleteRemovedFiles(iload_result.controlId))
					{
						this.DeleteWebImageFiles(oldValue.Storage, oldValue.ConfigurationInternalCode, oldValue.Id, oldValue.K2, oldValue.FolderPathEnc);
					}
				}
			}
		}
		
		this.SetValue(iload_result.controlId, iload_result.index, true, true, false);
	}
}

Radactive_WebControls_ILoad.prototype.ClearTemporaryFiles = function(ssid, clearAll)
{
	var url = "WebCoreModule.ashx?__ac=1&__ac_wcmid=RAWCIL&__ac_lib=Radactive.WebControls.ILoad&__ac_key=RAWCCIL_2011&__ac_sid=34egxszquew1yy45zqtvsb45&__ac_cn=&__ac_ssid=&fr=" + URLEncode(Date());
	url += "&ssidToClear=" + URLEncode(ssid);
	if (clearAll)
	{
		url += "&removeTemporaryFiles=1";
	}
	createXMLDOMFromRequest(url, false);
}

Radactive_WebControls_ILoad.prototype.DeleteWebImageFiles = function(storage, configurationInternalCode, id, k2, folderPathEnc)
{
	var url = "WebCoreModule.ashx?__ac=1&__ac_wcmid=RAWCIL&__ac_lib=Radactive.WebControls.ILoad&__ac_key=RAWCCIL_2012&__ac_sid=34egxszquew1yy45zqtvsb45&__ac_cn=&__ac_ssid=&fr=" + URLEncode(Date());
	url += "&storage=" + URLEncode(storage);
	url += "&configIC=" + URLEncode(configurationInternalCode);
	url += "&id=" + URLEncode(id);
	url += "&k2=" + URLEncode(k2);
	url += "&folderPath=" + URLEncode(folderPathEnc);
	
	createXMLDOMFromRequest(url, false);
}

Radactive_WebControls_ILoad.prototype.RemoveImage = function(controlId)
{
	if (window.confirm(this.GetLRMText(controlId, "ILoad_Alert_ConfirmRemoveImage", "Are you sure you want to remove this image ?")))
	{
		this.SetValue(controlId, null, true, true, false);
	}
}	

Radactive_WebControls_ILoad.prototype.GetValue = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return null;
	}
	return control.WebImage;
}



Radactive_WebControls_ILoad.prototype.SetValue = function(controlId, newWebImage, raiseValueChangedEventHandler, raiseValidation, setOldValue)
{
	var webImage = null;
	var useIndex = false;
	
	if (typeof raiseValidation == "undefined")
	{
		raiseValidation = true;
	}
	
	if (newWebImage)
	{
		if (typeof newWebImage == "string")
		{
			webImage = new WebImage(newWebImage);
			if (webImage.ImageDefinitionInternalCode == "")
			{
				// Safari bug
				for(var i=0;i<10;i++)
				{
					webImage = new WebImage(newWebImage);
					if (webImage.ImageDefinitionInternalCode != "")
					{
						break;
					}
				}
			}
			useIndex = true;
		}
		else
		{
			webImage = newWebImage;
		}
	}
	
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	var valueSpace = Radactive.WebControls.GetFormElement(controlId + "__Value");
	if (!valueSpace)
	{
		return;
	}
	
	var oldValueSpace = Radactive.WebControls.GetFormElement(controlId + "__OldValue");	
	
	var oldValue = control.WebImage;
	if (oldValue)
	{
		if (!oldValue.IsSameImage(webImage))
		{
			if (oldValue.IsTemporary())
			{
				if (this.GetAutomaticallyClearTemporaryFiles(controlId))
				{
					this.ClearTemporaryFiles(oldValue.Id, true);
				}
			}
			else
			{
				if (this.GetAutomaticallyDeleteRemovedFiles(controlId))
				{
					this.DeleteWebImageFiles(oldValue.Storage, oldValue.ConfigurationInternalCode, oldValue.Id, oldValue.K2, oldValue.FolderPathEnc);
				}
			}
		}
	}
	control.WebImage = webImage;
	
	if (webImage)
	{
		if (useIndex)
		{
			valueSpace.value = URLEncode(newWebImage);
		}
		else
		{
			valueSpace.value = URLEncode(webImage.GetIndex());
		}
	}
	else
	{
		valueSpace.value = "";
	}
	
	if (setOldValue)
	{
		if (oldValueSpace)
		{
			oldValueSpace.value = valueSpace.value;
		}
	}
	
	if (raiseValueChangedEventHandler)
	{
		if (control.ValueChangedEventHandler)
		{
			if (control.ValueChangedEventHandler.prototype)
			{
				control.ValueChangedEventHandler(controlId, webImage);
			}
			else
			{
				var f = eval(control.ValueChangedEventHandler);
				if (f)
				{
					if (f.prototype)
					{
						f(controlId, webImage);
					}
				}
			}
		}
	}
	
	var control2 = this.GetControl2(controlId);
	if (control2)
	{
		if (control2.onValueChange)
		{
			if (control2.onValueChange.prototype)
			{
				control2.onValueChange();
			}
			else
			{
				eval(control2.onValueChange);
			}
		}
	}
	
	if (this.GetAutoPostBack(controlId))
	{
		window.setTimeout("Radactive.WebControls.ILoad.RaiseBackEventHandler('" + controlId + "');",500);
		return;
	}
	
	var appearance = this.GetAppearance(controlId);
	switch(appearance)
	{
		case 1:
			// Default:
			var iconPreviewSpace = document.getElementById(controlId + "__IconPreview");
			var imageDetailSpace = document.getElementById(controlId + "__ImageDetails");
			var imageDetailEmptySpace = document.getElementById(controlId + "__ImageDetailsEmpty");
			var removeImageSpace = document.getElementById(controlId + "__RemoveImage");
			var editImageSpace = document.getElementById(controlId + "__EditImage")
			var addImageSpace = document.getElementById(controlId + "__AddImage");
			
			if (webImage)
			{
				var iconResize = null;
				var iconCustomResize = this.GetIconCustomResize(controlId);
				if (iconCustomResize != "")
				{
					iconResize = webImage.GetResizeByName(iconCustomResize);
				}
				if (!iconResize)
				{
					iconResize = webImage.IconImage();
				}
				if (iconResize)
				{
					if (iconPreviewSpace)
					{
						var iconCode = "<img src=\"" + iconResize.FileUrl_NoCache() + "\" border=\"0\"";
						if (this.GetAllowPreviewWindow(controlId))
						{
							iconCode += " alt=\"" + this.GetLRMText(controlId, "ILoad_Text_ShowImagePreview", "Show image preview") + "\"";
						}
						else
						{
							iconCode += " alt=\"\"";
						}
						iconCode += " style=\"border:solid 1px #CCCCCC;\" HIDEFOCUS=\"true\">";
						if (this.GetAllowPreviewWindow(controlId))
						{
							iconCode = "<a href=\"javascript:void(0);\" onclick=\"Radactive.WebControls.ILoad.ShowImagePreview('" + controlId + "'); return false;\">" + iconCode + "</A>";
						}
						iconPreviewSpace.innerHTML = iconCode;
					}
				}
				if (imageDetailSpace)
				{
					var str = "";
					var definitionTitle = this.GetDefinitionTitle(controlId, webImage.ImageDefinitionInternalCode);
					if (definitionTitle == "")
					{
						definitionTitle = "Unknown";
					}
					str += this.GetLRMText(controlId, "ILoad_Text_Definition", "Definition: ") + definitionTitle + "<br>";
					var selectedResize = webImage.SelectedImage();
					if (selectedResize)
					{
						str += this.GetLRMText(controlId, "ILoad_Text_Size", "Size (px): ") + selectedResize.ImageSizeText  + "&nbsp;&nbsp;(" + selectedResize.Extension + " - " + selectedResize.FileSizeText + ")<br>";
					}
					imageDetailSpace.innerHTML = str;
					imageDetailSpace.style.display = "block";
				}
				if (imageDetailEmptySpace)
				{
					imageDetailEmptySpace.style.display = "none";
				}
				if (editImageSpace)
				{
					editImageSpace.style.display = "block";
					if (addImageSpace)
					{
						addImageSpace.style.display = "none";
					}
				}
				else
				{
					if (addImageSpace)
					{
						addImageSpace.style.display = "block";
					}
				}
				if (removeImageSpace)
				{
					removeImageSpace.style.display = "block";
				}
			}
			else
			{
				if (iconPreviewSpace)
				{
					iconPreviewSpace.innerHTML = "";
				}
				if (imageDetailSpace)
				{
					imageDetailSpace.style.display = "none";
				}
				if (imageDetailEmptySpace)
				{
					imageDetailEmptySpace.style.display = "block";
				}
				if (addImageSpace)
				{
					addImageSpace.style.display = "block";
				}
				if (editImageSpace)
				{
					editImageSpace.style.display = "none";
				}
				if (removeImageSpace)
				{
					removeImageSpace.style.display = "none";
				}
			}
			break;
		case 2:
			// Button
			var buttonSpace = document.getElementById(controlId);
			
			var buttonText = this.GetAddImageButtonText(controlId);
			if (webImage)
			{
				var allowEditImage = this.GetAllowEditImage(controlId);
				if (allowEditImage)
				{
					buttonText = this.GetEditImageButtonText(controlId);
				}
			}
			
			if (buttonSpace)
			{
				buttonSpace.value = buttonText;
			}

			break;
		case 3:
			// Hidden
			break;
	}
			
	if (raiseValidation)
	{		
		this.UpdateValidators(controlId);
	}	
}


Radactive_WebControls_ILoad.prototype.SetHiddenValue = function(controlId, value, gdt)
{
	var valueSpace = Radactive.WebControls.GetFormElement(controlId + "__HiddenValue");
	if (valueSpace)
	{
		valueSpace.value = URLEncode(value);
	}
	var valueGDTSpace = Radactive.WebControls.GetFormElement(controlId + "__HiddenValue_GDT");
	if (valueGDTSpace)
	{
		valueGDTSpace.value = gdt;
	}
}


Radactive_WebControls_ILoad.prototype.SetAutoPostBack = function(controlId, value)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	if (value)
	{
		control.AutoPostBack = true;
	}
	else
	{
		control.AutoPostBack = false;
	}
}

Radactive_WebControls_ILoad.prototype.GetAutoPostBack = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return false;
	}
	if (control.AutoPostBack == true)
	{
		return true;
	}
	if (control.AutoPostBack == false)
	{
		return false;
	}
	return false;
}

Radactive_WebControls_ILoad.prototype.SetAutomaticallyClearTemporaryFiles = function(controlId, value)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	if (value)
	{
		control.AutomaticallyClearTemporaryFiles = true;
	}
	else
	{
		control.AutomaticallyClearTemporaryFiles = false;
	}
}

Radactive_WebControls_ILoad.prototype.GetAutomaticallyClearTemporaryFiles = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return false;
	}
	if (control.AutomaticallyClearTemporaryFiles == true)
	{
		return true;
	}
	if (control.AutomaticallyClearTemporaryFiles == false)
	{
		return false;
	}
	return false;
}

Radactive_WebControls_ILoad.prototype.SetAutomaticallyDeleteRemovedFiles = function(controlId, value)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	if (value)
	{
		control.AutomaticallyDeleteRemovedFiles = true;
	}
	else
	{
		control.AutomaticallyDeleteRemovedFiles = false;
	}
}

Radactive_WebControls_ILoad.prototype.GetAutomaticallyDeleteRemovedFiles = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return false;
	}
	if (control.AutomaticallyDeleteRemovedFiles == true)
	{
		return true;
	}
	if (control.AutomaticallyDeleteRemovedFiles == false)
	{
		return false;
	}
	return false;
}

Radactive_WebControls_ILoad.prototype.SetAllowEditImage = function(controlId, value)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	if (value)
	{
		control.AllowEditImage = true;
	}
	else
	{
		control.AllowEditImage = false;
	}
}

Radactive_WebControls_ILoad.prototype.GetAllowEditImage = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return false;
	}
	if (control.AllowEditImage == true)
	{
		return true;
	}
	if (control.AllowEditImage == false)
	{
		return false;
	}
	return false;
}

Radactive_WebControls_ILoad.prototype.SetAllowPreviewWindow = function(controlId, value)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	if (value)
	{
		control.AllowPreviewWindow = true;
	}
	else
	{
		control.AllowPreviewWindow = false;
	}
}

Radactive_WebControls_ILoad.prototype.GetAllowPreviewWindow = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return false;
	}
	if (control.AllowPreviewWindow == true)
	{
		return true;
	}
	if (control.AllowPreviewWindow == false)
	{
		return false;
	}
	return false;
}

Radactive_WebControls_ILoad.prototype.SetIconCustomResize = function(controlId, value)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	control.IconCustomResize = value;
}

Radactive_WebControls_ILoad.prototype.GetIconCustomResize = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return "";
	}
	if (control.IconCustomResize)
	{
		return control.IconCustomResize;
	}
	else
	{
		return "";
	}
}

Radactive_WebControls_ILoad.prototype.SetPostBackEventHandler = function(controlId, value)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	control.AutoPostBackEventHandler = value;
}

Radactive_WebControls_ILoad.prototype.RaiseBackEventHandler = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	if (control.AutoPostBackEventHandler)
	{
		if (typeof(__doPostBack) == "undefined")
		{
			__doPostBack = function(eventTarget, eventArgument) 
			{
				var theForm = document.forms[0];

				if (!theForm.onsubmit || (theForm.onsubmit() != false)) 
				{
					theForm.__EVENTTARGET.value = eventTarget;
					theForm.__EVENTARGUMENT.value = eventArgument;
					theForm.submit();
				}
		    }
		}
		
		if (control.AutoPostBackEventHandler.prototype)
		{
			control.AutoPostBackEventHandler();
		}
		else
		{
			eval(control.AutoPostBackEventHandler);
		}
	}
}

Radactive_WebControls_ILoad.prototype.SetValueChangedEventHandler = function(controlId, valueChangedEventHandler)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	control.ValueChangedEventHandler = valueChangedEventHandler;
}

Radactive_WebControls_ILoad.prototype.SetCulture = function(controlId, culture)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	control.Culture = culture;
}

Radactive_WebControls_ILoad.prototype.GetCulture = function(controlId, culture)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return "";
	}
	return control.Culture;
}

Radactive_WebControls_ILoad.prototype.GetLRMContext = function(controlId)
{
	return "ILoad1|" + controlId;
}

Radactive_WebControls_ILoad.prototype.SetLRMText = function(controlId, key, value)
{
	var context = this.GetLRMContext(controlId);
	var culture = this.GetCulture(controlId);
	Radactive.LRM.SetString(context, culture, key, value);
	return value;
}

Radactive_WebControls_ILoad.prototype.GetLRMText = function(controlId, key, defaultValue)
{
	var context = this.GetLRMContext(controlId);
	var culture = this.GetCulture(controlId);
	return Radactive.LRM.GetString(context, culture, key, defaultValue);
}

Radactive_WebControls_ILoad.prototype.SetControlTitle = function(controlId, controlTitle)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	control.ControlTitle = controlTitle;
}

Radactive_WebControls_ILoad.prototype.GetControlTitle = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return "I-Load";
	}
	return control.ControlTitle;
}

Radactive_WebControls_ILoad.prototype.SetPreviewWindowTitle = function(controlId, previewWindowTitle)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	control.PreviewWindowTitle = previewWindowTitle;
}

Radactive_WebControls_ILoad.prototype.GetPreviewWindowTitle = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return "I-Load - Preview";
	}
	return control.PreviewWindowTitle;
}

Radactive_WebControls_ILoad.prototype.SetAddImageButtonText = function(controlId, buttonText)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	control.AddImageButtonText = buttonText;
}

Radactive_WebControls_ILoad.prototype.GetAddImageButtonText = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return "Browse...";
	}
	return control.AddImageButtonText;
}

Radactive_WebControls_ILoad.prototype.SetEditImageButtonText = function(controlId, buttonText)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	control.EditImageButtonText = buttonText;
}

Radactive_WebControls_ILoad.prototype.GetEditImageButtonText = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return "Edit...";
	}
	return control.EditImageButtonText;
}

Radactive_WebControls_ILoad.prototype.SetAppearance = function(controlId, value)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	control.Appearance = value;
}

Radactive_WebControls_ILoad.prototype.GetAppearance = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return 1;
	}
	return control.Appearance;
}

Radactive_WebControls_ILoad.prototype.SetDefinitionTitles = function(controlId, definitions)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	var vett = definitions.split("\r");
	control.Definition_InternalCodes = vett[0].split("\n");
	control.Definition_Titles = vett[1].split("\n");
}

Radactive_WebControls_ILoad.prototype.GetDefinitionTitle = function(controlId, internalCode)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return "";
	}
	for(var i=0;i<control.Definition_InternalCodes.length;i++)
	{
		if (control.Definition_InternalCodes[i] == internalCode)
		{
			return control.Definition_Titles[i];
		}
	}
	return "";
}

Radactive_WebControls_ILoad.prototype.SetResizeDefinitionTitles = function(controlId, resizes)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return;
	}
	var vett = resizes.split("\r");
	control.ResizeDefinition_InternalCodes = vett[0].split("\n");
	control.ResizeDefinition_Titles = vett[1].split("\n");
}

Radactive_WebControls_ILoad.prototype.GetResizeDefinitionTitles = function(controlId, internalCode)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return "";
	}
	var webImage = this.GetValue(controlId);
	if (webImage)
	{
		internalCode = webImage.ImageDefinitionInternalCode + "|" + internalCode;
	}
	for(var i=0;i<control.ResizeDefinition_InternalCodes.length;i++)
	{
		if (control.ResizeDefinition_InternalCodes[i] == internalCode)
		{
			return control.ResizeDefinition_Titles[i];
		}
	}
	return "";
}

Radactive_WebControls_ILoad.prototype.SetControlKey = function(controlId, controlKey)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return "";
	}
	control.ControlKey = controlKey;
}

Radactive_WebControls_ILoad.prototype.GetShowImagePreviewPopupUrl = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return "";
	}
	
	var controlKey = control.ControlKey;	
	var url = "WebCoreModule.ashx?__ac=1&__ac_wcmid=RAWCIL&__ac_lib=Radactive.WebControls.ILoad&__ac_key=RAWCCIL_301&__ac_sid=34egxszquew1yy45zqtvsb45&__ControlKey=" + URLEncode(controlKey) +  "&fr=" + URLEncode(Date());
	url += "&__ac_cn=" + URLEncode(control.Culture);

	return url;
}

Radactive_WebControls_ILoad.prototype.Last_ShowImagePreview_ControlId = ""; 
Radactive_WebControls_ILoad.prototype.ShowImagePreview = function(controlId)
{
	var control = this.GetControl(controlId);
	if (!control)
	{
		return "";
	}
	this.Last_ShowImagePreview_ControlId = controlId;
	var resizable = true;
	if (0 > 0)
	{
		resizable = false;
	}
	
	var url = this.GetShowImagePreviewPopupUrl(controlId);

	var result = Radactive.WebControls.ShowDialog2(url, this.GetPreviewWindowTitle(controlId), 450, 470, true, true, resizable);
}

Radactive_WebControls_ILoad.prototype.Validate = function(validatorControl)
{
	var controlId = validatorControl.controltovalidate;
	var control = Radactive.WebControls.ILoad.GetControl(controlId);
	var webImage = Radactive.WebControls.ILoad.GetValue(controlId);
	if (webImage)
	{
		return true;
	}
	else
	{
		return false;
	}
}

Radactive_WebControls_ILoad.prototype.RegisterValidator = function(controlId, controlToValidateId)
{
	var validator = document.all ? document.all[controlId] : document.getElementById(controlId);
	if (validator)
	{
		if (!window.Page_Validators) 
		{
			window.Page_Validators = new Array();
		}
		if (window.Page_Validators)
		{
			if (!this.GetValidator(controlId)) 
			{
				window.Page_Validators[window.Page_Validators.length] = validator;
			}
		}

		validator.controltovalidate = controlToValidateId;
		validator.evaluationfunction = "Radactive.WebControls.ILoad.Validate";
		validator.dispose = function() {Radactive.WebControls.ILoad.UnregisterValidator(controlId);};
	}
}

Radactive_WebControls_ILoad.prototype.UnregisterValidator = function(controlId)
{
	if (window.Page_Validators)
	{
		var validator = this.GetValidator(controlId);
		if (validator) 
		{
			if (Array.remove)
			{
				Array.remove(window.Page_Validators, validator);
			}
		}
	}
}

Radactive_WebControls_ILoad.prototype.GetValidatorForControl = function(controlId)
{
	if (!controlId)
	{
		return null;
	}
	
	if (window.Page_Validators)
	{
		for(var i=0;i<window.Page_Validators.length;i++)
		{
			var validator = window.Page_Validators[i];
			if (validator)
			{
				if (validator.controltovalidate == controlId)
				{
					return validator;
				}
			}
		}
	}
	
	return null;
}

Radactive_WebControls_ILoad.prototype.GetValidator = function(controlId)
{
	if (!controlId)
	{
		return null;
	}
	
	if (window.Page_Validators)
	{
		for(var i=0;i<window.Page_Validators.length;i++)
		{
			var validator = window.Page_Validators[i];
			if (validator)
			{
				if (validator.id == controlId)
				{
					return validator;
				}
			}
		}
	}
	
	return null;
}

Radactive_WebControls_ILoad.prototype.ValidatorUpdateDisplay = function(val) 
{
	if (!val)
	{
		return;
	}
    if (typeof(val.display) == "string") {
        if (val.display == "None") {
            return;
        }
        if (val.display == "Dynamic") {
            val.style.display = val.isvalid ? "none" : "inline";
            return;
        }
    }
    if ((navigator.userAgent.indexOf("Mac") > -1) &&
        (navigator.userAgent.indexOf("MSIE") > -1)) {
        val.style.display = "inline";
    }
    val.style.visibility = val.isvalid ? "hidden" : "visible";
}

Radactive_WebControls_ILoad.prototype.UpdateValidators = function(controlId)
{
	if (window.Page_Validators)
	{
		for(var i=0;i<window.Page_Validators.length;i++)
		{
			var validator = window.Page_Validators[i];
			if (validator)
			{
				if ((validator.evaluationfunction == Radactive.WebControls.ILoad.Validate) || (validator.evaluationfunction == "Radactive.WebControls.ILoad.Validate"))
				{
					if (validator.controltovalidate == controlId)
					{
						if (window.ValidatorValidate)
						{
							window.ValidatorValidate(validator);
						}
						else
						{
							validator.isvalid = Radactive.WebControls.ILoad.Validate(validator);
							if (window.ValidatorUpdateDisplay)
							{
								window.ValidatorUpdateDisplay(validator);
							}
							else
							{
								this.ValidatorUpdateDisplay(validator);
							}
						}
					}
				}
			}
		}
	}
}

function ILoadResult()
{
}

ILoadResult.prototype.controlId = "";
ILoadResult.prototype.subSessionId = "";
ILoadResult.prototype.completed = false;
ILoadResult.prototype.index = null;

function WebImage(index)
{
	this.Resizes = new Array();
	
	var doc = createXMLDOMFromString(index);
	var root = doc.documentElement;
		
	var attribute = root.attributes.getNamedItem("FolderPath");
	if (attribute != null)
	{
		this.FolderPath = attribute.value;
	}
	else
	{
		attribute = root.attributes.getNamedItem("folderpath");
		if (attribute != null)
		{
			this.FolderPath = attribute.value;
		}
	}
	
	attribute = root.attributes.getNamedItem("FolderPathEnc");
	if (attribute != null)
	{
		this.FolderPathEnc = attribute.value;
	}
	else
	{
		attribute = root.attributes.getNamedItem("folderpathenc");
		if (attribute != null)
		{
			this.FolderPathEnc = attribute.value;
		}
	}

	attribute = root.attributes.getNamedItem("FolderUrl");
	if (attribute != null)
	{
		this.FolderUrl = attribute.value;
	}
	else
	{
		attribute = root.attributes.getNamedItem("folderurl");
		if (attribute != null)
		{
			this.FolderUrl = attribute.value;
		}
	}
	
	attribute = root.attributes.getNamedItem("Id");
	if (attribute != null)
	{
		this.Id = attribute.value;
	}
	else
	{
		attribute = root.attributes.getNamedItem("id");
		if (attribute != null)
		{
			this.Id = attribute.value;
		}
	}
		
	attribute = root.attributes.getNamedItem("K2");
	if (attribute != null)
	{
		this.K2 = attribute.value;
	}
	else
	{
		attribute = root.attributes.getNamedItem("k2");
		if (attribute != null)
		{
			this.K2 = attribute.value;
		}
	}
	
	attribute = root.attributes.getNamedItem("ConfigurationInternalCode");
	if (attribute != null)
	{
		this.ConfigurationInternalCode = attribute.value;
	}
	else
	{
		attribute = root.attributes.getNamedItem("configurationinternalcode");
		if (attribute != null)
		{
			this.ConfigurationInternalCode = attribute.value;
		}
	}
	
	attribute = root.attributes.getNamedItem("ImageDefinitionInternalCode");
	if (attribute != null)
	{
		this.ImageDefinitionInternalCode = attribute.value;
	}
	else
	{
		attribute = root.attributes.getNamedItem("imagedefinitioninternalcode");
		if (attribute != null)
		{
			this.ImageDefinitionInternalCode = attribute.value;
		}
	}
	
	attribute = root.attributes.getNamedItem("Storage");
	if (attribute != null)
	{
		this.Storage = attribute.value;
	}
	else
	{
		attribute = root.attributes.getNamedItem("storage");
		if (attribute != null)
		{
			this.Storage = attribute.value;
		}
	}
	
	attribute = root.attributes.getNamedItem("SourceImageClientFileName");
	if (attribute != null)
	{
		this.SourceImageClientFileName = attribute.value;
	}
	else
	{
		attribute = root.attributes.getNamedItem("sourceimageclientfilename");
		if (attribute != null)
		{
			this.SourceImageClientFileName = attribute.value;
		}
		else
		{
			this.SourceImageClientFileName = "";
		}
	}
	
	var nodes = root.getElementsByTagName("SourceFilters");
	if (nodes.length > 0)
	{
		var sourceFiltersElement = nodes[0];
		this.SourceFilters = new ImageCropFilters();
		
		
		nodes = sourceFiltersElement.getElementsByTagName("SourceImageSize");
		if (nodes.length == 0)
		{
			nodes = sourceFiltersElement.getElementsByTagName("sourceimagesize");
		}
		if (nodes.length > 0)
		{
			var sourceImageSizeElement = nodes[0];

			var width = 0;
			attribute = sourceImageSizeElement.attributes.getNamedItem("Width");
			if (attribute != null)
			{
				width = attribute.value;
			}
			else
			{
				attribute = sourceImageSizeElement.attributes.getNamedItem("width");
				if (attribute != null)
				{
					width = attribute.value;
				}
			}

			var height = 0;
			attribute = sourceImageSizeElement.attributes.getNamedItem("Height");
			if (attribute != null)
			{
				height = attribute.value;
			}
			else
			{
				attribute = sourceImageSizeElement.attributes.getNamedItem("height");
				if (attribute != null)
				{
					height = attribute.value;
				}
			}

			this.SourceFilters.SourceImageSize = new Size(width,height);
		}


		attribute = sourceFiltersElement.attributes.getNamedItem("ZoomFactor");
		if (attribute != null)
		{
			this.SourceFilters.ZoomFactor = attribute.value;
		}
		else
		{
			attribute = sourceFiltersElement.attributes.getNamedItem("zoomfactor");
			if (attribute != null)
			{
				this.SourceFilters.ZoomFactor = attribute.value;
			}
		}
		

		nodes = sourceFiltersElement.getElementsByTagName("SourceRectangle");
		if (nodes.length == 0)
		{
			nodes = sourceFiltersElement.getElementsByTagName("sourcerectangle");
		}
		if (nodes.length > 0)
		{
			var sourceRectangleElement = nodes[0];

			var x = 0;
			attribute = sourceRectangleElement.attributes.getNamedItem("X");
			if (attribute != null)
			{
				x = attribute.value;
			}
			else
			{
				attribute = sourceRectangleElement.attributes.getNamedItem("x");
				if (attribute != null)
				{
					x = attribute.value;
				}
			}

			var y = 0;
			attribute = sourceRectangleElement.attributes.getNamedItem("Y");
			if (attribute != null)
			{
				y = attribute.value;
			}
			else
			{
				attribute = sourceRectangleElement.attributes.getNamedItem("y");
				if (attribute != null)
				{
					y = attribute.value;
				}
			}

			var width = 0;
			attribute = sourceRectangleElement.attributes.getNamedItem("Width");
			if (attribute != null)
			{
				width = attribute.value;
			}
			else
			{
				attribute = sourceRectangleElement.attributes.getNamedItem("width");
				if (attribute != null)
				{
					width = attribute.value;
				}
			}

			var height = 0;
			attribute = sourceRectangleElement.attributes.getNamedItem("Height");
			if (attribute != null)
			{
				height = attribute.value;
			}
			else
			{
				attribute = sourceRectangleElement.attributes.getNamedItem("height");
				if (attribute != null)
				{
					height = attribute.value;
				}
			}

			this.SourceFilters.SourceRectangle = new Rectangle(x,y,width,height);
		}
		
		
		attribute = sourceFiltersElement.attributes.getNamedItem("RotationAngle");
		if (attribute != null)
		{
			this.SourceFilters.RotationAngle = attribute.value;
		}
		else
		{
			attribute = sourceFiltersElement.attributes.getNamedItem("rotationangle");
			if (attribute != null)
			{
				this.SourceFilters.RotationAngle = attribute.value;
			}
		}
		
		attribute = sourceFiltersElement.attributes.getNamedItem("FlipHorizontal");
		if (attribute == null)
		{
			attribute = sourceFiltersElement.attributes.getNamedItem("fliphorizontal");
		}
		if (attribute != null)
		{
			if (attribute.value == "1")
			{
				this.SourceFilters.FlipHorizontal = true;
			}
		}
		
		attribute = sourceFiltersElement.attributes.getNamedItem("FlipVertical");
		if (attribute == null)
		{
			attribute = sourceFiltersElement.attributes.getNamedItem("flipvertical");
		}
		if (attribute != null)
		{
			if (attribute.value == "1")
			{
				this.SourceFilters.FlipVertical = true;
			}
		}
	}

	nodes = root.getElementsByTagName("Resizes");
	if (nodes.length > 0)
	{
		var resizesElement = nodes[0];
		if (resizesElement != null)
		{
			for(var i=0;i<resizesElement.childNodes.length; i++)
			{
				var node = resizesElement.childNodes[i];
				var resizeElement = node;

				var internalCode = "";
				attribute = resizeElement.attributes.getNamedItem("InternalCode");
				if (attribute != null)
				{
					internalCode = attribute.value;
				}
				else
				{
					attribute = resizeElement.attributes.getNamedItem("internalcode");
					if (attribute != null)
					{
						internalCode = attribute.value;
					}
				}
				
				var imageSize = new Size(0,0);

				nodes = resizeElement.getElementsByTagName("ImageSize");
				if (nodes.length > 0)
				{
					var imageSizeElement = nodes[0];
					var width = 0;
					attribute = imageSizeElement.attributes.getNamedItem("Width");
					if (attribute != null)
					{
						width = attribute.value;
					}
					else
					{
						attribute = imageSizeElement.attributes.getNamedItem("width");
						if (attribute != null)
						{
							width = attribute.value;
						}
					}

					var height = 0;
					attribute = imageSizeElement.attributes.getNamedItem("Height");
					if (attribute != null)
					{
						height = attribute.value;
					}
					else
					{
						attribute = imageSizeElement.attributes.getNamedItem("height");
						if (attribute != null)
						{
							height = attribute.value;
						}
					}

					imageSize = new Size(width,height);
				}

				var fileSize = 0;
				attribute = resizeElement.attributes.getNamedItem("FileSize");
				if (attribute != null)
				{
					fileSize = attribute.value;
				}
				else
				{
					attribute = resizeElement.attributes.getNamedItem("filesize");
					if (attribute != null)
					{
						fileSize = attribute.value;
					}
				}
				
				var extension = "";
				attribute = resizeElement.attributes.getNamedItem("Extension");
				if (attribute != null)
				{
					extension = attribute.value;
				}
				else
				{
					attribute = resizeElement.attributes.getNamedItem("extension");
					if (attribute != null)
					{
						extension = attribute.value;
					}
				}
				
				var imageFormatText = "";
				attribute = resizeElement.attributes.getNamedItem("ImageFormatText");
				if (attribute != null)
				{
					imageFormatText = attribute.value;
				}
				else
				{
					attribute = resizeElement.attributes.getNamedItem("imageformattext");
					if (attribute != null)
					{
						imageFormatText = attribute.value;
					}
				}
				
				var imageSizeText = "";
				attribute = resizeElement.attributes.getNamedItem("ImageSizeText");
				if (attribute != null)
				{
					imageSizeText = attribute.value;
				}
				else
				{
					attribute = resizeElement.attributes.getNamedItem("imagesizetext");
					if (attribute != null)
					{
						imageSizeText = attribute.value;
					}
				}
				
				var fileSizeText = "";
				attribute = resizeElement.attributes.getNamedItem("FileSizeText");
				if (attribute != null)
				{
					fileSizeText = attribute.value;
				}
				else
				{
					attribute = resizeElement.attributes.getNamedItem("filesizetext");
					if (attribute != null)
					{
						fileSizeText = attribute.value;
					}
				}
				
				var resize = new WebImageResize(this, internalCode, imageSize, fileSize, extension, imageFormatText, imageSizeText, fileSizeText);

			}
		}
	}
		
	doc = null;
}

WebImage.prototype.Resizes = null;
WebImage.prototype.GetResizeByName = function(internalCode)
{
	for(var i=0;i<this.Resizes.length;i++)
	{
		if (this.Resizes[i].InternalCode == internalCode)
		{
			return this.Resizes[i];
		}
	}
	return null;
}

WebImage.prototype.SourceImage = function()
{
	return this.GetResizeByName("__Source");
}

WebImage.prototype.SelectedImage = function()
{
	return this.GetResizeByName("__Selected");
}

WebImage.prototype.IconImage = function()
{
	return this.GetResizeByName("__Icon");
}

WebImage.prototype.FolderPath = "";
WebImage.prototype.FolderPathEnc = "";
WebImage.prototype.FolderUrl = "";
WebImage.prototype.Id = "";
WebImage.prototype.K2 = "";
WebImage.prototype.ConfigurationInternalCode = "";
WebImage.prototype.ImageDefinitionInternalCode = "";
WebImage.prototype.SourceFilters = null;
WebImage.prototype.SourceImageClientFileName = "";
WebImage.prototype.Storage = "";

WebImage.prototype.IsTemporary = function()
{
	if (this.Storage == "TemporaryFolder")
	{
		return true;
	}
	else
	{
		return false;
	}
}

WebImage.prototype.UseCustomStorage = function()
{
	if (this.Storage == "Custom")
	{
		return true;
	}
	else
	{
		return false;
	}
}

WebImage.prototype.UseFileSystemStorage = function()
{
	return !this.UseCustomStorage();
}

WebImage.prototype.GetFileName = function(internalCode, extension)
{
	if (this.UseFileSystemStorage())
	{
		if (extension[0] == ".")
		{
			var s = "";
			extension = extension.substring(1, extension.length-1);
		}
		return this.Id + "_" + internalCode + "." + extension;
	}
	else
	{
		return this.GetFileUrlName(internalCode, extension);
	}
}

WebImage.prototype.GetFileUrlName = function(internalCode, extension)
{
	if (this.UseFileSystemStorage())
	{
		if (this.Storage == "WebPublishedFileSystem")
		{
			return this.GetFileName(internalCode, extension);
		}
		else
		{
			var res = "";
			res += "__GIPath=" + URLEncode(this.FolderPathEnc);
			res += "&__GIId=" + URLEncode(this.Id);
			res += "&__GIResize=" + URLEncode(internalCode);
			res += "&__GIExt=" + URLEncode(extension);
			res += "&__GIK2=" + URLEncode(this.K2);
			return res;
		}
	}
	else
	{
		var res = "";
		res += "&ConfigIC=" + URLEncode(this.ConfigurationInternalCode);
		res += "&Id=" + URLEncode(this.Id);
		res += "&Resize=" + URLEncode(internalCode);
		res += "&FileExtension=" + URLEncode(extension.toLowerCase());
		return res;
	}
}

WebImage.prototype.GetFilePath = function(fileName)
{
	if (!this.UseFileSystemStorage())
	{
		window.alert("Ivalid operation.");
		return null;
	}
	if (this.FolderPath)
	{
		var lastChar = this.FolderPath.substr(this.FolderPath.length-1,1);
		if ((lastChar == "/") || (lastChar == "\\"))
		{
			return this.FolderPath + fileName;
		}
		else
		{
			return this.FolderPath + "/" + fileName;
		}
	}
	return fileName;
}

WebImage.prototype.GetFileUrl = function(fileName)
{
	if (this.UseFileSystemStorage())
	{
		if (this.Storage == "WebPublishedFileSystem")
		{
			if (this.FolderUrl)
			{
				var lastChar = this.FolderUrl.substr(this.FolderUrl.length-1,1);
				if (lastChar == "/")
				{
					return this.FolderUrl + fileName;
				}
				else
				{
					return this.FolderUrl + "/" + fileName;
				}
			}
			return fileName;
		}
	}
	if (this.FolderUrl.indexOf("?") >= 0)
	{
		return this.FolderUrl + "&" + fileName;
	}
	else
	{
		return this.FolderUrl + "?" + fileName;
	}
}

WebImage.prototype.GetIndex = function()
{
	var doc = createXMLDOM("WebImage");
	var root = doc.firstChild;
	
	root.setAttribute("Version", "2.0");
	
	root.setAttribute("ConfigurationInternalCode", "" + this.ConfigurationInternalCode);	
	root.setAttribute("ImageDefinitionInternalCode", "" + this.ImageDefinitionInternalCode);
	root.setAttribute("FolderPath", "" + this.FolderPath);
	root.setAttribute("FolderPathEnc", "" + this.FolderPathEnc);
	root.setAttribute("FolderUrl", "" + this.FolderUrl);
	root.setAttribute("Id", "" + this.Id);
	root.setAttribute("K2", "" + this.K2);
	root.setAttribute("Storage", "" + this.Storage);
	root.setAttribute("SourceImageClientFileName", "" + this.SourceImageClientFileName);
	
	if (this.SourceFilters != null)
	{
		var sourceFiltersElement = doc.createElement("SourceFilters");
		root.appendChild(sourceFiltersElement);
		
		sourceFiltersElement.setAttribute("ZoomFactor", "" + this.SourceFilters.ZoomFactor);

		var sourceImageSizeElement = doc.createElement("SourceImageSize");
		sourceFiltersElement.appendChild(sourceImageSizeElement);
		
		sourceImageSizeElement.setAttribute("Width", "" + this.SourceFilters.SourceImageSize.Width);
		sourceImageSizeElement.setAttribute("Height", "" + this.SourceFilters.SourceImageSize.Height);

		var sourceRectangleElement = doc.createElement("SourceRectangle");
		sourceFiltersElement.appendChild(sourceRectangleElement);
		
		sourceRectangleElement.setAttribute("X", "" + this.SourceFilters.SourceRectangle.X);
		sourceRectangleElement.setAttribute("Y", "" + this.SourceFilters.SourceRectangle.Y);
		sourceRectangleElement.setAttribute("Width", "" + this.SourceFilters.SourceRectangle.Width);
		sourceRectangleElement.setAttribute("Height", "" + this.SourceFilters.SourceRectangle.Height);

		sourceFiltersElement.setAttribute("RotationAngle", "" + this.SourceFilters.RotationAngle);
		if (this.SourceFilters.FlipHorizontal)
		{
			sourceFiltersElement.setAttribute("FlipHorizontal", "1");
		}
		else
		{
			sourceFiltersElement.setAttribute("FlipHorizontal", "0");
		}
		if (this.SourceFilters.FlipVertical)
		{
			sourceFiltersElement.setAttribute("FlipVertical", "1");
		}
		else
		{
			sourceFiltersElement.setAttribute("FlipVertical", "0");
		}

	}

	var resizesElement = doc.createElement("Resizes");
	root.appendChild(resizesElement);

	for(var i=0;i<this.Resizes.length;i++)
	{
		var resize = this.Resizes[i];

		var resizeElement = doc.createElement("Resize");
		resizesElement.appendChild(resizeElement);
		
		resizeElement.setAttribute("InternalCode", resize.InternalCode);

		var imageSizeElement = doc.createElement("ImageSize");
		resizeElement.appendChild(imageSizeElement);
		
		imageSizeElement.setAttribute("Width", "" + resize.Size.Width);
		imageSizeElement.setAttribute("Height", "" + resize.Size.Height);
		
		resizeElement.setAttribute("Extension", "" + resize.Extension);
		resizeElement.setAttribute("FileSize", "" + resize.FileSize);
		resizeElement.setAttribute("ImageFormatText", "" + resize.ImageFormatText);
		resizeElement.setAttribute("ImageSizeText", "" + resize.ImageSizeText);
		resizeElement.setAttribute("FileSizeText", "" + resize.FileSizeText);
	}
	
	var res = "";
	if (window.ActiveXObject)
	{
		res += doc.xml;
	}
	else
	{		
		var xmlSerializer = new XMLSerializer();
		res += xmlSerializer.serializeToString(doc);
		xmlSerializer = null;
		
		if ((!res) || (res == ""))
		{
			//res = getInnerXMLGeneric(doc);
		}
	}
		
	res = StringReplace(res, "&amp;", "_^?@EC1?^_");
	res = StringReplace(res, "&", "_^?@EC2?^_");
	res = StringReplace(res, "_^?@EC1?^_", "&amp;");
	res = StringReplace(res, "_^?@EC2?^_", "&amp;");
			
	doc = null;
	return res;
}

WebImage.prototype.IsSameImage = function(value)
{
	if (value != null)
	{
		if (value.K2 == this.K2)
		{
			if (value.ImageDefinitionInternalCode == this.ImageDefinitionInternalCode)
			{
				if (value.SourceImageClientFileName == this.SourceImageClientFileName)
				{
					if (value.SourceImage != null)
					{
						if (value.SourceImage.ImageFormatText == this.SourceImage.ImageFormatText)
						{
							if (value.SourceImage.ImageSizeText == this.SourceImage.ImageSizeText)
							{
								return true;
							}
						}
					}
				}
			}
		}
	}
	return false;
}

function WebImageResize(webImage, internalCode, size, fileSize, extension, imageFormatText, imageSizeText, fileSizeText)
{
	this.WebImage = webImage;
	this.InternalCode = internalCode;
	this.Size = size;
	this.FileSize = fileSize;
	this.Extension = extension;
	if (this.WebImage.Resizes.push)
	{
		this.WebImage.Resizes.push(this);
	}
	else
	{
		this.WebImage.Resizes[this.WebImage.Resizes.length] = this
	}
	
	this.ImageFormatText = imageFormatText;
	this.ImageSizeText = imageSizeText;
	this.FileSizeText = fileSizeText;
}

WebImageResize.prototype.WebImage = null;
WebImageResize.prototype.InternalCode = "";
WebImageResize.prototype.Extension = "";
WebImageResize.prototype.Size = null;
WebImageResize.prototype.FileSize = "";

WebImageResize.prototype.ImageSizeText = "";
WebImageResize.prototype.FileSizeText = "";
WebImageResize.prototype.ImageFormatText = "";

WebImageResize.prototype.FileName = function()
{
	return this.WebImage.GetFileName(this.InternalCode, this.Extension);
}

WebImageResize.prototype.FileUrlName = function()
{
	return this.WebImage.GetFileUrlName(this.InternalCode, this.Extension);
}

WebImageResize.prototype.FilePath = function()
{
	return this.WebImage.GetFilePath(this.FileName());
}

WebImageResize.prototype.FileUrl = function()
{
	return this.WebImage.GetFileUrl(this.FileUrlName());
}

WebImageResize.prototype.FileUrl_NoCache = function()
{
	var url = this.FileUrl();
	if (url.indexOf("?") < 0)
	{
		return url + "?fr=" + escape(Date());
	}
	else
	{
		return url + "&fr=" + escape(Date());
	}
}

function ILoadControl(controlId)
{
	this.ControlId = controlId;
}
ILoadControl.prototype.ControlId = "";
ILoadControl.prototype.ControlKey = "";
ILoadControl.prototype.WebImage = null;
ILoadControl.prototype.AutoPostBack = false;
ILoadControl.prototype.AutomaticallyClearTemporaryFiles = true;
ILoadControl.prototype.AutomaticallyDeleteRemovedFiles = false;
ILoadControl.prototype.AllowEditImage = false;
ILoadControl.prototype.AllowPreviewWindow = true;
ILoadControl.prototype.IconCustomResize = "";
ILoadControl.prototype.AutoPostBackEventHandler = false;
ILoadControl.prototype.ControlTitle = "";
ILoadControl.prototype.PreviewWindowTitle = "";
ILoadControl.prototype.AddImageButtonText = "Browse...";
ILoadControl.prototype.EditImageButtonText = "Edit...";
ILoadControl.prototype.Appearance = 1;
ILoadControl.prototype.Definition_InternalCodes = null;
ILoadControl.prototype.Definition_Titles = null;
ILoadControl.prototype.ResizeDefinition_InternalCodes = null;
ILoadControl.prototype.ResizeDefinition_Titles = null;
ILoadControl.prototype.ValueChangedEventHandler = false;
ILoadControl.prototype.Culture = "";

var ILoadControls = new Array();