function TagEditor(A,B,D){this.VariableName=A;this.AllTagsHandle=document.getElementById(B);this.SelectedTagsHandle=document.getElementById(D);this.PreviousTags=new Array();this.PreviousValue="";this.CurrentTag="";this.CurrentTagPosition=0;if(typeof GloballyAvailableTags!="undefined"){var C=GloballyAvailableTags}else{var C=window.parent.GloballyAvailableTags}this.GetAllTags=function(){var G=C.split("&");var F=new Array();for(var E=0;E<G.length;E+=2){if(G[E]!=""){F[F.length]=decodeURIComponent(G[E].replace(/\+/g," "))}}return F};this.GetAllTagsWithEncoding=function(){var G=C.split("&");var F=new Array();for(var E=0;E<G.length;E+=2){if(G[E]!=""){F[F.length]=new Array(decodeURIComponent(G[E].replace(/\+/g," ")),decodeURIComponent(G[E+1].replace(/\+/g," ")))}}return F};this.SetSelectedTags=function(E){var F=new Array();var I=this.GetSelectedTags();var H=this.GetAllTags();var J;for(var G=0;G<I.length;G++){J=false;for(var K=0;K<H.length;K++){if(I[G].toUpperCase()==H[K].toUpperCase()){J=true;break}}if(!J){F[F.length]=I[G]}}for(G=0;G<E.length;G++){F[F.length]=E[G]}this.SelectedTagsHandle.value=F.join("; ")};this.GetSelectedTags=function(){var G=this.SelectedTagsHandle.value.split(/;|,/);var E=new Array();for(var F=0;F<G.length;F++){G[F]=this.Trim(G[F]);if(G[F]!=""){E[E.length]=G[F]}}return E};this.Trim=function(E){return E.replace(/^\s+|\s+$/g,"")};this.EditorKeyDown=function(E){if(!E){E=window.event}if(!E){return}if(E.keyCode==13){this.SelectedTagsHandle.focus();if(document.selection){var G=window.document.selection.createRange();if(G.text&&G.text.length>0){G.moveStart("character",G.text.length);G.select()}}else{if(this.SelectedTagsHandle.selectionStart||this.SelectedTagsHandle.selectionStart=="0"){this.SelectedTagsHandle.selectionStart=this.SelectedTagsHandle.selectionEnd}}E.cancelBubble=true;E.returnValue=false;return false}else{if(E.keyCode==8){this.SelectedTagsHandle.focus();if(document.selection){var G=window.document.selection.createRange();if(G){G.moveStart("character",-1);G.text="";E.cancelBubble=true;E.returnValue=false;return false}}else{if(this.SelectedTagsHandle.selectionStart||this.SelectedTagsHandle.selectionStart=="0"){var H=this.SelectedTagsHandle.selectionStart;var F=this.SelectedTagsHandle.selectionEnd;if(H==F){return true}if(H>0){H--}this.SelectedTagsHandle.value=this.SelectedTagsHandle.value.substring(0,H)+this.SelectedTagsHandle.value.substring(F);this.SelectedTagsHandle.selectionStart=H;this.SelectedTagsHandle.selectionEnd=H;E.cancelBubble=true;E.returnValue=false;return false}}}}return true};this.EditorKeyUp=function(F){if(!document.selection&&!this.SelectedTagsHandle.selectionStart&&this.SelectedTagsHandle.selectionStart!="0"){return true}if(this.SelectedTagsHandle.value==this.PreviousValue){return true}this.PreviousValue=this.SelectedTagsHandle.value;this.GetCurrentTag();if(this.CurrentTag==""){return true}var G=this.GetTagSuggestion(this.CurrentTag);if(!G||G.length==this.CurrentTag.length){return true}G=G.substr(this.CurrentTag.length);this.SelectedTagsHandle.value=this.SelectedTagsHandle.value.substr(0,this.CurrentTagPosition+this.CurrentTag.length)+G+this.SelectedTagsHandle.value.substr(this.CurrentTagPosition+this.CurrentTag.length);this.SelectedTagsHandle.focus();if(document.selection){var E=this.SelectedTagsHandle.createTextRange();E.select();E.moveStart("character",this.CurrentTagPosition+this.CurrentTag.length);E.moveEnd("character",-(this.SelectedTagsHandle.value.length-(this.CurrentTagPosition+this.CurrentTag.length+G.length)));E.select()}else{if(this.SelectedTagsHandle.selectionStart||this.SelectedTagsHandle.selectionStart=="0"){this.SelectedTagsHandle.selectionStart=this.CurrentTagPosition+this.CurrentTag.length;this.SelectedTagsHandle.selectionEnd=this.CurrentTagPosition+this.CurrentTag.length+G.length}}return true};this.GetCurrentTag=function(){var F=this.SelectedTagsHandle.value.toLowerCase().split(/;|,/);var E,K,G;this.CurrentTag="";var H=0;var I;var J=true;for(E=0;E<F.length;E++){I=F[E].replace(/^\s+/g,"");H+=F[E].length-I.length;F[E]=I;G=false;for(K=0;K<this.PreviousTags.length&&!G;K++){if(F[E]==this.PreviousTags[K]){this.PreviousTags.splice(K,1);G=true}}if(!G){if(this.CurrentTag!=""){J=false}else{this.CurrentTag=F[E];this.CurrentTagPosition=H}}H+=F[E].length+1}if(!J){this.CurrentTag=""}this.PreviousTags=F};this.GetTagSuggestion=function(E){var F,I,G;var H=this.GetAllTags();for(F=0;F<H.length;F++){if(H[F].toLowerCase().indexOf(E)==0){G=false;for(I=0;I<this.PreviousTags.length&&!G;I++){if(this.PreviousTags[I]==H[F].toLowerCase()){G=true}}if(!G){return H[F]}}}return null};if(this.SelectedTagsHandle){this.GetCurrentTag();this.SelectedTagsHandle.onkeyup=new Function("event","return "+this.VariableName+".EditorKeyUp(event);");this.SelectedTagsHandle.onkeydown=new Function("event","return "+this.VariableName+".EditorKeyDown(event);")}}function InlineTagEditor(B,D,A,C,E){this._variableName=B;this._clientID=D;this._container=document.getElementById(A);this._content=document.getElementById(C);this._allTags=document.getElementById(E);this._callback=null;this._panelName=null;this.SetContent=function(F){var H=/\<a[^\>]*?\>(.*?)\<\/a\>/ig;var I;var J="";while((I=H.exec(F))!=null){var G=this._trim(this._stripHtml(I[1]));if(G){if(J!=""){J+="; "}J+=G}}this._content.value=J};this.SetInlineEditorPanelAndParameter=function(F,G){this._callback=G;this._panelName=F._variableName};this.GetContent=function(){if(this._callback){this._callback(this._content.value,new Function("result","eval('result = ' + result); "+this._panelName+".SetContent(result.tags);"+this._variableName+"._allTags.value = result.availableTags;"),new Function("alert('An error occured while saving or formatting tags');"))}return"..."};this.Focus=function(){try{this._content.focus()}catch(F){}};this.Resize=function(I,F,H){this._container.style.height="auto";this._content.style.height=F+"px";var K=this._calculateStyleOffset(this._container);var J=this._calculateStyleOffset(this._content);try{this._content.style.height=((F-(this._container.offsetHeight-this._content.offsetHeight))-J.Height)+"px"}catch(G){}try{this._container.style.width=(I-K.Width)+"px"}catch(G){}try{this._container.style.height=(F-K.Height)+"px"}catch(G){}if(!H){this.Resize(I,F,true)}};this._trim=function(F){return F.replace(/^\s+|\s+$/g,"")};this._stripHtml=function(F){return F.replace(/<[^>]*?>/g,"")};this._getCurrentStyleValue=function(H,I,F){var G=0;if(document.defaultView&&document.defaultView.getComputedStyle){G=parseInt(document.defaultView.getComputedStyle(H,"").getPropertyValue(I),0)}else{if(H.currentStyle){G=parseInt(H.currentStyle[F],0)}}if(!isNaN(G)){return G}else{return 0}};this._calculateStyleOffset=function(G){var F=new Object();F.Height=this._getCurrentStyleValue(G,"border-top-width","borderTopWidth")+this._getCurrentStyleValue(G,"border-bottom-width","borderBottomWidth")+this._getCurrentStyleValue(G,"padding-top","paddingTop")+this._getCurrentStyleValue(G,"padding-bottom","paddingBottom");F.Width=this._getCurrentStyleValue(G,"border-left-width","borderLeftWidth")+this._getCurrentStyleValue(G,"border-right-width","borderRightWidth")+this._getCurrentStyleValue(G,"padding-left","paddingLeft")+this._getCurrentStyleValue(G,"padding-right","paddingRight");return F}};