var ActiveNetwork=window.ActiveNetwork||{};if(!Array.__each){Array.prototype.__each=function(b){for(var a=0;a<this.length;a++){b.call(window,this[a],a,this)}}}if(!Array.__last){Array.prototype.__last=function(){if(this.length>1){return this[this.length-1]}else{return this.__first()}}}if(!Array.__first){Array.prototype.__first=function(){return this[0]}}if(!Object.eventTarget){Object.eventTarget=function(a){return window.event?window.event.srcElement:a.target}}(function(){if(ActiveNetwork&&ActiveNetwork.NearYouWidget){return}ActiveNetwork.NearYouWidget=function(a){this.initialize(a)};(function(){var b=(function(){var c=navigator.userAgent;return{ie:c.match(/MSIE\s([^;]*)/)}}());var a=(function(){return{add:function(g,e,f){var d=document.createElement(g);var c;for(c in e){if(e.hasOwnProperty(c)){d[c]=e[c]}}return f.appendChild(d)},get:function(c){return document.getElementById(c)}}}());ActiveNetwork.NearYouWidget.WIDGET_NUMBER=0;ActiveNetwork.NearYouWidget.domain="http://widgets.active.com";ActiveNetwork.NearYouWidget.searchUrl="http://widgets.active.com/widgets/nearyou/search";ActiveNetwork.NearYouWidget.defaultStylePath="/widgets/nearyou/stylesheets/";ActiveNetwork.NearYouWidget.cssFilename="default.min.css";ActiveNetwork.NearYouWidget.apiKey="45ts42zbd3tjfp25g722juwz";ActiveNetwork.NearYouWidget.isLoadingStylesheet=false;ActiveNetwork.NearYouWidget.hasLoadedStylesheet=false;ActiveNetwork.NearYouWidget.prototype=(function(){return{initialize:function(d){var c=this;this.widgetNumber=++ActiveNetwork.NearYouWidget.WIDGET_NUMBER;ActiveNetwork.NearYouWidget["searchCallback_"+this.widgetNumber]=function(e){c.doSearchCallback.call(c,e)};this.setOptions(d);this.searchCallback="ActiveNetwork.NearYouWidget.searchCallback_"+this.widgetNumber;this.searchUrl+="?api_key="+this.apiKey+"&s=date_asc&k=&f=activities&v=json&cb="+this.searchCallback+"&m=meta%3AstartDate%3Adaterange%3Atoday..";this.defaultStyleUrl=this.domain+ActiveNetwork.NearYouWidget.defaultStylePath+this.cssFilename;this.animationInterval=25;this.prefix="an-nyw";this.id=this.prefix+"_"+this.widgetNumber;this.results=[];document.write('<div class="'+this.prefix+'" id="'+this.id+'" style="width:'+this.width+"px;height:"+this.height+'px;"></div>');this.isStartIndicatorRunning=null;this.isDetailIndicatorRunning=null;this.isLoadingEvents=false;this.showing="results";this.getDefaultStyles();return this},setOptions:function(c){this.showLocationSelector=(c.showLocationSelector===undefined)?true:c.showLocationSelector;this.showActivitySelector=(c.showActivitySelector===undefined)?true:c.showActivitySelector;this.location=c.location||"";this.activity=c.activity||"";this.num=c.num||10;this.width=c.width||300;this.height=c.height||400;this.style=c.style||undefined;this.title=c.title||"Things to do Near You";this.domain=c.domain||this.domain||ActiveNetwork.NearYouWidget.domain;this.searchUrl=c.searchUrl||this.searchUrl||ActiveNetwork.NearYouWidget.searchUrl;this.cssFilename=c.cssFilename||this.cssFilename||ActiveNetwork.NearYouWidget.cssFilename;this.apiKey=c.apiKey||this.apiKey||ActiveNetwork.NearYouWidget.apiKey},remote:function(d,e){var c=a.add("script",{type:"text/javascript",src:d},document.getElementsByTagName("head")[0]);if(e){e.call(this,c)}return c},getDefaultStyles:function(){var d=this;var c=function(h,j){var i=null;if(document.defaultView&&document.defaultView.getComputedStyle){var g=document.defaultView.getComputedStyle(h,"");if(g){i=g[j]}var f=h.style[j]||i;return f}else{if(document.documentElement.currentStyle){i=h.currentStyle?h.currentStyle[j]:null;return(h.style[j]||i)}}};if(!ActiveNetwork.NearYouWidget.isLoadingStylesheet){ActiveNetwork.NearYouWidget.isLoadingStylesheet=true;a.add("link",{rel:"stylesheet",type:"text/css",href:this.defaultStyleUrl},document.getElementsByTagName("head")[0]);var e=setInterval(function(){var f=c(document.getElementById(d.id),"position");if(f==="relative"){clearInterval(e);ActiveNetwork.NearYouWidget.hasLoadedStylesheet=true}},50)}},setCustomStyles:function(){var e=this;if(this.style){var i=[];var h;for(h in this.style){if(this.style.hasOwnProperty(h)){var g=[];var d=[];switch(h){case"frame":g=["","."+this.prefix+"-detail"];break;case"title":g=["."+this.prefix+"-header h2","."+this.prefix+"-back"];break;case"window":g=["."+this.prefix+"-window","."+this.prefix+"-box"];break;case"text":g=["."+this.prefix+"-result","."+this.prefix+"-detail","."+this.prefix+"-result ."+this.prefix+"-location","."+this.prefix+"-result ."+this.prefix+"-location"];break;case"result":g=["."+this.prefix+"-result"];break;case"links":g=["."+this.prefix+"-result a","."+this.prefix+"-detail h2 a","."+this.prefix+"-contact a"];break;case"buttons":g=["."+this.prefix+"-go","."+this.prefix+"-link"];break;case"tags":g=["."+this.prefix+"-tag"];break}g.__each(function(j){var m="#"+e.id+" "+j+" { ";var k;for(k in e.style[h]){var l=e.style[h];m+=k+":"+l[k]+"; "}m+="}\n";i.push(m)})}}var c=document.createElement("style");c.type="text/css";if(b.ie){c.styleSheet.cssText=i.join(" ")}else{var f=document.createDocumentFragment();f.appendChild(document.createTextNode(i.join(" ")));c.appendChild(f)}document.getElementsByTagName("head")[0].appendChild(c)}},getEvents:function(){if(!this.isLoadingEvents){this.isLoadingEvents=true;this.clearResults();this.showSpinner();var c=this.searchUrl;if(this.activity!==""&&this.activity!=="any"){c+="+meta%3Achannel%3D"+this.activity.replace(/ /,"%2520")}c+="&l="+this.location;c+="&num="+this.num;this.remote(c)}},render:function(){var p=this;if(!ActiveNetwork.NearYouWidget.hasLoadedStylesheet){window.setTimeout(function(){p.render.call(p)},50);return this}this.setCustomStyles();var v=document.getElementById(this.id).offsetWidth;var e=document.getElementById(this.id).offsetHeight;var x=a.add("div",{className:this.prefix+"-header"},document.getElementById(this.id));a.add("h2",{},x).innerHTML=this.title;var g=a.add("div",{className:this.prefix+"-window"},document.getElementById(this.id));g.style.width=v-6+"px";var n=a.add("div",{id:this.id+"_container",className:this.prefix+"-container"},g);n.style.width=v*2+"px";n.style.height=e-95+"px";var t=a.add("div",{id:this.id+"_results",className:this.prefix+"-results"},n);var y=a.add("div",{id:this.id+"_detail",className:this.prefix+"-detail"},n);y.style.width=t.style.width=v-6+"px";y.style.height=t.style.height=e-95+"px";var j=a.add("div",{id:this.id+"_wrapper",className:this.prefix+"-wrapper"},y);var u=a.add("a",{id:this.id+"_back",className:this.prefix+"-back",href:"#"},j);u.innerHTML="&laquo; Back";u.onclick=function(B){p.show("results");return false};var m=a.add("div",{className:this.prefix+"-box"},j);var A=a.add("h2",{id:this.id+"_title",className:this.prefix+"-title"},m);a.add("a",{href:"#"},A);var c=a.add("div",{className:this.prefix+"-location"},m);a.add("span",{id:this.id+"_location_name",className:this.prefix+"-location_name"},c);a.add("span",{id:this.id+"_address",className:this.prefix+"-address"},c);a.add("span",{id:this.id+"_city",className:this.prefix+"-city"},c);a.add("span",{id:this.id+"_state",className:this.prefix+"-state"},c);a.add("span",{id:this.id+"_zip",className:this.prefix+"-zip"},c);var i=a.add("div",{className:this.prefix+"-dates"},m);a.add("span",{id:this.id+"_start_date",className:this.prefix+"-start_date"},i);a.add("span",{id:this.id+"_end_date",className:this.prefix+"-end_date"},i);var o=a.add("div",{id:this.id+"_tags",className:this.prefix+"-tags"},m);var s=a.add("div",{},o);s.style.clear="both";a.add("a",{id:this.id+"_register",className:this.prefix+"-link",href:"#",title:"Go to Active.com"},j).innerHTML="Register on Active.com &raquo;";this.showSpinner();var q=a.add("div",{className:this.prefix+"-footer"},document.getElementById(this.id));if(this.showActivitySelector||this.showLocationSelector){var f=a.add("form",{method:"post",action:"activity"},q);f.onsubmit=function(B){p.refresh();return false};if(this.showActivitySelector){var r=a.add("select",{className:this.prefix+"-activity",id:this.id+"-activity",name:this.id+"-activity"},f);var d={Any:"any",Baseball:"baseball",Basketball:"basketball",Cheerleading:"cheerleading",Cycling:"cycling","Field Hockey":"field hockey",Football:"football",Golf:"golf","Ice Hockey":"ice hockey",Lacrosse:"lacrosse","Mountain Biking":"mountain biking",Outdoors:"outdoors",Running:"running",Sailing:"sailing",Soccer:"soccer",Softball:"softball",Swimming:"swimming",Tennis:"tennis",Triathlon:"triathlon",Volleyball:"volleyball",Walking:"walking"};var k=0;r.options[k++]=new Option("Choose Activity...","",false,false);var z;for(z in d){if(d.hasOwnProperty(z)){r.options[k++]=new Option(z,d[z],false,(this.activity===d[z]))}}r.onchange=function(B){Object.eventTarget(B).parentNode.onsubmit()}}if(this.showLocationSelector){var w;if(this.location===""){w=a.add("input",{id:this.id+"-location",name:this.id+"-location",type:"text",className:this.prefix+"-location "+this.prefix+"-default",value:"zip code"},f)}else{w=a.add("input",{id:this.id+"-location",name:this.id+"-location",type:"text",className:this.prefix+"-location",value:this.location},f)}w.onfocus=function(C){var B=Object.eventTarget(C);if(B.value==="zip code"){B.value="";B.className=p.prefix+"-location"}};var h=a.add("a",{href:"#",className:this.prefix+"-go"},f);h.innerHTML="Go";h.onclick=function(B){if(document.getElementById(p.id+"-location").value!=="zip code"){Object.eventTarget(B).parentNode.onsubmit()}return false}}}var l=a.add("a",{href:"http://www.active.com",title:"Go to Active.com"},q);a.add("img",{src:this.domain+"/widgets/nearyou/images/powered_by_active.png",alt:"Powered by Active.com"},l);this.showing="results";this.getEvents();return this},destroy:function(){document.getElementById(this.id).innerHTML="";return this},doSearchCallback:function(d){var c=this;this.isLoadingEvents=false;this.hideSpinner();if(d._results.length>0){this.results=d._results;this.results.__each(function(e){var g=a.add("div",{className:c.prefix+"-result"},document.getElementById(c.id+"_results"));var f=a.add("a",{href:"#"},g);f.onclick=function(h){c.showDetail(e);return false};a.add("span",{className:c.prefix+"-title"},f).innerHTML=e.title.split("|").__first();if(e.meta.location){a.add("span",{className:c.prefix+"-location"},g).innerHTML=e.meta.city+", "+e.meta.state}a.add("span",{className:c.prefix+"-date"},g).innerHTML=c.dateFormat(e.meta.startDate)})}else{this.noResults()}},noResults:function(){a.add("div",{className:this.prefix+"-result "+this.prefix+"-empty"},document.getElementById(this.id).childNodes[1].childNodes[0].childNodes[0]).innerHTML="No events found!"},refresh:function(){if(this.showActivitySelector){var c=document.getElementById(this.id+"-activity").value;if(c==="any"){this.activity=""}else{this.activity=c}}if(this.showLocationSelector){this.location=document.getElementById(this.id+"-location").value}if(this.showing==="detail"){this.show("results")}this.getEvents()},showDetail:function(d){var e=this;var h=a.get(this.id+"_title").childNodes[0];h.innerHTML=d.title.split("|").__first();h.href=d.url+"?cmp=415";a.get(this.id+"_location_name").innerHTML=d.meta.locationName;if(d.meta.city){a.get(this.id+"_city").innerHTML=d.meta.city+","}if(d.meta.state){a.get(this.id+"_state").innerHTML=d.meta.state}if(d.meta.zip){a.get(this.id+"_zip").innerHTML=d.meta.zip}var c=a.get(this.id+"_start_date");c.innerHTML="<strong>Starts:</strong>"+this.dateFormat(d.meta.startDate);if(d.meta.startTime!=="0:00:00"){c.innerHTML+=" @ "+this.timeFormat(d.meta.startTime)}if(d.meta.startDate!==d.meta.endDate||d.meta.startTime!==d.meta.endTime){var g=a.get(this.id+"_end_date");g.innerHTML="<strong>Ends:</strong>"+this.dateFormat(d.meta.endDate);if(d.meta.endTime!=="0:00:00"){g.innerHTML+=" @ "+this.timeFormat(d.meta.endTime)}}var f=a.get(this.id+"_tags");f.innerHTML="";if(d.meta.channel){if(typeof d.meta.channel==="string"){a.add("span",{className:this.prefix+"-tag"},f).innerHTML=d.meta.channel}else{d.meta.channel.__each(function(i){a.add("span",{className:e.prefix+"-tag"},f).innerHTML=i})}}if(d.meta.splitMediaType){if(typeof d.meta.splitMediaType==="string"){a.add("span",{className:this.prefix+"-tag"},f).innerHTML=d.meta.splitMediaType}else{d.meta.splitMediaType.__each(function(i){a.add("span",{className:e.prefix+"-tag"},f).innerHTML=i.split(":").__last()})}}if(d.meta.participationCriteria){d.meta.participationCriteria.split(",").__each(function(i){a.add("span",{className:e.prefix+"-tag"},f).innerHTML=i})}a.get(this.id+"_register").href=d.url+"?cmp=415";this.show("detail")},show:function(i){var g=document.getElementById(this.id+"_container");var e=g.parentNode.offsetWidth;var f=e/(1000/this.animationInterval)*4;var h=0;var d=this;var c=function(j){var k,l;if(j==="left"){k=0;l=f;g.style.left=-e+"px"}else{if(j==="right"){k=-e;l=-f;g.style.left="0px"}}d.showInterval=setInterval(function(){var n=parseFloat(g.style.left);if(Math.ceil(h)>=e){g.style.left=k+"px";clearInterval(d.showInterval)}else{var m=n+l;g.style.left=m+"px";h+=Math.abs(l)}},d.animationInterval)};if(i==="detail"){c("right");this.showing="detail"}else{if(i==="results"){c("left");this.showing="results"}}},showSpinner:function(){a.add("img",{id:this.id+"_start-indicator",className:this.prefix+"-indicator",src:this.domain+"/widgets/nearyou/images/indicator_medium.gif"},document.getElementById(this.id+"_results"));this.isStartIndicatorRunning=true},hideSpinner:function(){document.getElementById(this.id+"_start-indicator").style.display="none";this.isStartIndicatorRunning=false},clearResults:function(){document.getElementById(this.id+"_results").innerHTML=""},dateFormat:function(d){var c=["January","February","March","April","May","June","July","August","September","October","November","December"];var e=d.split("-");return e[2]+" "+c[e[1]-1]+" "+e[0]},timeFormat:function(e){var c=e.split(":")[0];var f=e.split(":")[1];var d="am";if(c>12){c-=12;d="pm"}return c+":"+f+" "+d}}}())}())}());