Bounce.strings["error.timeout"]="The server is taking far too long to respond,it probably got distracted by something shiny. You may want to try again momentarily.";Bounce.strings["error.unknown_feed_type"]="The feed was not a recognized type.";Bounce.fetchers=[];Bounce.fetcherCount=0;BOUNCE.prototype.FeedFetcher=function(url,timeout){ this.context=Bounce;this.url=url;this.onLoad=this.defaultOnLoad;this.onLoadObject=null;this.scriptElement=null;this.results=null;this.timeout=(timeout||20) * 1000;this.timer=null;this.fetchID;this.get=function(onLoad){ var now=new Date();var scriptElement=document.createElement('script');if(onLoad){ if(typeof onLoad=='string'){ this.onLoad=eval(onLoad);if(onLoad.indexOf('.') > -1){ this.onLoadObject=eval(onLoad.substr(0,onLoad.lastIndexOf('.')));}}else{ this.onLoad=onLoad;}}if(this.url){ this.fetchID=now.getTime()+'-'+(this.context.fetcherCount++);this.context.fetchers[this.fetchID]=this;this.timer=setTimeout(this.context.varName+".fetchers['"+this.fetchID+"'].error("+this.context.varName+".strings['error.timeout'])",this.timeout);scriptElement.setAttribute("src",this.context.apiUrl+"/bounce-fetch.js?u="+escape(this.url)+"&i="+this.fetchID);this.context.body.appendChild(scriptElement);this.scriptElement=scriptElement;}else{ this.error("FeedFetcher error: A url is required in order to fetch a feed.  Panic!");}};this.load=function(string){ var feed;if(string){ clearTimeout(this.timer);if(string.charAt(0)=='{'){ feed=new Bounce.Feed("("+string+")");}else{ feed={"error":string};}if(this.onLoadObject){ this.onLoad.call(this.onLoadObject,feed)}else{ this.onLoad(feed);}}this.context.body.removeChild(this.scriptElement);delete this.results;delete this.scriptElement;delete this.context.fetchers[this.fetchID];};this.error=function(message){ this.load(message);};this.defaultOnLoad=function(feed){ if(feed.error){ alert(feed.error);}else{ alert("You must supply the FeedFetcher.get() function with a function reference.");}};};BOUNCE.prototype.MixedResultsSearch=function(group,keywords,exclude,zip,numPerPage,pageNum,affiliateID){ this.group=group;this.keywords=keywords;this.exclude=exclude;this.zip=zip;this.numPerPage=numPerPage;this.pageNum=pageNum;this.affiliateID=affiliateID;this.skipSources=[];this.context=Bounce;this.skipSource=function(name){ this.skipSources.push(name);};this.get=function(onLoad){ var fetcher=new this.context.FeedFetcher();var url=this.context.searchUrl+"?";if(this.group){ url+= "group="+this.group+"&Keywords="+escape(this.keywords)+"&output=json";if(this.zip){ url+= "&Postal="+escape(this.zip);}if(this.exclude){ url+= "&Exclude="+escape(this.exclude);}if(this.numPerPage){ url+= "&npp="+escape(this.numPerPage);}if(this.pageNum){ url+= "&page="+escape(this.pageNum);}if(this.affiliateID){ url+= "&aid="+escape(this.affiliateID);}for(var i=0;i < this.skipSources.length;i++){ url+= "&notsrc[]="+this.skipSources[i];}fetcher.url=url;fetcher.get(onLoad);return fetcher;}else{ fetcher.onLoad=onLoad;fetcher.error("MixedResultsSearch error: the 'group' parameter is required.  Panic!");return false;}};};BOUNCE.prototype.Feed=function(jsonString){ this.context=Bounce;this.months=["January","February","March","April","May","June","July","August","September","October","November","December"];this.init=function(jsonString){ var model=eval(jsonString);for(var prop in model){ this[prop]=model[prop];}for(var i=0;i < this.entries.length;i++){ if(this.entries[i].date){ this.entries[i].date=this.parseDate(this.entries[i].date);}if(!this.entries[i].snippet&&this.entries[i].content){ this.entries[i].snippet=this.createSnippet(this.entries[i].content);}this.entries[i].index=i;}};this.sortEntries=function(propertyName,sortType,direction){ var sortFunction=function(A,B){ var a=A[propertyName];var b=B[propertyName];if(sortType==SORT_ALPHABETIC){ a=a.toLowerCase();b=b.toLowerCase();}else{ a=(Number(a)||0);b=(Number(b)||0);}if(a > b){ return direction;}if(a < b){ return direction * -1;}if(A.index > B.index){ return direction;}if(A.index < B.index){ return direction;}return 0;};this.entries.sort(sortFunction);};this.parseDate=function(string){ if(string){ if(string.search(this.context.date_ISO8601) > -1){ dateBits=string.split(this.context.date_ISO8601_split);string=this.months[dateBits[1]-1]+" "+dateBits[2]+","+dateBits[0]+" "+dateBits[3];}return new Date(string);}return null;};this.createSnippet=function(text){ var snippet='';snippet=text.replace(this.context.htmlTag,'');return snippet.substr(0,this.context.snippetLength);};this.init(jsonString);};