(function(a){a.event.special.mousewheel={setup:function(){var b=a.event.special.mousewheel.handler;if(a.browser.mozilla){a(this).bind("mousemove.mousewheel",function(c){a.data(this,"mwcursorposdata",{pageX:c.pageX,pageY:c.pageY,clientX:c.clientX,clientY:c.clientY})})}if(this.addEventListener){this.addEventListener((a.browser.mozilla?"DOMMouseScroll":"mousewheel"),b,false)}else{this.onmousewheel=b}},teardown:function(){var b=a.event.special.mousewheel.handler;a(this).unbind("mousemove.mousewheel");if(this.removeEventListener){this.removeEventListener((a.browser.mozilla?"DOMMouseScroll":"mousewheel"),b,false)}else{this.onmousewheel=function(){}}a.removeData(this,"mwcursorposdata")},handler:function(d){var b=Array.prototype.slice.call(arguments,1);d=a.event.fix(d||window.event);a.extend(d,a.data(this,"mwcursorposdata")||{});var e=0,c=true;if(d.wheelDelta){e=d.wheelDelta/120}if(d.detail){e=-d.detail/3}if(a.browser.opera){e=-d.wheelDelta}d.data=d.data||{};d.type="mousewheel";b.unshift(e);b.unshift(d);return a.event.handle.apply(this,b)}};a.fn.extend({mousewheel:function(b){return b?this.bind("mousewheel",b):this.trigger("mousewheel")},unmousewheel:function(b){return this.unbind("mousewheel",b)}})})(jQuery);(function(b){var a=null;b.fn.autogrow=function(c){return this.each(function(){new b.autogrow(this,c)})};b.autogrow=function(c,d){this.options=d||{};this.dummy=null;this.interval=null;this.line_height=this.options.lineHeight||parseInt(b(c).css("line-height"));this.min_height=this.options.minHeight||parseInt(b(c).css("min-height"));this.max_height=this.options.maxHeight||parseInt(b(c).css("max-height"));this.textarea=b(c);this.onexpand=this.options.onexpand||null;if(this.line_height==NaN){this.line_height=0}if(this.min_height==NaN||this.min_height==0){this.min_height==this.textarea.height()}this.init()};b.autogrow.fn=b.autogrow.prototype={autogrow:"1.2.2"};b.autogrow.fn.extend=b.autogrow.extend=b.extend;b.autogrow.fn.extend({init:function(){var c=this;this.textarea.css({overflow:"hidden",display:"block"});this.textarea.bind("focus",function(){c.startExpand()}).bind("blur",function(){c.stopExpand()});this.checkExpand()},startExpand:function(){var c=this;this.interval=window.setInterval(function(){c.checkExpand()},400)},stopExpand:function(){clearInterval(this.interval)},checkExpand:function(){var c=this;if(this.dummy==null){if($("#"+this.textarea.id+"_dumber").length===0){this.dummy=b("<div></div>").attr("id",this.textarea.id+"_dumber")}else{this.dummy=$("#"+this.textarea.id+"_dumber")}this.dummy.css({"font-size":this.textarea.css("font-size"),"font-family":this.textarea.css("font-family"),width:this.textarea.css("width"),"line-height":this.line_height+"px","overflow-x":"hidden",position:"absolute",top:0,left:-9999}).appendTo("body")}var d=this.textarea.val().replace(/(<|>)/g,"");if($.browser.msie){d=d.replace(/\n/g,"<BR>new")}else{d=d.replace(/\n/g,"<br>new")}if(this.dummy.html()!=d){this.dummy.html(d);if(this.max_height>0&&(this.dummy.height()+this.line_height>this.max_height)){this.textarea.css("overflow-y","auto")}else{this.textarea.css("overflow-y","hidden");if(this.textarea.height()<this.dummy.height()+this.line_height||(this.dummy.height()<this.textarea.height())){this.textarea.animate({height:(this.dummy.height()+this.line_height)+"px"},100,function(){if(c.onexpand){c.onexpand()}})}}}}})})(jQuery);Annotation=function(a){this.id=Annotation.prototype.lastId++;this.x=a.x;this.y=a.y;this.databaseId=a.id||null;this.done=a.done||false;this.checkedOff=false;this.readonly=a.readonly;this.byDesigner=a.byDesigner||false;this.lineColor="rgb(0, 0, 0)";this.lineOutlineColor="rgb(255, 255, 255)";this.showLine=true;this.pointsX=a.pointsX||[];this.pointsY=a.pointsY||[];this.thread=a.thread||[];if(this.databaseId===null&&Annotator.isDesignerAnnotator){this.byDesigner=true}if(Annotator.annotationsListMinimized){Annotator.slideBackAnnotationList()}if(!this.byDesigner){this.pinkify()}if(Annotator.isDesignerAnnotator){this.ajaxCreate=this.ajaxCreateDesigner;this.ajaxRemove=this.ajaxRemoveDesigner}else{this.ajaxCreate=this.ajaxCreateClient;this.ajaxRemove=this.ajaxRemoveClient}this.listEntry=new ListEntry(this);if(this.databaseId===null){this.ajaxCreate()}if(this.done&&this.byDesigner===false){this.listEntry.checkOff();this.showLine=false}};currentPointsX=[];currentPointsY=[];Annotation.prototype.color={};Annotation.prototype.color.black="rgb(0, 0, 0)";Annotation.prototype.color.pink="rgb(255, 37, 37)";Annotation.prototype.color.white="rgb(255, 255, 255)";Annotation.prototype.lastId=0;Annotation.prototype.pinkify=function(){this.lineColor=this.color.pink};Annotation.prototype.draw=function(){if(this.drawLine()){var a=Annotator.mainContext;if(this.pointsX.length>0){a.lineWidth=4;a.strokeStyle=this.lineOutlineColor;a.beginPath();a.moveTo(imageHandler.x+this.pointsX[0]*imageHandler.width,imageHandler.y+this.pointsY[0]*imageHandler.height);for(var b=1;b<this.pointsX.length;b++){a.lineTo(imageHandler.x+this.pointsX[b]*imageHandler.width,imageHandler.y+this.pointsY[b]*imageHandler.height)}a.stroke();a.lineWidth=2;a.strokeStyle=this.lineColor;a.beginPath();a.moveTo(imageHandler.x+this.pointsX[0]*imageHandler.width,imageHandler.y+this.pointsY[0]*imageHandler.height);for(b=1;b<this.pointsX.length;b++){a.lineTo(imageHandler.x+this.pointsX[b]*imageHandler.width,imageHandler.y+this.pointsY[b]*imageHandler.height)}a.stroke()}}};Annotation.prototype.drawLine=function(){if(!this.showLine||Annotator.annotationsListMinimized){return false}var j=Annotator.mainContext;var c=imageHandler.x+this.x*imageHandler.width;var b=imageHandler.y+this.y*imageHandler.height;var a=this.listEntry.getOffset();var i=a.left-Annotator.x;var g=a.top-Annotator.y+10;if(g>Annotator.height||g<0){return false}var h=Math.abs(b-g);var d=h/1;if(c+d>Annotator.width){d=h/2.727272727272727;if(c+d>Annotator.width){d=0}}var f=c+d;var e=g;j.lineJoin="round";j.lineCap="round";j.strokeStyle=this.lineOutlineColor;j.lineWidth=2.5;j.beginPath();j.moveTo(c,b);j.lineTo(f,e);j.lineTo(i,g);j.stroke();j.lineWidth=1;j.strokeStyle=this.lineColor;j.beginPath();j.moveTo(c,b);j.lineTo(f,e);j.lineTo(i,g);j.stroke();return true};Annotation.prototype.ajaxCreateDesigner=function(){var a=this;a.listEntry.comments[0].fetchingIdInProgress=true;ajaxCall({type:"POST",url:"/designer/create_annotation/"+Annotator.currentIteration.id,data:{x:a.x,y:a.y,pointsX:a.pointsX.join(","),pointsY:a.pointsY.join(","),title:Annotator.name,done:false},success:function(c,d){if(c!="NOT FOUND"&&c!="ACCESS DENIED"){var b=c.split(" ");a.databaseId=b[0];a.listEntry.comments[0].databaseId=b[1];a.listEntry.comments[0].fetchingIdInProgress=false}else{showError("Error","Invalid request sent to the server");a.listEntry.comments[0].fetchingIdInProgress=false}},error:function(d,b,c){showError("Ajax error "+d.status,"The server could not process your request.");a.listEntry.comments[0].fetchingIdInProgress=false}})};Annotation.prototype.ajaxCreateClient=function(){var a=this;a.listEntry.comments[0].fetchingIdInProgress=true;ajaxCall({type:"POST",url:"/client/create_annotation/"+Annotator.projectCode,data:{x:a.x,y:a.y,pointsX:a.pointsX.join(","),pointsY:a.pointsY.join(","),title:Annotator.name,iteration_id:Annotator.currentIteration.id,done:false},success:function(c,d){if(c!="NOT FOUND"&&c!="ACCESS DENIED"){var b=c.split(" ");a.databaseId=b[0];a.listEntry.comments[0].databaseId=b[1];a.listEntry.comments[0].fetchingIdInProgress=false}else{showError("Error","Invalid request sent to the server");a.listEntry.comments[0].fetchingIdInProgress=false}},error:function(d,b,c){showError("Ajax error "+d.status,"The server could not process your request.");a.listEntry.comments[0].fetchingIdInProgress=false}})};Annotation.prototype.ajaxRemoveClient=function(){var a=this;ajaxCall({type:"POST",url:"/client/delete_annotation/"+Annotator.projectCode,data:{id:a.databaseId},success:function(b,c){if(b.toLowerCase()!="done"){showError("Error","Invalid request sent to the server")}},error:function(d,b,c){showError("Ajax error "+d.status,"The server could not process your request.")}})};Annotation.prototype.ajaxRemoveDesigner=function(){var a=this;ajaxCall({type:"POST",url:"/designer/delete_annotation/"+a.databaseId,data:{},success:function(b,c){if(b.toLowerCase()!="done"){showError("Error","Invalid request sent to the server")}},error:function(d,b,c){showError("Ajax error "+d.status,"The server could not process your request.")}})};Annotation.prototype.remove=function(a){this.listEntry.remove(a);delete this.listEntry;var b=0;while(Annotator.annotations[b].id!==this.id){b++}delete Annotator.annotations[b];Annotator.annotations.splice(b,1);Annotator.draw()};Annotation.prototype.removeAndDelete=function(a){var b=this;b.ajaxRemove();b.remove(a)};Annotation.prototype.getTitle=function(){return this.listEntry.getTitle()};Annotation.prototype.getComment=function(){return this.listEntry.getComment()};Annotation.prototype.toggleComment=function(){this.listEntry.toggleComment()};Annotation.prototype.getCoordinates=function(){return{x:this.x,y:this.y}};Annotation.prototype.getPoints=function(){return{x:this.pointsX,y:this.pointsY}};Annotation.prototype.checkOff=function(){var a=this;if(a.currentlyUpdating){return}a.checkedOff=true;a.showLine=false;a.listEntry.checkOff();drawLine=a.drawLineToList;currentlyUpdating=true;Annotator.draw();ajaxCall({type:"POST",url:"/designer/set_annotation_status/"+a.databaseId,data:{done:true},success:function(b,c){if(b!=="DONE"){showError("Error","Invalid request sent to the server");a.checkedOff=false;a.showLine=true;a.listEntry.uncheckOff();a.draw()}a.currentlyUpdating=false},error:function(b){showError("Ajax error "+b.status,"The server could not process your request.");a.checkedOff=false;a.showLine=true;a.listEntry.uncheckOff();a.currentlyUpdating=false;a.draw()}})};Annotation.prototype.uncheckOff=function(){var a=this;if(this.currentlyUpdating){return}a.checkedOff=false;a.listEntry.uncheckOff();a.showLine=true;Annotator.draw();a.currentlyUpdating=true;ajaxCall({type:"POST",url:"/designer/set_annotation_status/"+a.databaseId,data:{done:false},success:function(b,c){if(b!=="DONE"){showError("Error","Invalid request sent to the server");a.checkedOff=true;a.line.remove();a.listEntry.checkOff()}a.currentlyUpdating=false},error:function(b){showError("Ajax error "+b.status,"The server could not process your request.");a.checkedOff=true;a.line.remove();a.listEntry.checkOff();a.currentlyUpdating=false}})};zoom=function(){var b=0;var c=[];var a=0;var g=0;var e=0.1;var f=0;function d(){if(imageHandler.origWidth===0||imageHandler.origHeight===0){return null}var m=Annotator.width;var l=Annotator.height;var k=m/l;var j=imageHandler.origWidth/imageHandler.origHeight;var i,h;if(j>k){i=m;h=m*imageHandler.origHeight/imageHandler.origWidth}else{h=l;i=l*imageHandler.origWidth/imageHandler.origHeight}return({width:i,height:h})}return{zoomDrag:false,adjustMinMaxZoom:function(i,j){a=Math.max(Math.min(j/3,Annotator.height-200),1);g=Math.max(j*3,Annotator.height+200)},isResizeAllowed:function(i,h){return(h>=a&&h<=g)},moveZoomCursor:function(){$("#zoomCursor").css("top",b-f*b-3+"px")},zoomIn:function(){this.zoomAboutPoint(1+e);Annotator.updateAnnotations()},zoomOut:function(){this.zoomAboutPoint(1-e);Annotator.updateAnnotations()},resizeScroller:function(h){$("#zoomScroller").css("top",Annotator.$mainCanvas.css("top"));b=h;$("#zoomArea").css("height",h+"px");var i=Math.floor(h/162)+1;var j=c.length;while(i>j){var k=$("<div class='zoomAreaDiv'><img class='zoomAreaImg' src='/media/images/annotator/zoomcontrols.png' /></div>");c.push(k);$("#zoomArea").append(k);j++}while(i<j){c[c.length-1].remove();c.pop();j--}b-=6;this.adjustMinMaxZoom(imageHandler.origWidth,imageHandler.origHeight);if(a!==0&&g!==0){this.updateZoomCursor();this.updateZoomMarkers()}},applyZoom:function(){var h=a+f*(g-a);var i=imageHandler.height;this.zoomAboutPoint(h/i);Annotator.draw()},updateZoomCursor:function(){var h=imageHandler.height;f=(h-a)/(g-a);this.moveZoomCursor()},updateZoomMarkers:function(){var i=d();if(i!==null){var h=(imageHandler.origHeight-a)/(g-a);$("#zoomOriginalDiv").css("top",b-h*b-3+"px");var k=i.height;var j=(k-a)/(g-a);$("#zoomFitDiv").css("top",b-j*b-3+"px")}},zoomAboutPoint:function(l,n,k){var j=imageHandler.width;var m=imageHandler.height;if(!n||!k||n<0||k<0||n>j||k>m){n=0.5*j;k=0.5*m}var i=(l-1)*n;var h=(l-1)*k;if(imageHandler.resize(j*l,m*l)){imageHandler.moveImage(-i,-h)}},zoomOriginal:function(){if(imageHandler.origHeight===0||imageHandler.origWidth===0){return}imageHandler.setPosition((Annotator.width-imageHandler.origWidth)/2,(Annotator.height-imageHandler.origHeight)/2);imageHandler.resize(imageHandler.origWidth,imageHandler.origHeight);Annotator.draw()},zoomInitial:function(){if(imageHandler.origHeight>Annotator.height){this.zoomToFit()}else{this.zoomOriginal()}},zoomToFit:function(){var h=d();if(h!==null){imageHandler.setPosition((Annotator.width-h.width)/2,(Annotator.height-h.height)/2);imageHandler.resize(h.width,h.height);Annotator.draw()}},zoomwheelCallback:function(h,l){var j=1;if(l>0){j+=e}else{j-=e}var k=h.pageX-imageHandler.x-Annotator.x;var i=h.pageY-imageHandler.y-Annotator.y;zoom.zoomAboutPoint(j,k,i);zoom.updateZoomCursor();Annotator.draw();return false},mousemoveCallback:function(i){var h=1-(i.pageY-$("#zoomArea").offset().top)/$("#zoomArea").height();if(h>=0&&h<1){f=h;this.moveZoomCursor();this.applyZoom()}},init:function(){var h=this;$("#zoomArea").click(function(i){f=1-(i.pageY-$("#zoomArea").offset().top)/$("#zoomArea").height();h.moveZoomCursor();h.applyZoom();return false});$("#zoomArea").mousedown(function(i){h.zoomDrag=true;return false});$("#zoom_cursor").click(function(i){h.applyZoom();return false});$("#zoom_cursor").mousedown(function(i){h.zoomDrag=true;return false});$("#zoomFitDiv").click(function(){h.zoomToFit();return false});$("#zoomOriginalDiv").click(function(){h.zoomOriginal();return false});$("#zoomInButtonDiv").click(function(){h.zoomIn()});$("#zoomOutButtonDiv").click(function(){h.zoomOut()});$("#zoomArea").mousemove(Annotator.callbacks.mousemove);$("#zoomArea").mouseup(Annotator.callbacks.mouseup)}}}();if(!this.JSON){JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z"};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}})();var Button=function(){this.name="";this.id="";this.selected=false;this.enabled=true;this.activate=function(){if(!this.enabled){return false}$(this.id).addClass("selected");this.selected=true;if(this.customAction){this.customAction()}};this.deactivate=function(){this.selected=false;$(this.id).removeClass("selected")};this.disable=function(){this.enabled=false;$(this.id).removeClass("selected").addClass("disabled")};this.enable=function(){this.enabled=true;$(this.id).removeClass("disabled")};this.action=function(){if(this.enabled){buttons.deselectAll();this.activate()}};this.assign=function(){var a=this;$(a.id).click(function(){a.action()})}};buttons=function(){var a=new Button();a.name="annotation";a.id="#newCommentButton";a.customAction=function(){Annotator.$mainCanvas.css("cursor","auto")};var c=new Button();c.name="pencil";c.id="#pencilButton";c.customAction=function(){Annotator.$mainCanvas.css("cursor","auto")};var b=new Button();b.name="hand";b.id="#handButton";b.customAction=function(){if(Annotator.$mainCanvas){Annotator.$mainCanvas.css("cursor","url(/media/openhand.cur), default")}};return{handButton:b,annotationButton:a,pencilButton:c,deselectAll:function(){this.handButton.deactivate();this.pencilButton.deactivate();this.annotationButton.deactivate()},disable:function(){this.annotationButton.disable();this.pencilButton.disable()},enable:function(){this.annotationButton.enable();this.pencilButton.enable()},assign:function(){this.handButton.assign();this.pencilButton.assign();this.annotationButton.assign()}}}();iterationLoader=function(){var a=true;return{iterations:[],selectedIteration:-1,lastIterationId:-1,annotationsDrawn:false,loadImage:function(b){a=false;this.annotationsDrawn=false;imageHandler.loadImage(b)},setAnnotatorTitleText:function(c){var b=c.formattedDate.substring(0,c.formattedDate.lastIndexOf(" "));b="("+c.formattedDate+")";$("#annotatorHdrTitleDate").html(b)},loadIterationFromJSON:function(e,d,c){var b=this;Annotator.deleteAllAnnotations();Annotator.importFromJSON(d,c);b.setAnnotatorTitleText(e);Annotator.currentIteration=e;zoom.zoomInitial();buttons.handButton.action();a=true;initializeScrollPane();setTimeout(function(){b.annotationsDrawn=true;reinitializeScrollPane()},ajaxRetryTime)},fixVersionNumbers:function(){var b=0;for(var c=0;c<this.iterations.length;c++){if(this.iterations[c].by_designer===0){b++}this.iterations[c].version-=b}},parseIterationsFromJSON:function(b){this.iterations=JSON.parse(b);this.fixVersionNumbers()},hasIterationFinishedLoading:function(){return(imageHandler.imageLoaded&&a)}}};designerIterationLoader=function(){var a=iterationLoader();a.loadIteration=function(c,b){this.loadImage("/media/user_images/"+Annotator.projectId+"/"+c.imageFilename);if(typeof(b)==="undefined"){b=true}ajaxCall({type:"GET",url:"/designer/get_annotations/"+c.id,success:function(d,g){if(d!="NOT FOUND"&&d!="ACCESS DENIED"){var h=null;try{h=JSON.parse(d)}catch(f){}a.loadIterationFromJSON(c,h,b)}else{showError("Error","Invalid request sent to the server")}},error:function(){showError("Connection error","Could not connect to server, please check your internet connection.")}})};a.selectIteration=function(b){var c=this.iterations[b];if(c.id==this.selectedIteration||!this.hasIterationFinishedLoading()){return}if(c.id==this.lastIterationId){buttons.enable();this.loadIteration(c,false)}else{buttons.disable();buttons.handButton.action();this.loadIteration(c,true)}this.selectedIteration=c.id};return a};clientIterationLoader=function(){var a=iterationLoader();a.loadIteration=function(d,b,c){this.loadImage("/media/user_images/"+Annotator.projectId+"/"+d.imageFilename);ajaxCall({type:"GET",url:"/client/get_annotations/"+b+"/"+d.id,success:function(f,h){if(f!="NOT FOUND"&&f!="ACCESS DENIED"){var i=null;try{i=JSON.parse(f)}catch(g){}a.loadIterationFromJSON(d,i,c)}else{showError("Error","Invalid request sent to the server")}},error:function(){showError("Connection error","Could not connect to server, please check your internet connection.")}})};a.lastIterationAnnotObj="";a.loadIterationCurrent=function(d,c,b){this.loadImage("/media/user_images/"+Annotator.projectId+"/"+d.imageFilename);this.loadIterationFromJSON(d,c,b)};a.selectIteration=function(b){var c=this.iterations[b];if(c.id==this.selectedIteration||!this.hasIterationFinishedLoading()){return}if(c.id==this.lastIterationId){buttons.enable();this.loadIteration(c,projectCode,false)}else{buttons.disable();buttons.handButton.action();this.loadIteration(c,projectCode,true)}this.selectedIteration=c.id};return a};Comment=function(e){var b=this;this.annotation=e.listentry.annotation;this.listentry=e.listentry;this.options=e;this.properties=e.listentry.annotation.properties;this.id=Comment.prototype.lastId++;if(typeof(e.id)==="undefined"){this.databaseId=null}else{this.databaseId=e.id}this.fetchingIdInProgress=false;this.title=e.title;this.comment=e.comment;this.commentDiv=$("<div class='comment' id=\"comment"+this.id+'"></div>').hide();this.initTitleBox();this.initCommentBox();e.listentry.annotationListEntry.append(this.commentDiv);var f=$("#commentBoxTitle_"+this.id);var c=$("#commentBoxTextArea_"+this.id);var d=$("#commentReplyButton_"+this.id);if(Annotator.isDesignerAnnotator){this.ajaxCreate=this.ajaxCreateDesigner;this.ajaxRemove=this.ajaxRemoveDesigner;this.ajaxUpdate=this.ajaxUpdateDesigner}else{this.ajaxCreate=this.ajaxCreateClient;this.ajaxRemove=this.ajaxRemoveClient;this.ajaxUpdate=this.ajaxUpdateClient}if(!this.options.readonly){var a=$("#commentBoxTextArea_"+this.id);if($.browser.opera){setTimeout(function(){a.autogrow(b.autoGrowOptions)},200)}else{a.autogrow(b.autoGrowOptions)}var g;a.focus(function(){if(a.val()==b.defaultComment){a.select()}g=a.val()}).blur(function(){if(a.val()!==g){b.comment=a.val();b.ajaxUpdate()}})}else{$(".commentTitleUncheckedBox",b.titleInput).click(function(){if(Annotator.isDesignerAnnotator){b.annotation.checkOff()}return false});$(".commentTitleCheckedBox",b.titleInput).click(function(){if(Annotator.isDesignerAnnotator){b.annotation.uncheckOff()}return false})}this.commentDiv.show();if(this.databaseId===null){setTimeout(function(){c.focus().select()},200)}d.click(function(){b.newReply()});if(this.title!==Annotator.designerName){this.pinkify()}if(!Annotator.isDesignerAnnotator){this.hideCheckboxes()}else{if(!((this.options.precedence===0)&&(this.title!==Annotator.name))){this.hideCheckboxes()}}if(e.thread){this.hideRightCollapseButtons();this.hideLeftCollapseButtons();this.threadify();this.toggleComment()}};Comment.prototype.lastId=0;Comment.prototype.defaultTitle="Enter title...";Comment.prototype.defaultComment="Leave comment here...";Comment.prototype.autoGrowOptions={minHeight:0,lineHeight:18,onexpand:function(){if(loader.hasIterationFinishedLoading()){var b=this.selectionStart;Annotator.draw();if($.browser.msie&&$.browser.version<8){$(".commentBox").css("top","1px").css("top","0px")}try{$(this).focus()}catch(a){}this.selectionStart=b;this.selectionEnd=b}}};Comment.prototype.ie7fix=function(){if($.browser.msie&&$.browser.version<8){$(".listentry").hide().show()}};Comment.prototype.hideRightCollapseButtons=function(){$(".commentTitleCollapseButton, .commentTitleUncollapseButton",this.titleInput).hide()};Comment.prototype.hideLeftCollapseButtons=function(){$(".commentTitleCollapseButtonLeft, .commentTitleUncollapseButtonLeft",this.titleInput).hide()};Comment.prototype.getTitle=function(){return $("#commentBoxTitle_"+this.id).attr("value")};Comment.prototype.setTitle=function(a){return $("#commentBoxTitle_"+this.id).attr("value",a)};Comment.prototype.getOffset=function(){return this.commentDiv.offset()};Comment.prototype.getComment=function(){if($("#commentBoxTextArea_"+this.id).length>0){return $("#commentBoxTextArea_"+this.id).attr("value")}else{return $(".commentCommentBoxTextDiv","#commentBox_"+this.id).html()}};Comment.prototype.setComment=function(a){if($("#commentBoxTextArea_"+this.id).length>0){$("#commentBoxTextArea_"+this.id).attr("value",a)}else{$(".commentCommentBoxTextDiv","#commentBox_"+this.id).html(a)}};Comment.prototype.remove=function(){var a=this;if(a.options.precedence===0&&a.listentry.comments.length>1){showThreadRemovePrompt(function(){a.ajaxRemove()},function(){a.annotation.removeAndDelete()})}else{a.ajaxRemove()}};Comment.prototype.listentryRemove=function(a){var b=this;if(a&&a=="immediately"){b.commentDiv.remove()}else{b.commentDiv.fadeOut("normal",function(){b.commentDiv.remove();reinitializeScrollPane();Annotator.draw()})}};Comment.prototype.toggleComment=function(b){var a=this;if(a.options.thread){a.threadItemToggle(b);return}if(this.commentBox.is(":hidden")||(b=="open")){if(!$("#uncollapseIconLeft_"+this.id).is(":hidden")){$("#uncollapseIconLeft_"+this.id).hide();$("#collapseIconLeft_"+this.id).show()}else{$("#uncollapseIcon_"+this.id).hide();$("#collapseIcon_"+this.id).show()}$("#commentTitle_"+a.id).html(this.title);this.commentBox.slideDown("fast",function(){Annotator.draw();Comment.prototype.ie7fix()});return}if(this.commentBox.is(":visible")||(b=="closed")){if(!$("#collapseIconLeft_"+this.id).is(":hidden")){$("#collapseIconLeft_"+this.id).hide();$("#uncollapseIconLeft_"+this.id).show()}else{$("#collapseIcon_"+this.id).hide();$("#uncollapseIcon_"+this.id).show()}$("#commentTitle_"+a.id).html(this.title+': <span style="font-weight: normal">'+a.getComment()+"</span>");this.commentBox.slideUp("fast",function(){Annotator.draw()})}};Comment.prototype.threadItemToggle=function(b){if(this.commentBox.is(":hidden")||(b=="open")){this.commentBox.slideDown("normal",function(){Annotator.draw();Comment.prototype.ie7fix()});$(".small",this.titleInput).removeClass("small");$(".commentTitleCollapseButtonLeft",this.titleInput).show();if(!this.options.readonly){$(".commentTitleRemoveButton",this.titleInput).show()}this.titleInput.removeClass("small");this.commentDiv.addClass("thread");$(".commentTitleTextDiv",this.titleInput).html(this.title);return}if(this.commentBox.is(":visible")||(b=="closed")){this.commentBox.slideUp("normal",function(){Annotator.draw()});var a=".commentTitleLeftCorner, .commentTitleRightCorner, .commentTitleBody,";a+=".commentTitleTextDiv, .commentTitleUncheckedBox, .commentTitleCheckedBox";$(a,this.titleInput).addClass("small");$(".commentTitleCollapseButtonLeft , .commentTitleRemoveButton",this.titleInput).hide();this.titleInput.addClass("small");this.commentDiv.removeClass("thread");$(".commentTitleTextDiv",this.titleInput).html(this.title+": "+this.comment)}};Comment.prototype.placeInAnnotationsList=function(){$annotContainer=$("#annotationsContainer");var d=-1;var c=10000;for(var a=0;a<Annotator.annotations.length;a++){var b=Annotator.annotations[a].y-this.annotation.y;if(b>0&&b<c){d=Annotator.annotations[a].id;c=b}}if(d!=-1){this.commentDiv.insertBefore("#a"+d+"_entry").hide()}else{this.commentDiv.appendTo("#annotationsContainer").hide()}};Comment.prototype.pinkify=function(){$(".commentTitleBody, .commentTitleLeftCorner, .commentTitleRightCorner, .commentTitleTextDiv",this.titleInput).addClass("pink");$(".commentCommentBoxTextarea",this.commentBox).addClass("pink");$(".commentTitleBody",this.titleInput).addClass("commentTitlePink");$(".commentTitleLeftCorner",this.titleInput).addClass("commentTitleLeftCornerPink");$(".commentTitleRightCorner",this.titleInput).addClass("commentTitleRightCornerPink");$(".commentCommentBox",this.commentBox).addClass("commentCommentPink");$(".commentCommentBoxTextarea",this.commentBox).addClass("commentCommentPink");$(".commentCommentBoxLeftCorner",this.commentBox).addClass("commentCommentBoxLeftCornerPink");$(".commentCommentBoxRightCorner",this.commentBox).addClass("commentCommentBoxRightCornerPink");$(".commentCommentBoxTextDiv",this.commentBox).addClass("commentCommentPink");$(".commentCommentBoxBottomBorder",this.commentBox).addClass("pink")};Comment.prototype.unPinkify=function(){$(".commentTitleBody",this.titleInput).removeClass("commentTitlePink");$(".commentTitleLeftCorner",this.titleInput).removeClass("commentTitleLeftCornerPink");$(".commentTitleRightCorner",this.titleInput).removeClass("commentTitleRightCornerPink");this.commentBox.removeClass("commentCommentPink");$(".commentCommentBoxTextarea",this.commentBox).removeClass("commentCommentPink");$(".commentCommentBoxLeftCorner",this.commentBox).removeClass("commentCommentBoxLeftCornerPink");$(".commentCommentBoxRightCorner",this.commentBox).removeClass("commentCommentBoxRightCornerPink");$(".commentCommentBoxTextDiv",this.commentBox).removeClass("commentCommentPink")};Comment.prototype.hideCheckboxes=function(){$(".commentTitleUncheckedBox",this.titleInput).hide();$(".commentTitleCheckedBox",this.titleInput).hide()};Comment.prototype.newReply=function(){var a=this;a.threadify();a.threadItemToggle();var b=new Comment({listentry:a.options.listentry,thread:false,readonly:false,title:Annotator.name,comment:a.defaultComment});a.options.listentry.comments.push(b);Comment.prototype.ie7fix()};Comment.prototype.ajaxCreateDesigner=function(b){var a=this;a.fetchingIdInProgress=true;ajaxCall({type:"POST",url:"/designer/create_annotation_comment/"+a.options.listentry.annotation.databaseId,data:{title:a.title,comment:a.comment},success:function(c){a.databaseId=c;a.fetchingIdInProgress=false},error:function(e,c,d){showError("Ajax error "+e.status,"The server could not process your request.");a.fetchingIdInProgress=false}})};Comment.prototype.ajaxCreateClient=function(b){var a=this;a.fetchingIdInProgress=true;ajaxCall({type:"POST",url:"/client/create_annotation_comment/"+Annotator.projectCode,data:{id:a.options.listentry.annotation.databaseId,title:a.title,comment:a.comment},success:function(c){a.databaseId=c;a.fetchingIdInProgress=false},error:function(e,c,d){showError("Ajax error "+e.status,"The server could not process your request.");a.fetchingIdInProgress=false}})};Comment.prototype.ajaxRemoveDesigner=function(){var a=this;if(a.fetchingIdInProgress){setTimeout(function(){a.ajaxRemoveDesigner()},ajaxRetryTime);return}a.options.listentry.removeComment(a);if(a.databaseId===null||a.listentry.comments.length===0){return}ajaxCall({type:"POST",url:"/designer/delete_annotation_comment/"+a.databaseId,data:{},success:function(b,c){if(b.toLowerCase()!="done"){showError("Error","Invalid request sent to the server")}},error:function(d,b,c){showError("Ajax error "+d.status,"The server could not process your request.")}})};Comment.prototype.ajaxRemoveClient=function(){var a=this;if(a.fetchingIdInProgress){setTimeout(function(){a.ajaxRemoveClient()},ajaxRetryTime);return}a.options.listentry.removeComment(a);if(a.databaseId===null||a.listentry.comments.length===0){return}ajaxCall({type:"POST",url:"/client/delete_annotation_comment/"+Annotator.projectCode,data:{id:a.databaseId},success:function(b,c){if(b.toLowerCase()!="done"){showError("Error","Invalid request sent to the server")}},error:function(d,b,c){showError("Ajax error "+d.status,"The server could not process your request.")}})};Comment.prototype.ajaxUpdateDesigner=function(){var a=this;if(a.fetchingIdInProgress){setTimeout(function(){a.ajaxUpdateDesigner()},ajaxRetryTime);return}if(a.databaseId===null){a.ajaxCreate();return}var b=$("#commentBoxTextArea_"+a.id);var c=a.comment;a.comment=b.val();ajaxCall({type:"POST",url:"/designer/update_annotation_comment/"+a.databaseId,data:{id:a.databaseId,title:a.title,comment:a.comment},success:function(d,e){if(d.toLowerCase()!="done"){a.comment=c;showError("Error","Invalid request sent to the server")}},error:function(f,d,e){a.comment=c;showError("Ajax error "+f.status,"The server could not process your request.")}})};Comment.prototype.ajaxUpdateClient=function(){var a=this;if(a.fetchingIdInProgress){setTimeout(function(){a.ajaxUpdateClient()},ajaxRetryTime);return}if(a.databaseId===null){a.ajaxCreate();return}var b=$("#commentBoxTextArea_"+a.id);var c=a.comment;a.comment=b.val();$.ajax({type:"POST",url:"/client/update_annotation_comment/"+Annotator.projectCode,data:{id:a.databaseId,title:a.title,comment:a.comment},success:function(d,e){if(d.toLowerCase()!="done"){a.comment=c;showError("Error","Invalid request sent to the server")}},error:function(f,d,e){a.comment=c;showError("Ajax error "+f.status,"The server could not process your request.")}})};Comment.prototype.initTitleBox=function(){var b="";var a=this;b+="<div class='commentTitle'>";b+="   <div class='commentTitleLeftCorner emptydiv'>&nbsp</div>";b+="   <div class='commentTitleRightCorner emptydiv'>&nbsp</div>";b+="   <div class='commentTitleBody'>";b+="       <div class='commentTitleRemoveButton button emptydiv'>&nbsp;</div>";b+="       <div class='commentTitleCollapseButtonLeft button emptydiv' id='collapseIconLeft_"+this.id+"'>&nbsp;</div>";b+="       <div class='commentTitleUncollapseButtonLeft button emptydiv' style='display: none' id='uncollapseIconLeft_"+this.id+"'>&nbsp;</div>";b+="       <div class='commentTitleUncheckedBox button emptydiv' id='uncheckedBox_"+this.id+"'>&nbsp;</div>";b+="       <div class='commentTitleCheckedBox button emptydiv' style='display: none;' id='checkedBox_"+this.id+"'>&nbsp;</div>";b+="       <div class='commentTitleCollapseButton button emptydiv' id='collapseIcon_"+this.id+"'>&nbsp;</div>";b+="       <div class='commentTitleUncollapseButton button emptydiv' style='display: none' id='uncollapseIcon_"+this.id+"'>&nbsp;</div>";b+="       <div style='float: left;'>&nbsp;</div>";b+="       <div class='commentTitleTextDiv' id='commentTitle_"+this.id+"'>";b+=this.title;b+="       </div>";b+="   </div>";b+="</div>";this.titleInput=$(b);if(!this.options.readonly){$(".commentTitleUncheckedBox, .commentTitleCheckedBox, .commentTitleCollapseButton, .commentTitleUncollapseButton",this.titleInput).hide();$(".commentTitleRemoveButton",this.titleInput).click(function(){a.remove()})}else{$(".commentTitleRemoveButton, .commentTitleCollapseButtonLeft, .commentTitleUncollapseButtonLeft",this.titleInput).hide()}$(".commentTitleCollapseButtonLeft, .commentTitleUncollapseButtonLeft, .commentTitleCollapseButton, .commentTitleUncollapseButton",this.titleInput).click(function(){a.toggleComment()});this.commentDiv.append(this.titleInput)};Comment.prototype.initCommentBox=function(){var a="";a+="<div id='commentBox_"+this.id+"' class='commentBox'>";a+="<div class='commentCommentBox'>";a+="<div id='commentReplyButton_"+this.id+"' class='commentReplyButton'>reply</div>";if(!this.options.readonly){a+="     <textarea id='commentBoxTextArea_"+this.id+"' class='commentCommentBoxTextarea' name='comments'>"+this.comment+"</textarea>"}else{a+="     <div class='commentCommentBoxTextDiv'>"+this.comment.replace(/\n/g,"<br/>")+"</div>"}a+="</div>";a+="    <div class='commentCommentBoxBottom'>";a+="        <div class='commentCommentBoxLeftCorner'></div>";a+="        <div class='commentCommentBoxRightCorner'></div>";a+="        <div class='commentCommentBoxBottomBorder'></div>";a+="    </div>";a+="</div>";this.commentBox=$(a);this.commentDiv.append(this.commentBox)};Comment.prototype.threadify=function(){var a=this;var b=".commentTitleLeftCorner, .commentTitleRightCorner, .commentTitleBody,";b+=".commentTitleTextDiv, .commentTitleCollapseButton, ";b+=".commentTitleCheckedBox, .commentTitleUncheckedBox,";b+=".commentCommentBox, .commentCommentBoxTextarea, .commentCommentBoxLeftCorner, .commentCommentBoxRightCorner,";$(b,this.titleInput).addClass("thread");this.titleInput.addClass("thread");this.titleInput.unbind("click");this.titleInput.click(function(){a.toggleComment("closed")});b=".commentReplyButton";$(b,this.commentBox).addClass("thread");this.options.thread=true};Comment.prototype.unThreadify=function(){var a=this;$(".thread",this.titleInput).removeClass("thread");this.titleInput.removeClass("thread");if(a.title!==Annotator.name){$(".commentTitleCollapseButton",this.titleInput).hide()}this.titleInput.unbind("click");elements=".commentReplyButton";$(elements,this.commentBox).removeClass("thread");this.toggleComment("open");this.options.thread=false};ListEntry=function(a){var c=this;this.id=a.id;this.annotation=a;this.annotationListEntry=$("<div class='listentry' id=\"a"+this.id+'_entry"></div>');this.thread=a.thread||[];this.comments=[];this.placeInAnnotationsList();if(this.thread.length>0){for(var d=0;d<this.thread.length;d++){var b=Annotator.name!==this.thread[d].title;this.comments.push(new Comment({listentry:c,thread:(d!==this.thread.length-1),readonly:b,id:this.thread[d].id,title:this.thread[d].title,comment:this.thread[d].comment,precedence:d}))}}else{this.comments.push(new Comment({listentry:c,thread:false,readonly:false,title:Annotator.name,comment:Comment.prototype.defaultComment,precedence:0}))}this.annotationListEntry.show()};ListEntry.prototype.autoGrowOptions={minHeight:0,lineHeight:18,onexpand:function(){var b=this.selectionStart;Annotator.draw();reinitializeScrollPane();try{this.focus()}catch(a){}this.selectionStart=b;this.selectionEnd=b}};ListEntry.prototype.getTitle=function(){return $("#commentBoxTitle_"+this.id).attr("value")};ListEntry.prototype.setTitle=function(a){return $("#commentBoxTitle_"+this.id).attr("value",a)};ListEntry.prototype.getOffset=function(){return this.annotationListEntry.offset()};ListEntry.prototype.getComment=function(){if($("#commentBoxTextArea_"+this.id).length>0){return $("#commentBoxTextArea_"+this.id).attr("value")}else{return $(".listentryCommentBoxTextDiv","#commentBox_"+this.id).html()}};ListEntry.prototype.setComment=function(a){if($("#commentBoxTextArea_"+this.id).length>0){$("#commentBoxTextArea_"+this.id).attr("value",a)}else{$(".listentryCommentBoxTextDiv","#commentBox_"+this.id).html(a)}};ListEntry.prototype.remove=function(a){var b=this;if(a&&a=="immediately"){b.annotationListEntry.remove()}else{b.annotationListEntry.fadeOut("normal",function(){b.annotationListEntry.remove();reinitializeScrollPane();Annotator.draw()})}};ListEntry.prototype.removeComment=function(b){for(var a=0;a<this.comments.length;a++){if(this.comments[a]===b){b.commentDiv.remove();this.comments.splice(a,1);Annotator.draw();break}}if(a>0&&a===this.comments.length){this.comments[a-1].unThreadify()}for((a>0)?(a=a-1):(a=0);a<this.comments.length;a++){this.comments[a].options.precedence=a}if(this.comments.length===0){this.annotation.removeAndDelete()}Comment.prototype.ie7fix()};ListEntry.prototype.placeInAnnotationsList=function(){$annotContainer=$("#annotationsContainer");var d=-1;var c=10000;for(var a=0;a<Annotator.annotations.length;a++){var b=Annotator.annotations[a].y-this.annotation.y;if(b>0&&b<c){d=Annotator.annotations[a].id;c=b}}if(d!=-1){this.annotationListEntry.insertBefore("#a"+d+"_entry").hide()}else{this.annotationListEntry.appendTo("#annotationsContainer").hide()}};ListEntry.prototype.checkOff=function(){$("#uncheckedBox_"+this.comments[0].id).hide();$("#checkedBox_"+this.comments[0].id).show();$("#annotTitle_"+this.comments[0].id).addClass("checked")};ListEntry.prototype.uncheckOff=function(){$("#checkedBox_"+this.comments[0].id).hide();$("#uncheckedBox_"+this.comments[0].id).show();$("#annotTitle_"+this.comments[0].id).removeClass("checked")};imageHandler=function(){var a=0;var d=0;var c=function(){var e;if($("#loadingIcon").length>0){e=$("#loadingIcon")}else{e=$("<div></div>").attr("id","loadingIcon").css({position:"absolute",left:"50%",top:"50%",width:"16px",height:"16px","background-image":'url("/media/ajax-loader.gif")',"background-repeat":"no-repeat","z-index":8}).appendTo("#annotatorCanvas")}};var b=function(){if($("#loadingIcon").length>0){$("#loadingIcon").remove()}};return{origHeight:0,origWidth:0,aspectRatio:0,height:0,width:0,x:0,y:0,imageLoaded:false,loadImage:function(f){this.imageLoaded=false;c();var e=this;delete Annotator.img;Annotator.img=new Image();Annotator.img.src=f;$(Annotator.img).load(function(){b();e.imageLoaded=true;e.setOriginalDimensions(this.width,this.height);zoom.updateZoomMarkers();zoom.zoomInitial();Annotator.draw()})},moveImage:function(e,f){this.x+=e;this.y+=f},setPosition:function(e,f){this.x=e;this.y=f},setOriginalDimensions:function(e,f){this.origWidth=e;this.origHeight=f;this.aspectRatio=this.origWidth/this.origHeight;zoom.adjustMinMaxZoom(this.origWidth,this.origHeight)},getRelativeCoords:function(f,e){return{x:(f-Annotator.x-this.x)/this.width,y:(e-Annotator.y-this.y)/this.height}},resize:function(f,e){if(!zoom.isResizeAllowed(f,e)){return false}this.width=f;this.height=e;zoom.updateZoomCursor();return true}}}();callbacks=function(a){return{click:function(c){if(buttons.annotationButton.selected){var b=imageHandler.getRelativeCoords(c.pageX,c.pageY);if(b.x>=0&&b.x<=1&&b.y>=0&&b.y<=1&&c.pageX>=Annotator.x&&c.pageX<=Annotator.x+Annotator.width&&c.pageY>=Annotator.y&&c.pageY<=Annotator.y+Annotator.height){a.addNewAnnotation({x:b.x,y:b.y,title:a.name,comment:Comment.prototype.defaultComment,pointsX:[],pointsY:[]});Annotator.draw();buttons.handButton.action();return false}}},mousedown:function(b){if(buttons.handButton.selected){Annotator.$mainCanvas.css("cursor","url(/media/closedhand.cur), default")}mouseDown=true;return false},mouseup:function(c){if(buttons.handButton.selected){Annotator.$mainCanvas.css("cursor","url(/media/openhand.cur), default")}lastMouseX=-1;lastMouseY=-1;if(mouseDown&&!zoom.zoomDrag&&buttons.pencilButton.selected){var b=imageHandler.getRelativeCoords(c.pageX,c.pageY);if(b.x>=0&&b.x<=1&&b.y>=0&&b.y<=1&&c.pageX>=Annotator.x&&c.pageX<=Annotator.x+Annotator.width&&c.pageY>=Annotator.y&&c.pageY<=Annotator.y+Annotator.height){a.addNewAnnotation({x:b.x,y:b.y,title:a.name,comment:Comment.prototype.defaultComment,pointsX:currentPointsX.slice(),pointsY:currentPointsY.slice()});delete currentPointsX;delete currentPointsY;currentPointsX=[];currentPointsY=[];Annotator.draw();buttons.handButton.action()}zoom.zoomDrag=false;mouseDown=false;return false}mouseDown=false;zoom.zoomDrag=false;return true},mousemove:function(f){if(!zoom.zoomDrag&&!mouseDown){return true}if(lastMouseX==-1||lastMouseY==-1){lastMouseX=f.pageX;lastMouseY=f.pageY;return false}var c=f.pageX-lastMouseX;var b=f.pageY-lastMouseY;lastMouseX=f.pageX;lastMouseY=f.pageY;if(zoom.zoomDrag){zoom.mousemoveCallback(f);return false}else{if(buttons.handButton.selected&&mouseDown){imageHandler.moveImage(c,b);Annotator.draw();if(annotationSelected==-1){return false}}else{if(buttons.pencilButton.selected&&mouseDown){var d=imageHandler.getRelativeCoords(f.pageX,f.pageY);if(d.x>=0&&d.x<=1&&d.y>=0&&d.y<=1){currentPointsX.push(d.x);currentPointsY.push(d.y);Annotator.draw()}return false}}}return true}}};var annotationSelected=-1;AnnotatorBase=function(){var b=0;var a=this;this.width=0;this.height=0;this.x=0;this.y=0;this.callbacks=callbacks(this);this.annotations=[];this.currentIteration=null;this.annotationsType=null;this.editableAnnotation=null;this.readonlyAnnotation=null;this.isDesignerAnnotator=false;this.ieResize=function(){$("#annotatorCanvas").height($(".annotatorMidpart").height());$("#rightSidebar").height($(".annotatorMidpart").height())};this.deleteAllAnnotations=function(){while(this.annotations.length>0){var c=this.annotations.length-1;this.annotations[c].remove("immediately")}};this.importFromJSON=function(e,c){if(!e||e.length===0){return false}if(e.dimensions){imageHandler.setOriginalDimensions(e.dimensions.width,e.dimensions.height)}for(var d=0;d<e.annotations.length;d++){var g=e.annotations[d];var f={id:g.id,x:g.x,y:g.y,pointsX:(g.pointsX?g.pointsX.split(","):[]),pointsY:(g.pointsY?g.pointsY.split(","):[]),readonly:c,title:g.title,comment:g.comment,done:g.done,byDesigner:g.byDesigner,thread:g.thread};if((g.title===Annotator.name)&&!c){f.readonly=false}else{f.readonly=true}this.addNewAnnotation(f)}};this.exportToJSON=function(e){if(!e){e=0}var c={};c.dimensions={};c.dimensions.width=imageHandler.origWidth;c.dimensions.height=imageHandler.origHeight;c.lastId=b;c.annotations=[];var d=0;for(var f=0;f<this.annotations.length;f++){var h=this.annotations[f];if(h.id>=e){var j=h.getCoordinates();var g=h.getPoints();c.annotations.push({id:h.id,x:j.x,y:j.y,pointsX:"",pointsY:"",title:h.getTitle(),comment:h.getComment(),done:h.done})}}return c};this.editProjectName=function(){var c=this;$("#annotatorHdrTitleText").hide();$("#annotatorHdrTitleEdit").show().focus().select().unbind("blur").blur(function(){if(c.projectName===$("#annotatorHdrTitleEdit").val()){$("#annotatorHdrTitleEdit").hide();$("#annotatorHdrTitleProjectName").text(c.projectName);$("#annotatorHdrTitleText").show()}else{$("#throbber").show();ajaxCall({type:"POST",url:"/designer/project/change_name/"+c.projectId,data:{name:$("#annotatorHdrTitleEdit").val()},success:function(d){if(d==="done"){c.projectName=$("#annotatorHdrTitleEdit").val()}else{showError("Error: "+d)}$("#throbber").hide();$("#annotatorHdrTitleEdit").hide();$("#annotatorHdrTitleProjectName").text(c.projectName);$("#annotatorHdrTitleText").show()},customError:function(){$("#throbber").hide();$("#annotatorHdrTitleEdit").hide();$("#annotatorHdrTitleProjectName").text(c.projectName);$("#annotatorHdrTitleText").show()}})}}).unbind("keypress").keypress(function(d){if(d.which===13){$("#annotatorHdrTitleEdit").blur()}})};this.draw=function(){var g=imageHandler;if(this.img&&this.mainContext&&g.origHeight!==0&&g.origWidth!==0){var d=this.mainContext;d.clearRect(0,0,this.width,this.height);if(this.img.complete){d.drawImage(this.img,g.x,g.y,g.width,g.height)}else{if(g.imageLoaded){var e=this;setTimeout(function(){e.draw()},ajaxRetryTime);return false}}if(!this.annotationsListMinimized){for(var f=0;f<this.annotations.length;f++){var c=this.annotations[f];c.draw()}if(currentPointsX.length>0){d.strokeStyle="rgb(0, 0, 0)";d.lineWidth=4;d.beginPath();d.moveTo(imageHandler.x+currentPointsX[0]*imageHandler.width,imageHandler.y+currentPointsY[0]*imageHandler.height);for(f=1;f<currentPointsX.length;f++){d.lineTo(imageHandler.x+currentPointsX[f]*imageHandler.width,imageHandler.y+currentPointsY[f]*imageHandler.height)}d.stroke()}}}};this.addNewAnnotation=function(c){var d=new Annotation(c);this.annotations.push(d)};this.resizeCanvas=function(){var c=this.$mainCanvas[0];c.width=c.parentNode.offsetWidth;c.height=c.parentNode.offsetHeight;this.x=this.$mainCanvas.offset().left;this.y=this.$mainCanvas.offset().top;this.width=c.width;this.height=c.height};this.initSidebar=function(){var d=false;var e=-1;var f=$("#rightSidebarResize");var c=this;f.mousedown(function(){d=true;return false});$("body").mouseup(function(){if(d===true){d=false;$(".commentBox").each(function(){$(".commentCommentBoxTextarea",this).width(Math.max($(this).width()-10,10)).autogrow(Comment.prototype.autoGrowOptions)});zoom.updateZoomMarkers();zoom.updateZoomCursor();c.resizeCanvas();c.draw();e=-1}});$("body").mousemove(function(i){if(d===false){return true}if(e===-1){e=i.pageX}else{var h=i.pageX-e;var g=$("#rightSidebar").width();$("#rightSidebar").width(g-h);e=i.pageX}return true});$("#feedbackComments").click(function(){if($("#annotationsContainer").is(":hidden")){$("#annotationsContainer").show();$(".toggleArrow","#feedbackComments").removeClass("closed");c.annotationsListMinimized=false}else{c.annotationsListMinimized=true;$("#annotationsContainer").hide();$(".toggleArrow","#feedbackComments").addClass("closed")}c.draw()});$("#clients").click(function(){if($("#clientsBox").is(":hidden")){$("#clientsBox").show();$(".toggleArrow","#clients").removeClass("closed")}else{$("#clientsBox").hide();$(".toggleArrow","#clients").addClass("closed")}c.draw()})};this.resize=function(){a.resizeCanvas();zoom.resizeScroller(a.height-64);$("#zoomScroller").css("top","4px");$("#zoomScroller").css("left","3px");zoom.updateZoomMarkers();zoom.updateZoomCursor();a.draw()};this.iePollContext=function(){var c=this;if(!c.mainContext){if(c.$mainCanvas[0].getContext("2d")){c.mainContext=c.$mainCanvas[0].getContext("2d")}else{setTimeout(function(){c.iePollContext()},500)}}};this.init=function(){this.$mainCanvas=$("#mainCanvas");this.resizeCanvas();var e=this;if($.browser.msie&&$.browser.version<8){$(window).resize(function(){e.ieResize()})}for(var d in this.clients){var c=this.clients[d];this.addClient(c)}$(window).resize(function(){e.resize()});this.initSidebar();this.mainContext=this.$mainCanvas[0].getContext("2d");if(!this.mainContext){this.iePollContext()}this.img=null;defaultTitleHeight=$("#annotatorBodyTitle").height();zoom.init();this.$mainCanvas.mousedown(this.callbacks.mousedown);this.$mainCanvas.mouseup(this.callbacks.mouseup);this.$mainCanvas.mousemove(this.callbacks.mousemove);this.$mainCanvas.click(this.callbacks.click);this.$mainCanvas.mousewheel(zoom.zoomwheelCallback);buttons.handButton.action();$(window).resize(this.screenResize);$(window).mouseup(this.callbacks.mouseup);$(window).mousemove(this.callbacks.mousemove);document.getElementById("annotationsContainer").onscroll=function(){Annotator.draw()};document.getElementById("rightSidebarContent").onscroll=function(){Annotator.draw()}}};var mouseDown=false;var lastMouseX=-1;var lastMouseY=-1;var defaultTitleHeight;var scrollPaneOptions={showArrows:true,scrollbarMargin:0,reinitialiseOnImageLoad:true};function initializeScrollPane(){}function reinitializeScrollPane(){}function scrollPaneToEnd(){if($.isFunction($("#annotationsContainer")[0].scrollTo)){$("#annotationsContainer")[0].scrollTo($("#annotationsContainer").data("jScrollPaneMaxScroll"))}}function expandComment(){var a=$("#annotatorBodyTitleText").height();$("#annotatorBodyTitle").animate({height:a});$("#annotatorBodyTitleExpandIcon").hide();$("#annotatorBodyTitleCollapseIcon").show()}function collapseComment(){var a=defaultTitleHeight;$("#annotatorBodyTitle").animate({height:a});$("#annotatorBodyTitleExpandIcon").show();$("#annotatorBodyTitleCollapseIcon").hide()}AnnotatorBase.prototype.removeClientAjax=function(c){var a=c.data("client");var b=this;$("#throbber",c).show();ajaxCall({type:"POST",url:"/designer/project/remove_client/"+a.id,success:function(d){$("#throbber",c).hide();if(d!=="done"){showError("Error",d)}delete b.clients[a.id]},customError:function(){$("#throbber",c).hide()}})};AnnotatorBase.prototype.createClientAjax=function(c){var b=this;var a=c.data("client");$("#throbber",c).show();ajaxCall({type:"POST",url:"/designer/project/add_client/"+b.projectId,data:{name:a.name,email:a.email},success:function(e){$("#throbber",c).hide();if(e.charAt(0)==="{"){var d=JSON.parse(e);a.id=d.id;a.url="http://redmark.com/client/annotate/"+d.pac;b.clients[a.id]=a;$("#url",c).val(a.url)}else{showError("Error",e)}},customError:function(){$("#throbber",c).hide()}})};AnnotatorBase.prototype.addClient=function(a){var b=this;if($(".client","#clientsContainer").length>=b.limitClients){showUpgradeMessage();return}if(typeof(a)==="undefined"){a={name:"Name",email:"E-Mail Address",url:"",id:-1}}var d="";d+='<div class="client" style="position: relative; background-color: #e9e9e9; padding: 3px; margin-left: 4px; margin-right: 3px; margin-top: 5px; width: auto;">';d+='	<div style="position: absolute; right: 6px; top: -2px;">';d+='		<img id="deleteButton" class="button" src="/media/images/buttons/x_button.png" />';d+="	</div>";d+='	<div style="position: absolute; left: 3px; top: -5px;">';d+='		<img id="throbber" class="button" src="/media/ajax-loader.gif" height=9 style="display: none"/>';d+="	</div>";d+='				<table width=100% cellpadding=0 cellspacing=0 style="padding: 2px;">';d+='					<tr style="height: 5px; font-size: 8pt;">';d+='                        <td width=16 valign="middle"></td>';d+="					    <td width=40%>";d+="					         Name:";d+="					    </td>";d+="					    <td>";d+="					         E-Mail:";d+="					    </td>";d+="					</tr>";d+='					<tr style="height: 20px;">';d+='                        <td width=16 valign="middle"><img src="/media/images/client_icon.png" height=20 style="vertical-align: middle" /></td>';d+="					    <td width=40%>";d+='					         <input id="name" type="text" value="'+a.name+'" style="width: 100%"></input>';d+="					    </td>";d+="					    <td>";d+='					         <input id="email" type="text" value="'+a.email+'" style="width: 100%"></input>';d+="					    </td>";d+="					</tr>";if(!($.browser.msie&&$.browser.version<8)){d+="					<tr>";d+="						<td colspan=3>";d+='							<div style="position: relative; width: 100%; margin-top: 2px;">';d+='								<div style="float: left; font-size: 8pt; margin-top: 4px;">Review URL:</div>';d+='								<div style="margin-left: 63px; width: auto;">';d+='									<input id="url" class="readonly" type="text" value="'+a.url+'" readonly style="width: 100%;"></input>';d+="								</div>";d+="							</div>";d+="						</td>";d+="					</tr>"}d+="				</table>";if($.browser.msie&&$.browser.version<8){d+='							<div style="position: relative; width: 100%;">';d+='								<div style="margin-right: 4px; width: auto;">';d+='									<span style="font-size: 8pt">Review URL:</span> <input id="url" class="readonly" type="text" value="'+a.url+'" readonly></input>';d+="								</div>";d+="							</div>"}d+="</div>";var c=$(d);c.data("client",a);c.appendTo("#clientsContainer");if(a.id===-1){$("#name",c).focus().select()}$("#deleteButton",c).click(function(){c.fadeOut("normal",function(){if(c.data("client").id!==-1){b.removeClientAjax(c)}c.remove();delete c})});$("#name",c).click(function(){if($(this).val()==="Name"){$(this).focus().select()}});$("#email",c).click(function(){if($(this).val()==="E-Mail Address"){$(this).focus().select()}});$("#url",c).click(function(){$(this).focus().select()});$("#name",c).blur(function(){var e=c.data("client");if(e.name===$(this).val()){return}e.name=$(this).val();if(e.id===-1){if(e.email!=="E-Mail Address"){b.createClientAjax(c)}}else{$("#throbber",c).show();ajaxCall({type:"POST",url:"/designer/project/edit_client/"+e.id,data:{name:e.name,email:e.email},success:function(f){$("#throbber",c).hide();if(f.substring(0,4)!=="done"){showError("Error",f)}},customError:function(){$("#throbber",c).hide()}})}}).keypress(function(f){if(f.which===13){$(this).blur()}});$("#email",c).blur(function(){var e=c.data("client");if(e.email===$(this).val()){return}e.email=$(this).val();if(e.id===-1){if(e.name!=="Name"){b.createClientAjax(c)}}else{$("#throbber",c).show();ajaxCall({type:"POST",url:"/designer/project/edit_client/"+e.id,data:{name:e.name,email:e.email},success:function(g){$("#throbber",c).hide();if(g.substring(0,4)!=="done"){showError("Error",g)}else{var f=g.substring(6);e.url="http://redmark.com/client/annotate/"+f;$("#url",c).val(e.url)}},customError:function(){$("#throbber",c).hide()}})}}).keypress(function(f){if(f.which===13){$(this).blur()}})};AnnotatorDesigner=function(a){var b=new AnnotatorBase();b.isDesignerAnnotator=true;for(option in a){b[option]=a[option]}b.notifyClients=function(){showSendingDialog();ajaxCall({type:"GET",url:"/designer/notify_clients/"+Annotator.projectId,data:{},success:function(c,d){hideSendingDialog();if(c.toLowerCase()==="done"){hideSendingDialog();var e="";e+="Your clients have been notified about your comments!";e+='<div style="text-align:right">';e+='<input type=button onClick="hideDialog(\'success\'); return false;" value="OK"></input>';e+="</div>";showDialog("success","Success",e);setTimeout(function(){hideDialog("success")},5000)}else{showError("Error","Could not send email to the specified address")}},error:function(e,c,d){hideSendingDialog();showError("Ajax error "+e.status,"The server could not process your request.")}})};return b};AnnotatorClient=function(a){var b=new AnnotatorBase();for(option in a){b[option]=a[option]}b.notifyDesigner=function(){showSendingDialog();ajaxCall({type:"GET",url:"/client/notify_designer/"+Annotator.projectCode,data:{},success:function(c,d){hideSendingDialog();if(c.toLowerCase()==="done"){var e="";e+="The graphic designer has been notified about your comments!";e+='<div style="text-align:right">';e+='<input type=button onClick="hideDialog(\'success\'); return false;" value="OK"></input>';e+="</div>";showDialog("success","Success",e);setTimeout(function(){hideDialog("success")},5000)}else{showError("Error","Could not send email to the specified address")}},error:function(e,c,d){hideSendingDialog();showError("Ajax error "+e.status,"The server could not process your request.")}})};return b};dock=function(b){var a=0;var c=function(){$("#uploadDialog").css({position:"absolute",top:($("#dockContainer").offset().top-170)+"px",left:"250px"}).fadeIn()};var d=function(){var e=document.getElementById("fisheye");e.fisheyeCfg.pos=jQuery.iUtil.getPosition(e)};return{initDock:function(){$("#fisheye").Fisheye({maxWidth:30,items:"div.fisheyeItem",itemsText:"span",container:".fisheyeContainter",itemWidth:65,proximity:70,offset:18,alignment:"left",valign:"bottom",halign:"left"});if($("#fisheyeContainer").offset().left+$("#fisheyeContainer").width()>$("#dockArrowRight").offset().left){a=($("#dockArrowRight").offset().left-$("#fisheyeContainer").width()-$("#fisheyeContainer").offset().left+5)}else{a=0}$("#fisheye").css({left:a+"px"});$("#dockTile").click(function(){if($("#dockContainer").is(":hidden")){document.getElementById("fisheye").fisheyeCfg.disabled=false;$("#dockContainer, #dockBackground").show();$(".toggleArrow",this).removeClass("closed");$(".annotatorMidpart").css("margin-bottom","86px");Annotator.resize()}else{document.getElementById("fisheye").fisheyeCfg.disabled=true;$("#dockContainer, #dockBackground").hide();$(".toggleArrow",this).addClass("closed");$(".annotatorMidpart").css("margin-bottom","18px");Annotator.resize()}});d()},addItems:function(){for(var e=0;e<b.iterations.length;e++){this.addItemToDock(b.iterations[e])}},addItemToDock:function(i){var h="";var f=i.imageFilename;var j=f.substring(0,f.lastIndexOf("."));var k=f.substring(f.lastIndexOf("."));j+="_dock.png";h+="<div id='dock_iteration_"+i.id+'\' class="fisheyeItem button">';h+="  <span>";h+='    <div class="dockPopupText">';h+='        <div class="dockPopupVersion">';if(i.by_designer===1){h+="Version "+i.version}else{h+="Suggestion"}h+="        </div>";h+='        <div class="dockPopupDateCount">'+i.formattedDate+"<BR>"+i.annotationCount+" comments</div>";h+="        </div>";h+="  </span>";h+="  <div style='position: relative;'>";h+='    <img class="reflect" src="/media/user_images/'+Annotator.projectId+"/"+j+'" />';if(i.by_designer===0){h+="     <div class='dockClientMarker'></div>"}h+="  </div>";h+="</div>";var g=$(h);var e=loader.iterations.indexOf(i);g.click(function(){return loader.selectIteration(e)});$("#fisheyeContainer").append(g)},addUploadButtonToDock:function(){var f="";f+='<div class="fisheyeItem button">';f+="<div class='fisheyeImgHolder'>";f+='<img class="reflect" src="/media/images/new_upload.png" />';f+="</div>";f+="</div>";var e=$(f);e.click(function(){showUploadDialog(Annotator.currentIteration.projectId)});$("#fisheyeContainer").append(e)},slideDown:function(){$("#dockContainer").animate({bottom:"-200px"},function(){$("#dockContainer").hide()});document.getElementById("fisheye").fisheyeCfg.disabled=true;this.hidden=true},slideUp:function(){$("#dockContainer").show().animate({bottom:"0px"});document.getElementById("fisheye").fisheyeCfg.disabled=false;this.hidden=false},toggle:function(){if(this.hidden===false){this.slideDown()}else{this.slideUp()}},slideLeft:function(){if($("#fisheye").offset().left>0){return}if($.browser.msie){jQuery.fx.off=false}a+=83;$("#fisheye").animate({left:a},function(){d();if($.browser.msie){jQuery.fx.off=true}})},slideRight:function(){if($("#fisheyeContainer").width()+$("#fisheye").offset().left-83-65<0){return}if($.browser.msie){jQuery.fx.off=false}a-=83;$("#fisheye").animate({left:a},function(){d();if($.browser.msie){jQuery.fx.off=true}})},hidden:false}};jQuery.iUtil={getPosition:function(g){var a=0;var i=0;var h=g.style;var f=false;if(jQuery(g).css("display")=="none"){var b=h.visibility;var d=h.position;f=true;h.visibility="hidden";h.display="block";h.position="absolute"}var c=g;while(c){a+=c.offsetLeft+(c.currentStyle&&!jQuery.browser.opera?parseInt(c.currentStyle.borderLeftWidth)||0:0);i+=c.offsetTop+(c.currentStyle&&!jQuery.browser.opera?parseInt(c.currentStyle.borderTopWidth)||0:0);c=c.offsetParent}c=g;while(c&&c.tagName&&c.tagName.toLowerCase()!="body"){a-=c.scrollLeft||0;i-=c.scrollTop||0;c=c.parentNode}if(f==true){h.display="none";h.position=d;h.visibility=b}return{x:a,y:i}},getPositionLite:function(b){var a=0,c=0;while(b){a+=b.offsetLeft||0;c+=b.offsetTop||0;b=b.offsetParent}return{x:a,y:c}},getSize:function(g){var a=jQuery.css(g,"width");var d=jQuery.css(g,"height");var f=0;var j=0;var i=g.style;if(jQuery(g).css("display")!="none"){f=g.offsetWidth;j=g.offsetHeight}else{var b=i.visibility;var c=i.position;i.visibility="hidden";i.display="block";i.position="absolute";f=g.offsetWidth;j=g.offsetHeight;i.display="none";i.position=c;i.visibility=b}return{w:a,h:d,wb:f,hb:j}},getSizeLite:function(a){return{wb:a.offsetWidth||0,hb:a.offsetHeight||0}},getClient:function(c){var b,a,d;if(c){a=c.clientWidth;b=c.clientHeight}else{d=document.documentElement;a=window.innerWidth||self.innerWidth||(d&&d.clientWidth)||document.body.clientWidth;b=window.innerHeight||self.innerHeight||(d&&d.clientHeight)||document.body.clientHeight}return{w:a,h:b}},getScroll:function(i){var d=0,b=0,a=0,f=0,c=0,g=0;if(i&&i.nodeName.toLowerCase()!="body"){d=i.scrollTop;b=i.scrollLeft;a=i.scrollWidth;f=i.scrollHeight;c=0;g=0}else{if(document.documentElement){d=document.documentElement.scrollTop;b=document.documentElement.scrollLeft;a=document.documentElement.scrollWidth;f=document.documentElement.scrollHeight}else{if(document.body){d=document.body.scrollTop;b=document.body.scrollLeft;a=document.body.scrollWidth;f=document.body.scrollHeight}}c=self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0;g=self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0}return{t:d,l:b,w:a,h:f,iw:c,ih:g}},getMargins:function(i,d){var g=jQuery(i);var f=g.css("marginTop")||"";var h=g.css("marginRight")||"";var a=g.css("marginBottom")||"";var c=g.css("marginLeft")||"";if(d){return{t:parseInt(f)||0,r:parseInt(h)||0,b:parseInt(a)||0,l:parseInt(c)}}else{return{t:f,r:h,b:a,l:c}}},getPadding:function(i,d){var g=jQuery(i);var f=g.css("paddingTop")||"";var h=g.css("paddingRight")||"";var a=g.css("paddingBottom")||"";var c=g.css("paddingLeft")||"";if(d){return{t:parseInt(f)||0,r:parseInt(h)||0,b:parseInt(a)||0,l:parseInt(c)}}else{return{t:f,r:h,b:a,l:c}}},getBorder:function(i,d){var g=jQuery(i);var f=g.css("borderTopWidth")||"";var h=g.css("borderRightWidth")||"";var a=g.css("borderBottomWidth")||"";var c=g.css("borderLeftWidth")||"";if(d){return{t:parseInt(f)||0,r:parseInt(h)||0,b:parseInt(a)||0,l:parseInt(c)||0}}else{return{t:f,r:h,b:a,l:c}}},getPointer:function(b){var a=b.pageX||(b.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft))||0;var c=b.pageY||(b.clientY+(document.documentElement.scrollTop||document.body.scrollTop))||0;return{x:a,y:c}},traverseDOM:function(a,b){b(a);a=a.firstChild;while(a){jQuery.iUtil.traverseDOM(a,b);a=a.nextSibling}},purgeEvents:function(a){jQuery.iUtil.traverseDOM(a,function(c){for(var b in c){if(typeof c[b]==="function"){c[b]=null}}})},centerEl:function(d,c){var a=jQuery.iUtil.getScroll();var b=jQuery.iUtil.getSize(d);if(!c||c=="vertically"){jQuery(d).css({top:a.t+((Math.max(a.h,a.ih)-a.t-b.hb)/2)+"px"})}if(!c||c=="horizontally"){jQuery(d).css({left:a.l+((Math.max(a.w,a.iw)-a.l-b.wb)/2)+"px"})}},fixPNG:function(b,d){var a=jQuery('img[@src*="png"]',b||document),c;a.each(function(){c=this.src;this.src=d;this.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+c+"')"})}};[].indexOf||(Array.prototype.indexOf=function(b,d){d=(d==null)?0:d;var a=this.length;for(var c=d;c<a;c++){if(this[c]==b){return c}}return -1});jQuery.iFisheye={build:function(a){return this.each(function(){var b=this;b.fisheyeCfg={items:jQuery(a.items,this),container:jQuery(a.container,this),pos:jQuery.iUtil.getPosition(this),itemWidth:a.itemWidth,itemsText:a.itemsText,proximity:a.proximity,valign:a.valign,halign:a.halign,maxWidth:a.maxWidth,offset:a.offset,disabled:false};jQuery.iFisheye.positionContainer(b,0);jQuery(window).bind("resize",function(){b.fisheyeCfg.pos=jQuery.iUtil.getPosition(b);jQuery.iFisheye.positionContainer(b,0);jQuery.iFisheye.positionItems(b)});jQuery.iFisheye.positionItems(b);b.fisheyeCfg.items.bind("mouseover",function(){if(jQuery(b.fisheyeCfg.itemsText,this).length>0){jQuery(b.fisheyeCfg.itemsText,this).get(0).style.display="block"}}).bind("mouseout",function(){if(jQuery(b.fisheyeCfg.itemsText,this).length>0){jQuery(b.fisheyeCfg.itemsText,this).get(0).style.display="none"}});jQuery(document).bind("mousemove",function(f){if(b.fisheyeCfg.disabled===true){return true}var g=jQuery.iUtil.getPointer(f);var d=0;if(b.fisheyeCfg.halign&&b.fisheyeCfg.halign=="center"){var c=g.x-b.fisheyeCfg.pos.x-(b.offsetWidth-(b.fisheyeCfg.itemWidth+b.fisheyeCfg.offset)*b.fisheyeCfg.items.size())/2-(b.fisheyeCfg.itemWidth+b.fisheyeCfg.offset)/2}else{if(b.fisheyeCfg.halign&&b.fisheyeCfg.halign=="right"){var c=g.x-b.fisheyeCfg.pos.x-b.offsetWidth+(b.fisheyeCfg.itemWidth+b.fisheyeCfg.offset)*b.fisheyeCfg.items.size()}else{var c=g.x-b.fisheyeCfg.pos.x-b.fisheyeCfg.offset}}var h=Math.pow(g.y-b.fisheyeCfg.pos.y-b.offsetHeight/2,2);b.fisheyeCfg.items.each(function(e){distance=Math.sqrt(Math.pow(c-e*b.fisheyeCfg.itemWidth-(e+1)*b.fisheyeCfg.offset,2)+h);distance-=b.fisheyeCfg.itemWidth/2;distance=distance<0?0:distance;distance=distance>b.fisheyeCfg.proximity?b.fisheyeCfg.proximity:distance;distance=b.fisheyeCfg.proximity-distance;extraWidth=b.fisheyeCfg.maxWidth*distance/b.fisheyeCfg.proximity;this.style.width=b.fisheyeCfg.itemWidth+extraWidth+"px";this.style.left=(b.fisheyeCfg.itemWidth*e+d+(e+1)*b.fisheyeCfg.offset)+"px";d+=extraWidth});jQuery.iFisheye.positionContainer(b,d)})})},positionContainer:function(b,a){if(b.fisheyeCfg.halign){if(b.fisheyeCfg.halign=="center"){b.fisheyeCfg.container.get(0).style.left=(b.offsetWidth-(b.fisheyeCfg.itemWidth+b.fisheyeCfg.offset)*b.fisheyeCfg.items.size())/2-a/2+"px"}else{if(b.fisheyeCfg.halign=="left"){b.fisheyeCfg.container.get(0).style.left=(-a/b.fisheyeCfg.items.size()/2)+"px"}else{if(b.fisheyeCfg.halign=="right"){b.fisheyeCfg.container.get(0).style.left=(b.offsetWidth-(b.fisheyeCfg.itemWidth+b.fisheyeCfg.offset)*b.fisheyeCfg.items.size())-a/2+"px"}}}}b.fisheyeCfg.container.get(0).style.width=(b.fisheyeCfg.itemWidth+b.fisheyeCfg.offset)*b.fisheyeCfg.items.size()+a+b.fisheyeCfg.offset+"px"},positionItems:function(a){a.fisheyeCfg.items.each(function(b){this.style.width=a.fisheyeCfg.itemWidth+"px";this.style.left=a.fisheyeCfg.offset+(a.fisheyeCfg.itemWidth+a.fisheyeCfg.offset)*b+"px"})}};jQuery.fn.Fisheye=jQuery.iFisheye.build;