﻿Type.registerNamespace('Inductronic');Inductronic._CropDragDropManager = function() {
Inductronic._CropDragDropManager.initializeBase(this);if (this._instance != null) {
delete this._instance;}
this._instance = null;}
Inductronic._CropDragDropManager.prototype = {
_getInstance: function() {
if (!this._instance) {
this._instance = new AjaxControlToolkit.GenericDragDropManager();this._instance.initialize();this._instance.add_dragStart(Function.createDelegate(this, this._raiseDragStart));this._instance.add_dragStop(Function.createDelegate(this, this._raiseDragStop));}
return this._instance;}
}
Inductronic._CropDragDropManager.DropPending = null;Inductronic._CropDragDropManager.registerClass('Inductronic._CropDragDropManager', AjaxControlToolkit._DragDropManager);Inductronic.CropDragDropManager = new Inductronic._CropDragDropManager();Inductronic.ImageCropBehavior = function(element) {
Inductronic.ImageCropBehavior.initializeBase(this, [element]);this._imageServiceMethod = '';this._imageServicePath = '';this._imageRecipe = '';this._key = '';this._imageUrl = '';this._ratioDimensionX = 0;this._ratioDimensionY = 0;this._minimumWidth = 0;this._minimumHeight = 0;this._maximumWidth = 0;this._maximumHeight = 0;this._x1 = 0;this._x2 = 0;this._y1 = 0;this._y2 = 0;this._onResizeDelegate = null;this._onDragDelegate = null;this._onEndCropDelegate = null;this._onLoadDelegate = null;this._updatePositionsDelegate = null;this._resizing = false;this._attached = false;this._fixedWidth = false;this._fixedHeight = false;this._ratioX = 0;this._ratioY = 0;this._imageWidth = 0;this._imageHeight = 0;this._previewLeft = 0;this._previewTop = 0;this._previewWidth = 0;this._previewHeight = 0;}
Inductronic.ImageCropBehavior.prototype = {
initialize : function() {
Inductronic.ImageCropBehavior.callBaseMethod(this, 'initialize');var element = this.get_element();this._img = document.createElement('img');element.appendChild( this._img );this._dragArea = document.createElement('div');element.appendChild( this._dragArea );this._dragArea.className = 'dragarea';this._north = document.createElement('div');this._dragArea.appendChild(this._north);this._north.className = 'overlay';this._north.innerHTML = '<span></span>';this._east = document.createElement('div');this._dragArea.appendChild(this._east);this._east.className = 'overlay';this._east.innerHTML = '<span></span>';this._south = document.createElement('div');this._dragArea.appendChild(this._south);this._south.className = 'overlay';this._south.innerHTML = '<span></span>';this._west = document.createElement('div');this._dragArea.appendChild(this._west);this._west.className = 'overlay';this._west.innerHTML = '<span></span>';this._selArea = document.createElement('div');this._dragArea.appendChild( this._selArea );this._selArea.className = 'selarea';var clickArea = document.createElement('div');this._dragArea.appendChild( clickArea );clickArea.className = 'clickarea';this._handleN = document.createElement('div');this._selArea.appendChild(this._handleN);this._handleN.className = 'handle handleN';this._handleNE = document.createElement('div');this._selArea.appendChild(this._handleNE);this._handleNE.className = 'handle handleNE';this._handleE = document.createElement('div');this._selArea.appendChild(this._handleE);this._handleE.className = 'handle handleE';this._handleSE = document.createElement('div');this._selArea.appendChild(this._handleSE);this._handleSE.className = 'handle handleSE';this._handleS = document.createElement('div');this._selArea.appendChild(this._handleS);this._handleS.className = 'handle handleS';this._handleSW = document.createElement('div');this._selArea.appendChild(this._handleSW);this._handleSW.className = 'handle handleSW';this._handleW = document.createElement('div');this._selArea.appendChild(this._handleW);this._handleW.className = 'handle handleW';this._handleNW = document.createElement('div');this._selArea.appendChild(this._handleNW);this._handleNW.className = 'handle handleNW';this._handles = [ this._handleN, this._handleNE, this._handleE, this._handleSE, this._handleS, this._handleSW, this._handleW, this._handleNW ];this._handleDelegates(true);$addHandler( this._img, 'load', this._onLoadDelegate );var dragBehavior = $create(Inductronic.ImageCropDragSourceBehavior, {id: this._selArea.id }, { updatePositions: this._updatePositionsDelegate }, null, this._selArea );Inductronic.DragDropManagerInternal.registerDropTarget(this);this.update();},
dispose : function() {
Inductronic.DragDropManagerInternal.unregisterDropTarget(this);var element = this.get_element();if (element) 
{
$removeHandler( this._img, 'load', this._onLoadDelegate );this._handleEvents(false);this._handleDelegates(false);}
Inductronic.ImageCropBehavior.callBaseMethod(this, 'dispose');},
_handleEvents : function(attach)
{
if( attach && this._attached === false )
{
this._attached = true;$addHandler( document, 'mousemove', this._onDragDelegate );$addHandler( document, 'mouseup', this._onEndCropDelegate );$addHandler( this.get_element(), 'updatePositions', this._updatePositionsDelegate );this._registerHandles( attach );}
else if( this._attached === true )
{
$removeHandler( this.get_element(), 'updatePositions', this._updatePositionsDelegate );$removeHandler( document, 'mousemove', this._onDragDelegate );$removeHandler( document, 'mouseup', this._onEndCropDelegate );this._registerHandles( attach );this._attached = false;}
}, 
_handleDelegates : function(create)
{
if( create )
{ 
this._onLoadDelegate = Function.createDelegate(this, this._onLoadEvent);this._onDragDelegate = Function.createDelegate(this, this._onDragEvent );this._onEndCropDelegate = Function.createDelegate(this, this._onEndCropEvent );this._onResizeDelegate = Function.createDelegate(this, this._onResizeEvent );this._updatePositionsDelegate = Function.createDelegate(this, this._updatePositionsEvent );}
else
{
if(this._onLoadDelegate)
{
delete this._onLoadDelegate;this._onLoadDelegate = null;} 
if(this._onDragDelegate)
{
delete this._onDragDelegate;this._onDragDelegate = null;} 
if(this._onEndCropDelegate)
{
delete this._onEndCropDelegate;this._onEndCropDelegate = null;} 
if(this._onResizeDelegate)
{
delete this._onResizeDelegate;this._onResizeDelegate = null;} 
if(this._updatePositionsDelegate)
{
delete this._updatePositionsDelegate;this._updatePositionsDelegate = null;}
}
},
_getGCD : function( a , b ) {
if( b === 0 ) return a;return this._getGCD(b, a % b );},
_onLoadEvent : function(e)
{ 
if(this._imageUrl != null && this._imageUrl.length > 0)
{
if(Sys.UI.DomElement.containsCssClass(this._img, 'loading'))
{
Sys.UI.DomElement.removeCssClass(this._img, 'loading');}
var element = this.get_element();this._imageWidth = this._img.width;this._imageHeight = this._img.height;this._resizing = false;this._ratioX = 0;this._ratioY = 0;this._attached = false;this._fixedWidth = ( this._maximumWidth > 0 && ( this._minimumWidth >= this._maximumWidth ) );this._fixedHeight = ( this._maximumHeight > 0 && ( this._minimumHeight >= this._maximumHeight ) );if( this._ratioDimensionX > 0 && this._ratioDimensionY > 0 ) {
var gcd = this._getGCD( this._ratioDimensionX, this._ratioDimensionY );this._ratioX = this._ratioDimensionX / gcd;this._ratioY = this._ratioDimensionY / gcd;}
this._north.style.height = '0';this._east.style.width = '0';this._east.style.height = '0';this._south.style.height = '0';this._west.style.width = '0';this._west.style.height = '0';element.style.width = this._imageWidth + 'px';element.style.height = this._imageHeight + 'px';var startCoords = { x1: 0, y1: 0, x2: 0, y2: 0 };var display = false;if( this._ratioDimensionX > 0 && this._ratioDimensionY > 0 ) {
startCoords.x1 = Math.ceil( ( this._imageWidth - this._ratioDimensionX ) / 2 );startCoords.y1 = Math.ceil( ( this._imageHeight - this._ratioDimensionY ) / 2 );startCoords.x2 = startCoords.x1 + this._ratioDimensionX;startCoords.y2 = startCoords.y1 + this._ratioDimensionY;display = true;} else if( this._x1 > 0 || this._x2 > 0 || this._y1 > 0 || this._y2 > 0 ) {
startCoords = { x1: this._x1, y1: this._y1, x2: this._x2, y2: this._y2 };display = true;} 
this._handleEvents(true);this._setAreaCoords( startCoords, false, false, null, null );if( display ){
this._drawArea();this._show(this._img);this._show(this._dragArea);}
}
this._raiseEvent('cropChanged', Sys.EventArgs.Empty);},
_registerHandles : function(registration)
{
for( var i = 0;i < this._handles.length;i++ ) {
var handle = this._handles[i];if( registration ) {
var hideHandle = false;if( this._fixedWidth && this._fixedHeight ) hideHandle = true;else if( this._fixedWidth || this._fixedHeight ) {
var isCornerHandle = handle.className.match( /([S|N][E|W])$/ )
var isWidthHandle = handle.className.match( /(E|W)$/ );var isHeightHandle = handle.className.match( /(N|S)$/ );if( isCornerHandle ) hideHandle = true;else if( this._fixedWidth && isWidthHandle ) hideHandle = true;else if( this._fixedHeight && isHeightHandle ) hideHandle = true;}
if( hideHandle ) 
this._hide(handle);else
{
$addHandler( handle, 'mousedown', this._onResizeDelegate );}
} else {
$removeHandler( handle, 'mousedown', this._onResizeDelegate );}
}
},
_hide: function(element) {
element.style.visibility = 'hidden';},
_show: function(element) {
element.style.visibility = 'visible';},
_cloneCoords: function( coords ) {
return { x1: coords.x1, y1: coords.y1, x2: coords.x2, y2: coords.y2 };},
_calculatedWidth: function() {
return (this._areaCoords.x2 - this._areaCoords.x1)
},
_calculatedHeight: function() {
return (this._areaCoords.y2 - this._areaCoords.y1)
},
_drawArea : function( ) { 
var areaWidth = this._calculatedWidth();var areaHeight = this._calculatedHeight();var px = 'px';var params = [
this._areaCoords.x1 + px,
this._areaCoords.y1 + px,
areaWidth + px,
areaHeight + px,
this._areaCoords.x2 + px,
this._areaCoords.y2 + px,
(this._img.width - this._areaCoords.x2) + px,
(this._img.height - this._areaCoords.y2) + px ];var areaStyle = this._selArea.style;areaStyle.left = params[0];areaStyle.top = params[1];areaStyle.width = params[2];areaStyle.height = params[3];var horizHandlePos = Math.ceil( (areaWidth - 6) / 2 ) + px;var vertHandlePos = Math.ceil( (areaHeight - 6) / 2 ) + px;this._handleN.style.left = horizHandlePos;this._handleE.style.top = vertHandlePos;this._handleS.style.left = horizHandlePos;this._handleW.style.top = vertHandlePos;this._north.style.height = params[1];var eastStyle = this._east.style;eastStyle.top = params[1];eastStyle.height = params[3];eastStyle.left = params[4];eastStyle.width = params[6];var southStyle = this._south.style;southStyle.top = params[5];southStyle.height = params[7];var westStyle = this._west.style;westStyle.top = params[1];westStyle.height = params[3];westStyle.width = params[0];if ( Sys.Browser.agent == Sys.Browser.InternetExplorer && Sys.Browser.version < 7) { 
var node = document.createTextNode(' ');this._selArea.appendChild(node);this._selArea.removeChild(node);}
},
_setAreaCoords : function( coords, moving, square, direction, resizeHandle ) 
{
if( moving ) 
{
var targW = coords.x2 - coords.x1;var targH = coords.y2 - coords.y1;if( coords.x1 < 0 ) {
coords.x1 = 0;coords.x2 = targW;}
if( coords.y1 < 0 ) {
coords.y1 = 0;coords.y2 = targH;}
if( coords.x2 > this._imageWidth ) {
coords.x2 = this._imageWidth;coords.x1 = this._imageWidth - targW;}
if( coords.y2 > this._imageHeight ) {
coords.y2 = this._imageHeight;coords.y1 = this._imageHeight - targH;} 
} else {
if( coords.x1 < 0 ) coords.x1 = 0;if( coords.y1 < 0 ) coords.y1 = 0;if( coords.x2 > this._imageWidth ) coords.x2 = this._imageWidth;if( coords.y2 > this._imageHeight ) coords.y2 = this._imageHeight;if( direction != null ) {
if( this._ratioX > 0 ) this._applyRatio( coords, { x: this._ratioX, y: this._ratioY }, direction, resizeHandle );else if( square ) this._applyRatio( coords, { x: 1, y: 1 }, direction, resizeHandle );var mins = [ this._minimumWidth, this._minimumHeight ];var maxs = [ this._maximumWidth, this._maximumHeight ];if( mins[0] > 0 || mins[1] > 0 || maxs[0] > 0 || maxs[1] > 0) {
var coordsTransX = { a1: coords.x1, a2: coords.x2 };var coordsTransY = { a1: coords.y1, a2: coords.y2 };var boundsX = { min: 0, max: this._imageWidth };var boundsY = { min: 0, max: this._imageHeight };if( (mins[0] != 0 || mins[1] != 0) && square ) {
if( mins[0] > 0 ) mins[1] = mins[0];else if( mins[1] > 0 ) mins[0] = mins[1];}
if( (maxs[0] != 0 || maxs[0] != 0) && square ) {
if( maxs[0] > 0 && maxs[0] <= maxs[1] ) 
maxs[1] = maxs[0];else if( maxs[1] > 0 && maxs[1] <= maxs[0] ) 
maxs[0] = maxs[1];}
if( mins[0] > 0 ) this._applyDimRestriction( coordsTransX, mins[0], direction.x, boundsX, 'min' );if( mins[1] > 1 ) this._applyDimRestriction( coordsTransY, mins[1], direction.y, boundsY, 'min' );if( maxs[0] > 0 ) this._applyDimRestriction( coordsTransX, maxs[0], direction.x, boundsX, 'max' );if( maxs[1] > 1 ) this._applyDimRestriction( coordsTransY, maxs[1], direction.y, boundsY, 'max' );coords = { x1: coordsTransX.a1, y1: coordsTransY.a1, x2: coordsTransX.a2, y2: coordsTransY.a2 };}
}
}
this._areaCoords = coords;},
_applyRatio : function( coords, ratio, direction, resizeHandle ) 
{
var newCoords;if( resizeHandle === 'N' || resizeHandle === 'S' ) {
newCoords = this._applyRatioToAxis( 
{ a1: coords.y1, b1: coords.x1, a2: coords.y2, b2: coords.x2 },
{ a: ratio.y, b: ratio.x },
{ a: direction.y, b: direction.x },
{ min: 0, max: this._imageWidth }
);coords.x1 = newCoords.b1;coords.y1 = newCoords.a1;coords.x2 = newCoords.b2;coords.y2 = newCoords.a2;} else {
newCoords = this._applyRatioToAxis( 
{ a1: coords.x1, b1: coords.y1, a2: coords.x2, b2: coords.y2 },
{ a: ratio.x, b: ratio.y },
{ a: direction.x, b: direction.y },
{ min: 0, max: this._imageHeight }
);coords.x1 = newCoords.a1;coords.y1 = newCoords.b1;coords.x2 = newCoords.a2;coords.y2 = newCoords.b2;}
},
_applyDimRestriction: function( coords, val, direction, bounds, type )
{
var check;if( type === 'min' ) 
check = ( ( coords.a2 - coords.a1 ) < val );else 
check = ( ( coords.a2 - coords.a1 ) > val );if( check ) {
if( direction === 1 ) 
coords.a2 = coords.a1 + val;else 
coords.a1 = coords.a2 - val;if( coords.a1 < bounds.min ) {
coords.a1 = bounds.min;coords.a2 = val;} else if( coords.a2 > bounds.max ) {
coords.a1 = bounds.max - val;coords.a2 = bounds.max;}
}
},
_applyRatioToAxis: function( coords, ratio, direction, bounds ) 
{
var newCoords = { a1: 0, b1: 0, a2: 0, b2: 0 };newCoords.a1 = coords.a1;newCoords.b1 = coords.b1;newCoords.a2 = coords.a2;newCoords.b2 = coords.b2;var calcDimA = newCoords.a2 - newCoords.a1;var targDimB = Math.floor( calcDimA * ratio.b / ratio.a );var targB;var targDimA;var calcDimB = null;if( direction.b === 1 ) {
targB = newCoords.b1 + targDimB;if( targB > bounds.max ) {
targB = bounds.max;calcDimB = targB - newCoords.b1;}
newCoords.b2 = targB;} else { 
targB = newCoords.b2 - targDimB;if( targB < bounds.min ) {
targB = bounds.min;calcDimB = targB + newCoords.b2;}
newCoords.b1 = targB;}
if( calcDimB != null ) {
targDimA = Math.floor( calcDimB * ratio.a / ratio.b );if( direction.a === 1 ) newCoords.a2 = newCoords.a1 + targDimA;else newCoords.a1 = newCoords.a1 = newCoords.a2 - targDimA;}
return newCoords;},
_cumulativeOffset : function(element) {
var valueT = 0, valueL = 0;do {
valueT += element.offsetTop || 0;valueL += element.offsetLeft || 0;element = element.offsetParent;} while (element);return [valueL, valueT];},
_getCurPos : function( e ) {
var el = this.get_element();var wrapOffsets = this._cumulativeOffset( el );while( el.nodeName != 'BODY' ) {
wrapOffsets[1] -= el.scrollTop || 0;wrapOffsets[0] -= el.scrollLeft || 0;el = el.parentNode;} 
return curPos = { 
x: e.clientX - wrapOffsets[0],
y: e.clientY - wrapOffsets[1]
}
},
_transformCoords : function( curVal, baseVal, coords, axis ) {
var newVals = [ curVal, baseVal ];if( curVal > baseVal ) newVals.reverse();coords[ axis + '1' ] = newVals[0];coords[ axis + '2' ] = newVals[1];},
_updatePositionsEvent : function(sender, args) {
this._setAreaCoords( 
{
x1: args[0], 
y1: args[1],
x2: args[0] + this._calculatedWidth(),
y2: args[1] + this._calculatedHeight()
},
true,
false,
null,
null
);this._drawArea();},
_onDragEvent : function(e)
{
if(this._resizing ) { 
var resizeHandle = null;var curPos = this._getCurPos( e );var newCoords = this._cloneCoords( this._areaCoords );var direction = { x: 1, y: 1 };resizeHandle = this._resizeHandle;if( resizeHandle.match(/E/) ) {
this._transformCoords( curPos.x, this._startCoords.x1, newCoords, 'x' );if( curPos.x < this._startCoords.x1 ) direction.x = -1;} else if( resizeHandle.match(/W/) ) {
this._transformCoords( curPos.x, this._startCoords.x2, newCoords, 'x' );if( curPos.x < this._startCoords.x2 ) direction.x = -1;}
if( resizeHandle.match(/N/) ) {
this._transformCoords( curPos.y, this._startCoords.y2, newCoords, 'y' );if( curPos.y < this._startCoords.y2 ) direction.y = -1;} else if( resizeHandle.match(/S/) ) {
this._transformCoords( curPos.y, this._startCoords.y1, newCoords, 'y' );if( curPos.y < this._startCoords.y1 ) direction.y = -1;}
this._setAreaCoords( newCoords, false, e.shiftKey, direction, resizeHandle );this._drawArea();e.preventDefault();e.stopPropagation();}
},
_onEndCropEvent : function(e)
{
this._resizing = false;var calcWidth = this._calculatedWidth();var calcHeight = this._calculatedHeight();this._x1 = this._areaCoords.x1;this._x2 = this._areaCoords.x2;this._y1 = this._areaCoords.y1;this._y2 = this._areaCoords.y2;this._previewWidth = Math.ceil( this._minimumWidth * ( this._imageWidth / calcWidth ) );this._previewHeight = Math.ceil( this._minimumHeight * ( this._imageHeight / calcHeight ) );this._previewLeft = -1 * Math.ceil( this._areaCoords.x1 / ( calcWidth / this._minimumWidth ) );this._previewTop = -1 * Math.ceil( this._areaCoords.y1 / ( calcHeight / this._minimumHeight ) );this._raiseEvent('cropClick', Sys.EventArgs.Empty);},
_onResizeEvent : function(e)
{
this._startCoords = this._cloneCoords( this._areaCoords );this._resizing = true;this._resizeHandle = e.target.className.replace(/([^N|NE|E|SE|S|SW|W|NW])+/, '');e.preventDefault();e.stopPropagation();},
update : function()
{
this._handleEvents(false);if(this._img != null && this._key != null && this._key.length > 0)
{
this.set_imageUrl(Inductronic.ApplicationManagerBehavior.getInstance().createImageUrl(this._key, this._imageRecipe));if(!Sys.UI.DomElement.containsCssClass(this._img, 'loading'))
{
Sys.UI.DomElement.addCssClass(this._img, 'loading');}
if( this._img.complete && Sys.Browser.agent == Sys.Browser.Opera )
{
this._img.src = this._imageUrl;this._onLoadEvent(null);}
else 
{ 
this._img.src = this._imageUrl;}
}
else if(this._img != null)
{
this._hide(this._dragArea);this._hide(this._img);this._img.src = '';this._x1 = 0;this._x2 = 0;this._y1 = 0;this._y2 = 0;this._previewLeft = 0;this._previewTop = 0;this._previewWidth = 0;this._previewHeight = 0;}
}, 
reset : function()
{
this.set_key('');this.set_imageUrl('');this.update();},
get_dropTargetElement: function()
{
return this.get_element();},
canDrop: function(dragMode, dataType, data)
{
return (dataType == 'DragDropImage' || dataType == 'CropDragImage');},
drop: function(dragMode, dataType, data)
{
if (dataType == 'DragDropImage')
{ 
this.set_key(data.key);this.update();}
},
onDragEnterTarget: function(dragMode, dataType, data)
{
}, 
onDragLeaveTarget: function(dragMode, dataType, data)
{
},
onDragInTarget: function(dragMode, dataType, data)
{
},
add_cropClick : function(handler) {
this.get_events().addHandler('cropClick', handler);}, 
remove_cropClick: function(handler) {
this.get_events().removeHandler('cropClick', handler);}, 
add_cropChanged: function(handler) {
this.get_events().addHandler('cropChanged', handler);}, 
remove_cropChanged: function(handler) {
this.get_events().removeHandler('cropChanged', handler);}, 
_raiseEvent : function(eventName, eventArgs) { 
var handler = this.get_events().getHandler(eventName);if (handler) { 
if (!eventArgs) { 
eventArgs = Sys.EventArgs.Empty;} 
handler(this, eventArgs);} 
}, 
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_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_imageUrl : function() {
return this._imageUrl;}, 
set_imageUrl : function(value) {
var e = Function._validateParams(arguments, [{name: 'value', type: String}]);if (e) throw e;if (this._imageUrl != value){ 
this._imageUrl = value;this.raisePropertyChanged('imageUrl');}
}, 
get_x1 : function() {
return this._x1;}, 
set_x1 : function(value) {
var e = Function._validateParams(arguments, [{name: 'value', type: Number}]);if (e) throw e;if (this._x1 != value) {
this._x1 = value;this.raisePropertyChanged('x1');}
}, 
get_x2 : function() {
return this._x2;}, 
set_x2 : function(value) {
var e = Function._validateParams(arguments, [{name: 'value', type: Number}]);if (e) throw e;if (this._x2 != value) {
this._x2 = value;this.raisePropertyChanged('x2');}
}, 
get_y1 : function() {
return this._y1;}, 
set_y1 : function(value) {
var e = Function._validateParams(arguments, [{name: 'value', type: Number}]);if (e) throw e;if (this._y1 != value) {
this._y1 = value;this.raisePropertyChanged('y1');}
}, 
get_y2 : function() {
return this._y2;}, 
set_y2 : function(value) {
var e = Function._validateParams(arguments, [{name: 'value', type: Number}]);if (e) throw e;if (this._y2 != value) {
this._y2 = value;this.raisePropertyChanged('y2');}
}, 
get_minimumHeight : function() {
return this._minimumHeight;}, 
set_minimumHeight : function(value) {
var e = Function._validateParams(arguments, [{name: 'value', type: Number}]);if (e) throw e;if (this._minimumHeight != value) {
this._minimumHeight = value;this.raisePropertyChanged('minimumHeight');}
}, 
get_minimumWidth : function() {
return this._minimumWidth;}, 
set_minimumWidth : function(value) {
var e = Function._validateParams(arguments, [{name: 'value', type: Number}]);if (e) throw e;if (this._minimumWidth != value) {
this._minimumWidth = value;this.raisePropertyChanged('minimumWidth');}
}, 
get_maximumHeight : function() {
return this._maximumHeight;}, 
set_maximumHeight : function(value) {
var e = Function._validateParams(arguments, [{name: 'value', type: Number}]);if (e) throw e;if (this._maximumHeight != value) {
this._maximumHeight = value;this.raisePropertyChanged('maximumHeight');}
}, 
get_maximumWidth : function() {
return this._maximumWidth;}, 
set_maximumWidth : function(value) {
var e = Function._validateParams(arguments, [{name: 'value', type: Number}]);if (e) throw e;if (this._maximumWidth != value) {
this._maximumWidth = value;this.raisePropertyChanged('maximumWidth');} 
}, 
get_ratioDimensionX : function() {
return this._ratioDimensionX;}, 
set_ratioDimensionX : function(value) {
var e = Function._validateParams(arguments, [{name: 'value', type: Number}]);if (e) throw e;if (this._ratioDimensionX != value) {
this._ratioDimensionX = value;this.raisePropertyChanged('ratioDimensionX');} 
}, 
get_ratioDimensionY : function() {
return this._ratioDimensionY;}, 
set_ratioDimensionY : function(value) {
var e = Function._validateParams(arguments, [{name: 'value', type: Number}]);if (e) throw e;if (this._ratioDimensionY != value) {
this._ratioDimensionY = value;this.raisePropertyChanged('ratioDimensionY');} 
}, 
get_imageWidth : function() {
return this._imageWidth;}, 
get_imageHeight : function() {
return this._imageHeight;}, 
get_previewLeft : function() {
return this._previewLeft;}, 
get_previewTop : function() {
return this._previewTop;}, 
get_previewWidth : function() {
return this._previewWidth;}, 
get_previewHeight : function() {
return this._previewHeight;}
}
Inductronic.ImageCropBehavior.registerClass('Inductronic.ImageCropBehavior', Sys.UI.Control, AjaxControlToolkit.IDropTarget , Sys.IDisposable );Inductronic.ImageCropDragSourceBehavior = function(element)
{
Inductronic.ImageCropDragSourceBehavior.initializeBase(this, [element]);this._onMouseDownDelegate = null;this._onMouseUpDelegate = null;this._onSelectStartDelegate = null;this._selectStartPending = false;this._dragArea = null;}
Inductronic.ImageCropDragSourceBehavior.prototype =
{
initialize: function()
{
Inductronic.ImageCropDragSourceBehavior.callBaseMethod(this,'initialize');var el = this.get_element();if(this._onMouseDownDelegate == null)
{
this._onMouseDownDelegate = Function.createDelegate(this,this._onMouseDownEvent);$addHandler( el, 'mousedown', this._onMouseDownDelegate);}
if(this._onMouseUpDelegate == null)
{
this._onMouseUpDelegate = Function.createDelegate(this,this._onMouseUpEvent);$addHandler( el, 'mouseup', this._onMouseUpDelegate);}
if(this._onSelectStartDelegate == null)
{
this._onSelectStartDelegate = Function.createDelegate(this, this._onSelectStartEvent);}
this._initializeDragArea();}, 
dispose: function()
{
var el = this.get_element();if (this._onMouseDownDelegate)
{
$removeHandler(el, 'mousedown',this._onMouseDownDelegate);delete this._onMouseDownDelegate;this._onMouseDownDelegate = null;}
if (this._onMouseUpDelegate)
{
$removeHandler(el, 'mouseup',this._onMouseUpDelegate);delete this._onMouseUpDelegate;this._onMouseUpDelegate = null;}
if(this._onSelectStartDelegate)
{
delete this._onSelectStartDelegate;this._onSelectStartDelegate = null;}
Inductronic.ImageCropDragSourceBehavior.callBaseMethod(this,'dispose');},
_onMouseDownEvent : function(ev)
{
if (Inductronic.CropDragDropManager.DropPending == null) {
Inductronic.CropDragDropManager.DropPending = this;window._event = ev;ev.preventDefault();this._selectStartPending = true;$addHandler(document, 'selectstart', this._onSelectStartDelegate);this.startDragDrop(this._dragArea);}
},
_onMouseUpEvent : function(ev)
{
if (Inductronic.CropDragDropManager.DropPending == this) {
Inductronic.CropDragDropManager.DropPending = null;if(this._selectStartPending) {
this._selectStartPending = false;$removeHandler(document, 'selectstart', this._onSelectStartDelegate);}
} 
},
_onSelectStartEvent : function(ev) {
ev.preventDefault();}, 
_initializeDragArea : function() {
var dh = this._dragArea = document.createElement('DIV');dh.style.position = 'absolute';dh.style.width = '1px';dh.style.height = '1px';dh.style.overflow = 'hidden';dh.style.zIndex = '999';dh.style.background = 'none';document.body.appendChild(this._dragArea);},
_resetDragArea : function() {
var dragAreaBounds = $common.getBounds(this.get_element());$common.setLocation(this._dragArea, {x:dragAreaBounds.x, y:dragAreaBounds.y});},
startDragDrop : function(dragVisual) {
this._resetDragArea();Inductronic.CropDragDropManager.startDragDrop(this, dragVisual, null);},
get_dragDataType: function() 
{ 
return 'CropDragImage';},
getDragData: function() 
{ 
return null;},
get_dragMode: function() 
{ 
return AjaxControlToolkit.DragMode.Move;},
onDragStart: function() 
{ 
this._resetDragArea();var pos = $common.getLocation(this.get_element());this._offset = [window._event.clientX-pos.x,window._event.clientY-pos.y];},
onDrag: function()
{ 
var el = this.get_element();var pos = $common.getLocation(el);var x = parseInt($common.getCurrentStyle(el, 'left') || '0');var y = parseInt($common.getCurrentStyle(el, 'top') || '0');pos.x -= x;pos.y -= y;var point = [0,0];point[0] = window._event.clientX - pos.x- this._offset[0];point[1] = window._event.clientY - pos.y- this._offset[1];var dragAreaBounds = $common.getBounds(this._dragArea);var cropBounds = $common.getBounds(el.parentNode);var areaPosition = { x:dragAreaBounds.x - cropBounds.x, y:dragAreaBounds.y - cropBounds.y };$common.setLocation(el, areaPosition);this._raiseEvent('updatePositions',point);},
onDragEnd: function() 
{
Inductronic.CropDragDropManager.DropPending = null;}, 
add_updatePositions : function(handler) {
this.get_events().addHandler('updatePositions', handler);}, 
remove_updatePositions : function(handler) {
this.get_events().removeHandler('updatePositions', handler);}, 
_raiseEvent : function(eventName, eventArgs) { 
var handler = this.get_events().getHandler(eventName);if (handler) { 
if (!eventArgs) { 
eventArgs = Sys.EventArgs.Empty;} 
handler(this, eventArgs);} 
}
}
Inductronic.DragDropManagerInternal.DropPending = null;Inductronic.CropDragDropManager.DropPending = null;Inductronic.ImageCropDragSourceBehavior.registerClass('Inductronic.ImageCropDragSourceBehavior', AjaxControlToolkit.BehaviorBase, AjaxControlToolkit.IDragSource);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();