dojo._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","cws.cws-core"],["provide","cws._C"],["provide","cws._W"],["provide","cws._Ad"],["provide","cws.AdsCoordinator"],["provide","cws.cws-core"]],defineResource:function(_4,_5,_6){_4.provide("cws.cws-core");if(!_4._hasResource["cws._C"]){_4._hasResource["cws._C"]=true;_4.provide("cws._C");_4.declare("cws._C",null,{constructor:function(){return 0;},con:{U_F:"feedback",P_SR:"_sr",S_R:"http://api.collarity.com/collarity/cws/",P:null}});_4.declare("cws._C.ImageUtilities",null,{});_4.mixin(cws,{loadCSS:function(_7){var s=document.createElement("link");s.rel="stylesheet";s.type="text/css";s.href=_7;document.getElementsByTagName("head")[0].appendChild(s);},loadConf:function(_9){_4.io.script.get({url:_9,timeout:11000,checkString:"_cws_widgets"});},createWidgets:function(_a){if(window["cws_widget"]){_4.mixin(_a,window["cws_widget"]);}window._cws_widgets=_a;this.createWidgets2(_a);},createWidgets2:function(_b){try{var _c=false;for(var i in _b){var w=_b[i];if(w["createContainer"]&&!_4.byId(w.containerId)){var c=document.createElement("div");c.setAttribute("id",w.containerId);document.body.appendChild(c);}if(w.widgetClass&&_4.byId(w.containerId)){if(!_4["require"](w.widgetClass)){_c=true;}if(w["props"]){var _wp=w["props"];var _11=_wp.adsObject;if(_11&&_11.widgetClass){if(!_4["require"](_11.widgetClass)){_c=true;}}var _12=_wp.isFloating;if(_12){if(!_4["require"]("cws.FloatingContainerManager")){_c=true;}}}}}if(_c||_4._inFlightCount>0){_4.addOnLoad(_4.hitch(this,"createWidgets2"));}else{this._createWidgets();}}catch(e){cws.sendError({c:new cws._C().con},e);}},_aptr:null,_createWidgets:function(){if(cws.adsCoordinator=="undefined"){if(cws._aptr){clearTimeout(cws._aptr);}cws._aptr=setTimeout("cws._createWidgets()",50);}else{if(window._dneb==0){clearTimeout(cws._aptr);var p=_cws_widgets;for(var i in p){var w=p[i];cws._widgets_descriptors[i]=w;cws._widgets[i]=cws._C.CollarityWidgetFactory(w.widgetClass,w["props"],w.containerId,i);}window._dneb=1;}}},_widgets:{},_widgets_descriptors:{},_request_cache:{},GetWidgetById:function(id){for(var i in cws._widgets){if(i==id||(cws._widgets[i]&&cws._widgets[i].containerNode.id==id)){return cws._widgets[i];}}return null;},GetWidgetDescriptorByContainerId:function(id){return cws._widgets_descriptors[id];},sendError:function(ref,_1a){if(!ref||!ref.c){return;}(new Image()).src=ref.c["S_R"]+"ef?"+"appid="+(ref.appid?encodeURIComponent(ref.appid):window.collarity_appid)+"&tid="+(ref.trackerId?encodeURIComponent(ref.trackerId):"")+"&message="+encodeURIComponent(_1a.message)+"&fileName="+(_1a.fileName?encodeURIComponent(_1a.fileName):"")+"&lineNumber="+(_1a.lineNumber?encodeURIComponent(_1a.lineNumber):"")+"&name="+encodeURIComponent(_1a.name)+"&stack="+(_1a.stack?encodeURIComponent(_1a.stack):"");},sendErrorMsg:function(msg){cws.sendError({c:new cws._C().con},{message:msg,name:""});},URLParameters:null,urlParams:function(){if(!cws.URLParameters){cws.URLParameters={};var nv=window.location.search.substring(1).split("&");for(var i=0;i<nv.length;i++){var eq=nv[i].indexOf("=");cws.URLParameters[nv[i].substring(0,eq)]=decodeURIComponent(nv[i].substring(eq+1).replace(/\+/g,"%20"));}}return cws.URLParameters;},configurationParameters:{},getAdvertisementHint:function(){return "";},interactionId:Math.ceil(Math.random()*10000000000000000)});_4.mixin(cws._C,{CollarityWidgetFactory:function(_1f,_20,_21,_22){try{var _23=_4.byId(_21);if(!_23){return null;}if(!_1f||_1f.length==0){cws.sendErrorMsg("Class not found: "+_1f);return null;}var _24=_4.getObject(_1f,false,window);if(!_4.isFunction(_24)){cws.sendErrorMsg("Bad constructor: "+_1f);return null;}var _25=_4["eval"]("new "+_1f+"()");if(typeof _20!="undefined"){_4.mixin(_25,_20);}if(_25.isFloating&&cws.FloatingContainerManager){_23=cws.FloatingContainerManager.createFloatingContainer(_23);}_25.containerNode=_23;if(_25.trackerId==""){_25.trackerId=_22;}_25.setupAdvertisement();_25.postCreate();return _25;}catch(e){cws.sendErrorMsg(e.message+" ("+_1f+")");return null;}},DelayedConstruct:function(id,_27){var w=cws.GetWidgetDescriptorByContainerId(id);if(typeof w!="undefined"){w.containerId=_27.containerId;_4.mixin(w.props,_27.props);cws._C.CollarityWidgetFactory(w.widgetClass,w.props,w.containerId,id);}},truncate:function(str,_2a){return (str?(str.length<=_2a?str:str.substring(0,_2a-3)+"..."):"");},truncateWB:function(str,_2c){return (str?(str.length<=_2c?str:str.substring(0,_2c-2).replace(/\w+$/,"")+"..."):"");},stripProtocol:function(str){var _2e=["http://","https://","ftp://"];var ret=str;_4.forEach(_2e,function(i){if(str.indexOf(i)>=0){ret=str.substring(i.length);}});return ret;},GetEventDOMRef:function(e){if(!e){e=window.event;}return e.target||e.srcElement;},GetEventDOMRefImage:function(e){if(!e){e=window.event;}return e.currentTarget||e.target||e.srcElement;},GetCookieSTValue:function(){return cws._C.GetCookieObject().st;},GetCookieObject:function(_st,_34){var st=_st||"site";var _36=_34||0.5;var c=_4.cookie("compass");if(c){c=_4.queryToObject(c);st=c.t?(c.t==0?"site":"web"):st;_36=c.l?c.l:_36;}return {st:st,level:_36};},GetDateFromDTString:function(dt){if(!dt){return null;}while(dt.length<"YYYYMMDDHHMMSS".length){dt+="0";}var y=dt.substring(0,4);var m=dt.substring(4,6);var d=dt.substring(6,8);var h=dt.substring(8,10);var min=dt.substring(10,12);var s=dt.substring(12,14);var ret=new Date();ret.setTime(Date.UTC(y,m-1,d,h,min,s,0));return ret;},FEEDBACK_TYPES:{UT_S:1,UT_CS:2,UT_A:3,UT_T:4,UT_SQ:5,UT_R:6,UT_CA:7,UT_TL:8,UT_AS:9,UT_BZ:10,UT_TN:11,UT_LS:12,UT_SB:13,UT_RV:14,UT_HA:15,UT_MS:16},MONTH_NAMES:[["January","Jan"],["February","Feb"],["March","Mar"],["April","Apr"],["May","May"],["June","Jun"],["July","Jul"],["August","Aug"],["September","Sep"],["October","Oct"],["November","Nov"],["December","Dec"]],CHARSET:"utf-8"});_4.mixin(cws._C.ImageUtilities,{imageLoadErrorUrl:_4.moduleUrl("cws","themes/images/no-image.jpg"),_imageLoadHandler:function(e){var _41=cws._C.GetEventDOMRefImage(e);if(!_41){return;}var _42=e.type;if(_42=="error"||_41.width<3){var _43="on"+_42+"Handler";var _44=_41[_43];try{_4.disconnect(_44);_41[_43]=null;if(_4.isFF){delete (_41[_43]);}}catch(err){}_41.setAttribute("src",this.imageLoadErrorUrl);}},attachImageHandlers:function(cls,_46){var _47=_4.query(cls,_46);var _48=["onerror","onload"];for(var i=0;i<_47.length;i++){for(var j=0;j<_48.length;j++){var _4b=_48[j];_47[i][_4b+"Handler"]=_4.connect(_47[i],_4b,this,"_imageLoadHandler");}}}});}if(!_4._hasResource["cws._W"]){_4._hasResource["cws._W"]=true;_4.provide("cws._W");_4.declare("cws._W",null,{apiBase:"",appid:window["collarity_appid"],level:0.5,searchType:"site",number:5,url:window.location.href,query:"",target:"",feedbackType:null,resultsLookupArray:[],src:"",dir:"ltr",isRTL:false,hintText:null,documentTitleAsHintText:false,isFloating:false,mainTemplate:"",itemTemplate:"",errorTemplate:"<div class='${w.baseClass}NoResultsMessage'>${error}</div>",dateTemplate:"",adUnitId:"",adsObject:null,adsAppendTemplate:"<div id='${w.adUnitId}'></div>",trackerId:"",responseId:"",enableInteractionId:false,appendAds:false,showErrors:false,dataCB:null,errorCB:null,c:new cws._C().con,containerNode:null,serviceErrorMessage:"Service unavailable",setupAdvertisement:function(){if(this.mainTemplate!=""&&this.appendAds){var _4c="${adsTemplate}";var _4d=this.mainTemplate.indexOf(_4c);if(_4d>0){this.mainTemplate=this.mainTemplate.substring(0,_4d)+this.substitute(this.adsAppendTemplate,{})+this.mainTemplate.substring(_4d+_4c.length);}}},instantiateAdvertisement:function(){var _=this;var _a=_.adsObject;if(_a&&_.adUnitId&&_a.widgetClass&&_a["props"]){cws._C.CollarityWidgetFactory(_a.widgetClass,_a["props"],_.adUnitId,_.trackerId);}},postCreate:function(){},constructor:function(){},getWidgetParams:function(){return "";},getRequestURL:function(){return this.c["S_R"]+this.apiBase+"?appid="+encodeURIComponent(this.appid)+(this.enableInteractionId?("&iid="+cws.interactionId):"")+"&st="+this.searchType+"&l="+this.level+"&nr="+this.number+"&url="+encodeURIComponent(this.url)+"&q="+encodeURIComponent(this.query)+"&src="+encodeURIComponent(this.src)+"&pe="+encodeURIComponent(cws._C.CHARSET)+"&tid="+encodeURIComponent(this.trackerId)+"&t="+(this.hintText!=null?(encodeURIComponent(this.hintText)):(this.documentTitleAsHintText?encodeURIComponent(document.title):""))+this.getWidgetParams();},requestData:function(){var u=this.getRequestURL();if(cws._request_cache[u]){setTimeout(_4.hitch(this,"responseSuccess",cws._request_cache[u]),"1");}else{var _51=_4.io.script.get({url:u,timeout:15000,callbackParamName:"callback"});if(_51){_51.addCallback(this,"responseSuccess");_51.addErrback(this,"responseError");}}},responseSuccess:function(_52){var u=this.getRequestURL();cws._request_cache[u]=_52;if(_52.rid){this.responseId=_52.rid;}if(_52.tracking){this.sendImpression(_52.tracking);}this.storeWidgetData(_52);try{if(_52.error){this.processError({errorMessage:this.serviceErrorMessage,cause:_52.error});if(this.errorCB){try{this.errorCB(_52);}catch(err){}}}else{this.processData(_52);this.instantiateAdvertisement();if(this.dataCB){try{this.dataCB(_52);}catch(err){}}}}catch(e){cws.sendError(this,e);}},responseError:function(_54){this.processError({errorMessage:this.serviceErrorMessage,cause:_54});if(this.errorCB){try{this.errorCB(_54);}catch(err){}}},processError:function(_55){if(this.containerNode&&this.showErrors){this.containerNode.innerHTML=this.substitute(this.errorTemplate,{error:_55.errorMessage});}cws.sendError(this,{message:_55.cause,name:""});},processData:function(_56){_56=null;},recordFilter:function(_57){return _57;},substitute:function(t,m){m["w"]=this;return t.replace(/\$\{([^\s\:\}]+)(?:\:([^\s\:\}]+))?\}/g,function(_5a,key,_5c){_5a=null;_5c=null;return _4.getObject(key,true,m).toString();});},getCookie:function(){var c=_4.cookie("compass");return c?_4.queryToObject(c):{t:0,l:0.5};},addLeadingZero:function(_5e){if(_5e<10){return "0"+_5e;}else{return _5e;}},formatDateObjectToDateTemplate:function(_5f){if(!_5f){return "";}var _60=_5f.getMonth();var day=_5f.getDate();var _62=cws._C.MONTH_NAMES[_60][0];var _63=cws._C.MONTH_NAMES[_60][1]||_62.substring(0,3);var _64=_5f.getHours()%12;if(_64==0){_64=12;}return this.substitute(this.dateTemplate,{m:_60+1,mm:this.addLeadingZero(_60+1),M:_62,MMM:_63,d:day,dd:this.addLeadingZero(day),y:_5f.getFullYear(),yy:_5f.getFullYear().toString().substring(2),hour12:_64,hour24:_5f.getHours(),min:_5f.getMinutes(),mmin:this.addLeadingZero(_5f.getMinutes()),sec:_5f.getSeconds(),ssec:this.addLeadingZero(_5f.getSeconds()),ampm:(_5f.getHours()<12?"AM":"PM")});},sendFeedback:function(_65,i,rta){this.sendImpression(this.c["S_R"]+this.c["U_F"]+"?appid="+encodeURIComponent(this.appid)+"&q="+encodeURIComponent(this.query)+"&l="+this.level+"&st="+this.searchType+"&u="+encodeURIComponent(_65.u||_65.url)+"&urlType="+this.feedbackType+"&p="+i+"&t="+encodeURIComponent(_65.t)+"&s="+encodeURIComponent(cws._C.truncate(_65.s,1000))+"&tid="+encodeURIComponent(this.trackerId)+"&iid="+cws.interactionId+"&rid="+this.responseId+"&id="+encodeURIComponent(_65.id||"")+"&rta="+(_65.cl?encodeURIComponent(_65.cl):(rta?encodeURIComponent(rta):"")));},sendImpression:function(url){if(document.images){var i=new Image();i.src=url;try{document.body.appendChild(i);i.style.position="absolute";i.style.left="-100px";i.style.top="-100px";}catch(err){}}},storeWidgetData:function(_6a){if(cws.keepWidgetsData==null){var s=document.cookie.match(/col_sd=([\w\d]*)/);cws.keepWidgetsData=(s&&s[1]=="on");}if(cws.keepWidgetsData){if(!cws.widgetsData){cws.widgetsData={};}cws.widgetsData[this.trackerId+" : "+this.declaredClass]={widget:this,data:_6a};}},registerResult:function(_6c,url,_6e){if(djConfig.isDebug){console.info("Attaching feedback: "+url+", map size:"+this.resultsLookupArray.length);}this.resultsLookupArray[_6c]={url:url,feedbackObject:_6e};},attachFeedback:function(_6f,rta,_71){try{var nl=_4.query("a",_6f);var _73=0;if(!_71){_71=0;}for(var i=0;i<nl.length;++i){var _75=nl[i];var url=_75.href;var _77=this.resultsLookupArray.length;var _78=null;var _79=null;while(_78==null&&_77>0){var _7a=this.resultsLookupArray[_73].url;var idx=url.indexOf(_7a);if(idx<0){idx=decodeURIComponent(url).indexOf(_7a);_79=decodeURIComponent(url).length;}else{_79=url.length;}if((idx>=0)&&(_79==idx+_7a.length)){_78=this.resultsLookupArray[_73].feedbackObject;}else{_73=(_73+1)%this.resultsLookupArray.length;_77--;}}if(_78!=null){_75.onmousedown=_4.hitch(this,"sendFeedback",_78,_71+_73,rta);}else{if(djConfig.isDebug){console.info("Failed to find link for the following url:"+url);}}}this.resultsLookupArray.length=0;}catch(err){if(djConfig.isDebug){console.info(err);}}}});}if(!_4._hasResource["cws._Ad"]){_4._hasResource["cws._Ad"]=true;_4.provide("cws._Ad");_4.declare("cws._Ad",cws._W,{apiBase:"v2/ad_engine",feedbackType:cws._C.FEEDBACK_TYPES.UT_A,channel:"",method:"",adHeader:"",appendAds:false,target:"_blank",enableInteractionId:true,pluginExt:"{}",enableDescField:false,postCreate:function(){if(!(this.method=="search"&&this.query=="")){this.requestData();}},requestData:function(){cws.adsCoordinator.registerAdsRequest(this);}});}if(!_4._hasResource["cws.AdsCoordinator"]){_4._hasResource["cws.AdsCoordinator"]=true;_4.provide("cws.AdsCoordinator");_4.declare("cws.AdsCoordinator",cws._W,{regWids:[],procWids:{},apiBase:"v2/ad_engine",desc:"",trackerId:"ads_coordinator",queueTimeout:null,timeoutLength:500,enableInteractionId:true,constructor:function(){var s=document.cookie.match(/adsScenario=([\w\d]*)/);if(s){cws.adsScenario=s[1];}},registerAdsRequest:function(_7d){if(_4.indexOf(this.regWids,_7d)==-1){this.regWids.push(_7d);this.processQueue();}else{}},processQueue:function(){if(this.queueTimeout!=null){clearTimeout(this.queueTimeout);}this.queueTimeout=setTimeout(_4.hitch(this,this._processQueue),this.timeoutLength);},_processQueue:function(){this.queueTimeout=null;var _7e=[];var _7f=[];var _80=null;while(this.regWids.length>0){var w=this.regWids.shift();_80=_80||w.method;if(_80==w.method){_7e.push(w);this.procWids[w.trackerId]=w;}else{_7f.push(w);}}this.regWids=this.regWids.concat(_7f);if(_7e.length>0){var n=0;var _83="";var sep="";var _85=["query","method","searchType","channel","hintText","url"];for(var i=0;i<_7e.length;i++){var w=_7e[i];if(i==0){var t=this;_4.forEach(_85,function(_88){t[_88]=w[_88];});}_83+=sep+w.trackerId+"."+w.number+"."+w.channel+"."+w.pluginExt;sep=";";n+=w.number;}if(n>0){this.number=n;this.desc=_83;this.requestData();}}if(_7f.length>0){this.processQueue();}},getWidgetParams:function(){var _89="&channel="+this.channel+"&method="+this.method+cws.getAdvertisementHint()+"&desc="+encodeURIComponent(this.desc);if(cws.adsScenario&&cws.adsScenario!=""){_89+="&abtest="+cws.adsScenario;}if(window.collarity_loader_properties&&window.collarity_loader_properties.collarity_qa){_89+="&staging=true";}return _89;},processData:function(_8a){if(_8a.adsType=="google"){if(cws.googleAdsConnector){cws.googleAdsConnector.processAds(_8a,this.procWids,_4.hitch(this,this.distributeAds));}else{this.distributeLegacyGoogleAds(_8a);}}else{this.distributeAds(_8a);}},distributeAds:function(_8b){var _8c=_8b.results;var _8d={rtl:_8b.rtl,tracking:_8b.tracking,rid:_8b.rid,query:_8b.query};for(var i=0;i<_8c.length;i++){var tid=_8c[i].tid;var w=this.procWids[tid];if(w){delete (this.procWids[tid]);w.storeWidgetData(_8d);_8d.items=_8c[i].items;w.processData(_8d);if(w.dataCB){try{w.dataCB(_8d.items);}catch(err){}}}}},distributeLegacyGoogleAds:function(_91){var _92=_91.results;var _93={rtl:_91.rtl,tracking:_91.tracking,rid:_91.rid};var tid=_92[0].tid;var w=this.procWids[tid];_93.items=_92[0].items;w.processData(_93);}});cws.adsCoordinator=new cws.AdsCoordinator();}if(!_4._hasResource["cws.cws-core"]){_4._hasResource["cws.cws-core"]=true;_4.provide("cws.cws-core");_4.global.cws_core_available=true;}}};});

