
function getStartLocationFromURL(){var curUrl=window.location.toString();var anchor_index=curUrl.indexOf('#/');if(anchor_index!=-1){return curUrl.substring(anchor_index+2);}else{return null;}}
function getUrlParameterByName(name){name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^&]*)";var regex=new RegExp(regexS);var results=regex.exec(window.location.href);if(results==null)
return"";else
return decodeURIComponent(results[1].replace(/\+/g," "));}
function raiseCommandEvent(commandName,params){var element=document.createElement("flexCommandEvent");element.setAttribute("commandName",commandName);for(var index in params){element.setAttribute(index,params[index]);}
document.documentElement.appendChild(element);var evt=document.createEvent("Events");evt.initEvent("flexCommandEvent",true,false);element.dispatchEvent(evt);}
function notifyLogin(){raiseCommandEvent("login");}
function notifyLogout(){raiseCommandEvent("logout");}
function notifyPearlDeleted(pearlUrl){var params=[];params['pearlUrl']=pearlUrl;raiseCommandEvent("pearlDeleted",params);}
function detectPearlbar(){raiseCommandEvent("detectPearlbar");raiseCommandEvent("getPearlbarVersion");}
function updateFirefoxAddon(addonTitle,addonURL,addonIcon){if(getOSName()=="Linux"){openNewPopup(getWebSiteUrl()+"collector/downloadProxy.html?url="+addonURL,300,100);}
else{openWindow(addonURL,"_top");}}
function callPearlbarCommand(commandName,param){getMainApplication().pearlbarCommand(commandName,param);}
function onPearlbarCommandEvent(event){var commandName=event.target.getAttribute("commandName");if(commandName=="pearlbarIsInstalled"){pearlbarIsInstalled=true;callPearlbarCommand("pearlbarIsInstalled");}
else if(commandName=="returnPearlbarVersion"){var value=event.target.getAttribute("value");callPearlbarCommand("setPearlbarVersion",value);}}
if(window.addEventListener){window.addEventListener("pearlbarCommandEvent",onPearlbarCommandEvent,false);}
else if(window.attachEvent){window.attachEvent("pearlbarCommandEvent",onPearlbarCommandEvent)}
function notifyNewAccountCreated(userId){if(self.location.hostname=="www.pearltrees.com"){if(pingbackUrl){(new Image).src=pingbackUrl+"&userId="+userId;}
if(_gaq){_gaq.push(['_setAllowAnchor',true]);_gaq.push(['_trackPageview']);_gaq.push(['_trackEvent','Home','Create Account',self.location.search]);}
var pearltreesPingBackUrl="http://piwik.pearltrees.com/piwik.php?url="+
escape(getServicesUrl()+"piwik/logAccountCreated/"+self.location.search)+"&action_name=create_account&idsite=1&title=create_account&urlref="+escape(document.referrer)+"&rec=1&rand="+Math.random();(new Image).src=pearltreesPingBackUrl;}}
function notifyUserHasDockedPearlWindow(userId){(new Image).src=getServicesUrl()+"check/userHasDockedPearlWindow/?userId="+userId;}
function getBrowserName(){return BrowserDetect.browser;}
function getOSName(){return BrowserDetect.OS;}
function getBrowserVersion(){return BrowserDetect.version;}
function getSessionID(){return readCookie('PEARLTREES-AUTH');}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function getUserLang(){return userLang;}
function createCookie(name,value,seconds){if(seconds){var date=new Date();date.setTime(date.getTime()+(seconds*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function eraseCookie(name){createCookie(name,"",-1);}
function hideWaitingPanel(){stopPreloader();getMainApplication().style.width='100%';getMainApplication().style.height='100%';document.getElementById('page').style.display='none';document.getElementById('page').innerHTML='';}
function onApplicationExit(){var app=getMainApplication();if(app&&app.onApplicationExit){app.onApplicationExit();}}
function getInvitationEmail(){return invitationEmail;}
function getInvitationKey(){return invitationKey;}
function getLostPasswordToken(){return lostPasswordToken;}
function getOrigin(){return origin;}
function getUserName(){return userName;}
function getUserId(){return userId;}
function getWebSiteUrl(){return webSiteUrl;}
function getStaticContentUrl(){return staticContentUrl;}
function getLogoUrl(){return logoUrl;}
function getAvatarUrl(){return avatarUrl;}
function getThumbshotUrl(){return thumbshotUrl;}
function getServicesUrl(){return servicesUrl;}
function getShortenerDomain(){return shortenerDomain;}
function getClientLang(){var urlParam=getUrlParameterByName("lang");if(urlParam){return urlParam;}else{return clientLang;}}
function getLoginUsername(){return loginUsername;}
function getStartTime(){return startTime;}
function getStartupMessage(){return startupMessage;}
function getPromoBigWindow(){return promoBigWindow;}
function getPromoLittleWindow(){return promoLittleWindow;}
function getArrivalTreeId(){return arrivalTreeId;}
function getPlayerStartUrl(){return startPlayerWithUrl;}
function changeParentUrl(parentUrl){top.location=parentUrl;}
function getInnerWidth(){var windowWidth=window.innerWidth;if(!windowWidth){windowWidth=document.documentElement.clientWidth;}
if(windowWidth<=0){windowWidth=document.body.clientWidth;}
return windowWidth;}
function getInnerHeight(){var windowHeight=window.innerHeight;if(!windowHeight){windowHeight=document.documentElement.clientHeight;}
if(windowHeight<=0){windowHeight=document.body.clientHeight;}
return windowHeight;}
function loadIFrame(frameID,iframeID,url){document.getElementById(iframeID).src=url;}
function sendStats(title){if(self.location.hostname!="www.pearltrees.com"){return;}
else if(self.location.href.indexOf("/#/embedWindow=1")!=-1){return;}
else if(noStats){if(self.location.href.indexOf("DP-n=tunnel")!=-1){noStats=false;}else{return;}}
if(_gaq){_gaq.push(['_setAllowAnchor',true]);_gaq.push(['_trackPageview']);}
(new Image).src="http://piwik.pearltrees.com/piwik.php?url="+
escape(window.location)+"&action_name="+escape(title)+"&idsite=1&title="+
escape(title)+"&urlref="+escape(document.referrer)+"&rec=1&rand="+Math.random();}
var isReloadingPage=false;function reloadPage(){if(!isReloadingPage){isReloadingPage=true;self.location.reload(true);}}
function getLocalLastSaveDate(){var lastSaveDate=readCookie("lastSaveDate");if(lastSaveDate==null){return 0;}
return lastSaveDate}
function setLocalLastSaveDate(lastSaveDate){createCookie("lastSaveDate",lastSaveDate,5);}
var prefetchFrameCounter=0;function loadPageInCache(url){var ff=false;var f=document.createElement("iframe");f.style.display="none";f.id="prefetchFrame"+(prefetchFrameCounter++);f.src=staticContentUrl+"s/prefetch/"+(ff?"link":"load")+"?url="+encodeURIComponent(url);f.onload=function(){pageInCacheLoaded(f.id);};document.body.appendChild(f);return f.id;}
function removePageInCache(id){var f=document.getElementById(id);if(f)document.body.removeChild(f);}
function pageInCacheLoaded(id){var app=getMainApplication();if(app&&app.onPageInCacheLoaded){app.onPageInCacheLoaded(id);}}
function testCookieEnabled(){var cookieEnabled=(navigator.cookieEnabled)?true:false
if(typeof navigator.cookieEnabled=="undefined"&&!cookieEnabled){document.cookie="testcookie"
cookieEnabled=(document.cookie.indexOf("testcookie")!=-1)?true:false}
return cookieEnabled;}
function getPotentialBadFrameId(){return readCookie("potentialBadFrameId");}
function savePotentialBadFrameId(lastPearlId){createCookie("potentialBadFrameId",lastPearlId,60);}
function openWindow(url,target){var newWin=window.open(url,target);return newWin&&!newWin.closed&&typeof newWin!='undefined'&&typeof newWin.closed!='undefined';}
function openNewPopup(url,width,height){var coordinates=getCenteredCoords(width,height);var newWin=window.open(url,"_blank","location=0,menubar=0,scrollbars=1,toolbar=0,resizable=1,status=0,directories=0,width="+width+",height="+height+",left="+coordinates[0]+",top="+coordinates[1]);return newWin&&!newWin.closed&&typeof newWin!='undefined'&&typeof newWin.closed!='undefined';}
var monitoredPopup;var intervalChecker;function openMonitoredPopup(url,width,height){var coordinates=getCenteredCoords(width,height);monitoredPopup=window.open(url,"monitoredPopup","location=0,menubar=0,scrollbars=1,toolbar=0,resizable=1,status=0,directories=0,"+"width="+width+",height="+height+",left="+coordinates[0]+",top="+coordinates[1]);if(isMonitoredPopupClosed()){return false;}
intervalChecker=window.setInterval(waitForPopupClose,80);return true;}
function closeMonitoredPopup(){if(monitoredPopup){monitoredPopup.close();if((null!==intervalChecker)){window.clearInterval(intervalChecker);intervalChecker=null;}}}
function isMonitoredPopupClosed(){try{return!monitoredPopup||monitoredPopup.closed||typeof monitoredPopup=='undefined'||typeof monitoredPopup.closed=='undefined';}
catch(err){return true;}}
function waitForPopupClose(){if(isMonitoredPopupClosed()){monitoredPopup=null;if(getMainApplication()){getMainApplication().onMonitoredPopupClose();}
if((null!==intervalChecker)){window.clearInterval(intervalChecker);intervalChecker=null;}}}
function getCenteredCoords(width,height){var parentSize=this.getWindowInnerSize();var parentPos=this.getParentCoords();var xPos=parentPos[0]+
Math.max(0,Math.floor((parentSize[0]-width)/2));var yPos=parentPos[1]+
Math.max(0,Math.floor((parentSize[1]-height)/2));return[xPos,yPos];}
function getWindowInnerSize(){var width=0;var height=0;var elem=null;if('innerWidth'in window){width=window.innerWidth;height=window.innerHeight;}else{if(('BackCompat'===window.document.compatMode)&&('body'in window.document)){elem=window.document.body;}else if('documentElement'in window.document){elem=window.document.documentElement;}
if(elem!==null){width=elem.offsetWidth;height=elem.offsetHeight;}}
return[width,height];}
function getParentCoords(){var width=0;var height=0;if('screenLeft'in window){width=window.screenLeft;height=window.screenTop;}else if('screenX'in window){width=window.screenX;height=window.screenY;}
return[width,height];}
