function _FOCUS_ImageCropper(a,b,c,d,f,e,g){
	this.a=a;
	t(this.a,"originalImage");
	this.q=b?b:false;
	this.k=c?c:2;
	this.J=d?d:"dashed blue";
	this.d=e?e:0;
	this.c=f?f:0;
	this.n=g?g:document.body;
	if(this.square){
		x(this.d===this.c)
	}
	this.L=I(this.n);
	this.e=N(this.a,this.n);
	this.a.ondragstart=function(){return false};
	o(document,"mousedown",this.F.bind(this),false);
	o(document,"mouseup",this.o.bind(this),false);
	o(document,"mousemove",this.G.bind(this),false);
	if(y()){o(window,"mouseout",this.H.bind(this),false)}this.I()
}
_FOCUS_ImageCropper.prototype._width=0;
_FOCUS_ImageCropper.prototype._height=0;
_FOCUS_ImageCropper.prototype._x=0;
_FOCUS_ImageCropper.prototype._y=0;
_FOCUS_ImageCropper.prototype.z=function(){
	var a=document.createElement("DIV");
	t(a,"selectionRegion");
	a.style.border=this.k+"px "+this.J;
	o(a,"mousedown",this.B.bind(this),false);o(a,"mouseup",this.D.bind(this),false);
	var b=document.createElement("IMG");
	t(b,"offsetImage");
	b.src=this.a.src;
	b.width=this.a.width;
	b.height=this.a.height;
	b.alt="Select tool"
	;a.appendChild(b);
	this.b=a;
	this.u=a.childNodes[0];
	this.n.appendChild(this.b)
};
_FOCUS_ImageCropper.prototype.I=function(){
	this.z();
	x(this.a.width>=this.c&&this.a.height>=this.d);
	if(this.q){
		this._width=(this._height=Math.max(this.c,Math.min(this.a.width,this.a.height)/2))
	} else {
		this._width=Math.max(this.a.width/3,this.c);this._height=Math.max(this.a.height/3,this.d)
	}
	this._x=(this.a.width-this._width)/2;this._y=(this.a.height-this._height)/2;
	this.p=new w(this._x,this._y);
	this.f=true;
	this.g=false;
	this.m()
};
_FOCUS_ImageCropper.prototype.H=function(a){
	var b=a||window.event;
	var c=b.relatedTarget||b.toElement;
	if(this.g&&!c){this.o(b)}
};
_FOCUS_ImageCropper.prototype.o=function(a){
	var b=a||window.event;
	if(this.g){
		b.cancelBubble=true;
		if(this._width<0){
			this._x+=this._width;
			this._width=-this._width
		}
		if(this._height<0){
			this._y+=this._height;
			this._height=-this._height
		}
		this.g=false;
		this.f=true;this.j(b)}
};
_FOCUS_ImageCropper.prototype.F=function(a){
	var b=a||window.event;
	b.cancelBubble=true;
	var c=this.l(b);
	var d=b.target?b.target:b.srcElement;
	if(d===this.a){
		this.f=false;
		this.g=true;
		this._x=c.x-this.e.x;
		this._y=c.y-this.e.y;
		this._width=this.c;
		this._height=this.d;
		this.m()
	}
	this.j(b)
};
_FOCUS_ImageCropper.prototype.G=function(a){
	if(!this.f&&this.g){
		var b=a||window.event;
		if(r()&&b&&b.button===0){
			this.o(a)
		} else {
			var c=this.l(b);
			var d=c.x-this.e.x;
			var f=c.y-this.e.y;
			this._width=d-this._x;
			this._height=f-this._y;
			this.m();
			this.j(b)
		}
	} else if(this.f){
		this.C(a)
	}
};
_FOCUS_ImageCropper.prototype.B=function(a){
	if(this.f){
		var b=a||window.event;
		b.cancelBubble=true;
		if(this.b.style.cursor=="move"){
			this.g=true;
			var c=this.l(b);
			var d=c.x-this._x-this.e.x;
			var f=c.y-this._y-this.e.y;
			this.p=new w(d,f)
		} else {
			if(this.b.style.cursor=="se-resize"){
				this._x+=this._width;
				this._y+=this._height;
				this._width=-this._width;
				this._height=-this._height
			} else if(this.b.style.cursor=="sw-resize"){
				this._y+=this._height;
				this._height=-this._height
			} else if(this.b.style.cursor=="ne-resize"){
				this._x+=this._width;
				this._width=-this._width
			}
			this.f=false;
			this.g=true
		}
	this.j(b)
	}
};
_FOCUS_ImageCropper.prototype.D=function(a){
	if(this.f){
		var b=a||window.event;
		b.cancelBubble=true;
		this.g=false;
		this.j(b)
	}
};
_FOCUS_ImageCropper.prototype.C=function(a){
	if(this.f){
		var b=a||window.event;
		b.cancelBubble=true;
		var c=this.l(b);
		var d=c.x-this.e.x;
		var f=c.y-this.e.y;
		if(this.g){
			this._x=d-this.p.dx;
			this._y=f-this.p.dy;
			this.m()
		} else {
			var e=d-this._x;
			var g=f-this._y;
			if(e<3&&g<=this._width/2||g<3&&e<=this._height/2){
				this.b.style.cursor="se-resize"
			} else if(e>this._width-3&&g>this._width/2||g>this._height-3&&e>this._height/2){
				this.b.style.cursor="nw-resize"
			} else if(e<3&&g>this._width/2||g>this._height-3&&e<=this._height/2){
				this.b.style.cursor="ne-resize"
			} else if(g<3&&e>this._height/2||e>this._width-3&&g<=this._width/2){
				this.b.style.cursor="sw-resize"
			} else {
				this.b.style.cursor="move"
			}
		}
	this.j(b)
	}
};
_FOCUS_ImageCropper.prototype.m=function(){
	var a;
	var b;
	var c;
	var d;
	this.A();
	if(this._width>=0){
		a=this._x;
		c=this._width
	} else {
		a=this._x+this._width;
		c=-this._width
	}
	if(this._height>=0){
		b=this._y;
		d=this._height
	} else {
		b=this._y+this._height;
		d=-this._height
	}
	this.b.style.left=a+this.e.x-this.k;
	this.b.style.top=b+this.e.y-this.k;
	this.b.style.width=c+this.k*2;
	this.b.style.height=d+this.k*2;
	this.u.style.left=-a+"px";
	this.u.style.top=-b+"px"
};
_FOCUS_ImageCropper.prototype.A=function(){
	var a;
	if(this.q){
		a=Math.max(Math.abs(this._width),Math.abs(this._height));
		this._width=this._width<0?-a:a;
		this._height=this._height<0?-a:a
	}
	if(this._x<0){
		this._x=0
	} else if(this._x+this._width<0){
		this._width=-this._x
	} else if(this._x+this._width>this.a.width){
		if(!this.f){
			this._width=this.a.width-this._x
		} else {
			this._x=this.a.width-this._width
		}
	}
	if(this._y<0){
		this._y=0
	} else if(this._y+this._height<0){
		this._height=-this._y
	} else if(this._y+this._height>this.a.height){
		if(!this.f){
			this._height=this.a.height-this._y
		} else {
		this._y=this.a.height-this._height
		}
	}
	if(this.q){
		a=Math.min(Math.abs(this._width),Math.abs(this._height));
		this._width=this._width<0?-a:a;
		this._height=this._height<0?-a:a
	}
	if(Math.abs(this._width)<this.c){
		if(this._width>=0){
			if(this._x+this.c>this.a.width){
				this._x-=this.c-this.a.width+this._x
			}
			this._width=this.c
		} else {
			if(this._x-this.c<0){
				this._x+=this._width+this.c
			}
			this._width=-this.c
		}
	}
	if(Math.abs(this._height)<this.d){
		if(this._height>=0){
			if(this._y+this.d>this.a.height){
				this._y-=this.d-this.a.height+this._y
			}
			this._height=this.d
		} else {
			if(this._y-this.d<0){
				this._y+=this._height+this.d
			}
			this._height=-this.d
		}
	}
};
_FOCUS_ImageCropper.prototype.j=function(a){
	if(a.preventDefault){
		a.preventDefault();a.stopPropagation()
	} else {
		a.returnValue=false
	}
};
_FOCUS_ImageCropper.prototype.l=function(a){
	var b=P(a);
	var c=I(this.n);
	b.x=b.x-c.x;
	b.y=b.y-c.y;
	return b
};
function N(a,b){
	var c=0;
	var d=0;
	while(a.offsetParent){
		c+=a.offsetLeft;
		d+=a.offsetTop;
		a=a.offsetParent;
		if(a==b){
			break
		}
	}
	return new n(c,d,window)
};
function h(){}

h.raise=function(a){
	if(typeof Error!="undefined"){
		throw new Error(a||"Assertion Failed");
	}
		else{throw a;
	}
};
h.fail=function(a){
	if(a===undefined) a="Assertion failed";
	if(!(s===undefined))s(a+"\n");
	h.raise(a)
};
h.isTrue=function(a,b){
	if(!a){
		if(b===undefined) b="Assertion failed";
		h.fail(b)
	}
};
h.equals=function(a,b,c){
	if(a!=b){
		if(c===undefined){
			c="AS_Assert.equals failed: <"+a+"> != <"+b+">"
		}
		h.fail(c)
	}
};
h.typeOf=function(a,b,c){
	if(typeof a==b)return;
	if(a||a==""){
		try{
			if(b==h.TYPE_MAP[typeof a]||a instanceof b){return}
		}
		catch(d){}
	}
	if(c===undefined){
		if(typeof b=="function"){
			var f=b.toString().match(/^\s*function\s+([^\s\{]+)/);
			if(f)b=f[1]
		}
		c="AS_Assert.typeOf failed: <"+a+"> not typeof "+b
	}
	h.fail(c)
};
h.TYPE_MAP={
	string:String,number:Number,"boolean":Boolean
};
h.numArgs=function(a,b){
	var c=h.numArgs.caller;
	if(c&&c.arguments.length!=a){
		if(b===undefined){
			b=c.name+" expected "+a+" arguments but received "+c.arguments.length
		}
		h.fail(b)
	}
};

Function.prototype.bind=function(a){
	if(typeof this!="function"){
		throw new Error("Bind must be called as a method of a function object.");
	}
	var b=this;
	var c=Array.prototype.splice.call(arguments,1,arguments.length);
	return function(){
		var d=c.concat();
		for(var f=0;f<arguments.length;f++){
			d.push(arguments[f])
		}
		return b.apply(a,d)
	}
};

function q(a){
	if(a in u){
		return u[a]
	}
	return u[a]=navigator.userAgent.toLowerCase().indexOf(a)!=-1
}
var u={};
function r(){
	return q("msie")&&!window.opera
}
function y(){
	return!r()&&!(q("safari")||q("konqueror"))&&q("mozilla")
}
function ca(a){
	if(typeof Error!="undefined"){
		throw new Error(a||"Assertion Failed");
	} else {
		throw a;
	}
}
function O(a){
	if(a===undefined)a="Assertion failed";
	if(typeof s!="undefined")s(a+"\n");
	ca(a)
}
function x(a,b){
	if(!a){
		if(b===undefined)b="Assertion failed";O(b)
		}
	};
function Q(a,b){
	if(a==null||a.className==null)return false;
	if(a.className==b){
		return true
	}
	var c=a.className.split(" ");
	for(var d=0;d<c.length;d++){
		if(c[d]==b){
			return true
		}
	}
	return false
}
function t(a,b){
	if(Q(a,b))return;
	a.className+=" "+b
}
function E(a){
	return F(a,Y)
}
var Y={s:function(a){return a.document.body.scrollTop},t:function(a){return a.document.documentElement.scrollTop},r:function(a){return a.pageYOffset}};
function D(a){return F(a,X)}
var X={s:function(a){return a.document.body.scrollLeft},t:function(a){return a.document.documentElement.scrollLeft},r:function(a){return a.pageXOffset}};
function F(a,b){
	try{
		if("compatMode" in a.document&&a.document.compatMode=="CSS1Compat"){
			return b.t(a)
		} else if(r()){
			return b.s(a)
		}
	}
	catch(c){}
	return b.r(a)
}
var S=/&/g;
var $=/</g;
var Z=/>/g;
function G(a){
	if(!a)return"";
	return a.replace(S,"&amp;").replace($,"&lt;").replace(Z,"&gt;").replace(ba,"&quot;")
}
var ba=/\"/g;
function U(a){
	return document.getElementById(a)
}
function V(a){
	return document.all[a]
}
var T=document.getElementById?U:V;
function H(a){
	try{
		if(window.parent!=window&&window.parent.log){
			window.parent.log(window.name+"::"+a);
			return
		}
	}
	catch(b){}
	var c=T("log");
	if(c){
		var d="<p class=logentry><span class=logdate>"+new Date+"</span><span class=logmsg>"+a+"</span></p>";
		c.innerHTML=d+c.innerHTML
	} else {
		window.status=a
	}
};
var B=false;
function s(a){
	try{
		throw a;
	}
	catch(b){
		C(b)
	}
}
function C(a,b){
	var c="Javascript exception: "+(b?b:"")+" "+a;
	if(r()){
		c+=" "+a.name+": "+a.message+" ("+a.number+")"
	}
	var d="";
	if(typeof a=="string"){
		d=a+"\n"
	} else {
		for(var f in a){
			try{
				d+=f+": "+a[f]+"\n"
			} catch(e){}
		}
	}
	d+=z(C.caller);
	L(c+"\n"+d,1)
}
var W=/function (\w+)/;
function J(a){
	var b=W.exec(String(a));
	if(b){
		return b[1]
	}
	return""
}
function z(a){
	try{
		if(y()){
			return Error().stack
		}
		if(!a)return"";
		var b="- "+J(a)+"(";
		for(var c=0;c<a.arguments.length;c++){
			if(c>0)b+=", ";
			var d=String(a.arguments[c]);
			if(d.length>40){
				d=d.substr(0,40)+"..."
			}
			b+=d
		}
		b+=")\n";
		b+=z(a.caller);
		return b
	}
	catch(f){
		return"[Cannot get stack trace]: "+f+"\n"
	}
}
var M;
var k=null;
var v=false;
function K(){
	if((k==null||k.closed)&&!v){
		try{
			v=true;
			k=window.open("","debug","width=700,height=500,toolbar=no,resizable=yes,scrollbars=yes,left=16,top=16,screenx=16,screeny=16");
			k.blur();
			k.document.open();
			v=false;
			var a="<font color=#ff0000><b>To turn off this debugging window,hit 'D' inside the main caribou window, then close this window.</b></font><br>"
			;
			A(a)
		}
		catch(b){}
	}
}
function L(a,b){
	if(!B){
		if(typeof H!="undefined"){
			H(G(a))
		}
		return
	}
	try{
		var c=(new Date).getTime()-M;
		var d="["+c+"] "+G(a).replace(/\n/g,"<br>")+"<br>";
		if(b==1){
			d="<font color=#ff0000><b>Error: "+d+"</b></font>";
			k.focus()
		}
		A(d)
	}
	catch(f){}
}
function A(a){
	if(!B){
		return
	}
	try{
		K();
		k.document.write(a);
		k.scrollTo(0,1000000)
	}
	catch(b){}
};
function aa(a){
	var b;
	if(a.ownerDocument&&a.ownerDocument.parentWindow){
		b=a.ownerDocument.parentWindow
	} else {
		b=window
	}
	if(a.ownerDocument&&a.ownerDocument.getBoxObjectFor){
		var c=a.ownerDocument.getBoxObjectFor(a);
		return new m(c.x,c.y,c.width,c.height,b)
	}
	if(a.getBoundingClientRect){
		var d=a.getBoundingClientRect();
		return new m(d.left+D(b),d.top+E(b),d.right-d.left,d.bottom-d.top,b)
	}
	var f=0;
	var e=0;
	for(var g=a;g.offsetParent;g=g.offsetParent){
		f+=g.offsetLeft;
		e+=g.offsetTop
	}
	return new m(f,e,a.offsetWidth,a.offsetHeight,b)
}
function I(a){
	var b=aa(a);
	return new n(b.x,b.y,b.coordinateFrame)
}
function P(a){
	var b=0;
	var c=0;
	if(a.pageX||a.pageY){
		b=a.pageX;c=a.pageY
	} else if(a.clientX||a.clientY){
		var d=a.target?a.target:a.srcElement;
		var f;
		if(d.ownerDocument&&d.ownerDocument.parentWindow){
			f=d.ownerDocument.parentWindow
		} else {
			f=window
		}
		b=a.clientX+D(f);
		c=a.clientY+E(f)
	}
	return new n(b,c,window)
};
var o;
var da;
(function(){
	var a={};
	var b=0;
	function c(e){
		if(!e.v){
			e.v=++b
		}
	return e.v
	}
	function d(e,g,p,j){
		var i=c(e);
		var l=c(p);
		j=!(!j);
		var R=i+"_"+g+"_"+l+"_"+j;
		return R
	}
	o=function(e,g,p,j){
		var i=d(e,g,p,j);
		if(i in a){
			return i
		}
		var l=f.bind(null,i);
		a[i]={listener:p,proxy:l};
		if(e.addEventListener){
			e.addEventListener(g,l,j)
		}
		else if(e.attachEvent){
			e.attachEvent("on"+g,l)
		} else {
			throw new Error("Node {"+e+"} does not support event listeners.");
		}
	return i
	};
	da=function(e,g,p,j){
		var i=d(e,g,p,j);
		if(!(i in a)){
			return false
		}
		var l=a[i].proxy;
		if(e.removeEventListener){
			e.removeEventListener(g,l,j)
		} else if(e.detachEvent){
			e.detachEvent("on"+g,l)
		}
		delete a[i];
		return true
	};
	function f(e){
		var g=Array.prototype.splice.call(arguments,1,arguments.length);
		return a[e].listener.apply(null,g)
	}
})();
function n(a,b,c){
	this.x=a;
	this.y=b;
	this.coordinateFrame=c||null
}
n.prototype.toString=function(){
	return"[P "+this.x+","+this.y+"]"
};
n.prototype.K=function(){
	return new n(this.x,this.y,this.coordinateFrame)
};
function w(a,b){
	this.dx=a;
	this.dy=b
}
w.prototype.toString=function(){
	return"[D "+this.dx+","+this.dy+"]"
};
function m(a,b,c,d,f){
	this.x=a;
	this.y=b;
	this.w=c;
	this.h=d;
	this.coordinateFrame=f||null
}
m.prototype.i=function(a){
	return this.x<=a.x&&a.x<this.x+this.w&&this.y<=a.y&&a.y<this.y+this.h
};
m.prototype.M=function(a){
	var b=function(c,d){
		return new n(c,d,null)
	};
	return this.i(b(a.x,a.y))||this.i(b(a.x+a.w,a.y))||this.i(b(a.x+a.w,a.y+a.h))||this.i(b(a.x,a.y+a.h))||a.i(b(this.x,this.y))||a.i(b(this.x+this.w,this.y))||a.i(b(this.x+this.w,this.y+this.h))||a.i(b(this.x,this.y+this.h))
};
m.prototype.toString=function(){
	return"[R "+this.w+"x"+this.h+"+"+this.x+"+"+this.y+"]"
};
m.prototype.K=function(){
	return new m(this.x,this.y,this.w,this.h,this.coordinateFrame)
};




