// This has been autogenerated by \lib\JSMin\jsmin.exe, do not modify manually

var sg={timer:null,listItem:function(obj)
{this.getValue=function()
{return obj.value;};this.getText=function()
{return obj.value;};},dictionaryItem:function(obj)
{var propertyName;for(var key in obj)
{propertyName=key;}
this.getValue=function()
{return obj[propertyName];};this.getText=function()
{return propertyName;};},valueStore:function(hiddenFieldId)
{var jHidden=$(hiddenFieldId);this.setValue=function(text)
{jHidden.val(text);};},searchSuggest:function()
{var maxShown=10;var minChar=1;var bgColor='#AAA';var suBgColor='#FFF';var suBorderWidth=1;var suBorderStyle='solid';var suBorderColor='#666';var suColor='#000';var autoSubmit=false;var forceSuggestions=false;var me=this;var searchBox;var suggestList;this.init=function(options)
{maxShown=options.maxShown||maxShown;minChar=options.minChar||minChar;bgColor=options.bgColor||bgColor;suBgColor=options.suBgColor||suBgColor;suBorderWidth=options.suBorderWidth||suBorderWidth;suBorderStyle=options.suBorderStyle||suBorderStyle;suBorderColor=options.suBorderColor||suBorderColor;forceSuggestions=options.forceSuggestions||forceSuggestions;suColor=options.suColor||suColor;autoSubmit=options.autoSubmit||autoSubmit;if(!document.getElementById||!document.createTextNode){return;}
if(!document.getElementById(options.searchField.replace('#',''))){return;}
var itemContainer=sg.listItem;if(options.dictionaryMode)
{itemContainer=sg.dictionaryItem;}
var collectionManager=new sg.collectionManager(options.jsonUrl,itemContainer,options.loadingElementId);searchBox=new sg.searchBox(options.searchField,options.valueStore,forceSuggestions);suggestList=new sg.suggestList(collectionManager,searchBox,options.searchField+'-suggest',minChar,maxShown,forceSuggestions,{bgColor:bgColor,suBgColor:suBgColor,suBorderWidth:suBorderWidth,suBorderStyle:suBorderStyle,suBorderColor:suBorderColor,suColor:suColor},autoSubmit);suggestList.setLayout();me.eventHandlerSetup();};this.setLayout=function()
{suggestList.setLayout();};this.setItem=function(text,value)
{var obj=new Object();obj[text]=value;var item=new sg.dictionaryItem(obj);searchBox.completeWord(item);};this.eventHandlerSetup=function()
{$(document).click(function(){suggestList.hide();});$(window).resize(function(){suggestList.setLayout();});};},collectionManager:function(jsonUrl,itemContainer,loadingElementId)
{var me=this;var requested=null;var resultList=null;var listUpdatedListener=null;if(loadingElementId){$(loadingElementId).css('visibility','hidden');}
this.clearList=function()
{resultList=null;listUpdatedListener([]);};this.updateList=function(val,minChar)
{if(resultList==null)
{me.getJsonResults(val,minChar);}
else
{me.filterSuggestions(val);}};this.getJsonResults=function(text,minChar)
{var shortVal=text;if(shortVal.length>minChar)
{shortVal=shortVal.substring(0,minChar);}
if(requested==null||requested!=shortVal)
{requested=shortVal;var url=jsonUrl+shortVal;resultList=null;if(loadingElementId){$(loadingElementId).css('visibility','visible');}
$.getJSON(url,function(json){me.jsonResponseHandler(json,text);});}};this.jsonResponseHandler=function(json,val)
{if(loadingElementId){$(loadingElementId).css('visibility','hidden');}
requested=null;var jsonRet=json.suggestion;if(jsonRet)
{resultList=new Array();for(var i=0;i<jsonRet.length;i++)
{resultList.push(new itemContainer(jsonRet[i]));}
me.filterSuggestions(val);}};this.filterSuggestions=function(text)
{var matches=me.getMatches(text);listUpdatedListener(matches);};this.isInList=function(text)
{return me.getMatches(text).length!=0;};this.getMatches=function(text)
{var matches=[];if(resultList!==null)
{var text=text.toLowerCase();for(var i=0;i<resultList.length;i++)
{if(resultList[i].getText().toLowerCase().indexOf(text)==0)
{matches.push(resultList[i]);}}}
return matches;};this.getExactMatch=function(text)
{if(resultList!==null)
{var text=text.toLowerCase();for(var i=0;i<resultList.length;i++)
{if(resultList[i].getText().toLowerCase()==text)
{return resultList[i];}}}
return null;};this.listUpdated=function(listener)
{listUpdatedListener=listener;};},suggestList:function(collectionManager,searchBox,jQueryId,minChar,maxShown,forceSuggestions,cssSettings,autoSubmit)
{var me=this;var sugSel=-1;var resultList;var id=jQueryId.substring(1);var searchfield=jQueryId.split('-suggest')[0];var form=$(searchfield).parents('form').get(0);var css={position:'absolute',listStyle:'none',margin:'0',padding:'0',zIndex:'1000',backgroundColor:cssSettings.suBgColor,borderStyle:cssSettings.suBorderStyle,borderWidth:cssSettings.suBorderWidth+'px',borderColor:cssSettings.suBorderColor,color:cssSettings.suColor};$('<ul id="'+id+'"></ul>').css(css).appendTo('body').hide();var jSuggestList=$(jQueryId);collectionManager.listUpdated(function(results){if(me.ensureKeywordIntegrity())
{me.displaySuggestions(results);var exact=collectionManager.getExactMatch(searchBox.getPartialValue());searchBox.completeWord(exact);}});searchBox.keyup(function(code){me.keyup(code);});searchBox.blur(function(event){sg.timer=setTimeout(function(){me.ensureKeywordIntegrity();me.hide();},500);});searchBox.focus(function(event){me.textChanged();});this.keyup=function(code)
{if(code===38||code===40)
{return me.selectSuggestions(code);}
if(code===27)
{me.hide();}
if(code>40||code===8)
{me.textChanged();}};this.textChanged=function()
{var val=searchBox.getPartialValue();if(val.length<minChar)
{collectionManager.clearList();me.hide();}
else
{collectionManager.updateList(val,minChar);}};this.selectSuggestions=function(code)
{var selected=me.changeSelection(code);searchBox.overlayText(selected);};this.displaySuggestions=function(results)
{if(results.length>0)
{me.setResults(results);me.show();}
else
{me.hide();}};this.ensureKeywordIntegrity=function()
{if(forceSuggestions)
{var text=searchBox.getPartialValue();var val=text;while(!collectionManager.isInList(val)&&val.length>0)
{val=val.substring(0,val.length-1);}
if(val!=text)
{searchBox.setPartialValue(val);me.textChanged();return false;}}
return true;};this.setResults=function(filteredResults)
{resultList=filteredResults;var max=maxShown;if(resultList.length<max)
{max=resultList.length;}
jSuggestList.empty();for(var j=0;j<max;j++)
{var jLi=$('<li>'+resultList[j].getText()+'</li>');jSuggestList.append(jLi);wireMouseHandlers(jLi,resultList[j]);}
sugSel=-1;};this.changeSelection=function(code)
{if(code===40)
{sugSel+=1;if(sugSel===resultList.length)
{sugSel=-1;}}
else if(code===38)
{sugSel-=1;if(sugSel<-1)
{sugSel=resultList.length-1;}}
$(jQueryId+' li').css({backgroundColor:'transparent',cursor:'pointer',width:'100%'});if(sugSel!==-1)
{$(jQueryId+' li:eq('+sugSel+')').css({backgroundColor:cssSettings.bgColor});return resultList[sugSel];}
return null;};this.setLayout=function()
{var dims=searchBox.getDimensions();jSuggestList.css({left:dims.left+'px',top:dims.top+'px',width:dims.width-(cssSettings.suBorderWidth*2)+'px'});};this.show=function()
{$(jQueryId+':hidden').slideDown('fast');};this.hide=function()
{$(jQueryId+':visible').slideUp('fast').hide();};function wireMouseHandlers(jLi,listContainer)
{jLi.click(function(e){clearTimeout(sg.timer);searchBox.completeWord(listContainer);if(autoSubmit!==undefined){form.submit();}});jLi.mouseover(function(){$(jQueryId+' li').css({backgroundColor:'transparent'});$(this).css({backgroundColor:cssSettings.bgColor});});}},searchBox:function(jQueryId,valueStore,forceSuggestions)
{var me=this;var keyboardListener;var typedValue='';var jSearchField=$(jQueryId);jSearchField.attr('autocomplete','off');jSearchField.keyup(function(event){me.keyboardHandler(event);});jSearchField.click(function(e){e.stopPropagation();});this.setPartialValue=function(newValue)
{typedValue=newValue;me.setTextBoxValue(newValue);};this.setTextBoxValue=function(newValue)
{jSearchField.val(newValue);};this.getPartialValue=function()
{var rawVal=jSearchField.val();return rawVal.replace(/[!#\$%\^&\*\(\)=\{\}\\\[\]\|":;\?\/><,]/g,' ');};this.overlayText=function(itemContainer)
{var text=typedValue;if(itemContainer!=null)
{text=itemContainer.getText();me.setHiddenField(itemContainer.getValue());}
else
{me.setHiddenField('');}
this.setTextBoxValue(text);};this.completeWord=function(itemContainer)
{if(itemContainer!=null)
{me.setPartialValue(itemContainer.getText());me.setHiddenField(itemContainer.getValue());}
else
{me.setHiddenField('');}};this.setHiddenField=function(text)
{if(valueStore!=null)
{valueStore.setValue(text);}
if(forceSuggestions)
{if(text=='')
{jSearchField.css('color','#F00');}
else
{jSearchField.css('color','#000');}}};this.keyboardHandler=function(event)
{var code;if(event.keyCode)
{code=event.keyCode;}
else if(event.which)
{code=event.which;}
if(code>40||code===8)
{typedValue=me.getPartialValue();}
keyboardListener(code);};this.keyup=function(listener)
{keyboardListener=listener;};this.blur=function(listener)
{jSearchField.blur(listener);};this.focus=function(listener)
{jSearchField.focus(listener);};this.getDimensions=function()
{var offset=jSearchField.offset();return{left:offset.left,top:offset.top+jSearchField.outerHeight(),width:jSearchField.outerWidth()};};}};