function LinkSearch(){this.LINK_SEARCH_ID="LinkSearch";this.LINK_SEARCH_CLASS_NAME="linkSearch";this.LINK_SEARCH_ALL_FIELDS_PANEL_CLASS_NAME="linkSearchAllFieldsPanel";this.LINK_SEARCH_THIS_FIELD_PANEL_CLASS_NAME="linkSearchThisFieldPanel";this.LINK_SEARCH_MAIN_PANEL_CLASS_NAME="linkSearchMainPanel";this.LINK_SEARCH_THIS_FIELD_MENU_CLASS_NAME="linkSearchThisFieldMenu";this.LINK_SEARCH_ALL_FIELDS_MENU_CLASS_NAME="linkSearchAllFieldsMenu";this.LINK_SEARCH_VALUE_SEPARATOR=/;(?!\S+&)|\s>rb<\s/;this.SEARCH_THIS_FIELD="Search ";this.SEARCH_ALL_FIELDS="Search All Fields";this.SEARCH_OR_OPERATOR=" or ";this.mLinkSearchAllFieldsPanel=null;this.mLinkSearchThisFieldPanel=null;this.mLinkSearchThisFieldMenu=null;this.mLinkSearchAllFieldsMenu=null;this.mLinkSearchMainPanel=null;this.mMediaInformationContainer=null;this.mSearchPrefixUrl=null;this.mExcludedFields=null;this.mShowTimeout=0;this.mHideTimeout=0;this.mSortFields=null;this.mLinkSearch=$(document.createElement("div"));this.mLinkSearch.addClassName(this.LINK_SEARCH_CLASS_NAME);this.mLinkSearch.id=this.LINK_SEARCH_ID;this.mLinkSearch.linkSearch=this;this.init=function(){var B=this.mMediaInformationContainer.getElementsByClassName("singleValueValue");var E=this.mMediaInformationContainer.getElementsByClassName("valueFieldDisplayNameTD");for(var D=0;D<B.length;D++){var F=E[D].innerHTML.strip();if(F.endsWith(":")){F=F.substring(0,F.length-1)}if(this.isExcludedField(F)){continue}YAHOO.util.Event.addListener(B[D],"mouseover",Static_Media_Value_MouseOver);YAHOO.util.Event.addListener(E[D],"mouseover",Static_Media_Value_MouseOver)}var A=$("MediaInformation");var C=A.down(".body");YAHOO.util.Event.addListener(C,"mouseout",Static_Media_Container_Body_MouseOut);if($$("a#collapseButton")){YAHOO.util.Event.addListener($$("a#collapseButton"),"click",Static_Collapse_Button_Click)}if($$("a#middleStateButton")){YAHOO.util.Event.addListener($$("a#middleStateButton"),"click",Static_Collapse_Button_Click)}if($$("a#expandedButton")){YAHOO.util.Event.addListener($$("a#expandedButton"),"click",Static_Collapse_Button_Click)}};this.render=function(A){if(A){this.mMediaInformationContainer=A;this.mMediaInformationContainer.appendChild(this.mLinkSearch);this.init()}};this.setSearchPrefixUrl=function(A){if(A){this.mSearchPrefixUrl=A}};this.setExcludedFields=function(A){if(A){for(i=0;i<A.length;i++){A[i]=A[i].strip()}this.mExcludedFields=A}};this.setShowTimeOut=function(A){if(A&&A>0){this.mShowTimeout=A}};this.setHideTimeOut=function(A){if(A&&A>0){this.mHideTimeout=A}};this.setSort=function(A){if(A!=null){this.mSortFields=A}};this.isExcludedField=function(A){if(this.mExcludedFields!=null){for(i=0;i<this.mExcludedFields.length;i++){if(this.mExcludedFields[i].toLowerCase()==A.toLowerCase()){return true}}}return false};this.constructLinkSearchMainPanel=function(D,C,B){var A=$(document.createElement("div"));A.addClassName(this.LINK_SEARCH_MAIN_PANEL_CLASS_NAME);A.style.position="absolute";A.style.top=D+"px";A.style.left=C+"px";this.mLinkSearchAllFieldsPanel=this.constructLinkSearchAllFieldsPanel(B);this.mLinkSearchThisFieldPanel=this.constructLinkSearchThisFieldPanel(B);A.appendChild(this.mLinkSearchAllFieldsPanel);A.appendChild(this.mLinkSearchThisFieldPanel);YAHOO.util.Event.addListener(A,"mouseout",Static_Link_Search_MouseOut);return A};this.constructLinkSearchAllFieldsPanel=function(B){var A=$(document.createElement("div"));A.addClassName(this.LINK_SEARCH_ALL_FIELDS_PANEL_CLASS_NAME);A.style.cssFloat="left";A.style.styleFloat="left";A.style.backgroundColor="#CAC2B7";A.style.textAlign="center";A.innerHTML=this.SEARCH_ALL_FIELDS;YAHOO.util.Event.addListener(A,"click",Static_Field_Button_MouseClick,B);YAHOO.util.Event.addListener(A,"mouseover",Static_All_Fields_MouseOver);YAHOO.util.Event.addListener(A,"mouseout",Static_All_Fields_MouseOut);return A};this.constructLinkSearchThisFieldPanel=function(D){var A=$(document.createElement("div"));A.addClassName(this.LINK_SEARCH_THIS_FIELD_PANEL_CLASS_NAME);A.style.cssFloat="left";A.style.styleFloat="left";A.style.backgroundColor="#CAC2B7";A.style.textAlign="center";var B=D.displayName.unescapeHTML().strip();var C=document.createElement("span");C.appendChild(document.createTextNode(this.SEARCH_THIS_FIELD+" "+B));A.appendChild(C);YAHOO.util.Event.addListener(A,"click",Static_Field_Button_MouseClick,D);YAHOO.util.Event.addListener(A,"mouseover",Static_This_Field_MouseOver);YAHOO.util.Event.addListener(A,"mouseout",Static_This_Field_MouseOut);return A};this.constructLinkSearchThisFieldMenu=function(F){var E=F.fieldName.split(/]\|#/);var G=$(document.createElement("div"));var A=jshReverseString(F.fieldValue).split(this.LINK_SEARCH_VALUE_SEPARATOR);A=A.reverse();G.addClassName(this.LINK_SEARCH_THIS_FIELD_MENU_CLASS_NAME);for(i=0;i<A.length;i++){var B=i;while(E[B]==null&&B>0){B--}var C=document.createElement("a");var D=jshReverseString(A[i].strip()).unescapeHTML();C.href=this.mSearchPrefixUrl+"?q="+E[B].strip().replace(" ","")+'="'+encodeURIComponent(D)+'"'+(this.mSortFields!=null?"&sort="+this.mSortFields:"");C.appendChild(document.createTextNode(this.fixedLengthString(D)));C.style.display="block";C.style.textAlign="left";C.style.textDecoration="none";G.appendChild(C)}YAHOO.util.Event.addListener(G,"mouseover",Static_Field_Menu_MouseOver);return G};this.constructLinkSearchAllFieldsMenu=function(F){var E=F.fieldName.split(/]\|#/);var G=$(document.createElement("div"));var A=jshReverseString(F.fieldValue).split(this.LINK_SEARCH_VALUE_SEPARATOR);A=A.reverse();G.addClassName(this.LINK_SEARCH_ALL_FIELDS_MENU_CLASS_NAME);for(i=0;i<A.length;i++){var B=i;while(E[B]==null&&B>0){B--}var C=document.createElement("a");var D=jshReverseString(A[i].strip()).unescapeHTML();C.href=this.mSearchPrefixUrl+'?q=="'+encodeURIComponent(D)+'"'+(this.mSortFields!=null?"&sort="+this.mSortFields:"");C.appendChild(document.createTextNode(this.fixedLengthString(D)));C.style.display="block";C.style.textAlign="left";C.style.textDecoration="none";G.appendChild(C)}YAHOO.util.Event.addListener(G,"mouseover",Static_Field_Menu_MouseOver);return G};this.fixedLengthString=function(A){return A.truncate()};this.buildSearchQuery=function(F,A){var B=jshReverseString(F.fieldValue).split(this.LINK_SEARCH_VALUE_SEPARATOR);var E=F.fieldName.split(/<br>|<br\s*\/>|]\|#/);var D=this.mSearchPrefixUrl+"?q=";B=B.reverse();if(A){for(i=0;i<B.length;i++){if(i>0){D+=" AND ="}else{if(i==0){D+="="}}D+='"'+encodeURIComponent(jshReverseString(B[i].strip()).unescapeHTML())+'"'}}else{var C="";var G="";for(i=0;i<B.length;i++){if(i>0){D+=" AND "}if(i>=E.length){G=C}else{G=E[i].strip().replace(" ","");C=G}D+=G+'="'+encodeURIComponent(jshReverseString(B[i].strip()).unescapeHTML())+'"'}}if(D!=null&&this.mSortFields!=null){D+="&sort="+this.mSortFields}return D};this.performLinkSearch=function(B,A){window.document.location.href=this.buildSearchQuery(B,A)};this.hideLinkSearchContainer=function(A){if(A!=null&&A.descendantOf(this.mLinkSearch)){}else{if(this.mLinkSearch){while(this.mLinkSearch.hasChildNodes()){this.mLinkSearch.removeChild(this.mLinkSearch.lastChild)}}}};this.showLinkSearchContainer=function(E,A){this.hideLinkSearchContainer();if(E&&A){var B=A.up(1).getElementsByClassName("linkSearchContainer");var C=E.up("tr");var G=C.cumulativeOffset();var F={fieldName:B[0].getElementsByClassName("linkSearchFieldName")[0].innerHTML,fieldValue:B[0].getElementsByClassName("linkSearchFieldValue")[0].innerHTML,displayName:B[0].getElementsByClassName("linkSearchFieldDisplayName")[0].innerHTML};if(YAHOO.env.ua.ie>0){F.fieldValue=F.fieldValue.replace(/<BR>/,"<br> ")}var D=this.constructLinkSearchMainPanel(G[1],G[0]+C.getWidth(),F);this.mLinkSearchAllFieldsMenu=this.constructLinkSearchAllFieldsMenu(F);this.mLinkSearchThisFieldMenu=this.constructLinkSearchThisFieldMenu(F);this.mLinkSearch.appendChild(D);this.mLinkSearch.appendChild(this.mLinkSearchAllFieldsMenu);this.mLinkSearch.appendChild(this.mLinkSearchThisFieldMenu);$$("div.linkSearchThisFieldPanel")[0].style.minWidth=this.mLinkSearchAllFieldsPanel.getWidth()+"px";$$("div.linkSearchAllFieldsPanel")[0].style.minWidth=this.mLinkSearchAllFieldsPanel.getWidth()+"px"}};this.showThisFieldMenu=function(){if(this.mLinkSearchThisFieldMenu){this.mLinkSearchThisFieldMenu.style.display="block";this.mLinkSearchThisFieldMenu.style.visibility="visible";if(this.mLinkSearchThisFieldPanel){var A=this.mLinkSearchThisFieldPanel.cumulativeOffset();this.mLinkSearchThisFieldMenu.style.position="absolute";this.mLinkSearchThisFieldMenu.style.top=A[1]+this.mLinkSearchThisFieldPanel.getHeight()+5+"px";this.mLinkSearchThisFieldMenu.style.left=A[0]+"px";this.mLinkSearchThisFieldMenu.style.width=this.mLinkSearchThisFieldPanel.getWidth()+"px"}}};this.showAllFieldsMenu=function(){if(this.mLinkSearchAllFieldsMenu){this.mLinkSearchAllFieldsMenu.style.display="block";this.mLinkSearchAllFieldsMenu.style.visibility="visible";if(this.mLinkSearchAllFieldsPanel){var A=this.mLinkSearchAllFieldsPanel.cumulativeOffset();this.mLinkSearchAllFieldsMenu.style.position="absolute";this.mLinkSearchAllFieldsMenu.style.top=A[1]+this.mLinkSearchAllFieldsPanel.getHeight()+5+"px";this.mLinkSearchAllFieldsMenu.style.left=A[0]+"px";this.mLinkSearchAllFieldsMenu.style.width=this.mLinkSearchAllFieldsPanel.getWidth()+"px"}}};this.hideThisFieldMenu=function(C,B){if(B!=null&&B.descendantOf(this.mLinkSearch)&&C.className!=this.LINK_SEARCH_ALL_FIELDS_PANEL_CLASS_NAME){}else{if(C&&C.className==this.LINK_SEARCH_ALL_FIELDS_PANEL_CLASS_NAME){var A=C.up("."+this.LINK_SEARCH_CLASS_NAME).down("."+this.LINK_SEARCH_THIS_FIELD_MENU_CLASS_NAME);if(A){A.style.display="none";A.style.visibility="hidden"}}}};this.hideAllFieldsMenu=function(C,A,D){if(A!=null&&A.descendantOf(this.mLinkSearch)&&C.className!=this.LINK_SEARCH_THIS_FIELD_PANEL_CLASS_NAME){}if(D||(C&&C.className==this.LINK_SEARCH_THIS_FIELD_PANEL_CLASS_NAME)){var B=C.up("."+this.LINK_SEARCH_CLASS_NAME).down("."+this.LINK_SEARCH_ALL_FIELDS_MENU_CLASS_NAME);if(B){B.style.display="none";B.style.visibility="hidden"}}};this.resetRowStyle=function(){var B=$$("td.valueFieldDisplayNameTD");for(i=0;i<B.length;i++){B[i].up("tr").style.backgroundColor=""}var A=$$("td.valueValueTD");for(i=0;i<A.length;i++){A[i].up("tr").style.backgroundColor=""}};this.enableRowStyle=function(B,A){if(B){this.resetRowStyle();var C;C=B.up("tr");if(C){C.style.backgroundColor="#E7E1D8"}C=A.up("tr");if(C){C.style.backgroundColor="#E7E1D8"}}};this.disableRowStyle=function(B,A){var C;if(B){C=B.up("tr");if(C){C.style.backgroundColor=""}}if(A){C=A.up("tr");if(C){C.style.backgroundColor=""}}};this.destroy=function(){this.resetRowStyle();this.hideLinkSearchContainer()}}function Static_Is_Row_Style_Enabled(A){if(A&&A.style.backgroundColor==""){return false}else{return true}}function Static_Is_Same_Field(B,A){if(B&&A){if(B.up("tr")&&A.up("tr")&&B.up("tr")==A.up("tr")){return true}if(B.className=="valueFieldDisplayNameTD"&&A.descendantOf(B.up("tr").nextSiblings()[0])){return true}else{if(A.className=="valueFieldDisplayNameTD"&&B.descendantOf(B.up("tr").nextSiblings()[0])){return true}else{if((B.className=="valueValueTD"||B.className=="singleValueValue")&&A.descendantOf(B.up("tr").previousSiblings()[0])){return true}else{if((A.className=="valueValueTD"||A.className=="singleValueValue")&&B.descendantOf(A.up("tr").previousSiblings()[0])){return true}}}}}return false}function Static_Media_Value_MouseOver(H){H=jshGetEvent(H);var D=jshGetSourceElement(H);var E=".linkSearch";var B=null;var G=null;var C=H.relatedTarget||H.toElement;C=$(C);if(Static_Is_Same_Field(D,C)&&Static_Is_Row_Style_Enabled(D.up("tr"))){return }if(D){var A=$("MediaInformation");var F=A.down(E).linkSearch;if(D.className=="valueFieldDisplayNameTD"){G=D;B=D.up("tr").nextSiblings()[0].down(".singleValueValue")}else{if(D.className=="singleValueValue"){G=D.up("tr").previousSiblings()[0].down(".valueFieldDisplayNameTD");B=D}}YAHOO.util.Event.addListener(G,"mouseout",Static_Media_Value_MouseOut);YAHOO.util.Event.addListener(B,"mouseout",Static_Media_Value_MouseOut);if(G.up("tr")&&B.up("tr")){YAHOO.util.Event.addListener(G.up("tr"),"mouseout",Static_Media_Value_MouseOut);YAHOO.util.Event.addListener(B.up("tr"),"mouseout",Static_Media_Value_MouseOut)}F.enableRowStyle(G,B);F.hideLinkSearchContainer();if(linkSearchShowTimerId!=null&&linkSearchShowTimerId>0){window.clearTimeout(linkSearchShowTimerId)}linkSearchShowTimerId=window.setTimeout(function(){F.showLinkSearchContainer(G,B)},F.mShowTimeout)}else{}}function Static_Media_Container_Body_MouseOut(F){var C=jshGetSourceElement(F);var D=".linkSearch";var B=F.relatedTarget||F.toElement;B=$(B);var A=$("MediaInformation");var E=A.down(D).linkSearch;if(B==null||!B.up("#MediaInformation")){if(linkSearchHideTimerId!=null&&linkSearchHideTimerId>0){window.clearTimeout(linkSearchHideTimerId)}linkSearchHideTimerId=window.setTimeout(function(){E.hideLinkSearchContainer();E.resetRowStyle()},E.mHideTimeout)}}function Static_Media_Value_MouseOut(H){H=jshGetEvent(H);var D=jshGetSourceElement(H);var E=".linkSearch";var C=H.relatedTarget||H.toElement;C=$(C);var B=null;var G=null;var A=$("MediaInformation");var F=A.down(E).linkSearch;if(Static_Is_Same_Field(D,C)){}else{if(C==null||!C.up("#MediaInformation")){if(D.className=="valueFieldDisplayNameTD"){G=D;B=D.up("tr").nextSiblings()[0].down(".singleValueValue")}else{if(D.className=="singleValueValue"||D.className=="valueValueTD"){G=D.up("tr").previousSiblings()[0].down(".valueFieldDisplayNameTD");B=D}}if(linkSearchHideTimerId!=null&&linkSearchHideTimerId>0){window.clearTimeout(linkSearchHideTimerId)}linkSearchHideTimerId=window.setTimeout(function(){F.hideLinkSearchContainer();F.disableRowStyle(G,B)},F.mHideTimeout)}}}function Static_Link_Search_MouseOut(H){H=jshGetEvent(H);var D=jshGetSourceElement(H);var E=".linkSearch";var C=H.relatedTarget||H.toElement;C=$(C);var B=null;var G=null;var A=$("MediaInformation");var F=A.down(E).linkSearch;if(C==null||!C.up("#MediaInformation")){if(linkSearchHideTimerId!=null&&linkSearchHideTimerId>0){window.clearTimeout(linkSearchHideTimerId)}linkSearchHideTimerId=window.setTimeout(function(){F.hideLinkSearchContainer();F.resetRowStyle()},F.mHideTimeout)}}function Static_Field_Button_MouseClick(G,F){G=jshGetEvent(G);var C=jshGetSourceElement(G);var D=".linkSearch";var B=false;if(C){var A=$("MediaInformation");var E=A.down(D).linkSearch;if(C.className.indexOf("All")>=0){B=true}E.performLinkSearch(F,B)}}function Static_All_Fields_MouseOver(F){F=jshGetEvent(F);var C=jshGetSourceElement(F);var D=".linkSearch";var B=F.relatedTarget||F.toElement;B=$(B);if(C){if(linkSearchHideTimerId!=null&&linkSearchHideTimerId>0){window.clearTimeout(linkSearchHideTimerId)}var A=$("MediaInformation");var E=A.down(D).linkSearch;E.showAllFieldsMenu(C);E.hideThisFieldMenu(C,B)}}function Static_All_Fields_MouseOut(F){F=jshGetEvent(F);var C=jshGetSourceElement(F);var D=".linkSearch";var B=F.relatedTarget||F.toElement;B=$(B);if(C){var A=$("MediaInformation");var E=A.down(D).linkSearch;E.hideAllFieldsMenu(C,B)}}function Static_This_Field_MouseOver(F){F=jshGetEvent(F);var C=jshGetSourceElement(F);var D=".linkSearch";var B=F.relatedTarget||F.toElement;B=$(B);if(C){if(linkSearchHideTimerId!=null&&linkSearchHideTimerId>0){window.clearTimeout(linkSearchHideTimerId)}var A=$("MediaInformation");var E=A.down(D).linkSearch;E.showThisFieldMenu();E.hideAllFieldsMenu(C,B,true)}}function Static_This_Field_MouseOut(F){F=jshGetEvent(F);var C=jshGetSourceElement(F);var D=".linkSearch";var B=F.relatedTarget||F.toElement;B=$(B);if(C){var A=$("MediaInformation");var E=A.down(D).linkSearch;E.hideThisFieldMenu(C,B)}}function Static_Field_Menu_MouseOver(D){D=jshGetEvent(D);var B=jshGetSourceElement(D);var C=".linkSearch";var A=D.relatedTarget||D.toElement;A=$(A);if(B){if(linkSearchHideTimerId!=null&&linkSearchHideTimerId>0){window.clearTimeout(linkSearchHideTimerId)}}}function Static_Collapse_Button_Click(E){E=jshGetEvent(E);var B=jshGetSourceElement(E);var C=".linkSearch";if(B){var A=$("MediaInformation");var D=A.down(C).linkSearch;D.destroy()}};
