document.observe("dom:loaded",function(){Ajax.Responders.register({onCreate:function(){if(Ajax.activeRequestCount>0){setFlashText("Loading...")}},onComplete:function(){if(Ajax.activeRequestCount==0){clearFlashText()}}})});function SS(a,b){this.startX=0;this.startY=0;this.dragElement=null;this.scrollWatch=null;this.vector=$(b);this.sequence=$(a);disableSelection(this.sequence);disableSelection(this.vector);$(this.sequence).observe("mousedown",this.onMouseDown);$(this.vector).observe("mousedown",this.vectorDown);document.observe("mouseup",this.onMouseUp)}var getKeys=function(c){var b=[];for(var a in c){b.push(a)}return b};function detect_scroll(){var b=SS.clientY;var c=Math.max(SS.clientX,SP.x);if(b<(getTop(SS.sequence)+30)){var e=Math.min(Math.max((getTop(SS.sequence)+30)-b-25,1),25);SS.sequence.scrollTop=SS.sequence.scrollTop-e;var f=SS.sequence.scrollTop+b-getTop(SS.sequence);var a=SP.to_index(c,f);if(SS.target_index==1){SE.highlight_from(a,SS.target_id)}else{SE.highlight_to(SS.target_id,a)}}else{if(b>(getBottom(SS.sequence)-30)){var e=Math.min(Math.max(b-(getBottom(SS.sequence)-30)-25,1),25);SS.sequence.scrollTop=SS.sequence.scrollTop+e;var f=SS.sequence.scrollTop+b-getTop(SS.sequence);var a=SP.to_index(c,f);if(SS.target_index==1){SE.highlight_from(a,SS.target_id)}else{SE.highlight_to(SS.target_id,a)}}}}SS.prototype.onMouseDown=function(g){if(g==null){g=window.event}var f=g.target!=null?g.target:g.srcElement;var b=(g.button==1&&window.event!=null||g.button==0);if(f.onclick!=null){return f.onclick()}if(b&&g.clientX>SP.x&&g.clientX<SP.x+SP.width){var h=SS.sequence.scrollTop+g.clientY-getTop(SS.sequence);var c=SP.to_index(g.clientX,h);SS.target_id=c;SS.startX=g.clientX;SS.startY=g.clientY;SE.selected_feature="";var a=SE.last_highlight;if(a[0]!=a[1]&&a[0]>=0&&a[1]>=0){if(c==a[0]){SS.target_id=a[1];SS.target_index=1}else{if(c==a[1]){SS.target_id=a[0];SS.target_index=0}else{SE.highlight_no_scroll(c,c);SS.target_id=c;SS.target_index=0}}}else{SE.highlight_no_scroll(c,c);SS.target_id=c;SS.target_index==0}document.observe("mousemove",SS.onMouseMove);SS.clientX=g.clientX;SS.clientY=g.clientY;SS.scrollWatch=setInterval(detect_scroll,5);SS.dragElement=f;document.body.focus();document.onselectstart=function(){return false};f.ondragstart=function(){return false};return false}};SS.prototype.vectorDown=function(g){if(g==null){g=window.event}var f=g.target!=null?g.target:g.srcElement;var b=(g.button==1&&window.event!=null||g.button==0);if(f.onclick!=null){return f.onclick()}var h=10;if(b&&isParentOf(f,SS.vector)){SS.dragElement=f;SS.clientX=g.clientX;SS.clientY=g.clientY;SE.selected_feature="";var c=CV.pos_to_sequence(g.clientX-getLeft(SS.vector),g.clientY-getTop(SS.vector),CV.sequence_length)-1;var a=SE.last_highlight;if(a[0]!=a[1]&&a[0]>=0&&a[1]>=0){if(QaDV.distance_squared(CV.sequence_to_pos(c+1,CV.sequence_length),CV.sequence_to_pos(a[0],CV.sequence_length))<h*h){SS.target_id=a[1];SS.target_index=1}else{if(QaDV.distance_squared(CV.sequence_to_pos(c+1,CV.sequence_length),CV.sequence_to_pos(a[1]+1,CV.sequence_length))<h*h){SS.target_id=a[0];SS.target_index=0}else{SE.highlight_from(c,c);SS.target_id=c;SS.target_index=0}}}else{SE.highlight_from(c,c);SS.target_id=c;SS.target_index=0}f.ondragstart=function(){return false};document.body.focus();document.onselectstart=function(){return false};document.observe("mousemove",SS.vectorMove);return false}};function angle_diff(a,b){d1=Math.cos(a)-Math.cos(b);d2=Math.sin(a)-Math.sin(b);d=Math.sqrt(d1*d1+d2*d2);return d}SS.prototype.vectorMove=function(c){if(c==null){c=window.event}var b=c.target!=null?c.target:c.srcElement;SS.clientX=c.clientX;SS.clientY=c.clientY;var a=CV.pos_to_sequence(c.clientX-getLeft(SS.vector),c.clientY-getTop(SS.vector),CV.sequence_length)-1;SS.dragElement=b;b.ondragstart=function(){return false};if(SS.target_index==1){SE.highlight_from(a,SS.target_id)}else{SE.highlight_to(SS.target_id,a)}};function isParentOf(e,b){var a=e;while(a!=null){if(a==b){return true}a=a.parentNode}return false}function extractNumber(a){var b=parseInt(a);return b==null||isNaN(b)?0:b}SS.prototype.onMouseMove=function(f){if(f==null){f=window.event}SS.clientX=f.clientX;SS.clientY=f.clientY;var c=Math.max(f.clientX,SP.x);var b=Math.max(f.clientY,getTop(SS.sequence));var g=SS.sequence.scrollTop+b-getTop(SS.sequence);var a=SP.to_index(c,g);if(SS.target_index==1){SE.highlight_no_scroll(a,SS.target_id)}else{SE.highlight_no_scroll(SS.target_id,a)}};SS.prototype.onMouseUp=function(a){if(SS.dragElement!=null){document.stopObserving("mousemove");document.onselectstart=null;clearInterval(SS.scrollWatch);SS.dragElement.ondragstart=null;SS.dragElement=null}};SE=function(){this.last_highlight=[0,0];this.selected_feature="";this.sequence=$("sequence");this.highlight_info=$("highlight_info")};function getTop(a){if(a.offsetParent){return(a.offsetTop+getTop(a.offsetParent))}else{return(a.offsetTop)}}function getLeft(a){if(a.offsetParent){return(a.offsetLeft+getLeft(a.offsetParent))}else{return(a.offsetLeft)}}function getRight(a){return(a.offsetWidth+getLeft(a))}function getBottom(a){return(a.offsetHeight+getTop(a))}SE.prototype.clear_highlight=function(g,f){if(f<g){return}var b=SP.to_line(g);var e=SP.to_line(f);for(var a=b;a<=e;a++){var c=SP.text_lines[a].innerHTML;c=c.replace(/<[^>]*>/g,"");c=c.replace(/&nbsp;/g,"");c=c.replace(/\s+$/g,"");SP.text_lines[a].innerHTML=c}};SE.prototype.make_highlight=function(g,f){if(f<g){return}from_line=SP.to_line(g);to_line=SP.to_line(f);var a=SP.to_str_index(g%(SP.LINE_LENGTH*SP.BLOCK_LENGTH));var c=SP.to_str_index(f%(SP.LINE_LENGTH*SP.BLOCK_LENGTH));if(from_line==to_line){this.highlight_line(a,c,SP.text_lines[from_line])}else{this.highlight_line(a,(SP.LINE_LENGTH*(SP.BLOCK_LENGTH+1))-1,SP.text_lines[from_line]);for(var b=from_line+1;b<to_line;b++){var e=SP.text_lines[b].innerHTML;e=e.replace(/<[^>]*>/g,"");e=e.replace(/&nbsp;/g,"");e=e.replace(/\s+$/g,"");e="<span class='highlight'>"+e+"</span>";SP.text_lines[b].innerHTML=e}this.highlight_line(0,c,SP.text_lines[to_line])}};SE.prototype.highlight_no_scroll=function(h,j){if(SP.x==null){computeHeight()}if(SP.text_lines.length==0){return}var g=this.last_highlight;j=Math.min(j,CV.sequence_length-1);j=Math.max(j,0);h=Math.min(h,CV.sequence_length-1);h=Math.max(h,0);if(h>j){if(g[0]>g[1]){this.highlight_sorted_block(h,CV.sequence_length-1,[g[0],CV.sequence_length-1]);this.highlight_sorted_block(0,j,[0,g[1]])}else{this.highlight_sorted_block(h,CV.sequence_length-1,[g[0],g[1]]);this.highlight_sorted_block(0,j,[-1,-1])}from_line=SP.to_line(h);to_line=SP.to_line(j);if(from_line==to_line){var b=SP.to_str_index(h%(SP.LINE_LENGTH*SP.BLOCK_LENGTH));var c=SP.to_str_index(j%(SP.LINE_LENGTH*SP.BLOCK_LENGTH));var k=SP.text_lines[from_line];var f=k.innerHTML;f=f.replace(/<[^>]*>/g,"");f=f.replace(/&nbsp;/g,"");f=f.replace(/\s+$/g,"");f="<span class='highlight'>"+f.substring(0,c+1)+"</span>"+f.substring(c+1,b)+"<span class='highlight'>"+f.substring(b,f.length)+"</span>";k.innerHTML=f}}else{if(g[0]>g[1]){this.clear_highlight(g[0],CV.sequence_length-1);this.highlight_sorted_block(h,j,[0,g[1]])}else{this.highlight_sorted_block(h,j,g)}}CV.updateBoth(h,j);this.last_highlight=[h,j];var a=-1;var e=getSequenceLength();if(h<=j){a=j-h+1}else{a=e-h+j+1}this.highlight_info.innerHTML="Selected: "+(h+1)+" to "+(j+1)+" ("+a+"/"+e+")"};SE.prototype.highlight_sorted_block=function(e,c,b){if(b[0]>=0&&b[1]>=0){var a=[Math.max(b[0],e),Math.min(b[1],c)];a[0]=Math.ceil(a[0]/(SP.BLOCK_LENGTH*SP.LINE_LENGTH))*(SP.BLOCK_LENGTH*SP.LINE_LENGTH);a[1]=Math.floor(a[1]/(SP.BLOCK_LENGTH*SP.LINE_LENGTH))*(SP.BLOCK_LENGTH*SP.LINE_LENGTH);if(a[1]>a[0]){this.clear_highlight(b[0],a[0]-1);this.clear_highlight(a[1],b[1]);this.make_highlight(a[1],c);this.make_highlight(e,a[0]-1)}else{this.clear_highlight(b[0],b[1]);this.make_highlight(e,c)}}else{this.make_highlight(e,c)}};SE.prototype.highlight_line=function(a,c,b){var e=b.innerHTML;e=e.replace(/&nbsp;/g,"");e=e.replace(/\s+$/g,"");e=e.substring(0,a)+"<span class='highlight'>"+e.substring(a,c+1)+"</span>"+e.substring(c+1);b.innerHTML=e};SE.prototype.scroll_to=function(a){SS.sequence.scrollTop=SP.get_y_before(a)};SE.prototype.highlight_from=function(b,a){if(SP.text_lines.length==0){return}this.highlight_no_scroll(b,a);SS.sequence.scrollTop=SP.get_y_before(b)};SE.prototype.highlight_to=function(b,a){if(SP.text_lines.length==0){return}this.highlight_no_scroll(b,a);SS.sequence.scrollTop=SP.get_y_before(a)};function searchDirect(a){var b=$(a).value.toLowerCase();search(b)}function searchByCheckbox(a,c){var b=$(a).value.toLowerCase();if($(c).checked){search(rc(b))}else{search(b)}}function search(b){var c=$("sequenceraw").innerHTML;from=SE.last_highlight[1]+1;var a=c.indexOf(b,from);if(a!=-1){SE.highlight_from(a,a+b.length-1)}else{a=c.indexOf(b);if(a!=-1){SE.highlight_from(a,a+b.length-1)}}}function disableSelection(a){a.onselectstart=function(){return false};a.unselectable="on";a.style.MozUserSelect="none";a.style.cursor="default"}function compareOptionText(e,c){return e.text!=c.text?e.text<c.text?-1:1:0}function sortOptions(c){var a=c.options.length;var b=new Array(a);for(i=0;i<a;i++){b[i]=new Option(c.options[i].text,c.options[i].value)}b.sort(compareOptionText);for(i=0;i<a;i++){c.options[i]=new Option(b[i].text,b[i].value)}}function getValueArray(c){var a=c.options.length;var b=new Array(a);for(i=0;i<a;i++){b[i]=c.options[i].value}return b}function removeDuplicates(e){var a=e.options.length;var c=new Hash();for(i=0;i<a;i++){c.set(e.options[i].text,e.options[i].value)}var b=0;c.each(function(g){e.options[b]=new Option(g.key,g.value);b++});var f=b;while(b<a){e.remove(f);b++}}function select_add(f,e,c){if(f.selectedIndex!=-1){for(var a=0,b=f.options.length;a<b;a++){if(f.options[a].selected){op=new Option(f.options[a].text,f.options[a].value);e.options[e.options.length]=op}}removeDuplicates(e);sortOptions(e)}c.value=getValueArray(e).join("::")}function remove_selection(c,b){if(c.selectedIndex!=-1){for(var a=0;a<c.options.length;a++){if(c.options[a].selected){c.remove(a);a=a-1}}}b.value=getValueArray(c).join("::")}function ClickFunctions(c){this.feature_hash=[];for(var e=0,a=c.length;e<a;e++){var b=c[e];this.feature_hash[b.feature_id]=b}}ClickFunctions.prototype.click=function(c){var e=this.feature_hash[c];var b=e.sequence_start-1;var a=e.sequence_end-1;SE.selected_feature=c;SE.highlight_from(b,a)};function setFlashText(a){str="";str=str+'<div id="notice" class="status_message">';str=str+a;str=str+"</div>&nbsp;";$("header_status_message").style.backgroundColor="#95D0FA";$("script_box").innerHTML=str;setTimeout(function(){if($("notice")!=null){$("header_status_message").style.backgroundColor="#ffffff";$("notice").hide()}},12000)}function clearFlashText(){if($("notice")){$("header_status_message").style.backgroundColor="#ffffff";$("notice").hide()}}function getSequenceLength(){return $("sequenceraw").innerHTML.length}function getSequenceSelection(){var c=$("sequenceraw").innerHTML;var b=null;var a=[SE.last_highlight[0]+1,SE.last_highlight[1]+1];if(a[0]<=a[1]){b=c.substring(a[0]-1,a[1])}else{b=c.substring(a[0]-1,c.length)+c.substring(0,a[1])}return b}String.prototype.reverse=function(){var a=this.split("");var c=a.reverse();var b=c.join("");return b};function checkEnter(a,c){var b;if(window.event){b=a.keyCode}else{if(a.which){b=a.which}}if(b==13){c();return false}return true};