
Mundia.namespaces("controls");Mundia.controls.CountryLanguageSelector=new Class({Extends:Mundia.controls.Control,initialize:function(elementId){this.parent(elementId);},_attachEvents:function(){this.parent();if($('editLanguageLink')){$('editLanguageLink').addEvent('click',this._showLanguagePreferences.bind(this));}
if($('editCountryLink')){$('editCountryLink').addEvent('click',this._showLanguagePreferences.bind(this));}},_showLanguagePreferences:function(){$$('.defaultLanguagePreferences').addClass('hidden');$('selectCountryLanguageSettings1').removeClass('hidden');$('selectCountryLanguageSettings2').removeClass('hidden');$('editLanguageLink').addClass('hidden');}});
Mundia.namespaces("controls");Mundia.controls.SurnameHandler=new Class({Extends:Mundia.controls.Control,initialize:function(elementId){this.parent(elementId);this._defaultSearchText='';},_render:function(){this.parent();var element=this.get_element();if(element){if($hasValue(element.getElement('input[name=surname]').get('tgn:defaultvalue'))){this._defaultSearchText=element.getElement('input[name=surname]').get('tgn:defaultvalue');if($('enter-family')){$('enter-family').addEvent('click',function(event){event.stop();var target=$(event.target);value=target.get('value');if(value==this._defaultSearchText){target.set('value','');}}.bind(this));$('enter-family').addEvent('blur',function(event){event.stop();var target=$(event.target);value=target.get('value');if(!$hasValue(value)){target.set('value',this._defaultSearchText);return;}
value=value.replace(/\s/g,'');if(!$chk(value)){target.set('value',this._defaultSearchText);return;}}.bind(this));}
element.getElement('input[name=surname]').set('value',this._defaultSearchText);}}},_attachEvents:function(){this.parent();var element=this.get_element();if(element){element.addEvent('submit',this._searchForm_submit.bind(this));}},_searchForm_submit:function(event){event.stop();var target=$(event.target).getElement('a');var surname=this.get_element().getElement('input[name=surname]').get('value');if($hasValue(this._defaultSearchText)){if(surname.toLowerCase()==this._defaultSearchText.toLowerCase()){surname='';target.removeClass('disabled');return;}}
if(!$hasValue(surname)){target.removeClass('disabled');return;}
surname=surname.replace(/\s/g,'');if(!$chk(surname)){target.removeClass('disabled');return;}
path=Page.Url.correctPath(Page.properties.surnameBaseUrl);window.location=Mundia.WebContext.get_currentUrl()+path+Mundia.UrlUtility.encodeSurname(surname);}});
Mundia.namespaces("controls");Mundia.controls.PersonPopupSection=new Class({Extends:Mundia.controls.Control,initialize:function(elementId,templateElementId,viewDataKey,popupOffset)
{var ele1=$(elementId);if($(elementId))
{this.parent(elementId);this.HIDE_POPUP_DELAY=300;this.POPUP_OFFSET={x:7+popupOffset.x,y:-24+popupOffset.y};this.ARROW_OFFSET=15;this._viewDataKey=viewDataKey;this._templateElementId=templateElementId;this._hidePopupTimeoutId=null;}},_render:function()
{this.parent();if($('map-popup'))
{$(document.body).adopt($('map-popup').getParent());}
if($('hover-card-details'))
{$(document.body).adopt($('hover-card-details').getParent());}},_attachEvents:function()
{this.parent();if(this.get_element())
{this.get_element().addEvent('mouseover',this._section_mouseOver.bind(this));this.get_element().addEvent('mouseout',this._section_mouseOut.bind(this));}
var popup=$('map-popup');if(!popup)
{popup=$('hover-card-details');}
if(popup)
{var popupBoxEl=popup.getParent();popupBoxEl.addEvent('mouseover',this._popupBox_mouseOver.bind(this));popupBoxEl.addEvent('mouseout',this._popupBox_mouseOut.bind(this));}},_section_mouseOver:function(event)
{var popup=$('map-popup');if(!popup)
{popup=$('hover-card-details');}
if(popup)
{var target=$(event.target);if(target.get('tag')==='a')
{if(this._hidePopupTimeoutId)
{clearTimeout(this._hidePopupTimeoutId);}
var personKey=target.get('tgn:personKey');if(personKey)
{var personData=Page.ViewData[this._viewDataKey][personKey];if(personData)
{var popupContentEl=popup;var html=TrimPath.processDOMTemplate(this._templateElementId,personData);popupContentEl.set('html',html);var popupBoxEl=popupContentEl.getParent();popupBoxEl.removeClass('left-popup');popupBoxEl.removeClass('hidden');var personPosition=target.getPosition();var popupBoxWidth=popupBoxEl.getSize().x;var position={x:personPosition.x-popupBoxWidth+this.POPUP_OFFSET.x,y:personPosition.y+this.POPUP_OFFSET.y};var toppos=(personPosition.y+this.POPUP_OFFSET.y)+'px';var rightPosVal=($(window).getSize().x-personPosition.x-this.POPUP_OFFSET.x);var leftPosVal=rightPosVal+popupBoxWidth;var arrow=$('hover-card-arrow-id');if(leftPosVal>$(window).getSize().x)
{var asize=target.getSize().x;rightPosVal=$(window).getSize().x-personPosition.x-popupBoxWidth-asize-this.ARROW_OFFSET;if(arrow)
{arrow.removeClass('card-arrow-right');arrow.addClass('card-arrow-left');}}
else
{if(arrow)
{arrow.removeClass('card-arrow-left');arrow.addClass('card-arrow-right');}}
var rightpos=rightPosVal+'px';popupBoxEl.setStyles({top:toppos,left:'auto',right:rightpos});}}}}},_popupBox_mouseOver:function(event)
{if(this._hidePopupTimeoutId)
{clearTimeout(this._hidePopupTimeoutId);}},_popupBox_mouseOut:function(event)
{var target=$(event.target);var targetparent=target.getParent();if(target.match('.person-popup')||target.match('.main-popup')||target.match('.l-popup')||target.match('.r-popup')||target.match('.profile-hover-card')||targetparent.match('.profile-hover-card'))
{if(this._hidePopupTimeoutId)
{clearTimeout(this._hidePopupTimeoutId);}
this._hidePopupTimeoutId=this._hidePopupAsync.delay(this.HIDE_POPUP_DELAY);}},_section_mouseOut:function(event)
{var target=$(event.target);if(target.match('a'))
{if(this._hidePopupTimeoutId)
{clearTimeout(this._hidePopupTimeoutId);}
this._hidePopupTimeoutId=this._hidePopupAsync.delay(this.HIDE_POPUP_DELAY);}},_hidePopupAsync:function()
{if(this._hidePopupTimeoutId)
{clearTimeout(this._hidePopupTimeoutId);}
if($('map-popup'))
{$('map-popup').getParent().addClass('hidden');}
if($('hover-card-details'))
{$('hover-card-details').getParent().addClass('hidden');}}});
Mundia.namespaces("home.index");Mundia.home.index.DynamicNodeCounter=new Class({Extends:Mundia.controls.Control,initialize:function(elementId,estimatedNodeCount,nodesAddedPerMillisecond,estimateTime){this.parent(elementId);this.MAX_NODE_COUNT_UPDATE_INTERVAL=4000;this.MIN_NODE_COUNT_UPDATE_INTERVAL=1000;this.ESTIMATED_NODE_COUNT_ADJUSTMENT=0.5;this._estimatedNodeCount=estimatedNodeCount;this._nodesAddedPerMillisecond=nodesAddedPerMillisecond;this._estimateTime=estimateTime;this._isFirstUpdate=true;this._boundUpdateNodeCount=this._updateNodeCount.bind(this);this._timeoutId=0;},_attachEvents:function(){this._timeoutId=setTimeout(this._boundUpdateNodeCount,0);},_updateNodeCount:function(){clearTimeout(this._timeoutId);var curTime=(new Date()).getTime();var millisecondsElapsed=curTime-this._estimateTime;var curNodeCount=Math.floor((0.97*this._estimatedNodeCount)+(0.80*this._nodesAddedPerMillisecond*millisecondsElapsed));var element=this.get_element();if(element)
{this.get_element().set('html',Mundia.LocalizedFormatter.formatNumber(curNodeCount));}
if(this._isFirstUpdate)
{if(element)
{this.get_element().setStyle('visibility','visible');}
this._isFirstUpdate=false;}
setTimeout(this._boundUpdateNodeCount,this._getNodeCountUpdateInterval());},_getNodeCountUpdateInterval:function(){return this.MIN_NODE_COUNT_UPDATE_INTERVAL+Math.floor(Math.random()*((this.MAX_NODE_COUNT_UPDATE_INTERVAL-this.MIN_NODE_COUNT_UPDATE_INTERVAL)+1));},stop:function(){clearTimeout(this._timeoutId);}});
Mundia.namespaces("home.index");Mundia.home.index.Page=new Class({Extends:Mundia.controls.Page,initialize:function(){this.parent();},_createControls:function(){this.parent();this.controls.surnameHandler=new Mundia.controls.SurnameHandler('search-form');this.controls.dynamicNodeCounter=new Mundia.home.index.DynamicNodeCounter('dynamic-node-count',this.properties.estimatedNodeCount,this.properties.nodesAddedPerMillisecond,this.properties.estimateTime);this.controls.countryLanguageSelector=new Mundia.controls.CountryLanguageSelector('selectCountryLanguageSettings1');},_render:function(){this.parent();if($('map-popup')){this.controls.mapPersonPopupSection=new Mundia.controls.PersonPopupSection('map-people-list','person-popup-template','MapActivity',{x:0,y:0});}
this.intervalId=this.showRecentActivity.periodical(1000,this);},showRecentActivity:function(){var peoplelist=$$('.people-map li.hidden');var person=peoplelist.getRandom();if(person===null){clearInterval(this.intervalId);}
else{person.removeClass('hidden');}},_attachEvents:function(){this.parent();window.addEvent('beforeunload',this._window_beforeUnload.bind(this));var enterFamilyEl=$('enter-family');if(enterFamilyEl){$('enter-family').addEvent('keyup',this._checkCharacters.bind(this));}},_window_beforeUnload:function(event){Page.controls.dynamicNodeCounter.stop();},_checkCharacters:function(event){event.target.value=event.target.value.replace(/[\/\\\$\|\%\|\=\<\>\,\.\{\}\&\*\&\#\@\!\:\;\+\?\[\]\""\' '\'0'\'1'\'2'\'3'\'4'\'5'\'6'\'7'\'8'\'9']/g,"");}});Page.set_pageType(Mundia.home.index.Page);