﻿Type.registerNamespace('Inductronic');Inductronic.ImagePreviewBehavior = function(element) {
Inductronic.ImagePreviewBehavior.initializeBase(this, [element]);this._backgroundImageUrl = '';this._imageRecipe = '';this._key = '';this._width = 0;this._height = 0;this._left = 0;this._top = 0;this._onLoadDelegate = null;this._imgType = null;this._imgPreview = null;this._holderDiv = null;this._previewCssClass = '';this._backgroundImageCssClass = '';this._preloadImageUrl = '';}
Inductronic.ImagePreviewBehavior.prototype = {
initialize: function() {
Inductronic.ImagePreviewBehavior.callBaseMethod(this, 'initialize');this._holderDiv = document.createElement('div');this._imgType = document.createElement('img');this._imgPreview = document.createElement('img');this.get_element().appendChild(this._imgType);this.get_element().appendChild(this._holderDiv);this._holderDiv.appendChild(this._imgPreview);this._imgPreview.style.position = 'absolute';$common.setVisible(this._imgPreview, false);if (this._previewCssClass.length > 0) {
Sys.UI.DomElement.addCssClass(this._holderDiv, this._previewCssClass);}
else {
this._previewCssClass = 'previewarea';Sys.UI.DomElement.addCssClass(this._holderDiv, this._previewCssClass);}
if (this._backgroundImageCssClass.length > 0) {
Sys.UI.DomElement.addCssClass(this._imgType, this._backgroundImageCssClass);}
else {
Sys.UI.DomElement.addCssClass(this._imgType, 'previewtype');}
this._imgType.alt = '';this._imgPreview.alt = '';if (this.get_backgroundImageUrl() != null && this.get_backgroundImageUrl().length > 0) {
this._imgType.src = this.get_backgroundImageUrl();}
else {
$common.setVisible(this._imgType, false);}
if (this._onLoadDelegate == null) {
this._onLoadDelegate = Function.createDelegate(this, this._onLoadEvent);$addHandler(this._imgPreview, 'load', this._onLoadDelegate);}
this.update();},
dispose: function() {
if (this._onLoadDelegate != null) {
$removeHandler(this._imgPreview, 'load', this._onLoadDelegate);delete this._onLoadDelegate;this._onLoadDelegate = null;}
Inductronic.ImagePreviewBehavior.callBaseMethod(this, 'dispose');},
_onLoadEvent: function(e) {
if (Sys.UI.DomElement.containsCssClass(this._imgPreview, 'loading')) {
Sys.UI.DomElement.removeCssClass(this._imgPreview, 'loading');}
if (this._key != null && this._key.length > 0) {
var previewStyle = this._imgPreview.style;previewStyle.height = this.get_height() + 'px';previewStyle.width = this.get_width() + 'px';previewStyle.left = this.get_left() + 'px';previewStyle.top = this.get_top() + 'px';$common.setVisible(this._imgPreview, true);}
},
update: function() {
if (this._imgPreview != null && this._key != null && this._key.length > 0) {
if (this._preloadImageUrl != null && this._preloadImageUrl.length > 0) {
if (!Sys.UI.DomElement.containsCssClass(this._imgPreview, 'loading')) {
Sys.UI.DomElement.addCssClass(this._imgPreview, 'loading');}
this._imgPreview.src = this._preloadImageUrl;} 
this._imgPreview.src = Inductronic.ApplicationManagerBehavior.getInstance().createImageUrl(this._key, this._imageRecipe);if (this._imgPreview.complete && Sys.Browser.agent === Sys.Browser.Opera) {
this._onLoadEvent(null);}
}
else if (this._imgPreview != null) {
$common.setVisible(this._imgPreview, false);this._imgPreview.src = '';this.set_left(0);this.set_top(0);this.set_height(0);this.set_width(0);}
},
reset: function() {
this.set_key('');this.update();},
_raiseEvent: function(eventName, eventArgs) {
var handler = this.get_events().getHandler(eventName);if (handler) {
if (!eventArgs) {
eventArgs = Sys.EventArgs.Empty;}
handler(this, eventArgs);}
},
get_backgroundImageUrl: function() {
return this._backgroundImageUrl;},
set_backgroundImageUrl: function(value) {
var e = Function._validateParams(arguments, [{ name: 'value', type: String}]);if (e) throw e;if (this._backgroundImageUrl != value) {
this._backgroundImageUrl = value;if (this._imgType != null && this._backgroundImageUrl != null && this._backgroundImageUrl.length > 0) {
this._imgType.src = this._backgroundImageUrl;}
this.raisePropertyChanged('backgroundImageUrl');}
},
get_backgroundImageCssClass: function() {
return this._backgroundImageCssClass;},
set_backgroundImageCssClass: function(value) {
var e = Function._validateParams(arguments, [{ name: 'value', type: String}]);if (e) throw e;if (this._backgroundImageCssClass != value) {
this._backgroundImageCssClass = value;this.raisePropertyChanged('backgroundImageCssClass');}
},
get_previewCssClass: function() {
return this._previewCssClass;},
set_previewCssClass: function(value) {
var e = Function._validateParams(arguments, [{ name: 'value', type: String}]);if (e) throw e;if (this._previewCssClass != value) {
this._previewCssClass = value;this.raisePropertyChanged('previewCssClass');}
},
get_key: function() {
return this._key;},
set_key: function(value) {
var e = Function._validateParams(arguments, [{ name: 'value', type: String}]);if (e) throw e;if (this._key != value) {
this._key = value;this.raisePropertyChanged('key');}
},
get_imageRecipe: function() {
return this._imageRecipe;},
set_imageRecipe: function(value) {
var e = Function._validateParams(arguments, [{ name: 'value', type: String}]);if (e) throw e;if (this._imageRecipe != value) {
this._imageRecipe = value;this.raisePropertyChanged('imageRecipe');}
},
get_left: function() {
return this._left;},
set_left: function(value) {
var e = Function._validateParams(arguments, [{ name: 'value', type: Number}]);if (e) throw e;if (this._left != value) {
this._left = value;this.raisePropertyChanged('left');}
},
get_top: function() {
return this._top;},
set_top: function(value) {
var e = Function._validateParams(arguments, [{ name: 'value', type: Number}]);if (e) throw e;if (this._top != value) {
this._top = value;this.raisePropertyChanged('top');}
},
get_height: function() {
return this._height;},
set_height: function(value) {
var e = Function._validateParams(arguments, [{ name: 'value', type: Number}]);if (e) throw e;if (this._height != value) {
this._height = value;this.raisePropertyChanged('height');}
},
get_width: function() {
return this._width;},
set_width: function(value) {
var e = Function._validateParams(arguments, [{ name: 'value', type: Number}]);if (e) throw e;if (this._width != value) {
this._width = value;this.raisePropertyChanged('width');}
},
get_preloadImageUrl : function() {
return this._preloadImageUrl;}, 
set_preloadImageUrl : function(value) {
var e = Function._validateParams(arguments, [{name: 'value', type: String}]);if (e) throw e;if (this._preloadImageUrl != value) {
this._preloadImageUrl = value;this.raisePropertyChanged('preloadImageUrl');}
}
}
Inductronic.ImagePreviewBehavior.registerClass('Inductronic.ImagePreviewBehavior', AjaxControlToolkit.BehaviorBase);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();