if(window.Evri===undefined){window.Evri={};}
if(window.Evri.defineNamespace===undefined){window.Evri.defineNamespace=function(root,namespace,items){items=items||{};if(root[namespace]===undefined){root[namespace]=items;}};window.Evri.extendNamespace=function(namespace,extensions){for(var i in extensions){if(namespace[i]===undefined){namespace[i]=extensions[i];}}};window.Evri.defineClass=function(root,className,constructor){if(root[className]===undefined){root[className]=function(){constructor.apply(this,arguments);};}};window.Evri.extendClass=function(klass,extensions){for(var i in extensions){if(klass.prototype[i]===undefined){klass.prototype[i]=extensions[i];}}};};Evri.defineNamespace(Evri,"API");Evri.extendNamespace(Evri.API,{isSetup:false,requestFailed:function(options){console.log(options.httpCode+": "+options.message);},setup:function(options){options=options||{};Evri.API.Environment.setTransport(options.transport);if(Evri.API.isSetup===false){Evri.API.Transport.setup();Evri.API.isSetup=true;}}});Evri.defineNamespace(Evri.API,"Environment");Evri.extendNamespace(Evri.API.Environment,{apiHost:"api.evri.com",apiPort:80,apiVersion:"v1",staticAssetBaseUrl:"http://www.evri.com/widget",portalHost:"www.evri.com",swfProxyHost:"www.evri.com",articleInIframe:false,set:function(key,value){if(key=="Transport"){alert("Use setTransport to change transport.");}else{Evri.API.Environment[key]=value;}
return Evri.API.Environment;},setTransport:function(transport){switch(transport){case"XmlHttp":Evri.API.Transport=Evri.API.XmlHttp;break;default:Evri.API.Transport=Evri.API.CrossDomain;break;}
return Evri.API.Environment;}});Evri.defineNamespace(Evri.API,"Utilities");Evri.extendNamespace(Evri.API.Utilities,{articleTracker:{'evri-washington-post':'waporef=evri.widget.1'},Date:{relativeDate:function(date,options){var displayDate="";options=options||{};if(date!==undefined){var nowDate=new Date();var pubDate=new Date(date);var nowDateUTCEpoch=Evri.API.Utilities.Date.utcEpochFor(nowDate);var pubDateUTCEpoch=Evri.API.Utilities.Date.utcEpochFor(pubDate);var epochDiff=Math.abs(nowDateUTCEpoch-pubDateUTCEpoch);var minute=60;var hour=60*minute;var day=24*hour;var week=7*day;var months=['January','February','March','April','May','June','July','August','September','October','November','December'];if(epochDiff<week){if(epochDiff<minute){displayDate="less than a minute ago";}else if(epochDiff<hour){var minutesAgo=Math.floor(epochDiff/minute);displayDate=""+minutesAgo+" minute"+(minutesAgo==1?'':'s')+" ago";}else if(epochDiff<day){var hoursAgo=Math.floor(epochDiff/hour);displayDate=""+hoursAgo+" hour"+(hoursAgo==1?'':'s')+" ago";}else{var daysAgo=Math.floor(epochDiff/day)
displayDate=""+daysAgo+" day"+(daysAgo==1?'':'s')+" ago";}}else{displayDate=months[pubDate.getUTCMonth()]+" "+pubDate.getUTCDate()+", "+pubDate.getUTCFullYear();}}
return displayDate;},utcEpochFor:function(date){return parseInt(Date.UTC(date.getFullYear(),date.getMonth(),date.getDate(),date.getHours(),date.getMinutes(),date.getSeconds(),date.getMilliseconds())/1000);}},HTML:{attributesFrom:function(attrs){var attrString="";for(var attrName in attrs){switch(attrName){case'class':attrString+=" "+attrName+'="'+attrs[attrName].replace(/\"/,'&quot;')+'"';break;default:break;}}
return attrString;},tokenizeStringHighlights:function(session,content,matches){var tokens=[];if(matches.length>0){var startPosition=0;for(var i=0;i<matches.length;i++){var match=matches[i];if(match.start>startPosition){tokens.push(new session.models.ContentRange(content.substr(startPosition,(match.start-startPosition))));}
tokens.push(new session.models.ContentRange(content.substr(match.start,match.snippetLength),match));startPosition=match.start+match.snippetLength;}
if(startPosition<content.length){tokens.push(new session.models.ContentRange(content.substr(startPosition,(content.length-startPosition))));}}else{tokens.push(new session.models.ContentRange(content));}
return tokens;},highlightContent:function(session,content,matches,tag,attrs){attrs=attrs||{};var tokens=Evri.API.Utilities.HTML.tokenizeStringHighlights(session,content,matches);var newContent="";var startTag="<"+tag+Evri.API.Utilities.HTML.attributesFrom(attrs)+">";var endTag="</"+tag+">";for(var i=0;i<tokens.length;i++){var range=tokens[i];newContent+=(range.matchedLocation!==undefined?startTag+range.content+endTag:range.content)}
return newContent;}},String:{capitalize:function(content){return content.charAt(0).toUpperCase()+content.substring(1).toLowerCase();}},URI:{cleanDomain:function(possibleDomain){return possibleDomain;},params:function(url){var hasQueryString=url.indexOf('?')>-1?true:false;var queryParams={};if(hasQueryString){var queryString=url.substring(url.indexOf('?')+1);var queryItems=queryString.split('&');for(var i=0;i<queryItems.length;i++){var queryItem=queryItems[i].split('=');queryParams[queryItem[0]]=decodeURIComponent(queryItem[1]);}}
return queryParams;}},baseUrl:function(){var url="http://"
+Evri.API.Environment.apiHost
+(isNaN(Evri.API.Environment.apiPort)==true||parseInt(Evri.API.Environment.apiPort)==80?"":":"+Evri.API.Environment.apiPort)
+"/"
+Evri.API.Environment.apiVersion;return url;},toQueryString:function(params,options){var prefix='?';options=options||{};if(options.truncateLongValues===undefined){options.truncateLongValues=false;}
if(options.hasQueryString!==undefined&&options.hasQueryString===true){prefix='&';}
var paramsList=[];for(var key in params){if(params[key]!==undefined){if((params[key]instanceof Array)===true){for(var i=0;i<params[key].length;i++){var value=encodeURIComponent(params[key][i]);paramsList.push(key+"="+value);}}else{var value=params[key];if(typeof(value)==="string"){if(key=="text"&&options.truncateLongValues===true){value=value.substr(0,1250).replace(/\s\S+?$/,'');}}
value=encodeURIComponent(value);paramsList.push(key+"="+value);}}}
var queryString=paramsList.join("&");return prefix+queryString;},currentURI:function(){return window.location.href.split('#')[0];},getRequestDuration:function(requestKey){return((new Date()).getTime()-(parseInt(requestKey.split("_")[0])))/1000;},apiURIForPath:function(uriPath){return window.location.protocol+"//"+Evri.API.Environment.apiHost+"/"+Evri.API.Environment.apiVersion+uriPath;},portalURIForPath:function(uriPath){var hasQueryString=uriPath.indexOf('?')>-1?true:false;return window.location.protocol+"//"
+Evri.API.Environment.portalHost+uriPath
+Evri.API.Utilities.toQueryString({jsapi:window.location.host},{hasQueryString:hasQueryString});},Class:{create:function(klassName){function klass(){this.klass=klassName;this.initialize.apply(this,arguments);}
return klass;}},JSON:{bindChildrenAndAttributesToObject:function(jsonNode,target){if(target.instanceAttributes===undefined){}
for(var member in jsonNode){if(Evri.API.Utilities.JSON.isAttribute(member)===true){target[member.substring(1)]=Evri.API.Utilities.JSON.getAttributeForNode(jsonNode,member);}else{target[member]=Evri.API.Utilities.JSON.getValueForPath(jsonNode,member);}}},getAttributeForNode:function(jsonNode,attr){return jsonNode[attr];},getNodeForPath:function(jsonNode,path){var nodeSet=Evri.API.Utilities.JSON.getNodeSetForPath(jsonNode,path);var node=undefined;if(nodeSet!==undefined&&nodeSet.length>0){node=nodeSet[0];}
return node;},getNodeSetForPath:function(jsonNode,path){var traversal=Evri.API.Utilities.JSON.__traversal(jsonNode,path);var referenceNodeSet=[];if(traversal.status===true){referenceNodeSet=traversal.referenceNodeSet;}
return referenceNodeSet;},getValueForPath:function(jsonNode,path){var referenceNodeSet=Evri.API.Utilities.JSON.getNodeSetForPath(jsonNode,path);var value=null;if(referenceNodeSet!==undefined&&referenceNodeSet.length>0&&referenceNodeSet[0]['$']!==undefined){value=referenceNodeSet[0]['$'];}
return value;},getValueForNode:function(jsonNode){return(jsonNode.$===undefined?undefined:jsonNode.$);},getValueForNodeSet:function(jsonNode,path){var nodeSet=Evri.API.Utilities.JSON.getNodeSetForPath(jsonNode,path);var values=[];if(nodeSet.length>0){for(var cntr=0;cntr<nodeSet.length;cntr++){values.push(Evri.API.Utilities.JSON.getValueForNode(nodeSet[cntr]));}}
return values;},hasDescendantsForPath:function(jsonNode,path){return Evri.API.Utilities.JSON.__traversal(jsonNode,path).status;},isAttribute:function(path){return path.substring(0,1)=='@';},__traversal:function(jsonNode,path){var pathItems=path.split('/');var status=true;var referenceNode=jsonNode;var referenceNodeSet=[];for(var i=0;i<pathItems.length;i++){var pathItem=pathItems[i];if(referenceNode[pathItem]!==undefined){if((referenceNode[pathItem]instanceof Array)===true){referenceNodeSet=referenceNode[pathItem];referenceNode=referenceNodeSet[0];}else{referenceNodeSet=[referenceNode[pathItem]];referenceNode=referenceNodeSet[0];}}else{status=false;}}
return{referenceNode:referenceNode,referenceNodeSet:referenceNodeSet,status:status};}},buildMediaSourceUrl:function(pageUrl,title,defaultUrl,articleLinkTrackerKey){var mediaSourceUrl=defaultUrl;if(Evri.API.Environment.articleInIframe===true){if(articleLinkTrackerKey){var hasQueryString=pageUrl.indexOf('?')>-1?true:false;var articleLinkTrackerToken='';if(hasQueryString){articleLinkTrackerToken="&"+articleLinkTrackerKey;}
else{articleLinkTrackerToken="?"+articleLinkTrackerKey;}
pageUrl+=articleLinkTrackerToken;}
var portalUrl=window.location.protocol+"//"+Evri.API.Environment.portalHost;var widgetHostUrl=window.location.protocol+"//"+window.location.host;var mediaIFramePath="/media/article?page="+encodeURIComponent(pageUrl)+"&source="+encodeURIComponent(widgetHostUrl)+"&title="+encodeURIComponent(title);mediaSourceUrl=portalUrl+mediaIFramePath;}
else{if(articleLinkTrackerKey){var hasQueryString=mediaSourceUrl.indexOf('?')>-1?true:false;if(hasQueryString){var queryParams=Evri.API.Utilities.URI.params(mediaSourceUrl);var mediaSourceUrlStrippedQueryString=mediaSourceUrl.substring(0,mediaSourceUrl.indexOf('?'));var urlqueryTokenValue=queryParams["url"];if(urlqueryTokenValue){var articleLinkTrackerToken='';var hasQueryString=urlqueryTokenValue.indexOf('?')>-1?true:false;if(hasQueryString){articleLinkTrackerToken="&"+articleLinkTrackerKey;}
else{articleLinkTrackerToken="?"+articleLinkTrackerKey;}
queryParams["url"]=urlqueryTokenValue+articleLinkTrackerToken;mediaSourceUrlStrippedQueryString+=Evri.API.Utilities.toQueryString(queryParams);mediaSourceUrl=mediaSourceUrlStrippedQueryString;}}}}
return mediaSourceUrl;}});Evri.defineNamespace(Evri.API,"CrossDomain");Evri.extendNamespace(Evri.API.CrossDomain,{Model:{KeyGenerator:Evri.API.Utilities.Class.create('KeyGenerator')},Callbacks:{},setup:function(){Evri.API.CrossDomain.Model.KeyGenerator.prototype={initialize:function(){var self=this;var requestCounter=0;self.generateKey=function(){return""+(new Date()).getTime()+"_"+(++requestCounter);};}};Evri.API.CrossDomain.KeyGenerator=new Evri.API.CrossDomain.Model.KeyGenerator();},request:function(resource,params){if(params.uri===undefined&&params.queryToken===undefined){params.uri=Evri.API.Utilities.currentURI();}
Evri.API.CrossDomain.requestViaScriptTag(resource,params);},requestViaScriptTag:function(resource,params){var requestUrl='';if(params.isThirdPartyAPICall===true){params.appId=undefined;params.isThirdPartyAPICall=undefined;params.uri=undefined;var options={truncateLongValues:true};if(params.hasQueryString!==undefined&&params.hasQueryString===true){options.hasQueryString=true;params.hasQueryString=undefined;}
requestUrl=resource+Evri.API.Utilities.toQueryString(params,options);}
else{requestUrl=Evri.API.Utilities.baseUrl()+resource+".json"+Evri.API.Utilities.toQueryString(params,{truncateLongValues:true});}
var script=document.createElement("script");script.type="text/javascript";script.src=requestUrl;script.setAttribute("class","evri-jsonp-request");document.body.appendChild(script);},callRemoteMethod:function(session,resource,jsonpCallback,params,responseCallbacks){var requestKey=Evri.API.CrossDomain.KeyGenerator.generateKey();Evri.API.CrossDomain.Callbacks["_"+requestKey]={handler:function(responseJSON){responseJSON.requestDuration=Evri.API.Utilities.getRequestDuration(requestKey);jsonpCallback.call(null,responseJSON,responseCallbacks);}};for(var paramKey in session.sharedQueryStringParameters){params[paramKey]=session.sharedQueryStringParameters[paramKey];}
params.callback="Evri.API.CrossDomain.Callbacks._"+requestKey+".handler";if(responseCallbacks.onCreate!==undefined){responseCallbacks.onCreate.call();}
Evri.API.CrossDomain.request(resource,params);},handleJSONResponse:function(session,responseJSON,callbacks,responseHandler){var evriThingNode=responseJSON.evriThing;var responseStatus=Evri.API.Utilities.JSON.getAttributeForNode(evriThingNode,'@status');var requestDuration=responseJSON.requestDuration;if(callbacks!==undefined){var responseMessages=Evri.API.Utilities.JSON.getNodeSetForPath(evriThingNode,"messages/message");var errorMessages=[];if(responseStatus!="OK"&&responseMessages.length>1){for(var i=0;i<responseMessages.length;i++){var message=responseMessages[i];if(parseInt(message["@code"])!==0){errorMessages.push(Evri.API.Utilities.JSON.getValueForNode(message));}}}
if(responseStatus=="ERROR"&&callbacks.onFailure!==undefined){var errorMessage="An error occurred";if(errorMessages.length>=1){errorMessage=errorMessages.join("; ");}
var error=new session.models.APIError(errorMessages,{"responseJSON":responseJSON});error.requestDuration=requestDuration;callbacks.onFailure.call(null,error);return;}
var responseItem=null;if(callbacks.onLoaded!==undefined){callbacks.onLoaded.call(null,responseJSON);}
responseItem=responseHandler.call(null,responseJSON.evriThing);if(responseItem===null||responseItem===undefined){if(callbacks.onFailure!==undefined){var error=new session.models.APIError("Response object could not be instantiated",{"responseJSON":responseJSON});error.requestDuration=requestDuration;callbacks.onFailure.call(null,error);}}else{responseItem.requestDuration=requestDuration;if(callbacks.bindWith!==undefined){callbacks.bindWith.call(null,responseItem);}
callbacks.onComplete.call(null,responseItem);}}}});Evri.defineNamespace(Evri.API,"XmlHttp");Evri.defineNamespace(Evri.API,"Model");Evri.extendNamespace(Evri.API.Model,{entityTypes:['animal','bacterium','chemical','concept','condition','disorder','event','location','organism','organization','person','plant','product','substance','virus'],classes:['APIError','Article','ArticleLink','ArticleList','ContentRange','Entity','EntityConstraint','EntityList','EntityHistories','EntityHistory','EntityHistoryMention','EntityProperty','EntityPropertyList','EntityRelation','EntityRelationList','EntitySet','Facet','Graph','Image','ImageList','MatchedLocation','Media','MediaConstraint','Pair','Product','ProductList','Quote','QuoteList','Sentiment','SentimentList','SentimentSummary','SentimentSummaryList','Target','TargetList','Tweet','TweetList','TwitterQuery','TweetMatchedLocation','Video','VideoList','VideoStillImage','Zeitgeist'],generateForSession:function(session){session.models={};for(var i=0;i<Evri.API.Model.classes.length;i++){var klassName=Evri.API.Model.classes[i];Evri.API.Model.Class.create(klassName,session);}},generateResponseHandler:function(session,klass,handlerOptions){handlerOptions=handlerOptions||{};return function(responseJSON,responseCallbacks){Evri.API.Transport.handleJSONResponse(session,responseJSON,responseCallbacks,function(jsonNode){if(handlerOptions.beforeInstantiate!==undefined){switch(typeof(handlerOptions.beforeInstantiate)){case"function":jsonNode=handlerOptions.beforeInstantiate.call(null,jsonNode);break;case"string":jsonNode=Evri.API.Utilities.JSON.getNodeForPath(jsonNode,handlerOptions.beforeInstantiate);break;default:break;}}
return new(session.models[klass])(jsonNode);});};}});Evri.defineNamespace(Evri.API.Model,"Class");Evri.extendNamespace(Evri.API.Model.Class,{create:function(klassName,session){if(Evri.API.Model[klassName]._prototypeWith!==undefined){session.models[klassName]=function(){this.klass=klassName;this.session=session;this.documentationUrl=Evri.API.Utilities.portalURIForPath("/developer/jsapi/index")+"#"+klassName+"Model";this.initialize.apply(this,arguments);};for(var prototypeDef in Evri.API.Model[klassName]._prototypeWith){session.models[klassName].prototype[prototypeDef]=Evri.API.Model[klassName]._prototypeWith[prototypeDef];}}else{session.models[klassName]={};}
for(var classMethodName in Evri.API.Model[klassName]._classMethodGenerators){session.models[klassName][classMethodName]=Evri.API.Model[klassName]._classMethodGenerators[classMethodName](session);}}});Evri.defineNamespace(Evri.API.Model,"APIError");Evri.extendNamespace(Evri.API.Model.APIError,{_classMethodGenerators:{},_prototypeWith:{initialize:function(message,options){var self=this;options=options||{};self.message=message;for(var key in options){if(self[key]===undefined){self[key]=options[key];}}
return self;},instanceAttributes:['documentationUrl','klass','message'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"Article");Evri.extendNamespace(Evri.API.Model.Article,{_classMethodGenerators:{},_prototypeWith:{initialize:function(articleJSON){var self=this;Evri.API.Utilities.JSON.bindChildrenAndAttributesToObject(articleJSON,self);var linkNode=Evri.API.Utilities.JSON.getNodeForPath(articleJSON,"link");if(linkNode!==undefined){self.link=new self.session.models.ArticleLink(linkNode,self);}
self.titleMatchedLocations=[];self.contentMatchedLocations=[];var titleMatchedLocationJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(articleJSON,"titleMatchedLocations/matchedLoc");var contentMatchedLocationJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(articleJSON,"contentMatchedLocations/matchedLoc");for(var i=0;i<titleMatchedLocationJSONNodes.length;i++){self.titleMatchedLocations.push(new self.session.models.MatchedLocation(titleMatchedLocationJSONNodes[i]));}
for(var i=0;i<contentMatchedLocationJSONNodes.length;i++){self.contentMatchedLocations.push(new self.session.models.MatchedLocation(contentMatchedLocationJSONNodes[i]));}
self.titleQueryMatches=[];self.contentQueryMatches=[];for(var i=0;i<self.titleMatchedLocations.length;i++){var match=self.titleMatchedLocations[i];if(match.matchType!='nonQueryEntity'){self.titleQueryMatches.push(match);}}
for(var i=0;i<self.contentMatchedLocations.length;i++){var match=self.contentMatchedLocations[i];if(match.matchType!='nonQueryEntity'){self.contentQueryMatches.push(match);}}
self.topEntities=[];var topEntitiesJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(articleJSON,"topEntities/entity");for(var i=0;i<topEntitiesJSONNodes.length;i++){self.topEntities.push(new self.session.models.Entity(topEntitiesJSONNodes[i]));}
return self;},instanceAttributes:['belongsTo','documentationUrl','klass','author','content','contentMatchedLocations','link','mentionedEntities','published','title','titleMatchedLocations'],instanceMethods:['getContentRanges','getGraph','getHighlightedContent','getHighlightedTitle','getRelativePublicationDate','getTitleRanges'],getGraph:function(callbacks,options){var self=this;self.session.models.Graph.getForURI(self.link.sourceUrl,callbacks,options);},getHighlightedTitle:function(tag,attrs){var self=this;return Evri.API.Utilities.HTML.highlightContent(self.session,self.title,self.titleQueryMatches,tag,attrs);},getTitleRanges:function(){var self=this;return Evri.API.Utilities.HTML.tokenizeStringHighlights(self.session,self.title,self.titleMatchedLocations);},getHighlightedContent:function(tag,attrs){var self=this;return Evri.API.Utilities.HTML.highlightContent(self.session,self.content,self.contentQueryMatches,tag,attrs);},getContentRanges:function(){var self=this;return Evri.API.Utilities.HTML.tokenizeStringHighlights(self.session,self.content,self.contentMatchedLocations);},getRelativePublicationDate:function(options){var self=this;return Evri.API.Utilities.Date.relativeDate(self.published,options);}}});Evri.defineNamespace(Evri.API.Model,"Quote");Evri.extendNamespace(Evri.API.Model.Quote,{_classMethodGenerators:{findQuotesAboutEntity:function(session){return function(resource,callbacks,options){var params={};options=options||{};params["entityURI"]=resource;session.models.QuoteList.handleRequestOptions(params,options);Evri.API.Transport.callRemoteMethod(session,"/quotes/about",session.models.QuoteList.handleResponse,params,callbacks);};},findQuotesByEntity:function(session){return function(resource,callbacks,options){var params={};options=options||{};params["speaker"]=resource;session.models.QuoteList.handleRequestOptions(params,options);Evri.API.Transport.callRemoteMethod(session,"/quotes",session.models.QuoteList.handleResponse,params,callbacks);};}},_prototypeWith:{initialize:function(quoteJSON){var self=this;Evri.API.Utilities.JSON.bindChildrenAndAttributesToObject(quoteJSON,self);var articleNode=Evri.API.Utilities.JSON.getNodeForPath(quoteJSON,"article");self.article=new self.session.models.Article(articleNode);var entityNode=Evri.API.Utilities.JSON.getNodeForPath(quoteJSON,"speaker/entity");if(entityNode!==undefined){self.speaker=new self.session.models.Entity(entityNode);}
self.quoteBoundaryMatchedLocations=[];var quoteBoundaryMatchedLocationJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(quoteJSON,"quoteBoundaryMatchedLocations/matchedLoc");self.quoteBoundaryQueryMatches=[];for(var i=0;i<quoteBoundaryMatchedLocationJSONNodes.length;i++){self.quoteBoundaryMatchedLocations.push(new self.session.models.MatchedLocation(quoteBoundaryMatchedLocationJSONNodes[i]));}
for(var i=0;i<self.quoteBoundaryMatchedLocations.length;i++){var match=self.quoteBoundaryMatchedLocations[i];if(match.matchType!='nonQueryEntity'){self.quoteBoundaryQueryMatches.push(match);}}
return self;},instanceAttributes:['belongsTo','documentationUrl','klass','content','quoteBoundaryMatchedLocations','article','speaker'],instanceMethods:['getQuoteBoundaryRanges','getHighlightedContent','getRelativePublicationDate'],getQuoteBoundaryRanges:function(){var self=this;return Evri.API.Utilities.HTML.tokenizeStringHighlights(self.session,self.content,self.quoteBoundaryMatchedLocations);},getHighlightedContent:function(tag,attrs){var self=this;return Evri.API.Utilities.HTML.highlightContent(self.session,self.content,self.quoteBoundaryQueryMatches,tag,attrs);},getRelativePublicationDate:function(options){var self=this;return Evri.API.Utilities.Date.relativeDate(self.article.published,options);}}});Evri.defineNamespace(Evri.API.Model,"Sentiment");Evri.extendNamespace(Evri.API.Model.Sentiment,{findSentimentsAboutEntity:function(session,params,options,callbacks){session.models.SentimentList.handleRequestOptions(params,options);Evri.API.Transport.callRemoteMethod(session,"/sentiment/about",session.models.SentimentList.handleResponse,params,callbacks);},setParamameter:function(entityURI,sentimentSource,sentimentType){var params={};if(entityURI){params.entityURI=entityURI;}
if(sentimentSource){params.sentimentSource=sentimentSource;}
if(sentimentType){params.sentimentType=sentimentType;}
return params;},_classMethodGenerators:{findPositiveSentiments:function(session){return function(entityURI,sentimentSource,callbacks,options){options=options||{};var params=Evri.API.Model.Sentiment.setParamameter(entityURI,sentimentSource,"positive");Evri.API.Model.Sentiment.findSentimentsAboutEntity(session,params,options,callbacks);};},findNegativeSentiments:function(session){return function(entityURI,sentimentSource,callbacks,options){options=options||{};var params=Evri.API.Model.Sentiment.setParamameter(entityURI,sentimentSource,"negative");Evri.API.Model.Sentiment.findSentimentsAboutEntity(session,params,options,callbacks);};},findPositiveSentimentsAboutEverything:function(session){return function(sentimentSource,callbacks,options){this.findPositiveSentiments(null,sentimentSource,callbacks,options);};},findNegativeSentimentsAboutEverything:function(session){return function(sentimentSource,callbacks,options){this.findNegativeSentiments(null,sentimentSource,callbacks,options);};},findPositiveSentimentsByEverything:function(session){return function(entityURI,callbacks,options){this.findPositiveSentiments(entityURI,null,callbacks,options);};},findNegativeSentimentsByEverything:function(session){return function(entityURI,callbacks,options){this.findNegativeSentiments(entityURI,null,callbacks,options);};}}});Evri.defineNamespace(Evri.API.Model,"SentimentSummary");Evri.extendNamespace(Evri.API.Model.SentimentSummary,{_classMethodGenerators:{findSentimentsSummaryAboutEntity:function(session){return function(resource,callbacks,options){var params={};options=options||{};params.entityURI=resource;params.includeSummaryDetails=true;session.models.SentimentSummaryList.handleRequestOptions(params,options);Evri.API.Transport.callRemoteMethod(session,"/sentiment/summary/about",session.models.SentimentSummaryList.handleResponse,params,callbacks);};},findSentimentsSummaryByEntity:function(session){return function(resource,callbacks,options){var params={};options=options||{};params.sentimentSource=resource;params.includeSummaryDetails=true;session.models.SentimentSummaryList.handleRequestOptions(params,options);Evri.API.Transport.callRemoteMethod(session,"/sentiment/summary",session.models.SentimentSummaryList.handleResponse,params,callbacks);};}},_prototypeWith:{initialize:function(sentimentSummaryJSON){var self=this;Evri.API.Utilities.JSON.bindChildrenAndAttributesToObject(sentimentSummaryJSON,self);self.entityList=new Array();var sentimentSourceEntityList=Evri.API.Utilities.JSON.getNodeForPath(sentimentSummaryJSON,"sentimentSourceEntityList");if(sentimentSourceEntityList===undefined){sentimentSourceEntityList=Evri.API.Utilities.JSON.getNodeForPath(sentimentSummaryJSON,"sentimentSubjectEntityList");}
if(sentimentSourceEntityList){var entityList=Evri.API.Utilities.JSON.getNodeSetForPath(sentimentSourceEntityList,"entity");if(entityList!==undefined){for(var j=0;j<entityList.length;j++){var entity=new self.session.models.Entity(entityList[j]);entity.belongsTo=self;self.entityList.push(entity);}}}
return self;},instanceAttributes:['belongsTo','documentationUrl','klass','entityList'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"ArticleLink");Evri.extendNamespace(Evri.API.Model.ArticleLink,{_classMethodGenerators:{},_prototypeWith:{initialize:function(linkJSONNode,article){var self=this;Evri.API.Utilities.JSON.bindChildrenAndAttributesToObject(linkJSONNode,self);self.sourceUrl="http://"+self.hostName+self.path;var articleLinkTrackerKey=Evri.API.Utilities.articleTracker[self.session.sharedQueryStringParameters["appId"]];var defaultArticleUrl=window.location.protocol+"//"+Evri.API.Environment.portalHost+self.href;self.href=Evri.API.Utilities.buildMediaSourceUrl(self.sourceUrl,article.title,defaultArticleUrl,articleLinkTrackerKey);return self;},instanceAttributes:['documentationUrl','klass','href','path','sourceUrl'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"ArticleList");Evri.extendNamespace(Evri.API.Model.ArticleList,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'ArticleList',{beforeInstantiate:"mediaResult"});},handleEntityRelationResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'ArticleList',{beforeInstantiate:"relations/relation"});},handleTargetRelationResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'ArticleList',{beforeInstantiate:"relations/relation/targets/entity"});},handleRequestOptions:function(session){return function(params,options){var boolean_params=['includeMatchedLocations','includeTopEntities'];for(var i=0;i<boolean_params.length;i++){var paramKey=boolean_params[i];if(params[paramKey]===undefined&&options[paramKey]===true){params[paramKey]=true;}}
if(options.mediaConstraint!==undefined&&options.mediaConstraint.klass=="MediaConstraint"){var constraints=options.mediaConstraint.toParams();if(constraints.includeDomains!==undefined){params.includeDomains=constraints.includeDomains;}
if(constraints.excludedDomains!==undefined){params.excludedDomains=constraints.excludedDomains;}}
if(options.articleSnippetLength!==undefined){params.articleSnippetLength=parseInt(options.articleSnippetLength);}
if(options.resultsPerPage!==undefined){params.resultsPerPage=parseInt(options.resultsPerPage);}
if(options.includeDates!==undefined){params.includeDates=options.includeDates;}};}},_prototypeWith:{initialize:function(jsonNode){var self=this;self.articles=[];var articleListNode=Evri.API.Utilities.JSON.getNodeForPath(jsonNode,"articleList");if(articleListNode!==undefined){var articleJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(articleListNode,"article");for(var i=0;i<articleJSONNodes.length;i++){var article=new self.session.models.Article(articleJSONNodes[i]);article.belongsTo=self;self.articles.push(article);}}
return self;},instanceAttributes:['belongsTo','documentationUrl','klass','articles'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"QuoteList");Evri.extendNamespace(Evri.API.Model.QuoteList,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'QuoteList',{beforeInstantiate:"mediaResult"});},handleRequestOptions:function(session){return function(params,options){var boolean_params=['includeMatchedLocations'];for(var i=0;i<boolean_params.length;i++){var paramKey=boolean_params[i];if(params[paramKey]===undefined&&options[paramKey]===true){params[paramKey]=true;}}
if(options.resultsPerPage!==undefined){params.resultsPerPage=parseInt(options.resultsPerPage);}};}},_prototypeWith:{initialize:function(jsonNode){var self=this;self.quotes=[];var quoteListNode=Evri.API.Utilities.JSON.getNodeForPath(jsonNode,"quoteList");if(quoteListNode!==undefined){var quoteJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(quoteListNode,"quote");for(var i=0;i<quoteJSONNodes.length;i++){var quote=new self.session.models.Quote(quoteJSONNodes[i]);quote.belongsTo=self;self.quotes.push(quote);}}
return self;},instanceAttributes:['belongsTo','documentationUrl','klass','quotes'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"SentimentList");Evri.extendNamespace(Evri.API.Model.SentimentList,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'SentimentList',{beforeInstantiate:"mediaResult"});},handleRequestOptions:function(session){return function(params,options){if(params.includeMatchedLocations===undefined&&options.includeMatchedLocations===true){params.includeMatchedLocations=true;}
if(options.mediaConstraint!==undefined&&options.mediaConstraint.klass==="MediaConstraint"){var constraints=options.mediaConstraint.toParams();if(constraints.includeDomains!==undefined){params.includeDomains=constraints.includeDomains;}
if(constraints.excludedDomains!==undefined){params.excludedDomains=constraints.excludedDomains;}}
if(options.articleSnippetLength!==undefined){params.articleSnippetLength=parseInt(options.articleSnippetLength);}
if(options.resultsPerPage!==undefined){params.resultsPerPage=parseInt(options.resultsPerPage);}
if(options.sentimentType!==undefined){params.sentimentType=options.sentimentType;}
if(options.sort!==undefined){params.sort=options.sort;}};}},_prototypeWith:{initialize:function(jsonNode){var self=this;self.articles=[];var sentimentListNode=Evri.API.Utilities.JSON.getNodeForPath(jsonNode,"sentimentList");var sentimentNodes=Evri.API.Utilities.JSON.getNodeSetForPath(sentimentListNode,"sentiment");if(sentimentNodes!==undefined){for(var i=0;i<sentimentNodes.length;i++){var articleJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(sentimentNodes[i],"article");for(var j=0;j<articleJSONNodes.length;j++){var article=new self.session.models.Article(articleJSONNodes[j]);article.belongsTo=self;self.articles.push(article);}}}
return self;},instanceAttributes:['belongsTo','documentationUrl','klass','articles'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"SentimentSummaryList");Evri.extendNamespace(Evri.API.Model.SentimentSummaryList,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,"SentimentSummaryList",{beforeInstantiate:"mediaResult"});},handleRequestOptions:function(session){return function(params,options){if(params.includeMatchedLocations===undefined&&options.includeMatchedLocations===true){params.includeMatchedLocations=true;}
if(options.mediaConstraint!==undefined&&options.mediaConstraint.klass==="MediaConstraint"){var constraints=options.mediaConstraint.toParams();if(constraints.includeDomains!==undefined){params.includeDomains=constraints.includeDomains;}
if(constraints.excludedDomains!==undefined){params.excludedDomains=constraints.excludedDomains;}}
if(options.resultsPerPage!==undefined){params.resultsPerPage=parseInt(options.resultsPerPage);}
if(options.sentimentType!==undefined){params.sentimentType=options.sentimentType;}
if(options.sort!==undefined){params.sort=options.sort;}
if(options.includeSummaryDetails!==undefined){params.includeSummaryDetails=options.includeSummaryDetails;}};}},_prototypeWith:{initialize:function(jsonNode){var self=this;var sentimentSummaryListNode=Evri.API.Utilities.JSON.getNodeForPath(jsonNode,"sentimentSummaryList");var sentimentSummaryNodes=Evri.API.Utilities.JSON.getNodeSetForPath(sentimentSummaryListNode,"sentimentSummary");for(var i=0;i<sentimentSummaryNodes.length;i++){var summaryDetail=new self.session.models.SentimentSummary(sentimentSummaryNodes[i]);if(summaryDetail.type==="positive"){self.positiveSummaryDetail=summaryDetail;}
else if(summaryDetail.type==="negative"){self.negativeSummaryDetail=summaryDetail;}}
return self;},instanceAttributes:['belongsTo','documentationUrl','klass','positiveSummaryDetail','negativeSummaryDetail'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"ContentRange");Evri.extendNamespace(Evri.API.Model.ContentRange,{_classMethodGenerators:{},_prototypeWith:{initialize:function(content,matchedLocation,options){var self=this;options=options||{};self.content=content||"";self.matchedLocation=matchedLocation||undefined;return self;},instanceAttributes:['documentationUrl','klass','content','matchedLocation'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"Entity");Evri.extendNamespace(Evri.API.Model.Entity,{_classMethodGenerators:{getById:function(session){return function(entityIds,property,callbacks){Evri.API.Transport.callRemoteMethod(session,"/entities",session.models.Entity.handleResponse,{entityId:entityIds,property:property},callbacks);};},findByName:function(session){return function(name,callbacks){Evri.API.Transport.callRemoteMethod(session,"/entities/find",session.models.EntityList.handleResponse,{name:name},callbacks);};},findById:function(session){return function(entityIds,callbacks){Evri.API.Transport.callRemoteMethod(session,"/entities/find",session.models.EntityList.handleResponse,{'entityId':entityIds},callbacks);};},findByPrefix:function(session){return function(prefix,callbacks){Evri.API.Transport.callRemoteMethod(session,"/entities/find",session.models.EntityList.handleResponse,{prefix:prefix},callbacks);};},findByResource:function(session){return function(resource,callbacks){Evri.API.Transport.callRemoteMethod(session,resource,session.models.Entity.handleResponse,{},callbacks);};},handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,"Entity",{beforeInstantiate:"entity"});},parseIdFromResource:function(session){return function(resource){var entityId=undefined;if(resource.match(/0x[A-Fa-f0-9]+$/)!==null){entityId=parseInt(resource.match(/0x[A-Fa-f0-9]+$/)[0],16)}
return entityId;};}},_prototypeWith:{initialize:function(entityJSON){var self=this;Evri.API.Utilities.JSON.bindChildrenAndAttributesToObject(entityJSON,self);self.resource=self.href;self.relationsResource=self.resource+"/relations"
self.mediaResource=self.resource+"/media/related"
self.relatedEntitiesResource=self.resource+"/related/entities";self.known=false;if(self.resource!==undefined&&self.resource.match(/0x[a-fA-F0-9]+$/)!==null){self.known=true;if(self.id===undefined){self.id=self.session.models.Entity.parseIdFromResource(self.resource);}}
self.portalURI=self.resource===undefined?undefined:Evri.API.Utilities.portalURIForPath(self.resource);self.relationsServiceURI=Evri.API.Utilities.apiURIForPath(self.resource+"/relations");self.media=new self.session.models.Media(self);self.facets=[];var facetNodes=Evri.API.Utilities.JSON.getNodeSetForPath(entityJSON,"facets/facet");for(var i=0;i<facetNodes.length;i++){self.facets.push(new self.session.models.Facet(facetNodes[i]));}
self.propertyList=new self.session.models.EntityPropertyList(Evri.API.Utilities.JSON.getNodeForPath(entityJSON,"properties"));if(self.propertyList.findByName('wikipedia_paragraph').length>0){self.description=self.propertyList.findByName('wikipedia_paragraph')[0].value;}
else if(self.propertyList.findByName('crunchbase_paragraph').length>0){self.description=self.propertyList.findByName('crunchbase_paragraph')[0].value;}
return self;},instanceAttributes:['documentationUrl','klass','description','facets','href','id','known','media','mediaResource','name','portalURI','properties','relatedEntitiesResource','relationsResource','relationsServiceURI','resource','type'],instanceMethods:['getMentionStatistics','getName','getRelatedEntities','getRelations','getTopRelationsTargets','getTweetsAbout'],getRelatedEntities:function(callbacks,options){var self=this;options=options||{}
callbacks.bindWith=function(graph){self.graph=graph;graph.belongsTo=self;};if(self.queryToken!==undefined){Evri.API.Transport.callRemoteMethod(self.session,self.relatedEntitiesResource,self.session.models.Graph.handleResponse,{queryToken:self.queryToken},callbacks);}else{Evri.API.Transport.callRemoteMethod(self.session,self.relationsResource,self.session.models.EntityList.handleEntityRelationsGraphResponse,{'graphRelationsCount':(options.count!==undefined?options.count:10)},callbacks);}},getTopRelationsTargets:function(callbacks,options){var self=this;var params={};options=options||{};callbacks.bindWith=function(targetList){self.topTargetsList=targetList;targetList.belongsTo=self;};self.session.models.EntityList.handleRequestOptions(params,options);Evri.API.Transport.callRemoteMethod(self.session,self.relationsResource,self.session.models.TargetList.handleEntityRelationsGraphResponse,params,callbacks);},getRelations:function(callbacks,options){var self=this;options=options||{};callbacks.bindWith=function(relationList){self.relationList=relationList;relationList.belongsTo=self;};Evri.API.Transport.callRemoteMethod(self.session,self.relationsResource,self.session.models.EntityRelationList.handleResponse,{},callbacks);},getName:function(){var self=this;return self.name;},getMentionStatistics:function(callbacks,options){var self=this;options=options||{};callbacks.bindWith=function(entityHistory){entityHistory.belongsTo=self;};Evri.API.Transport.callRemoteMethod(self.session,"/zeitgeist/entity-history",self.session.models.EntityHistory.handleResponse,{data:"mentions",uri:self.resource,count:30,timeSpan:"day"},callbacks);},getTweetsAbout:function(callbacks,options){var self=this;options=options||{};callbacks.bindWith=function(tweetList){tweetList.belongsTo=self;};self.session.models.Tweet.findForEntityResource(self.resource,callbacks);}}});Evri.defineNamespace(Evri.API.Model,"EntityList");Evri.extendNamespace(Evri.API.Model.EntityList,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'EntityList',{beforeInstantiate:"entities"});},handleZeitgeistEntitiesPopularResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'EntityList',{beforeInstantiate:"zeitgeist/popular/entities"});},handleZeitgeistEntitiesRisingResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'EntityList',{beforeInstantiate:"zeitgeist/rising/entities"});},handleZeitgeistEntitiesFallingResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'EntityList',{beforeInstantiate:"zeitgeist/falling/entities"});},handleEntityRelationsGraphResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'EntityList',{beforeInstantiate:function(jsonNode){var relationNodes=Evri.API.Utilities.JSON.getNodeSetForPath(jsonNode,"relations/graph/relation");var responseNode={entity:[]};if(relationNodes.length>0){for(var i=0;i<relationNodes.length;i++){var entityNodes=Evri.API.Utilities.JSON.getNodeSetForPath(relationNodes[i],"targets/entity");if(entityNodes.length>0){for(var j=0;j<entityNodes.length;j++){responseNode.entity.push(entityNodes[j]);}}}}
return responseNode;}});},handleRequestOptions:function(session){return function(params,options){if(options.entityConstraint!==undefined&&options.entityConstraint.klass=="EntityConstraint"){var constraints=options.entityConstraint.toParams();if(constraints.includeDomains!==undefined){params.includeDomains=constraints.includeDomains;}
if(constraints.excludedDomains!==undefined){params.excludedDomains=constraints.excludedDomains;}}
params.graphRelationsCount=(options.count!==undefined?options.count:10);};}},_prototypeWith:{initialize:function(listJSON){var self=this;var entityNodes=Evri.API.Utilities.JSON.getNodeSetForPath(listJSON,"entity");self.entities=[];for(var i=0;i<entityNodes.length;i++){self.entities.push(new self.session.models.Entity(entityNodes[i]));}
return self;},instanceAttributes:['documentationUrl','klass','entities'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"EntityHistories");Evri.extendNamespace(Evri.API.Model.EntityHistories,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'EntityHistories',{beforeInstantiate:"entityHistories"});},findByEntityResource:function(session){return function(entityResources,callbacks,options){options=options||{};if(typeof(entityResources)==="string"){entityResources=[entityResources];}
Evri.API.Transport.callRemoteMethod(session,"/zeitgeist/entity-history",session.models.EntityHistories.handleResponse,{data:"mentions",uri:entityResources,count:30,timeSpan:"day"},callbacks);};},findForEntityList:function(session){return function(entityList,callbacks,options){options=options||{};var entityResources=[];for(var i=0;i<entityList.entities.length;i++){entityResources.push(entityList.entities[i].resource);}
Evri.API.Transport.callRemoteMethod(session,"/zeitgeist/entity-history",session.models.EntityHistories.handleResponse,{data:"mentions",uri:entityResources,count:30,timeSpan:"day"},callbacks);};}},_prototypeWith:{initialize:function(historiesJSON){var self=this;var historyJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(historiesJSON,"entityHistory");self.histories=[];self.historyMapByEntityResource={};for(var i=0;i<historyJSONNodes.length;i++){var history=new self.session.models.EntityHistory(historyJSONNodes[i])
self.histories.push(history);self.historyMapByEntityResource[history.entityResource]=history;}
return self;},instanceAttributes:['documentationUrl','klass','histories','historyMapByEntityResource'],instanceMethods:['getStatisticsForEntity'],getStatisticsForEntity:function(entity){var self=this;return self.historyMapByEntityResource[entity.resource];}}});Evri.defineNamespace(Evri.API.Model,"EntityHistory");Evri.extendNamespace(Evri.API.Model.EntityHistory,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'EntityHistory',{beforeInstantiate:"entityHistories/entityHistory"});}},_prototypeWith:{initialize:function(historyJSON){var self=this;self.entityResource=Evri.API.Utilities.JSON.getAttributeForNode(historyJSON,"@href");self.mentions=[];var mentionData=Evri.API.Utilities.JSON.getValueForPath(historyJSON,"mentions");var now=(new Date()).getTime();var dayLength=24*60*60*1000;if(mentionData!==null){var mentions=mentionData.split(/,/);var mentionsLastIndex=mentions.length-1;for(var i=0;i<=mentionsLastIndex;i++){var count=parseInt(mentions[i]);var date=new Date(now-(dayLength*(mentionsLastIndex-i)));self.mentions.push(new self.session.models.EntityHistoryMention(count,date));}}
return self;},instanceAttributes:['documentationUrl','klass','mentions'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"EntityHistoryMention");Evri.extendNamespace(Evri.API.Model.EntityHistoryMention,{_classMethodGenerators:{},_prototypeWith:{initialize:function(count,date){var self=this;self.count=count;self.date=date;return self;},instanceAttributes:['documentationUrl','klass','count','date'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"EntityProperty");Evri.extendNamespace(Evri.API.Model.EntityProperty,{_classMethodGenerators:{},_prototypeWith:{initialize:function(propertyJSON){var self=this;Evri.API.Utilities.JSON.bindChildrenAndAttributesToObject(propertyJSON,self);if(self.linkHref!==undefined){self.resource=self.linkHref;self.portalURI=Evri.API.Utilities.portalURIForPath(self.resource);}
return self;},instanceAttributes:['documentationUrl','klass','linkObjectName','linkHref','portalURI','name','resource','value'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"EntityPropertyList");Evri.extendNamespace(Evri.API.Model.EntityPropertyList,{_classMethodGenerators:{},_prototypeWith:{initialize:function(propertyListJSON){var self=this;self.properties=[];self.propertyNames=[];self.propertyMap={};if(propertyListJSON!==undefined){var propertyJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(propertyListJSON,"property");for(var i=0;i<propertyJSONNodes.length;i++){self.properties.push(new self.session.models.EntityProperty(propertyJSONNodes[i]));}
for(var i=0;i<self.properties.length;i++){var property=self.properties[i];if(self.propertyMap[property.name]===undefined){self.propertyMap[property.name]=[];}
self.propertyMap[property.name].push(property);}
for(var name in self.propertyMap){self.propertyNames.push(name);}
self.propertyNames=self.propertyNames.sort();}
return self;},instanceAttributes:['documentationUrl','klass','properties','propertyMap','propertyNames'],instanceMethods:['findByName','findHavingResource'],findByName:function(name){var self=this;var matchProperties=[];if(self.propertyMap[name]!==undefined){matchProperties=self.propertyMap[name];}
return matchProperties;},findHavingResource:function(){var self=this;var propertiesHavingResources=[];for(var i=0;i<self.properties.length;i++){var property=self.properties[i];if(property.resource!==undefined){propertiesHavingResources.push(property);}}
return propertiesHavingResources;}}});Evri.defineNamespace(Evri.API.Model,"EntityRelation");Evri.extendNamespace(Evri.API.Model.EntityRelation,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'EntityRelation');}},_prototypeWith:{initialize:function(relationJSON){var self=this;Evri.API.Utilities.JSON.bindChildrenAndAttributesToObject(relationJSON,self);self.resource=self.href;self.mediaResource=self.resource;self.portalURI=Evri.API.Utilities.portalURIForPath(self.resource);self.media=new self.session.models.Media(self,{responseHandlerMethod:"handleEntityRelationResponse",mediaTypeSpecifier:'media'});return self;},instanceAttributes:['documentationUrl','klass','href','media','mediaResource','portalURI','resource'],instanceMethods:['getName','getTargets'],getName:function(){var self=this;return self.name;},getTargets:function(callbacks,options){var self=this;options=options||{};callbacks.bindWith=function(targetList){self.targetList=targetList;targetList.belongsTo=self;};Evri.API.Transport.callRemoteMethod(self.session,self.resource,self.session.models.TargetList.handleResponse,{},callbacks);}}});Evri.defineNamespace(Evri.API.Model,"EntityRelationList");Evri.extendNamespace(Evri.API.Model.EntityRelationList,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'EntityRelationList');}},_prototypeWith:{initialize:function(listJSON){var self=this;var relationsNodeSet=Evri.API.Utilities.JSON.getNodeSetForPath(listJSON,"relations/relation");var graphNode=Evri.API.Utilities.JSON.getNodeForPath(listJSON,"relations/graph");self.relations=[];for(var i=0;i<relationsNodeSet.length;i++){self.relations.push(new self.session.models.EntityRelation(relationsNodeSet[i]));}
return self;},instanceAttributes:['documentationUrl','klass','relations'],instanceMethods:['getFacets','getVerbs'],getFacets:function(){var self=this;var facets=[];for(var i=0;i<self.relations.length;i++){var relation=self.relations[i];switch(relation.type.toLowerCase()){case"facet":facets.push(relation);break;default:break;}}
return facets;},getVerbs:function(){var self=this;var verbs=[];for(var i=0;i<self.relations.length;i++){var relation=self.relations[i];switch(relation.type.toLowerCase()){case"verb":case"qt":verbs.push(relation);break;default:break;}}
return verbs;}}});Evri.defineNamespace(Evri.API.Model,"EntitySet");Evri.extendNamespace(Evri.API.Model.EntitySet,{_classMethodGenerators:{},_prototypeWith:{initialize:function(entityResources){var self=this;self.mediaResource="/entity-set/media";var entityIds=[];for(var cntr=0;cntr<entityResources.length;cntr++){var entityId=self.session.models.Entity.parseIdFromResource(entityResources[cntr]);if(entityId!==undefined){entityIds.push(entityId);}}
self.entityIdList=entityIds.join(",");self.media=new self.session.models.Media(self);return self;},instanceAttributes:['documentationUrl','klass'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"Facet");Evri.extendNamespace(Evri.API.Model.Facet,{_classMethodGenerators:{},_prototypeWith:{initialize:function(facetJSON){var self=this;Evri.API.Utilities.JSON.bindChildrenAndAttributesToObject(facetJSON,self);return self;},instanceAttributes:['documentationUrl','klass','name'],instanceMethods:['getName'],getName:function(){return self.name;}}});Evri.defineNamespace(Evri.API.Model,"Graph");Evri.extendNamespace(Evri.API.Model.Graph,{_classMethodGenerators:{getForContent:function(session){return function(content,callbacks,options){options=options||{};var remoteMethodParams={text:content};if(options.uri!==undefined){remoteMethodParams.uri=options.uri;}
Evri.API.Transport.callRemoteMethod(session,"/media/entities",session.models.Graph.handleResponse,remoteMethodParams,callbacks);};},getForURI:function(session){return function(uri,callbacks,options){var params={uri:uri};options=options||{};if(options.nocache===true){params.nocache=true;if(uri.match(/\?/)===null){params.uri+='?nocache='+(new Date()).getTime();}else{params.uri+='&nocache='+(new Date()).getTime();}}
Evri.API.Transport.callRemoteMethod(session,"/media/entities",session.models.Graph.handleResponse,params,callbacks);};},getForCurrentPage:function(session){return function(callbacks,options){session.models.Graph.getForURI(Evri.API.Utilities.currentURI(),callbacks,options);};},handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'Graph');}},_prototypeWith:{initialize:function(jsonNode){var self=this;var entityJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(jsonNode,"graph/entities/entity");self.belongsTo=undefined;self.entities=[];self.pairs=[];for(var i=0;i<entityJSONNodes.length;i++){self.entities.push(new self.session.models.Entity(entityJSONNodes[i]));};var pairJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(jsonNode,"graph/pairs/pair");if(pairJSONNodes!==undefined){for(var i=0;i<pairJSONNodes.length;i++){var pairJSONNode=pairJSONNodes[i];var pairEntityNodes=Evri.API.Utilities.JSON.getNodeSetForPath(pairJSONNode,"entity");var entities=[];for(var j=0;j<pairEntityNodes.length;j++){entities.push(new self.session.models.Entity(pairEntityNodes[j]));}
self.pairs.push(new self.session.models.Pair(entities[0],entities[1],pairJSONNode));}}
self.queryToken=Evri.API.Utilities.JSON.getValueForPath(jsonNode,"graph/queryToken");self.media=new self.session.models.Media(self);return self;},instanceAttributes:['documentationUrl','klass','entities','media','pairs','queryToken'],instanceMethods:['getName'],getName:function(){var self=this;return self.belongsTo===undefined?"Text Content Graph":self.belongsTo.getName()+" "+self.belongsTo.klass+" Graph";}}});Evri.defineNamespace(Evri.API.Model,"Image");Evri.extendNamespace(Evri.API.Model.Image,{_classMethodGenerators:{},_prototypeWith:{initialize:function(imageJSON){var self=this;Evri.API.Utilities.JSON.bindChildrenAndAttributesToObject(imageJSON,self);var thumbnailNode=Evri.API.Utilities.JSON.getNodeForPath(imageJSON,"thumbnail");if(thumbnailNode!==undefined){self.thumbnail=new self.session.models.Image(thumbnailNode);self.clickUrl=Evri.API.Utilities.buildMediaSourceUrl(self.clickUrl,self.title,self.clickUrl);self.thumbnail.belongsTo=self;}
return self;},instanceAttributes:['belongsTo','documentationUrl','klass','articleHref','clickUrl','content','date','height','mimeType','size','thumbnail','title','url','width'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"ImageList");Evri.extendNamespace(Evri.API.Model.ImageList,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'ImageList',{beforeInstantiate:"mediaResult"});},handleTargetRelationResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'ImageList',{beforeInstantiate:"relations/relation/targets/entity"});},handleRequestOptions:function(session){return function(params,options){var acceptedOptions=['resultsPerPage'];for(var i=0;i<acceptedOptions.length;i++){var key=acceptedOptions[i];if(options[key]!==undefined){params[key]=options[key];}}
if(options.page!==undefined){var page=parseInt(options.page);var resultsPerPage=params.resultsPerPage||10;params.startId=((page-1)*resultsPerPage);}};}},_prototypeWith:{initialize:function(jsonNode){var self=this;self.images=[];var listNode=Evri.API.Utilities.JSON.getNodeForPath(jsonNode,"imageList");if(listNode!==undefined){var imageJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(listNode,"image");for(var i=0;i<imageJSONNodes.length;i++){var image=new self.session.models.Image(imageJSONNodes[i]);image.belongsTo=self;self.images.push(image);}}
return self;},instanceAttributes:['belongsTo','documentationUrl','klass','images'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"MatchedLocation");Evri.extendNamespace(Evri.API.Model.MatchedLocation,{_classMethodGenerators:{},_prototypeWith:{initialize:function(jsonNode){var self=this;self.start=parseInt(jsonNode["@startPtr"]);self.end=parseInt(jsonNode["@endPtr"]);self.href=jsonNode["@href"];self.portalURI=undefined;self.matchType=jsonNode["@matchType"];self.snippetLength=self.end-self.start+1;if(self.href!==undefined&&self.href.length>0){self.portalURI=Evri.API.Utilities.portalURIForPath(self.href);}
return self;},instanceAttributes:['documentationUrl','klass','end','href','matchType','portalURI','snippetLength','start'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"Media");Evri.extendNamespace(Evri.API.Model.Media,{getMediaByTypeGenerator:function(mediaListClass,mediaType,listsContainer){return function(callbacks,options){var self=this;var params={};options=options||{};params[self.mediaTypeSpecifier]=mediaType;if(self.belongsTo.queryToken!==undefined){params.queryToken=self.belongsTo.queryToken;}
if(self.belongsTo.entityIdList!==undefined){params.entityIdList=self.belongsTo.entityIdList;}
if(self.belongsTo.mediaParams!==undefined){for(var paramKey in self.belongsTo.mediaParams){params[paramKey]=self.belongsTo.mediaParams[paramKey];}}
callbacks.bindWith=function(list){list.belongsTo=self;self[listsContainer].push(list);};self.session.models[mediaListClass].handleRequestOptions(params,options)
Evri.API.Transport.callRemoteMethod(self.session,self.resource,self.session.models[mediaListClass][self.responseHandlerMethod],params,callbacks);};}});Evri.extendNamespace(Evri.API.Model.Media,{_classMethodGenerators:{},_prototypeWith:{initialize:function(belongsTo,options){var self=this;options=options||{}
self.belongsTo=belongsTo;self.mediaTypeSpecifier=options.mediaTypeSpecifier!==undefined?options.mediaTypeSpecifier:'type';self.responseHandlerMethod=(options.responseHandlerMethod!==undefined?options.responseHandlerMethod:"handleResponse");self.articleLists=[];self.imageLists=[];self.videoLists=[];self.productLists=[];self.tweetLists=[];self.resource=(belongsTo.mediaResource||"/media/related");return self;},instanceAttributes:['belongsTo','documentationUrl','klass','articleLists','imageLists','videoLists','productLists','tweetLists'],instanceMethods:['getArticles','getImages','getName','getVideos','getProducts','getRecommendedProducts','getTweets'],getArticles:Evri.API.Model.Media.getMediaByTypeGenerator("ArticleList","article","articleLists"),getImages:Evri.API.Model.Media.getMediaByTypeGenerator("ImageList","image","imageLists"),getVideos:Evri.API.Model.Media.getMediaByTypeGenerator("VideoList","video","videoLists"),getProducts:Evri.API.Model.Media.getMediaByTypeGenerator("ProductList","product","productLists"),getRecommendedProducts:Evri.API.Model.Media.getMediaByTypeGenerator("ProductList","productad","productLists"),getTweets:Evri.API.Model.Media.getMediaByTypeGenerator("TweetList","tweet","tweetLists"),getName:function(){var self=this;return self.belongsTo.getName()+" Media";}}});Evri.defineNamespace(Evri.API.Model,"MediaConstraint");Evri.extendNamespace(Evri.API.Model.MediaConstraint,{_classMethodGenerators:{},_prototypeWith:{initialize:function(){var self=this;self.includedDomains=[];self.excludedDomains=[];return self;},instanceAttributes:['documentationUrl','klass','excludedDomains','includedDomains'],instanceMethods:['excludeDomain','includeDomain','toParams'],excludeDomain:function(domain){var self=this;if(typeof(domain)==="string"){self.excludedDomains.push(Evri.API.Utilities.URI.cleanDomain(domain));}
return self;},includeDomain:function(domain){var self=this;if(typeof(domain)==="string"){self.includedDomains.push(Evri.API.Utilities.URI.cleanDomain(domain));}
return self;},toParams:function(){var self=this;var params={};if(self.includedDomains.length>0){params.includeDomains=self.includedDomains.join(',');}
if(self.excludedDomains.length>0){params.excludeDomains=self.excludedDomains.join(',');}
return params;}}});Evri.defineNamespace(Evri.API.Model,"EntityConstraint",Evri.API.Model.MediaConstraint);Evri.defineNamespace(Evri.API.Model,"Product");Evri.extendNamespace(Evri.API.Model.Product,{_classMethodGenerators:{},_prototypeWith:{initialize:function(productJSON){var self=this;Evri.API.Utilities.JSON.bindChildrenAndAttributesToObject(productJSON,self);var productCreatorData=["author","artist","composer","creator","director","manufacturer"];for(var cntr=0;cntr<productCreatorData.length;cntr++){var nodeName=productCreatorData[cntr];var key=nodeName.toLowerCase()+"s";self[key]=Evri.API.Utilities.JSON.getValueForNodeSet(productJSON,nodeName);}
return self;},instanceAttributes:['belongsTo','documentationUrl','klass','name','id','group','url','imageurl','rating','price','label','releaseDate','height','width','referringUri','authors','artists','composers','directors','manufacturers','creators'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"ProductList");Evri.extendNamespace(Evri.API.Model.ProductList,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'ProductList',{beforeInstantiate:"mediaResult"});},handleRequestOptions:function(session){return function(params,options){};}},_prototypeWith:{initialize:function(jsonNode){var self=this;self.products=[];var productListNode=Evri.API.Utilities.JSON.getNodeForPath(jsonNode,"productList");if(productListNode!==undefined){var productJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(productListNode,"product");for(var i=0;i<productJSONNodes.length;i++){var product=new self.session.models.Product(productJSONNodes[i]);product.belongsTo=self;self.products.push(product);}}
return self;},instanceAttributes:['belongsTo','documentationUrl','klass','products'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"Pair");Evri.extendNamespace(Evri.API.Model.Pair,{_classMethodGenerators:{},_prototypeWith:{initialize:function(entity1,entity2,pairJSON){var self=this;self.entity1=entity1;self.entity2=entity2;if(pairJSON!==undefined){Evri.API.Utilities.JSON.bindChildrenAndAttributesToObject(pairJSON,self);}
if(self.queryToken===undefined){self.mediaParams={'entityURI':[self.entity1.resource,self.entity2.resource]};}
self.media=new self.session.models.Media(self);return self;},instanceAttributes:['documentationUrl','klass','entity1','entity2','media','mediaParams','queryToken'],instanceMethods:['getName'],getName:function(){var self=this;return self.entity1.name+" => "+self.entity2.name;}}});Evri.defineNamespace(Evri.API.Model,"Target");Evri.extendNamespace(Evri.API.Model.Target,{_classMethodGenerators:{},_prototypeWith:{initialize:function(entityJSON){var self=this;self.entity=new self.session.models.Entity(entityJSON);self.href=self.entity.targetHref;self.resource=self.href;self.portalURI=Evri.API.Utilities.portalURIForPath(self.resource);self.mediaResource=self.resource;self.media=new self.session.models.Media(self,{responseHandlerMethod:"handleTargetRelationResponse",mediaTypeSpecifier:'media'});return self;},instanceAttributes:['documentationUrl','klass','entity','href','media','mediaResource','portalURI','resource'],instanceMethods:['getName'],getName:function(){var self=this;return self.entity.getName();}}});Evri.defineNamespace(Evri.API.Model,"TargetList");Evri.extendNamespace(Evri.API.Model.TargetList,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'TargetList',{beforeInstantiate:"relations/relation/targets"});},handleEntityRelationsGraphResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'TargetList',{beforeInstantiate:function(jsonNode){var relationNodes=Evri.API.Utilities.JSON.getNodeSetForPath(jsonNode,"relations/graph/relation");var responseNode={entity:[]};if(relationNodes.length>0){for(var i=0;i<relationNodes.length;i++){var entityNodes=Evri.API.Utilities.JSON.getNodeSetForPath(relationNodes[i],"targets/entity");if(entityNodes.length>0){for(var j=0;j<entityNodes.length;j++){responseNode.entity.push(entityNodes[j]);}}}}
return responseNode;}});}},_prototypeWith:{initialize:function(targetsJSON){var self=this;var targetNodes=Evri.API.Utilities.JSON.getNodeSetForPath(targetsJSON,"entity");self.targets=[];for(var i=0;i<targetNodes.length;i++){self.targets.push(new self.session.models.Target(targetNodes[i]));}
return self;},instanceAttributes:['documentationUrl','klass','targets'],instanceMethods:['getName'],getName:function(){var self=this;return"Targets for '"+self.belongsTo.getName()+"' EntityRelation";}}});Evri.defineNamespace(Evri.API.Model,"Tweet");Evri.extendNamespace(Evri.API.Model.Tweet,{_classMethodGenerators:{findForQuery:function(session){return function(query,callbacks){Evri.API.Transport.callRemoteMethod(session,"/mashups/twitter/tag",session.models.TweetList.handleResponse,{'q':query},callbacks);};},findForEntityResource:function(session){return function(entityResource,callbacks){Evri.API.Transport.callRemoteMethod(session,"/mashups/twitter/tag",session.models.TweetList.handleResponse,{'entityURI':entityResource},callbacks);};},findFromUsername:function(session){return function(username,callbacks){var query="from:"+username.replace('@','');session.models.Tweet.findForQuery(query,callbacks);};},findToUsername:function(session){return function(username,callbacks){var query="to:"+username.replace('@','');session.models.Tweet.findForQuery(query,callbacks);};},getFindForEntityResourceFunction:function(session){return function(entityResource,callbacks){Evri.API.Transport.callRemoteMethod(session,"/mashups/twitter/query",session.models.TwitterQuery.handleResponse,{'entityURI':entityResource},callbacks);};},callTwitterForEntityResource:function(session){return function(twitterQuery,callbacks){Evri.API.Transport.callRemoteMethod(session,twitterQuery,session.models.TweetList.handleTwitterResponse,{isThirdPartyAPICall:true,hasQueryString:true},callbacks);};}},_prototypeWith:{initialize:function(tweetJSON){var self=this;var twitterEntryJSON=Evri.API.Utilities.JSON.getNodeForPath(tweetJSON,"twitterEntry");Evri.API.Utilities.JSON.bindChildrenAndAttributesToObject(twitterEntryJSON,self);self.matchedLocations=[];self.entityResources=[];self.entityIds=[];var entityResourcesNodes=Evri.API.Utilities.JSON.getNodeSetForPath(tweetJSON,"entities/taggedEntityData/entityUris/string");for(var i=0;i<entityResourcesNodes.length;i++){var resource=Evri.API.Utilities.JSON.getValueForNode(entityResourcesNodes[i]);self.entityResources.push(resource);var entityId=self.session.models.Entity.parseIdFromResource(resource);if(entityId!==undefined){self.entityIds.push(entityId);}}
var entityMatchedLocations=Evri.API.Utilities.JSON.getNodeSetForPath(tweetJSON,"entities/taggedEntityData/entityLocations/location");for(var i=0;i<entityMatchedLocations.length;i++){self.matchedLocations.push(new self.session.models.TweetMatchedLocation(entityMatchedLocations[i],self.entityResources));}
return self;},instanceAttributes:['documentationUrl','klass','belongsTo','authorName','authorURI','content','entityIds','entityResources','id','imageURI','matchedLocations','permalink','published','title','updated'],instanceMethods:['getEntityDetails','getRelativePublicationDate','getTitleRanges'],getEntityDetails:function(callbacks){var self=this;self.session.models.Entity.findById(self.entityIds,callbacks)},getRelativePublicationDate:function(options){var self=this;return Evri.API.Utilities.Date.relativeDate(self.published,options);},getTitleRanges:function(){var self=this;return Evri.API.Utilities.HTML.tokenizeStringHighlights(self.session,self.title,self.matchedLocations);}}});Evri.defineNamespace(Evri.API.Model,"TweetList");Evri.extendNamespace(Evri.API.Model.TweetList,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,"TweetList",{beforeInstantiate:"twitterNet/twitterEntryData"});},handleTwitterResponse:function(session){return function(responseJSON,responseCallbacks){if(responseCallbacks!==undefined){if(responseJSON!==null){if(responseJSON.error!==undefined){var error=new session.models.APIError(responseJSON.error,{"responseJSON":responseJSON});responseCallbacks.onFailure.call(null,error);}
else{var responseItem=new(session.models["TweetList"])(responseJSON,{twitterResponse:true});responseCallbacks.onComplete.call(null,responseItem);}}
else{var error=new session.models.APIError("Response object is null");responseCallbacks.onFailure.call(null,error);}}};},handleRequestOptions:function(session){return function(params,options){};}},_prototypeWith:{initialize:function(tweetListJSON,options){var self=this;options=options||{};self.tweets=[];self.entityIds=[];self.entityResources=[];var tweetNodes=[];if(options.twitterResponse===true){tweetNodes=Evri.API.Utilities.JSON.getNodeSetForPath(tweetListJSON,"results");}
else{tweetNodes=Evri.API.Utilities.JSON.getNodeSetForPath(tweetListJSON,"taggedTwitterEntryData");}
var entityIdsMap={};var entityResourcesMap={};for(var i=0;i<tweetNodes.length;i++){var tweetNode=tweetNodes[i];var tweet=new self.session.models.Tweet(tweetNode);if(options.twitterResponse===true){tweet.authorName=tweetNode.from_user;tweet.authorURI="http://www.twitter.com/"+tweetNode.from_user;tweet.content=tweetNode.text;tweet.title=tweetNode.text;tweet.imageURI=tweetNode.profile_image_url;tweet.published=tweetNode.created_at;tweet.id=tweetNode.id;tweet.permalink='';tweet.updated='';}
self.tweets.push(tweet);for(var j=0;j<tweet.entityIds.length;j++){var entityId=tweet.entityIds[j];if(entityIdsMap[entityId]===undefined){entityIdsMap[entityId]=1;self.entityIds.push(entityId);}}
for(var j=0;j<tweet.entityResources.length;j++){var resource=tweet.entityResources[j];if(entityResourcesMap[resource]===undefined){entityResourcesMap[resource]=1;self.entityResources.push(resource);}}}
return self;},instanceAttributes:['entityIds','entityResources','tweets'],instanceMethods:['getEntityDetails'],getEntityDetails:function(callbacks){var self=this;self.session.models.Entity.findById(self.entityIds,callbacks)}}});Evri.defineNamespace(Evri.API.Model,"TweetMatchedLocation");Evri.extendNamespace(Evri.API.Model.TweetMatchedLocation,{_classMethodGenerators:{},_prototypeWith:{initialize:function(locationJSON,entityResources){var self=this;var entityIndex=parseInt(Evri.API.Utilities.JSON.getValueForPath(locationJSON,"ei"));self.href=entityResources[entityIndex];self.start=parseInt(Evri.API.Utilities.JSON.getValueForPath(locationJSON,"sp"));self.end=parseInt(Evri.API.Utilities.JSON.getValueForPath(locationJSON,"ep"));self.snippetLength=self.end-self.start;self.portalURI=Evri.API.Utilities.portalURIForPath(self.href);return self;},instanceAttributes:['documentationUrl','klass','end','href','portalURI','snippetLength','start',],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"TwitterQuery");Evri.extendNamespace(Evri.API.Model.TwitterQuery,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,"TwitterQuery",{beforeInstantiate:"twitterResult"});},handleRequestOptions:function(session){return function(params,options){};}},_prototypeWith:{initialize:function(twitterQueryJSON){var self=this;var twitterQueryJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(twitterQueryJSON,"query");if(twitterQueryJSONNodes.length>0){self.twitterSearchAPI=Evri.API.Utilities.JSON.getValueForNode(twitterQueryJSONNodes[0]);self.callTwitterForEntityResource=function(callbacks){self.session.models.Tweet.callTwitterForEntityResource(self.twitterSearchAPI,callbacks);};}
return self;},instanceAttributes:['twitterSearchAPI'],instanceMethods:['findByResource']}});Evri.defineNamespace(Evri.API.Model,"Video");Evri.extendNamespace(Evri.API.Model.Video,{_classMethodGenerators:{},_prototypeWith:{initialize:function(videoJSON){var self=this;Evri.API.Utilities.JSON.bindChildrenAndAttributesToObject(videoJSON,self);var thumbnailNodes=Evri.API.Utilities.JSON.getNodeSetForPath(videoJSON,"thumbnails/image");self.thumbnails=[];for(var i=0;i<thumbnailNodes.length;i++){var thumbnail=new self.session.models.VideoStillImage(thumbnailNodes[i]);thumbnail.belongsTo=self;self.thumbnails.push(thumbnail);}
return self;},instanceAttributes:['belongsTo','documentationUrl','klass','author','content','duration','id','medium','thumbnails','title','type','url'],instanceMethods:['getSourceUrl'],getSourceUrl:function(){var self=this;var sourceUrl="";if(self.id.match(/gdata\.youtube\.com/)!==-1){var youtubeBaseUrl="http://www.youtube.com/watch?v=";var urlComponents=self.id.split("/");var youtubeVideoId=urlComponents[urlComponents.length-1];sourceUrl=youtubeBaseUrl+youtubeVideoId;}
return sourceUrl;}}});Evri.defineNamespace(Evri.API.Model,"VideoList");Evri.extendNamespace(Evri.API.Model.VideoList,{_classMethodGenerators:{handleResponse:function(session){return Evri.API.Model.generateResponseHandler(session,'VideoList',{beforeInstantiate:"mediaResult"});},handleTargetRelationResponse:function(session){Evri.API.Model.generateResponseHandler(session,'VideoList',{beforeInstantiate:"relations/relation/targets/entity"});},handleRequestOptions:function(session){return function(params,options){};}},_prototypeWith:{initialize:function(jsonNode){var self=this;self.videos=[];var videoListNode=Evri.API.Utilities.JSON.getNodeForPath(jsonNode,"videoList");if(videoListNode!==undefined){var videoJSONNodes=Evri.API.Utilities.JSON.getNodeSetForPath(videoListNode,"video");for(var i=0;i<videoJSONNodes.length;i++){var video=new self.session.models.Video(videoJSONNodes[i]);video.belongsTo=self;self.videos.push(video);}}
return self;},instanceAttributes:['belongsTo','documentationUrl','klass','videos'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"VideoStillImage");Evri.extendNamespace(Evri.API.Model.VideoStillImage,{_classMethodGenerators:{},_prototypeWith:{initialize:function(jsonNode){var self=this;Evri.API.Utilities.JSON.bindChildrenAndAttributesToObject(jsonNode,self);return self;},instanceAttributes:['belongsTo','documentationUrl','klass','height','size','time','url','width'],instanceMethods:[]}});Evri.defineNamespace(Evri.API.Model,"Zeitgeist");Evri.extendNamespace(Evri.API.Model.Zeitgeist,{getEntitiesByEntityTypeAndZeitgeistTypeGenerator:function(session,zeitgeistType){return function(entityType,callbacks,options){var params={};options=options||{};if(options.resultsPerPage!==undefined){params.max=parseInt(options.resultsPerPage);}
if(options.facet!==undefined){params.facet=options.facet;}
Evri.API.Transport.callRemoteMethod(session,"/zeitgeist/entities/"+entityType+"/"+zeitgeistType,session.models.EntityList["handleZeitgeistEntities"+Evri.API.Utilities.String.capitalize(zeitgeistType)+"Response"],params,callbacks);};},_classMethodGenerators:{getPopularEntitiesByType:function(session){return Evri.API.Model.Zeitgeist.getEntitiesByEntityTypeAndZeitgeistTypeGenerator(session,'popular');},getRisingEntitiesByType:function(session){return Evri.API.Model.Zeitgeist.getEntitiesByEntityTypeAndZeitgeistTypeGenerator(session,'rising');},getFallingEntitiesByType:function(session){return Evri.API.Model.Zeitgeist.getEntitiesByEntityTypeAndZeitgeistTypeGenerator(session,'falling');}}});Evri.defineClass(Evri.API,"Session",function(options){var self=this;self.klass="Session";self.requiredQueryStringParameterKeys=['appId'];self.sharedQueryStringParameters={};for(var i=0;i<self.requiredQueryStringParameterKeys.length;i++){var key=self.requiredQueryStringParameterKeys[i];if(options[key]===undefined){alert(key+" is a required to create an Evri.API.Session");return undefined;}else{self.sharedQueryStringParameters[key]=options[key];}}
Evri.API.Model.generateForSession(self);return self;});Evri.API.setup({'transport':'CrossDomain'});Evri.jQuery||(function(){var
window=this,undefined,jQuery=window.Evri.jQuery=window.Evri.$=function(selector,context){return new jQuery.fn.init(selector,context);},quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,isSimple=/^.[^:#\[\.,]*$/;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;this.context=selector;return this;}
if(typeof selector==="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])
selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem&&elem.id!=match[3])
return jQuery().find(selector);var ret=jQuery(elem||[]);ret.context=document;ret.selector=selector;return ret;}}else
return jQuery(context).find(selector);}else if(jQuery.isFunction(selector))
return jQuery(document).ready(selector);if(selector.selector&&selector.context){this.selector=selector.selector;this.context=selector.context;}
return this.setArray(jQuery.isArray(selector)?selector:jQuery.makeArray(selector));},selector:"",jquery:"1.3.2",size:function(){return this.length;},get:function(num){return num===undefined?Array.prototype.slice.call(this):this[num];},pushStack:function(elems,name,selector){var ret=jQuery(elems);ret.prevObject=this;ret.context=this.context;if(name==="find")
ret.selector=this.selector+(this.selector?" ":"")+selector;else if(name)
ret.selector=this.selector+"."+name+"("+selector+")";return ret;},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this;},each:function(callback,args){return jQuery.each(this,callback,args);},index:function(elem){return jQuery.inArray(elem&&elem.jquery?elem[0]:elem,this);},attr:function(name,value,type){var options=name;if(typeof name==="string")
if(value===undefined)
return this[0]&&jQuery[type||"attr"](this[0],name);else{options={};options[name]=value;}
return this.each(function(i){for(name in options)
jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));});},css:function(key,value){if((key=='width'||key=='height')&&parseFloat(value)<0)
value=undefined;return this.attr(key,value,"curCSS");},text:function(text){if(typeof text!=="object"&&text!=null)
return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8)
ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);});});return ret;},wrapAll:function(html){if(this[0]){var wrap=jQuery(html,this[0].ownerDocument).clone();if(this[0].parentNode)
wrap.insertBefore(this[0]);wrap.map(function(){var elem=this;while(elem.firstChild)
elem=elem.firstChild;return elem;}).append(this);}
return this;},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);});},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);});},append:function(){return this.domManip(arguments,true,function(elem){if(this.nodeType==1)
this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,function(elem){if(this.nodeType==1)
this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},push:[].push,sort:[].sort,splice:[].splice,find:function(selector){if(this.length===1){var ret=this.pushStack([],"find",selector);ret.length=0;jQuery.find(selector,this[0],ret);return ret;}else{return this.pushStack(jQuery.unique(jQuery.map(this,function(elem){return jQuery.find(selector,elem);})),"find",selector);}},clone:function(events){var ret=this.map(function(){if(!jQuery.support.noCloneEvent&&!jQuery.isXMLDoc(this)){var html=this.outerHTML;if(!html){var div=this.ownerDocument.createElement("div");div.appendChild(this.cloneNode(true));html=div.innerHTML;}
return jQuery.clean([html.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0];}else
return this.cloneNode(true);});if(events===true){var orig=this.find("*").andSelf(),i=0;ret.find("*").andSelf().each(function(){if(this.nodeName!==orig[i].nodeName)
return;var events=jQuery.data(orig[i],"events");for(var type in events){for(var handler in events[type]){jQuery.event.add(this,type,events[type][handler],events[type][handler].data);}}
i++;});}
return ret;},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);})||jQuery.multiFilter(selector,jQuery.grep(this,function(elem){return elem.nodeType===1;})),"filter",selector);},closest:function(selector){var pos=jQuery.expr.match.POS.test(selector)?jQuery(selector):null,closer=0;return this.map(function(){var cur=this;while(cur&&cur.ownerDocument){if(pos?pos.index(cur)>-1:jQuery(cur).is(selector)){jQuery.data(cur,"closest",closer);return cur;}
cur=cur.parentNode;closer++;}});},not:function(selector){if(typeof selector==="string")
if(isSimple.test(selector))
return this.pushStack(jQuery.multiFilter(selector,this,true),"not",selector);else
selector=jQuery.multiFilter(selector,this);var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;});},add:function(selector){return this.pushStack(jQuery.unique(jQuery.merge(this.get(),typeof selector==="string"?jQuery(selector):jQuery.makeArray(selector))));},is:function(selector){return!!selector&&jQuery.multiFilter(selector,this).length>0;},hasClass:function(selector){return!!selector&&this.is("."+selector);},val:function(value){if(value===undefined){var elem=this[0];if(elem){if(jQuery.nodeName(elem,'option'))
return(elem.attributes.value||{}).specified?elem.value:elem.text;if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0)
return null;for(var i=one?index:0,max=one?index+1:options.length;i<max;i++){var option=options[i];if(option.selected){value=jQuery(option).val();if(one)
return value;values.push(value);}}
return values;}
return(elem.value||"").replace(/\r/g,"");}
return undefined;}
if(typeof value==="number")
value+='';return this.each(function(){if(this.nodeType!=1)
return;if(jQuery.isArray(value)&&/radio|checkbox/.test(this.type))
this.checked=(jQuery.inArray(this.value,value)>=0||jQuery.inArray(this.name,value)>=0);else if(jQuery.nodeName(this,"select")){var values=jQuery.makeArray(value);jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);});if(!values.length)
this.selectedIndex=-1;}else
this.value=value;});},html:function(value){return value===undefined?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(value);},replaceWith:function(value){return this.after(value).remove();},eq:function(i){return this.slice(i,+i+1);},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","));},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);}));},andSelf:function(){return this.add(this.prevObject);},domManip:function(args,table,callback){if(this[0]){var fragment=(this[0].ownerDocument||this[0]).createDocumentFragment(),scripts=jQuery.clean(args,(this[0].ownerDocument||this[0]),fragment),first=fragment.firstChild;if(first)
for(var i=0,l=this.length;i<l;i++)
callback.call(root(this[i],first),this.length>1||i>0?fragment.cloneNode(true):fragment);if(scripts)
jQuery.each(scripts,evalScript);}
return this;function root(elem,cur){return table&&jQuery.nodeName(elem,"table")&&jQuery.nodeName(cur,"tr")?(elem.getElementsByTagName("tbody")[0]||elem.appendChild(elem.ownerDocument.createElement("tbody"))):elem;}}};jQuery.fn.init.prototype=jQuery.fn;function evalScript(i,elem){if(elem.src)
jQuery.ajax({url:elem.src,async:false,dataType:"script"});else
jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");if(elem.parentNode)
elem.parentNode.removeChild(elem);}
function now(){return+new Date;}
jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(typeof target==="boolean"){deep=target;target=arguments[1]||{};i=2;}
if(typeof target!=="object"&&!jQuery.isFunction(target))
target={};if(length==i){target=this;--i;}
for(;i<length;i++)
if((options=arguments[i])!=null)
for(var name in options){var src=target[name],copy=options[name];if(target===copy)
continue;if(deep&&copy&&typeof copy==="object"&&!copy.nodeType)
target[name]=jQuery.extend(deep,src||(copy.length!=null?[]:{}),copy);else if(copy!==undefined)
target[name]=copy;}
return target;};var exclude=/z-?index|font-?weight|opacity|zoom|line-?height/i,defaultView=document.defaultView||{},toString=Object.prototype.toString;jQuery.extend({noConflict:function(deep){window.$=_$;if(deep)
window.jQuery=_jQuery;return jQuery;},isFunction:function(obj){return toString.call(obj)==="[object Function]";},isArray:function(obj){return toString.call(obj)==="[object Array]";},isXMLDoc:function(elem){return elem.nodeType===9&&elem.documentElement.nodeName!=="HTML"||!!elem.ownerDocument&&jQuery.isXMLDoc(elem.ownerDocument);},globalEval:function(data){if(data&&/\S/.test(data)){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");script.type="text/javascript";if(jQuery.support.scriptEval)
script.appendChild(document.createTextNode(data));else
script.text=data;head.insertBefore(script,head.firstChild);head.removeChild(script);}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()==name.toUpperCase();},each:function(object,callback,args){var name,i=0,length=object.length;if(args){if(length===undefined){for(name in object)
if(callback.apply(object[name],args)===false)
break;}else
for(;i<length;)
if(callback.apply(object[i++],args)===false)
break;}else{if(length===undefined){for(name in object)
if(callback.call(object[name],name,object[name])===false)
break;}else
for(var value=object[0];i<length&&callback.call(value,i,value)!==false;value=object[++i]){}}
return object;},prop:function(elem,value,type,i,name){if(jQuery.isFunction(value))
value=value.call(elem,i);return typeof value==="number"&&type=="curCSS"&&!exclude.test(name)?value+"px":value;},className:{add:function(elem,classNames){jQuery.each((classNames||"").split(/\s+/),function(i,className){if(elem.nodeType==1&&!jQuery.className.has(elem.className,className))
elem.className+=(elem.className?" ":"")+className;});},remove:function(elem,classNames){if(elem.nodeType==1)
elem.className=classNames!==undefined?jQuery.grep(elem.className.split(/\s+/),function(className){return!jQuery.className.has(classNames,className);}).join(" "):"";},has:function(elem,className){return elem&&jQuery.inArray(className,(elem.className||elem).toString().split(/\s+/))>-1;}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name];}
callback.call(elem);for(var name in options)
elem.style[name]=old[name];},css:function(elem,name,force,extra){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;if(extra==="border")
return;jQuery.each(which,function(){if(!extra)
val-=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;if(extra==="margin")
val+=parseFloat(jQuery.curCSS(elem,"margin"+this,true))||0;else
val-=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});}
if(elem.offsetWidth!==0)
getWH();else
jQuery.swap(elem,props,getWH);return Math.max(0,Math.round(val));}
return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret,style=elem.style;if(name=="opacity"&&!jQuery.support.opacity){ret=jQuery.attr(style,"opacity");return ret==""?"1":ret;}
if(name.match(/float/i))
name=styleFloat;if(!force&&style&&style[name])
ret=style[name];else if(defaultView.getComputedStyle){if(name.match(/float/i))
name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle)
ret=computedStyle.getPropertyValue(name);if(name=="opacity"&&ret=="")
ret="1";}else if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase();});ret=elem.currentStyle[name]||elem.currentStyle[camelCase];if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var left=style.left,rsLeft=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;style.left=ret||0;ret=style.pixelLeft+"px";style.left=left;elem.runtimeStyle.left=rsLeft;}}
return ret;},clean:function(elems,context,fragment){context=context||document;if(typeof context.createElement==="undefined")
context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;if(!fragment&&elems.length===1&&typeof elems[0]==="string"){var match=/^<(\w+)\s*\/?>$/.exec(elems[0]);if(match)
return[context.createElement(match[1])];}
var ret=[],scripts=[],div=context.createElement("div");jQuery.each(elems,function(i,elem){if(typeof elem==="number")
elem+='';if(!elem)
return;if(typeof elem==="string"){elem=elem.replace(/(<(\w+)[^>]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+"></"+tag+">";});var tags=elem.replace(/^\s+/,"").substring(0,10).toLowerCase();var wrap=!tags.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!tags.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!tags.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!tags.indexOf("<td")||!tags.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!tags.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||!jQuery.support.htmlSerialize&&[1,"div<div>","</div>"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)
div=div.lastChild;if(!jQuery.support.tbody){var hasBody=/<tbody/i.test(elem),tbody=!tags.indexOf("<table")&&!hasBody?div.firstChild&&div.firstChild.childNodes:wrap[1]=="<table>"&&!hasBody?div.childNodes:[];for(var j=tbody.length-1;j>=0;--j)
if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)
tbody[j].parentNode.removeChild(tbody[j]);}
if(!jQuery.support.leadingWhitespace&&/^\s/.test(elem))
div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);elem=jQuery.makeArray(div.childNodes);}
if(elem.nodeType)
ret.push(elem);else
ret=jQuery.merge(ret,elem);});if(fragment){for(var i=0;ret[i];i++){if(jQuery.nodeName(ret[i],"script")&&(!ret[i].type||ret[i].type.toLowerCase()==="text/javascript")){scripts.push(ret[i].parentNode?ret[i].parentNode.removeChild(ret[i]):ret[i]);}else{if(ret[i].nodeType===1)
ret.splice.apply(ret,[i+1,0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))));fragment.appendChild(ret[i]);}}
return scripts;}
return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)
return undefined;var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined;name=notxml&&jQuery.props[name]||name;if(elem.tagName){var special=/href|src|style/.test(name);if(name=="selected"&&elem.parentNode)
elem.parentNode.selectedIndex;if(name in elem&&notxml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)
throw"type property can't be changed";elem[name]=value;}
if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name))
return elem.getAttributeNode(name).nodeValue;if(name=="tabIndex"){var attributeNode=elem.getAttributeNode("tabIndex");return attributeNode&&attributeNode.specified?attributeNode.value:elem.nodeName.match(/(button|input|object|select|textarea)/i)?0:elem.nodeName.match(/^(a|area)$/i)&&elem.href?0:undefined;}
return elem[name];}
if(!jQuery.support.style&&notxml&&name=="style")
return jQuery.attr(elem.style,"cssText",value);if(set)
elem.setAttribute(name,""+value);var attr=!jQuery.support.hrefNormalized&&notxml&&special?elem.getAttribute(name,2):elem.getAttribute(name);return attr===null?undefined:attr;}
if(!jQuery.support.opacity&&name=="opacity"){if(set){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+
(parseInt(value)+''=="NaN"?"":"alpha(opacity="+value*100+")");}
return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+'':"";}
name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(set)
elem[name]=value;return elem[name];},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(array!=null){var i=array.length;if(i==null||typeof array==="string"||jQuery.isFunction(array)||array.setInterval)
ret[0]=array;else
while(i)
ret[--i]=array[i];}
return ret;},inArray:function(elem,array){for(var i=0,length=array.length;i<length;i++)
if(array[i]===elem)
return i;return-1;},merge:function(first,second){var i=0,elem,pos=first.length;if(!jQuery.support.getAll){while((elem=second[i++])!=null)
if(elem.nodeType!=8)
first[pos++]=elem;}else
while((elem=second[i++])!=null)
first[pos++]=elem;return first;},unique:function(array){var ret=[],done={};try{for(var i=0,length=array.length;i<length;i++){var id=jQuery.data(array[i]);if(!done[id]){done[id]=true;ret.push(array[i]);}}}catch(e){ret=array;}
return ret;},grep:function(elems,callback,inv){var ret=[];for(var i=0,length=elems.length;i<length;i++)
if(!inv!=!callback(elems[i],i))
ret.push(elems[i]);return ret;},map:function(elems,callback){var ret=[];for(var i=0,length=elems.length;i<length;i++){var value=callback(elems[i],i);if(value!=null)
ret[ret.length]=value;}
return ret.concat.apply([],ret);}});var userAgent=navigator.userAgent.toLowerCase();jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,'0'])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};jQuery.each({parent:function(elem){return elem.parentNode;},parents:function(elem){return jQuery.dir(elem,"parentNode");},next:function(elem){return jQuery.nth(elem,2,"nextSibling");},prev:function(elem){return jQuery.nth(elem,2,"previousSibling");},nextAll:function(elem){return jQuery.dir(elem,"nextSibling");},prevAll:function(elem){return jQuery.dir(elem,"previousSibling");},siblings:function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},children:function(elem){return jQuery.sibling(elem.firstChild);},contents:function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}},function(name,fn){jQuery.fn[name]=function(selector){var ret=jQuery.map(this,fn);if(selector&&typeof selector=="string")
ret=jQuery.multiFilter(selector,ret);return this.pushStack(jQuery.unique(ret),name,selector);};});jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(selector){var ret=[],insert=jQuery(selector);for(var i=0,l=insert.length;i<l;i++){var elems=(i>0?this.clone(true):this).get();jQuery.fn[original].apply(jQuery(insert[i]),elems);ret=ret.concat(elems);}
return this.pushStack(ret,name,selector);};});jQuery.each({removeAttr:function(name){jQuery.attr(this,name,"");if(this.nodeType==1)
this.removeAttribute(name);},addClass:function(classNames){jQuery.className.add(this,classNames);},removeClass:function(classNames){jQuery.className.remove(this,classNames);},toggleClass:function(classNames,state){if(typeof state!=="boolean")
state=!jQuery.className.has(this,classNames);jQuery.className[state?"add":"remove"](this,classNames);},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).length){jQuery("*",this).add([this]).each(function(){jQuery.event.remove(this);jQuery.removeData(this);});if(this.parentNode)
this.parentNode.removeChild(this);}},empty:function(){jQuery(this).children().remove();while(this.firstChild)
this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0;}
var expando="jQuery"+now(),uuid=0,windowData={};jQuery.extend({cache:{},data:function(elem,name,data){elem=elem==window?windowData:elem;var id=elem[expando];if(!id)
id=elem[expando]=++uuid;if(name&&!jQuery.cache[id])
jQuery.cache[id]={};if(data!==undefined)
jQuery.cache[id][name]=data;return name?jQuery.cache[id][name]:id;},removeData:function(elem,name){elem=elem==window?windowData:elem;var id=elem[expando];if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];name="";for(name in jQuery.cache[id])
break;if(!name)
jQuery.removeData(elem);}}else{try{delete elem[expando];}catch(e){if(elem.removeAttribute)
elem.removeAttribute(expando);}
delete jQuery.cache[id];}},queue:function(elem,type,data){if(elem){type=(type||"fx")+"queue";var q=jQuery.data(elem,type);if(!q||jQuery.isArray(data))
q=jQuery.data(elem,type,jQuery.makeArray(data));else if(data)
q.push(data);}
return q;},dequeue:function(elem,type){var queue=jQuery.queue(elem,type),fn=queue.shift();if(!type||type==="fx")
fn=queue[0];if(fn!==undefined)
fn.call(elem);}});jQuery.fn.extend({data:function(key,value){var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data===undefined&&this.length)
data=jQuery.data(this[0],key);return data===undefined&&parts[1]?this.data(parts[0]):data;}else
return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value);});},removeData:function(key){return this.each(function(){jQuery.removeData(this,key);});},queue:function(type,data){if(typeof type!=="string"){data=type;type="fx";}
if(data===undefined)
return jQuery.queue(this[0],type);return this.each(function(){var queue=jQuery.queue(this,type,data);if(type=="fx"&&queue.length==1)
queue[0].call(this);});},dequeue:function(type){return this.each(function(){jQuery.dequeue(this,type);});}});(function(){var chunker=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,done=0,toString=Object.prototype.toString;var Sizzle=function(selector,context,results,seed){results=results||[];context=context||document;if(context.nodeType!==1&&context.nodeType!==9)
return[];if(!selector||typeof selector!=="string"){return results;}
var parts=[],m,set,checkSet,check,mode,extra,prune=true;chunker.lastIndex=0;while((m=chunker.exec(selector))!==null){parts.push(m[1]);if(m[2]){extra=RegExp.rightContext;break;}}
if(parts.length>1&&origPOS.exec(selector)){if(parts.length===2&&Expr.relative[parts[0]]){set=posProcess(parts[0]+parts[1],context);}else{set=Expr.relative[parts[0]]?[context]:Sizzle(parts.shift(),context);while(parts.length){selector=parts.shift();if(Expr.relative[selector])
selector+=parts.shift();set=posProcess(selector,set);}}}else{var ret=seed?{expr:parts.pop(),set:makeArray(seed)}:Sizzle.find(parts.pop(),parts.length===1&&context.parentNode?context.parentNode:context,isXML(context));set=Sizzle.filter(ret.expr,ret.set);if(parts.length>0){checkSet=makeArray(set);}else{prune=false;}
while(parts.length){var cur=parts.pop(),pop=cur;if(!Expr.relative[cur]){cur="";}else{pop=parts.pop();}
if(pop==null){pop=context;}
Expr.relative[cur](checkSet,pop,isXML(context));}}
if(!checkSet){checkSet=set;}
if(!checkSet){throw"Syntax error, unrecognized expression: "+(cur||selector);}
if(toString.call(checkSet)==="[object Array]"){if(!prune){results.push.apply(results,checkSet);}else if(context.nodeType===1){for(var i=0;checkSet[i]!=null;i++){if(checkSet[i]&&(checkSet[i]===true||checkSet[i].nodeType===1&&contains(context,checkSet[i]))){results.push(set[i]);}}}else{for(var i=0;checkSet[i]!=null;i++){if(checkSet[i]&&checkSet[i].nodeType===1){results.push(set[i]);}}}}else{makeArray(checkSet,results);}
if(extra){Sizzle(extra,context,results,seed);if(sortOrder){hasDuplicate=false;results.sort(sortOrder);if(hasDuplicate){for(var i=1;i<results.length;i++){if(results[i]===results[i-1]){results.splice(i--,1);}}}}}
return results;};Sizzle.matches=function(expr,set){return Sizzle(expr,null,null,set);};Sizzle.find=function(expr,context,isXML){var set,match;if(!expr){return[];}
for(var i=0,l=Expr.order.length;i<l;i++){var type=Expr.order[i],match;if((match=Expr.match[type].exec(expr))){var left=RegExp.leftContext;if(left.substr(left.length-1)!=="\\"){match[1]=(match[1]||"").replace(/\\/g,"");set=Expr.find[type](match,context,isXML);if(set!=null){expr=expr.replace(Expr.match[type],"");break;}}}}
if(!set){set=context.getElementsByTagName("*");}
return{set:set,expr:expr};};Sizzle.filter=function(expr,set,inplace,not){var old=expr,result=[],curLoop=set,match,anyFound,isXMLFilter=set&&set[0]&&isXML(set[0]);while(expr&&set.length){for(var type in Expr.filter){if((match=Expr.match[type].exec(expr))!=null){var filter=Expr.filter[type],found,item;anyFound=false;if(curLoop==result){result=[];}
if(Expr.preFilter[type]){match=Expr.preFilter[type](match,curLoop,inplace,result,not,isXMLFilter);if(!match){anyFound=found=true;}else if(match===true){continue;}}
if(match){for(var i=0;(item=curLoop[i])!=null;i++){if(item){found=filter(item,match,i,curLoop);var pass=not^!!found;if(inplace&&found!=null){if(pass){anyFound=true;}else{curLoop[i]=false;}}else if(pass){result.push(item);anyFound=true;}}}}
if(found!==undefined){if(!inplace){curLoop=result;}
expr=expr.replace(Expr.match[type],"");if(!anyFound){return[];}
break;}}}
if(expr==old){if(anyFound==null){throw"Syntax error, unrecognized expression: "+expr;}else{break;}}
old=expr;}
return curLoop;};var Expr=Sizzle.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(elem){return elem.getAttribute("href");}},relative:{"+":function(checkSet,part,isXML){var isPartStr=typeof part==="string",isTag=isPartStr&&!/\W/.test(part),isPartStrNotTag=isPartStr&&!isTag;if(isTag&&!isXML){part=part.toUpperCase();}
for(var i=0,l=checkSet.length,elem;i<l;i++){if((elem=checkSet[i])){while((elem=elem.previousSibling)&&elem.nodeType!==1){}
checkSet[i]=isPartStrNotTag||elem&&elem.nodeName===part?elem||false:elem===part;}}
if(isPartStrNotTag){Sizzle.filter(part,checkSet,true);}},">":function(checkSet,part,isXML){var isPartStr=typeof part==="string";if(isPartStr&&!/\W/.test(part)){part=isXML?part:part.toUpperCase();for(var i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){var parent=elem.parentNode;checkSet[i]=parent.nodeName===part?parent:false;}}}else{for(var i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){checkSet[i]=isPartStr?elem.parentNode:elem.parentNode===part;}}
if(isPartStr){Sizzle.filter(part,checkSet,true);}}},"":function(checkSet,part,isXML){var doneName=done++,checkFn=dirCheck;if(!part.match(/\W/)){var nodeCheck=part=isXML?part:part.toUpperCase();checkFn=dirNodeCheck;}
checkFn("parentNode",part,doneName,checkSet,nodeCheck,isXML);},"~":function(checkSet,part,isXML){var doneName=done++,checkFn=dirCheck;if(typeof part==="string"&&!part.match(/\W/)){var nodeCheck=part=isXML?part:part.toUpperCase();checkFn=dirNodeCheck;}
checkFn("previousSibling",part,doneName,checkSet,nodeCheck,isXML);}},find:{ID:function(match,context,isXML){if(typeof context.getElementById!=="undefined"&&!isXML){var m=context.getElementById(match[1]);return m?[m]:[];}},NAME:function(match,context,isXML){if(typeof context.getElementsByName!=="undefined"){var ret=[],results=context.getElementsByName(match[1]);for(var i=0,l=results.length;i<l;i++){if(results[i].getAttribute("name")===match[1]){ret.push(results[i]);}}
return ret.length===0?null:ret;}},TAG:function(match,context){return context.getElementsByTagName(match[1]);}},preFilter:{CLASS:function(match,curLoop,inplace,result,not,isXML){match=" "+match[1].replace(/\\/g,"")+" ";if(isXML){return match;}
for(var i=0,elem;(elem=curLoop[i])!=null;i++){if(elem){if(not^(elem.className&&(" "+elem.className+" ").indexOf(match)>=0)){if(!inplace)
result.push(elem);}else if(inplace){curLoop[i]=false;}}}
return false;},ID:function(match){return match[1].replace(/\\/g,"");},TAG:function(match,curLoop){for(var i=0;curLoop[i]===false;i++){}
return curLoop[i]&&isXML(curLoop[i])?match[1]:match[1].toUpperCase();},CHILD:function(match){if(match[1]=="nth"){var test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(match[2]=="even"&&"2n"||match[2]=="odd"&&"2n+1"||!/\D/.test(match[2])&&"0n+"+match[2]||match[2]);match[2]=(test[1]+(test[2]||1))-0;match[3]=test[3]-0;}
match[0]=done++;return match;},ATTR:function(match,curLoop,inplace,result,not,isXML){var name=match[1].replace(/\\/g,"");if(!isXML&&Expr.attrMap[name]){match[1]=Expr.attrMap[name];}
if(match[2]==="~="){match[4]=" "+match[4]+" ";}
return match;},PSEUDO:function(match,curLoop,inplace,result,not){if(match[1]==="not"){if(match[3].match(chunker).length>1||/^\w/.test(match[3])){match[3]=Sizzle(match[3],null,null,curLoop);}else{var ret=Sizzle.filter(match[3],curLoop,inplace,true^not);if(!inplace){result.push.apply(result,ret);}
return false;}}else if(Expr.match.POS.test(match[0])||Expr.match.CHILD.test(match[0])){return true;}
return match;},POS:function(match){match.unshift(true);return match;}},filters:{enabled:function(elem){return elem.disabled===false&&elem.type!=="hidden";},disabled:function(elem){return elem.disabled===true;},checked:function(elem){return elem.checked===true;},selected:function(elem){elem.parentNode.selectedIndex;return elem.selected===true;},parent:function(elem){return!!elem.firstChild;},empty:function(elem){return!elem.firstChild;},has:function(elem,i,match){return!!Sizzle(match[3],elem).length;},header:function(elem){return/h\d/i.test(elem.nodeName);},text:function(elem){return"text"===elem.type;},radio:function(elem){return"radio"===elem.type;},checkbox:function(elem){return"checkbox"===elem.type;},file:function(elem){return"file"===elem.type;},password:function(elem){return"password"===elem.type;},submit:function(elem){return"submit"===elem.type;},image:function(elem){return"image"===elem.type;},reset:function(elem){return"reset"===elem.type;},button:function(elem){return"button"===elem.type||elem.nodeName.toUpperCase()==="BUTTON";},input:function(elem){return/input|select|textarea|button/i.test(elem.nodeName);}},setFilters:{first:function(elem,i){return i===0;},last:function(elem,i,match,array){return i===array.length-1;},even:function(elem,i){return i%2===0;},odd:function(elem,i){return i%2===1;},lt:function(elem,i,match){return i<match[3]-0;},gt:function(elem,i,match){return i>match[3]-0;},nth:function(elem,i,match){return match[3]-0==i;},eq:function(elem,i,match){return match[3]-0==i;}},filter:{PSEUDO:function(elem,match,i,array){var name=match[1],filter=Expr.filters[name];if(filter){return filter(elem,i,match,array);}else if(name==="contains"){return(elem.textContent||elem.innerText||"").indexOf(match[3])>=0;}else if(name==="not"){var not=match[3];for(var i=0,l=not.length;i<l;i++){if(not[i]===elem){return false;}}
return true;}},CHILD:function(elem,match){var type=match[1],node=elem;switch(type){case'only':case'first':while(node=node.previousSibling){if(node.nodeType===1)return false;}
if(type=='first')return true;node=elem;case'last':while(node=node.nextSibling){if(node.nodeType===1)return false;}
return true;case'nth':var first=match[2],last=match[3];if(first==1&&last==0){return true;}
var doneName=match[0],parent=elem.parentNode;if(parent&&(parent.sizcache!==doneName||!elem.nodeIndex)){var count=0;for(node=parent.firstChild;node;node=node.nextSibling){if(node.nodeType===1){node.nodeIndex=++count;}}
parent.sizcache=doneName;}
var diff=elem.nodeIndex-last;if(first==0){return diff==0;}else{return(diff%first==0&&diff/first>=0);}}},ID:function(elem,match){return elem.nodeType===1&&elem.getAttribute("id")===match;},TAG:function(elem,match){return(match==="*"&&elem.nodeType===1)||elem.nodeName===match;},CLASS:function(elem,match){return(" "+(elem.className||elem.getAttribute("class"))+" ").indexOf(match)>-1;},ATTR:function(elem,match){var name=match[1],result=Expr.attrHandle[name]?Expr.attrHandle[name](elem):elem[name]!=null?elem[name]:elem.getAttribute(name),value=result+"",type=match[2],check=match[4];return result==null?type==="!=":type==="="?value===check:type==="*="?value.indexOf(check)>=0:type==="~="?(" "+value+" ").indexOf(check)>=0:!check?value&&result!==false:type==="!="?value!=check:type==="^="?value.indexOf(check)===0:type==="$="?value.substr(value.length-check.length)===check:type==="|="?value===check||value.substr(0,check.length+1)===check+"-":false;},POS:function(elem,match,i,array){var name=match[2],filter=Expr.setFilters[name];if(filter){return filter(elem,i,match,array);}}}};var origPOS=Expr.match.POS;for(var type in Expr.match){Expr.match[type]=RegExp(Expr.match[type].source+/(?![^\[]*\])(?![^\(]*\))/.source);}
var makeArray=function(array,results){array=Array.prototype.slice.call(array);if(results){results.push.apply(results,array);return results;}
return array;};try{Array.prototype.slice.call(document.documentElement.childNodes);}catch(e){makeArray=function(array,results){var ret=results||[];if(toString.call(array)==="[object Array]"){Array.prototype.push.apply(ret,array);}else{if(typeof array.length==="number"){for(var i=0,l=array.length;i<l;i++){ret.push(array[i]);}}else{for(var i=0;array[i];i++){ret.push(array[i]);}}}
return ret;};}
var sortOrder;if(document.documentElement.compareDocumentPosition){sortOrder=function(a,b){var ret=a.compareDocumentPosition(b)&4?-1:a===b?0:1;if(ret===0){hasDuplicate=true;}
return ret;};}else if("sourceIndex"in document.documentElement){sortOrder=function(a,b){var ret=a.sourceIndex-b.sourceIndex;if(ret===0){hasDuplicate=true;}
return ret;};}else if(document.createRange){sortOrder=function(a,b){var aRange=a.ownerDocument.createRange(),bRange=b.ownerDocument.createRange();aRange.selectNode(a);aRange.collapse(true);bRange.selectNode(b);bRange.collapse(true);var ret=aRange.compareBoundaryPoints(Range.START_TO_END,bRange);if(ret===0){hasDuplicate=true;}
return ret;};}
(function(){var form=document.createElement("form"),id="script"+(new Date).getTime();form.innerHTML="<input name='"+id+"'/>";var root=document.documentElement;root.insertBefore(form,root.firstChild);if(!!document.getElementById(id)){Expr.find.ID=function(match,context,isXML){if(typeof context.getElementById!=="undefined"&&!isXML){var m=context.getElementById(match[1]);return m?m.id===match[1]||typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id").nodeValue===match[1]?[m]:undefined:[];}};Expr.filter.ID=function(elem,match){var node=typeof elem.getAttributeNode!=="undefined"&&elem.getAttributeNode("id");return elem.nodeType===1&&node&&node.nodeValue===match;};}
root.removeChild(form);})();(function(){var div=document.createElement("div");div.appendChild(document.createComment(""));if(div.getElementsByTagName("*").length>0){Expr.find.TAG=function(match,context){var results=context.getElementsByTagName(match[1]);if(match[1]==="*"){var tmp=[];for(var i=0;results[i];i++){if(results[i].nodeType===1){tmp.push(results[i]);}}
results=tmp;}
return results;};}
div.innerHTML="<a href='#'></a>";if(div.firstChild&&typeof div.firstChild.getAttribute!=="undefined"&&div.firstChild.getAttribute("href")!=="#"){Expr.attrHandle.href=function(elem){return elem.getAttribute("href",2);};}})();if(document.querySelectorAll)(function(){var oldSizzle=Sizzle,div=document.createElement("div");div.innerHTML="<p class='TEST'></p>";if(div.querySelectorAll&&div.querySelectorAll(".TEST").length===0){return;}
Sizzle=function(query,context,extra,seed){context=context||document;if(!seed&&context.nodeType===9&&!isXML(context)){try{return makeArray(context.querySelectorAll(query),extra);}catch(e){}}
return oldSizzle(query,context,extra,seed);};Sizzle.find=oldSizzle.find;Sizzle.filter=oldSizzle.filter;Sizzle.selectors=oldSizzle.selectors;Sizzle.matches=oldSizzle.matches;})();if(document.getElementsByClassName&&document.documentElement.getElementsByClassName)(function(){var div=document.createElement("div");div.innerHTML="<div class='test e'></div><div class='test'></div>";if(div.getElementsByClassName("e").length===0)
return;div.lastChild.className="e";if(div.getElementsByClassName("e").length===1)
return;Expr.order.splice(1,0,"CLASS");Expr.find.CLASS=function(match,context,isXML){if(typeof context.getElementsByClassName!=="undefined"&&!isXML){return context.getElementsByClassName(match[1]);}};})();function dirNodeCheck(dir,cur,doneName,checkSet,nodeCheck,isXML){var sibDir=dir=="previousSibling"&&!isXML;for(var i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){if(sibDir&&elem.nodeType===1){elem.sizcache=doneName;elem.sizset=i;}
elem=elem[dir];var match=false;while(elem){if(elem.sizcache===doneName){match=checkSet[elem.sizset];break;}
if(elem.nodeType===1&&!isXML){elem.sizcache=doneName;elem.sizset=i;}
if(elem.nodeName===cur){match=elem;break;}
elem=elem[dir];}
checkSet[i]=match;}}}
function dirCheck(dir,cur,doneName,checkSet,nodeCheck,isXML){var sibDir=dir=="previousSibling"&&!isXML;for(var i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){if(sibDir&&elem.nodeType===1){elem.sizcache=doneName;elem.sizset=i;}
elem=elem[dir];var match=false;while(elem){if(elem.sizcache===doneName){match=checkSet[elem.sizset];break;}
if(elem.nodeType===1){if(!isXML){elem.sizcache=doneName;elem.sizset=i;}
if(typeof cur!=="string"){if(elem===cur){match=true;break;}}else if(Sizzle.filter(cur,[elem]).length>0){match=elem;break;}}
elem=elem[dir];}
checkSet[i]=match;}}}
var contains=document.compareDocumentPosition?function(a,b){return a.compareDocumentPosition(b)&16;}:function(a,b){return a!==b&&(a.contains?a.contains(b):true);};var isXML=function(elem){return elem.nodeType===9&&elem.documentElement.nodeName!=="HTML"||!!elem.ownerDocument&&isXML(elem.ownerDocument);};var posProcess=function(selector,context){var tmpSet=[],later="",match,root=context.nodeType?[context]:context;while((match=Expr.match.PSEUDO.exec(selector))){later+=match[0];selector=selector.replace(Expr.match.PSEUDO,"");}
selector=Expr.relative[selector]?selector+"*":selector;for(var i=0,l=root.length;i<l;i++){Sizzle(selector,root[i],tmpSet);}
return Sizzle.filter(later,tmpSet);};jQuery.find=Sizzle;jQuery.filter=Sizzle.filter;jQuery.expr=Sizzle.selectors;jQuery.expr[":"]=jQuery.expr.filters;Sizzle.selectors.filters.hidden=function(elem){return elem.offsetWidth===0||elem.offsetHeight===0;};Sizzle.selectors.filters.visible=function(elem){return elem.offsetWidth>0||elem.offsetHeight>0;};Sizzle.selectors.filters.animated=function(elem){return jQuery.grep(jQuery.timers,function(fn){return elem===fn.elem;}).length;};jQuery.multiFilter=function(expr,elems,not){if(not){expr=":not("+expr+")";}
return Sizzle.matches(expr,elems);};jQuery.dir=function(elem,dir){var matched=[],cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)
matched.push(cur);cur=cur[dir];}
return matched;};jQuery.nth=function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])
if(cur.nodeType==1&&++num==result)
break;return cur;};jQuery.sibling=function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&n!=elem)
r.push(n);}
return r;};return;window.Sizzle=Sizzle;})();jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)
return;if(elem.setInterval&&elem!=window)
elem=window;if(!handler.guid)
handler.guid=this.guid++;if(data!==undefined){var fn=handler;handler=this.proxy(fn);handler.data=data;}
var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){return typeof jQuery!=="undefined"&&!jQuery.event.triggered?jQuery.event.handle.apply(arguments.callee.elem,arguments):undefined;});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var namespaces=type.split(".");type=namespaces.shift();handler.type=namespaces.slice().sort().join(".");var handlers=events[type];if(jQuery.event.specialAll[type])
jQuery.event.specialAll[type].setup.call(elem,data,namespaces);if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem,data,namespaces)===false){if(elem.addEventListener)
elem.addEventListener(type,handle,false);else if(elem.attachEvent)
elem.attachEvent("on"+type,handle);}}
handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)
return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types===undefined||(typeof types==="string"&&types.charAt(0)=="."))
for(var type in events)
this.remove(elem,type+(types||""));else{if(types.type){handler=types.handler;types=types.type;}
jQuery.each(types.split(/\s+/),function(index,type){var namespaces=type.split(".");type=namespaces.shift();var namespace=RegExp("(^|\\.)"+namespaces.slice().sort().join(".*\\.")+"(\\.|$)");if(events[type]){if(handler)
delete events[type][handler.guid];else
for(var handle in events[type])
if(namespace.test(events[type][handle].type))
delete events[type][handle];if(jQuery.event.specialAll[type])
jQuery.event.specialAll[type].teardown.call(elem,namespaces);for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem,namespaces)===false){if(elem.removeEventListener)
elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)
elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}
ret=null;delete events[type];}}});}
for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(event,data,elem,bubbling){var type=event.type||event;if(!bubbling){event=typeof event==="object"?event[expando]?event:jQuery.extend(jQuery.Event(type),event):jQuery.Event(type);if(type.indexOf("!")>=0){event.type=type=type.slice(0,-1);event.exclusive=true;}
if(!elem){event.stopPropagation();if(this.global[type])
jQuery.each(jQuery.cache,function(){if(this.events&&this.events[type])
jQuery.event.trigger(event,data,this.handle.elem);});}
if(!elem||elem.nodeType==3||elem.nodeType==8)
return undefined;event.result=undefined;event.target=elem;data=jQuery.makeArray(data);data.unshift(event);}
event.currentTarget=elem;var handle=jQuery.data(elem,"handle");if(handle)
handle.apply(elem,data);if((!elem[type]||(jQuery.nodeName(elem,'a')&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)
event.result=false;if(!bubbling&&elem[type]&&!event.isDefaultPrevented()&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}
this.triggered=false;if(!event.isPropagationStopped()){var parent=elem.parentNode||elem.ownerDocument;if(parent)
jQuery.event.trigger(event,data,parent,true);}},handle:function(event){var all,handlers;event=arguments[0]=jQuery.event.fix(event||window.event);event.currentTarget=this;var namespaces=event.type.split(".");event.type=namespaces.shift();all=!namespaces.length&&!event.exclusive;var namespace=RegExp("(^|\\.)"+namespaces.slice().sort().join(".*\\.")+"(\\.|$)");handlers=(jQuery.data(this,"events")||{})[event.type];for(var j in handlers){var handler=handlers[j];if(all||namespace.test(handler.type)){event.handler=handler;event.data=handler.data;var ret=handler.apply(this,arguments);if(ret!==undefined){event.result=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}
if(event.isImmediatePropagationStopped())
break;}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(event){if(event[expando])
return event;var originalEvent=event;event=jQuery.Event(originalEvent);for(var i=this.props.length,prop;i;){prop=this.props[--i];event[prop]=originalEvent[prop];}
if(!event.target)
event.target=event.srcElement||document;if(event.target.nodeType==3)
event.target=event.target.parentNode;if(!event.relatedTarget&&event.fromElement)
event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}
if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))
event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)
event.metaKey=event.ctrlKey;if(!event.which&&event.button)
event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},proxy:function(fn,proxy){proxy=proxy||function(){return fn.apply(this,arguments);};proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;return proxy;},special:{ready:{setup:bindReady,teardown:function(){}}},specialAll:{live:{setup:function(selector,namespaces){jQuery.event.add(this,namespaces[0],liveHandler);},teardown:function(namespaces){if(namespaces.length){var remove=0,name=RegExp("(^|\\.)"+namespaces[0]+"(\\.|$)");jQuery.each((jQuery.data(this,"events").live||{}),function(){if(name.test(this.type))
remove++;});if(remove<1)
jQuery.event.remove(this,namespaces[0],liveHandler);}}}}};jQuery.Event=function(src){if(!this.preventDefault)
return new jQuery.Event(src);if(src&&src.type){this.originalEvent=src;this.type=src.type;}else
this.type=src;this.timeStamp=now();this[expando]=true;};function returnFalse(){return false;}
function returnTrue(){return true;}
jQuery.Event.prototype={preventDefault:function(){this.isDefaultPrevented=returnTrue;var e=this.originalEvent;if(!e)
return;if(e.preventDefault)
e.preventDefault();e.returnValue=false;},stopPropagation:function(){this.isPropagationStopped=returnTrue;var e=this.originalEvent;if(!e)
return;if(e.stopPropagation)
e.stopPropagation();e.cancelBubble=true;},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=returnTrue;this.stopPropagation();},isDefaultPrevented:returnFalse,isPropagationStopped:returnFalse,isImmediatePropagationStopped:returnFalse};var withinElement=function(event){var parent=event.relatedTarget;while(parent&&parent!=this)
try{parent=parent.parentNode;}
catch(e){parent=this;}
if(parent!=this){event.type=event.data;jQuery.event.handle.apply(this,arguments);}};jQuery.each({mouseover:'mouseenter',mouseout:'mouseleave'},function(orig,fix){jQuery.event.special[fix]={setup:function(){jQuery.event.add(this,orig,withinElement,fix);},teardown:function(){jQuery.event.remove(this,orig,withinElement);}};});jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);return(fn||data).apply(this,arguments);});return this.each(function(){jQuery.event.add(this,type,one,fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data){return this.each(function(){jQuery.event.trigger(type,data,this);});},triggerHandler:function(type,data){if(this[0]){var event=jQuery.Event(type);event.preventDefault();event.stopPropagation();jQuery.event.trigger(event,data,this[0]);return event.result;}},toggle:function(fn){var args=arguments,i=1;while(i<args.length)
jQuery.event.proxy(fn,args[i++]);return this.click(jQuery.event.proxy(fn,function(event){this.lastToggle=(this.lastToggle||0)%i;event.preventDefault();return args[this.lastToggle++].apply(this,arguments)||false;}));},hover:function(fnOver,fnOut){return this.mouseenter(fnOver).mouseleave(fnOut);},ready:function(fn){bindReady();if(jQuery.isReady)
fn.call(document,jQuery);else
jQuery.readyList.push(fn);return this;},live:function(type,fn){var proxy=jQuery.event.proxy(fn);proxy.guid+=this.selector+type;jQuery(document).bind(liveConvert(type,this.selector),this.selector,proxy);return this;},die:function(type,fn){jQuery(document).unbind(liveConvert(type,this.selector),fn?{guid:fn.guid+this.selector+type}:null);return this;}});function liveHandler(event){var check=RegExp("(^|\\.)"+event.type+"(\\.|$)"),stop=true,elems=[];jQuery.each(jQuery.data(this,"events").live||[],function(i,fn){if(check.test(fn.type)){var elem=jQuery(event.target).closest(fn.data)[0];if(elem)
elems.push({elem:elem,fn:fn});}});elems.sort(function(a,b){return jQuery.data(a.elem,"closest")-jQuery.data(b.elem,"closest");});jQuery.each(elems,function(){if(this.fn.call(this.elem,event,this.fn.data)===false)
return(stop=false);});return stop;}
function liveConvert(type,selector){return["live",type,selector.replace(/\./g,"`").replace(/ /g,"|")].join(".");}
jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.call(document,jQuery);});jQuery.readyList=null;}
jQuery(document).triggerHandler("ready");}}});var readyBound=false;function bindReady(){if(readyBound)return;readyBound=true;if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);jQuery.ready();},false);}else if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);jQuery.ready();}});if(document.documentElement.doScroll&&window==window.top)(function(){if(jQuery.isReady)return;try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;}
jQuery.ready();})();}
jQuery.event.add(window,"load",jQuery.ready);}
jQuery.each(("blur,focus,load,resize,scroll,unload,click,dblclick,"+"mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,"+"change,select,submit,keydown,keypress,keyup,error").split(","),function(i,name){jQuery.fn[name]=function(fn){return fn?this.bind(name,fn):this.trigger(name);};});jQuery(window).bind('unload',function(){for(var id in jQuery.cache)
if(id!=1&&jQuery.cache[id].handle)
jQuery.event.remove(jQuery.cache[id].handle.elem);});(function(){jQuery.support={};var root=document.documentElement,script=document.createElement("script"),div=document.createElement("div"),id="script"+(new Date).getTime();div.style.display="none";div.innerHTML='   <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';var all=div.getElementsByTagName("*"),a=div.getElementsByTagName("a")[0];if(!all||!all.length||!a){return;}
jQuery.support={leadingWhitespace:div.firstChild.nodeType==3,tbody:!div.getElementsByTagName("tbody").length,objectAll:!!div.getElementsByTagName("object")[0].getElementsByTagName("*").length,htmlSerialize:!!div.getElementsByTagName("link").length,style:/red/.test(a.getAttribute("style")),hrefNormalized:a.getAttribute("href")==="/a",opacity:a.style.opacity==="0.5",cssFloat:!!a.style.cssFloat,scriptEval:false,noCloneEvent:true,boxModel:null};script.type="text/javascript";try{script.appendChild(document.createTextNode("window."+id+"=1;"));}catch(e){}
root.insertBefore(script,root.firstChild);if(window[id]){jQuery.support.scriptEval=true;delete window[id];}
root.removeChild(script);if(div.attachEvent&&div.fireEvent){div.attachEvent("onclick",function(){jQuery.support.noCloneEvent=false;div.detachEvent("onclick",arguments.callee);});div.cloneNode(true).fireEvent("onclick");}
jQuery(function(){var div=document.createElement("div");div.style.width=div.style.paddingLeft="1px";document.body.appendChild(div);jQuery.boxModel=jQuery.support.boxModel=div.offsetWidth===2;document.body.removeChild(div).style.display='none';});})();var styleFloat=jQuery.support.cssFloat?"cssFloat":"styleFloat";jQuery.props={"for":"htmlFor","class":"className","float":styleFloat,cssFloat:styleFloat,styleFloat:styleFloat,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",tabindex:"tabIndex"};jQuery.fn.extend({_load:jQuery.fn.load,load:function(url,params,callback){if(typeof url!=="string")
return this._load(url);var off=url.indexOf(" ");if(off>=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}
var type="GET";if(params)
if(jQuery.isFunction(params)){callback=params;params=null;}else if(typeof params==="object"){params=jQuery.param(params);type="POST";}
var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")
self.html(selector?jQuery("<div/>").append(res.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(selector):res.responseText);if(callback)
self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return this.elements?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:jQuery.isArray(val)?jQuery.map(val,function(val,i){return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);};});var jsc=now();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null;}
return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={};}
return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));var jsonp,jsre=/=\?(&|$)/g,status,data,type=s.type.toUpperCase();if(s.data&&s.processData&&typeof s.data!=="string")
s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(type=="GET"){if(!s.url.match(jsre))
s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";}else if(!s.data||!s.data.match(jsre))
s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";s.dataType="json";}
if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data)
s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp];}catch(e){}
if(head)
head.removeChild(script);};}
if(s.dataType=="script"&&s.cache==null)
s.cache=false;if(s.cache===false&&type=="GET"){var ts=now();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}
if(s.data&&type=="GET"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}
if(s.global&&!jQuery.active++)
jQuery.event.trigger("ajaxStart");var parts=/^(\w+:)?\/\/([^\/?#]+)/.exec(s.url);if(s.dataType=="script"&&type=="GET"&&parts&&(parts[1]&&parts[1]!=location.protocol||parts[2]!=location.host)){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset)
script.charset=s.scriptCharset;if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();script.onload=script.onreadystatechange=null;head.removeChild(script);}};}
head.appendChild(script);return undefined;}
var requestDone=false;var xhr=s.xhr();if(s.username)
xhr.open(type,s.url,s.async,s.username,s.password);else
xhr.open(type,s.url,s.async);try{if(s.data)
xhr.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)
xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}
if(s.beforeSend&&s.beforeSend(xhr,s)===false){if(s.global&&!--jQuery.active)
jQuery.event.trigger("ajaxStop");xhr.abort();return false;}
if(s.global)
jQuery.event.trigger("ajaxSend",[xhr,s]);var onreadystatechange=function(isTimeout){if(xhr.readyState==0){if(ival){clearInterval(ival);ival=null;if(s.global&&!--jQuery.active)
jQuery.event.trigger("ajaxStop");}}else if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}
status=isTimeout=="timeout"?"timeout":!jQuery.httpSuccess(xhr)?"error":s.ifModified&&jQuery.httpNotModified(xhr,s.url)?"notmodified":"success";if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s);}catch(e){status="parsererror";}}
if(status=="success"){var modRes;try{modRes=xhr.getResponseHeader("Last-Modified");}catch(e){}
if(s.ifModified&&modRes)
jQuery.lastModified[s.url]=modRes;if(!jsonp)
success();}else
jQuery.handleError(s,xhr,status);complete();if(isTimeout)
xhr.abort();if(s.async)
xhr=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)
setTimeout(function(){if(xhr&&!requestDone)
onreadystatechange("timeout");},s.timeout);}
try{xhr.send(s.data);}catch(e){jQuery.handleError(s,xhr,null,e);}
if(!s.async)
onreadystatechange();function success(){if(s.success)
s.success(data,status);if(s.global)
jQuery.event.trigger("ajaxSuccess",[xhr,s]);}
function complete(){if(s.complete)
s.complete(xhr,status);if(s.global)
jQuery.event.trigger("ajaxComplete",[xhr,s]);if(s.global&&!--jQuery.active)
jQuery.event.trigger("ajaxStop");}
return xhr;},handleError:function(s,xhr,status,e){if(s.error)s.error(xhr,status,e);if(s.global)
jQuery.event.trigger("ajaxError",[xhr,s,e]);},active:0,httpSuccess:function(xhr){try{return!xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223;}catch(e){}
return false;},httpNotModified:function(xhr,url){try{var xhrRes=xhr.getResponseHeader("Last-Modified");return xhr.status==304||xhrRes==jQuery.lastModified[url];}catch(e){}
return false;},httpData:function(xhr,type,s){var ct=xhr.getResponseHeader("content-type"),xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;if(xml&&data.documentElement.tagName=="parsererror")
throw"parsererror";if(s&&s.dataFilter)
data=s.dataFilter(data,type);if(typeof data==="string"){if(type=="script")
jQuery.globalEval(data);if(type=="json")
data=window["eval"]("("+data+")");}
return data;},param:function(a){var s=[];function add(key,value){s[s.length]=encodeURIComponent(key)+'='+encodeURIComponent(value);};if(jQuery.isArray(a)||a.jquery)
jQuery.each(a,function(){add(this.name,this.value);});else
for(var j in a)
if(jQuery.isArray(a[j]))
jQuery.each(a[j],function(){add(j,this);});else
add(j,jQuery.isFunction(a[j])?a[j]():a[j]);return s.join("&").replace(/%20/g,"+");}});var elemdisplay={},timerId,fxAttrs=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function genFx(type,num){var obj={};jQuery.each(fxAttrs.concat.apply([],fxAttrs.slice(0,num)),function(){obj[this]=type;});return obj;}
jQuery.fn.extend({show:function(speed,callback){if(speed){return this.animate(genFx("show",3),speed,callback);}else{for(var i=0,l=this.length;i<l;i++){var old=jQuery.data(this[i],"olddisplay");this[i].style.display=old||"";if(jQuery.css(this[i],"display")==="none"){var tagName=this[i].tagName,display;if(elemdisplay[tagName]){display=elemdisplay[tagName];}else{var elem=jQuery("<"+tagName+" />").appendTo("body");display=elem.css("display");if(display==="none")
display="block";elem.remove();elemdisplay[tagName]=display;}
jQuery.data(this[i],"olddisplay",display);}}
for(var i=0,l=this.length;i<l;i++){this[i].style.display=jQuery.data(this[i],"olddisplay")||"";}
return this;}},hide:function(speed,callback){if(speed){return this.animate(genFx("hide",3),speed,callback);}else{for(var i=0,l=this.length;i<l;i++){var old=jQuery.data(this[i],"olddisplay");if(!old&&old!=="none")
jQuery.data(this[i],"olddisplay",jQuery.css(this[i],"display"));}
for(var i=0,l=this.length;i<l;i++){this[i].style.display="none";}
return this;}},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){var bool=typeof fn==="boolean";return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle.apply(this,arguments):fn==null||bool?this.each(function(){var state=bool?fn:jQuery(this).is(":hidden");jQuery(this)[state?"show":"hide"]();}):this.animate(genFx("toggle",3),fn,fn2);},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);return this[optall.queue===false?"each":"queue"](function(){var opt=jQuery.extend({},optall),p,hidden=this.nodeType==1&&jQuery(this).is(":hidden"),self=this;for(p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)
return opt.complete.call(this);if((p=="height"||p=="width")&&this.style){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow;}}
if(opt.overflow!=null)
this.style.overflow="hidden";opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(/toggle|show|hide/.test(val))
e[val=="toggle"?hidden?"show":"hide":val](prop);else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit;}
if(parts[1])
end=((parts[1]=="-="?-1:1)*end)+start;e.custom(start,end,unit);}else
e.custom(start,val,"");}});return true;});},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue)
this.queue([]);this.each(function(){for(var i=timers.length-1;i>=0;i--)
if(timers[i].elem==this){if(gotoEnd)
timers[i](true);timers.splice(i,1);}});if(!gotoEnd)
this.dequeue();return this;}});jQuery.each({slideDown:genFx("show",1),slideUp:genFx("hide",1),slideToggle:genFx("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(name,props){jQuery.fn[name]=function(speed,callback){return this.animate(props,speed,callback);};});jQuery.extend({speed:function(speed,easing,fn){var opt=typeof speed==="object"?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&!jQuery.isFunction(easing)&&easing};opt.duration=jQuery.fx.off?0:typeof opt.duration==="number"?opt.duration:jQuery.fx.speeds[opt.duration]||jQuery.fx.speeds._default;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)
jQuery(this).dequeue();if(jQuery.isFunction(opt.old))
opt.old.call(this);};return opt;},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;}},timers:[],fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig)
options.orig={};}});jQuery.fx.prototype={update:function(){if(this.options.step)
this.options.step.call(this.elem,this.now,this);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style)
this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))
return this.elem[this.prop];var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;},custom:function(from,to,unit){this.startTime=now();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;var self=this;function t(gotoEnd){return self.step(gotoEnd);}
t.elem=this.elem;if(t()&&jQuery.timers.push(t)&&!timerId){timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;i<timers.length;i++)
if(!timers[i]())
timers.splice(i--,1);if(!timers.length){clearInterval(timerId);timerId=undefined;}},13);}},show:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.show=true;this.custom(this.prop=="width"||this.prop=="height"?1:0,this.cur());jQuery(this.elem).show();},hide:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0);},step:function(gotoEnd){var t=now();if(gotoEnd||t>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim)
if(this.options.curAnim[i]!==true)
done=false;if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none")
this.elem.style.display="block";}
if(this.options.hide)
jQuery(this.elem).hide();if(this.options.hide||this.options.show)
for(var p in this.options.curAnim)
jQuery.attr(this.elem.style,p,this.options.orig[p]);this.options.complete.call(this.elem);}
return false;}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update();}
return true;}};jQuery.extend(jQuery.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){if(fx.elem.style&&fx.elem.style[fx.prop]!=null)
fx.elem.style[fx.prop]=fx.now+fx.unit;else
fx.elem[fx.prop]=fx.now;}}});if(document.documentElement["getBoundingClientRect"])
jQuery.fn.offset=function(){if(!this[0])return{top:0,left:0};if(this[0]===this[0].ownerDocument.body)return jQuery.offset.bodyOffset(this[0]);var box=this[0].getBoundingClientRect(),doc=this[0].ownerDocument,body=doc.body,docElem=doc.documentElement,clientTop=docElem.clientTop||body.clientTop||0,clientLeft=docElem.clientLeft||body.clientLeft||0,top=box.top+(self.pageYOffset||jQuery.boxModel&&docElem.scrollTop||body.scrollTop)-clientTop,left=box.left+(self.pageXOffset||jQuery.boxModel&&docElem.scrollLeft||body.scrollLeft)-clientLeft;return{top:top,left:left};};else
jQuery.fn.offset=function(){if(!this[0])return{top:0,left:0};if(this[0]===this[0].ownerDocument.body)return jQuery.offset.bodyOffset(this[0]);jQuery.offset.initialized||jQuery.offset.initialize();var elem=this[0],offsetParent=elem.offsetParent,prevOffsetParent=elem,doc=elem.ownerDocument,computedStyle,docElem=doc.documentElement,body=doc.body,defaultView=doc.defaultView,prevComputedStyle=defaultView.getComputedStyle(elem,null),top=elem.offsetTop,left=elem.offsetLeft;while((elem=elem.parentNode)&&elem!==body&&elem!==docElem){computedStyle=defaultView.getComputedStyle(elem,null);top-=elem.scrollTop,left-=elem.scrollLeft;if(elem===offsetParent){top+=elem.offsetTop,left+=elem.offsetLeft;if(jQuery.offset.doesNotAddBorder&&!(jQuery.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(elem.tagName)))
top+=parseInt(computedStyle.borderTopWidth,10)||0,left+=parseInt(computedStyle.borderLeftWidth,10)||0;prevOffsetParent=offsetParent,offsetParent=elem.offsetParent;}
if(jQuery.offset.subtractsBorderForOverflowNotVisible&&computedStyle.overflow!=="visible")
top+=parseInt(computedStyle.borderTopWidth,10)||0,left+=parseInt(computedStyle.borderLeftWidth,10)||0;prevComputedStyle=computedStyle;}
if(prevComputedStyle.position==="relative"||prevComputedStyle.position==="static")
top+=body.offsetTop,left+=body.offsetLeft;if(prevComputedStyle.position==="fixed")
top+=Math.max(docElem.scrollTop,body.scrollTop),left+=Math.max(docElem.scrollLeft,body.scrollLeft);return{top:top,left:left};};jQuery.offset={initialize:function(){if(this.initialized)return;var body=document.body,container=document.createElement('div'),innerDiv,checkDiv,table,td,rules,prop,bodyMarginTop=body.style.marginTop,html='<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';rules={position:'absolute',top:0,left:0,margin:0,border:0,width:'1px',height:'1px',visibility:'hidden'};for(prop in rules)container.style[prop]=rules[prop];container.innerHTML=html;body.insertBefore(container,body.firstChild);innerDiv=container.firstChild,checkDiv=innerDiv.firstChild,td=innerDiv.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(checkDiv.offsetTop!==5);this.doesAddBorderForTableAndCells=(td.offsetTop===5);innerDiv.style.overflow='hidden',innerDiv.style.position='relative';this.subtractsBorderForOverflowNotVisible=(checkDiv.offsetTop===-5);body.style.marginTop='1px';this.doesNotIncludeMarginInBodyOffset=(body.offsetTop===0);body.style.marginTop=bodyMarginTop;body.removeChild(container);this.initialized=true;},bodyOffset:function(body){jQuery.offset.initialized||jQuery.offset.initialize();var top=body.offsetTop,left=body.offsetLeft;if(jQuery.offset.doesNotIncludeMarginInBodyOffset)
top+=parseInt(jQuery.curCSS(body,'marginTop',true),10)||0,left+=parseInt(jQuery.curCSS(body,'marginLeft',true),10)||0;return{top:top,left:left};}};jQuery.fn.extend({position:function(){var left=0,top=0,results;if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();offset.top-=num(this,'marginTop');offset.left-=num(this,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}
return results;},offsetParent:function(){var offsetParent=this[0].offsetParent||document.body;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,'position')=='static'))
offsetParent=offsetParent.offsetParent;return jQuery(offsetParent);}});jQuery.each(['Left','Top'],function(i,name){var method='scroll'+name;jQuery.fn[method]=function(val){if(!this[0])return null;return val!==undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;}):this[0]==window||this[0]==document?self[i?'pageYOffset':'pageXOffset']||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];};});jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom",lower=name.toLowerCase();jQuery.fn["inner"+name]=function(){return this[0]?jQuery.css(this[0],lower,false,"padding"):null;};jQuery.fn["outer"+name]=function(margin){return this[0]?jQuery.css(this[0],lower,false,margin?"margin":"border"):null;};var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(document.documentElement["client"+name],document.body["scroll"+name],document.documentElement["scroll"+name],document.body["offset"+name],document.documentElement["offset"+name]):size===undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,typeof size==="string"?size:size+"px");};});})();Evri.jQuery.browser.msie6=Evri.jQuery.browser.msie&&(parseInt(Evri.jQuery.browser.version)<=6);Evri.jQuery.browser.msie7=Evri.jQuery.browser.msie&&(parseInt(Evri.jQuery.browser.version)==7);Evri.jQuery.browser.msie8=Evri.jQuery.browser.msie&&(parseInt(Evri.jQuery.browser.version)==8);Evri.jQuery.windowDimensions=function(){var myWidth=0,myHeight=0;if(typeof(window.innerWidth)=='number'){myWidth=window.innerWidth;myHeight=window.innerHeight;}
else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){myWidth=document.documentElement.clientWidth;myHeight=document.documentElement.clientHeight;}
else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){myWidth=document.body.clientWidth;myHeight=document.body.clientHeight;}
return{width:myWidth,height:myHeight};};Evri.jQuery.windowScroll=function()
{var scrOfX=0,scrOfY=0;if(typeof(window.pageYOffset)=='number'){scrOfY=window.pageYOffset;scrOfX=window.pageXOffset;}
else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;scrOfX=document.body.scrollLeft;}
else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;scrOfX=document.documentElement.scrollLeft;}
return{x:scrOfX,y:scrOfY};};Evri.jQuery.fn.center=function()
{this.each(function(){var el=Evri.jQuery(this);var winH=Evri.jQuery.windowDimensions().height;var winW=Evri.jQuery.windowDimensions().width;if(winH<el.height())
{var y=0;}
else
{var y=winH/2-el.height()/2;}
if(winW<el.width())
{var x=winW-el.width();}
else
{var x=winW/2-el.width()/2;}
if(Evri.jQuery.browser.msie6)
{el.css('position','absolute');y+=Evri.jQuery.windowScroll().y;x+=Evri.jQuery.windowScroll().x;}
el.css("top",y);el.css("left",x);});return this;};Evri.jQuery.fn.mergeHtml=function(){var text='';var textForNodes={};this.each(function(index,element){var nodeText=Evri.$(element).text();if(textForNodes[nodeText]===undefined){text+=nodeText+'\n\n';textForNodes[nodeText]=1;}});return text;};Evri.jQuery.fn.forceLayout=function(defer){if(Evri.jQuery.browser.msie6){defer=defer||0;setTimeout(function(){this.css("zoom",1);},defer);}
return this;};Evri.jQuery.fn.pngFix=function(){var $=Evri.jQuery;if(!Evri.jQuery.browser.msie6)return this;function fixImage(img)
{var imgName=img.src.toUpperCase();if(imgName.substring(imgName.length-3,imgName.length)=="PNG")
{var span=$("<span />");var properties=["id","class","title","alt","style"];$.each(properties,function(i,prop){span.attr(prop,$(img).attr(prop));});var filter="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+"(src=\'"+img.src+"\', sizingMethod='scale');";span.attr("style",span.attr("style")+filter);$(img).replaceWith(span);}}
this.each(function(){fixImage(this);});return this;};Evri.jQuery.browser.macFirefox=function(){var userAgent=navigator.userAgent.toLowerCase();if(userAgent.indexOf('mac')!=-1&&userAgent.indexOf('firefox')!=-1){return true;}
return false;};Evri.jQuery.fn.browserClass=function(){var self=this;var browsers=["msie","mozilla","safari"];Evri.jQuery.each(browsers,function(){Evri.jQuery.browser[this]&&self.addClass(this);});return self;};Evri.jQuery.parseQueryString=function(str){var value={};var items=str.split("&");Evri.$.each(items,function(k,v){var vals=v.split("=");value[vals[0]]=decodeURIComponent(vals[1]);});return value;};(function($){$.fn.onScrollIntoView=function(callback,options){var $selection=this;var $window=Evri.$(window);options=options||{};options.topOffset=options.topOffset||0;options.interval=options.interval||2500;$selection.each(function(index,item){var $container=$(item);var scrollIntoViewProcessId=undefined;scrollIntoViewProcessId=setInterval(function(){var windowScrollBottom=$window.scrollTop()+$window.height();var containerTop=$container.offset().top;if(windowScrollBottom>(containerTop+options.topOffset)){callback.call();clearInterval(scrollIntoViewProcessId);}},options.interval);});return $selection;};})(Evri.$);Evri.defineNamespace(Evri,'Widget');Evri.defineNamespace(Evri.Widget,"Utilities");Evri.extendNamespace(Evri.Widget.Utilities,{getContent:function(){return Evri.$("h1, p").mergeHtml();},toQueryString:function(params){var paramItems=[];for(var key in params){paramItems.push(key+"="+encodeURIComponent(params[key]));}
return paramItems.join('&');},useStylesheet:function(url){Evri.$("head").append(Evri.$('<link rel="stylesheet" type="text/css" href="'+url+'" />'));}});Evri.defineNamespace(Evri.Widget,"Environment",{set:function(name,value){Evri.Widget.Environment[name]=value;},apiURL:"http://api.evri.com",domainURL:"http://www.evri.com",verticalWidgetURL:"http://www.evri.com/widget/swfs/VerticalSidebar.swf",widgetURL:"http://www.evri.com/widget/swfs/WidgetBase.swf",youTubePlayerURL:"http://www.evri.com/widget/swfs/YouTube.swf"});Evri.defineClass(Evri.Widget,"Analytics",function(widgetName){var self=this;self.name=widgetName;self.host=window.location.hostname;self.path=window.location.pathname;self.loggingDomain=Evri.Widget.Environment.domainURL;return self;});Evri.extendClass(Evri.Widget.Analytics,{log:function(eventName,params){var self=this;params=params||{};var iframe=document.createElement('iframe');iframe.style.position='absolute';iframe.style.height='1px';iframe.style.width='1px';iframe.style.top='0px';iframe.style.left='-10px';iframe.setAttribute("src",self.loggingStatement(eventName,params));document.body.appendChild(iframe);iframe.blur();},logTest:function(eventName,params){var self=this;var statement=self.loggingStatement(eventName,params);try{console.log(statement);}catch(e){};},loggingStatement:function(eventName,params){var self=this;params=params||{};var statement=self.loggingDomain+"/analytics/"+self.name+"/"+self.host+"/-/"+eventName;params.path=self.path;statement+='?'+Evri.Widget.Utilities.toQueryString(params);return statement;},trackDHTML:function(eventName,params){var self=this;params=params||{};self.log("DHTML/"+eventName,params);},trackReferral:function(eventName,params){var self=this;params=params||{};self.log("REFERRAL/"+eventName,params);},trackError:function(name,params){var self=this;params=params||{};self.log("ERROR/"+name,params);},setTestMode:function(){var self=this;self.log=self.logTest;}});Evri.defineClass(Evri.Widget,"MediaViewSet",function(session){var self=this;self.views=[new Evri.Widget.MediaView('From the web')];self.currentView=self.views[0];self.session=session;return self;});Evri.extendClass(Evri.Widget.MediaViewSet,{clear:function(){var self=this;self.views=[];self.currentView=undefined;return self;},addView:function(label){var self=this;var mc=new self.session.models.MediaConstraint();var mediaView=new Evri.Widget.MediaView(label,mc);if(self.views.length===0){self.currentView=mediaView;}
self.views.push(mediaView);return mediaView;},setView:function(view){var self=this;for(var i=0;i<self.views.length;i++){if(self.views[i]===view){self.currentView=view;}}
if(self.currentView===undefined&&self.views.length>0){self.currentView=view;}
return self;}});Evri.defineClass(Evri.Widget,"MediaView",function(label,constraint){var self=this;self.label=label;self.mediaConstraint=constraint;return self;});Evri.extendClass(Evri.Widget.MediaView,{clearConstraints:function(){var self=this;self.mediaConstraint=undefined;return self;},includeDomain:function(domain){var self=this;self.mediaConstraint.includeDomain(domain);return self;},excludeDomain:function(domain){var self=this;self.mediaConstraint.excludeDomain(domain);return self;}});Evri.defineNamespace(Evri.Widget,"Components");Evri.defineNamespace(Evri.Widget.Components,"Behaviors",{bindable:function(self){var bindings={};self.addBinding=function(bindingName,callback){bindings[bindingName]=bindings[bindingName]||[];bindings[bindingName].push(callback);};self.executeBinding=function(bindingName){var binding=bindings[bindingName];if(binding===undefined){return;}
for(var i=0;i<binding.length;i++){binding[i].call(self,self);}};return self;}});Evri.defineNamespace(Evri.Widget.Components,"Helpers",{jQueryBaconl:function(template){var tokens=Evri.Widget.Components.Helpers.baconl(template);var element=Evri.jQuery("<"+tokens.tag+"/>");if(tokens.id){element.attr("id",tokens.id);}
if(tokens.classes.length>0){element.addClass(tokens.classes.join(" "));}
return element;},baconl:function(template){if(template===undefined){return undefined;}
var tokens={id:undefined,classes:[],tag:undefined,innerHTML:""};var tagDefinition=/^\s*%([A-Za-z][A-Za-z0-9]*)/;var idDefinition=/^\#([A-Za-z][A-Za-z0-9:_\-]*)/;var classDefinition=/^\.([A-Za-z][A-Za-z0-9:_\-]*)/;var innerHTMLDefinition=/\s*\\?((.|[\n])+)/m;var nextToken=template.match(tagDefinition);if(!!nextToken){tokens.tag=nextToken[1];}
template=template.replace(tagDefinition,"");nextToken=template.match(idDefinition);tokens.id=!!nextToken?nextToken[1]:undefined;template=template.replace(idDefinition,"");nextToken=template.match(classDefinition);while(!!nextToken){tokens.classes.push(nextToken[1]);template=template.replace(classDefinition,"");nextToken=template.match(classDefinition);}
if(tokens.tag===undefined){tokens.tag="div";}
nextToken=template.match(innerHTMLDefinition);tokens.innerHTML=!!nextToken?nextToken[1]:undefined;return tokens;},wordTruncateString:function(string,length){if(string.length<length)return string;var truncatedString=string.substring(0,length);truncatedString=truncatedString.replace(/(\s*\w*)$/,"...");return truncatedString;},scrollAnalytics:function(self,section,analytics){var $=Evri.$;self.find(".up-scroll").bind("click.analytics",function(){if(!$(this).is(".up-scroll-disabled")){analytics.trackDHTML(section+"/ScrollUp");}}).end().find(".down-scroll").bind("click.analytics",function(){if(!$(this).is(".down-scroll-disabled")){analytics.trackDHTML(section+"/ScrollDown");}});},createScrollButtonsForList:function(list,analyticsSection){var $=Evri.jQuery;list.css({top:0});var upButton=$("<a />").addClass("up-scroll").attr({'href':'javascript:void(0);'}).append($("<div />").addClass("arrow-icon").css("zoom",1));var downButton=$("<a />").addClass("down-scroll").attr({'href':'javascript:void(0);'}).append($("<div />").addClass("arrow-icon"));var listItems=list.children("li");var scrollDownFocusIndex=undefined;var scrollUpFocusIndex=0;function scrollDown(){var listOffsetTop=Math.abs(parseInt(list.css('top')));var viewPaneHeight=list.parent().outerHeight();var viewPaneIntersectHeight=listOffsetTop+viewPaneHeight;var veryLastItem=list.children("li:last");var lastItemInView=undefined;var lastItemIndexInView=undefined;$.each(listItems,function(index,item){var position=$(item).position();if(position.top<viewPaneIntersectHeight){lastItemInView=item;lastItemIndexInView=index;}});if(scrollDownFocusIndex===lastItemIndexInView&&lastItemInView!==veryLastItem[0]){lastItemInView=$(lastItemInView).next()[0];lastItemIndexInView++;}
scrollDownFocusIndex=lastItemIndexInView;scrollUpFocusIndex=undefined;var newListOffsetTop=0-($(lastItemInView).position().top+$(lastItemInView).outerHeight()-viewPaneHeight);scrollToTopPosition(newListOffsetTop);};function scrollUp(){var listOffsetTop=Math.abs(parseInt(list.css('top')));var firstItemInView=undefined;if(scrollUpFocusIndex!==0){if(scrollUpFocusIndex!==undefined&&scrollUpFocusIndex>0){scrollUpFocusIndex--;firstItemInView=listItems[scrollUpFocusIndex];}
else{scrollDownFocusIndex=undefined;$.each(listItems,function(index,item){var position=$(item).position();if(position.top<listOffsetTop){firstItemInView=item;scrollUpFocusIndex=index;}});}
var newListOffsetTop=0-($(firstItemInView).position().top);scrollToTopPosition(newListOffsetTop);}};function scrollToTopPosition(topPosition){while(list.is(":animated"))list.stop();list.animate({"top":topPosition});};function resetButtons(){if(scrollUpFocusIndex!==0){upButton.removeClass("up-scroll-disabled");}
else{upButton.addClass("up-scroll-disabled");}
if(scrollDownFocusIndex!==(listItems.length-1)){downButton.removeClass("down-scroll-disabled");}
else{downButton.addClass("down-scroll-disabled");}}
downButton.click(function(){if((!$(this).hasClass("down-scroll-disabled"))&&(scrollDownFocusIndex===undefined||scrollDownFocusIndex<(listItems.length-1))){downButton.blur();scrollDown();resetButtons();}});upButton.click(function(){if(scrollUpFocusIndex===undefined||scrollUpFocusIndex>0){upButton.blur();scrollUp();resetButtons();}});resetButtons();return{up:upButton,down:downButton};},makeVerticalCarousel:function(orderedList){var Helpers=Evri.Widget.Components.Helpers;return Helpers.createScrollButtonsForList(orderedList,"");},generateVerticalCarousel:function(itemsList,itemBuilder){var Helpers=Evri.Widget.Components.Helpers;var listViewport=Helpers.generateItemsList(itemsList,itemBuilder);var buttons=Helpers.makeVerticalCarousel(listViewport.find("ol"));return[buttons.up,listViewport,buttons.down];},expandVerticalCarrousel:function(object){var buttons=object.children(".component-button");var listHeight=0;object.height(object.parent().height());listHeight=object.height();buttons.each(function(index,object){listHeight-=Evri.jQuery(object).height();});object.children(".viewport").height(listHeight);},generateItemsList:function(items,itemGenerator){var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;var $=Evri.jQuery;var orderedList=baconl("%ol");var viewport=baconl("%div.viewport");viewport.append(orderedList);$.each(items,function(index,item){orderedList.append(itemGenerator(item,orderedList));});return viewport;},generateArticleListItem:function(article){var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;var listItem=baconl("%li");var attribution=baconl("%p.component-attribution");var hasAuthor=(article.author!==undefined&&article.author.length)||(article.link&&article.link.hostName&&article.link.hostName.length);attribution.append(article.getRelativePublicationDate());if(hasAuthor&&article.getRelativePublicationDate().length>0){attribution.append(" | ");}
attribution.append(article.author||article.link.hostName);listItem.append(baconl("%h3").html(baconl("%a").html(article.title).attr({"href":article.link.href,"target":"_blank"})),baconl("%p.component-snippet").html(article.getHighlightedContent('em')),attribution);return listItem;},createHorizontalScrollButtonsForList:function(list,analyticsSection){var $=Evri.jQuery;list.css({left:0});var leftButton=$("<a />").addClass("left-scroll").attr({'href':'javascript:void(0);'}).append($("<div />").addClass("arrow-icon").css("zoom",1));var rightButton=$("<a />").addClass("right-scroll").attr({'href':'javascript:void(0);'}).append($("<div />").addClass("arrow-icon"));var listItems=list.children("li");list.children("li:first").addClass("current-item");var scrollRightFocusIndex=undefined;var scrollLeftFocusIndex=0;function scrollRight(){var listOffsetleft=Math.abs(parseInt(list.css('left')));var viewPaneWidth=list.parent().outerWidth();var viewPaneIntersectWidth=listOffsetleft+viewPaneWidth;var veryLastItem=list.children("li:last");var lastItemInView=undefined;var lastItemIndexInView=undefined;$.each(listItems,function(index,item){var position=$(item).position();if(position.left<viewPaneIntersectWidth){lastItemInView=item;lastItemIndexInView=index;}});if((scrollRightFocusIndex==undefined||scrollRightFocusIndex===lastItemIndexInView)&&lastItemInView!==veryLastItem[0]){lastItemInView=$(lastItemInView).next()[0];lastItemIndexInView++;}
scrollRightFocusIndex=lastItemIndexInView;scrollLeftFocusIndex=undefined;var newListOffsetLeft=0-($(lastItemInView).position().left+$(lastItemInView).outerWidth()-viewPaneWidth);scrollToLeftPosition(newListOffsetLeft,lastItemInView);};function scrollLeft(){var listOffsetleft=Math.abs(parseInt(list.css('left')));var firstItemInView=undefined;if(scrollLeftFocusIndex!==0){if(scrollLeftFocusIndex!==undefined&&scrollLeftFocusIndex>0){scrollLeftFocusIndex--;firstItemInView=listItems[scrollLeftFocusIndex];}else{scrollRightFocusIndex=undefined;$.each(listItems,function(index,item){var position=$(item).position();if(position.left<listOffsetleft){firstItemInView=item;scrollLeftFocusIndex=index;}});}
var newListOffsetLeft=0-($(firstItemInView).position().left);scrollToLeftPosition(newListOffsetLeft,firstItemInView);}};function scrollToLeftPosition(leftPosition,currentItem){list.find("li").removeClass("current-item");$(currentItem).addClass("current-item");while(list.is(":animated"))list.stop();list.animate({"left":leftPosition});};function resetButtons(){if(scrollLeftFocusIndex!==0){leftButton.removeClass("left-scroll-disabled");}else{leftButton.addClass("left-scroll-disabled");}
if(scrollRightFocusIndex!==(listItems.length-1)){rightButton.removeClass("right-scroll-disabled");}else{rightButton.addClass("right-scroll-disabled");}};rightButton.click(function(){if((!$(this).hasClass("right-scroll-disabled"))&&(scrollRightFocusIndex===undefined||scrollRightFocusIndex<(listItems.length-1))){rightButton.blur();scrollRight();resetButtons();}});leftButton.click(function(){if(scrollLeftFocusIndex===undefined||scrollLeftFocusIndex>0){leftButton.blur();scrollLeft();resetButtons();}});resetButtons();return{left:leftButton,right:rightButton};},makeHorizontalCarousel:function(orderedList){var Helpers=Evri.Widget.Components.Helpers;return Helpers.createHorizontalScrollButtonsForList(orderedList,"");},generateHorizontalItemsList:function(items,itemBuilder){var Helpers=Evri.Widget.Components.Helpers;var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;var $=Evri.$;var viewport=baconl("%div.horizontal-viewport");viewport.append(itemBuilder(items));var buttons=Helpers.makeHorizontalCarousel(viewport.find("ol.horizontal"));return[buttons.left,viewport,buttons.right];},trimLongText:function(text,heightAvailable,styles){var self=this;self.$=Evri.$;if(self.$("#evri-ph-for-stringWidth").length==0){self.$(document.body).append(self.$('<div/>').attr('id','evri-ph-for-stringWidth').css({'visibility':'hidden','position':'absolute'}));}
var div=self.$("#evri-ph-for-stringWidth").css(styles).empty();div.html(text);var initialHeight=div.get(0).offsetHeight;if(initialHeight<=heightAvailable){div.empty();return text;}else{for(var cntr=text.length;cntr>=0;cntr--){div.empty();var newText=text.substr(0,cntr);div.html(newText);var currentHeight=div.get(0).offsetHeight;if(currentHeight<=heightAvailable){div.empty();newText=newText.substr(0,newText.length-3);return newText+"...";}}}},validateVerticalScroll:function(listViewport,buttonUp,buttonDown){var list=listViewport.find("ol");var listOffsetTop=Math.abs(parseInt(list.css('top')));var viewPaneHeight=list.parent().outerHeight();if(listOffsetTop==0){var listHeight=list.outerHeight();if(listHeight<viewPaneHeight){var thumbnails=list.find("img.component-thumbnail");var thumbnailCount=thumbnails.length;if(thumbnailCount==0){Evri.Widget.Components.Helpers.checkAndDisableVerticalScroll(list,buttonDown);}else{Evri.Widget.Components.Helpers.waitForThumbnailsToLoad(list,buttonDown,thumbnails);}}}},checkAndDisableVerticalScroll:function(list,buttonDown){var listHeight=list.outerHeight();var viewPaneHeight=list.parent().outerHeight();if(listHeight>viewPaneHeight){buttonDown.removeClass("down-scroll-disabled");}else{buttonDown.addClass("down-scroll-disabled");}},waitForThumbnailsToLoad:function(list,buttonDown,thumbnails){Evri.$.each(thumbnails,function(index,thumbnail){if(thumbnail.complete){Evri.Widget.Components.Helpers.checkAndDisableVerticalScroll(list,buttonDown);}
else{Evri.$(thumbnail).load(function(){Evri.Widget.Components.Helpers.checkAndDisableVerticalScroll(list,buttonDown);});Evri.$(thumbnail).error(function(){Evri.Widget.Components.Helpers.checkAndDisableVerticalScroll(list,buttonDown);});}});}});Evri.defineClass(Evri.Widget.Components,"MediaListColumns",function(options){options=options||{};var analytics=options.analytics||new Evri.Widget.Analytics(this.componentName);var columns=options.columns||1;var $=Evri.jQuery;var Helpers=Evri.Widget.Components.Helpers;var baconl=Helpers.jQueryBaconl;var self=this;$.extend(self,baconl("%div").addClass(this.componentClass));self.columns=function(){return columns;}
self.analytics=function(){return analytics;}});Evri.extendClass(Evri.Widget.Components.MediaListColumns,{render:function(list){var Helpers=Evri.Widget.Components.Helpers;var self=this;self.empty();var mediaRows=[];var currentRow=[];Evri.$.each(list,function(i){currentRow.push(this);if(currentRow.length===self.columns()||i===(list.length-1)){mediaRows.push(currentRow);currentRow=[];}});var items=self.generateListItems(mediaRows);self.append.apply(self,items);Helpers.validateVerticalScroll(items[1],items[0],items[2]);self.bindAnalytics();},renderHorizontal:function(list,viewPort){var self=this;var Helpers=Evri.Widget.Components.Helpers;if(viewPort){viewPort.remove();}else{self.empty();}
var listViewport=Helpers.generateHorizontalItemsList(list,function(){return self.itemGenerator.apply(self,arguments);});self.append.apply(self,listViewport);self.afterRender&&self.afterRender();return self;},renderMessage:function(str){var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;this.html(baconl("%div.evri-info-message.centered").html(str));},generateListItems:function(mediaRows){var Helpers=Evri.Widget.Components.Helpers;var baconl=Helpers.jQueryBaconl;var self=this;return Helpers.generateVerticalCarousel(mediaRows,function(items,orderedList){var wrapper=baconl("%li");Evri.$.each(items,function(i,item){var thumbnail=self.generateItemCell(item,orderedList);wrapper.append(thumbnail);});return wrapper;});}});Evri.defineClass(Evri.Widget.Components,"MediaList",function(){var self=this;var options=Evri.$.extend({analytics:new Evri.Widget.Analytics(self.componentName)},arguments[0]||{});self.analytics=options.analytics;var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;Evri.$.extend(self,baconl("%div").addClass(self.componentClass));Evri.Widget.Components.Behaviors.bindable(self);});Evri.extendClass(Evri.Widget.Components.MediaList,{componentClass:"evri-component",render:function(list){var self=this;var Helpers=Evri.Widget.Components.Helpers;self.empty();var listViewport=Helpers.generateItemsList(list,function(){return self.itemGenerator.apply(self,arguments);});self.append(listViewport);self.afterRender&&self.afterRender();self.executeBinding("render");return self;},renderMessage:function(str){var b=Evri.Widget.Components.Helpers.jQueryBaconl;var self=this;self.html(b("%div.evri-info-message.centered").html(str));return self;}});Evri.defineClass(Evri.Widget.Components,"Tabs",function(options){var self=this;options=options||{};var analytics=options.analytics||new Evri.Widget.Analytics('ComponentTabs');var $=Evri.jQuery;var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;Evri.Widget.Components.Behaviors.bindable(self);$.extend(self,baconl("%div.evri-component.component-tabs"));var tabsList=baconl("%ul");var viewArea=baconl("%div.component-tabs-view");var views=[];var selectedIndex=0;self.addTab=function(label,view){var listItem=baconl("%li.component-button.component-tab").append(baconl("%p.component-tab-label").text(label));listItem.bind("click.analytics",function(){analytics.trackDHTML("ComponentTabs/"+label);});listItem.bind("click",function(){selectedIndex=$(tabsList).children().index(this);tabsList.find(".component-tab").removeClass("component-tab-selected");listItem.addClass("component-tab-selected");viewArea.children().hide();view.show();});views.push(view);tabsList.append(listItem);viewArea.append(view);return listItem;};self.selectTab=function(index){if(index===undefined)return selectedIndex;tabsList.children("li").eq(index).trigger("click.");};self.append(tabsList,viewArea);});Evri.defineClass(Evri.Widget.Components,"SourceConstrainedArticles",function(options){var self=this;options=Evri.$.extend({analytics:new Evri.Widget.Analytics(self.componentName)},options||{});Evri.$.extend(this,Evri.$("<div/>").addClass(this.componentClass));});Evri.extendClass(Evri.Widget.Components.SourceConstrainedArticles,{componentName:'SourceConstrainedArticles',componentClass:"evri-source-constrained-articles",setMediaSet:function(ms){this.mediaSet=ms;this.render(ms);},retrieveArticles:function(model,view,carousel){var self=this;var tab=self.find(".component-tab-selected");var errorCallb=arguments.callee;carousel.renderMessage("... loading ...");model.media.getArticles({onError:function(){var link=self.errorHandler(function(){errorCallb.call(self,model,view,carousel);});carousel.html(link);},onComplete:function(a){if(a.articles.length){carousel.setArticles(a);}
else{tab.next().trigger("click.").length&&tab.addClass("component-tab-disabled");carousel.renderMessage("No articles found.");}}},{articleSnippetLength:80,mediaConstraint:view.mediaConstraint,includeMatchedLocations:true});},articlesFor:function(model){this.currentModel=model;this.find(".component-tab-selected").trigger("click.");},errorHandler:function(callb){var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;var errorMessage="There was an error loading this section.";return baconl(".evri-info-message.centered").append(baconl("%p").text(errorMessage),baconl("%a").text("Click here to try again").click(callb));},addTabFor:function(view,tabsPanel){var self=this;var c=new Evri.Widget.Components.ArticlesVerticalCarousel();c.attr("data-label-name",view.label);tabsPanel.addTab(view.label,c);tabsPanel.find(".component-tab:last").click(function(){self.retrieveArticles(self.currentModel,view,c);});},render:function(ms){var self=this;var mediaSetTabs=new Evri.Widget.Components.Tabs();mediaSetTabs.addClass("evri-articles-tabs").find(".component-tabs-view").addClass("evri-media-viewport");Evri.$.each(ms.views,function(i,view){self.addTabFor(view,mediaSetTabs);});this.html(mediaSetTabs);}});Evri.defineClass(Evri.Widget.Components,"ArticlesList",Evri.Widget.Components.MediaList);Evri.extendClass(Evri.Widget.Components.ArticlesList,Evri.Widget.Components.MediaList.prototype);Evri.extendClass(Evri.Widget.Components.ArticlesList,{itemGenerator:Evri.Widget.Components.Helpers.generateArticleListItem,setArticles:function(list){var self=this;var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;list.articles.length>0?self.render(list.articles):self.renderMessage(baconl("%p.light").text("No related articles"));return self;},afterRender:function(){var self=this;self.find("h3 a").bind("click.analytics",function(){self.analytics.trackReferral("Article/ListItem");});}});Evri.$.extend(Evri.Widget.Components.ArticlesList.prototype,{componentName:'ComponentArticlesList',componentClass:"articles"});Evri.defineClass(Evri.Widget.Components,"ArticlesVerticalCarousel",Evri.Widget.Components.ArticlesList);Evri.extendClass(Evri.Widget.Components.ArticlesVerticalCarousel,Evri.Widget.Components.ArticlesList.prototype);Evri.$.extend(Evri.Widget.Components.ArticlesVerticalCarousel.prototype,{componentName:'ComponentArticlesVerticalCarousel',componentClass:"articles articles-vertical-carousel",afterRender:function(){var self=this;var Helpers=Evri.Widget.Components.Helpers;var buttons=Helpers.makeVerticalCarousel(self.find("ol"));self.prepend(buttons.up);self.append(buttons.down);Helpers.validateVerticalScroll(self,buttons.up,buttons.down);Helpers.scrollAnalytics(self,"ArticlesCarousel",self.analytics);}});Evri.defineClass(Evri.Widget.Components,"ArticlesColumn",function(){var self=this;var options=arguments[0]||{};var analytics=options.analytics||new Evri.Widget.Analytics('ComponentArticlesColumn');var $=Evri.jQuery;var Helpers=Evri.Widget.Components.Helpers;var baconl=Helpers.jQueryBaconl;Evri.Widget.Components.Behaviors.bindable(self);$.extend(self,baconl("%div.evri-component.articles-column"));function render(list){var listElement=baconl("%ol");$.each(list,function(index,article){listElement.append(Helpers.generateArticleListItem(article));});self.html(listElement);self.find("h3 a").bind("click.analytics",function(){analytics.trackReferral("ComponentArticlesColumn/OpenArticle");});self.executeBinding("render",self);return self;}
self.renderMessage=function(str){self.html(baconl("%div.evri-info-message.centered").html(str));};self.setArticles=function(list){if(list.articles.length>0){render(list.articles);}
else{self.renderMessage(baconl("%p.light").text("No related articles"));}
return self;};});Evri.defineClass(Evri.Widget.Components,"ImagesListColumns",Evri.Widget.Components.MediaListColumns);Evri.extendClass(Evri.Widget.Components.ImagesListColumns,Evri.Widget.Components.MediaListColumns.prototype);Evri.extendClass(Evri.Widget.Components.ImagesListColumns,{componentName:'ComponentImagesListColumns',componentClass:"evri-component images",setImages:function(list){var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;var message=baconl("%p.light").text("No images found")
list.images.length>0?this.render(list.images):this.renderMessage(message);return this;},generateItemCell:function(image){var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;var thumb=baconl("%img.component-thumbnail").attr("src",image.thumbnail.url);return baconl("%a").attr("href",image.clickUrl).attr("target","_blank").append(thumb);},bindAnalytics:function(){var Helpers=Evri.Widget.Components.Helpers;var self=this;self.find("li a").bind("click.analytics",function(){self.analytics().trackDHTML("ComponentImagesList/OpenImage");});Helpers.scrollAnalytics(self,"ImagesCarousel",self.analytics());}});Evri.defineClass(Evri.Widget.Components,"ImagesList",Evri.Widget.Components.MediaList);Evri.extendClass(Evri.Widget.Components.ImagesList,Evri.Widget.Components.MediaList.prototype);Evri.$.extend(Evri.Widget.Components.ImagesList.prototype,{componentName:'ComponentImagesList',componentClass:"images"});Evri.extendClass(Evri.Widget.Components.ImagesList,{setImages:function(list){var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;list.images.length>0?this.render(list.images):this.renderMessage(baconl("%p.light").text("No images found"));return this;},itemGenerator:function(image){var self=this;var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;var thumbnail=baconl("%img").attr("src",image.thumbnail.url);if(parseInt(image.thumbnail.width)>(self.width()*2/3))
{thumbnail.width(self.width()*(2/3));}
return baconl("%li").append(baconl("%a.centered").attr("href",image.clickUrl).attr("target","_blank").append(thumbnail));}});Evri.defineClass(Evri.Widget.Components,"ImagesVerticalCarousel",Evri.Widget.Components.ImagesList);Evri.extendClass(Evri.Widget.Components.ImagesVerticalCarousel,Evri.Widget.Components.ImagesList.prototype);Evri.$.extend(Evri.Widget.Components.ImagesVerticalCarousel.prototype,{componentName:'ComponentImagesVerticalCarousel',componentClass:"images images-vertical-carousel",afterRender:function(){var self=this;var Helpers=Evri.Widget.Components.Helpers;var buttons=Helpers.makeVerticalCarousel(self.find("ol"));self.prepend(buttons.up);self.append(buttons.down);Helpers.scrollAnalytics(self,"ImagesCarousel",self.analytics);}});Evri.defineClass(Evri.Widget.Components,"VideosListColumns",Evri.Widget.Components.MediaListColumns);Evri.extendClass(Evri.Widget.Components.VideosListColumns,Evri.Widget.Components.MediaListColumns.prototype);Evri.extendClass(Evri.Widget.Components.VideosListColumns,{componentName:'ComponentVideosListColumns',componentClass:"evri-component videos",setVideos:function(list){var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;var message=baconl("%p.light").text("No videos found")
list.videos.length>0?this.render(list.videos):this.renderMessage(message);return this;},generateItemCell:function(video){var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;var t=baconl("%img.component-thumbnail").attr("src",video.thumbnails[0].url);return baconl("%a").attr("href",video.url).attr("target","_blank").append(t);},bindAnalytics:function(){var Helpers=Evri.Widget.Components.Helpers;var self=this;self.find("li a").bind("click.analytics",function(){self.analytics().trackDHTML("ComponentVideosList/OpenVideo");});Helpers.scrollAnalytics(self,"VideosCarousel",self.analytics());}});Evri.defineClass(Evri.Widget.Components,"VideoPlayer",function(video,opts){var options=Evri.$.extend({analytics:new Evri.Widget.Analytics('VideoPlayer')},opts);var b=Evri.Widget.Components.Helpers.jQueryBaconl;Evri.$.extend(this,b("%div.evri-component.video-player"));this.renderMarkup(video);});Evri.extendClass(Evri.Widget.Components.VideoPlayer,{insertVideo:function(vid){var self=this;var randomId="evri-video-player"+(new Date).getTime();var youtubeURL=vid.url+"&enablejsapi=1";var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;var player=baconl("%div.evri-video-player").attr("id",randomId);var embedArea=self.find(".evri-video-player-embed-area").append(player);setTimeout(function(){Evri.Flash.swfobject.embedSWF(youtubeURL,randomId,embedArea.width(),embedArea.height(),"8",null,null,{allowScriptAccess:"always"},{},true);},300)
return self;},renderMarkup:function(video){var b=Evri.Widget.Components.Helpers.jQueryBaconl;var self=this;var seconds=parseInt(video.duration%60);seconds=seconds<10?("0"+seconds):(""+seconds);var minutes=parseInt(video.duration/60);var duration=""+minutes+":"+seconds;function link(text){return b("%a").attr("href",video.url).text(text);}
self.append(b("%a.evri-video-player-close"),b(".evri-video-player-embed-area"),b(".evri-video-data").append(b("%h3").html(link(video.title)),b("%p.evri-video-duration").text(duration),b(".evri-video-description").text(video.content),b("%p.evri-video-source").append("Source: ",link("YouTube"))));self.insertVideo(video);return self;}});Evri.defineClass(Evri.Widget.Components,"VideosList",Evri.Widget.Components.MediaList);Evri.extendClass(Evri.Widget.Components.VideosList,Evri.Widget.Components.MediaList.prototype);Evri.$.extend(Evri.Widget.Components.VideosList.prototype,{componentName:'ComponentVideosList',componentClass:"videos"});Evri.extendClass(Evri.Widget.Components.VideosList,{setVideos:function(list){var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;list.videos.length>0?this.render(list.videos):this.renderMessage(baconl("%p.light").text("No videos found"));return this;},itemGenerator:function(video){var self=this;var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;var image=video.thumbnails[0];var thumbnail=baconl("%img").attr("src",image.url);return baconl("%li").append(baconl("%a.centered").attr("href",video.url).attr("target","_blank").append(thumbnail));}});Evri.defineClass(Evri.Widget.Components,"ProfilesListColumns",Evri.Widget.Components.MediaListColumns);Evri.extendClass(Evri.Widget.Components.ProfilesListColumns,Evri.Widget.Components.MediaListColumns.prototype);Evri.extendClass(Evri.Widget.Components.ProfilesListColumns,{componentName:'ComponentProfilesListColumns',componentClass:"evri-component profiles",$:Evri.$,THUMBNAIL_WIDTH:70,showAvatar:true,setProfiles:function(list,showAvatar){var self=this;if(showAvatar!=undefined){self.showAvatar=showAvatar;}
var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;var message=baconl("%p.light").text("No entities found")
list.length>0?this.render(list):this.renderMessage(message);return this;},generateItemCell:function(entity,orderedList){var self=this;var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;var container=baconl("%div.entity-profiles-container");var rightContainer=baconl("%div.right-container");var entityNameFacetContainer=baconl("%div.entity-name-facet-container");entityNameFacetContainer.append(baconl("%a").attr({"href":entity.portalURI,"target":"_blank"}).text(entity.name));var facets=self.getEntityFacets(entity);entityNameFacetContainer.append(baconl("%span.facets").text(facets));rightContainer.append(entityNameFacetContainer);if(entity.description&&entity.description.length>0){var description="";if(entity.showCompleteDescription){entity.showCompleteDescription=false;description=entity.description;}else{description=entity.description.length>100?entity.description.substr(0,100)+"...":entity.description;}
rightContainer.append(baconl("%div.entity-description").text(description));}
rightContainer.append(baconl("%a.learn-more-link").attr({"href":entity.portalURI,"target":"_blank"}).text("Learn more on evri.com"));var leftContainer=baconl("%div.left-container");var thumbnail=baconl("%img.component-thumbnail").error(function(){leftContainer.hide();rightContainer.css({"margin":"0","visibility":"visible"});}).attr("src",Evri.Widget.Environment.domainURL+"/entity-images"+entity.href+".jpg");leftContainer.append(thumbnail);container.append(leftContainer,rightContainer,baconl("%div.clear"));if(thumbnail.get(0).complete){setTimeout(function(){self.resizeViewPort(orderedList,rightContainer,leftContainer);},50);}
else{thumbnail.load(function(){self.resizeViewPort(orderedList,rightContainer,leftContainer);});}
return container;},resizeViewPort:function(orderedList,rightContainer,leftContainer){var self=this;var viewportArea=orderedList.width();var leftContainerWidth=leftContainer.width();var viewportAreaWidth=viewportArea;if(leftContainerWidth>0){viewportAreaWidth=viewportAreaWidth-leftContainerWidth-10;}
if(Evri.$.browser.msie6){viewportAreaWidth=viewportAreaWidth-20;rightContainer.parent().parent().height(rightContainer.parent().parent().height());}
if(self.showAvatar){rightContainer.css({"width":viewportAreaWidth});leftContainer.show();}else{rightContainer.css({"margin":"0"});}
rightContainer.css({"visibility":"visible"});},getEntityFacets:function(entity){var facets=' ';var self=this;if(entity&&entity.facets&&entity.facets.length!=0){var totalFacets=entity.facets.length;self.$.each(entity.facets,function(index,facet){if(index==0){facets=facets+facet.name;}else if(index==totalFacets-1){facets=facets+' and '+facet.name;}else{facets=facets+', '+facet.name;}});}
return facets;},bindAnalytics:function(){var Helpers=Evri.Widget.Components.Helpers;var self=this;self.find("li a.learn-more-link").bind("click.analytics",function(){self.analytics().trackDHTML("ComponentProfilesList/LearnMore");});Helpers.scrollAnalytics(self,"ProfilesCarousel",self.analytics());}});Evri.defineClass(Evri.Widget.Components,"TweetsListColumns",Evri.Widget.Components.MediaListColumns);Evri.extendClass(Evri.Widget.Components.TweetsListColumns,Evri.Widget.Components.MediaListColumns.prototype);Evri.extendClass(Evri.Widget.Components.TweetsListColumns,{componentName:'ComponentTweetsListColumns',componentClass:"evri-component tweets",$:Evri.$,setTweets:function(list,entityURIList){var self=this;var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;self.entityURIList=entityURIList;var message=baconl("%p.light").text("No tweets found");list.length>0?this.render(list):this.renderMessage(message);return this;},generateItemCell:function(tweet,listContainer){var self=this;var tweetContentRanges=tweet.getTitleRanges();var entityLinkedTweet="";self.$.each(tweetContentRanges,function(rangeIndex,range){if(range.matchedLocation!==undefined){if(range.matchedLocation.href==self.entityURIList[range.matchedLocation.href]){entityLinkedTweet+="<em>"+range.content+"</em>";}else{entityLinkedTweet+='<a href="'+range.matchedLocation.portalURI+'" class="entity-match">'+range.content+'</a>';}}else{entityLinkedTweet+=range.content;}});var rawTweet=tweet.content;var author=tweet.authorName.replace(/\s\(.+\).*$/,'');var tweetLinks=self.$("<div />").html(rawTweet).find("a");tweetLinks.each(function(link_index,link){var link=self.$(link);link.addClass("tweet-origin");var linkMarkup=self.$("<div/>").append(link).html();entityLinkedTweet=entityLinkedTweet.replace(link.text(),linkMarkup);});var userImage=self.$("<a/>").attr("href",tweet.authorURI).append(self.$("<img/>").attr("src",tweet.imageURI));var tweetContainer=self.$("<div/>");var tweetImage=self.$("<div/>").addClass("tweet-image");var tweetTop=self.$("<div/>").addClass("tweet-top");tweetTop.append(self.$("<p/>").addClass("content"))
var tweetBottom=self.$("<div/>").addClass("tweet-bottom");tweetBottom.append(self.$("<a/>").addClass("attribution"),self.$("<span/>").text("|"),self.$("<span/>").addClass("publication-date"),self.$("<span/>").text("|"),self.$("<a/>").addClass("retweet"));var clear=self.$("<div/>").addClass("clear");tweetContainer.append(tweetImage,tweetTop,tweetBottom,clear);tweetContainer.addClass('tweet')
tweetImage.append(userImage);tweetTop.find("p.content").html(entityLinkedTweet);tweetBottom.find("a.attribution").attr({"href":tweet.authorURI,"target":"_blank"}).text(author);var user=encodeURIComponent(author);var status=encodeURIComponent(tweet.title);var retweetURI=Evri.Widget.Environment.domainURL+"/twitter/retweet?twitter_user="+user+"&status="+status;tweetBottom.find("a.retweet").text("retweet").attr({"href":retweetURI,"target":"_blank"});tweetBottom.find("span.publication-date").text(tweet.getRelativePublicationDate());return tweetContainer;},bindAnalytics:function(){var Helpers=Evri.Widget.Components.Helpers;var self=this;self.find("li a").bind("click.analytics",function(){self.analytics().trackDHTML("ComponentTweetsList/linkClick");});Helpers.scrollAnalytics(self,"TweetsCarousel",self.analytics());}});Evri.extendNamespace(Evri,{JSTweener:(function(){var JSTweener={looping:false,frameRate:60,objects:[],defaultOptions:{time:1,transition:'easeoutexpo',delay:0,prefix:{},suffix:{},onStart:undefined,onStartParams:undefined,onUpdate:undefined,onUpdateParams:undefined,onComplete:undefined,onCompleteParams:undefined},inited:false,easingFunctionsLowerCase:{},init:function(){this.inited=true;for(var key in JSTweener.easingFunctions){this.easingFunctionsLowerCase[key.toLowerCase()]=JSTweener.easingFunctions[key];}},toNumber:function(value,prefix,suffix){if(!suffix)suffix='px';return value.toString().match(/[0-9]/)?Number(value.toString().replace(new RegExp(suffix+'$'),'').replace(new RegExp('^'+(prefix?prefix:'')),'')):0;},addTween:function(obj,options){var self=this;if(!this.inited)this.init();var o={};o.target=obj;o.targetPropeties={};for(var key in this.defaultOptions){if(typeof options[key]!='undefined'){o[key]=options[key];delete options[key];}else{o[key]=this.defaultOptions[key];}}
if(typeof o.transition=='function'){o.easing=o.transition;}else{o.easing=this.easingFunctionsLowerCase[o.transition.toLowerCase()];}
for(var key in options){if(!o.prefix[key])o.prefix[key]='';if(!o.suffix[key])o.suffix[key]='';var sB=this.toNumber(obj[key],o.prefix[key],o.suffix[key]);o.targetPropeties[key]={b:sB,c:options[key]-sB};}
setTimeout(function(){o.startTime=(new Date()-0);o.endTime=o.time*1000+o.startTime;if(typeof o.onStart=='function'){if(o.onStartParams){o.onStart.apply(o,o.onStartParams);}else{o.onStart();}}
self.objects.push(o);if(!self.looping){self.looping=true;self.eventLoop.call(self);}},o.delay*1000);},eventLoop:function(){var now=(new Date()-0);for(var i=0;i<this.objects.length;i++){var o=this.objects[i];var t=now-o.startTime;var d=o.endTime-o.startTime;if(t>=d){for(var property in o.targetPropeties){var tP=o.targetPropeties[property];try{o.target[property]=o.prefix[property]+(tP.b+tP.c)+o.suffix[property];}catch(e){}}
this.objects.splice(i,1);if(typeof o.onUpdate=='function'){if(o.onUpdateParams){o.onUpdate.apply(o,o.onUpdateParams);}else{o.onUpdate();}}
if(typeof o.onComplete=='function'){if(o.onCompleteParams){o.onComplete.apply(o,o.onCompleteParams);}else{o.onComplete();}}}else{for(var property in o.targetPropeties){var tP=o.targetPropeties[property];var val=o.easing(t,tP.b,tP.c,d);try{o.target[property]=o.prefix[property]+val+o.suffix[property];}catch(e){}}
if(typeof o.onUpdate=='function'){if(o.onUpdateParams){o.onUpdate.apply(o,o.onUpdateParams);}else{o.onUpdate();}}}}
if(this.objects.length>0){var self=this;setTimeout(function(){self.eventLoop()},1000/self.frameRate);}else{this.looping=false;}}};JSTweener.Utils={bezier2:function(t,p0,p1,p2){return(1-t)*(1-t)*p0+2*t*(1-t)*p1+t*t*p2;},bezier3:function(t,p0,p1,p2,p3){return Math.pow(1-t,3)*p0+3*t*Math.pow(1-t,2)*p1+3*t*t*(1-t)*p2+t*t*t*p3;},allSetStyleProperties:function(element){var css;if(document.defaultView&&document.defaultView.getComputedStyle){css=document.defaultView.getComputedStyle(element,null);}else{css=element.currentStyle}
for(var key in css){if(!key.match(/^\d+$/)){try{element.style[key]=css[key];}catch(e){};}}}}
JSTweener.easingFunctions={easeNone:function(t,b,c,d){return c*t/d+b;},easeInQuad:function(t,b,c,d){return c*(t/=d)*t+b;},easeOutQuad:function(t,b,c,d){return-c*(t/=d)*(t-2)+b;},easeInOutQuad:function(t,b,c,d){if((t/=d/2)<1)return c/2*t*t+b;return-c/2*((--t)*(t-2)-1)+b;},easeInCubic:function(t,b,c,d){return c*(t/=d)*t*t+b;},easeOutCubic:function(t,b,c,d){return c*((t=t/d-1)*t*t+1)+b;},easeInOutCubic:function(t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t+b;return c/2*((t-=2)*t*t+2)+b;},easeOutInCubic:function(t,b,c,d){if(t<d/2)return JSTweener.easingFunctions.easeOutCubic(t*2,b,c/2,d);return JSTweener.easingFunctions.easeInCubic((t*2)-d,b+c/2,c/2,d);},easeInQuart:function(t,b,c,d){return c*(t/=d)*t*t*t+b;},easeOutQuart:function(t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b;},easeInOutQuart:function(t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t+b;return-c/2*((t-=2)*t*t*t-2)+b;},easeOutInQuart:function(t,b,c,d){if(t<d/2)return JSTweener.easingFunctions.easeOutQuart(t*2,b,c/2,d);return JSTweener.easingFunctions.easeInQuart((t*2)-d,b+c/2,c/2,d);},easeInQuint:function(t,b,c,d){return c*(t/=d)*t*t*t*t+b;},easeOutQuint:function(t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b;},easeInOutQuint:function(t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t*t+b;return c/2*((t-=2)*t*t*t*t+2)+b;},easeOutInQuint:function(t,b,c,d){if(t<d/2)return JSTweener.easingFunctions.easeOutQuint(t*2,b,c/2,d);return JSTweener.easingFunctions.easeInQuint((t*2)-d,b+c/2,c/2,d);},easeInSine:function(t,b,c,d){return-c*Math.cos(t/d*(Math.PI/2))+c+b;},easeOutSine:function(t,b,c,d){return c*Math.sin(t/d*(Math.PI/2))+b;},easeInOutSine:function(t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b;},easeOutInSine:function(t,b,c,d){if(t<d/2)return JSTweener.easingFunctions.easeOutSine(t*2,b,c/2,d);return JSTweener.easingFunctions.easeInSine((t*2)-d,b+c/2,c/2,d);},easeInExpo:function(t,b,c,d){return(t==0)?b:c*Math.pow(2,10*(t/d-1))+b-c*0.001;},easeOutExpo:function(t,b,c,d){return(t==d)?b+c:c*1.001*(-Math.pow(2,-10*t/d)+1)+b;},easeInOutExpo:function(t,b,c,d){if(t==0)return b;if(t==d)return b+c;if((t/=d/2)<1)return c/2*Math.pow(2,10*(t-1))+b-c*0.0005;return c/2*1.0005*(-Math.pow(2,-10*--t)+2)+b;},easeOutInExpo:function(t,b,c,d){if(t<d/2)return JSTweener.easingFunctions.easeOutExpo(t*2,b,c/2,d);return JSTweener.easingFunctions.easeInExpo((t*2)-d,b+c/2,c/2,d);},easeInCirc:function(t,b,c,d){return-c*(Math.sqrt(1-(t/=d)*t)-1)+b;},easeOutCirc:function(t,b,c,d){return c*Math.sqrt(1-(t=t/d-1)*t)+b;},easeInOutCirc:function(t,b,c,d){if((t/=d/2)<1)return-c/2*(Math.sqrt(1-t*t)-1)+b;return c/2*(Math.sqrt(1-(t-=2)*t)+1)+b;},easeOutInCirc:function(t,b,c,d){if(t<d/2)return JSTweener.easingFunctions.easeOutCirc(t*2,b,c/2,d);return JSTweener.easingFunctions.easeInCirc((t*2)-d,b+c/2,c/2,d);},easeInElastic:function(t,b,c,d,a,p){var s;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(!a||a<Math.abs(c)){a=c;s=p/4;}else s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;},easeOutElastic:function(t,b,c,d,a,p){var s;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(!a||a<Math.abs(c)){a=c;s=p/4;}else s=p/(2*Math.PI)*Math.asin(c/a);return(a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b);},easeInOutElastic:function(t,b,c,d,a,p){var s;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(!a||a<Math.abs(c)){a=c;s=p/4;}else s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b;},easeOutInElastic:function(t,b,c,d,a,p){if(t<d/2)return JSTweener.easingFunctions.easeOutElastic(t*2,b,c/2,d,a,p);return JSTweener.easingFunctions.easeInElastic((t*2)-d,b+c/2,c/2,d,a,p);},easeInBack:function(t,b,c,d,s){if(s==undefined)s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b;},easeOutBack:function(t,b,c,d,s){if(s==undefined)s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b;},easeInOutBack:function(t,b,c,d,s){if(s==undefined)s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b;},easeOutInBack:function(t,b,c,d,s){if(t<d/2)return JSTweener.easingFunctions.easeOutBack(t*2,b,c/2,d,s);return JSTweener.easingFunctions.easeInBack((t*2)-d,b+c/2,c/2,d,s);},easeInBounce:function(t,b,c,d){return c-JSTweener.easingFunctions.easeOutBounce(d-t,0,c,d)+b;},easeOutBounce:function(t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b;}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b;}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b;}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b;}},easeInOutBounce:function(t,b,c,d){if(t<d/2)return JSTweener.easingFunctions.easeInBounce(t*2,0,c,d)*.5+b;else return JSTweener.easingFunctions.easeOutBounce(t*2-d,0,c,d)*.5+c*.5+b;},easeOutInBounce:function(t,b,c,d){if(t<d/2)return JSTweener.easingFunctions.easeOutBounce(t*2,b,c/2,d);return JSTweener.easingFunctions.easeInBounce((t*2)-d,b+c/2,c/2,d);}};JSTweener.easingFunctions.linear=JSTweener.easingFunctions.easeNone;return JSTweener;})()});Evri.Raphael=(function(){var separator=/[, ]+/,create,doc=document,win=window,R=function(){return create.apply(R,arguments);};R.version="0.7.2";R.type=(win.SVGAngle?"SVG":"VML");R.svg=!(R.vml=R.type=="VML");R.idGenerator=0;var paper={};R.fn={};var availableAttrs={cx:0,cy:0,fill:"#fff","fill-opacity":1,font:'10px "Arial"',"font-family":'"Arial"',"font-size":"10",gradient:0,height:0,opacity:1,path:"M0,0",r:0,rotation:0,rx:0,ry:0,scale:"1 1",src:"",stroke:"#000","stroke-dasharray":"","stroke-linecap":"butt","stroke-linejoin":"butt","stroke-miterlimit":0,"stroke-opacity":1,"stroke-width":1,translation:"0 0",width:0,x:0,y:0},availableAnimAttrs={cx:"number",cy:"number",fill:"colour","fill-opacity":"number","font-size":"number",height:"number",opacity:"number",path:"path",r:"number",rotation:"csv",rx:"number",ry:"number",scale:"csv",stroke:"colour","stroke-opacity":"number","stroke-width":"number",translation:"csv",width:"number",x:"number",y:"number"},events=["click","dblclick","mousedown","mousemove","mouseout","mouseover","mouseup"];R.toString=function(){return"Your browser "+(this.vml?"doesn't ":"")+"support"+(this.svg?"s":"")+" SVG.\nYou are running "+unescape("Rapha%EBl%20")+this.version;};R.setWindow=function(newwin){win=newwin;doc=win.document;};R.hsb2rgb=function(hue,saturation,brightness){if(typeof hue=="object"&&"h"in hue&&"s"in hue&&"b"in hue){brightness=hue.b;saturation=hue.s;hue=hue.h;}
var red,green,blue;if(brightness==0){return{r:0,g:0,b:0,hex:"#000"};}
if(hue>1||saturation>1||brightness>1){hue/=255;saturation/=255;brightness/=255;}
var i=Math.floor(hue*6),f=(hue*6)-i,p=brightness*(1-saturation),q=brightness*(1-(saturation*f)),t=brightness*(1-(saturation*(1-f)));red=[brightness,q,p,p,t,brightness,brightness][i];green=[t,brightness,brightness,q,p,p,t][i];blue=[p,p,t,brightness,brightness,q,p][i];red*=255;green*=255;blue*=255;var rgb={r:red,g:green,b:blue};var r=Math.round(red).toString(16);if(r.length==1){r="0"+r;}
var g=Math.round(green).toString(16);if(g.length==1){g="0"+g;}
var b=Math.round(blue).toString(16);if(b.length==1){b="0"+b;}
rgb.hex="#"+r+g+b;return rgb;};R.rgb2hsb=function(red,green,blue){if(typeof red=="object"&&"r"in red&&"g"in red&&"b"in red){blue=red.b;green=red.g;red=red.r;}
if(typeof red=="string"){var clr=getRGB(red);red=clr.r;green=clr.g;blue=clr.b;}
if(red>1||green>1||blue>1){red/=255;green/=255;blue/=255;}
var max=Math.max(red,green,blue),min=Math.min(red,green,blue),hue,saturation,brightness=max;if(min==max){return{h:0,s:0,b:max};}else{var delta=(max-min);saturation=delta/max;if(red==max){hue=(green-blue)/delta;}else if(green==max){hue=2+((blue-red)/delta);}else{hue=4+((red-green)/delta);}
hue/=6;if(hue<0){hue+=1;}
if(hue>1){hue-=1;}}
return{h:hue,s:saturation,b:brightness};};var getRGB=function(colour){var htmlcolors={aliceblue:"#f0f8ff",amethyst:"#96c",antiquewhite:"#faebd7",aqua:"#0ff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000",blanchedalmond:"#ffebcd",blue:"#00f",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#0ff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#f0f",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#789",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#0f0",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#f0f",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#f00",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#fff",whitesmoke:"#f5f5f5",yellow:"#ff0",yellowgreen:"#9acd32"};if(colour.toString().toLowerCase()in htmlcolors){colour=htmlcolors[colour.toString().toLowerCase()];}
if(!colour){return{r:0,g:0,b:0,hex:"#000"};}
if(colour=="none"){return{r:-1,g:-1,b:-1,hex:"none"};}
var red,green,blue,rgb=colour.match(/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgb\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|rgb\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\)|hsb\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|hsb\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\))\s*$/i);if(rgb){if(rgb[2]){blue=parseInt(rgb[2].substring(5),16);green=parseInt(rgb[2].substring(3,5),16);red=parseInt(rgb[2].substring(1,3),16);}
if(rgb[3]){blue=parseInt(rgb[3].substring(3)+rgb[3].substring(3),16);green=parseInt(rgb[3].substring(2,3)+rgb[3].substring(2,3),16);red=parseInt(rgb[3].substring(1,2)+rgb[3].substring(1,2),16);}
if(rgb[4]){rgb=rgb[4].split(/\s*,\s*/);red=parseFloat(rgb[0],10);green=parseFloat(rgb[1],10);blue=parseFloat(rgb[2],10);}
if(rgb[5]){rgb=rgb[5].split(/\s*,\s*/);red=parseFloat(rgb[0],10)*2.55;green=parseFloat(rgb[1],10)*2.55;blue=parseFloat(rgb[2],10)*2.55;}
if(rgb[6]){rgb=rgb[6].split(/\s*,\s*/);red=parseFloat(rgb[0],10);green=parseFloat(rgb[1],10);blue=parseFloat(rgb[2],10);return Raphael.hsb2rgb(red,green,blue);}
if(rgb[7]){rgb=rgb[7].split(/\s*,\s*/);red=parseFloat(rgb[0],10)*2.55;green=parseFloat(rgb[1],10)*2.55;blue=parseFloat(rgb[2],10)*2.55;return Raphael.hsb2rgb(red,green,blue);}
var rgb={r:red,g:green,b:blue};var r=Math.round(red).toString(16);(r.length==1)&&(r="0"+r);var g=Math.round(green).toString(16);(g.length==1)&&(g="0"+g);var b=Math.round(blue).toString(16);(b.length==1)&&(b="0"+b);rgb.hex="#"+r+g+b;return rgb;}else{return{r:-1,g:-1,b:-1,hex:"none"};}};R.getColor=function(value){var start=arguments.callee.start=arguments.callee.start||{h:0,s:1,b:value||.75};var rgb=Raphael.hsb2rgb(start.h,start.s,start.b);start.h+=.075;if(start.h>1){start.h=0;start.s-=.2;if(start.s<=0){arguments.callee.start={h:0,s:1,b:start.b};}}
return rgb.hex;};R.getColor.reset=function(){this.start=undefined;};R.parsePathString=function(pathString){var paramCounts={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},data=[],toString=function(){var res="";for(var i=0,ii=this.length;i<ii;i++){res+=this[i][0]+this[i].join(",").substring(2);}
return res;};if(pathString.toString.toString()==toString.toString()){return pathString;}
pathString.replace(/([achlmqstvz])[\s,]*((-?\d*(?:e-?\d+|\.?\d*)\s*,?\s*)+)/ig,function(a,b,c){var params=[],name=b.toLowerCase();c.replace(/(-?\d*(?:e-?\d+|\.?\d*))\s*,?\s*/ig,function(a,b){b&&params.push(+b);});while(params.length>=paramCounts[name]){data.push([b].concat(params.splice(0,paramCounts[name])));if(!paramCounts[name]){break;};}});data.toString=toString;return data;};var pathDimensions=function(path){var pathArray=path;if(typeof path=="string"){pathArray=Raphael.parsePathString(path);}
pathArray=pathToAbsolute(pathArray);var x=[],y=[],length=0;for(var i=0,ii=pathArray.length;i<ii;i++){switch(pathArray[i][0]){case"Z":break;case"A":x.push(pathArray[i][pathArray[i].length-2]);y.push(pathArray[i][pathArray[i].length-1]);break;default:for(var j=1,jj=pathArray[i].length;j<jj;j++){if(j%2){x.push(pathArray[i][j]);}else{y.push(pathArray[i][j]);}}}}
var minx=Math.min.apply(Math,x),miny=Math.min.apply(Math,y);return{x:minx,y:miny,width:Math.max.apply(Math,x)-minx,height:Math.max.apply(Math,y)-miny,X:x,Y:y};};var pathToRelative=function(pathArray){var res=[];if(typeof pathArray=="string"){pathArray=R.parsePathString(pathArray);}
var x=0,y=0,start=0;if(pathArray[0][0]=="M"){x=pathArray[0][1];y=pathArray[0][2];start++;res.push(pathArray[0]);}
for(var i=start,ii=pathArray.length;i<ii;i++){res[i]=[];if(pathArray[i][0]!=pathArray[i][0].toLowerCase()){res[i][0]=pathArray[i][0].toLowerCase();switch(res[i][0]){case"a":res[i][1]=pathArray[i][1];res[i][2]=pathArray[i][2];res[i][3]=0;res[i][4]=pathArray[i][4];res[i][5]=pathArray[i][5];res[i][6]=+(pathArray[i][6]-x).toFixed(3);res[i][7]=+(pathArray[i][7]-y).toFixed(3);break;case"v":res[i][1]=+(pathArray[i][1]-y).toFixed(3);break;default:for(var j=1,jj=pathArray[i].length;j<jj;j++){res[i][j]=+(pathArray[i][j]-((j%2)?x:y)).toFixed(3);}}}else{res[i]=pathArray[i];}
switch(res[i][0]){case"z":break;case"h":x+=res[i][res[i].length-1];break;case"v":y+=res[i][res[i].length-1];break;default:x+=res[i][res[i].length-2];y+=res[i][res[i].length-1];}}
res.toString=pathArray.toString;return res;};var pathToAbsolute=function(pathArray){var res=[];if(typeof pathArray=="string"){pathArray=R.parsePathString(pathArray);}
var x=0,y=0,start=0;if(pathArray[0][0]=="M"){x=+pathArray[0][1];y=+pathArray[0][2];start++;res[0]=pathArray[0];}
for(var i=start,ii=pathArray.length;i<ii;i++){res[i]=[];if(pathArray[i][0]!=(pathArray[i][0]+"").toUpperCase()){res[i][0]=(pathArray[i][0]+"").toUpperCase();switch(res[i][0]){case"A":res[i][1]=pathArray[i][1];res[i][2]=pathArray[i][2];res[i][3]=0;res[i][4]=pathArray[i][4];res[i][5]=pathArray[i][5];res[i][6]=+(pathArray[i][6]+x).toFixed(3);res[i][7]=+(pathArray[i][7]+y).toFixed(3);break;case"V":res[i][1]=+pathArray[i][1]+y;break;default:for(var j=1,jj=pathArray[i].length;j<jj;j++){res[i][j]=+pathArray[i][j]+((j%2)?x:y);}}}else{res[i]=pathArray[i];}
switch(res[i][0]){case"Z":break;case"H":x=res[i][1];break;case"V":y=res[i][1];break;default:x=res[i][res[i].length-2];y=res[i][res[i].length-1];}}
res.toString=pathArray.toString;return res;};var pathEqualiser=function(path1,path2){var data=[pathToAbsolute(Raphael.parsePathString(path1)),pathToAbsolute(Raphael.parsePathString(path2))],attrs=[{x:0,y:0,bx:0,by:0,X:0,Y:0},{x:0,y:0,bx:0,by:0,X:0,Y:0}],processPath=function(path,d){if(!path){return["U"];}
switch(path[0]){case"M":d.X=path[1];d.Y=path[2];break;case"S":var nx=d.x+(d.x-(d.bx||d.x));var ny=d.y+(d.y-(d.by||d.y));path=["C",nx,ny,path[1],path[2],path[3],path[4]];break;case"T":var nx=d.x+(d.x-(d.bx||d.x));var ny=d.y+(d.y-(d.by||d.y));path=["Q",nx,ny,path[1],path[2]];break;case"H":path=["L",path[1],d.y];break;case"V":path=["L",d.x,path[1]];break;case"Z":path=["L",d.X,d.Y];break;}
return path;},edgeCases=function(a,b,i){if(data[a][i][0]=="M"&&data[b][i][0]!="M"){data[b].splice(i,0,["M",attrs[b].x,attrs[b].y]);attrs[a].bx=data[a][i][data[a][i].length-4]||0;attrs[a].by=data[a][i][data[a][i].length-3]||0;attrs[a].x=data[a][i][data[a][i].length-2];attrs[a].y=data[a][i][data[a][i].length-1];return true;}else if(data[a][i][0]=="L"&&data[b][i][0]=="C"){data[a][i]=["C",attrs[a].x,attrs[a].y,data[a][i][1],data[a][i][2],data[a][i][1],data[a][i][2]];}else if(data[a][i][0]=="L"&&data[b][i][0]=="Q"){data[a][i]=["Q",data[a][i][1],data[a][i][2],data[a][i][1],data[a][i][2]];}else if(data[a][i][0]=="Q"&&data[b][i][0]=="C"){var x=data[b][i][data[b][i].length-2];var y=data[b][i][data[b][i].length-1];data[b].splice(i+1,0,["Q",x,y,x,y]);data[a].splice(i,0,["C",attrs[a].x,attrs[a].y,attrs[a].x,attrs[a].y,attrs[a].x,attrs[a].y]);i++;attrs[b].bx=data[b][i][data[b][i].length-4]||0;attrs[b].by=data[b][i][data[b][i].length-3]||0;attrs[b].x=data[b][i][data[b][i].length-2];attrs[b].y=data[b][i][data[b][i].length-1];return true;}else if(data[a][i][0]=="A"&&data[b][i][0]=="C"){var x=data[b][i][data[b][i].length-2];var y=data[b][i][data[b][i].length-1];data[b].splice(i+1,0,["A",0,0,data[a][i][3],data[a][i][4],data[a][i][5],x,y]);data[a].splice(i,0,["C",attrs[a].x,attrs[a].y,attrs[a].x,attrs[a].y,attrs[a].x,attrs[a].y]);i++;attrs[b].bx=data[b][i][data[b][i].length-4]||0;attrs[b].by=data[b][i][data[b][i].length-3]||0;attrs[b].x=data[b][i][data[b][i].length-2];attrs[b].y=data[b][i][data[b][i].length-1];return true;}else if(data[a][i][0]=="U"){data[a][i][0]=data[b][i][0];for(var j=1,jj=data[b][i].length;j<jj;j++){data[a][i][j]=(j%2)?attrs[a].x:attrs[a].y;}}
return false;};for(var i=0;i<Math.max(data[0].length,data[1].length);i++){data[0][i]=processPath(data[0][i],attrs[0]);data[1][i]=processPath(data[1][i],attrs[1]);if(data[0][i][0]!=data[1][i][0]&&(edgeCases(0,1,i)||edgeCases(1,0,i))){continue;}
attrs[0].bx=data[0][i][data[0][i].length-4]||0;attrs[0].by=data[0][i][data[0][i].length-3]||0;attrs[0].x=data[0][i][data[0][i].length-2];attrs[0].y=data[0][i][data[0][i].length-1];attrs[1].bx=data[1][i][data[1][i].length-4]||0;attrs[1].by=data[1][i][data[1][i].length-3]||0;attrs[1].x=data[1][i][data[1][i].length-2];attrs[1].y=data[1][i][data[1][i].length-1];}
return data;};var toGradient=function(gradient){if(typeof gradient=="string"){gradient=gradient.split(/\s*\-\s*/);var angle=gradient.shift();if(angle.toLowerCase()=="v"){angle=90;}else if(angle.toLowerCase()=="h"){angle=0;}else{angle=parseFloat(angle,10);}
angle=-angle;var grobj={angle:angle,type:"linear",dots:[],vector:[0,0,Math.cos(angle*Math.PI/180).toFixed(3),Math.sin(angle*Math.PI/180).toFixed(3)]};var max=1/(Math.max(Math.abs(grobj.vector[2]),Math.abs(grobj.vector[3]))||1);grobj.vector[2]*=max;grobj.vector[3]*=max;if(grobj.vector[2]<0){grobj.vector[0]=-grobj.vector[2];grobj.vector[2]=0;}
if(grobj.vector[3]<0){grobj.vector[1]=-grobj.vector[3];grobj.vector[3]=0;}
grobj.vector[0]=grobj.vector[0].toFixed(3);grobj.vector[1]=grobj.vector[1].toFixed(3);grobj.vector[2]=grobj.vector[2].toFixed(3);grobj.vector[3]=grobj.vector[3].toFixed(3);for(var i=0,ii=gradient.length;i<ii;i++){var dot={};var par=gradient[i].match(/^([^:]*):?([\d\.]*)/);dot.color=getRGB(par[1]).hex;par[2]&&(dot.offset=par[2]+"%");grobj.dots.push(dot);}
for(var i=1,ii=grobj.dots.length-1;i<ii;i++){if(!grobj.dots[i].offset){var start=parseFloat(grobj.dots[i-1].offset||0,10),end=false;for(var j=i+1;j<ii;j++){if(grobj.dots[j].offset){end=grobj.dots[j].offset;break;}}
if(!end){end=100;j=ii;}
end=parseFloat(end,10);var d=(end-start)/(j-i+1);for(;i<j;i++){start+=d;grobj.dots[i].offset=start+"%";}}}
return grobj;}else{return gradient;}};if(R.svg){var thePath=function(params,pathString,SVG){var el=doc.createElementNS(SVG.svgns,"path");el.setAttribute("fill","none");if(SVG.canvas){SVG.canvas.appendChild(el);}
var p=new Element(el,SVG);p.isAbsolute=true;p.type="path";p.last={x:0,y:0,bx:0,by:0};p.absolutely=function(){this.isAbsolute=true;return this;};p.relatively=function(){this.isAbsolute=false;return this;};p.moveTo=function(x,y){var d=this.isAbsolute?"M":"m";d+=parseFloat(x,10).toFixed(3)+" "+parseFloat(y,10).toFixed(3)+" ";var oldD=this[0].getAttribute("d")||"";(oldD=="M0,0")&&(oldD="");this[0].setAttribute("d",oldD+d);this.last.x=(this.isAbsolute?0:this.last.x)+parseFloat(x,10);this.last.y=(this.isAbsolute?0:this.last.y)+parseFloat(y,10);this.attrs.path=oldD+d;return this;};p.lineTo=function(x,y){this.last.x=(this.isAbsolute?0:this.last.x)+parseFloat(x,10);this.last.y=(this.isAbsolute?0:this.last.y)+parseFloat(y,10);var d=this.isAbsolute?"L":"l";d+=parseFloat(x,10).toFixed(3)+" "+parseFloat(y,10).toFixed(3)+" ";var oldD=this[0].getAttribute("d")||"";this[0].setAttribute("d",oldD+d);this.attrs.path=oldD+d;return this;};p.arcTo=function(rx,ry,large_arc_flag,sweep_flag,x,y){var d=this.isAbsolute?"A":"a";d+=[parseFloat(rx,10).toFixed(3),parseFloat(ry,10).toFixed(3),0,large_arc_flag,sweep_flag,parseFloat(x,10).toFixed(3),parseFloat(y,10).toFixed(3)].join(" ");var oldD=this[0].getAttribute("d")||"";this[0].setAttribute("d",oldD+d);this.last.x=parseFloat(x,10);this.last.y=parseFloat(y,10);this.attrs.path=oldD+d;return this;};p.cplineTo=function(x1,y1,w1){if(!w1){return this.lineTo(x1,y1);}else{var p={};var x=parseFloat(x1,10);var y=parseFloat(y1,10);var w=parseFloat(w1,10);var d=this.isAbsolute?"C":"c";var attr=[+this.last.x+w,+this.last.y,x-w,y,x,y];for(var i=0,ii=attr.length;i<ii;i++){d+=attr[i].toFixed(3)+" ";}
this.last.x=(this.isAbsolute?0:this.last.x)+attr[4];this.last.y=(this.isAbsolute?0:this.last.y)+attr[5];this.last.bx=attr[2];this.last.by=attr[3];var oldD=this[0].getAttribute("d")||"";this[0].setAttribute("d",oldD+d);this.attrs.path=oldD+d;return this;}};p.curveTo=function(){var p={},command=[0,1,2,3,"s",5,"c"];var d=command[arguments.length];if(this.isAbsolute){d=d.toUpperCase();}
for(var i=0,ii=arguments.length;i<ii;i++){d+=parseFloat(arguments[i],10).toFixed(3)+" ";}
this.last.x=(this.isAbsolute?0:this.last.x)+parseFloat(arguments[arguments.length-2],10);this.last.y=(this.isAbsolute?0:this.last.y)+parseFloat(arguments[arguments.length-1],10);this.last.bx=parseFloat(arguments[arguments.length-4],10);this.last.by=parseFloat(arguments[arguments.length-3],10);var oldD=this.node.getAttribute("d")||"";this.node.setAttribute("d",oldD+d);this.attrs.path=oldD+d;return this;};p.qcurveTo=function(){var p={},command=[0,1,"t",3,"q"];var d=command[arguments.length];if(this.isAbsolute){d=d.toUpperCase();}
for(var i=0,ii=arguments.length;i<ii;i++){d+=parseFloat(arguments[i],10).toFixed(3)+" ";}
this.last.x=(this.isAbsolute?0:this.last.x)+parseFloat(arguments[arguments.length-2],10);this.last.y=(this.isAbsolute?0:this.last.y)+parseFloat(arguments[arguments.length-1],10);if(arguments.length!=2){this.last.qx=parseFloat(arguments[arguments.length-4],10);this.last.qy=parseFloat(arguments[arguments.length-3],10);}
var oldD=this.node.getAttribute("d")||"";this.node.setAttribute("d",oldD+d);this.attrs.path=oldD+d;return this;};p.addRoundedCorner=function(r,dir){var R=.5522*r,rollback=this.isAbsolute,o=this;if(rollback){this.relatively();rollback=function(){o.absolutely();};}else{rollback=function(){};}
var actions={l:function(){return{u:function(){o.curveTo(-R,0,-r,-(r-R),-r,-r);},d:function(){o.curveTo(-R,0,-r,r-R,-r,r);}};},r:function(){return{u:function(){o.curveTo(R,0,r,-(r-R),r,-r);},d:function(){o.curveTo(R,0,r,r-R,r,r);}};},u:function(){return{r:function(){o.curveTo(0,-R,-(R-r),-r,r,-r);},l:function(){o.curveTo(0,-R,R-r,-r,-r,-r);}};},d:function(){return{r:function(){o.curveTo(0,R,-(R-r),r,r,r);},l:function(){o.curveTo(0,R,R-r,r,-r,r);}};}};actions[dir[0]]()[dir[1]]();rollback();return o;};p.andClose=function(){var oldD=this[0].getAttribute("d")||"";this[0].setAttribute("d",oldD+"Z ");this.attrs.path=oldD+"Z ";return this;};if(pathString){p.attrs.path=""+pathString;p.absolutely();paper.pathfinder(p,p.attrs.path);}
if(params){setFillAndStroke(p,params);}
return p;};var addGrdientFill=function(o,gradient,SVG){gradient=toGradient(gradient);var el=doc.createElementNS(SVG.svgns,(gradient.type||"linear")+"Gradient");el.id="raphael-gradient-"+Raphael.idGenerator++;if(gradient.vector&&gradient.vector.length){el.setAttribute("x1",gradient.vector[0]);el.setAttribute("y1",gradient.vector[1]);el.setAttribute("x2",gradient.vector[2]);el.setAttribute("y2",gradient.vector[3]);}
SVG.defs.appendChild(el);var isopacity=true;for(var i=0,ii=gradient.dots.length;i<ii;i++){var stop=doc.createElementNS(SVG.svgns,"stop");if(gradient.dots[i].offset){isopacity=false;}
stop.setAttribute("offset",gradient.dots[i].offset?gradient.dots[i].offset:(i==0)?"0%":"100%");stop.setAttribute("stop-color",getRGB(gradient.dots[i].color).hex||"#fff");el.appendChild(stop);};if(isopacity&&typeof gradient.dots[ii-1].opacity!="undefined"){stop.setAttribute("stop-opacity",gradient.dots[ii-1].opacity);}
o.setAttribute("fill","url(#"+el.id+")");o.style.opacity=1;o.style.fillOpacity=1;o.setAttribute("opacity",1);o.setAttribute("fill-opacity",1);};var updatePosition=function(o){if(o.pattern){var bbox=o.node.getBBox();o.pattern.setAttribute("patternTransform","translate("+[bbox.x,bbox.y].join(",")+")");}};var setFillAndStroke=function(o,params){var dasharray={"-":[3,1],".":[1,1],"-.":[3,1,1,1],"-..":[3,1,1,1,1,1],". ":[1,3],"- ":[4,3],"--":[8,3],"- .":[4,3,1,3],"--.":[8,3,1,3],"--..":[8,3,1,3,1,3]},addDashes=function(o,value){value=dasharray[value.toString().toLowerCase()];if(value){var width=o.attrs["stroke-width"]||"1",butt={round:width,square:width,butt:0}[o.attrs["stroke-linecap"]||params["stroke-linecap"]]||0,dashes=[];for(var i=0,ii=value.length;i<ii;i++){dashes.push(value[i]*width+((i%2)?1:-1)*butt);}
value=dashes.join(",");o.node.setAttribute("stroke-dasharray",value);}};for(var att in params){var value=params[att];o.attrs[att]=value;switch(att){case"path":if(o.type=="path"){o.node.setAttribute("d","M0,0");paper.pathfinder(o,value);}
case"rx":case"cx":case"x":o.node.setAttribute(att,value);updatePosition(o);break;case"ry":case"cy":case"y":o.node.setAttribute(att,value);updatePosition(o);break;case"width":o.node.setAttribute(att,value);break;case"height":o.node.setAttribute(att,value);break;case"src":if(o.type=="image"){o.node.setAttributeNS(svg.xlink,"href",value);}
break;case"stroke-width":o.node.style.strokeWidth=value;o.node.setAttribute(att,value);if(o.attrs["stroke-dasharray"]){addDashes(o,o.attrs["stroke-dasharray"]);}
break;case"stroke-dasharray":addDashes(o,value);break;case"rotation":o.rotate(value,true);break;case"translation":var xy=(value+"").split(separator);o.translate((+xy[0]+1||2)-1,(+xy[1]+1||2)-1);break;case"scale":var xy=(value+"").split(separator);o.scale(+xy[0]||1,+xy[1]||+xy[0]||1);break;case"fill":var isURL=value.match(/^url\(([^\)]+)\)$/i);if(isURL){var el=doc.createElementNS(o.svg.svgns,"pattern");var ig=doc.createElementNS(o.svg.svgns,"image");el.id="raphael-pattern-"+Raphael.idGenerator++;el.setAttribute("x",0);el.setAttribute("y",0);el.setAttribute("patternUnits","userSpaceOnUse");ig.setAttribute("x",0);ig.setAttribute("y",0);ig.setAttributeNS(o.svg.xlink,"href",isURL[1]);el.appendChild(ig);var img=doc.createElement("img");img.style.position="absolute";img.style.top="-9999em";img.style.left="-9999em";img.onload=function(){el.setAttribute("width",this.offsetWidth);el.setAttribute("height",this.offsetHeight);ig.setAttribute("width",this.offsetWidth);ig.setAttribute("height",this.offsetHeight);doc.body.removeChild(this);paper.safari();};doc.body.appendChild(img);img.src=isURL[1];o.svg.defs.appendChild(el);o.node.style.fill="url(#"+el.id+")";o.node.setAttribute("fill","url(#"+el.id+")");o.pattern=el;updatePosition(o);break;}
delete params.gradient;delete o.attrs.gradient;if(typeof o.attrs.opacity!="undefined"&&typeof params.opacity=="undefined"){o.node.style.opacity=o.attrs.opacity;o.node.setAttribute("opacity",o.attrs.opacity);}
if(typeof o.attrs["fill-opacity"]!="undefined"&&typeof params["fill-opacity"]=="undefined"){o.node.style.fillOpacity=o.attrs["fill-opacity"];o.node.setAttribute("fill-opacity",o.attrs["fill-opacity"]);}
case"stroke":o.node.style[att]=getRGB(value).hex;o.node.setAttribute(att,getRGB(value).hex);break;case"gradient":addGrdientFill(o.node,value,o.svg);break;case"opacity":case"fill-opacity":if(o.attrs.gradient){var gradient=doc.getElementById(o.node.getAttribute("fill").replace(/^url\(#|\)$/g,""));if(gradient){var stops=gradient.getElementsByTagName("stop");stops[stops.length-1].setAttribute("stop-opacity",value);}
break;}
default:var cssrule=att.replace(/(\-.)/g,function(w){return w.substring(1).toUpperCase();});o.node.style[cssrule]=value;o.node.setAttribute(att,value);break;}}
tuneText(o,params);};var leading=1.2;var tuneText=function(element,params){if(element.type!="text"||!("text"in params||"font"in params||"font-size"in params||"x"in params)){return;}
var fontSize=element.node.firstChild?parseInt(doc.defaultView.getComputedStyle(element.node.firstChild,"").getPropertyValue("font-size"),10):10;var height=0;if("text"in params){while(element.node.firstChild){element.node.removeChild(element.node.firstChild);}
var texts=(params.text+"").split("\n");for(var i=0,ii=texts.length;i<ii;i++){var tspan=doc.createElementNS(element.svg.svgns,"tspan");i&&tspan.setAttribute("dy",fontSize*leading);i&&tspan.setAttribute("x",element.attrs.x);tspan.appendChild(doc.createTextNode(texts[i]));element.node.appendChild(tspan);height+=fontSize*leading;}}else{var texts=element.node.getElementsByTagName("tspan");for(var i=0,ii=texts.length;i<ii;i++){i&&texts[i].setAttribute("dy",fontSize*leading);i&&texts[i].setAttribute("x",element.attrs.x);height+=fontSize*leading;}}
height-=fontSize*(leading-1);var dif=height/2-fontSize;if(dif){element.node.setAttribute("y",element.attrs.y-dif);}
setTimeout(function(){});};var Element=function(node,svg){var X=0,Y=0;this[0]=node;this.node=node;this.svg=svg;this.attrs=this.attrs||{};this.transformations=[];this._={tx:0,ty:0,rt:{deg:0,x:0,y:0},sx:1,sy:1};};Element.prototype.rotate=function(deg,cx,cy){if(deg==null){return this._.rt.deg;}
var bbox=this.getBBox();deg=deg.toString().split(separator);if(deg.length-1){cx=parseFloat(deg[1],10);cy=parseFloat(deg[2],10);}
deg=parseFloat(deg[0],10);if(cx!=null){this._.rt.deg=deg;}else{this._.rt.deg+=deg;}
if(cy==null){cx=null;}
cx=cx==null?bbox.x+bbox.width/2:cx;cy=cy==null?bbox.y+bbox.height/2:cy;if(this._.rt.deg){this.transformations[0]=("rotate("+this._.rt.deg+" "+cx+" "+cy+")");}else{this.transformations[0]="";}
this.node.setAttribute("transform",this.transformations.join(" "));return this;};Element.prototype.hide=function(){this.node.style.display="none";return this;};Element.prototype.show=function(){this.node.style.display="block";return this;};Element.prototype.remove=function(){this.node.parentNode.removeChild(this.node);};Element.prototype.getBBox=function(){return this.node.getBBox();};Element.prototype.attr=function(){if(arguments.length==1&&typeof arguments[0]=="string"){if(arguments[0]=="translation"){return this.translate();}
return this.attrs[arguments[0]];}
if(arguments.length==1&&arguments[0]instanceof Array){var values={};for(var j in arguments[0]){values[arguments[0][j]]=this.attrs[arguments[0][j]];}
return values;}
if(arguments.length==2){var params={};params[arguments[0]]=arguments[1];setFillAndStroke(this,params);}else if(arguments.length==1&&typeof arguments[0]=="object"){setFillAndStroke(this,arguments[0]);}
return this;};Element.prototype.toFront=function(){this.node.parentNode.appendChild(this.node);return this;};Element.prototype.toBack=function(){if(this.node.parentNode.firstChild!=this.node){this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild);}
return this;};Element.prototype.insertAfter=function(element){if(element.node.nextSibling){element.node.parentNode.insertBefore(this.node,element.node.nextSibling);}else{element.node.parentNode.appendChild(this.node);}
return this;};Element.prototype.insertBefore=function(element){element.node.parentNode.insertBefore(this.node,element.node);return this;};var theCircle=function(svg,x,y,r){var el=doc.createElementNS(svg.svgns,"circle");el.setAttribute("cx",x);el.setAttribute("cy",y);el.setAttribute("r",r);el.setAttribute("fill","none");el.setAttribute("stroke","#000");if(svg.canvas){svg.canvas.appendChild(el);}
var res=new Element(el,svg);res.attrs=res.attrs||{};res.attrs.cx=x;res.attrs.cy=y;res.attrs.r=r;res.attrs.stroke="#000";res.type="circle";return res;};var theRect=function(svg,x,y,w,h,r){var el=doc.createElementNS(svg.svgns,"rect");el.setAttribute("x",x);el.setAttribute("y",y);el.setAttribute("width",w);el.setAttribute("height",h);if(r){el.setAttribute("rx",r);el.setAttribute("ry",r);}
el.setAttribute("fill","none");el.setAttribute("stroke","#000");if(svg.canvas){svg.canvas.appendChild(el);}
var res=new Element(el,svg);res.attrs=res.attrs||{};res.attrs.x=x;res.attrs.y=y;res.attrs.width=w;res.attrs.height=h;res.attrs.stroke="#000";if(r){res.attrs.rx=res.attrs.ry=r;}
res.type="rect";return res;};var theEllipse=function(svg,x,y,rx,ry){var el=doc.createElementNS(svg.svgns,"ellipse");el.setAttribute("cx",x);el.setAttribute("cy",y);el.setAttribute("rx",rx);el.setAttribute("ry",ry);el.setAttribute("fill","none");el.setAttribute("stroke","#000");if(svg.canvas){svg.canvas.appendChild(el);}
var res=new Element(el,svg);res.attrs=res.attrs||{};res.attrs.cx=x;res.attrs.cy=y;res.attrs.rx=rx;res.attrs.ry=ry;res.attrs.stroke="#000";res.type="ellipse";return res;};var theImage=function(svg,src,x,y,w,h){var el=doc.createElementNS(svg.svgns,"image");el.setAttribute("x",x);el.setAttribute("y",y);el.setAttribute("width",w);el.setAttribute("height",h);el.setAttribute("preserveAspectRatio","none");el.setAttributeNS(svg.xlink,"href",src);if(svg.canvas){svg.canvas.appendChild(el);}
var res=new Element(el,svg);res.attrs=res.attrs||{};res.attrs.x=x;res.attrs.y=y;res.attrs.width=w;res.attrs.height=h;res.type="image";return res;};var theText=function(svg,x,y,text){var el=doc.createElementNS(svg.svgns,"text");el.setAttribute("x",x);el.setAttribute("y",y);el.setAttribute("text-anchor","middle");if(svg.canvas){svg.canvas.appendChild(el);}
var res=new Element(el,svg);res.attrs=res.attrs||{};res.attrs.x=x;res.attrs.y=y;res.type="text";setFillAndStroke(res,{font:availableAttrs.font,stroke:"none",fill:"#000",text:text});return res;};var theGroup=function(svg){var el=doc.createElementNS(svg.svgns,"g");if(svg.canvas){svg.canvas.appendChild(el);}
var i=new Element(el,svg);for(var f in svg){if(f[0]!="_"&&typeof svg[f]=="function"){i[f]=(function(f){return function(){var e=svg[f].apply(svg,arguments);el.appendChild(e[0]);return e;};})(f);}}
i.type="group";return i;};var setSize=function(width,height){this.width=width||this.width;this.height=height||this.height;this.canvas.setAttribute("width",this.width);this.canvas.setAttribute("height",this.height);return this;};var create=function(){if(typeof arguments[0]=="string"){var container=doc.getElementById(arguments[0]);var width=arguments[1];var height=arguments[2];}
if(typeof arguments[0]=="object"){var container=arguments[0];var width=arguments[1];var height=arguments[2];}
if(typeof arguments[0]=="number"){var container=1,x=arguments[0],y=arguments[1],width=arguments[2],height=arguments[3];}
if(!container){throw new Error("SVG container not found.");}
paper.canvas=doc.createElementNS(paper.svgns,"svg");paper.canvas.setAttribute("width",width||320);paper.width=width||320;paper.canvas.setAttribute("height",height||200);paper.height=height||200;if(container==1){doc.body.appendChild(paper.canvas);paper.canvas.style.position="absolute";paper.canvas.style.left=x+"px";paper.canvas.style.top=y+"px";}else{if(container.firstChild){container.insertBefore(paper.canvas,container.firstChild);}else{container.appendChild(paper.canvas);}}
container={canvas:paper.canvas,clear:function(){while(this.canvas.firstChild){this.canvas.removeChild(this.canvas.firstChild);}
this.defs=doc.createElementNS(paper.svgns,"defs");this.canvas.appendChild(this.defs);}};for(var prop in paper){if(prop!="create"){container[prop]=paper[prop];}}
for(var prop in R.fn){if(!container[prop]){container[prop]=R.fn[prop];}}
container.clear();return container;};paper.remove=function(){this.canvas.parentNode.removeChild(this.canvas);};paper.svgns="http://www.w3.org/2000/svg";paper.xlink="http://www.w3.org/1999/xlink";paper.safari=function(){if(navigator.vendor=="Apple Computer, Inc."){var rect=this.rect(-this.width,-this.height,this.width*3,this.height*3).attr({stroke:"none"});setTimeout(function(){rect.remove();},0);}};}
if(R.vml){thePath=function(params,pathString,VML){var g=createNode("group"),gl=g.style;gl.position="absolute";gl.left=0;gl.top=0;gl.width=VML.width+"px";gl.height=VML.height+"px";var el=createNode("shape"),ol=el.style;ol.width=VML.width+"px";ol.height=VML.height+"px";el.path="";if(params["class"]){el.className="rvml "+params["class"];}
el.coordsize=this.coordsize;el.coordorigin=this.coordorigin;g.appendChild(el);VML.canvas.appendChild(g);var p=new Element(el,g,VML);p.isAbsolute=true;p.type="path";p.path=[];p.last={x:0,y:0,bx:0,by:0,isAbsolute:true};p.Path="";p.absolutely=function(){this.isAbsolute=true;return this;};p.relatively=function(){this.isAbsolute=false;return this;};p.moveTo=function(x,y){var d=this.isAbsolute?"m":"t";d+=Math.round(parseFloat(x,10))+" "+Math.round(parseFloat(y,10));this.node.path=this.Path+=d;this.last.x=(this.isAbsolute?0:this.last.x)+parseFloat(x,10);this.last.y=(this.isAbsolute?0:this.last.y)+parseFloat(y,10);this.last.isAbsolute=this.isAbsolute;this.attrs.path+=(this.isAbsolute?"M":"m")+[x,y];return this;};p.lineTo=function(x,y){var d=this.isAbsolute?"l":"r";d+=Math.round(parseFloat(x,10))+" "+Math.round(parseFloat(y,10));this[0].path=this.Path+=d;this.last.x=(this.isAbsolute?0:this.last.x)+parseFloat(x,10);this.last.y=(this.isAbsolute?0:this.last.y)+parseFloat(y,10);this.last.isAbsolute=this.isAbsolute;this.attrs.path+=(this.isAbsolute?"L":"l")+[x,y];return this;};p.arcTo=function(rx,ry,large_arc_flag,sweep_flag,x2,y2){x2=(this.isAbsolute?0:this.last.x)+x2;y2=(this.isAbsolute?0:this.last.y)+y2;var x1=this.last.x,y1=this.last.y,x=(x1-x2)/2,y=(y1-y2)/2,k=(large_arc_flag==sweep_flag?-1:1)*Math.sqrt(Math.abs(rx*rx*ry*ry-rx*rx*y*y-ry*ry*x*x)/(rx*rx*y*y+ry*ry*x*x)),cx=k*rx*y/ry+(x1+x2)/2,cy=k*-ry*x/rx+(y1+y2)/2,d=sweep_flag?(this.isAbsolute?"wa":"wr"):(this.isAbsolute?"at":"ar"),left=Math.round(cx-rx),top=Math.round(cy-ry);d+=[left,top,Math.round(left+rx*2),Math.round(top+ry*2),Math.round(x1),Math.round(y1),Math.round(parseFloat(x2,10)),Math.round(parseFloat(y2,10))].join(", ");this.node.path=this.Path+=d;this.last.x=(this.isAbsolute?0:this.last.x)+parseFloat(x2,10);this.last.y=(this.isAbsolute?0:this.last.y)+parseFloat(y2,10);this.last.isAbsolute=this.isAbsolute;this.attrs.path+=(this.isAbsolute?"A":"a")+[rx,ry,0,large_arc_flag,sweep_flag,x2,y2];return this;};p.cplineTo=function(x1,y1,w1){if(!w1){return this.lineTo(x1,y1);}else{var x=Math.round(Math.round(parseFloat(x1,10)*100)/100),y=Math.round(Math.round(parseFloat(y1,10)*100)/100),w=Math.round(Math.round(parseFloat(w1,10)*100)/100),d=this.isAbsolute?"c":"v",attr=[Math.round(this.last.x)+w,Math.round(this.last.y),x-w,y,x,y],svgattr=[this.last.x+w1,this.last.y,x1-w1,y1,x1,y1];d+=attr.join(" ")+" ";this.last.x=(this.isAbsolute?0:this.last.x)+attr[4];this.last.y=(this.isAbsolute?0:this.last.y)+attr[5];this.last.bx=attr[2];this.last.by=attr[3];this.node.path=this.Path+=d;this.attrs.path+=(this.isAbsolute?"C":"c")+svgattr;return this;}};p.curveTo=function(){var d=this.isAbsolute?"c":"v";if(arguments.length==6){this.last.bx=(this.isAbsolute?0:this.last.x)+parseFloat(arguments[2],10);this.last.by=(this.isAbsolute?0:this.last.y)+parseFloat(arguments[3],10);this.last.x=(this.isAbsolute?0:this.last.x)+parseFloat(arguments[4],10);this.last.y=(this.isAbsolute?0:this.last.y)+parseFloat(arguments[5],10);d+=[Math.round(parseFloat(arguments[0],10)),Math.round(parseFloat(arguments[1],10)),Math.round(parseFloat(arguments[2],10)),Math.round(parseFloat(arguments[3],10)),Math.round(parseFloat(arguments[4],10)),Math.round(parseFloat(arguments[5],10))].join(" ")+" ";this.last.isAbsolute=this.isAbsolute;this.attrs.path+=(this.isAbsolute?"C":"c")+Array.prototype.splice.call(arguments,0,arguments.length);}
if(arguments.length==4){var bx=this.last.x*2-this.last.bx;var by=this.last.y*2-this.last.by;this.last.bx=(this.isAbsolute?0:this.last.x)+parseFloat(arguments[0],10);this.last.by=(this.isAbsolute?0:this.last.y)+parseFloat(arguments[1],10);this.last.x=(this.isAbsolute?0:this.last.x)+parseFloat(arguments[2],10);this.last.y=(this.isAbsolute?0:this.last.y)+parseFloat(arguments[3],10);d+=[Math.round(bx),Math.round(by),Math.round(parseFloat(arguments[0],10)),Math.round(parseFloat(arguments[1],10)),Math.round(parseFloat(arguments[2],10)),Math.round(parseFloat(arguments[3],10))].join(" ")+" ";this.attrs.path+=(this.isAbsolute?"S":"s")+Array.prototype.splice.call(arguments,0,arguments.length);}
this.node.path=this.Path+=d;return this;};p.qcurveTo=function(){var d="qb";if(arguments.length==4){this.last.qx=(this.isAbsolute?0:this.last.x)+parseFloat(arguments[0],10);this.last.qy=(this.isAbsolute?0:this.last.y)+parseFloat(arguments[1],10);this.last.x=(this.isAbsolute?0:this.last.x)+parseFloat(arguments[2],10);this.last.y=(this.isAbsolute?0:this.last.y)+parseFloat(arguments[3],10);d+=[Math.round(this.last.qx),Math.round(this.last.qy),Math.round(this.last.x),Math.round(this.last.y)].join(" ")+" ";this.last.isAbsolute=this.isAbsolute;this.attrs.path+=(this.isAbsolute?"Q":"q")+Array.prototype.splice.call(arguments,0,arguments.length);}
if(arguments.length==2){this.last.qx=this.last.x*2-this.last.qx;this.last.qy=this.last.y*2-this.last.qy;this.last.x=(this.isAbsolute?0:this.last.x)+parseFloat(arguments[2],10);this.last.y=(this.isAbsolute?0:this.last.y)+parseFloat(arguments[3],10);d+=[Math.round(this.last.qx),Math.round(this.last.qy),Math.round(this.last.x),Math.round(this.last.y)].join(" ")+" ";this.attrs.path+=(this.isAbsolute?"T":"t")+Array.prototype.splice.call(arguments,0,arguments.length);}
this.node.path=this.Path+=d;this.path.push({type:"qcurve",arg:[].slice.call(arguments,0),pos:this.isAbsolute});return this;};p.addRoundedCorner=function(r,dir){var R=.5522*r,rollback=this.isAbsolute,o=this;if(rollback){this.relatively();rollback=function(){o.absolutely();};}else{rollback=function(){};}
var actions={l:function(){return{u:function(){o.curveTo(-R,0,-r,-(r-R),-r,-r);},d:function(){o.curveTo(-R,0,-r,r-R,-r,r);}};},r:function(){return{u:function(){o.curveTo(R,0,r,-(r-R),r,-r);},d:function(){o.curveTo(R,0,r,r-R,r,r);}};},u:function(){return{r:function(){o.curveTo(0,-R,-(R-r),-r,r,-r);},l:function(){o.curveTo(0,-R,R-r,-r,-r,-r);}};},d:function(){return{r:function(){o.curveTo(0,R,-(R-r),r,r,r);},l:function(){o.curveTo(0,R,R-r,r,-r,r);}};}};actions[dir.charAt(0)]()[dir.charAt(1)]();rollback();return o;};p.andClose=function(){this.node.path=(this.Path+="x e");this.attrs.path+="z";return this;};if(pathString){p.absolutely();p.attrs.path="";paper.pathfinder(p,""+pathString);}
setFillAndStroke(p,params);if(params.gradient){addGrdientFill(p,params.gradient);}
return p;};var setFillAndStroke=function(o,params){var s=o.node.style,res=o;o.attrs=o.attrs||{};for(var par in params){o.attrs[par]=params[par];}
if(params.path&&o.type=="path"){o.Path="";o.path=[];paper.pathfinder(o,params.path);}
if(params.rotation!=null){o.rotate(params.rotation,true);}
if(params.translation){var xy=(params.translation+"").split(separator);o.translate(xy[0],xy[1]);}
if(params.scale){var xy=(params.scale+"").split(separator);o.scale(xy[0],xy[1]);}
if(o.type=="image"&&params.src){o.node.src=params.src;}
if(o.type=="image"&&params.opacity){o.node.filterOpacity=" progid:DXImageTransform.Microsoft.Alpha(opacity="+(params.opacity*100)+")";o.node.style.filter=(o.node.filterMatrix||"")+(o.node.filterOpacity||"");}
params.font&&(s.font=params.font);params["font-family"]&&(s.fontFamily=params["font-family"]);params["font-size"]&&(s.fontSize=params["font-size"]);params["font-weight"]&&(s.fontWeight=params["font-weight"]);params["font-style"]&&(s.fontStyle=params["font-style"]);if(typeof params.opacity!="undefined"||typeof params["stroke-width"]!="undefined"||typeof params.fill!="undefined"||typeof params.stroke!="undefined"||params["stroke-width"]||params["stroke-opacity"]||params["stroke-dasharray"]||params["stroke-miterlimit"]||params["stroke-linejoin"]||params["stroke-linecap"]){o=o.shape||o.node;var fill=(o.getElementsByTagName("fill")&&o.getElementsByTagName("fill")[0])||createNode("fill");if("fill-opacity"in params||"opacity"in params){fill.opacity=((+params["fill-opacity"]+1||2)-1)*((+params.opacity+1||2)-1);}
if(params.fill){fill.on=true;}
if(typeof fill.on=="undefined"||params.fill=="none"){fill.on=false;}
if(fill.on&&params.fill){var isURL=params.fill.match(/^url\(([^\)]+)\)$/i);if(isURL){fill.src=isURL[1];fill.type="tile";}else{fill.color=getRGB(params.fill).hex;fill.src="";fill.type="solid";}}
o.appendChild(fill);var stroke=(o.getElementsByTagName("stroke")&&o.getElementsByTagName("stroke")[0])||createNode("stroke");if((params.stroke&&params.stroke!="none")||params["stroke-width"]||typeof params["stroke-opacity"]!="undefined"||params["stroke-dasharray"]||params["stroke-miterlimit"]||params["stroke-linejoin"]||params["stroke-linecap"]){stroke.on=true;}
if(params.stroke=="none"||typeof stroke.on=="undefined"||params.stroke==0){stroke.on=false;}
if(stroke.on&&params.stroke){stroke.color=getRGB(params.stroke).hex;}
stroke.opacity=((+params["stroke-opacity"]+1||2)-1)*((+params.opacity+1||2)-1);params["stroke-linejoin"]&&(stroke.joinstyle=params["stroke-linejoin"]||"miter");stroke.miterlimit=params["stroke-miterlimit"]||8;params["stroke-linecap"]&&(stroke.endcap={butt:"flat",square:"square",round:"round"}[params["stroke-linecap"]]||"miter");params["stroke-width"]&&(stroke.weight=(parseFloat(params["stroke-width"],10)||1)*12/16);if(params["stroke-dasharray"]){var dasharray={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};stroke.dashstyle=dasharray[params["stroke-dasharray"]]||"";}
o.appendChild(stroke);}
if(res.type=="text"){var span=doc.createElement("span"),s=span.style;res.attrs.font&&(s.font=res.attrs.font);res.attrs["font-family"]&&(s.fontFamily=res.attrs["font-family"]);res.attrs["font-size"]&&(s.fontSize=res.attrs["font-size"]);res.attrs["font-weight"]&&(s.fontWeight=res.attrs["font-weight"]);res.attrs["font-style"]&&(s.fontStyle=res.attrs["font-style"]);res.node.parentNode.appendChild(span);span.innerText=res.node.string;res.W=res.attrs.w=span.offsetWidth;res.H=res.attrs.h=span.offsetHeight;res.X=res.attrs.x-Math.round(res.W/2);res.Y=res.attrs.y-Math.round(res.H/2);res.node.parentNode.removeChild(span);}};var getAngle=function(a,b,c,d){var angle=Math.round(Math.atan((parseFloat(c,10)-parseFloat(a,10))/(parseFloat(d,10)-parseFloat(b,10)))*57.29)||0;if(!angle&&parseFloat(a,10)<parseFloat(b,10)){angle=180;}
angle-=180;if(angle<0){angle+=360;}
return angle;};var addGrdientFill=function(o,gradient){gradient=toGradient(gradient);o.attrs=o.attrs||{};var attrs=o.attrs;o.attrs.gradient=gradient;o=o.shape||o[0];var fill=o.getElementsByTagName("fill");if(fill.length){fill=fill[0];}else{fill=createNode("fill");}
if(gradient.dots.length){fill.on=true;fill.method="none";fill.type=((gradient.type+"").toLowerCase()=="radial")?"gradientTitle":"gradient";if(typeof gradient.dots[0].color!="undefined"){fill.color=getRGB(gradient.dots[0].color).hex;}
if(typeof gradient.dots[gradient.dots.length-1].color!="undefined"){fill.color2=getRGB(gradient.dots[gradient.dots.length-1].color).hex;}
var colors=[];for(var i=0,ii=gradient.dots.length;i<ii;i++){if(gradient.dots[i].offset){colors.push(gradient.dots[i].offset+" "+getRGB(gradient.dots[i].color).hex);}};var fillOpacity=typeof gradient.dots[gradient.dots.length-1].opacity=="undefined"?(typeof attrs.opacity=="undefined"?1:attrs.opacity):gradient.dots[gradient.dots.length-1].opacity;if(colors.length){fill.colors.value=colors.join(",");fillOpacity=typeof attrs.opacity=="undefined"?1:attrs.opacity;}else{fill.colors.value="0% "+fill.color;}
fill.opacity=fillOpacity;if(typeof gradient.angle!="undefined"){fill.angle=(-gradient.angle+270)%360;}else if(gradient.vector){fill.angle=getAngle.apply(null,gradient.vector);}
if((gradient.type+"").toLowerCase()=="radial"){fill.focus="100%";fill.focusposition="0.5 0.5";}}};var Element=function(node,group,vml){var Rotation=0,RotX=0,RotY=0,Scale=1;this[0]=node;this.node=node;this.X=0;this.Y=0;this.attrs={};this.Group=group;this.vml=vml;this._={tx:0,ty:0,rt:{deg:0},sx:1,sy:1};};Element.prototype.rotate=function(deg,cx,cy){if(deg==null){return this._.rt.deg;}
deg=deg.toString().split(separator);if(deg.length-1){cx=parseFloat(deg[1],10);cy=parseFloat(deg[2],10);}
deg=parseFloat(deg[0],10);if(cy==null){cx=null;}
if(cx!=null){this._.rt.deg=deg;}else{this._.rt.deg+=deg;}
this._.rt.cx=cx;this._.rt.cy=cy;this.setBox(null,cx,cy);this.Group.style.rotation=this._.rt.deg;return this;};Element.prototype.setBox=function(params,cx,cy){var gs=this.Group.style,os=(this.shape&&this.shape.style)||this.node.style;for(var i in params){this.attrs[i]=params[i];}
cx=cx||this._.rt.cx;cy=cy||this._.rt.cy;var attr=this.attrs,x,y,w,h;switch(this.type){case"circle":x=attr.cx-attr.r;y=attr.cy-attr.r;w=h=attr.r*2;break;case"ellipse":x=attr.cx-attr.rx;y=attr.cy-attr.ry;w=attr.rx*2;h=attr.ry*2;break;case"rect":case"image":x=attr.x;y=attr.y;w=attr.width||0;h=attr.height||0;break;case"text":this.textpath.v=["m",Math.round(attr.x),", ",Math.round(attr.y-2),"l",Math.round(attr.x)+1,", ",Math.round(attr.y-2)].join("");x=attr.x-Math.round(this.W/2);y=attr.y-this.H/2;w=this.W;h=this.H;break;case"path":if(!this.attrs.path){x=0;y=0;w=this.vml.width;h=this.vml.height;}else{var dim=pathDimensions(this.attrs.path),x=dim.x;y=dim.y;w=dim.width;h=dim.height;}
break;default:x=0;y=0;w=this.vml.width;h=this.vml.height;break;}
cx=(cx==null)?x+w/2:cx;cy=(cy==null)?y+h/2:cy;var left=cx-this.vml.width/2,top=cy-this.vml.height/2;if(this.type=="path"||this.type=="text"){gs.left=left+"px";gs.top=top+"px";this.X=this.type=="text"?x:-left;this.Y=this.type=="text"?y:-top;this.W=w;this.H=h;os.left=-left+"px";os.top=-top+"px";}else{gs.left=left+"px";gs.top=top+"px";this.X=x;this.Y=y;this.W=w;this.H=h;gs.width=this.vml.width+"px";gs.height=this.vml.height+"px";os.left=x-left+"px";os.top=y-top+"px";os.width=w+"px";os.height=h+"px";}};Element.prototype.hide=function(){this.Group.style.display="none";return this;};Element.prototype.show=function(){this.Group.style.display="block";return this;};Element.prototype.getBBox=function(){return{x:this.X,y:this.Y,width:this.W,height:this.H};};Element.prototype.remove=function(){this[0].parentNode.removeChild(this[0]);this.Group.parentNode.removeChild(this.Group);this.shape&&this.shape.parentNode.removeChild(this.shape);};Element.prototype.attr=function(){if(arguments.length==1&&typeof arguments[0]=="string"){if(arguments[0]=="translation"){return this.translate();}
return this.attrs[arguments[0]];}
if(this.attrs&&arguments.length==1&&arguments[0]instanceof Array){var values={};for(var i=0,ii=arguments[0].length;i<ii;i++){values[arguments[0][i]]=this.attrs[arguments[0][i]];};return values;}
var params;if(arguments.length==2){params={};params[arguments[0]]=arguments[1];}
if(arguments.length==1&&typeof arguments[0]=="object"){params=arguments[0];}
if(params){if(params.gradient){addGrdientFill(this,params.gradient);}
if(params.text&&this.type=="text"){this.node.string=params.text;}
if(params.id){this.node.id=params.id;}
setFillAndStroke(this,params);this.setBox(params);}
return this;};Element.prototype.toFront=function(){this.Group.parentNode.appendChild(this.Group);return this;};Element.prototype.toBack=function(){if(this.Group.parentNode.firstChild!=this.Group){this.Group.parentNode.insertBefore(this.Group,this.Group.parentNode.firstChild);}
return this;};Element.prototype.insertAfter=function(element){if(element.Group.nextSibling){element.Group.parentNode.insertBefore(this.Group,element.Group.nextSibling);}else{element.Group.parentNode.appendChild(this.Group);}
return this;};Element.prototype.insertBefore=function(element){element.Group.parentNode.insertBefore(this.Group,element.Group);return this;};var theCircle=function(vml,x,y,r){var g=createNode("group");var o=createNode("oval");g.appendChild(o);vml.canvas.appendChild(g);var res=new Element(o,g,vml);res.type="circle";setFillAndStroke(res,{stroke:"#000",fill:"none"});res.attrs.cx=x;res.attrs.cy=y;res.attrs.r=r;res.setBox({x:x-r,y:y-r,width:r*2,height:r*2});return res;};var theRect=function(vml,x,y,w,h,r){var g=createNode("group");var o=createNode(r?"roundrect":"rect");if(r){o.arcsize=r/(Math.min(w,h));}
g.appendChild(o);vml.canvas.appendChild(g);var res=new Element(o,g,vml);res.type="rect";setFillAndStroke(res,{stroke:"#000"});res.attrs.x=x;res.attrs.y=y;res.attrs.w=w;res.attrs.h=h;res.attrs.r=r;res.setBox({x:x,y:y,width:w,height:h});return res;};var theEllipse=function(vml,x,y,rx,ry){var g=createNode("group");var o=createNode("oval");g.appendChild(o);vml.canvas.appendChild(g);var res=new Element(o,g,vml);res.type="ellipse";setFillAndStroke(res,{stroke:"#000"});res.attrs.cx=x;res.attrs.cy=y;res.attrs.rx=rx;res.attrs.ry=ry;res.setBox({x:x-rx,y:y-ry,width:rx*2,height:ry*2});return res;};var theImage=function(vml,src,x,y,w,h){var g=createNode("group");var o=createNode("image");o.src=src;g.appendChild(o);vml.canvas.appendChild(g);var res=new Element(o,g,vml);res.type="image";res.attrs.x=x;res.attrs.y=y;res.attrs.w=w;res.attrs.h=h;res.setBox({x:x,y:y,width:w,height:h});return res;};var theText=function(vml,x,y,text){var g=createNode("group"),gs=g.style;var el=createNode("shape"),ol=el.style;var path=createNode("path"),ps=path.style;path.v=["m",Math.round(x),", ",Math.round(y-2),"l",Math.round(x)+1,", ",Math.round(y-2)].join("");path.textpathok=true;ol.width=vml.width;ol.height=vml.height;gs.position="absolute";gs.left=0;gs.top=0;gs.width=vml.width;gs.height=vml.height;var o=createNode("textpath");o.string=text;o.on=true;o.coordsize=vml.coordsize;o.coordorigin=vml.coordorigin;el.appendChild(o);el.appendChild(path);g.appendChild(el);vml.canvas.appendChild(g);var res=new Element(o,g,vml);res.shape=el;res.textpath=path;res.type="text";res.attrs.x=x;res.attrs.y=y;res.attrs.w=1;res.attrs.h=1;setFillAndStroke(res,{font:availableAttrs.font,stroke:"none",fill:"#000"});return res;};var setSize=function(width,height){this.width=width||this.width;this.height=height||this.height;this.canvas.style.width=this.width+"px";this.canvas.style.height=this.height+"px";this.canvas.parentNode.style.clip="rect(0 "+this.width+" "+this.height+" 0)";this.canvas.coordsize=this.width+" "+this.height;return this;};doc.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)");try{if(!doc.namespaces.rvml){doc.namespaces.add("rvml","urn:schemas-microsoft-com:vml");}
var createNode=function(tagName){return doc.createElement('<rvml:'+tagName+' class="rvml">');};}catch(e){var createNode=function(tagName){return doc.createElement('<'+tagName+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');};}
var create=function(){var container,width,height;if(typeof arguments[0]=="string"){container=doc.getElementById(arguments[0]);width=arguments[1];height=arguments[2];}
if(typeof arguments[0]=="object"){container=arguments[0];width=arguments[1];height=arguments[2];}
if(typeof arguments[0]=="number"){container=1;x=arguments[0];y=arguments[1];width=arguments[2];height=arguments[3];}
if(!container){throw new Error("VML container not found.");}
var c=doc.createElement("div"),d=doc.createElement("div"),r=paper.canvas=createNode("group"),cs=c.style,rs=r.style;paper.width=width;paper.height=height;width=width||"320px";height=height||"200px";cs.clip="rect(0 "+width+"px "+height+"px 0)";cs.top="-2px";cs.left="-2px";cs.position="absolute";rs.position="absolute";d.style.position="relative";rs.width=width;rs.height=height;r.coordsize=(/%$/.test(width)?width:parseFloat(width,10))+" "+(/%$/.test(height)?height:parseFloat(height,10));r.coordorigin="0 0";var b=createNode("rect"),bs=b.style;bs.left=bs.top=0;bs.width=rs.width;bs.height=rs.height;b.filled=b.stroked="f";r.appendChild(b);c.appendChild(r);d.appendChild(c);if(container==1){doc.body.appendChild(d);cs.position="absolute";cs.left=x+"px";cs.top=y+"px";cs.width=width;cs.height=height;container={style:{width:width,height:height}};}else{cs.width=container.style.width=width;cs.height=container.style.height=height;if(container.firstChild){container.insertBefore(d,container.firstChild);}else{container.appendChild(d);}}
for(var prop in paper){container[prop]=paper[prop];}
for(var prop in R.fn){if(!container[prop]){container[prop]=R.fn[prop];}}
container.clear=function(){var todel=[];for(var i=0,ii=r.childNodes.length;i<ii;i++){if(r.childNodes[i]!=b){todel.push(r.childNodes[i]);}}
for(i=0,ii=todel.length;i<ii;i++){r.removeChild(todel[i]);}};return container;};paper.remove=function(){this.canvas.parentNode.parentNode.parentNode.removeChild(this.canvas.parentNode.parentNode);};paper.safari=function(){};}
var addEvent=(function(){if(doc.addEventListener){return function(obj,type,fn,element){var f=function(e){return fn.call(element,e);};obj.addEventListener(type,f,false);return function(){obj.removeEventListener(type,f,false);return true;};};}else if(doc.attachEvent){return function(obj,type,fn,element){var f=function(e){return fn.call(element,e||win.event);};obj.attachEvent("on"+type,f);var detacher=function(){obj.detachEvent("on"+type,f);return true;};if(type=="mouseover"){obj.attachEvent("onmouseenter",f);return function(){obj.detachEvent("onmouseenter",f);return detacher();};}else if(type=="mouseout"){obj.attachEvent("onmouseleave",f);return function(){obj.detachEvent("onmouseleave",f);return detacher();};}
return detacher;};}})();for(var i=events.length;i--;){(function(eventName){Element.prototype[eventName]=function(fn){if(typeof fn=="function"){this.events=this.events||{};this.events[eventName]=this.events[eventName]||{};this.events[eventName][fn]=this.events[eventName][fn]||[];this.events[eventName][fn].push(addEvent(this.shape||this.node,eventName,fn,this));}
return this;};Element.prototype["un"+eventName]=function(fn){this.events&&this.events[eventName]&&this.events[eventName][fn]&&this.events[eventName][fn].length&&this.events[eventName][fn].shift()()&&!this.events[eventName][fn].length&&delete this.events[eventName][fn];};})(events[i]);}
paper.circle=function(x,y,r){return theCircle(this,x,y,r);};paper.rect=function(x,y,w,h,r){return theRect(this,x,y,w,h,r);};paper.ellipse=function(x,y,rx,ry){return theEllipse(this,x,y,rx,ry);};paper.path=function(params,pathString){return thePath(params,pathString,this);};paper.image=function(src,x,y,w,h){return theImage(this,src,x,y,w,h);};paper.text=function(x,y,text){return theText(this,x,y,text);};paper.group=function(){return this;};paper.drawGrid=function(x,y,w,h,wv,hv,color){color=color||"#000";var path=["M",x,y,"L",x+w,y,x+w,y+h,x,y+h,x,y],rowHeight=h/hv,columnWidth=w/wv;for(var i=1;i<hv;i++){path=path.concat(["M",x,y+i*rowHeight,"L",x+w,y+i*rowHeight]);}
for(var i=1;i<wv;i++){path=path.concat(["M",x+i*columnWidth,y,"L",x+i*columnWidth,y+h]);}
return this.path({stroke:color,"stroke-width":1},path.join(","));};paper.pathfinder=function(p,path){var commands={M:function(x,y){this.moveTo(x,y);},C:function(x1,y1,x2,y2,x3,y3){this.curveTo(x1,y1,x2,y2,x3,y3);},Q:function(x1,y1,x2,y2){this.qcurveTo(x1,y1,x2,y2);},T:function(x,y){this.qcurveTo(x,y);},S:function(x1,y1,x2,y2){p.curveTo(x1,y1,x2,y2);},L:function(x,y){p.lineTo(x,y);},H:function(x){this.lineTo(x,this.last.y);},V:function(y){this.lineTo(this.last.x,y);},A:function(rx,ry,xaxisrotation,largearcflag,sweepflag,x,y){this.arcTo(rx,ry,largearcflag,sweepflag,x,y);},Z:function(){this.andClose();}};path=pathToAbsolute(path);for(var i=0,ii=path.length;i<ii;i++){var b=path[i].shift();commands[b].apply(p,path[i]);}};paper.set=function(itemsArray){return new Set(itemsArray);};paper.setSize=setSize;Element.prototype.stop=function(){clearTimeout(this.animation_in_progress);};Element.prototype.scale=function(x,y){if(x==undefined&&y==undefined){return{x:this._.sx,y:this._.sy};}
y=y||x;isNaN(y)&&(y=x);var dx,dy,cx,cy;if(x!=0){var dirx=Math.round(x/Math.abs(x)),diry=Math.round(y/Math.abs(y)),s=this.node.style;dx=this.attr("x");dy=this.attr("y");cx=this.attr("cx");cy=this.attr("cy");if(dirx!=1||diry!=1){if(this.transformations){this.transformations[2]="scale("+[dirx,diry]+")";this.node.setAttribute("transform",this.transformations.join(" "));dx=(dirx<0)?-this.attr("x")-this.attrs.width*x*dirx/this._.sx:this.attr("x");dy=(diry<0)?-this.attr("y")-this.attrs.height*y*diry/this._.sy:this.attr("y");cx=this.attr("cx")*dirx;cy=this.attr("cy")*diry;}else{this.node.filterMatrix=" progid:DXImageTransform.Microsoft.Matrix(M11="+dirx+", M12=0, M21=0, M22="+diry+", Dx=0, Dy=0, sizingmethod='auto expand', filtertype='bilinear')";s.filter=(this.node.filterMatrix||"")+(this.node.filterOpacity||"");}}else{if(this.transformations){this.transformations[2]="";this.node.setAttribute("transform",this.transformations.join(" "));}else{this.node.filterMatrix="";s.filter=(this.node.filterMatrix||"")+(this.node.filterOpacity||"");}}
switch(this.type){case"rect":case"image":this.attr({width:this.attrs.width*x*dirx/this._.sx,height:this.attrs.height*y*diry/this._.sy,x:dx,y:dy});break;case"circle":case"ellipse":this.attr({rx:this.attrs.rx*x*dirx/this._.sx,ry:this.attrs.ry*y*diry/this._.sy,r:this.attrs.r*x*diry/this._.sx,cx:cx,cy:cy});break;case"path":var path=pathToRelative(Raphael.parsePathString(this.attr("path"))),skip=true,dim=pathDimensions(this.attrs.path),dx=-dim.width*(x-1)/2,dy=-dim.height*(y-1)/2;for(var i=0,ii=path.length;i<ii;i++){if(path[i][0].toUpperCase()=="M"&&skip){continue;}else{skip=false;}
if(path[i][0].toUpperCase()=="A"){path[i][path[i].length-2]*=x*dirx;path[i][path[i].length-1]*=y*diry;}else{for(var j=1,jj=path[i].length;j<jj;j++){path[i][j]*=(j%2)?x*dirx/this._.sx:y*diry/this._.sy;}}}
var dim2=pathDimensions(path),dx=dim.x+dim.width/2-dim2.x-dim2.width/2,dy=dim.y+dim.height/2-dim2.y-dim2.height/2;path=pathToRelative(path);path[0][1]+=dx;path[0][2]+=dy;this.attr({path:path.join(" ")});}}
this._.sx=x;this._.sy=y;return this;};Element.prototype.animate=function(params,ms,callback){clearTimeout(this.animation_in_progress);var from={},to={},diff={},t={x:0,y:0};for(var attr in params){if(attr in availableAnimAttrs){from[attr]=this.attr(attr);if(typeof from[attr]=="undefined"){from[attr]=availableAttrs[attr];}
to[attr]=params[attr];switch(availableAnimAttrs[attr]){case"number":diff[attr]=(to[attr]-from[attr])/ms;break;case"colour":from[attr]=getRGB(from[attr]);var toColour=getRGB(to[attr]);diff[attr]={r:(toColour.r-from[attr].r)/ms,g:(toColour.g-from[attr].g)/ms,b:(toColour.b-from[attr].b)/ms};break;case"path":var pathes=pathEqualiser(from[attr],to[attr]);from[attr]=pathes[0];to[attr]=pathes[1];diff[attr]=[];for(var i=0,ii=from[attr].length;i<ii;i++){diff[attr][i]=[0];for(var j=1,jj=from[attr][i].length;j<jj;j++){diff[attr][i][j]=(to[attr][i][j]-from[attr][i][j])/ms;}}
break;case"csv":var values=params[attr].toString().split(separator),from2=from[attr].toString().split(separator);if(attr=="translation"){from[attr]=[0,0];diff[attr]=[values[0]/ms,values[1]/ms];}else if(attr=="rotation"){from[attr]=(from2[1]==values[1]&&from2[2]==values[2])?from2:[0,values[1],values[2]];diff[attr]=[(values[0]-from[attr][0])/ms,0,0];}else{from[attr]=(from[attr]+"").split(separator);diff[attr]=[(values[0]-from[attr][0])/ms,(values[1]-from[attr][0])/ms];}
to[attr]=values;}}}
var start=new Date(),prev=0,that=this;(function(){var time=(new Date()).getTime()-start.getTime(),set={},now;if(time<ms){for(var attr in from){switch(availableAnimAttrs[attr]){case"number":now=+from[attr]+time*diff[attr];break;case"colour":now="rgb("+[Math.round(from[attr].r+time*diff[attr].r),Math.round(from[attr].g+time*diff[attr].g),Math.round(from[attr].b+time*diff[attr].b)].join(",")+")";break;case"path":now=[];for(var i=0,ii=from[attr].length;i<ii;i++){now[i]=[from[attr][i][0]];for(var j=1,jj=from[attr][i].length;j<jj;j++){now[i][j]=from[attr][i][j]+time*diff[attr][i][j];}
now[i]=now[i].join(" ");}
now=now.join(" ");break;case"csv":if(attr=="translation"){var x=diff[attr][0]*(time-prev),y=diff[attr][1]*(time-prev);t.x+=x;t.y+=y;now=[x,y].join(" ");}else if(attr=="rotation"){now=+from[attr][0]+time*diff[attr][0];from[attr][1]&&(now+=","+from[attr][1]+","+from[attr][2]);}else{now=[+from[attr][0]+time*diff[attr][0],+from[attr][1]+time*diff[attr][1]].join(" ");}
break;}
if(attr=="font-size"){set[attr]=now+"px";}else{set[attr]=now;}}
that.attr(set);that.animation_in_progress=setTimeout(arguments.callee,0);paper.safari();}else{(t.x||t.y)&&that.translate(-t.x,-t.y);that.attr(params);clearTimeout(that.animation_in_progress);paper.safari();(typeof callback=="function")&&callback.call(that);}
prev=time;})();return this;};Element.prototype.translate=function(x,y){if(x==null){return{x:this._.tx,y:this._.ty};}
this._.tx+=+x;this._.ty+=+y;switch(this.type){case"circle":case"ellipse":this.attr({cx:this.attrs.cx+x,cy:this.attrs.cy+y});break;case"rect":case"image":case"text":this.attr({x:this.attrs.x+(+x),y:this.attrs.y+(+y)});break;case"path":var path=pathToRelative(this.attrs.path);path[0][1]+=+x;path[0][2]+=+y;this.attr({path:path.join(" ")});break;}
return this;};var Set=function(itemsArray){this.items=[];this.length=(itemsArray&&itemsArray.length)||0;if(itemsArray&&itemsArray.constructor==Array){for(var i=itemsArray.length;i--;){if(itemsArray[i].constructor==Element){this.items[this.items.length]=itemsArray[i];}}}};Set.prototype.push=function(item){if(item&&item.constructor==Element){var len=this.items.length;this.items[len]=item;this[len]=item;this.length++;}
return this;};Set.prototype.pull=function(id){var res=this.items.splice(id,1)[0];for(var j=id,jj=this.items.length;j<jj;j++){this[j]=this[j+1];}
delete this[jj+1];this.length--;return res;};for(var method in Element.prototype){Set.prototype[method]=(function(methodname){return function(){for(var i=this.items.length;i--;){this.items[i][methodname].apply(this.items[i],arguments);}
return this;};})(method);}
Set.prototype.getBBox=function(){var x=[],y=[],w=[],h=[];for(var i=this.items.length;i--;){var box=this.items[i].getBBox();x.push(box.x);y.push(box.y);w.push(box.x+box.width);h.push(box.y+box.height);}
x=Math.min.apply(Math,x);y=Math.min.apply(Math,y);return{x:x,y:y,width:Math.max.apply(Math,w)-x,height:Math.max.apply(Math,h)-y};};return R;})();Evri.defineNamespace(Evri.Widget.Components,"Visualization");Evri.defineClass(Evri.Widget.Components.Visualization,"Canvas",function(width,height){var self=this;var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;self.wrapper=baconl(".evri-component.component-visualization");self.wrapper.width(width);self.wrapper.height(height);self.width=function(){return width;}
self.height=function(){return height;}
self.paper=Evri.Raphael(self.wrapper[0],width,height);if(Evri.$.browser.msie){Evri.$(self.paper).find("group").css("position","absolute");self.wrapper.append(baconl(".evri-vml-wrapper").height(height).width(width));}});Evri.extendClass(Evri.Widget.Components.Visualization.Canvas,{empty:function(){Evri.$(this.paper.canvas).empty();this.wrapper.children(".evri-visualization-label").remove();return this;},attributesForEntity:function(entityType){var def={"stroke":"#B1B1B1","fill":"#CCCCCC","stroke-width":3};var attributes={"organization":{"stroke":"#EB122F","fill":"#FFC4CC","stroke-width":3},"product":{"stroke":"#A56ECA","fill":"#E8C5FF","stroke-width":3},"person":{"stroke":"#B1D535","fill":"#E9FF9F","stroke-width":3},"location":{"stroke":"#7BC2FF","fill":"#BDE0FF","stroke-width":3},"event":{"stroke":"#48628E","fill":"#C0D7FF","stroke-width":3},"concept":{"stroke":"#F6EAA7","fill":"#FFF9D6","stroke-width":3},"action":{"stroke":"#FF9C34","fill":"#FFCE9A","stroke-width":3},"other":def};return attributes[entityType]||def;},nodeForEntity:function(x,y,radius,entity){var self=this;var $=Evri.$;var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;var label=baconl("%div.evri-visualization-label-ellipsis.evri-visualization-label").css({"position":"absolute","opacity":0}).append(baconl("%div.evri-truncated").text(entity.name),baconl("%div.evri-expanded").text(entity.name));self.wrapper.append(label);var circle=self.paper.circle(x,y,radius);var attributes=self.attributesForEntity(entity.href.split("/")[1]);function expand(){label.removeClass("evri-visualization-label-ellipsis");label.css("top",y-label.height()/2);return this;}
function shrink(){label.addClass("evri-visualization-label-ellipsis");label.css("top",y-label.height()/2);return this;}
function center(){label.css({"left":x-label.outerWidth()/2,"top":y-label.outerHeight()/2+1});}
center();return{entity:entity,label:label,circle:circle,center:center,attributes:function(){return attributes;},fadeIn:function(callback){var obj=this;circle.attr("r",0);var start={r:0,opacity:0};Evri.JSTweener.addTween(start,{r:radius,opacity:1.0,time:1,transition:"easeOutBack",onUpdate:function(){circle.attr("r",start.r);if(start.opacity<=1.0&&start.opacity>=0){label.css("opacity",start.opacity);}},onComplete:function(){if(callback!==undefined)callback.call(obj);}});return false;},fadeOut:function(callback){var obj=this;var start={r:radius,opacity:1};Evri.JSTweener.addTween(start,{r:0,opacity:0,time:1,transition:"easeInBack",onUpdate:function(){circle.attr("r",start.r);if(start.opacity<=1.0&&start.opacity>=0){label.css("opacity",start.opacity);}},onComplete:function(){if(callback!==undefined)callback.call(obj);}});return false;},unbind:function(name,fun){$(label[0]).unbind(name,fun);return this;},bind:function(name,fn){$(label[0]).bind(name,fn);return this;},expand:expand,shrink:shrink,selected:function(){label.addClass("evri-selected");circle.attr(attributes);return false;},unselected:function(){label.removeClass("evri-selected");circle.attr(Evri.$.extend({},attributes,{"fill":"#FFFFFF"}));return false;}};}});Evri.defineClass(Evri.Widget.Components.Visualization,"Graph",function(paper,options){var self=this;options=options||{};self.analytics=options.analytics||new Evri.Widget.Analytics("VisualizationGraphComponent");var baconl=Evri.Widget.Components.Helpers.jQueryBaconl;self.paper=function(){return paper;}});Evri.extendClass(Evri.Widget.Components.Visualization.Graph,{render:function(entities,options){var self=this;var $=Evri.$;var defaults={centerX:self.paper().width()/2,centerY:self.paper().height()/2,centerRadius:30,connectionRadius:20,radius:100,radiusScaleX:1,radiusScaleY:1,arcAngle:360,arcAngleCenter:0};var returnValue={connections:[]};$.extend(defaults,options||{});if(entities.center!==undefined){returnValue.center=self.paper().nodeForEntity(defaults.centerX,defaults.centerY,defaults.centerRadius,entities.center);returnValue.center.label.addClass("evri-visualization-label-center");returnValue.center.center();returnValue.center.fadeIn();}
function calculateAngle(index){return entities.connections.length>1?(defaults.arcAngle/(entities.connections.length-1)*index+defaults.arcAngleCenter-defaults.arcAngle/2):defaults.arcAngleCenter;}
$.each(entities.connections||[],function(i,entity){var angle=calculateAngle(i);var x=Math.cos(Math.PI/180*angle)*defaults.radius*defaults.radiusScaleX;var y=Math.sin(Math.PI/180*angle)*defaults.radius*defaults.radiusScaleY;self.paper().paper.path({stroke:"#FCA240","stroke-width":4}).moveTo(defaults.centerX,defaults.centerY).lineTo(x+defaults.centerX,y+defaults.centerY);var n=self.paper().nodeForEntity(x+defaults.centerX,y+defaults.centerY,defaults.connectionRadius,entity);n.fadeIn();n.label.addClass("evri-visualization-label-circumference");returnValue.connections.push(n);n.unselected();});if(entities.center!==undefined){returnValue.center.circle.toFront();returnValue.center.unselected();}
return returnValue;}});Evri.defineClass(Evri.Widget.Components.Visualization,"List",function(paper){var self=this;var nodes=[];self.paper=function(){return paper;}
self.nodes=function(n){if(!n){return nodes;}
nodes=n;return self;}});Evri.extendClass(Evri.Widget.Components.Visualization.List,{setEntitiesByRows:function(entities,opts){var options=Evri.$.extend({radius:25,maxCols:5},opts||{});var self=this;var currentRow=0;var w=self.paper().width();var h=self.paper().height();var nodeOffset=options.radius+3;var horizontalExternalRadius=(nodeOffset+13)*1.7;var verticalExternalRadius=(nodeOffset+10)*1.5;var matrix=[];while(entities.length>0){matrix.push(entities.slice(0,options.maxCols-currentRow%2));var entities=entities.slice(options.maxCols-currentRow%2);currentRow++;}
var verticalMargin=(h-matrix.length*verticalExternalRadius)/2;var nodes=[]
Evri.$.each(matrix,function(row,entityList){var horizontalMargin=(w-entityList.length*horizontalExternalRadius)/2;Evri.$.each(entityList,function(col,entity){var x=col*horizontalExternalRadius+nodeOffset+horizontalMargin;var y=row*verticalExternalRadius+nodeOffset+verticalMargin;var node=self.paper().nodeForEntity(x,y,options.radius,entity);node.fadeIn();nodes.push(node);});});self.nodes(nodes);return nodes;}});Evri.defineClass(Evri.Widget.Components.Visualization,"Orbiting",function(paper,options){var self=this;var nodes=[];var selected;var nodesPositions={};options=Evri.$.extend({center:{x:paper.width()/2,y:paper.height()/2},radius:25,circleRadius:40,arcAngle:360,arcAngleBegin:0,selectedAngle:0},options);self.positionFor=function(href,angle){if(angle===undefined){return nodesPositions[href];}
nodesPositions[href]={angle:angle,distance:self.options().circleRadius};return self;}
self.paper=function(){return paper;}
self.selected=function(s){if(!arguments.length){return selected;}
selected&&selected.label.removeClass("evri-selected-node");selected=s;selected&&selected.label.addClass("evri-selected-node");s?self.select():self.deselect();return self;}
self.select=function(callb){callb?paper.wrapper.bind("node-selected",callb):paper.wrapper.triggerHandler("node-selected",self.selected());return self;}
self.deselect=function(callb){callb?paper.wrapper.bind("node-deselected",callb):paper.wrapper.triggerHandler("node-deselected");return self;}
self.nodes=function(n){if(!n){return nodes;}
nodes=n;return self;}
self.options=function(o){if(!o){return options;}
Evri.$.extend(options,o);return self;}})
Evri.extendClass(Evri.Widget.Components.Visualization.Orbiting,{coordinatesFor:function(href){var pos=this.positionFor(href);return{x:Math.cos(pos.angle)*pos.distance+this.options().center.x,y:Math.sin(pos.angle)*pos.distance+this.options().center.y}},toggleNode:function(n){this.selected()!==n?this.selectNode(n):this.deselectNode();},deselectNode:function(callb){var self=this;var selection=self.selected();selection.unselected();selection?selection.circle.animate({r:self.options().radius},200,function(){callb&&callb();}):(callb&&callb());self.selected(undefined);return self},selectNode:function(n,callb){var self=this;var sel=self.selected();if(sel===n)return self;if(sel){sel.unselected();sel.circle.animate({r:self.options().radius},100);}
var r=self.options().circleRadius;var start={x:n.circle.attr("cx")-self.options().center.x,y:n.circle.attr("cy")-self.options().center.y};var end={x:r,y:0};var e=end.x,a=start.x,b=start.y;var f=end.y,c=start.y,d=-1*start.x;var determinant=a*d-b*c;var cos=(e*d-b*f)/determinant;var sin=(a*f-e*c)/determinant;var a=self.positionFor(n.entity.href).angle;function animation(){n.circle.animate({r:n.circle.attr("r")*1.3},200,function(){callb&&callb();});}
self.selected()?self.selected().circle.animate({r:self.options().radius},200,animation):animation();self.selected(n);n.selected();return self;},setEntitiesRadially:function(entities,opts){var self=this;self.options(opts||{});var options=self.options();var circleCenter=self.options().center;var angleBetweenNodes=(Math.PI/180)*(options.arcAngle/entities.length);var nodes=[];Evri.$.each(entities,function(i,entity){var startingAngle=angleBetweenNodes*i+(Math.PI/180)*options.arcAngleBegin;self.positionFor(entity.href,startingAngle);var pos=self.coordinatesFor(entity.href);var n=self.paper().nodeForEntity(pos.x,pos.y,options.radius,entity);n.fadeIn();n.unselected();nodes.push(n);});self.nodes(nodes);self.refreshNodes();return nodes;},refreshNodes:function(callb){var self=this;Evri.$.each(this.nodes(),function(i,node){var pos=self.coordinatesFor(this.entity.href)
this.circle.animate({cx:pos.x,cy:pos.y},200);this.label.css("margin-left",-1*this.label.outerWidth()/2).css("margin-top",-1*this.label.outerHeight()/2).animate({left:pos.x,top:pos.y},200,function(){i===0&&callb&&callb();});});},rotateByArc:function(angle,callb){var self=this;var circleCenter=self.options().center;var r=self.options().circleRadius;Evri.$.each(this.nodes(),function(i){var a=self.positionFor(this.entity.href).angle;self.positionFor(this.entity.href,a+angle);});self.refreshNodes(callb);return self;}});Evri.defineNamespace(Evri,'Flash');Evri.extendNamespace(Evri.Flash,{swfobject:function(){var UNDEF="undefined",OBJECT="object",SHOCKWAVE_FLASH="Shockwave Flash",SHOCKWAVE_FLASH_AX="ShockwaveFlash.ShockwaveFlash",FLASH_MIME_TYPE="application/x-shockwave-flash",EXPRESS_INSTALL_ID="SWFObjectExprInst",win=window,doc=document,nav=navigator,domLoadFnArr=[],regObjArr=[],objIdArr=[],listenersArr=[],script,timer=null,storedAltContent=null,storedAltContentId=null,isDomLoaded=false,isExpressInstallActive=false;var ua=function(){var w3cdom=typeof doc.getElementById!=UNDEF&&typeof doc.getElementsByTagName!=UNDEF&&typeof doc.createElement!=UNDEF,playerVersion=[0,0,0],d=null;if(typeof nav.plugins!=UNDEF&&typeof nav.plugins[SHOCKWAVE_FLASH]==OBJECT){d=nav.plugins[SHOCKWAVE_FLASH].description;if(d&&!(typeof nav.mimeTypes!=UNDEF&&nav.mimeTypes[FLASH_MIME_TYPE]&&!nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)){d=d.replace(/^.*\s+(\S+\s+\S+$)/,"$1");playerVersion[0]=parseInt(d.replace(/^(.*)\..*$/,"$1"),10);playerVersion[1]=parseInt(d.replace(/^.*\.(.*)\s.*$/,"$1"),10);playerVersion[2]=/r/.test(d)?parseInt(d.replace(/^.*r(.*)$/,"$1"),10):0;}}
else if(typeof win.ActiveXObject!=UNDEF){var a=null,fp6Crash=false;try{a=new ActiveXObject(SHOCKWAVE_FLASH_AX+".7");}
catch(e){try{a=new ActiveXObject(SHOCKWAVE_FLASH_AX+".6");playerVersion=[6,0,21];a.AllowScriptAccess="always";}
catch(e){if(playerVersion[0]==6){fp6Crash=true;}}
if(!fp6Crash){try{a=new ActiveXObject(SHOCKWAVE_FLASH_AX);}
catch(e){}}}
if(!fp6Crash&&a){try{d=a.GetVariable("$version");if(d){d=d.split(" ")[1].split(",");playerVersion=[parseInt(d[0],10),parseInt(d[1],10),parseInt(d[2],10)];}}
catch(e){}}}
var u=nav.userAgent.toLowerCase(),p=nav.platform.toLowerCase(),webkit=/webkit/.test(u)?parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,ie=(/msie/.test(u)&&!/opera/.test(u)),windows=p?/win/.test(p):/win/.test(u),mac=p?/mac/.test(p):/mac/.test(u);return{w3cdom:w3cdom,pv:playerVersion,webkit:webkit,ie:ie,win:windows,mac:mac};}();var onDomLoad=function(){if(!ua.w3cdom){return;}
addDomLoadEvent(main);if(ua.ie&&ua.win){try{doc.write("<scr"+"ipt id=__ie_ondomload defer=true src=//:></scr"+"ipt>");script=getElementById("__ie_ondomload");if(script){addListener(script,"onreadystatechange",checkReadyState);}}
catch(e){}}
if(ua.webkit&&typeof doc.readyState!=UNDEF){timer=setInterval(function(){if(/loaded|complete/.test(doc.readyState)){callDomLoadFunctions();}},10);}
if(typeof doc.addEventListener!=UNDEF){doc.addEventListener("DOMContentLoaded",callDomLoadFunctions,null);}
addLoadEvent(callDomLoadFunctions);}();function checkReadyState(){if(script.readyState=="complete"){if(script.parentNode){script.parentNode.removeChild(script);}
callDomLoadFunctions();}}
function callDomLoadFunctions(){if(isDomLoaded){return;}
if(ua.ie&&ua.win){var s=createElement("span");try{var t=doc.getElementsByTagName("body")[0].appendChild(s);t.parentNode.removeChild(t);}
catch(e){return;}}
isDomLoaded=true;if(timer){clearInterval(timer);timer=null;}
var dl=domLoadFnArr.length;for(var i=0;i<dl;i++){domLoadFnArr[i]();}}
function addDomLoadEvent(fn,forceLoad){forceLoad=!!forceLoad;if(isDomLoaded||forceLoad){fn();}
else{domLoadFnArr[domLoadFnArr.length]=fn;}}
function addLoadEvent(fn){if(typeof win.addEventListener!=UNDEF){win.addEventListener("load",fn,false);}
else if(typeof doc.addEventListener!=UNDEF){doc.addEventListener("load",fn,false);}
else if(typeof win.attachEvent!=UNDEF){addListener(win,"onload",fn);}
else if(typeof win.onload=="function"){var fnOld=win.onload;win.onload=function(){fnOld();fn();};}
else{win.onload=fn;}}
function main(){var rl=regObjArr.length;for(var i=0;i<rl;i++){var id=regObjArr[i].id;if(ua.pv[0]>0){var obj=getElementById(id);if(obj){regObjArr[i].width=obj.getAttribute("width")?obj.getAttribute("width"):"0";regObjArr[i].height=obj.getAttribute("height")?obj.getAttribute("height"):"0";if(hasPlayerVersion(regObjArr[i].swfVersion)){if(ua.webkit&&ua.webkit<312){fixParams(obj);}
setVisibility(id,true);}
else if(regObjArr[i].expressInstall&&!isExpressInstallActive&&hasPlayerVersion("6.0.65")&&(ua.win||ua.mac)){showExpressInstall(regObjArr[i]);}
else{displayAltContent(obj);}}}
else{setVisibility(id,true);}}}
function fixParams(obj){var nestedObj=obj.getElementsByTagName(OBJECT)[0];if(nestedObj){var e=createElement("embed"),a=nestedObj.attributes;if(a){var al=a.length;for(var i=0;i<al;i++){if(a[i].nodeName=="DATA"){e.setAttribute("src",a[i].nodeValue);}
else{e.setAttribute(a[i].nodeName,a[i].nodeValue);}}}
var c=nestedObj.childNodes;if(c){var cl=c.length;for(var j=0;j<cl;j++){if(c[j].nodeType==1&&c[j].nodeName=="PARAM"){e.setAttribute(c[j].getAttribute("name"),c[j].getAttribute("value"));}}}
obj.parentNode.replaceChild(e,obj);}}
function showExpressInstall(regObj){isExpressInstallActive=true;var obj=getElementById(regObj.id);if(obj){if(regObj.altContentId){var ac=getElementById(regObj.altContentId);if(ac){storedAltContent=ac;storedAltContentId=regObj.altContentId;}}
else{storedAltContent=abstractAltContent(obj);}
if(!(/%$/.test(regObj.width))&&parseInt(regObj.width,10)<310){regObj.width="310";}
if(!(/%$/.test(regObj.height))&&parseInt(regObj.height,10)<137){regObj.height="137";}
doc.title=doc.title.slice(0,47)+" - Flash Player Installation";var pt=ua.ie&&ua.win?"ActiveX":"PlugIn",dt=doc.title,fv="MMredirectURL="+win.location+"&MMplayerType="+pt+"&MMdoctitle="+dt,replaceId=regObj.id;if(ua.ie&&ua.win&&obj.readyState!=4){var newObj=createElement("div");replaceId+="SWFObjectNew";newObj.setAttribute("id",replaceId);obj.parentNode.insertBefore(newObj,obj);obj.style.display="none";var fn=function(){obj.parentNode.removeChild(obj);};addListener(win,"onload",fn);}
createSWF({data:regObj.expressInstall,id:EXPRESS_INSTALL_ID,width:regObj.width,height:regObj.height},{flashvars:fv},replaceId);}}
function displayAltContent(obj){if(ua.ie&&ua.win&&obj.readyState!=4){var el=createElement("div");obj.parentNode.insertBefore(el,obj);el.parentNode.replaceChild(abstractAltContent(obj),el);obj.style.display="none";var fn=function(){obj.parentNode.removeChild(obj);};addListener(win,"onload",fn);}
else{obj.parentNode.replaceChild(abstractAltContent(obj),obj);}}
function abstractAltContent(obj){var ac=createElement("div");if(ua.win&&ua.ie){ac.innerHTML=obj.innerHTML;}
else{var nestedObj=obj.getElementsByTagName(OBJECT)[0];if(nestedObj){var c=nestedObj.childNodes;if(c){var cl=c.length;for(var i=0;i<cl;i++){if(!(c[i].nodeType==1&&c[i].nodeName=="PARAM")&&!(c[i].nodeType==8)){ac.appendChild(c[i].cloneNode(true));}}}}}
return ac;}
function createSWF(attObj,parObj,id){var r,el=getElementById(id);if(el){if(typeof attObj.id==UNDEF){attObj.id=id;}
if(ua.ie&&ua.win){var att="";for(var i in attObj){if(attObj[i]!=Object.prototype[i]){if(i.toLowerCase()=="data"){parObj.movie=attObj[i];}
else if(i.toLowerCase()=="styleclass"){att+=' class="'+attObj[i]+'"';}
else if(i.toLowerCase()!="classid"){att+=' '+i+'="'+attObj[i]+'"';}}}
var par="";for(var j in parObj){if(parObj[j]!=Object.prototype[j]){par+='<param name="'+j+'" value="'+parObj[j]+'" />';}}
el.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+att+'>'+par+'</object>';objIdArr[objIdArr.length]=attObj.id;r=getElementById(attObj.id);}
else if(ua.webkit&&ua.webkit<312){var e=createElement("embed");e.setAttribute("type",FLASH_MIME_TYPE);for(var k in attObj){if(attObj[k]!=Object.prototype[k]){if(k.toLowerCase()=="data"){e.setAttribute("src",attObj[k]);}
else if(k.toLowerCase()=="styleclass"){e.setAttribute("class",attObj[k]);}
else if(k.toLowerCase()!="classid"){e.setAttribute(k,attObj[k]);}}}
for(var l in parObj){if(parObj[l]!=Object.prototype[l]){if(l.toLowerCase()!="movie"){e.setAttribute(l,parObj[l]);}}}
el.parentNode.replaceChild(e,el);r=e;}
else{var o=createElement(OBJECT);o.setAttribute("type",FLASH_MIME_TYPE);for(var m in attObj){if(attObj[m]!=Object.prototype[m]){if(m.toLowerCase()=="styleclass"){o.setAttribute("class",attObj[m]);}
else if(m.toLowerCase()!="classid"){o.setAttribute(m,attObj[m]);}}}
for(var n in parObj){if(parObj[n]!=Object.prototype[n]&&n.toLowerCase()!="movie"){createObjParam(o,n,parObj[n]);}}
el.parentNode.replaceChild(o,el);r=o;}}
return r;}
function createObjParam(el,pName,pValue){var p=createElement("param");p.setAttribute("name",pName);p.setAttribute("value",pValue);el.appendChild(p);}
function removeSWF(id){var obj=getElementById(id);if(obj&&(obj.nodeName=="OBJECT"||obj.nodeName=="EMBED")){if(ua.ie&&ua.win){if(obj.readyState==4){removeObjectInIE(id);}
else{win.attachEvent("onload",function(){removeObjectInIE(id);});}}
else{obj.parentNode.removeChild(obj);}}}
function removeObjectInIE(id){var obj=getElementById(id);if(obj){for(var i in obj){if(typeof obj[i]=="function"){obj[i]=null;}}
obj.parentNode.removeChild(obj);}}
function getElementById(id){var el=null;try{el=doc.getElementById(id);}
catch(e){}
return el;}
function createElement(el){return doc.createElement(el);}
function addListener(target,eventType,fn){target.attachEvent(eventType,fn);listenersArr[listenersArr.length]=[target,eventType,fn];}
function hasPlayerVersion(rv){var pv=ua.pv,v=rv.split(".");v[0]=parseInt(v[0],10);v[1]=parseInt(v[1],10)||0;v[2]=parseInt(v[2],10)||0;return(pv[0]>v[0]||(pv[0]==v[0]&&pv[1]>v[1])||(pv[0]==v[0]&&pv[1]==v[1]&&pv[2]>=v[2]))?true:false;}
function createCSS(sel,decl){if(ua.ie&&ua.mac){return;}
var h=doc.getElementsByTagName("head")[0],s=createElement("style");s.setAttribute("type","text/css");s.setAttribute("media","screen");if(!(ua.ie&&ua.win)&&typeof doc.createTextNode!=UNDEF){s.appendChild(doc.createTextNode(sel+" {"+decl+"}"));}
h.appendChild(s);if(ua.ie&&ua.win&&typeof doc.styleSheets!=UNDEF&&doc.styleSheets.length>0){var ls=doc.styleSheets[doc.styleSheets.length-1];if(typeof ls.addRule==OBJECT){ls.addRule(sel,decl);}}}
function setVisibility(id,isVisible){var v=isVisible?"visible":"hidden";if(isDomLoaded&&getElementById(id)){getElementById(id).style.visibility=v;}
else{createCSS("#"+id,"visibility:"+v);}}
function urlEncodeIfNecessary(s){var regex=/[\\\"<>\.;]/;var hasBadChars=regex.exec(s)!=null;return hasBadChars?encodeURIComponent(s):s;}
var cleanup=function(){if(ua.ie&&ua.win){window.attachEvent("onunload",function(){var ll=listenersArr.length;for(var i=0;i<ll;i++){listenersArr[i][0].detachEvent(listenersArr[i][1],listenersArr[i][2]);}
var il=objIdArr.length;for(var j=0;j<il;j++){removeSWF(objIdArr[j]);}
for(var k in ua){ua[k]=null;}
ua=null;for(var l in Evri.Flash.swfobject){Evri.Flash.swfobject[l]=null;}
Evri.Flash.swfobject=null;});}}();return{registerObject:function(objectIdStr,swfVersionStr,xiSwfUrlStr){if(!ua.w3cdom||!objectIdStr||!swfVersionStr){return;}
var regObj={};regObj.id=objectIdStr;regObj.swfVersion=swfVersionStr;regObj.expressInstall=xiSwfUrlStr?xiSwfUrlStr:false;regObjArr[regObjArr.length]=regObj;setVisibility(objectIdStr,false);},getObjectById:function(objectIdStr){var r=null;if(ua.w3cdom){var o=getElementById(objectIdStr);if(o){var n=o.getElementsByTagName(OBJECT)[0];if(!n||(n&&typeof o.SetVariable!=UNDEF)){r=o;}
else if(typeof n.SetVariable!=UNDEF){r=n;}}}
return r;},embedSWF:function(swfUrlStr,replaceElemIdStr,widthStr,heightStr,swfVersionStr,xiSwfUrlStr,flashvarsObj,parObj,attObj,forceLoad){forceLoad=!!forceLoad;if(!ua.w3cdom||!swfUrlStr||!replaceElemIdStr||!widthStr||!heightStr||!swfVersionStr){return;}
widthStr+="";heightStr+="";if(hasPlayerVersion(swfVersionStr)){setVisibility(replaceElemIdStr,false);var att={};if(attObj&&typeof attObj===OBJECT){for(var i in attObj){if(attObj[i]!=Object.prototype[i]){att[i]=attObj[i];}}}
att.data=swfUrlStr;att.width=widthStr;att.height=heightStr;var par={};if(parObj&&typeof parObj===OBJECT){for(var j in parObj){if(parObj[j]!=Object.prototype[j]){par[j]=parObj[j];}}}
if(flashvarsObj&&typeof flashvarsObj===OBJECT){for(var k in flashvarsObj){if(flashvarsObj[k]!=Object.prototype[k]){if(typeof par.flashvars!=UNDEF){par.flashvars+="&"+k+"="+flashvarsObj[k];}
else{par.flashvars=k+"="+flashvarsObj[k];}}}}
addDomLoadEvent(function(){createSWF(att,par,replaceElemIdStr);if(att.id==replaceElemIdStr){setVisibility(replaceElemIdStr,true);}},forceLoad);}
else if(xiSwfUrlStr&&!isExpressInstallActive&&hasPlayerVersion("6.0.65")&&(ua.win||ua.mac)){isExpressInstallActive=true;setVisibility(replaceElemIdStr,false);addDomLoadEvent(function(){var regObj={};regObj.id=regObj.altContentId=replaceElemIdStr;regObj.width=widthStr;regObj.height=heightStr;regObj.expressInstall=xiSwfUrlStr;showExpressInstall(regObj);});}},getFlashPlayerVersion:function(){return{major:ua.pv[0],minor:ua.pv[1],release:ua.pv[2]};},hasFlashPlayerVersion:hasPlayerVersion,createSWF:function(attObj,parObj,replaceElemIdStr){if(ua.w3cdom){return createSWF(attObj,parObj,replaceElemIdStr);}
else{return undefined;}},removeSWF:function(objElemIdStr){if(ua.w3cdom){removeSWF(objElemIdStr);}},createCSS:function(sel,decl){if(ua.w3cdom){createCSS(sel,decl);}},addDomLoadEvent:addDomLoadEvent,addLoadEvent:addLoadEvent,getQueryParamValue:function(param){var q=doc.location.search||doc.location.hash;if(param==null){return urlEncodeIfNecessary(q);}
if(q){var pairs=q.substring(1).split("&");for(var i=0;i<pairs.length;i++){if(pairs[i].substring(0,pairs[i].indexOf("="))==param){return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=")+1)));}}}
return"";},expressInstallCallback:function(){if(isExpressInstallActive&&storedAltContent){var obj=getElementById(EXPRESS_INSTALL_ID);if(obj){obj.parentNode.replaceChild(storedAltContent,obj);if(storedAltContentId){setVisibility(storedAltContentId,true);if(ua.ie&&ua.win){storedAltContent.style.display="block";}}
storedAltContent=null;storedAltContentId=null;isExpressInstallActive=false;}}}};}()});Evri.defineClass(Evri.Widget,"VerticalSingleEntity",function(entityURI,options){var self=this;self.$=Evri.$;self.entityURI=entityURI;self.initialize(options);});Evri.extendClass(Evri.Widget.VerticalSingleEntity,{contentviews:"evri-articles evri-images evri-videos evri-profiles",defaultSourceConstraints:[{label:"The web",includeDomains:[]}],Helpers:Evri.Widget.Components.Helpers,Components:Evri.Widget.Components,appId:"evri-singleentity",analyticsTrackingId:"verticalSingleEntity",MINIMUM_WIDTH:160,MAXIMUM_WIDTH:320,CONNECTION_GRAPH_REQUIRED_WIDTH:240,TWEETS_TAB_REQUIRED_WIDTH:200,THUMBNAIL_MAX_WIDTH:120,THUMBNAIL_MAX_HEIGHT:90,GRAPH_ENTITIES_COUNT:5,CONNECTION_GRAPH_MIN_VIEW_WIDTH:260,CONNECTION_GRAPH_MIN_VIEW_CENTER_RADIUS:25,CONNECTION_GRAPH_MIN_VIEW_NODE_RADIUS:18,CONNECTION_GRAPH_MIN_VIEW_LABEL_MAX_WIDTH:40,MAC_TAB_SCROLLBAR_REQUIRED_WIDTH:250,isGraphView:true,isMultiSubjectView:false,showVideoImagesHorizontally:true,showTweetsHorizontally:true,showEntityProfilesAvatar:true,initialize:function(options){var self=this;self.defaults={height:500,width:320,stylesheet:Evri.API.Environment.staticAssetBaseUrl+"/stylesheets/VerticalSingleEntity.1.css",imagesHost:Evri.API.Environment.staticAssetBaseUrl+"/images/VerticalSingleEntity/"};self.graphProperties={arcAngleCenter:-90,centerX:159,radius:77,radiusScaleY:0.80,radiusScaleX:1.2,centerRadius:30,connectionRadius:20,labelMaxWidth:70,labelMinWidth:40};var mainEntityFacetContainer=self.$("<div/>").addClass("entity-facet-container");var graphWrapper=self.$("<div/>").addClass("component-graph");graphWrapper.append(self.$("<p/>").addClass("evri-see-full-profile"));self.Session=new Evri.API.Session({"appId":self.appId});self.widgetUtilities=Evri.Widget.Helper;self.analytics=self.widgetUtilities.createAnalytics(self.analyticsTrackingId);self.analytics.trackDHTML("Instantiate");self.$.extend(self,self.$("<div/>").addClass("evri-entity-widget-container").addClass("evri-component"));self.$.extend(self.defaults,options||{});self.widgetUtilities.loadStyleSheet(self.defaults.stylesheet);self.contentWrapper=self.widgetUtilities.createContentWrapper(self.analytics);self.append(mainEntityFacetContainer,graphWrapper,self.contentWrapper);self.width(self.defaults.width);self.entityDetailsList={};self.setupArticles();self.currentModel=self.widgetUtilities.accessor(function(obj){if(self.is(".evri-articles")){self.widgetUtilities.closeVideoPlayer(self);self.articlesFor(obj,self);}
if(self.is(".evri-tweets")){self.widgetUtilities.closeVideoPlayer(self);self.tweetsFor(obj,self);}
if(self.is(".evri-images")){self.widgetUtilities.closeVideoPlayer(self);self.imagesFor(obj,self);}
if(self.is(".evri-videos")){self.videosFor(obj,self);}
if(self.is(".evri-profiles")){self.widgetUtilities.closeVideoPlayer(self);self.profilesFor(obj,self);}});self.mediaSet=self.initMediaSet();self.resetMediaSet();self.setupTweets();self.setupImages();self.setupVideos();self.setupProfiles();self.contentWrapper.selectTab(0);},setupArticles:function(){var self=this;var articles=self.widgetUtilities.addTabContent(self.contentWrapper,"News",self.$("<div/>").addClass("evri-articles-view"),function(){self.removeClass(self.contentviews).addClass("evri-articles");if(self.currentModel){self.currentModel(self.currentModel());}});},setupTweets:function(){var self=this;var tweets=self.widgetUtilities.addTabContent(self.contentWrapper,"Tweets",self.widgetUtilities.initTweets(),function(){self.removeClass(self.contentviews).addClass("evri-tweets");self.currentModel(self.currentModel());}).find(".evri-media-viewport");self.tweetsFor=self.widgetUtilities.createTweetsUpdateFunction(tweets,self.analytics);},setupImages:function(){var self=this;var images=self.widgetUtilities.addTabContent(self.contentWrapper,"Images",self.widgetUtilities.initImages(),function(){self.removeClass(self.contentviews).addClass("evri-images");self.currentModel(self.currentModel());}).find("a.attribution").bind("click.analytics",function(){self.analytics.trackReferral("Images/Yahoo");}).end().find(".evri-media-viewport");self.imagesFor=self.widgetUtilities.createImagesUpdateFunction(images,self.analytics);},setupVideos:function(){var self=this;var videos=self.widgetUtilities.addTabContent(self.contentWrapper,"Videos",self.widgetUtilities.initVideos(self.analytics),function(){self.removeClass(self.contentviews).addClass("evri-videos");self.currentModel(self.currentModel());}).find(".evri-media-viewport");self.videosFor=self.widgetUtilities.createVideosUpdateFunction(videos,self.analytics);},setupProfiles:function(){var self=this;var profiles=self.widgetUtilities.addTabContent(self.contentWrapper,"Profiles",self.widgetUtilities.initProfiles(self.analytics),function(){self.removeClass(self.contentviews).addClass("evri-profiles");self.currentModel(self.currentModel());}).find(".evri-media-viewport");self.profilesFor=self.widgetUtilities.createProfilesUpdateFunction(profiles,self.analytics);},initMediaSet:function(){var self=this;var ms=new Evri.Widget.MediaViewSet(this.Session);ms.clear();self.$.each(this.defaultSourceConstraints,function(i,sc){var defaultView=ms.addView(sc.label);self.$.each(sc.includeDomains,function(index,site){defaultView.includeDomain(site);});});return ms;},resetMediaSet:function(){var tabView=this.find("div.evri-articles-view");var articlesView=new Evri.Widget.Components.SourceConstrainedArticles();articlesView.setMediaSet(this.mediaSet);tabView.empty().append(articlesView);articlesView.find(".component-tab:first").addClass("component-tab-selected");this.articlesTabs=articlesView;if(this.currentModel()){this.articlesFor(this.currentModel());}},articlesFor:function(model){this.articlesTabs.articlesFor(model);},render:function(widgetContainerId){var self=this;self.initializeWidget(widgetContainerId,self.$(document.body));self.getEntityByResource(self.entityURI);var queryParams=Evri.API.Utilities.toQueryString({"entity_uri":self.entityURI});var options={widgetName:"Single_Subject",queryParams:queryParams};self.widgetUtilities.createWidgetFooter(self,options);},initializeWidget:function(widgetContainerId,widgetParent){var self=this;var container=self.$(widgetContainerId);if(container.length===0){container=self.$("<div/>").attr("id",widgetContainerId).css("background-color","#FFFFFF");if(self.isMultiSubjectView){widgetParent.before(container);}else{widgetParent.append(container);}}
container.empty();var widgetWrapperWidth=container.width();if(self.isMultiSubjectView){widgetWrapperWidth+=2;}
self.configureWidget(widgetWrapperWidth);self.$(container).append(self.widgetUtilities.namespace(self));var isMacFireFox=self.$.browser.macFirefox();var addTabScrollButton=false;if(!isMacFireFox&&widgetWrapperWidth<self.CONNECTION_GRAPH_REQUIRED_WIDTH){addTabScrollButton=true;}else if(isMacFireFox&&widgetWrapperWidth<self.MAC_TAB_SCROLLBAR_REQUIRED_WIDTH){addTabScrollButton=true;}
if(addTabScrollButton){self.find(".evri-entity-widget-tabs").addClass("narrow-view-widget-tabs");self.addTabScrollbarButton();}},configureWidget:function(widgetWrapperWidth){var self=this;if(widgetWrapperWidth<self.MINIMUM_WIDTH){widgetWrapperWidth=self.MINIMUM_WIDTH;}else if(widgetWrapperWidth>self.MAXIMUM_WIDTH){widgetWrapperWidth=self.MAXIMUM_WIDTH;}
self.width(widgetWrapperWidth-2);if(widgetWrapperWidth<269){self.showVideoImagesHorizontally=false;}
if(widgetWrapperWidth<self.CONNECTION_GRAPH_REQUIRED_WIDTH){self.isGraphView=false;self.addClass("narrow-view-entity-widget-container");self.find(".component-graph").addClass("narrow-view-component-graph");self.find(".entity-facet-container").addClass("narrow-view-entity-facet-container");self.showEntityProfilesAvatar=false;}else{widgetWrapperWidth-=2;self.graphProperties.centerX=widgetWrapperWidth/2;if(widgetWrapperWidth<=self.CONNECTION_GRAPH_MIN_VIEW_WIDTH){self.graphProperties.centerRadius=self.CONNECTION_GRAPH_MIN_VIEW_CENTER_RADIUS;self.graphProperties.connectionRadius=self.CONNECTION_GRAPH_MIN_VIEW_NODE_RADIUS;self.graphProperties.labelMaxWidth=self.CONNECTION_GRAPH_MIN_VIEW_LABEL_MAX_WIDTH;}}},getEntityByResource:function(entityURI){var self=this;var callback=arguments.callee;var args=arguments;self.Session.models.Entity.findByResource(entityURI,{onComplete:function(entityDetail){self.renderEntityDetails(entityDetail);},onFailure:function(error){self.widgetUtilities.renderErrorMessage("evri-articles-view",self.widgetUtilities.createErrorHandler(function(){callback.apply(self,args);return false;}),self);}});},renderEntityDetails:function(entity){var self=this;self.entityDetailsList[self.entityURI]=entity;self.currentModel(entity);self.getRecentConnectionsForEntity(entity);var entityContainer=self.find("div.entity-facet-container");self.widgetUtilities.renderEntityFacets(entityContainer,entity);},createWidgetContainerId:function(entityURI){var self=this;entityURI=entityURI.replace(/\W/g,'-');return"evri-miniedp-container-div"+entityURI;},getRecentConnectionsForEntity:function(entity){var self=this;var callback=arguments.callee;var args=arguments;self.widgetUtilities.renderMessage("component-graph",self.widgetUtilities.LOADING_MESSAGE,self);entity.getTopRelationsTargets({onComplete:function(targetList){var recentConnectionsList=[];for(var cntr=0;cntr<targetList.targets.length;cntr++){var recentEntity=targetList.targets[cntr].entity;recentConnectionsList.push(recentEntity);}
if(self.isGraphView){self.setGlobalGraph(entity,recentConnectionsList);}else{self.widgetUtilities.renderRecentConnectionsTextView(self,entity,recentConnectionsList);}
self.find("div.get-this-widget-container").removeClass("disabled-link");},onFailure:function(error){self.widgetUtilities.renderErrorMessage("component-graph",self.widgetUtilities.createErrorHandler(function(){callback.apply(self,args);}),self);self.find("div.get-this-widget-container").removeClass("disabled-link");}},{count:25,entityConstraint:self.entityConstraint});},setGlobalGraph:function(mainEntity,entities){var self=this;if(entities&&entities.length>0){self.initVisualization(mainEntity,entities);}else{self.widgetUtilities.renderMessage("component-graph","No entities found",self);}},initVisualization:function(mainEntity,entities){var self=this;var knowEntitiesList=[];var count=0;self.$.each(entities,function(i,entity){if(entity.known){count++;if(count>self.GRAPH_ENTITIES_COUNT){return;}
knowEntitiesList.push(entity);}});var visualization=self.initCanvas();var centerNode=visualization.render({center:mainEntity},self.graphProperties);var graphNodes=visualization.render({connections:knowEntitiesList},self.$.extend({arcAngle:knowEntitiesList.length*36},self.graphProperties));centerNode.center.circle.toFront();centerNode.center.selected();self.createProfileLinks(mainEntity);self.styleLabel(centerNode.center,"center");self.bindNodesEvent(centerNode.center,graphNodes.connections,-1);},bindNodesEvent:function(centerNode,nodes,index){var self=this;self.$.each(nodes,function(i,node){if(index!==i){self.styleLabel(node,"circumference");node.bind("mouseover",node.selected);node.bind("mouseout",node.unselected);node.bind("mouseover",node.expand);node.bind("mouseout",node.shrink);node.unselected();node.bind("click",function(){self.styleLabel(node,"center");node.selected();node.unbind("click");node.unbind("mouseout");var entityPair=new self.Session.models.Pair(centerNode.entity,node.entity);self.currentModel(entityPair);self.createProfileLinks(centerNode.entity,node.entity);centerNode.bind("click",function(){centerNode.unbind("click");self.currentModel(centerNode.entity);self.createProfileLinks(centerNode.entity);self.bindNodesEvent(centerNode,nodes,-1);});self.bindNodesEvent(centerNode,nodes,i);});}});},initCanvas:function(){var self=this;var graphCanvas=new Evri.Widget.Components.Visualization.Canvas(self.width(),200);self.find("div.component-graph").html(graphCanvas.wrapper);var visualization=new Evri.Widget.Components.Visualization.Graph(graphCanvas);return visualization;},createProfileLinks:function(entity1,entity2){var self=this;var profilesLinksContainer=self.find("p.evri-see-full-profile").empty();if(profilesLinksContainer.length===0){profilesLinksContainer=self.$("<p/>").addClass("evri-see-full-profile");self.find("div.component-graph").append(profilesLinksContainer);}
function entityLink(e,type){var entityProfileLink=self.$("<a/>");entityProfileLink.text(e.name).attr({"title":"More about "+e.name+" at Evri.com","target":"_blank"}).bind("click.analytics",function(){self.analytics.trackReferral("VerticalSingleEntity/GraphBreadcrumb/EDP/"+type);});return entityProfileLink;}
profilesLinksContainer.append("More about: ");var mainEntityLink=entityLink(entity1,"Source");mainEntityLink.attr("href",entity1.portalURI);profilesLinksContainer.append(mainEntityLink);if(entity2!==undefined){profilesLinksContainer.append(", ");var relatedEntityLink=entityLink(entity2,"Target");var referringEntityURI=entity2.portalURI+"&referring_entity_uri="+entity1.href;relatedEntityLink.attr("href",referringEntityURI);profilesLinksContainer.append(relatedEntityLink);}},styleLabel:function(node,position){var self=this;var maxWidth=self.graphProperties.labelMaxWidth;var minWidth=self.graphProperties.labelMinWidth;var label=node.label;function showPreview(){if(position==="center"){if(label.outerHeight()>42){label.height(42);}}else if(label.is(":not(.evri-current)")){label.find("div.evri-truncated").show();label.find("div.evri-expanded").hide();}
node.center();}
function showFull(){if(position==="center"){label.height("auto");}else{label.find("div.evri-truncated").hide();label.find("div.evri-expanded").show();}
node.center();}
label.css({height:"auto",padding:"0 2px",border:"1px solid #AAA","line-height":"14px","overflow":"hidden","font":"11px Arial"});if(position==="center"){label.children(".evri-truncated").hide();if(label.outerWidth()>maxWidth){label.width(maxWidth);label.find(".evri-truncated").width(maxWidth);label.addClass("evri-label-needs-truncation");}else if(label.outerWidth()<minWidth){label.width(minWidth);label.addClass("evri-label-needs-expansion");}}else{if(label.outerWidth()>maxWidth){label.width(maxWidth);label.find(".evri-truncated").width(maxWidth);label.addClass("evri-label-needs-truncation");}else if(label.outerWidth()<minWidth){label.width(minWidth);label.addClass("evri-label-needs-expansion");}}
label.hover(showFull,showPreview);showPreview();},renderSingleSubjectWidget:function(options){var self=this;self.isMultiSubjectView=true;self.MAXIMUM_WIDTH=options.widgetMaxWidth;self.mediaSet=options.mediaSet;self.resetMediaSet();self.initializeWidget(options.singleWidgetContainerId,options.widgetParentContainer);self.renderEntityDetails(options.entity);},addTabScrollbarButton:function(){var self=this;var tabsWrapper=self.$("<div/>").addClass("tabs-list-wrapper");tabsWrapper.width(self.width()-30);var tabList=self.find(".evri-entity-widget-tabs-list");tabsWrapper.html(tabList);self.contentWrapper.prepend(tabsWrapper);tabList=self.find(".evri-entity-widget-tabs-list");var buttons=Evri.Widget.Components.Helpers.makeHorizontalCarousel(tabList);self.find("div.evri-entity-widget-tabs").prepend(buttons.left);self.find("div.evri-entity-widget-tabs").append(buttons.right);}});Evri.defineClass(Evri.Widget,"Instantiation",function(parentObject,options){var self=this;self.$=Evri.$;self.parentObject=parentObject;self.imagesPath=Evri.API.Environment.staticAssetBaseUrl+"/images/";self.componentClass=options.componentClass||self.componentClass;var widgetCodeContainer=self.$('<div/>').addClass(self.componentClass);if(options.widgetWidth){widgetCodeContainer.width(options.widgetWidth);}
self.parentObject.append(widgetCodeContainer);var widgetInstantiationSourceUrl={"Gamera":"http://"+Evri.API.Environment.portalHost+"/widget_utilities/instantiation_code/gamera?callback=?","Jirafa":"http://"+Evri.API.Environment.portalHost+"/widget_utilities/instantiation_code/jirafa?all&callback=?","Single_Subject":"http://"+Evri.API.Environment.portalHost+"/widget_utilities/instantiation_code/single_subject"+options.queryParams+"&callback=?","Multi_Subject":"http://"+Evri.API.Environment.portalHost+"/widget_utilities/instantiation_code/multi_subject?callback=?","Quotes":"http://"+Evri.API.Environment.portalHost+"/widget_utilities/instantiation_code/quotes"+options.queryParams+"&callback=?","Twitter":"http://"+Evri.API.Environment.portalHost+"/widget_utilities/instantiation_code/twitter"+options.queryParams+"&callback=?","Sentiment":"http://"+Evri.API.Environment.portalHost+"/widget_utilities/instantiation_code/sentiment"+options.queryParams+"&callback=?"};self.WEB_BLOG_DESCRIPTION='Copy the code below and paste it into your web page or blog:';self.WORDPRESS_DESCRIPTION='Copy the code below and paste it into your WordPress blog:';self.BLOGGER_DESCRIPTION='Click the "Add Evri Widget" button to bring up the Blogger installer page:';self.TYPEPAD_DESCRIPTION='Click the "Add Evri Widget" button to bring up the TypePad installer page:';self.$.extend(self,widgetCodeContainer);self.widgetInstantiationSourceUrl=widgetInstantiationSourceUrl[options.widgetName];return self;});Evri.extendClass(Evri.Widget.Instantiation,{componentClass:"evri-widget-installation-script-container",initializeGetThisWidget:function(buttonsParent,buttonsContainerClass,callBeforeGetWidgetLoad){var self=this;self.addGetWidgetButton(buttonsParent,buttonsContainerClass,callBeforeGetWidgetLoad);},renderWidgetInstantiationContainer:function(widgetInstallationScript){var self=this;self.empty();var widgetCodeDescriptionDiv=self.$('<div/>').addClass('evri-widget-installation-script-description');widgetCodeDescriptionDiv.html(self.getWidgetCodeDescription());var tabContainerDiv=self.getTabContainer(widgetInstallationScript);self.append(widgetCodeDescriptionDiv,tabContainerDiv);self.selectTab(0);},getWidgetCodeDescription:function(){var text='Pick the blogging platform you use,or pick "&lt;/&gt;" to put this widget anywhere javascript is allowed.<br><br>Want to get a widget about something else? We have even more widgets <a target="_new" href="http://www.evri.com/partners-and-bloggers.html">here</a>.';return text;},getTabContainer:function(widgetInstallationScript){var self=this;var tabsUL=self.$('<ul/>').addClass('evri-widget-installation-script-tabs');var tabsContainer=self.$('<div/>').addClass('evri-tabs-container');var tabLi=self.addTab('tab_1_contents','logo.code.gif');tabLi.addClass('evri-active-tab');tabsUL.append(tabLi);tabsUL.append(self.addTab('tab_2_contents','logo.blogger.gif'));tabsUL.append(self.addTab('tab_3_contents','logo.tp.gif'));tabsUL.append(self.addTab('tab_4_contents','logo.wp.gif'));var clearDiv=self.$('<div/>').addClass('evri-widget-tab-clear');var tabContentsContainer=self.$('<div/>').addClass('evri-tab-contents-container');for(var tabCntr=1;tabCntr<5;tabCntr++){var tabContents=self.$('<div/>').addClass('evri-tab-contents tab_'+tabCntr+'_contents');self.getTabContent(tabCntr,tabContents,widgetInstallationScript);tabContentsContainer.append(tabContents);}
tabsContainer.append(tabsUL,clearDiv,tabContentsContainer);return tabsContainer;},getTabContent:function(tabIndex,tabContents,widgetInstallationScript){var self=this;switch(tabIndex){case 1:self.setWebContent(tabContents,widgetInstallationScript,self.WEB_BLOG_DESCRIPTION);break;case 2:self.setBlogContent(tabContents,widgetInstallationScript,self.BLOGGER_DESCRIPTION,true);break;case 3:self.setBlogContent(tabContents,widgetInstallationScript,self.TYPEPAD_DESCRIPTION,false);break;case 4:self.setWebContent(tabContents,widgetInstallationScript,self.WORDPRESS_DESCRIPTION);break;}},addTab:function(linkRel,imageSrc){var self=this;self.$=Evri.$;var img=self.$('<img/>').attr('src',self.imagesPath+imageSrc);var tabLink=self.$('<a/>').addClass('evri-multientity-tab').attr({'href':'javascript:void(0);','rel':linkRel}).click(function(){self.find('.evri-widget-installation-script-tabs li').removeClass('evri-active-tab');self.$(this).parent().addClass('evri-active-tab');self.find('.evri-tab-contents-active').removeClass('evri-tab-contents-active');var tabContentsContainer=self.find('.'+linkRel).addClass('evri-tab-contents-active');var textArea=tabContentsContainer.find(".evri-widget-installation-script-textarea");if(textArea.length>0){textArea.height(self.height()-textArea.position().top-10);}
self.find("div.add-evri-widget-div").css('visibility','hidden');tabContentsContainer.find("div.add-evri-widget-div").css({'visibility':'visible','display':'block'});}).append(img);var tabLi=self.$('<li/>').append(tabLink);return tabLi;},setWebContent:function(tabContentsContainer,widgetInstallationScript,description){var self=this;var descriptionDiv=self.$('<div/>').addClass('evri-widget-javascript-code-description').text(description);var widgetCode=widgetInstallationScript.find('.any-web-page-form-container').text();var codeDiv=self.$('<textarea/>').attr("readonly","true").addClass('evri-widget-installation-script-textarea').css('width',self.width()-20).text(widgetCode).click(function(){this.select();});var codeDivContainer=self.$('<div/>').append(codeDiv);tabContentsContainer.append(descriptionDiv,codeDivContainer);},setBlogContent:function(tabContentsContainer,widgetInstallationScript,description,isBlogger){var self=this;var descriptionDiv=self.$('<div/>').addClass('evri-widget-javascript-code-description').text(description);var addEvriWidgetDiv=self.$('<div/>').addClass('add-evri-widget-div');var blogInstallationButton=self.$('<a/>').attr('href','javascript:void(0);').addClass('blog-installation-button').css({'background':"url("+self.imagesPath+'add-ongray.gif) right bottom no-repeat'}).hover(function(){self.$(this).css("background-position","right top");},function(){self.$(this).css("background-position","right bottom");});blogInstallationButton.click(function(){var bloggerForm=self.$(tabContentsContainer).find('.widget-installer');bloggerForm.submit();return false;});addEvriWidgetDiv.append(blogInstallationButton);var form=undefined;if(isBlogger){form=widgetInstallationScript.find('.blogger-form-container');}else{form=widgetInstallationScript.find('.typepad-form-container');}
tabContentsContainer.append(descriptionDiv,addEvriWidgetDiv,form);},selectTab:function(index){var self=this;var activeTab=self.find('.evri-multientity-tab').eq(index);if(activeTab.length>0){activeTab.trigger("click");}
return false;},showHide:function(buttonsContainerClass){var self=this;if(self.parentObject.find("."+buttonsContainerClass).length>0){self.css({'height':self.parentObject.find("."+buttonsContainerClass).position().top});}else{self.css({'height':self.parentObject.height()-2});}
self.find("div.add-evri-widget-div").hide();self.toggle();},addGetWidgetButton:function(buttonsParent,buttonsContainerClass,callBeforeGetWidgetLoad){var self=this;var buttonCss={"background-color":"#fff","position":"relative","cursor":"pointer","border":"none","float":"right","width":"93px","height":"11px"};var getButton=self.$('<a/>').css(buttonCss).css("background","url("+self.imagesPath+"get-ongray.gif) right bottom no-repeat");buttonCss.width="39px";var backButton=self.$('<a/>').css(buttonCss).css("background","url("+self.imagesPath+"back-ongray.gif) right bottom no-repeat").hide();getButton.click(function(e){if(callBeforeGetWidgetLoad){callBeforeGetWidgetLoad.call();}
if(!self.$(this).parent().hasClass("disabled-link")){buttonsParent.find("a").toggle();self.showHide(buttonsContainerClass);if(self.find(".evri-widget-installation-script-textarea").length==0){self.renderLoadingMessage();self.$.getJSON(self.widgetInstantiationSourceUrl,function(data){if(self.parentObject.afterWidgetInstallationScriptLoad){data=self.parentObject.afterWidgetInstallationScriptLoad(data);}
self.renderWidgetInstantiationContainer(self.$(data));});}else{self.selectTab(0);}}});getButton.hover(function(){self.$(this).css("background-position","right top");},function(){self.$(this).css("background-position","right bottom");});backButton.click(function(e){buttonsParent.find("a").toggle();self.showHide(buttonsContainerClass);});backButton.hover(function(){self.$(this).css("background-position","right top");},function(){self.$(this).css("background-position","right bottom");});buttonsParent.append(getButton,backButton);},renderLoadingMessage:function(){var self=this;var messageContainer=self.$("<div/>").addClass("evri-info-message").addClass("centered").html(self.$("<p/>").addClass("evri-loading-message").text("... loading ..."));self.empty();self.append(messageContainer);var mainContainerHeight=self.height();var messageContainerHeight=messageContainer.height();var top=((mainContainerHeight-messageContainerHeight)/2);messageContainer.css("top",top);}});Evri.defineNamespace(Evri.Widget,"Helper");Evri.extendNamespace(Evri.Widget.Helper,{$:Evri.$,LOADING_MESSAGE:"... loading ...",namespace:function(widget,footer){var self=this;var browser="";if(self.$.browser.msie&&!self.$.browser.msie8){browser="msie";}
if(self.$.browser.mozilla){if(self.$.browser.macFirefox()){browser=navigator.userAgent.match(/Firefox\/3/)?"firefox firefox3 mac-firefox":"firefox firefox2 mac-firefox";}else{browser=navigator.userAgent.match(/Firefox\/3/)?"firefox firefox3":"firefox firefox2";}}
if(self.$.browser.safari){browser="safari";}
var widgetWrapper=self.$("<div/>").attr("id","evri").append(widget);if(footer){widgetWrapper.append(footer);}
return self.$("<div/>").attr("id","evri").addClass(browser).append(self.$("<div/>").attr("id","evri").append(self.$("<div/>").attr("id","evri").append(widgetWrapper)));},loadStyleSheet:function(stylesheetURL){var self=this;self.$("<link/>").attr("href",stylesheetURL).attr("rel","stylesheet").appendTo("head");},createAnalytics:function(analyticsTrackingId){var self=this;var analytics=new Evri.Widget.Analytics(analyticsTrackingId);return analytics;},accessor:function(callback){var objectToLoad;return function(object){if(!object){return objectToLoad;}
objectToLoad=object;callback.call(this,objectToLoad);};},addTabContent:function(tabsWrapper,tabName,tabContentsWrapper,clickCallback){tabsWrapper.addTab(tabName,tabContentsWrapper).addClass("evri-tab-"+tabName.toLowerCase());tabsWrapper.children("ul").find("li:last").bind("click",clickCallback);return tabContentsWrapper;},initTweets:function(){var self=this;var tweetsView=self.$("<div/>").addClass("evri-tweets-view");tweetsView.append(self.$("<div/>").addClass("evri-media-viewport"));return tweetsView;},initImages:function(){var self=this;var imagesView=self.$("<div/>").addClass("evri-images-view");imagesView.append(self.$("<div/>").addClass("evri-media-attribution").html("Images from <a class='attribution' href='http://www.yahoo.com'>Yahoo!</a>"),self.$("<div/>").addClass("evri-media-viewport"));return imagesView;},initVideos:function(analytics){var self=this;var ytlink=self.$("<a/>").addClass("attribution");ytlink.bind("click.analytics",function(){analytics.trackReferral("Videos/YouTube");}).attr("href","http://www.youtube.com").append(self.$("<span/>").addClass("yt-attribution-black").text("You"),self.$("<span/>").addClass("yt-attribution-white").text("Tube"));var videosView=self.$("<div/>").addClass("evri-videos-view");videosView.append(self.$("<div/>").addClass("evri-media-attribution").append("Videos from ",ytlink),self.$("<div/>").addClass("evri-media-viewport"));return videosView;},initProfiles:function(){var self=this;var profilesView=self.$("<div/>").addClass("evri-profiles-view");profilesView.append(self.$("<div/>").addClass("evri-media-viewport"));return profilesView;},createErrorHandler:function(callback){var self=this;var errorMessage="There was an error loading this section.";var container=self.$("<div/>").addClass("evri-info-message").addClass("centered");container.append(self.$("<p/>").text(errorMessage),self.$("<a/>").text("Click here to try again").click(callback));return container;},renderErrorMessage:function(wrapperClass,errorContainer,widget){var self=this;var wrapper=widget.find("."+wrapperClass);wrapper.find("div.viewport").empty();wrapper.find("div.evri-info-message").remove();wrapper.append(errorContainer);var wrapperHeight=wrapper.height();var errorContainerHeight=errorContainer.height();var top=((wrapperHeight-errorContainerHeight)/2);errorContainer.css("top",top);},createTweetsUpdateFunction:function(tweetsWrapper,analytics){var utilities=this;var currentModel;return function(model,widget){var callback=arguments.callee;var args=arguments;var self=this;if(currentModel===model){return;}
currentModel=model;utilities.renderMessage("evri-tweets-view",utilities.LOADING_MESSAGE,widget);var entitiesList=[];if(currentModel.klass&&currentModel.klass==="Pair"){entitiesList.push(currentModel.entity1);entitiesList.push(currentModel.entity2);}else{entitiesList.push(currentModel);}
var totalEntity=entitiesList.length;var tweetsLoaded=0;var tweets=[];var tweetsForEntities={};Evri.$.each(entitiesList,function(i,entity){widget.Session.models.Tweet.findForEntityResource(entity.href,{onComplete:function(tweetList){tweetsLoaded++;tweetsForEntities[entity.href]=tweetList;Evri.$.merge(tweets,tweetList.tweets);if(tweetsLoaded===totalEntity){utilities.renderTweets(widget,tweetsWrapper,tweets,tweetsForEntities,analytics);}},onFailure:function(error){tweetsLoaded++;if(totalEntity>1&&tweetsLoaded===totalEntity){utilities.renderTweets(widget,tweetsWrapper,tweets,tweetsForEntities,analytics);}else{currentModel=undefined;utilities.renderErrorMessage("evri-tweets-view",utilities.createErrorHandler(function(){callback.apply(self,args);}),widget);}}});});};},createImagesUpdateFunction:function(imagesWrapper,analytics){var utilities=this;var currentModel;return function(model,widget){var callback=arguments.callee;var args=arguments;var self=this;if(currentModel===model){return;}
currentModel=model;utilities.renderMessage("evri-images-view",utilities.LOADING_MESSAGE,widget);model.media.getImages({onComplete:function(imagesList){utilities.renderImages(imagesWrapper,imagesList,widget,analytics);},onFailure:function(){currentModel=undefined;utilities.renderErrorMessage("evri-images-view",utilities.createErrorHandler(function(){callback.apply(self,args);}),widget);}});};},createVideosUpdateFunction:function(videosWrapper,analytics){var currentModel;var utilities=this;return function(model,widget){var callback=arguments.callee;var args=arguments;var self=this;if(currentModel===model){return;}
currentModel=model;utilities.closeVideoPlayer(widget);utilities.renderMessage("evri-videos-view",utilities.LOADING_MESSAGE,widget);model.media.getVideos({onComplete:function(videosList){utilities.renderVideos(videosWrapper,videosList,widget,analytics);},onFailure:function(){currentModel=undefined;utilities.renderErrorMessage("evri-videos-view",utilities.createErrorHandler(function(){callback.apply(self,args);}),widget);}});};},createProfilesUpdateFunction:function(profilesWrapper,analytics){var currentModel;var self=this;return function(model,widget){if(currentModel===model){return;}
self.renderMessage("evri-profiles-view",self.LOADING_MESSAGE,widget);currentModel=model;var profilesEntityList=new Array();if(currentModel.klass&&currentModel.klass==="Pair"){profilesEntityList.push(currentModel.entity1);widget.Session.models.Entity.findByResource(currentModel.entity2.href,{onComplete:function(entityDetail){profilesEntityList.push(entityDetail);self.renderProfiles(profilesWrapper,profilesEntityList,widget,analytics);},onFailure:function(error){self.renderProfiles(profilesWrapper,profilesEntityList,widget,analytics);}});}else{self.$.each(widget.entityDetailsList,function(i,entity){profilesEntityList.push(entity);});self.renderProfiles(profilesWrapper,profilesEntityList,widget,analytics);}};},renderProfiles:function(profilesWrapper,profilesEntityList,widget,analytics){var self=this;var Components=Evri.Widget.Components;var profilesList=new Components.ProfilesListColumns({analytics:analytics});widget.find("div.evri-profiles-view").find("div.evri-info-message").remove();profilesWrapper.html(profilesList);if(profilesEntityList&&profilesEntityList.length===1){profilesEntityList[0].showCompleteDescription=true;}
profilesList.setProfiles(profilesEntityList,widget.showEntityProfilesAvatar);},renderTweets:function(widget,tweetsWrapper,tweets,tweetsForEntities,analytics){var self=this;var tweetsListColumns=new Evri.Widget.Components.TweetsListColumns({analytics:analytics});tweetsWrapper.html(tweetsListColumns);self.$("div.evri-tweets-view").find("div.evri-info-message").remove();tweetsListColumns.setTweets(tweets,tweetsForEntities);var viewPortWidth=self.$("div.tweets").find("div.viewport").width();if(widget.showTweetsHorizontally){tweetsListColumns.find("li").each(function(i){var imageContainerWidth=self.$(this).find(".tweet-image:visible").width();if(imageContainerWidth){var availableWidth=viewPortWidth-imageContainerWidth-10;self.$(this).find(".tweet-top").width(availableWidth);self.$(this).find(".tweet-bottom").width(availableWidth);}});}else{self.$("div.tweets").find("div.viewport").addClass("narrow-view");}},renderImages:function(imagesWrapper,imagesList,widget,analytics){var self=this;if(imagesList.images.length===0){self.renderMessage("evri-images-view","No images found",widget);return;}
var Components=Evri.Widget.Components;var columns=1;if(widget.showVideoImagesHorizontally){columns=2;}
var imagesColumns=new Components.ImagesListColumns({columns:columns,analytics:analytics});imagesWrapper.html(imagesColumns);self.$("div.evri-images-view").find("div.evri-info-message").remove();imagesColumns.setImages(imagesList);var thumbnailContainers=imagesColumns.find("li a");thumbnailContainers.append(self.$("<div/>").addClass("hover-image"));thumbnailContainers.hover(function(){self.$(this).addClass("hover");},function(){self.$(this).removeClass("hover");});var maxWidth=widget.THUMBNAIL_MAX_WIDTH-2;var maxHeight=widget.THUMBNAIL_MAX_HEIGHT-2;self.resizeThumbnail(imagesColumns,maxWidth,maxHeight);thumbnailContainers.each(function(i){self.createImageDescription(imagesList.images[i],self.$(this),widget.showVideoImagesHorizontally,i);});if(self.$.browser.msie6){imagesColumns.find("li").each(function(i){self.$(this).height(self.$(this).height());});}else{imagesColumns.find("li").append(self.$("<div/>").addClass("clear"));}},renderVideos:function(videosWrapper,videosList,widget,analytics){var self=this;if(videosList.videos.length===0){self.renderMessage("evri-videos-view","No videos found",widget);return;}
var Components=Evri.Widget.Components;var videosColumns=new Components.VideosListColumns({columns:1,analytics:analytics});videosWrapper.html(videosColumns);widget.find("div.evri-videos-view").find("div.evri-info-message").remove();videosColumns.setVideos(videosList);var thumbnailContainers=videosColumns.find("li a");thumbnailContainers.each(function(i){var video=videosList.videos[i];self.$(this).attr("title",video.title).click(function(){self.appendVideoPlayer(self.$(this),self.$(this).parent(),video,widget);return false;}).addClass("thumbnail-contents");if(widget.showVideoImagesHorizontally){self.$(this).css("float","left");}else{self.$(this).addClass("narrow-view-video-title");}});var maxWidth=widget.THUMBNAIL_MAX_WIDTH-2;var maxHeight=widget.THUMBNAIL_MAX_HEIGHT-2;self.resizeThumbnail(videosColumns,maxWidth,maxHeight);videosColumns.find("li").each(function(i){var video=videosList.videos[i];var thumbnail=video.thumbnails[0];var videoTitle=video.title;var source="";var videoDuration=self.getVideoTime(video);source=video.getSourceUrl();if(source&&source!==""){source=source.match(/:\/\/(.[^/]+)/)[1];}
var descriptionContainer=self.$("<div/>").addClass("video-description-container");descriptionContainer.append(self.$("<a/>").addClass("video-title").text(videoTitle),self.$("<span/>").addClass("video-duration").text(videoDuration),self.$("<span/>").addClass("video-source").text(source));if(widget.showVideoImagesHorizontally){descriptionContainer.css("float","right").width(parseInt(self.$(this).parent().width(),10)-130);}else{descriptionContainer.css("margin","4px 0 0");}
self.$(this).append(descriptionContainer);});if(self.$.browser.msie6){videosColumns.find("li").each(function(i){self.$(this).height(self.$(this).height());});}else{videosColumns.find("li").append(self.$("<div/>").addClass("clear"));}},getVideoTime:function(video){var videoDuration="";var totalSeconds=video.duration;var hours=0;hours=Math.floor(totalSeconds/360);totalSeconds=totalSeconds%360;var minutes=0;if(totalSeconds>60){minutes=Math.floor(totalSeconds/60);totalSeconds=totalSeconds%60;}
var seconds=totalSeconds;if(hours<10){hours="0"+hours;}
if(minutes<10){minutes="0"+minutes;}
if(seconds<10){seconds="0"+seconds;}
if(hours>0){videoDuration=hours+"."+minutes+"."+seconds+" minutes";}else{videoDuration=minutes+"."+seconds+" minutes";}
return videoDuration;},createImageDescription:function(imageObject,thumbnailContainer,showVideoImagesHorizontally,index){var self=this;var container=self.$("<div/>").addClass("thumbnail-container");if(showVideoImagesHorizontally){var viewPortWidth=self.$("div.images").find("div.viewport").width();viewPortWidth=Math.floor((viewPortWidth-4)/2);container.width(viewPortWidth);if(index%2===1){container.css("float","right");}}
thumbnailContainer.width("118px").height("88px").attr("title",imageObject.title).addClass("thumbnail-contents");thumbnailContainer.parent().append(container);var truncatedTitle=imageObject.title;truncatedTitle=self.trimLongText(truncatedTitle,15,{"line-height":"11px","font-size":"11px","font-weight":"normal","width":container.width()-10});var thumbnailDescription=self.$("<span/>").addClass("thumbnail-description");thumbnailDescription.attr({"title":imageObject.title}).text(truncatedTitle);container.append(thumbnailContainer,thumbnailDescription);},appendVideoPlayer:function(thumbnailContainer,thumbnailContainerParent,video,widget){var self=this;var randomId="widgetVideoPlayer"+(new Date()).getTime();var youtubeURL=video.url+"&enablejsapi=1";var wrapper=self.$("<div/>").addClass("video-player-wrapper");var player=self.$("<div/>").addClass("video-player").attr("id",randomId);var videosViewArea=widget.find("div.evri-videos-view");var videoDescriptionContainer=self.$(thumbnailContainerParent).find("div.video-description-container").clone();videoDescriptionContainer.css({"width":"auto","margin":"0 8px 8px 8px","float":"left"});var truncatedTitle=self.trimLongText(video.title,15,{"line-height":"11px","font-size":"11px","font-weight":"normal","width":videosViewArea.width()-20});videoDescriptionContainer.find("a.video-title").text(truncatedTitle).attr("title",video.title);var videoToolbar=self.getVideoToolbar(wrapper,widget);wrapper.hide().appendTo(thumbnailContainer).append(videoToolbar,player,videoDescriptionContainer).fadeIn();wrapper.height(videosViewArea.height());Evri.Flash.swfobject.embedSWF(youtubeURL,randomId,videosViewArea.width()-16,150,"8",null,null,{allowScriptAccess:"always"},{"class":"video-player"},true);videosViewArea.append(wrapper);},getVideoToolbar:function(wrapper,widget){var self=this;var videoToolbar=self.$("<div/>").addClass("evri-video-toolbar");var videoPlayerBackButton=self.$("<a/>").addClass("evri-back-button").css("background","transparent url( "+widget.defaults.imagesHost+"/back-ongray.gif) no-repeat scroll left bottom");videoPlayerBackButton.click(function(){wrapper.fadeOut(function(){wrapper.remove();});return false;});videoPlayerBackButton.hover(function(){self.$(this).css("background-position","left top");},function(){self.$(this).css("background-position","left bottom");});videoToolbar.append(videoPlayerBackButton);return videoToolbar;},closeVideoPlayer:function(widget){var self=this;widget.find("div.video-player-wrapper").fadeOut(function(){widget.find("div.video-player-wrapper").remove();});},resizeThumbnail:function(thumbnailsContainer,maxWidth,maxHeight){var self=this;thumbnailsContainer.find("img").load(function(){var thumbnail=self.$(this);var thumbnailWidth=thumbnail.width();if(thumbnail.width()>maxWidth){thumbnail.width(maxWidth);thumbnail.css("height","auto");while(thumbnail.height()>maxHeight){thumbnailWidth--;thumbnail.width(thumbnailWidth);}}else if(thumbnail.height()>maxHeight){var thumbnailHeight=thumbnail.height();thumbnail.height(maxHeight);thumbnail.css("width","auto");while(thumbnail.width()>maxWidth){thumbnailHeight--;thumbnail.height(thumbnailHeight);}}
thumbnailHeight=thumbnail.height();if(thumbnailHeight<maxHeight){var marginTop=(maxHeight-thumbnailHeight)/2;thumbnail.css("margin-top",marginTop);}});},createContentWrapper:function(analytics){var tabs=new Evri.Widget.Components.Tabs({analytics:analytics});tabs.addClass("evri-entity-widget-tabs").children("ul").addClass("evri-entity-widget-tabs-list").end().find(".component-tabs-view").addClass("component-global-view");return tabs;},renderEntityFacets:function(entityContainer,entity){var self=this;var facets=self.getFacets(entity);var entityTruncateLength=Math.floor(entityContainer.width()*10/100);var facetsTruncateLength=Math.floor(entityContainer.width()*10/100);var entityNameLength=entityTruncateLength;var entityFacetsLength=facetsTruncateLength;if(entity.name.length<entityTruncateLength){entityTruncateLength=entity.name.length;facetsTruncateLength+=(entityNameLength-entityTruncateLength);}
if(facets.length<entityFacetsLength){facetsTruncateLength=facets.length;entityTruncateLength+=(entityFacetsLength-facetsTruncateLength);}
var entityNameContainer=self.$("<a/>");entityNameContainer.attr({"href":entity.portalURI,"title":entity.name,"target":"_blank"}).text(self.truncateString(entity.name,entityTruncateLength));var facetContainer=self.$("<span/>");facetContainer.addClass("facets").text(self.truncateString(facets,facetsTruncateLength)).attr("title",facets);entityContainer.append(entityNameContainer,facetContainer);},getFacets:function(entity){var facets="";var self=this;if(entity.facets&&entity.facets.length!==0){var totalFacets=entity.facets.length;facets=" - ";self.$.each(entity.facets,function(index,facet){if(index===0){facets+=facet.name;}else if(index===totalFacets-1){facets+=" and "+facet.name;}else{facets+=", "+facet.name;}});}
return facets;},renderRecentConnectionsTextView:function(widget,mainEntity,relatedEntitiesList,selectedEntity){var self=this;var graphContainer=widget.find("div.component-graph").empty();var count=0;var entitiesContainer=graphContainer.find("ul.related-entities-container");if(entitiesContainer.length===1){entitiesContainer.empty();}else{entitiesContainer=self.$("<ul/>").addClass("related-entities-container");graphContainer.append(entitiesContainer);}
if(selectedEntity){self.bindBackArticleButton(widget,mainEntity,relatedEntitiesList,entitiesContainer);}else{entitiesContainer.append(self.$("<li/>").append(self.$("<span/>").text("Recent connections:").css("color","#8D8D8D")));}
self.$.each(relatedEntitiesList,function(index,entity){if(count>=widget.GRAPH_ENTITIES_COUNT){return false;}
if(entity.known){var entityNameContainer=self.createRecentConnectionProfileLinks(widget,mainEntity,entity,graphContainer);if(selectedEntity&&selectedEntity.href===entity.href){entitiesContainer.append(self.$("<li/>").append(entityNameContainer.addClass("selected-related-entity")));}else{entityNameContainer.addClass("related-entity-names");entityNameContainer.click(function(){self.closeVideoPlayer(widget);var entityPair=new widget.Session.models.Pair(mainEntity,entity);widget.currentModel(entityPair);self.renderRecentConnectionsTextView(widget,mainEntity,relatedEntitiesList,entity);return false;});entitiesContainer.append(self.$("<li/>").append(entityNameContainer));}
count++;}});},bindBackArticleButton:function(widget,mainEntity,relatedEntitiesList,container){var self=this;var backButton=self.$("<a/>").addClass("evri-back-button").css("background","transparent url( "+widget.defaults.imagesHost+"/back-ongray.gif) no-repeat scroll left bottom");backButton.click(function(){widget.currentModel(mainEntity);self.closeVideoPlayer(widget);self.renderRecentConnectionsTextView(widget,mainEntity,relatedEntitiesList);});backButton.hover(function(){self.$(this).css("background-position","left top");},function(){self.$(this).css("background-position","left bottom");});container.append(self.$("<li/>").append(backButton));},createRecentConnectionProfileLinks:function(widget,mainEntity,entity,graphContainer){var self=this;var truncatedEntityName=self.trimLongText(entity.name,16,{"line-height":"11px","font-size":"11px","font-weight":"normal","width":graphContainer.width()-40});var entityNameContainer=self.$("<a/>");entityNameContainer.attr({"title":entity.name}).text(truncatedEntityName);entityNameContainer.hover(function(){self.$(this).find("a").show();},function(){self.$(this).find("a").hide();});var profileButton=self.$("<a/>").addClass("evri-seefull-profile-button").css("background","transparent url( "+widget.defaults.imagesHost+"/evriarrow-ongray.gif) no-repeat scroll right bottom");profileButton.attr({"target":"_blank"});profileButton.click(function(){var referringEntityURI=entity.portalURI+"&referring_entity_uri="+mainEntity.href;window.open(referringEntityURI);return false;});profileButton.hover(function(){self.$(this).css("background-position","right top");},function(){self.$(this).css("background-position","right bottom");});entityNameContainer.append(profileButton);return entityNameContainer;},createWidgetFooter:function(widget,options){var self=this;var container=self.$("<div/>").addClass("entity-widget-footer");var evriLogo=self.$("<img/>").addClass("evri-logo");evriLogo.attr("src",Evri.API.Environment.staticAssetBaseUrl+"/images/widget.png");evriLogo.click(function(){window.open("http://www.evri.com");});var getThisWidgetContainer=self.$("<div/>");getThisWidgetContainer.addClass("get-this-widget-container").addClass("disabled-link");if(widget.width()<172){container.addClass("narrow-view-entity-widget-footer");}
widget.append(container.append(evriLogo,getThisWidgetContainer,self.$("<div/>").addClass("clear")));var callBeforeGetWidgetLoad=function(){var videoPlayerWrapper=widget.find("div.video-player-wrapper:visible");if(videoPlayerWrapper.length>0){self.$(this).attr("delay",700);self.closeVideoPlayer(widget);}else{self.$(this).attr("delay",0);}};var instantiation=new Evri.Widget.Instantiation(widget,options);instantiation.initializeGetThisWidget(getThisWidgetContainer,"entity-widget-footer",callBeforeGetWidgetLoad);},renderMessage:function(wrapperClass,message,widget){var self=this;var wrapper=widget.find("."+wrapperClass);var messageContainer=self.$("<div/>");messageContainer.addClass("evri-info-message").addClass("centered");messageContainer.html(self.$("<p/>").addClass("evri-loading-message").text(message));wrapper.find("div.viewport").empty();wrapper.find("div.evri-info-message").remove();wrapper.append(messageContainer);var wrapperHeight=wrapper.height();var messageContainerHeight=messageContainer.height();var top=((wrapperHeight-messageContainerHeight)/2);messageContainer.css("top",top);},trimLongText:function(text,heightAvailable,CSS){var self=this;if(self.$("#evri-ph-for-stringWidth").length===0){self.$(document.body).append(self.$("<div/>").attr("id","evri-ph-for-stringWidth").css({"visibility":"hidden","position":"absolute"}));}
var div=self.$("#evri-ph-for-stringWidth").css(CSS).empty();div.html(text);var initialHeight=div.get(0).offsetHeight;if(initialHeight<=heightAvailable){div.empty();return text;}else{for(var cntr=text.length;cntr>=0;cntr--){div.empty();var newText=text.substr(0,cntr);div.html(newText);var currentHeight=div.get(0).offsetHeight;if(currentHeight<=heightAvailable){div.empty();return self.removePartialWord(newText);}}}},removePartialWord:function(truncatedString){var self=this;var stringToTruncate=self.$.trim(truncatedString).replace(/(\s*\w*)$/,"...");if(stringToTruncate.length<4){stringToTruncate=self.$.trim(truncatedString)+"...";}
return stringToTruncate;},truncateString:function(stringToTruncate,lengthRequired){var self=this;if(stringToTruncate!==undefined&&stringToTruncate.length>lengthRequired){stringToTruncate=stringToTruncate.substr(0,lengthRequired)+"...";}
return stringToTruncate;}});