// Copyright 2005-2010 Meebo, inc.
//
// RSA javascript implementation Copyright 1998-2005 David Shapiro
// please see http://www.ohdave.com/rsa/
// SHA256 javascript implementation Copyright 2003-2004 Angel Marin
// please see http://anmar.eu.org/
// dom offset javascript implementation Copyright 2009 John Resig
// please see http://docs.jquery.com/Source_Code
//
// interested in joining meebo?  we have positions for back-end software engineer, front-end software engineer, and visual designer
// email your resume and cover letter to secretjobs at meebo dot com!
var lib={};
function Class(b,e,d){var a=(d?Class.extend(e,d):Class.create(e));
if(b){var c=b.lastIndexOf(".");
Class.getObject(b.slice(0,Math.max(c,0)))[b.slice(c+1)]=a
}return a
}function Singleton(b,a){return new (Class(null,b,a))()
}Class.create=function(b){function c(){if(typeof this.initialize=="function"){return this.initialize.apply(this,arguments)
}}function a(f,g,e){var d=b;
if(!e){e=[]
}while(d=d.prototype){if(d[g]){return d[g].apply(f,e)
}}throw new Error("method does not exist")
}c.prototype=new b(a);
c.prototype.constructor=c;
c.prototype.supr=a;
return c
};
Class.extend=function(a,b){b.prototype=a.prototype;
return Class.create(b)
};
Class.category=function(a,c){var b=new c(a.prototype.supr);
for(property in b){a.prototype[property]=b[property]
}};
Class.getObject=function(pkg){var parts=pkg.split(".");
if(typeof window=="undefined"){var object=eval(parts[0]+" = typeof "+parts[0]+' == "undefined" ? {} : '+parts[0]+";");
parts.shift()
}else{var object=window
}while(parts.length){var part=parts.shift();
if(!part){continue
}if(!object[part]){object[part]={}
}object=object[part]
}return object
};
Class.objectExists=function(a){var c=a.split("."),b=window;
while(c.length){b=b[c.shift()];
if(!b){return false
}}return true
};
Class("lib.pQueue",function(){this.size=0;
this.m_hash=null;
this.m_priorities=null;
this.initialize=function(){this.size=0;
this.m_hash={};
this.m_priorities=[]
};
this.put=function(b,a){a=a||0;
if(!(a in this.m_hash)){this.m_hash[a]={index:0,items:[]};
this.m_priorities.push(a);
this.m_priorities.sort(function(d,c){return c-d
})
}this.m_hash[a].items.push(b);
++this.size
};
this.take=function(){for(var c;
typeof(c=this.m_priorities.pop())=="number";
){var a=this.m_hash[c];
if(a){if(a.items.length>a.index){var b=a.index++;
var d=a.items[b];
delete a.items[b];
--this.size;
if(a.items.length>a.index){this.m_priorities.push(c)
}else{delete this.m_hash[c]
}return d
}else{delete this.m_hash[c]
}}}return
};
this.takeAll=function(c){var a=this.m_hash[c];
if(a){this.size-=a.items.length-a.index;
var b=a.items.slice(a.index);
a.items=[];
a.index=0;
return b
}return[]
}
});
Class("lib.deferred",function(){this.initialize=function(){this.q=new lib.pQueue();
this.state=-1;
this.paused=0;
this.bFiring=false;
this.results=[null,null]
};
this.addCb=function(e,f){return this.add(e,null,f)
};
this.addEb=function(f,e){return this.add(null,f,e)
};
this.addBoth=function(f,e){return this.add(f,f,e)
};
this.add=function(e,g,f){this.q.put([e,g],f);
c.call(this);
return this
};
this._=function(f){var e=argsToArray(arguments).slice(1);
return this.addBoth(function(g){if(g[f]){return g[f].apply(g,e)
}})
};
function a(f){++this.paused;
var e=this;
f.addBoth(function(){if(--e.paused==0){c.apply(e,arguments)
}})
}function d(e){return(e instanceof lib.deferred)
}function b(f,e){if(d(f)){a.call(this,f)
}else{if(typeof f=="function"){var g=f.apply(this,e);
if(d(g)){a.call(this,g)
}}}}function c(){if(this.state<0){return
}while(this.q.size>0&&!this.paused&&!this.bFiring){var e=this.q.take();
this.bFiring=true;
b.call(this,e[this.state],this.results[this.state]);
this.bFiring=false
}}this.callback=function(){this.state=0;
this.results[this.state]=argsToArray(arguments);
c.call(this);
return this
};
this.errback=function(){this.state=1;
this.results[this.state]=argsToArray(arguments);
c.call(this);
return this
}
});
Class("lib.deferred.error",function(){this.initialize=function(a){this.m_msg=a
};
this.toString=function(){return"Error: "+this.m_msg
}
});
Class("lib.serializer",function(){this.initialize=function(){this.m_bExec=false;
this.m_queue=[]
};
this.serialize=function(c){var b=this;
function a(){if(b.m_queue.length){b.m_bExec=true;
b.m_queue.shift()(a);
return
}b.m_bExec=false
}this.m_queue.push(c);
if(!this.m_bExec){a()
}}
});
Class("lib.PubSub",function(){this.initialize=function(){this.m_subscribers={};
this.m_publisherSubscribers={}
};
this.publish=function(b,l){var a=this.m_subscribers[l],c=b.__id__,f,d;
if(c&&(f=this.m_publisherSubscribers[c])&&(d=f[l])){a=!a?d:d.concat(a)
}a=a&&a.slice(0);
for(var g=0,k;
a&&(k=a[g]);
g++){if(typeof k.callback!="function"){k.callback=hitch(k.context,k.callback)
}try{k.callback.apply(k.context||this,arguments)
}catch(h){}}};
this.subscribe=function(d,a,b,f){if(typeof d=="string"){f=b;
b=a;
a=d;
d=null
}var c=this.m_subscribers;
if(d){var g=d.__id__||(d.__id__=String(getUniqueId()));
var c=this.m_publisherSubscribers[g]||(this.m_publisherSubscribers[g]={})
}var e=c[a]||(c[a]=[]);
e[e.length]={context:b,callback:f}
};
this.subscribeAll=function(e,c,b){if(arguments.length==2){b=c;
c=e;
e=null
}var d=this.m_subscribers;
if(e){var g=e.__id__||(e.__id__=String(getUniqueId()));
var d=this.m_publisherSubscribers[g]||(this.m_publisherSubscribers[g]={})
}for(var a in b){var f=d[a]||(d[a]=[]);
f[f.length]={context:c,callback:b[a]}
}};
this.unsubscribe=function(f,a,d){if(typeof f=="string"){d=a;
a=f;
f=null
}if(!d){return
}var e=this.m_subscribers;
if(f){var h=f.__id__;
if(!h){f.__id__=String(getUniqueId())
}var e=this.m_publisherSubscribers[h]
}var g=e&&e[a];
for(var c=0;
g&&c<g.length;
c++){var b=g[c];
if(b.context==d){g.splice(c,1);
c--
}}}
});
Class("lib.Publisher",function(){this.initialize=function(){this.m_subscribers={}
};
this.subscribe=function(d,c,e){if(!c){c=this
}var b=this.m_subscribers[d]||(this.m_subscribers[d]=[]);
var a=Array.prototype.slice.call(arguments,1);
a.splice(2,0,null);
b[b.length]=a;
return this
};
this.unsubscribe=function(d,c,e){if(!c){this.m_subscribers[d]=[];
return
}var b=this.m_subscribers[d]||(this.m_subscribers[d]=[]);
for(var a=b.length-1;
a>=0;
a--){if(b[a][0]==c&&(!e||b[a][1]==e)){b.splice(a,1)
}}return this
};
this.publish=function(d){var c=(this.m_subscribers[d]||(this.m_subscribers[d]=[])).slice(0);
var a=Array.prototype.slice.call(arguments,1);
for(var b=0,e;
(e=c[b]);
b++){if(typeof e[1]!="function"&&typeof e[2]!="function"){e[2]=hitch(e[0],e[1])
}(e[2]||e[1]).apply(e[0],e.slice(3).concat(a))
}return this
};
this.publishDeferred=function(e){var a=new lib.deferred();
var d=this.m_subscribers[e]||(this.m_subscribers[e]=[]);
for(var c=0,f;
(f=d[c]);
c++){a.addBoth(hitch(f[0],f[1]))
}var b=Array.prototype.slice.call(arguments,1);
a.callback.apply(a,b);
return a
}
});
lib.ResourceManager=function(a){this.m_queue=[];
this.m_create=a;
this.m_isRecyclable=true;
this.getOne=function(b){this.m_queue.length?b(this.m_queue.shift()):this.m_create(b)
};
this.recycle=function(b){if(this.m_isRecyclable){this.m_queue.push(b)
}};
this.setRecyclable=function(b){this.m_isRecyclable=b
};
this.allocate=function(d){var c=hitch(this,"recycle");
for(var b=this.m_queue.length;
b<d;
++b){this.m_create(c)
}}
};
Class("lib.CallbackManager",function(){this.initialize=function(){this.m_callbacks={};
this.m_namespace="CallbackManager"+new Date().getTime()+"_"+Math.floor(Math.random()*100000);
this.m_callbackCount=0
};
this.scheduleCallback=function(b){var a=this.m_namespace+"_"+(this.m_callbackCount++);
this.m_callbacks[a]=b;
return a
};
this.executeCallback=function(b,a){if(!this.m_callbacks[b]){return
}var a=this.m_callbacks[b].call(this,a);
delete this.m_callbacks[b];
return a
}
});
Class("lib.Hashtable",function(){this.m_list=null;
this.length=0;
this.initialize=function(){this.m_list={};
this.length=0
};
this.add=function(a,b){if(!(a in this.m_list)){++this.length
}this.m_list[a]=b;
return b
};
this.get=function(a){return this.m_list[a]
};
this.remove=function(a){var b=null;
if(a in this.m_list){--this.length;
b=this.m_list[a];
delete this.m_list[a]
}return b
};
this.member=function(a){return a in this.m_list
};
this.foreach=function(c,b){for(var a in this.m_list){if(c.call(b,a,this.m_list[a])){break
}}};
this.getByIndex=function(a){if(a<this.length){var c=0;
for(var b in this.m_list){if(c++==a){return this.m_list[b]
}}}return null
};
this.toArray=function(c){var b=[];
if(c){for(var a in this.m_list){b.push(a)
}}else{for(var a in this.m_list){b.push(this.m_list[a])
}}return b
}
});
Class("lib.Filterable",lib.Hashtable,function(a){this.m_map=null;
this.m_alwaysCompile=false;
this.m_compiledFilters=null;
this.initialize=function(c,b){a(this,"initialize",[]);
this.m_map=c;
this.m_alwaysCompile=!!b;
this.m_compiledFilters={}
};
this.flushCaches=function(){this.m_compiledFilters={}
};
this.add=function(b,c){var d=a(this,"add",arguments);
this.addItemToNode(b,c,this.m_compiledFilters);
return d
};
this.remove=function(b){var c=a(this,"remove",arguments);
this.removeItemFromNode(b,this.m_compiledFilters);
return c
};
this.getItemTestValue=function(c,b){var d=this.m_map[b];
if(typeof d=="string"){d=c[d]
}return d.call(c)
};
this.testItem=function(d,c){for(var b in c){if(this.getItemTestValue(d,b)!=c[b]){return false
}}return true
};
this.getItems=function(g,m){if(!this.length){return new lib.Hashtable()
}g=g||{};
if(m||((m!==false)&&this.m_alwaysCompile)){return this.compileFilter(g)
}var d=this.m_compiledFilters;
var c=this;
var f={};
var l=0;
var e=false;
for(var k in g){var b=g[k];
if(!e){if(("filters" in d)&&(k in d.filters)&&(b in d.filters[k])){d=d.filters[k][b];
if("items" in d){c=d.items;
f={};
l=0
}else{f[k]=b;
l++
}}else{e=true
}}if(e){f[k]=b;
l++
}}if(l<=0){return c
}else{var h=new lib.Hashtable();
c.foreach(hitch(this,function(p,n,o){if(this.testItem(o,p)){h.add(n,o)
}},f));
return h
}};
this.compileFilter=function(c){var d=this.m_compiledFilters;
for(var b in c){var e=c[b];
if(!("filters" in d)){d.filters={}
}if(!(b in d.filters)){d.filters[b]={}
}if(!(e in d.filters[b])){d.filters[b][e]={}
}d=d.filters[b][e]
}if(d==this.m_compiledFilters){return this
}d.items=this.getItems(c,false);
return d.items
};
this.addItemToNode=function(c,e,d){if("items" in d){d.items.add(c,e)
}if("filters" in d){for(var b in d.filters){var g=String(this.getItemTestValue(e,b));
for(var f in d.filters[b]){if(g==f){this.addItemToNode(c,e,d.filters[b][g])
}else{this.removeItemFromNode(c,d.filters[b][f])
}}}}};
this.removeItemFromNode=function(c,d){if("items" in d){if(!d.items.member(c)){return
}d.items.remove(c)
}if("filters" in d){for(var b in d.filters){for(var e in d.filters[b]){this.removeItemFromNode(c,d.filters[b][e])
}}}};
this.onItemChange=function(b,c){this.addItemToNode(b,c,this.m_compiledFilters)
}
});
util={};
util.query={MEDIABAR_SHARE_ID:"ad",SPARK_SHARE_ID:"sparkAd",AUTO_LAUNCH_ID:"launch",MEEBO_USER:"mu",USER:"u",ADD_BUDDY_USERNAME:"ab",TRACK_VIRAL:"v",SESSION_KEY:"k",EG_SESSION_KEY:"e",FIREFOX_EXTENSION:"ff",AUTH_TOKEN:"t",NETWORK:"n",PROTOCOL:"p",NETWORK_SIGNON:"nso",GROUPCHAT_PASSWORD:"pass",GROUPCHAT_INVITE_RECEIVED:"m",FILE_ID:"fileid",PROMPT_SIGNUP:"signup",FORCE_TREATMENT:"treatment",CLIENT_TYPE:"ct",PREFILL_NAME:"pf",CONNECT_CALLER_URL:"ccu",CALLER_CLIENTID:"cid",PARTNER_AUTH_TOKEN:"pat",CALLBACK_ID:"cb",RWC_NAME:"rn",RWC_VALUE:"rv",SHOW_BLOG:"blog",REMOTE_CALL:"rc",REMOTE_URL:"ru",REMOTE_ARGS:"ra",REMOTE_CALLBACK:"rb",REMOTE_SUCCESS:"rs",REMOTE_REDIRECT:"redirect",REDIRECT_FRAME:"rf",REDIRECT_SERVER:"rv"};
function getQueryVariable(a){return getUrlVariable(a,window.location.search.substring(1))
}function getHashVariable(b,a){var c;
if(a){c=a.substr(a.indexOf("#")+1)
}else{c=window.location.hash.substr(1)
}return c&&getUrlVariable(b,c)||null
}function getUrlVariable(a,b){if(ui.isIE||ui.isWebKit){b=decodeURIComponent(b)
}return getURIParamsAsObject(b)[a]
}function getObjectAsURIParams(c){var a=[];
for(var b in c){a.push(encodeURIComponent(b)+((typeof c[b]!="undefined")?("="+encodeURIComponent(c[b])):""))
}return a.join("&")
}function getURIParamsAsObject(e){if(!e){return{}
}var c={};
var d=e.split("&");
for(var b=0;
b<d.length;
b++){var a=d[b].split("=");
c[decodeURIComponent(a[0])]=a[1]&&decodeURIComponent(a[1])||a[1]
}return c
}util.query.grabHashVariables=function(){util.query.m_hashValues=util.query.m_hashValues||{};
var a=window.location.href.split("#");
if(a[1]){if(navigator.userAgent.indexOf("WebKit")==-1){window.location.hash="#"
}util.query.m_hashValues=getURIParamsAsObject(a[1])
}};
util.query.getHashVariable=function(a){return util.query.m_hashValues[a]
};
util.query.addParams=function(c,k,a){var g=c.split("?");
if(g[1]){var l=g[0];
var b=(g[1]||"").split("#");
var d=b[0];
var e=b[1]
}else{var b=c.split("#");
var l=b[0];
var d="";
var e=b[1]
}var f=(d?d+"&":"")+getObjectAsURIParams(k);
var h=(e?e+"&":"")+getObjectAsURIParams(a);
return l+(f?"?"+f:"")+(h?"#"+h:"")
};
util.query.URL=function(a){var b=String(a).match(/^([^:\/?#]+:)?(?:\/\/)?([^\/?#]*)([^?\s#]*)?(\?([^#]*))?(#(.*))?$/);
if(b){this.protocol=b[1];
this.host=b[2];
this.pathname=b[3];
this.search=b[5]||"";
this.hash=b[7]
}};
util.query.URL.prototype.addToSearch=function(b){if(typeof b=="object"){for(var a in b){if(this.search){this.search+="&"
}this.search+=encodeURIComponent(a)+"="+encodeURIComponent(b[a])
}}else{this.search=this.search+(this.search?"&":"")+b
}};
util.query.URL.prototype.getSearchParams=function(){if(!this.searchParams){var d=this.search.split("&");
this.searchParams={};
for(var b=0,a=d.length;
b<a;
++b){var c=d[b].split("=");
if(c&&c[0]){this.searchParams[decodeURIComponent(c[0])]=(c[1]?decodeURIComponent(c[1]):"")
}}}return this.searchParams
};
util.query.URL.prototype.toString=function(){var a="";
if(this.protocol){a+=this.protocol
}if(this.host){a+="//"+this.host
}if(this.pathname){a+=this.pathname
}if(this.search){a+="?"+this.search
}if(this.hash){a+="#"+this.hash
}return a
};
util.query.URL.prototype.getHashParam=function(b){var a=this.hash&&this.hash.match("^(.*&)?"+b+"=([^&]*)");
return a&&a[2]
};
util.query.url=function(a){return new util.query.URL(a)
};
util.query.relativeTo=function(b,a){var c=util.query.url(b);
var b=util.query.url(b),a=util.query.url(a);
if(!b.protocol){c.protocol=a.protocol;
if(!b.host){c.host=a.host
}}return c.toString()
};
util.query.verifyDomain=function(c){var e=util.query.getVerifiedDomains();
if(!e.length){return true
}for(var b=0,d;
d=e[b];
b++){var a=new RegExp("(^|[.])"+d.replace(/\./g,"\\.")+"$","i");
if(a.test(c)){return true
}}return false
};
util.query.getVerifiedDomains=function(){return(typeof gVerifiedDomains!="undefined"?gVerifiedDomains:[])
};
util.cookie={};
util.cookie.save=function(a,f,d,c){if(typeof d!="number"&&!(d instanceof Date)){d=(365*24*60*60*1000)
}var b;
if(d instanceof Date){b=d
}else{if(d>=0){b=new Date();
b.setTime(b.getTime()+d)
}}var e=b?"expires="+b.toGMTString()+"; ":"";
var k=a+"="+encodeURIComponent(f)+"; ";
var g=c||(/(\.|^)meebo\.com$/i.test(document.domain)?".meebo.com":document.domain);
var c="domain="+g+"; ";
var h="path=/; ";
document.cookie=k+e+c+h
};
util.cookie.erase=function(b,a){util.cookie.save(b,"",new Date(0),a,false)
};
util.cookie.eraseFromDomains=function(c){var b=window.location.hostname.split(".");
for(var d=0,a=b.length;
d<a;
++d){var e=b.slice(d).join(".");
util.cookie.erase(c,e)
}};
util.cookie.load=function(b){var c=document.cookie;
if(c.length){var a=new RegExp("(?:^|;)\\s*"+b+"=(.*?)(?:;|$)").exec(c);
if(a&&a.length){return decodeURIComponent(a[1])
}}return null
};
util.css={};
function addClassName(c,b){var d=typeof c=="string";
if((!d&&!c)||!b){return
}var a=d?c:c.className;
if((" "+a+" ").indexOf(" "+b+" ")==-1){a+=(a?" ":"")+b
}if(!d){c.className=a
}return a
}function addClassNames(a){for(var b=1;
b<arguments.length;
b++){addClassName(a,arguments[b])
}}function removeClassName(c,b){var d=typeof c=="string";
if((!d&&!c)||!b){return
}var a=d?c:c.className;
a=(" "+a+" ").replace(" "+b+" "," ").replace(/^\s+|\s+$/g,"");
if(!d){c.className=a
}return a
}function removeClassNames(a){for(var b=1;
b<arguments.length;
b++){removeClassName(a,arguments[b])
}}function toggleClassName(c,b,a){if(b){addClassName(c,a)
}else{removeClassName(c,a)
}}function hasClassName(c,b){var d=typeof c=="string";
if((!d&&!c)||!b){return
}var a=d?c:c.className;
return((" "+a+" ").indexOf(" "+b+" ")!=-1)
}function roundElementCorners(a){if(ui.isFirefox||ui.isWebKit){addClassName(a,"roundCorners")
}else{var k=gDoc(a);
var l=a.parentNode;
var e=k.createElement("div");
l.removeChild(a);
e.appendChild(a);
l.appendChild(e);
addClassName(e,"stackedCorners");
addClassName(a,"stackedContent");
var h=k.createElement("b");
var f=k.createElement("b");
addClassName(h,"stack-top");
addClassName(f,"stack-bot");
for(var c=1;
c<=3;
c++){var g=k.createElement("b");
addClassName(g,"roundCorner stack"+c);
h.appendChild(g)
}for(var c=3;
c>=1;
c--){var g=k.createElement("b");
addClassName(g,"roundCorner stack"+c);
f.appendChild(g)
}var d=a.firstChild;
if(!d){d=a.ownerDocument.createElement("div");
a.appendChild(d)
}d.style.padding="0px 1px 0px";
a.parentNode.insertBefore(h,a);
a.parentNode.appendChild(f)
}}util.css.setOpacity=function(a,b){if(a&&a.style){if(ui.isIE){a.style.filter="alpha(opacity="+Math.floor(b*100)+")"
}else{a.style.opacity=b;
a.style.MozOpacity=b;
a.style.KhtmlOpacity=b
}}};
util.css.setStyle=function(b,a){for(var c in a){switch(c){case"float":b.style.styleFloat=b.style.cssFloat=a[c];
break;
case"borderRadius":b.style.borderRadius=b.style.webkitBorderRadius=b.style.MozBorderRadius=a[c];
break;
default:b.style[c]=a[c];
break
}}};
util.dom={};
function $(e){for(var c=0,d;
(d=$.docs[c]);
c++){try{var b=d.getElementById(e);
if(b){return b
}}catch(a){}}}$.docs=[document];
$.remember=function(b){for(var a=0;
a<$.docs.length;
++a){if(b===$.docs[a]){return
}}$.docs.push(b)
};
$.forget=function(c){var a=[];
for(var b=0;
b<$.docs.length;
++b){if($.docs[b]!==c){a.push($.docs[b])
}}$.docs=a
};
function gDoc(b){if(b){if(b.ownerDocument){return b.ownerDocument
}else{if(b.document){return b.document
}else{if(typeof(b.nodeName)=="string"){if(b.nodeName.match(/document/i)){return b
}else{if(gWin.isWindow(b)){return b.document
}}}}}var a=b.target||b.srcElement;
if(a){return gDoc(a)
}}return gDoc._doc
}gDoc._doc=document;
function gWin(c){if(gWin.wins.length==1){return gWin.wins[0]
}if(gWin.isWindow(c)){return c
}var b=gDoc(c);
for(var a=0;
a<gWin.wins.length;
a++){if(gWin.wins[a].document===b){return gWin.wins[a]
}}var d=b.parentWindow||b.defaultView;
return d||gWin.wins[0]
}gWin.wins=[window];
gWin.isWindow=function(c){var a=false;
try{a=(c&&typeof c.screen=="object")
}catch(b){a=true
}return a
};
gWin.map=function(b){for(var a=0;
a<gWin.wins.length;
++a){b(gWin.wins[a])
}};
gWin.remember=function(a){if(isDefined(a._gWinPos)){return
}a._gWinPos=gWin.wins.length;
gWin.wins.push(a)
};
gWin.forget=function(c){if(!isDefined(c._gWinPos)){return
}gWin.wins.splice(c._gWinPos,1);
for(var b=c._gWinPos;
b<gWin.wins.length;
b++){gWin.wins[b]._gWinPos=b
}try{delete c._gWinPos
}catch(a){}};
function getChild(a,c){if(!a){return
}if(!a.hasChildNodes){return
}var b=a.firstChild;
while(b){if(b.id==c){return b
}b=b.nextSibling
}}function recursiveGetPart(a,d){if(!a||!d){return
}if(!a.hasChildNodes()){return
}var c=a.firstChild;
while(c){if(c.id==d){return c
}var b=recursiveGetPart(c,d);
if(b){return b
}c=c.nextSibling
}return null
}function posWithRespectTo(b,a){var d={x:0,y:0,w:0,h:0};
if(b){d.w=b.offsetWidth;
d.h=b.offsetHeight
}var c=b;
while(c){if(c===a){break
}d.x+=c.offsetLeft;
d.y+=c.offsetTop;
if(c!=b){d.x-=c.scrollLeft;
d.y-=c.scrollTop
}c=c.offsetParent
}d.left=d.x;
d.top=d.y;
return d
}function getElementPosition(a){if(!a){return
}var b=gDoc(a),c=posWithRespectTo(a);
if(navigator.userAgent.indexOf("Mac")!=-1&&isDefined(b.body.leftMargin)){c.x+=b.body.leftMargin;
c.left=c.x;
c.y+=b.body.topMargin;
c.top=c.y
}return c
}
/*
 * jQuery JavaScript Library v1.3.2
 * http://jquery.com/
 *
 * Copyright (c) 2009 John Resig
 * Dual licensed under the MIT and GPL licenses.
 * http://docs.jquery.com/License
 *
 * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
 * Revision: 6246
 */
function getElementOffset(u,e){e=e||window;
if(u.getBoundingClientRect){var m=u.getBoundingClientRect(),D=u.ownerDocument,p=D.body,t=D.documentElement,y=t.clientTop||p.clientTop||0,w=t.clientLeft||p.clientLeft||0,q=m.top+(e.pageYOffset||t.scrollTop||p.scrollTop)-y,d=m.left+(e.pageXOffset||t.scrollLeft||p.scrollLeft)-w;
return{y:q,x:d,w:m.right-m.left,h:m.bottom-m.top}
}else{var g=arguments.callee.offset;
if(!g){var p=document.body,b=document.createElement("div"),B,A,v,l,n,c,C=p.style.marginTop,o='<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>';
n={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};
for(c in n){b.style[c]=n[c]
}b.innerHTML=o;
p.insertBefore(b,p.firstChild);
B=b.firstChild,A=B.firstChild,l=B.nextSibling.firstChild.firstChild;
var g={};
g.doesNotAddBorder=(A.offsetTop!==5);
g.doesAddBorderForTableAndCells=(l.offsetTop===5);
B.style.overflow="hidden",B.style.position="relative";
g.subtractsBorderForOverflowNotVisible=(A.offsetTop===-5);
p.style.marginTop="1px";
g.doesNotIncludeMarginInBodyOffset=(p.offsetTop===0);
p.style.marginTop=C;
p.removeChild(b);
arguments.callee.offset=g
}var z=u.offsetHeight;
var s=u.offsetWidth;
var a=u.offsetParent,f=u,D=u.ownerDocument,k,t=D.documentElement,p=D.body,x=D.defaultView,h=x.getComputedStyle(u,null),q=u.offsetTop,d=u.offsetLeft;
while((u=u.parentNode)&&u!==p&&u!==t){k=x.getComputedStyle(u,null);
q-=u.scrollTop,d-=u.scrollLeft;
if(u===a){q+=u.offsetTop,d+=u.offsetLeft;
if(g.doesNotAddBorder&&!(g.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(u.tagName))){q+=parseInt(k.borderTopWidth,10)||0;
d+=parseInt(k.borderLeftWidth,10)||0
}f=a;
a=u.offsetParent
}if(g.subtractsBorderForOverflowNotVisible&&k.overflow!=="visible"){q+=parseInt(k.borderTopWidth,10)||0;
d+=parseInt(k.borderLeftWidth,10)||0
}h=k
}if(h.position==="relative"||h.position==="static"){q+=p.offsetTop;
d+=p.offsetLeft
}if(h.position==="fixed"){q+=Math.max(t.scrollTop,p.scrollTop);
d+=Math.max(t.scrollLeft,p.scrollLeft)
}return{y:q,x:d,w:s,h:z}
}}function getPartFromElement(a,b){if(a){return recursiveGetPart(a,b)
}}function removeChildren(a){if(a){var b;
while(b=a.firstChild){a.removeChild(b)
}}return a
}function removeElement(b){try{if(!b||!b.parentNode){return b
}return b.parentNode.removeChild(b)
}catch(a){b.style.visibility="hidden";
return b
}}util.dom.getAttribute=function(a,b){try{return a.getAttribute?a.getAttribute(b):""
}catch(c){}};
util.dom.insertBefore=function(b,c,a){if(!b||!c){return
}if(a){return b.insertBefore(c,a)
}else{return b.appendChild(c)
}};
util.dom.insertAfter=function(a,b,c){if(!a||!b){return
}if(!c){if(a.firstChild){a.insertBefore(b,a.firstChild)
}else{a.appendChild(b)
}}else{if(!c.nextSibling){a.appendChild(b)
}else{a.insertBefore(b,c.nextSibling)
}}};
function hitch(c,d){var b=Array.prototype.slice.call(arguments,2);
function a(){var e=(typeof d=="function"?d:c[d]);
return e.apply(c,b.concat(Array.prototype.slice.call(arguments)))
}a.methodName=d;
return a
}util.html={};
function getValue(b){var a=$(b);
if(!a||!isDefined(a.value)||!a.value){return""
}return a.value
}function createRadio(b,c){if(ui.isIE){var a=c.document.createElement('<input type="radio" name="'+b+'">')
}else{var a=c.document.createElement("input");
a.type="radio";
a.name=b
}return a
}function copyStyles(f,c,a,e){for(var b=0,g;
g=e[b];
++b){getCSSProp.camelProp[g]||(getCSSProp.camelProp[g]=g.replace(/-\D/gi,getCSSProp.capitalize))
}var d=getCSSProp(c,e,f);
for(var g in d){if(d[g]){a.style[getCSSProp.camelProp[g]]=d[g]
}}}function getCSSProp(f,n,l){if(f.currentStyle){var a=f.style.display;
f.style.display=(a=="block"?"inline":"block");
f.style.display=a;
if(isArray(n)){var c={};
for(var g=0,b;
b=n[g];
++g){var d=getCSSProp.camelProp[b]||(getCSSProp.camelProp[b]=b.replace(/-\D/gi,getCSSProp.capitalize));
try{c[b]=f.currentStyle[d]
}catch(m){}}return c
}else{var d=getCSSProp.camelProp[n]||(getCSSProp.camelProp[n]=n.replace(/-\D/gi,getCSSProp.capitalize));
var h=/font/i;
if(h.test(d)){addClassName(f,"fontHack");
removeClassName(f,"fontHack")
}try{var c=f.currentStyle[d]
}catch(m){}return c
}}else{var l=l||gWin(f);
if(l.document.defaultView){var k=l.document.defaultView.getComputedStyle(f,"");
if(k){if(isArray(n)){var c={};
for(var g=0,b;
b=n[g];
++g){c[b]=k.getPropertyValue(b)
}return c
}else{return k.getPropertyValue(n)
}}}}if(f.style.getPropertyValue){if(isArray(n)){var c={};
for(var g=0,b;
b=n[g];
++g){c[b]=f.style.getPropertyValue(b)
}return c
}else{return f.style.getPropertyValue(n)
}}return null
}getCSSProp.capitalize=function(a){return a.charAt(a.length-1).toUpperCase()
};
getCSSProp.camelProp={};
function getTextHeight(e,b,a){if(!e||e.length<=0){return 0
}var c=setupRuler(a);
if(b){c.style.width=b+"px"
}else{c.style.width=document.body.offsetWidth+"px"
}setText(c,e);
c.className="";
var d=c.offsetHeight;
c.style.width="";
return d
}function setupRuler(b){var c=$("ruler");
if(!c){c=document.createElement("span");
c.id="ruler";
c.style.left="400px";
c.style.top="0px";
c.style.position="absolute";
c.style.visibility="hidden";
c=document.body.appendChild(c)
}if(b){var e=getCSSProp(b,"font-size");
var a=getCSSProp(b,"font-weight");
var d=getCSSProp(b,"font-family");
c.style.fontSize=e?e:"11px";
c.style.fontWeight=a?a:"normal";
c.style.fontFamily=d?d:"Tahoma, Arial, sans serif"
}return c
}function getFittedHeightText(h,a,b,c){if(c<=0){return""
}if(ui.isGecko){var d=15;
var f=h.split(" ");
for(var e=0;
e<f.length;
e++){if(f[e].length>d){f.splice(e+1,0,f[e].substring(d));
f[e]=f[e].substring(0,d)
}}h=f.join(" ")
}var g=getTextHeight(h,a,b);
while(g>c){var k=h.lastIndexOf(" ");
if(k==-1){return""
}h=h.substr(0,k)+"\u2026";
g=getTextHeight(h,a,b)
}return h
}function getbAttribute(a,b){if(!a||!a.getAttribute){return false
}var c=a.getAttribute(b);
if((!c)||(c.length<=0)){return false
}return c
}function truncateMiddle(d,b){if(d.length<=b){return d
}var a=Math.ceil(b/2);
var c=Math.floor(b/2);
return d.substr(0,a)+"\u2026"+d.substr(d.length-c)
}function truncateEnd(b,a){return b.substr(0,a)+"\u2026"
}function getTruncatedText(e,c,d,a,b){if(!e){return""
}b=b||arguments.callee.textbox;
if(!b){b=document.createElement("div");
b.style.fontSize="11px";
b.style.fontWeight="normal";
b.style.fontFamily="Tahoma, Arial, sans-serif";
b.style.position="absolute";
b.style.top=b.style.left="-999px";
b.style.visibility="hidden";
document.body.appendChild(b);
arguments.callee.textbox=b
}setTruncatedText(window,b,e,c,d,a);
return b.firstChild.nodeValue
}function setTruncatedText(k,c,s,q,p,n,h){if(q<=0){return false
}var t=getTextRuler(k,c,h);
if(p){t.style.width=q+"px";
t.style.whiteSpace="normal";
setText(t,s);
if(t.offsetHeight>p){var g=s;
var f=0,m=s.length,e="";
while(m-f>1){i=Math.floor((m+f)/2);
var l=g.substr(0,i)+"\u2026";
setText(t,l);
if(t.offsetHeight>p){m=i
}else{f=i;
s=l
}}}}else{t.style.width="auto";
t.style.whiteSpace="nowrap";
setText(t,s);
n=n||truncateEnd;
var a=t.offsetWidth;
if(q&&a>q){var o=s.length,b=0,d=s.length/2;
do{b=o;
o=Math.floor((q/a)*o);
setText(t,n(s,o));
a=t.offsetWidth
}while(d-->0&&(Math.abs(o-b)>1||(o!=b&&a>q)));
s=n(s,Math.min(o,b))
}}setText(c,s);
return a
}function getTextRuler(c,a,b){var d=setTruncatedText.ruler;
if(!d){d=c.document.createElement("div");
d.style.position="absolute";
d.style.top=d.style.left="-999px";
c.document.body.appendChild(d);
setTruncatedText.ruler=d
}if(a||b){b=b||{};
d.style.fontSize=b.fontSize||getCSSProp(a,"font-size",c)||"";
d.style.fontWeight=b.fontWeight||getCSSProp(a,"font-weight",c)||"";
d.style.fontFamily=b.fontFamily||getCSSProp(a,"font-family",c)||""
}return d
}function getTextWidth(b,a,c){var d=getTextRuler(b,a);
d.style.width="auto";
d.style.whiteSpace="nowrap";
setText(d,c);
return d.offsetWidth
}function setTruncatedTextContent(e,m,c,k,h,g){k=k||truncateEnd;
h=h||{};
if(c<0){c=0
}var n=arguments.callee.ruler;
if(!n){g=g||window;
n=g.document.createElement("div");
n.style.whiteSpace="nowrap";
n.style.position="absolute";
n.style.top=n.style.left="-999px";
n.style.visibility="hidden";
g.document.body.appendChild(n);
arguments.callee.ruler=n
}n.style.fontSize=h.fontSize||getCSSProp(e,"font-size",g)||"";
n.style.fontWeight=h.fontWeight||getCSSProp(e,"font-weight",g)||"";
n.style.fontFamily=h.fontFamily||getCSSProp(e,"font-family",g)||"";
setText(n,m);
var b=m;
var a=n.offsetWidth;
if(c&&a>c){var l=m.length,d=0,f=m.length/2;
do{d=l;
l=Math.floor((c/a)*l);
b=k(m,l);
setText(n,b);
a=n.offsetWidth
}while(f-->0&&(Math.abs(l-d)>1||(l!=d&&a>c)));
b=k(m,Math.min(l,d))
}setText(e,b);
return a
}function isCursorInElement(b,c){if(!c){c=gWin(b).event
}if(!c||!b){return false
}var e=getElementPosition(b);
var a=ui.getCursorX(c);
var d=ui.getCursorY(c);
return isInRect(a,d,e.x,e.y,e.w,e.h)
}function isChecked(b){var a=$(b);
if(a){return a.checked
}return false
}function moveToEnd(c){if(!c||ui.isWebKit){return
}try{if(c.createTextRange){var b=c.createTextRange();
b.collapse(false);
b.select()
}else{c.focus();
var a=c.value.length;
if(c.setSelectionRange&&a){c.setSelectionRange(a,a)
}}}catch(d){}}function sendMouseEvent(e,l,g,f,d,c,m,b,h,n){var o=gDoc(e);
var k=gWin(o);
if(ui.isIE){var a=o.createEventObject();
a.detail=0;
a.screenX=g;
a.screenY=f;
a.clientX=d;
a.clientY=c;
a.button=m;
a.ctrlKey=b;
a.altKey=h;
a.shiftKey=n;
a.metaKey=false;
a.relatedTarget=null;
e.fireEvent("on"+l,a)
}else{if(ui.isGecko){var a=o.createEvent("MouseEvents");
a.initMouseEvent(l,true,true,k,1,g,f,d,c,b,h,n,false,0,null);
e.dispatchEvent(a)
}}}function unselectText(b){var a,e=gWin(b);
var d=e.document;
if(d.selection){var c=d.selection;
if(!c||!c.createTextRange){return
}a=c.createTextRange();
if(!a||!a.collapse){a.collapse(false)
}}else{if(e&&e.getSelection){var c=e.getSelection();
if(!c||!c.removeRange){return
}if(c.rangeCount<=0){return
}var a=c.getRangeAt(0);
if(!a){return
}c.removeRange(a)
}}}function calcWinChrome(a){if(isDefined(a.outerWidth)){return{w:a.outerWidth-a.innerWidth-2,h:a.outerHeight-a.innerHeight-30}
}else{if(a===window){return{w:0,h:0}
}else{return{w:5,h:52}
}}}function calcWinPos(a){return{x:(a.screenLeft||a.screenX),y:(a.screenTop||a.screenY),w:(a.innerWidth||(a.document.documentElement&&a.document.documentElement.clientWidth)||a.document.body.clientWidth),h:(a.innerHeight||(a.document.documentElement&&a.document.documentElement.clientHeight)||a.document.body.clientHeight)}
}function fixPng(b,c,e){if(arguments.length==0){b=this
}c=c||gImages.getPath()+"blank.gif";
e=e||"scale";
if(ui.isIE&&ui.isIE<=6&&typeof b.style.filter=="string"&&b.src.match(/\.png$/i)!=null){var d=b.src;
if(b.width){b.style.width=b.width+"px"
}if(b.height){b.style.height=b.height+"px"
}b.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+d+"', sizingMethod='"+e+"')";
var a=function(){b.className=b.className.replace(/\bfixPng\b/g,"");
b.detachEvent("onload",a)
};
b.attachEvent("onload",a);
b.src=c
}else{b.className=b.className.replace(/\bfixPng\b/g,"")
}}if(navigator.platform=="Win32"&&navigator.appName=="Microsoft Internet Explorer"){document.write('<style type="text/css"> .fixPng { visibility: hidden; } </style>')
}function disableSelection(b,a){if(a){var d=b.all||b.getElementsByTagName("*");
for(var c=0;
c<d.length;
c++){arguments.callee(d[c])
}}b.style.userSelect="none";
b.style.MozUserSelect="none";
b.style.KhtmlUserSelect="none";
b.unselectable="on"
}function enableSelection(b,a){if(a){var d=b.all||b.getElementsByTagName("*");
for(var c=0;
c<d.length;
c++){arguments.callee(d[c])
}}else{b.style.MozUserSelect="";
b.style.KhtmlUserSelect="";
b.unselectable="off"
}}function isSelectionCollapsed(b){var d=gDoc(b);
var c=gWin(d);
if(d.selection){return d.selection.createRange().text==""
}else{if(c.getSelection){var a=c.getSelection();
if(typeof a=="string"){return a==""
}else{return a.isCollapsed
}}}}function setText(a,b){b=String(b);
if("textContent" in a){a.textContent=b
}else{a.innerHTML="";
a.appendChild(gDoc(a).createTextNode(b.replace(/\n/g," ")))
}return a
}function getText(a){if("textContent" in a){return a.textContent
}else{if("innerText" in a){return a.innerText
}else{return a.innerHTML
}}}function attachIframeCallback(a,b){a.onload=function(){a.onload=null;
a.onreadystatechange=null;
b.call(this)
};
a.onreadystatechange=function(){if(this.readyState=="complete"){a.onload=null;
a.onreadystatechange=null;
b.call(this)
}}
}function attachIframeMouseHandlers(e,d,b,a){var c=ui.isIE?e.contentWindow.document:e.contentDocument;
function f(l,h,k,m){var p=true;
if(m){p=m(l)
}var o=getElementPosition(e);
if(ui.isFirefox==1){o={left:0,top:0}
}var g=l.clientX+o.left;
var n=l.clientY+o.top;
sendMouseEvent(e.parentNode,h,g,n,g,n,k,false,false,false);
return p
}ui.connectEvent(c,"mousemove",this,f,true,false,"mousemove",0,d);
ui.connectEvent(c,"mousedown",this,f,true,false,"mousedown",0,a);
ui.connectEvent(c,"mouseup",this,f,true,false,"mouseup",0,a)
}function scrollToItem(b,h){if(!b||!b.style||!h||!h.style){return
}var g=b.scrollTop;
var a=b.offsetHeight;
var f=g+a;
var d=h.offsetTop;
var e=h.scrollHeight;
var c=d+e;
if((g<d)&&(c<f)){return
}if(g>d){b.scrollTop=d;
return
}if(c>f){b.scrollTop=d-a+e
}}(function(){util.html.createImage=function(h,k,g){var f=h.document.createElement("img"),e=document.createElement("img");
e.style.visibility="hidden";
e.onload=hitch(e,b,f,k,g);
e.onerror=hitch(e,a,f,k,g);
f.style.visibility="hidden";
setTimeout(hitch(this,c,e,k),0);
return f
};
function c(f,h){try{gPltMgr.getElement().appendChild(f)
}catch(g){}f.src=h
}function a(e,g,f){this.onload=this.onerror=null;
removeElement(e);
removeElement(this);
if(f){f.call(e,0,0)
}}function b(f,h,g){this.onload=this.onerror=null;
var e=new util.Interval(),g=hitch(this,d,e,f,h,g);
e.run(g,150);
g()
}function d(g,f,l,k){var h=this.width||this.naturalWidth||this.offsetWidth;
var e=this.height||this.naturalHeight||this.offsetHeight;
if(!h){return
}removeElement(this);
g.clear();
f.style.width=h+"px";
f.style.height=e+"px";
if(/\.png/.test(l)&&ui.isIE==6&&("filters" in f)){setTimeout(hitch(util.html,"png",f,l),0)
}else{f.src=l
}f.style.visibility="visible";
if(k){k.call(f,h,e)
}}})();
util.html.png=function(a,c){try{a.src=gConfig.getMeeboAppImageURL("blank.gif");
a.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+c+"', sizingMethod='scale')"
}catch(b){}};
function scaleImage(b,d,f){var g=b.height,a=b.width;
var e=f,c=d;
if(e!=g){b.height=e=Math.min(e,g);
b.width=c=(d/f)*e
}if(c>a){b.width=c=a;
b.height=e=(f/d)*c
}b.style.borderStyle="solid";
b.style.borderTopWidth=Math.floor((g-e)/2)+"px";
b.style.borderBottomWidth=Math.ceil((g-e)/2)+"px";
b.style.borderLeftWidth=Math.floor((a-c)/2)+"px";
b.style.borderRightWidth=Math.ceil((a-c)/2)+"px"
}function sanitizeLinks(b,e){var a=b.getElementsByTagName("a");
for(var d=0;
d<a.length;
d++){if(e){var c=new RegExp("(?:^|\\.)"+e.replace(/\./g,"\\.")+"$"),f=util.query.url(a[d].href).host,g=(f==e)||f.match(c);
if(!g){a[d].target="_blank"
}}else{a[d].target="_blank"
}}}function trackClickInIframe(d,c,a){a=a||document.body;
var b=$(d);
if(b){removeElement(b)
}var b=gDoc(a).createElement("iframe");
b.id=d;
b.style.position="absolute";
b.style.top="-1000px";
b.style.left="-1000px";
b.src=c;
a.appendChild(b)
}var g_currentUniqueId=1;
function getUniqueId(){return String(++g_currentUniqueId)
}function isDefined(a){return typeof a!="undefined"
}function isNumber(a){return typeof a=="number"||a instanceof Number
}function isString(a){return typeof a=="string"||a instanceof String
}function isFunction(a){return typeof a=="function"||a instanceof Function
}function isArray(b){return Object.prototype.toString.call(b)==="[object Array]"
}function callee(a){var c=a.callee,b=this;
return function(){return c.apply(b,a)
}
}function shallowCopy(b){var c={};
for(var a in b){c[a]=b[a]
}return c
}function argsToArray(a,b){b=b||0;
return Array.prototype.slice.call(a,b)
}function objectToArray(a){if(!a){return[]
}var c=[];
for(var b in a){if(a.hasOwnProperty(b)){c[c.length]=a[b]
}}return c
}function arrayToObject(b){if(!b){return{}
}var d={};
for(var c=0;
c<b.length;
c++){d[String(b[c])]=b[c]
}return d
}function isEmpty(a){if(!a){return true
}for(var b in a){if(a[b]!=null){return false
}}return true
}function copyProperties(d,c){for(var e in c){d[e]=c[e]
}}function doFunctions(b){if(!b){return true
}var d=argsToArray(arguments);
if(d){d=d.slice(1)
}var c=true;
for(var e=0;
e<b.length;
e++){if(b[e]){var a=b[e].apply(this,d);
c=c&&(typeof a!="boolean"||a)
}}return c
}function sprintf(){if(!arguments||arguments.length<1||!RegExp||!arguments[0]){return
}var b=arguments[0];
for(var a=1;
a<arguments.length;
a++){b=b.replace(new RegExp("%"+a,"g"),arguments[a]||"")
}return b
}function runInMainContext(){var b=null;
var c=arguments[0];
if(typeof c!="function"){b=arguments[0];
c=arguments[1];
if(typeof c=="string"){c=b[c]
}}var a=argsToArray(arguments).slice(b!=null?2:1);
setTimeout(function(){try{c.apply(b,a)
}catch(d){}},0)
}function createDelayedMethod(b,c,a){var d=function(){this[b]=createDelayedMethod.delayBind(this,c,a);
this[b].apply(this,arguments)
};
d.cancel=function(){};
return d
}createDelayedMethod.delayBind=function(c,d,a){a=a||0;
var b=function(){b.m_args=arguments;
if(a==0&&b.m_timeout!=null){return
}if(b.m_timeout){b.m_timeout.clear()
}b.m_timeout=new util.Timeout(b.run,a)
};
b.run=function(){b.cancel();
d.apply(c,b.m_args)
};
b.cancel=function(){if(b.m_timeout){b.m_timeout.clear();
b.m_timeout=null
}};
b.m_timeout=null;
return b
};
function createHandler(b){var a="m_on"+b;
var c="addOn"+b;
var e="removeOn"+b;
var d="on"+b;
if(!this[a]){this[a]=[]
}this[c]=function(f){this[a].push(f);
return f
};
this[e]=function(g){if(!g){this[a]=[];
return
}for(var f=this[a].length;
f>=0;
f--){if(this[a][f]==g){this[a].splice(f,1);
break
}}};
this[d]=function(){var f=argsToArray(arguments);
f.splice(0,0,this[a].slice());
doFunctions.apply(null,f)
}
}function createSetter(b,a){return function(d){if(this["m_"+b]==d){return
}var c=this["m_"+b];
this["m_"+b]=d;
if(a){gPubSub.publish(this,a,d,c)
}}
}if(typeof JSON=="undefined"){JSON={}
}if(!JSON.parse){JSON.parse=function(text){if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){return eval("("+text+")")
}}
}var getObjectAsStringStringReplace={'"':'\\"',"\\":"\\\\","\n":"\\n","\t":"\\t","\r":"\\r"};
var getObjectAsStringStringRegExp=/["\\\n\t\r]/g;
var getObjectAsStringStringFunction=function(a){return getObjectAsStringStringReplace[a]
};
if(!JSON.stringify){JSON.stringify=function(c){if(c&&typeof c.toJSON=="function"){return JSON.stringify(c.toJSON())
}else{if(typeof(c)=="string"){return'"'+c.replace(getObjectAsStringStringRegExp,getObjectAsStringStringFunction)+'"'
}else{if(c instanceof Array){var a=c.length;
var e=new Array(a);
for(var b=0;
b<a;
b++){e[b]=JSON.stringify(c[b])
}return"["+e.join(",")+"]"
}else{if(c==null){return"null"
}else{if(typeof(c)=="object"){var e=[];
for(var d in c){e.push(JSON.stringify(d)+":"+JSON.stringify(c[d]))
}return"{"+e.join(",")+"}"
}else{return String(c)
}}}}}}
}function isSpecialKey(a){return(!a||(a>=36&&a<=40)||a==45||a==46)
}function isArrowKey(a){return(a>=37&&a<=40)
}var modifier={ALT:1,CTRL:2,SHIFT:4};
function getFunctionKeysFromKeyEvent(b){var a=0;
if(b.altKey){a|=modifier.ALT
}if(b.ctrlKey||b.metaKey){a|=modifier.CTRL
}if(b.shiftKey){a|=modifier.SHIFT
}return a
}function rgbToHex(a){var c=/rgb\(([\d]+), ([\d]+), ([\d]+)\)/;
var b=a.match(c);
return"#"+toHex(b[1],2)+toHex(b[2],2)+toHex(b[3],2)
}function toHex(a,b){var d="0123456789ABCDEF";
var c=d.charAt(a&15);
while(a>15){a=a>>4;
c=d.charAt(a&15)+c
}while(c.length<b){c="0"+c
}return c
}function decToHex(a){if(typeof a=="string"){a=parseInt(a)
}return a.toString(16)
}function isInRect(d,c,a,f,b,e){if((d<a)||(d>=a+b)){return false
}if((c<f)||(c>=f+e)){return false
}return true
}function computeFileSize(b){var a=["K","M","G","T","P"];
var c=-1;
while(b/1024>1){b/=1024;
c++
}b=Math.floor(b*10)/10;
return b+" "+(c>-1?a[c]:"")+"B"
}util.session=new function(){var a="session";
this.get=function(){var b=util.storage.load(a);
if(!b){b=util.cookie.load(a)
}if(b){try{return JSON.parse(b)
}catch(c){}}return null
};
this.save=function(k){var h=this.get()||{};
if(!k){k={}
}h.key=k.key||gIMGateway.getSessionKey()||h.key;
var e=gLogon.getMeeboAccount();
var b=k.user||(e?e.getName():"");
if(h.user==b){var g=false;
var d=0;
for(var f;
f=h.network[d];
++d){if(f==gCIM.network){g=true;
break
}}if(!g){h.network[d]=gCIM.network
}}else{h.network=[gCIM.network];
h.user=b
}h.ts=new Date().getTime();
var c=JSON.stringify(h);
if(!util.storage.save(a,c)){util.cookie.save(a,c)
}return h
};
this.getMeeboAuthToken=function(){var d=util.cookie.load("mconnect")||util.storage.load("mconnect");
if(d){var c=d.split("&");
var e={};
e.mid=decodeURIComponent(c[0].split("=")[1]);
e.mat=decodeURIComponent(c[1].split("=")[1]);
if(c[2]){var b=parseInt(decodeURIComponent(c[2].split("=")[1]));
if(b<new Date().getTime()){util.storage.erase("mconnect");
return null
}}return e
}return null
};
this.setPartnerAuthToken=function(b){this.m_pat=b
};
this.getPartnerAuthToken=function(){return this.m_pat
}
};
(function(){if(window.google&&google.gears){return
}var a=null;
if(typeof navigator.mimeTypes!="undefined"&&navigator.mimeTypes["application/x-googlegears"]){a=document.createElement("object");
a.style.display="none";
a.width=a.height=0;
a.type="application/x-googlegears";
document.documentElement.appendChild(a)
}if(!a){return
}if(!window.google){google={}
}if(!google.gears){google.gears={factory:a}
}})();
util.storage=(function(){var d="meebo.com";
var h={version:"1",create:"CREATE TABLE IF NOT EXISTS localdata 			(k TEXT UNIQUE NOT NULL PRIMARY KEY, v TEXT NOT NULL)",get:"SELECT v FROM localdata WHERE k = ?",set:"INSERT INTO localdata(k, v) VALUES (?, ?)",remove:"DELETE FROM localdata WHERE k = ?",clear:"DELETE FROM localdata WHERE 1"};
if(window.globalStorage||window.localStorage){try{var b=window.localStorage||window.globalStorage[window.location.hostname]
}catch(f){}return{load:function(l){try{var k=b.getItem(l);
return window.localStorage?k:(k?k.value:null)
}catch(m){}},save:function(k,l){try{b.setItem(k,l);
return true
}catch(m){}},erase:function(k,l){try{b.removeItem(k);
return true
}catch(m){}},clear:function(){try{b.clear();
return true
}catch(k){}}}
}else{if(window.google&&google.gears){var a=null;
var g=function(l,e){if(!a){var k=google.gears.factory.hasPermission;
if(!k&&e){k=google.gears.factory.getPermission("Meebo","http://s.meebo.com/skin/beta/img/network/meebome_40_online.png",e)
}if(k){a=google.gears.factory.create("beta.database");
a.open(d);
a.execute(h.create).close()
}else{return false
}}a.execute("BEGIN");
l(a);
a.execute("COMMIT").close();
return true
};
return{load:function(e){var k=null;
g(function(l){var m=l.execute(h.get,[e]);
k=m.isValidRow()?m.field(0):null;
m.close()
});
return k
},save:function(k,m,e){var l=g(function(n){n.execute(h.remove,[k]);
n.execute(h.set,[k,m])
},e);
return l
},erase:function(e){var k=g(function(l){l.execute(h.remove,[e])
});
return k
},clear:function(){var e=g(function(k){k.execute(h.clear)
});
return e
}}
}else{if(document.documentElement.addBehavior){var c=function(k){try{var n=document.createElement("div");
document.body.appendChild(n);
n.addBehavior("#default#userData");
n.load(d);
var l=k(n);
n.save(d);
document.body.removeChild(n);
return l
}catch(m){return null
}};
return{load:function(e){return c(function(k){return k.getAttribute(e)
})
},save:function(e,k){c(function(l){l.setAttribute(e,k)
});
return true
},erase:function(e){c(function(k){k.removeAttribute(e)
});
return true
},clear:function(){c(function(e){var k=e.XMLDocument.documentElement.attributes;
for(var l=0;
l<k.length;
l++){e.removeAttribute(k[l].name)
}return true
})
}}
}else{return{load:function(e){return null
},save:function(e,k){return false
},erase:function(e){return false
},clear:function(){return false
},disabled:true}
}}}})();
function insertChar(e,b,d){if(!e){e=""
}if(d<=0){return b+e
}if(d>=e.length){return e+b
}var c=e.slice(0,d);
var a=e.slice(d);
return c+b+a
}function deleteChar(b,a){if(a<0){return b
}return b.slice(0,a-1)+b.slice(a)
}function parseGET(e){var a={};
var b=e.split("&");
for(var c=0;
c<b.length;
c++){var d=b[c].split("=");
a[d[0]]=decodeURIComponent(d[1])
}return a
}function stripWhitespace(a){return(a||"").replace(/(^\s+|\s+$)/g,"")
}function capitalize(a){if(!a||!a.length||!a.charAt){return a
}var b=a.charAt(0);
b=b.toUpperCase();
return b+a.substring(1)
}function isEmail(a){return a&&a.match(/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i)
}function unescapeHTML(b){var a={"&quot;":'"',"&lt;":"<","&gt;":">","&apos;":"'","&#39;":"'","&amp;":"&"};
if(!b||!b.length){return b
}return b.replace(/&(quot|lt|gt|apos|\#39|amp)\;/g,function(c){return a[c]
})
}function escapeHTML(h,m){if(!h||!h.length){return h
}var a={"&":"&amp;",'"':"&quot;","<":"&lt;",">":"&gt;","\n":"<br>","\r":"<br>","\r\n":"<br>"};
var n=/\r\n|[&"<>\r\n]/g;
if(m){var d,e=[];
while(d=n.exec(h)){e.push(d)
}for(var c=0,k;
(k=m[c]);
c++){var g=k.index,f=k.lastIndex;
for(var b=0,d;
(d=e[b]);
b++){var l=a[d[0]].length-d[0].length;
if(d.index<g){k.index+=l
}if(d.index<f){k.lastIndex+=l
}}}}return h.replace(n,function(o){return a[o]
})
}function removeHTML(b){if(!b){return b
}var a=unescapeHTML(b.replace(/<[^<>]+>/g,""));
return a
}function normalizeString(c){if(!c){return c
}var b=c.toLowerCase();
var a=b.replace(/\s/g,"");
return a
}function compressSpaces(a){return stripWhitespace(a).replace(/\s\s*/g," ")
}function isStringNumber(b){if(typeof b=="string"){return true
}var a=/^[0-9]+$/;
return(b.match(a)!=null)
}function linkify(a){return replaceLinks(a,findLinks(a))
}function findLinks(e){var d=[];
var a=function(h,g){var m={index:h.index+h[1].length,lastIndex:h.index+h[0].length,href:g+h[2]};
for(var k=d.length-1,l;
l=d[k];
--k){if(m.index>l.index){d.splice(k+1,0,m);
return
}}d.unshift(m)
};
var b;
var f=new RegExp('(^|[^\'"])(\\bhttps?://(?:[^\\s")<>(,;.:?\\!]|(?:[:");,.?!][^:\\s";)<>(,.?\\!])|(?:\\([^\\s";<>,.?\\!]*\\)))*)',"gi");
var c=new RegExp('(^|\\s+)((?:www(?:[-.]\\w+)+(?:\\.(?:[a-zA-Z]{2}|biz|com|info|name|net|org|pro|aero|asia|cat|coop|edu|gov|int|jobs|mil|mobi|museum|tel|travel)\\b)|(?!www)\\w+(?:[-.]\\w+)*(?:\\.(?:[a-zA-Z]{2,}\\.[a-zA-Z]{2}|biz|com|info|name|net|org|pro|aero|asia|cat|coop|edu|gov|int|jobs|mil|mobi|museum|tel|travel)\\b))(?:[^\\s")<>(,;.:?\\!]|(?:[:");,.?!][^:\\s";)<>(,.?\\!])|(?:\\([^\\s";<>,.?\\!]*\\)))*)',"gi");
while(b=f.exec(e)){a(b,"")
}while(b=c.exec(e)){a(b,"http://")
}return d
}function replaceLinks(h,d,c){var a=h.length;
var g="";
var b=0;
for(var e=0,f;
(f=d[e])&&f.index<a;
e++){g+=h.substring(b,f.index)+"<a"+(c?' class="'+c+'"':"")+' title="'+f.href+'" href="'+f.href+'" target="_blank">'+h.substring(f.index,f.lastIndex)+"</a>";
b=f.lastIndex
}g+=h.substring(b,a);
return g
}function isInsideTag(b,a){var f=b.lastIndexOf("<",a);
var d=b.lastIndexOf(">",a);
var c=b.indexOf("<",a);
var e=b.indexOf(">",a);
return !(d>=f&&c<=e)
}function isInsideEntity(b,a){var d=b.lastIndexOf("&",a-1);
var c=b.lastIndexOf(";",a-1);
return a&&c<d
}function decodeEntities(b){var a=decodeEntities.decoder;
a.innerHTML=b.replace(/</g,"&lt;").replace(/>/g,"&gt;");
return a.value
}decodeEntities.decoder=document.createElement("textarea");
function appendWbrUrl(d,e){var c;
var g=Array();
g[0]=/\b(https?:\/\/[^\s+\"\<\>]+)\b/ig;
g[1]=/\b(www\.[^\s+\"\<\>]+)\b/ig;
for(var b=0;
b<g.length;
b++){var f=0;
var a="";
while(c=g[b].exec(d)){a+=d.substr(f,c.index-f);
if(!isInsideTag(d,c.index)){a+=insertWbrText(c[1],e)
}else{a+=c[1]
}f=c.index+c[1].length
}a+=d.substr(f,d.length-f);
d=a
}return d
}function insertWbrText(e,d){var a=0;
var c="";
for(var b=0;
b<e.length;
b++){if(++a>=d&&!isInsideEntity(e,b)){a=0;
c+="<wbr>"
}c+=e.charAt(b)
}return c
}function pad(c,b){if(!c){c=""
}for(var a=0;
a<b;
a++){if(c.length==b){return c
}c="0"+c
}return c
}function isdigit(a){return((a>="0")&&(a<="9"))
}function insertTargets(a,b){if(!a||!a.indexOf){return a
}a=a.replace(/(<\s*a\s+[^>]*href\s*=\s*[\"\']?)([^\"\' >:]{5,6}[^:][^\"\' >:]+)/gi,"$1http://$2");
if(!b){b="_blank"
}a=a.replace(/<a /gi,'<a target="'+b+'" ');
return a
}function de(a){var b="";
for(i=0;
i<a.length;
i++){b+=String.fromCharCode(2^a.charCodeAt(i))
}return b
}function reverseString(c){var b="";
for(var a=c.length-1;
a>=0;
a--){b+=c.charAt(a)
}return b
}function makeTextSplittable(a){return a.replace(/(@|\/|\\)/g,"$1<wbr>")
}function escapeRegexp(b){if(!arguments.callee.sRE){var a=["/",".","*","+","?","|","^","$","(",")","[","]","{","}","\\"];
arguments.callee.sRE=new RegExp("(\\"+a.join("|\\")+")","g")
}return b.replace(arguments.callee.sRE,"\\$1")
}function ellipsize(b,a){if(b.length<=a){return b
}return(b.substr(0,a-1)+"...")
}function stringCompare(d,c){return(d<c)?-1:((d>c)?1:0)
}util.time={};
util.time.setTimestampString=function(c,b){var d=Math.floor((new Date().getTime()-b.getTime())/(1000*60)),h=Math.floor(d/60),l=Math.floor(h/24),a,k;
if(d<=0){a="less than a minute ago";
k=30*1000
}else{if(d<60){a=(d==1)?d+" minute ago":d+" minutes ago";
k=60*1000
}else{if(h<24){a=(h==1)?h+" hour ago":h+" hours ago";
k=30*60*1000
}else{if(l<30){a=(l==1)?l+" day ago":l+" days ago";
k=24*60*60*1000
}else{var g=b.getDate();
var e=b.getMonth();
var f=b.getFullYear();
a="on "+(e+1)+"/"+g+"/"+f;
k=false
}}}}setText(c,a);
return k
};
util.time.autoUpdateNode=function(b,a){var c=new util.Timeout();
util.time.autoUpdateNode.update(c,b,a);
return c
};
util.time.autoUpdateNode.update=function(d,c,b){var a=util.time.setTimestampString(c,b);
if(a&&d.run){d.run(hitch(util.time.autoUpdateNode,"update",d,c,b),a)
}};
function getTimeString(e,d){var f=Math.floor(e/(60*60*24));
e=e-(f*(60*60*24));
var a=Math.floor(e/(60*60));
e=e-(a*(60*60));
var b=Math.floor(e/60);
e=Math.floor(e-(b*60));
if(d){if(f>0){a=b=e=0
}else{if(a>0){b=e=0
}else{if(b>0){e=0
}}}}var c="";
if(f>0){c+=sprintf(((f==1)?gLang.timeDay:gLang.timeDays),f)
}if(a>0){if(c){c+=", "
}c+=sprintf(((a==1)?gLang.timeHour:gLang.timeHours),a)
}if(b>0){if(c){c+=", "
}c+=sprintf(((b==1)?gLang.timeMinute:gLang.timeMinutes),b)
}if(e>0){if(c){c+=", "
}c+=sprintf(((e==1)?gLang.timeSecond:gLang.timeSeconds),e)
}return c
}function getDayOfTheWeekString(a){return[gLang.sunday,gLang.monday,gLang.tuesday,gLang.wednesday,gLang.thursday,gLang.friday,gLang.saturday][a]
}function getMonthString(a){return[gLang.january,gLang.february,gLang.march,gLang.april,gLang.may,gLang.june,gLang.july,gLang.august,gLang.september,gLang.october,gLang.november,gLang.december][a]
}util.RSA={};
util.RSA.rsaEncrypt=(function(){var aj=2;
var I=16;
var l=I;
var t=1<<16;
var d=t>>>1;
var N=t*t;
var V=t-1;
var b=9999999999999998;
var n;
var ah;
var ab,af;
function s(am){n=am;
ah=new Array(n);
for(var al=0;
al<ah.length;
al++){ah[al]=0
}ab=new a();
af=new a();
af.digits[0]=1
}s(20);
var K=15;
var O=W(1000000000000000);
function a(al){if(typeof al=="boolean"&&al==true){this.digits=null
}else{this.digits=ah.slice(0)
}this.isNeg=false
}function o(ao){var an=ao.charAt(0)=="-";
var al=an?1:0;
var ap;
while(al<ao.length&&ao.charAt(al)=="0"){++al
}if(al==ao.length){ap=new a()
}else{var am=ao.length-al;
var aq=am%K;
if(aq==0){aq=K
}ap=W(Number(ao.substr(al,aq)));
al+=aq;
while(al<ao.length){ap=e(ak(ap,O),W(Number(ao.substr(al,K))));
al+=K
}ap.isNeg=an
}return ap
}function v(al){var am=new a(true);
am.digits=al.digits.slice(0);
am.isNeg=al.isNeg;
return am
}function W(am){var an=new a();
an.isNeg=am<0;
am=Math.abs(am);
var al=0;
while(am>0){an.digits[al++]=am&V;
am=Math.floor(am/t)
}return an
}function L(am){var an="";
for(var al=am.length-1;
al>-1;
--al){an+=am.charAt(al)
}return an
}var c=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
function u(am,ao){var al=new a();
al.digits[0]=ao;
var an=M(am,al);
var ap=c[an[1].digits[0]];
while(ae(an[0],ab)==1){an=M(an[0],al);
digit=an[1].digits[0];
ap+=c[an[1].digits[0]]
}return(am.isNeg?"-":"")+L(ap)
}function ai(am){var al=new a();
al.digits[0]=10;
var an=M(am,al);
var ao=String(an[1].digits[0]);
while(ae(an[0],ab)==1){an=M(an[0],al);
ao+=String(an[1].digits[0])
}return(am.isNeg?"-":"")+L(ao)
}var ad=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
function q(an){var al=15;
var am="";
for(i=0;
i<4;
++i){am+=ad[an&al];
an>>>=4
}return L(am)
}function F(al){var an="";
var ao=X(al);
for(var am=X(al);
am>-1;
--am){an+=q(al.digits[am])
}return an
}function A(at){var am=48;
var al=am+9;
var an=97;
var ar=an+25;
var aq=65;
var ao=65+25;
var ap;
if(at>=am&&at<=al){ap=at-am
}else{if(at>=aq&&at<=ao){ap=10+at-aq
}else{if(at>=an&&at<=ar){ap=10+at-an
}else{ap=0
}}}return ap
}function y(an){var ao=0;
var al=Math.min(an.length,4);
for(var am=0;
am<al;
++am){ao<<=4;
ao|=A(an.charCodeAt(am))
}return ao
}function m(ao){var ap=new a();
var al=ao.length;
for(var an=al,am=0;
an>0;
an-=4,++am){ap.digits[am]=y(ao.substr(Math.max(an-4,0),Math.min(an,4)))
}return ap
}function E(av,at){var al=av.charAt(0)=="-";
var ao=al?1:0;
var ar=new a();
var am=new a();
am.digits[0]=1;
for(var an=av.length-1;
an>=ao;
an--){var ap=av.charCodeAt(an);
var aq=A(ap);
var au=g(am,aq);
ar=e(ar,au);
am=g(am,at)
}ar.isNeg=al;
return ar
}function C(al){return(al.isNeg?"-":"")+al.digits.join(" ")
}function e(al,aq){var an;
if(al.isNeg!=aq.isNeg){aq.isNeg=!aq.isNeg;
an=p(al,aq);
aq.isNeg=!aq.isNeg
}else{an=new a();
var ap=0;
var ao;
for(var am=0;
am<al.digits.length;
++am){ao=al.digits[am]+aq.digits[am]+ap;
an.digits[am]=ao%t;
ap=Number(ao>=t)
}an.isNeg=al.isNeg
}return an
}function p(al,aq){var an;
if(al.isNeg!=aq.isNeg){aq.isNeg=!aq.isNeg;
an=e(al,aq);
aq.isNeg=!aq.isNeg
}else{an=new a();
var ap,ao;
ao=0;
for(var am=0;
am<al.digits.length;
++am){ap=al.digits[am]-aq.digits[am]+ao;
an.digits[am]=ap%t;
if(an.digits[am]<0){an.digits[am]+=t
}ao=0-Number(ap<0)
}if(ao==-1){ao=0;
for(var am=0;
am<al.digits.length;
++am){ap=0-an.digits[am]+ao;
an.digits[am]=ap%t;
if(an.digits[am]<0){an.digits[am]+=t
}ao=0-Number(ap<0)
}an.isNeg=!al.isNeg
}else{an.isNeg=al.isNeg
}}return an
}function X(al){var am=al.digits.length-1;
while(am>0&&al.digits[am]==0){--am
}return am
}function H(am){var ap=X(am);
var ao=am.digits[ap];
var al=(ap+1)*l;
var an;
for(an=al;
an>al-l;
--an){if((ao&32768)!=0){break
}ao<<=1
}return an
}function ak(at,ar){var aq=new a();
var ap;
var am=X(at);
var av=X(ar);
var au,al,an;
for(var ao=0;
ao<=av;
++ao){ap=0;
an=ao;
for(j=0;
j<=am;
++j,++an){al=aq.digits[an]+at.digits[j]*ar.digits[ao]+ap;
aq.digits[an]=al&V;
ap=al>>>I
}aq.digits[ao+am+1]=ap
}aq.isNeg=at.isNeg!=ar.isNeg;
return aq
}function g(al,aq){var ap,ao,an;
result=new a();
ap=X(al);
ao=0;
for(var am=0;
am<=ap;
++am){an=result.digits[am]+al.digits[am]*aq+ao;
result.digits[am]=an&V;
ao=an>>>I
}result.digits[1+ap]=ao;
return result
}function P(aq,ap,an,at,ar){var al=Math.min(ap+ar,aq.length);
for(var ao=ap,am=at;
ao<al;
++ao,++am){an[am]=aq[ao]
}}var Y=new Array(0,32768,49152,57344,61440,63488,64512,65024,65280,65408,65472,65504,65520,65528,65532,65534,65535);
function S(al,at){var ao=Math.floor(at/l);
var ar=new a();
P(al.digits,0,ar.digits,ao,ar.digits.length-ao);
var aq=at%l;
var an=l-aq;
for(var am=ar.digits.length-1,ap=am-1;
am>0;
--am,--ap){ar.digits[am]=((ar.digits[am]<<aq)&V)|((ar.digits[ap]&Y[aq])>>>(an))
}ar.digits[0]=((ar.digits[am]<<aq)&V);
ar.isNeg=al.isNeg;
return ar
}var B=new Array(0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535);
function ac(al,at){var an=Math.floor(at/l);
var aq=new a();
P(al.digits,an,aq.digits,0,al.digits.length-an);
var ap=at%l;
var ar=l-ap;
for(var am=0,ao=am+1;
am<aq.digits.length-1;
++am,++ao){aq.digits[am]=(aq.digits[am]>>>ap)|((aq.digits[ao]&B[ap])<<ar)
}aq.digits[aq.digits.length-1]>>>=ap;
aq.isNeg=al.isNeg;
return aq
}function J(al,an){var am=new a();
P(al.digits,0,am.digits,an,am.digits.length-an);
return am
}function f(al,an){var am=new a();
P(al.digits,an,am.digits,0,am.digits.length-an);
return am
}function w(al,an){var am=new a();
P(al.digits,0,am.digits,0,an);
return am
}function ae(al,an){if(al.isNeg!=an.isNeg){return 1-2*Number(al.isNeg)
}for(var am=al.digits.length-1;
am>=0;
--am){if(al.digits[am]!=an.digits[am]){if(al.isNeg){return 1-2*Number(al.digits[am]>an.digits[am])
}else{return 1-2*Number(al.digits[am]<an.digits[am])
}}}return 0
}function M(ar,aq){var am=H(ar);
var ap=H(aq);
var an=aq.isNeg;
var aw,au;
if(am<ap){if(ar.isNeg){aw=v(af);
aw.isNeg=!aq.isNeg;
ar.isNeg=false;
aq.isNeg=false;
au=p(aq,ar);
ar.isNeg=true;
aq.isNeg=an
}else{aw=new a();
au=v(ar)
}return new Array(aw,au)
}aw=new a();
au=ar;
var at=Math.ceil(ap/l)-1;
var al=0;
while(aq.digits[at]<d){aq=S(aq,1);
++al;
++ap;
at=Math.ceil(ap/l)-1
}au=S(au,al);
am+=al;
var az=Math.ceil(am/l)-1;
var aE=J(aq,az-at);
while(ae(au,aE)!=-1){++aw.digits[az-at];
au=p(au,aE)
}for(var aD=az;
aD>at;
--aD){var av=(aD>=au.digits.length)?0:au.digits[aD];
var aC=(aD-1>=au.digits.length)?0:au.digits[aD-1];
var aB=(aD-2>=au.digits.length)?0:au.digits[aD-2];
var aA=(at>=aq.digits.length)?0:aq.digits[at];
var ao=(at-1>=aq.digits.length)?0:aq.digits[at-1];
if(av==aA){aw.digits[aD-at-1]=V
}else{aw.digits[aD-at-1]=Math.floor((av*t+aC)/aA)
}var ay=aw.digits[aD-at-1]*((aA*t)+ao);
var ax=(av*N)+((aC*t)+aB);
while(ay>ax){--aw.digits[aD-at-1];
ay=aw.digits[aD-at-1]*((aA*t)|ao);
ax=(av*t*t)+((aC*t)+aB)
}aE=J(aq,aD-at-1);
au=p(au,g(aE,aw.digits[aD-at-1]));
if(au.isNeg){au=e(au,aE);
--aw.digits[aD-at-1]
}}au=ac(au,al);
aw.isNeg=ar.isNeg!=an;
if(ar.isNeg){if(an){aw=e(aw,af)
}else{aw=p(aw,af)
}aq=ac(aq,al);
au=p(aq,au)
}if(au.digits[0]==0&&X(au)==0){au.isNeg=false
}return new Array(aw,au)
}function h(al,am){return M(al,am)[0]
}function z(al,am){return M(al,am)[1]
}function R(am,an,al){return z(ak(am,an),al)
}function G(al,ao){var an=af;
var am=al;
while(true){if((ao&1)!=0){an=ak(an,am)
}ao>>=1;
if(ao==0){break
}am=ak(am,am)
}return an
}function D(am,aq,al){var ap=af;
var an=am;
var ao=aq;
while(true){if((ao.digits[0]&1)!=0){ap=R(ap,an,al)
}ao=ac(ao,1);
if(ao.digits[0]==0&&X(ao)==0){break
}an=R(an,an,al)
}return ap
}function ag(al){this.modulus=v(al);
this.k=X(this.modulus)+1;
var am=new a();
am.digits[2*this.k]=1;
this.mu=h(am,this.modulus);
this.bkplus1=new a();
this.bkplus1.digits[this.k+1]=1;
this.modulo=Z;
this.multiplyMod=x;
this.powMod=Q
}function Z(at){var ar=f(at,this.k-1);
var ap=ak(ar,this.mu);
var ao=f(ap,this.k+1);
var an=w(at,this.k+1);
var au=ak(ao,this.modulus);
var am=w(au,this.k+1);
var al=p(an,am);
if(al.isNeg){al=e(al,this.bkplus1)
}var aq=ae(al,this.modulus)>=0;
while(aq){al=p(al,this.modulus);
aq=ae(al,this.modulus)>=0
}return al
}function x(al,an){var am=ak(al,an);
return this.modulo(am)
}function Q(al,ap){var ao=new a();
ao.digits[0]=1;
var am=al;
var an=ap;
while(true){if((an.digits[0]&1)!=0){ao=this.multiplyMod(ao,am)
}an=ac(an,1);
if(an.digits[0]==0&&X(an)==0){break
}am=this.multiplyMod(am,am)
}return ao
}function k(am,an,al){this.e=m(am);
this.d=m(an);
this.m=m(al);
this.digitSize=2*X(this.m)+2;
this.chunkSize=this.digitSize-11;
this.radix=16;
this.barrett=new ag(this.m)
}function U(al){return(al<10?"0":"")+String(al)
}function T(ax,aC){if(ax.chunkSize>ax.digitSize-11){return"Error"
}var aw=new Array();
var am=aC.length;
var aq=0;
while(aq<am){aw[aq]=aC.charCodeAt(aq);
aq++
}var ar=aw.length;
var au="";
var ap,ao,an;
for(aq=0;
aq<ar;
aq+=ax.chunkSize){an=new a();
ap=0;
var av;
var aB=(aq+ax.chunkSize)>ar?ar%ax.chunkSize:ax.chunkSize;
var at=new Array();
for(av=0;
av<aB;
av++){at[av]=aw[aq+aB-1-av]
}at[aB]=0;
var aA=Math.max(8,ax.digitSize-3-aB);
for(av=0;
av<aA;
av++){at[aB+1+av]=Math.floor(Math.random()*254)+1
}at[ax.digitSize-2]=2;
at[ax.digitSize-1]=0;
for(ao=0;
ao<ax.digitSize;
++ap){an.digits[ap]=at[ao++];
an.digits[ap]+=at[ao++]<<8
}var az=ax.barrett.powMod(an,ax.e);
var ay=ax.radix==16?F(az):u(az,ax.radix);
au+=ay+" "
}return au.substring(0,au.length-1)
}function aa(ao){if(!ao){return""
}var al=arguments.callee.cache;
if(!al){al=arguments.callee.cache={}
}if(ao in al){return al[ao]
}var an=new Date().getTime();
s(160);
var ap=new k("25","","00846e46d25bc8743ac45c12c5ae9acbdb1ae2d632d9fdda3bc50ad0c02afbb3060ac5350af7d774014e4c01feef522edbc8f68d3b066025066b78e3de201fa2ec5e0f2006599c9f993ca18316ee940be6f7185b2fbd797fb692740da782e0c41b33e8b2dcb392f93b650526a4470ea9b6ae510dc6c84a69f0b1f27b3dbb43f615");
var am=T(ap,ao);
al[ao]=am;
return am
}return aa
})();
util.sha={};
util.sha.sha256=(function(){var n=8;
function l(q,u){var t=(q&65535)+(u&65535);
var s=(q>>16)+(u>>16)+(t>>16);
return(s<<16)|(t&65535)
}function e(s,q){return(s>>>q)|(s<<(32-q))
}function g(s,q){return(s>>>q)
}function a(q,t,s){return((q&t)^((~q)&s))
}function f(q,t,s){return((q&t)^(q&s)^(t&s))
}function b(q){return(e(q,2)^e(q,13)^e(q,22))
}function h(q){return(e(q,6)^e(q,11)^e(q,25))
}function m(q){return(e(q,7)^e(q,18)^g(q,3))
}function p(q){return(e(q,17)^e(q,19)^g(q,10))
}function d(s,t){var G=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298);
var u=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225);
var q=new Array(64);
var H,F,E,D,B,z,y,x,w,v;
var C,A;
s[t>>5]|=128<<(24-t%32);
s[((t+64>>9)<<4)+15]=t;
for(var w=0;
w<s.length;
w+=16){H=u[0];
F=u[1];
E=u[2];
D=u[3];
B=u[4];
z=u[5];
y=u[6];
x=u[7];
for(var v=0;
v<64;
v++){if(v<16){q[v]=s[v+w]
}else{q[v]=l(l(l(p(q[v-2]),q[v-7]),m(q[v-15])),q[v-16])
}C=l(l(l(l(x,h(B)),a(B,z,y)),G[v]),q[v]);
A=l(b(H),f(H,F,E));
x=y;
y=z;
z=B;
B=l(D,C);
D=E;
E=F;
F=H;
H=l(C,A)
}u[0]=l(H,u[0]);
u[1]=l(F,u[1]);
u[2]=l(E,u[2]);
u[3]=l(D,u[3]);
u[4]=l(B,u[4]);
u[5]=l(z,u[5]);
u[6]=l(y,u[6]);
u[7]=l(x,u[7])
}return u
}function k(u){var t=Array();
var q=(1<<n)-1;
for(var s=0;
s<u.length*n;
s+=n){t[s>>5]|=(u.charCodeAt(s/n)&q)<<(24-s%32)
}return t
}function o(u){var s=0;
var t=s?"0123456789ABCDEF":"0123456789abcdef";
var v="";
for(var q=0;
q<u.length*4;
q++){v+=t.charAt((u[q>>2]>>((3-q%4)*8+4))&15)+t.charAt((u[q>>2]>>((3-q%4)*8))&15)
}return v
}function c(q){return o(d(k(q),q.length*n))
}return function(q){return c(q)
}
})();
util.flash={};
util.flash.m_version=null;
util.flash.getVersion=function(){if(util.flash.m_version){return util.flash.m_version
}var b=[0,0,0];
try{if(navigator.plugins&&navigator.mimeTypes.length){var a=navigator.plugins["Shockwave Flash"];
if(a&&a.description){b=a.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split(".")
}}else{try{var c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")
}catch(d){try{var c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
b=[6,0,21];
c.AllowScriptAccess="always"
}catch(d){b[0]=4;
return b
}try{c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")
}catch(d){}}if(c!=null){b=c.GetVariable("$version").split(" ")[1].split(",")
}}}catch(d){}return(util.flash.m_version={major:b[0],minor:b[1],rev:b[2]})
};
util.flash.m_movieId=0;
util.flash.embed=function(c){c.win=c.win||gWin(c.parent);
c.width=c.width||1;
c.height=c.height||1;
c.wmode=c.wmode||"transparent";
c.id=c.id||"meeboFlashMovie"+(util.flash.m_movieId++);
c.flashVars=c.flashVars||{};
if(c.onReady){if(!c.win.__meeboFlashCallbackManager){c.win.__meeboFlashCallbackManager=new lib.CallbackManager()
}var a=c.win.__meeboFlashCallbackManager.scheduleCallback(c.onReady);
c.flashVars.callback=a
}var f=c.win.document;
var k=f.createElement("div");
if(c.style){for(var g in c.style){k.style[g]=c.style[g]
}}var b=getObjectAsURIParams(c.flashVars);
var e='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="'+c.id+'" width="'+c.width+'" height="'+c.height+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="movie" value="'+c.swfUrl+'" /><param name="quality" value="high" /><param name="wmode" value="'+c.wmode+'" /><param name="FlashVars" value="'+b+'" /><embed wmode="'+c.wmode+'" src="'+c.swfUrl+'" FlashVars="'+b+'" quality="high" width="'+c.width+'" height="'+c.height+'" swLiveConnect=true id="'+c.id+'" name="'+c.id+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" /></object>';
var h=c.parent||f.body;
if(c.insertBefore){h.insertBefore(k,c.insertBefore)
}else{h.appendChild(k)
}k.innerHTML=e;
var d=ui.isIE?c.win[c.id]:f[c.id];
if(!d&&c.onError){c.onError()
}return d
};
util.flash.getParent=function(a){var b=a;
while(b=b.parentNode){if(b.tagName=="DIV"){return b
}}};
var ComScore={m_tracked:false,track:function(a){if(this.m_tracked||!gConfig.getReleaseType().length){return
}this.m_tracked=true;
var c={c1:"7",c2:"5964888",c3:a,c4:"",c5:"",c6:"",c15:""};
var b=(document.location.protocol=="https:"?"https://sb":"http://b")+".scorecardresearch.com/beacon.js";
new ui.TrackingPixel(c,b,false,true).create()
},CORE_ID:1,CIM_ID:2};
util.notifications={};
util.notifications.displayMessage=function(d,g,e,c,a){e=e.match("http")?e:document.location.protocol+"//"+document.location.hostname+e;
var b=d+g;
var f=d+" says";
if(ui.isFluid){window.fluid.showGrowlNotification({title:f,description:g,priority:1,sticky:false,identifier:b,icon:e,onclick:function(){window.fluid.activate();
if(a){a()
}}})
}else{if(ui.isPrism){window.platform.showNotification(f,g,e)
}}};
Class("util._Timer",function(a){this.initialize=function(c,b){this.m_win=window;
if(c){this.run(c,b)
}};
this.run=function(c,b){this.m_timer=this.m_win["set"+this.m_type](hitch(this.m_win,c),b)
};
this.clear=function(){if(this.m_timer){this.m_win["clear"+this.m_type](this.m_timer);
this.m_timer=null;
this.run=null
}}
});
Class("util.Timeout",util._Timer,function(a){this.m_type="Timeout"
});
Class("util.Interval",util._Timer,function(a){this.m_type="Interval"
});
Class("util.FacebookConnect",lib.Publisher,function(a){var d=0,c=1,b=2;
this.initialize=function(h,g,e,f){a(this,"initialize");
this.m_win=g||window;
this.m_fbLoaded=d;
this.m_isConnecting=false;
this.m_show=[];
this.m_apiKey=h;
this.m_requiredPermissions=e||[];
this.m_requiredInfo=f||[];
this.m_info=null;
this.m_autoRequireConnect=true
};
this.setAutoRequireConnect=function(e){this.m_autoRequireConnect=e;
return this
};
this.loadFeatureLoader=function(){if(this.m_fbLoaded!=d){return
}this.m_fbLoaded=c;
var h=this.m_win.document;
var f=h.createElement("script");
f.type="text/javascript";
var g="//"+(h.location.protocol=="https:"?"www":"static.ak")+".connect.facebook.com";
f.src=g+"/js/api_lib/v0.4/FeatureLoader.js.php";
var e=false;
f.onload=f.onreadystatechange=hitch(this,function(){if(!e&&(!f.readyState||f.readyState=="loaded"||f.readyState=="complete")){this.initFB();
e=true
}});
h.documentElement.firstChild.appendChild(f);
this.publish("loading")
};
this.initFB=function(){document.write=function(){};
this.m_win.FB_RequireFeatures(["Connect"],hitch(this,function(){var f=this.m_win.document;
if(!f.getElementById("FB_HiddenContainer")){var g=f.createElement("div");
g.id="FB_HiddenContainer";
var e=g.style;
e.position="absolute";
e.top="-10000px";
e.width="0px";
e.height="0px";
f.body.appendChild(g)
}this.m_win.FB.Facebook.init(this.m_apiKey,"/facebook_xd_receiver.html",{ifUserConnected:hitch(this,"fbInited",true),ifUserNotConnected:hitch(this,"fbInited",false)})
}))
};
this.fbInited=function(e){if(this.m_fbLoaded==b){return
}this.m_fbLoaded=b;
this.m_win.FB.Connect.get_status().add_changed(hitch(this,"onStatusChanged"));
this.m_win.FB.Facebook.apiClient.get_sessionWaitable().add_changed(hitch(this,"onSessionChanged"));
gPubSub.subscribe("meebo.Logon::changeState",this,"onLogonChangeState");
if(this.m_autoRequireConnect){this.requireConnect(e)
}this.publish("loaded")
};
this.onStatusChanged=function(e){if(this.m_loggingOut){return
}if(e.result!=this.m_win.FB.ConnectState.connected){this.requireConnect(false)
}};
this.onSessionChanged=function(f){var e=f.result;
if(this.m_loggingOut){return
}if(!e){this.m_info=null;
this.requireConnect(false)
}else{if(this.m_isConnecting&&(!this.m_info||e.uid!=this.m_info.uid)){this.onSession()
}else{if(this.m_info){this.m_info.sessionKey=e.session_key
}}}};
this.onSession=function(){this.publish("loading");
this.m_info={uid:util.cookie.load(this.m_apiKey+"_user"),sessionKey:util.cookie.load(this.m_apiKey+"_session_key")};
if(!this.m_info.uid||!this.m_info.sessionKey){var e=this.m_win.FB.Facebook.apiClient.get_session();
if(e&&e.uid&&e.session_key){this.m_info.uid=e.uid;
this.m_info.sessionKey=e.session_key
}}if(this.m_requiredInfo.length){this.m_win.FB.Facebook.apiClient.users_getInfo([this.m_info.uid],this.m_requiredInfo,hitch(this,"onGetInfo"))
}else{this.requirePermissions()
}};
this.requirePermissions=function(){if(this.m_requiredPermissions.length){this.m_win.FB.Connect.showPermissionDialog(this.m_requiredPermissions.join(","),hitch(this,"onPermission"));
var e=this.m_win.FB.SessionDialog._singleton._connect._permissionDialog;
this.publish("resize",e._popupWidth,e._popupHeight);
e.sizing()
}else{this.onAuth()
}};
this.onPermission=function(g){g=arrayToObject((g||"").split(","));
for(var e=0,f;
(f=this.m_requiredPermissions[e]);
e++){this.m_info[f]=f in g
}this.onAuth()
};
this.onGetInfo=function(g,e){if(e){return
}var f=g[0];
if(this.m_info.uid==f.uid){for(var h in f){this.m_info[h]=f[h]
}}this.requirePermissions();
this.publish("loaded")
};
this.hasInfo=function(){if(!this.m_info){return false
}for(var e=0,f;
(f=this.m_requiredPermissions[e]);
e++){if(typeof this.m_info[f]!="boolean"){return false
}if(!this.m_info[f]){break
}}var g=this.m_win.FB.Facebook.apiClient.get_session();
if(g&&this.m_info.offline_access&&g.expires!=0){this.m_win.FB.Facebook.apiClient._session=null;
this.m_win.FB.Connect._singleton._loginStatusIFrameCreated=false;
this.m_win.FB.Connect._singleton._refreshQueryStatus();
return false
}for(var e=0,h;
(h=this.m_requiredInfo[e]);
e++){if(!this.m_info[h]){return false
}}return this.m_info.uid&&this.m_info.sessionKey
};
this.onAuth=function(){if(!this.hasInfo()){return
}this.publish("auth",this.m_info)
};
this.onCancel=function(){this.publish("cancel")
};
this.onLogonChangeState=function(g,f,k,h){if(k=="error"&&g.getNetwork()=="facebook"){var l=g.getLastError();
if(l.description=="Session key invalid or no longer valid"&&l.type==16){this.clearInfo()
}}};
this.setRequiredPermissions=function(e){this.m_requiredPermissions=e;
return this
};
this.show=function(e){this.loadFeatureLoader();
this.m_show.push(e)
};
this.hide=function(e){for(var f=this.m_show.length-1;
f>=0;
f--){if(this.m_show[f]==e){this.m_show.splice(f,1)
}}if(!this.m_show.length){if(this.m_fbLoaded==b){this.m_win.FB.SessionDialog.closeAll()
}this.m_isConnecting=false
}};
this.connect=function(e){this.m_loggingOut=false;
this.m_isConnecting=true;
if(this.m_fbLoaded!=b){this.loadFeatureLoader()
}else{this.requireConnect()
}};
this.requireConnect=function(e){if(!this.m_isConnecting){return
}if(this.m_info){for(var f=0;
f<this.m_requiredPermissions.length;
f++){var g=this.m_requiredPermissions[f];
if(typeof this.m_info[g]=="boolean"&&!this.m_info[g]){this.m_info[g]=null
}}}if(!e&&this.m_win.FB.Connect.get_status().get_isReady()&&this.m_win.FB.Connect.get_status().result==this.m_win.FB.ConnectState.connected&&this.m_win.FB.Facebook.apiClient.get_session()){e=true
}if(this.hasInfo()){this.onAuth()
}else{if(e||this.m_info&&this.m_info.uid&&this.m_info.sessionKey){this.onSession()
}else{this.m_win.FB.Connect.requireSession(null,hitch(this,"onCancel"),true)
}}};
this.clearInfo=function(){this.m_info=null;
util.cookie.erase(this.m_apiKey+"_user");
util.cookie.erase(this.m_apiKey+"_session_key");
util.cookie.erase(this.m_apiKey+"_expires");
util.cookie.erase(this.m_apiKey+"_ss");
util.cookie.erase(this.m_apiKey)
};
this.logout=function(e){if(this.m_fbLoaded==b){this.m_loggingOut=true;
this.m_win.FB.Connect.logout(hitch(this,function(){this.m_loggingOut=false;
if(e){e()
}}));
this.clearInfo()
}else{}};
this.isFbLoaded=function(){return(this.m_fbLoaded==b)
};
this.getCDN=function(){return ui.isHttps?"https://www.facebook.com":"http://static.ak.fbcdn.net"
};
this.getSessionRecord=function(){return this.m_win.FB.Facebook.apiClient.get_session()
};
this.checkPermissions=function(f,h){var e="publish_stream,read_stream,email,read_mailbox,offline_access,create_event,rsvp_event,sms,status_update,photo_upload,video_upload,create_note,share_item,xmpp_login";
var g=hitch(this,function(l){if(l&&l.length){if(this.m_info){for(var k in l[0]){this.m_info[k]=!!l[0][k]
}}h(l[0])
}});
this.m_win.FB.Facebook.apiClient.fql_query("SELECT "+e+" FROM permissions WHERE uid = "+f,g)
}
});
util.openPopup=function(o,m){var o=o||{},f=calcWinPos(window),k=o.loadingMsg,b=o.url,g=o.id=(o.id||"W"+getUniqueId()).replace(/[^A-Za-z0-9]/g,"_"),d=Math.max(f.w-200,800),q=Math.max(f.h-150,600),h={menubar:"no",location:"no",toolbar:"no",scrollbars:"yes",status:"yes",width:d,height:q,left:Math.max(f.x+50,f.x+Math.floor((f.w-d)/2)),top:Math.max(f.y+50,f.y+Math.floor((f.h-q)/2)),resizable:"yes"},l=[];
for(var s in h){if(!m||s in o){l.push(s+"="+(s in o?o[s]:h[s]))
}}if(!b){var a="";
if(gCIM.domain){a="document.domain='"+gCIM.domain+"';"
}b="javascript:document.open();"+a+"document.write(\"<html><body style='font:13px tahoma,sans-serif'>"+(k||gLang.loadingLink)+'");'
}try{var c=window.open(b,g,l.join(","));
if(c){c.focus()
}}catch(n){}return c
};
util.getConnectWinParams=function(d,f,b){var c=calcWinPos(d),a=Math,e={width:390,height:354,loadingMsg:gLang.connecting+"\u2026",left:c.x+a.max(a.floor((c.w-390)/2),0),top:c.y+a.max(a.floor((c.h-354)/2),0)};
if(f){e.id=f
}if(b){e.url=b
}return e
};
var gLog=false;
var gEventLog=false;
var gNetworkLog=false;
var gDebug=false;
var gLogTimer={};
var gDebugger;
function eventlog(a){if(!gEventLog||!gDebugger){return false
}gDebugger.addText(a);
gDebugger.m_dlg.showWindow(true);
return true
}function networklog(a){if(!gNetworkLog||!gDebugger){return false
}gDebugger.addText(a);
gDebugger.m_dlg.showWindow(true);
return true
}function startlogtime(b,a){gLogTimer[b]={time:a||new Date().getTime(),timing:true}
}function stoplogtime(a){gLogTimer[a].time=new Date().getTime()-gLogTimer[a].time;
gLogTimer[a].timing=false;
return gLogTimer[a].time
}function islogtiming(a){return gLogTimer[a]&&gLogTimer[a].timing
}function clearlogtime(a){delete gLogTimer[a]
}function log(a){if(!gLog||!gDebugger){return false
}var b=Array.prototype.join.call(arguments," ");
gDebugger.addText(b,null,false,false);
gDebugger.m_dlg.showWindow(true);
return true
}log.timedelta=function(a){function b(d,e){d=String(d);
e=e||2;
while(d.length<e){d="0"+d
}return d
}var c=new Date().getTime()-a;
return b(Math.floor(c/60000))+":"+b(Math.floor((c%60000)/1000))+"."+b(Math.floor(c%1000),3)
};
function logSpeed(){startTime=typeof startTime=="number"?startTime:0;
var a=log.timedelta(startTime)+" "+Array.prototype.join.call(arguments," ");
log(a)
}function initDebugging(b,a,e,c){var d=["meeboApp.debugDlg"];
if(c){d.push("meeboApp.debugEvents")
}gWindowMgr.loadObjects(d,function(){gLog=b;
gEventLog=a;
gNetworkLog=e;
gDebug=c;
if(!gDebugger&&(gLog||gEventLog||gNetworkLog)){try{gWindowMgr.createDebugDlg()
}catch(f){}}})
}net={};
net.getTransportLayer=function(){return this.m_transportLayer
};
net.use=function(a){this.m_transportLayer=a
};
net.post=function(a,b){a.method="POST";
this.request(a,b)
};
net.get=function(a,b){a.method="GET";
this.request(a,b)
};
net.abort=function(a){if(a&&a.transport){a.transport.abort(a)
}};
net.request=function(a,b){if(a.inflight){net.abort(a)
}a.timestamp=new Date().getTime();
a.aborted=false;
a.id=null;
if(!a.transport){a.transport=this.m_transportLayer
}return a.transport.request(a,b)
};
net.abortOnTimeout=function(a,b){if(a.timeout>0){a.timeoutTimer=setTimeout(function(){net.abort(a);
if(b){b(null,new net.RequestError("request timed out",1))
}},a.timeout)
}};
net.clearTimeout=function(a){clearTimeout(a.timeoutTimer)
};
net.doSslCheck=function(){return this.m_transportLayer.doSslCheck&&this.m_transportLayer.doSslCheck()
};
net.buildGetQuery=function(b){var c=b.url.split("?");
var a=this.buildQuery(b,c[1]);
if(!a){return b.url
}return c[0]+"?"+a
};
net.buildQuery=function(d,a){var c=[];
if(a){c.push(a)
}for(var b in d.args){var e=encodeURIComponent(b)+"="+encodeURIComponent(d.args[b]);
if(b=="sessionKey"){c.unshift(e)
}else{c.push(e)
}}return c.join("&")
};
net.REQUEST_ERROR=1;
net.SERVER_ERROR=2;
net.EVAL_ERROR=3;
net.RequestError=function(b,a){return{msg:b,code:a}
};
net.Request=function(a){return{inflight:false,aborted:false,err:null,responseType:null,args:a||{},sync:false,timeout:20000,timeoutTimer:null,timestamp:null,url:null,transport:null}
};
net.XHRTransport=new function(){this.m_id=0;
this.m_xhrs={};
this.XHRResource=new lib.ResourceManager(function(callback){var xhr=null;
if(typeof XMLHttpRequest!="undefined"){try{xhr=new XMLHttpRequest()
}catch(e){}}else{if(typeof Components!="undefined"){xhr=Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance();
xhr.QueryInterface(Components.interfaces.nsIXMLHttpRequest)
}}if(!xhr&&typeof ActiveXObject!="undefined"){try{xhr=new ActiveXObject("Msxml2.XMLHTTP")
}catch(e){}if(!xhr){try{xhr=new ActiveXObject("Microsoft.XMLHTTP")
}catch(e){}}}if(!xhr){alert("Meebo does not support your browser yet.  Stay tuned!")
}else{callback(xhr)
}});
this.recycleXHR=function(xhr){xhr.onreadystatechange=function(){};
this.XHRResource.recycle(xhr)
};
this.abort=function(request){if(!request){return
}var xhr=this.m_xhrs[request.xhrId];
if(!xhr){return
}delete this.m_xhrs[request.xhrId];
if(!request.aborted){request.xhrId=null;
request.aborted=true;
try{xhr.abort()
}catch(e){}if(!request.err){this.recycleXHR(xhr)
}}net.clearTimeout(request);
request.inflight=false
};
this.request=function(request,callback,xhr){if(!xhr||(xhr.readyState!=4&&xhr.readyState!=0)){this.XHRResource.getOne(hitch(this,this.request,request,callback));
return
}if(!callback){callback=function(){}
}if(!/^https?:/i.test(request.url)){request.url=window.location.protocol+"//"+document.domain+(window.location.port?":"+window.location.port:"")+request.url
}var id="X"+(this.m_id++);
this.m_xhrs[id]=xhr;
request.xhrId=id;
request.inflight=true;
if(request.method=="POST"){xhr.open(request.method,request.url,!request.sync)
}else{xhr.open("GET",net.buildGetQuery(request),!request.sync)
}xhr.onreadystatechange=hitch(this,onReadyStateChange,this.m_xhrs[id],request,callback);
xhr.setRequestHeader("If-Modified-Since",new Date(0));
if(request.args&&request.method=="POST"){xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
}try{net.abortOnTimeout(request,callback);
xhr.send(request.method=="POST"?net.buildQuery(request):null)
}catch(e){request.err=new net.RequestError("could not send",1);
this.abort(request);
throw request.err
}};
function getResponse(xhr,request){try{xhr.readyState
}catch(e){throw new net.RequestError("could not access readyState",1)
}if(xhr.readyState!=4){return null
}try{var status=xhr.status
}catch(e){throw new net.RequestError("could not access status",1)
}if(Math.floor(status/100)==5){throw new net.RequestError("status was 5xx",2)
}if(status!=200){throw new net.RequestError("status was "+status,1)
}var responseType=request.responseType;
var contentType=(xhr.getResponseHeader("Content-Type")||"").match(/[-a-z]+\/[-a-z]+/i);
if(contentType){contentType=contentType[0]
}else{if(!responseType){throw new net.RequestError("could not access content type",1)
}}try{var response=contentType=="text/xml"?xhr.responseXML:xhr.responseText
}catch(e){throw new net.RequestError("could not examine responseText",1)
}if(responseType=="text/plain"){return response
}else{if(responseType=="application/json"){try{response=eval("("+response+")")
}catch(e){var error=new net.RequestError("eval error",3);
error.e=e;
error.response=response;
throw error
}}else{if(contentType=="text/javascript"||contentType=="application/javascript"||contentType=="application/x-javascript"){eval(response)
}}}return response
}function onReadyStateChange(xhr,request,callback){if(request.aborted){return
}try{var response=getResponse(xhr,request);
if(response!=null){net.clearTimeout(request);
request.inflight=false;
callback(response);
this.recycleXHR(xhr)
}}catch(e){if(typeof net!="undefined"){net.clearTimeout(request);
request.inflight=false;
callback(null,e)
}}}this.destroy=function(){for(var xhr in this.m_xhrs){this.m_xhrs[xhr].abort()
}};
this.doSslCheck=function(){if(/\.meebo\.com$/i.test(document.domain)){if(gNetworkMgr.getProtocol()=="https:"){gNetworkMgr.enableLoginWithSsl();
return
}setTimeout(hitch(this,"requestSslIframe"),0)
}};
this.requestSslIframe=function(){enableLoginWithSsl=hitch(this,function(){gNetworkMgr.enableLoginWithSsl();
this.destroySslIframe()
});
var iframe=document.createElement("iframe");
iframe.style.position="absolute";
iframe.style.left="-5000px";
iframe.style.top="-5000px";
document.body.appendChild(iframe);
this.m_sslTestIframe=iframe;
iframe.src="https://"+document.domain+"/httpstest.html?"+String(new Date().getTime());
if(window.attachEvent){window.attachEvent("onunload",hitch(this,"destroySslIframe"))
}};
this.destroySslIframe=function(){if(this.m_sslTestIframe){document.body.removeChild(this.m_sslTestIframe);
this.m_sslTestIframe=null
}}
};
if(!net.getTransportLayer()){net.use(net.XHRTransport)
}net.FormTransport=new function(){this.m_id=0;
this.m_callbacks={};
this.m_init=false;
this.m_doc=document;
this.abort=function(request){request.aborted=true;
request.inflight=false;
if(ui.isWebKit){setTimeout(hitch(this,"cleanup",request),60000)
}else{this.cleanup(request)
}};
this.cleanup=function(request){var data=this.m_callbacks[request.formId];
if(data){removeElement(data.iframe);
removeElement(data.form);
if(data.xdPostRequest){net.abort(data.xdPostRequest)
}}delete this.m_callbacks[request.formId]
};
this.request=function(request,callback){if(!request.url.match("^https?://")){return
}if(!this.m_init){this.m_init=true;
this.tryHtmlFile()
}var doc=this.m_doc;
var hasFormElements=false;
var hasFileUpload=false;
for(var name in request.args){if(request.args[name]&&request.args[name].nodeName){doc=gDoc(request.args[name]);
if(request.args[name].type=="file"){hasFileUpload=true
}hasFormElements=true
}}var id=request.formId="F"+this.m_id++;
if(ui.isSafari==3&&!hasFileUpload&&!hasFormElements&&net.redirect){var url=new util.query.URL(request.url);
request.args.requestId=id;
var fwdReq=new net.Request();
fwdReq.url=url.protocol+"//"+url.host+"/cim/xdPost_v"+gConfig.getVersion()+".html";
fwdReq.args={url:request.url,args:request.args};
fwdReq.timeout=-1;
fwdReq.noRedirect=true;
fwdReq.transport=net.redirect;
net.request(fwdReq);
this.m_callbacks[id]={callback:callback,request:request,iframe:null,form:null,xdPostRequest:fwdReq};
return
}var formDiv=doc.createElement("div");
formDiv.innerHTML='<form action="'+request.url+'" method="'+request.method+'" target="FTFrame'+id+'" '+(hasFileUpload?'enctype="multipart/form-data" ':"")+'id="FTForm'+id+'"><input type="hidden" name="sessionKey"><input type="hidden" name="requestId" value="'+id+'"></form>';
var form=formDiv.firstChild;
form.style.position="absolute";
form.style.left=form.style.top="-999px";
form.style.width=form.style.height="1px";
form.style.overflow="hidden";
for(var name in request.args){var value=request.args[name];
if(name=="sessionKey"){form.firstChild.value=value
}else{if(value&&value.nodeName){form.appendChild(value)
}else{var input=doc.createElement("input");
input.type=hasFileUpload?"hidden":"password";
input.name=name;
input.readonly=true;
input.value=String(value);
form.appendChild(input)
}}}var iframe=null;
if(ui.isIE){try{iframe=doc.createElement('<iframe name="FTFrame'+id+'">');
iframe.src="javascript:false;"
}catch(e){}}if(!iframe){var iframeDiv=doc.createElement("div");
iframeDiv.innerHTML='<iframe name="FTFrame'+id+'" id="FTFrame'+id+'" src="javascript:void(0);"></iframe>';
iframe=iframeDiv.firstChild
}iframe.style.position="absolute";
iframe.style.left=iframe.style.top="-999px";
doc.body.appendChild(iframe);
doc.body.appendChild(form);
if(request.noRequestId){var onloadCallback=hitch(this,"onIFrameLoad",id);
if(ui.isIE){iframe.onreadystatechange=onloadCallback
}else{iframe.onload=onloadCallback
}}this.m_callbacks[id]={callback:callback,request:request,iframe:iframe,form:form};
net.abortOnTimeout(request,callback);
request.inflight=true;
setTimeout(hitch(this,this.submitForm,form),0)
};
this.submitForm=function(form){form.submit();
for(var i=0,el;
el=form.childNodes[i];
++i){try{el.disabled=true
}catch(e){}}};
this.onIFrameLoad=function(requestId){var iframe=this.m_callbacks[requestId].iframe;
try{var doc=iframe.contentWindow.document;
if(doc.location.href=="javascript:void(0);"||doc.location.href=="javascript:false;"||(ui.isIE&&doc.readyState!="complete")){return
}var response=removeHTML(doc.body.innerHTML);
try{response=eval("("+response+")")
}catch(e){}this.onResponse(requestId,response)
}catch(e){}};
this.tryHtmlFile=function(){try{if(!window.ActiveXObject){return
}var htmlfile=new ActiveXObject("htmlfile");
htmlfile.open();
htmlfile.write("<html></html>");
htmlfile.close();
this.m_doc=htmlfile;
window.attachEvent("onunload",hitch(this,this.removeHtmlFile))
}catch(e){}};
this.removeHtmlFile=function(){this.m_doc=null
};
this.onResponse=function(requestId,response){if(!this.m_callbacks[requestId]){return
}var request=this.m_callbacks[requestId].request;
var callback=this.m_callbacks[requestId].callback;
net.clearTimeout(request);
request.inflight=false;
setTimeout(hitch(this,"cleanup",request),1000);
if(callback){callback(response)
}}
};
Class("events.Client",lib.Publisher,function(a){this.m_serverTimeoutDuration=120000;
this.m_eventsPollDuration=40000;
this.m_eventsRequest=null;
this.m_networkPollDuration=10000;
this.m_testRequest=null;
this.m_testInterval=null;
this.m_noResponseLimit=12;
this.m_noResponses=0;
this.m_lastEventsFailed=false;
this.m_clientType="none";
this.m_bcookie="";
this.m_network=null;
this.m_ipAddress="";
this.m_url=window.location.protocol+"//"+window.location.host;
this.m_multimcmdPath="multimcmd";
this.initialize=function(){a(this,"initialize");
this.m_gateways=[]
};
this.addGateway=function(d){for(var b=0,c;
(c=this.m_gateways[b]);
b++){if(c==d){return
}}this.m_gateways.push(d);
this.publish("AddGateway",d);
this.startEvents()
};
this.removeGateway=function(c){for(var b=this.m_gateways.length-1;
b>=0;
--b){if(this.m_gateways[b]!=c){continue
}this.m_gateways.splice(b,1);
this.publish("RemoveGateway",c);
this.startEvents();
break
}};
this.setClientType=function(b){this.m_clientType=b
};
this.getClientType=function(){return this.m_clientType
};
this.setBCookie=function(b){this.m_bcookie=b
};
this.getBCookie=function(){return this.m_bcookie
};
this.setIPAddress=function(b){this.m_ipAddress=b
};
this.getIPAddress=function(){return this.m_ipAddress
};
this.setNetwork=function(b){this.m_network=b
};
this.getNetwork=function(){return this.m_network
};
this.setUrl=function(b){this.m_url=b
};
this.isSSL=function(){return/^https/.test(this.m_url)
};
this.constructCmdUrl=function(e,d,b){var c=util.query.url(this.m_url);
if(b){c.protocol="https:"
}return String(c)+"/"+e+"/"+d
};
this.getCmdUrl=function(f,b){var g=this.m_gateways;
var c=(g.length<2?g[0].getCmdUrl(f,b):this.constructCmdUrl(this.m_multimcmdPath,f,b));
var e=[];
for(var d=0,h;
(h=g[d]);
++d){e.push("sessionKey="+h.getSessionKey());
e.push("rev="+h.getEventsRev());
e.push("clientId="+h.getClientId())
}return c+"?"+e.join("&")
};
this.getGatewayFromResponse=function(c){var d=this.m_gateways;
if(c&&c.sessionKey){for(var b=d.length-1;
b>=0;
--b){if(d[b].getSessionKey()==c.sessionKey){return d[b]
}}}else{if(d.length==1){return d[0]
}}return null
};
this.startEvents=createDelayedMethod("startEvents",function(){if(!this.m_gateways.length){return this.stop()
}if(this.m_noResponses){return
}if(this.m_eventsRequest){net.abort(this.m_eventsRequest);
this.m_eventsRequest=null
}var b=this.m_eventsRequest=new net.Request();
b.responseType="application/json";
b.timeout=this.m_eventsPollDuration;
this.events()
});
this.events=createDelayedMethod("events",function(){if(!this.m_gateways.length){return
}this.m_eventsRequest.url=this.getCmdUrl("events");
this.publish("beforeEvents",this.m_eventsRequest.args);
try{net.get(this.m_eventsRequest,hitch(this,"eventsCallback"))
}catch(b){this.startTest(b.msg)
}});
this.eventsCallback=function(b,c){if(c&&c.code!=net.EVAL_ERROR){return this.startTest(c.msg)
}var d=this.getGatewayFromResponse(b);
if(c||!b||!d){if(this.m_lastEventsFailed){this.stop(true)
}else{this.m_lastEventsFailed=true;
this.events()
}return
}this.m_lastEventsFailed=false;
if(b.stat=="fail"||typeof b.rev!="number"){return d.stop(true)
}networklog("received events rev "+b.rev+" took "+(new Date().getTime()-this.m_eventsRequest.timestamp)/1000+"s");
d.setEventsRev(b.rev);
try{this.manageEvents(b.events,d)
}catch(c){}this.events()
};
this.manageEvents=function(b,g){b=b||[];
this.publish("EventsReceived",b);
for(var c=0,e;
e=b[c];
++c){var d=e.type,f=e.data;
switch(d){case"info::clientpublish":case"info::publish":net.publish.receive(f.data||f);
break;
case"mcmd":net.FormTransport.onResponse(e.requestId,f);
break;
case"info::external_session":if(f.stat=="ok"){g.cmd("quit");
g.onAttach(null,f.data)
}break;
case"info::terminated":g.terminate(f);
break;
case"info::push_client":g.setPushClient(f.type||f);
break;
case"info::push_client_gone":g.setPushClient(null);
break;
case"info::push_condition":g.setPushCondition(f);
break;
case"info::attached":g.addClient(f);
break;
case"info::detached":g.removeClient(f.clientId);
break;
case"info::client_idle":g.getClientById(f.clientId).setIdle(f.idle);
break;
case"info::locationid":g.setClientLocationId(f);
break;
default:if(/^info::/.test(d)){this.publish(d,f)
}break
}g.manageEvent(d,f)
}this.publish("EventsProcessed",b)
};
this.startTest=function(c){if(typeof networklog=="undefined"){return
}networklog("startTest: "+c);
var b=this.m_eventsRequest&&this.m_eventsRequest.timestamp;
if(b&&new Date().getTime()-b>this.m_serverTimeoutDuration||!this.m_gateways.length){this.stop(true)
}else{if(!this.m_noResponses){if(this.m_eventsRequest){net.abort(this.m_eventsRequest);
this.m_eventsRequest=null
}this.m_testInterval=new util.Interval(hitch(this,"test"),this.m_networkPollDuration);
this.test()
}}};
this.test=function(){if(this.m_testRequest){net.abort(this.m_testRequest);
this.m_testRequest=null
}var c=++this.m_noResponses;
if(c>=this.m_noResponseLimit){return this.stop(true)
}this.publish("fail",c);
networklog("sending test request "+c);
var b=this.m_testRequest=new net.Request();
b.responseType="application/json";
b.url=this.getCmdUrl("test");
b.args.ts=new Date().getTime();
try{net.get(b,hitch(this,"testCallback"))
}catch(d){}};
this.testCallback=function(b,c){var d=this.getGatewayFromResponse(b);
if(d&&(c&&c.code==net.SERVER_ERROR||b&&(b.error_code||b.stat=="fail"))){d.stop(true)
}else{if(!c&&b){this.endTest()
}}};
this.endTest=function(){networklog("endTest");
this.m_testRequest=null;
if(this.m_testInterval){this.m_testInterval.clear();
this.m_testInterval=null
}this.m_noResponses=0;
this.startEvents();
this.publish("resume")
};
this.isTesting=function(){return this.m_noResponses
};
this.stop=function(d){if(this.m_eventsRequest){net.abort(this.m_eventsRequest);
this.m_eventsRequest=null
}if(this.m_testRequest){net.abort(this.m_testRequest);
this.m_testRequest=null
}if(this.m_testInterval){this.m_testInterval.clear();
this.m_testInterval=null
}this.m_noResponses=0;
this.m_lastEventsFailed=false;
for(var b=0,c;
(c=this.m_gateways[b]);
++b){c.stop(d)
}}
});
Class("events.GatewayClient",function(a){this.initialize=function(c,b){this.m_id=c.clientId;
this.m_type=c.clientType;
this.m_ip=c.ip;
this.m_location=b;
this.m_isIdle=false
};
this.getId=function(){return this.m_id
};
this.getType=function(){return this.m_type
};
this.getLocation=function(){return this.m_location
};
this.isIdle=function(){return this.m_isIdle
};
this.setIdle=function(b){this.m_isIdle=b
}
});
Class("events.GatewayLocation",function(a){this.initialize=function(c,b){this.m_id=c;
this.m_startDate=b;
this.m_clients={}
};
this.getId=function(){return this.m_id
};
this.getStartDate=function(){return this.m_startDate
};
this.addClient=function(c){var b=this.m_clients,d=c.getId();
if(b[d]){return
}b[d]=c
};
this.removeClient=function(c){var b=this.m_clients,d=c.getId();
if(!b[d]){return
}delete b[d]
};
this.getClients=function(){return objectToArray(this.m_clients)
}
});
Class("events.Gateway",lib.Publisher,function(a){this.m_mcmds=["start","attach","detach","quit","test","events","changeip","setlocationid","dbg","uiset","uiclear"];
this.m_isGetRequest=["start","attach","detach","quit","uiset","uiclear"];
this.m_eventsRev=0;
this.m_commandPath="cmd";
this.m_modulePath="mcmd";
this.m_isConnecting=false;
this.m_isAttaching=false;
this.m_isConnected=false;
this.m_isAttached=false;
this.m_sessionKey=null;
this.m_clientId=null;
this.m_locationId=null;
this.m_logKey=null;
this.m_serverAttachTime=null;
this.m_startTime=null;
this.m_serverTimeOffset=null;
this.m_pushClient=null;
this.m_pushCondition=false;
this.m_client=null;
this.initialize=function(c){a(this,"initialize");
this.m_client=c;
for(var b=0,d;
(d=this.m_cmds[b]);
b++){this.m_cmds[d]=true
}for(var b=0,d;
(d=this.m_mcmds[b]);
b++){this.m_mcmds[d]=true
}for(var b=0,d;
(d=this.m_both[b]);
b++){this.m_both[d]=true
}for(var b=0,d;
(d=this.m_noSession[b]);
b++){this.m_noSession[d]=true
}for(var b=0,d;
(d=this.m_isGetRequest[b]);
b++){this.m_isGetRequest[d]=true
}this.m_activeRequests=[];
this.m_clients={};
this.m_locations={}
};
this.getSessionKey=function(){return this.m_sessionKey
};
this.getClientId=function(){return this.m_clientId
};
this.getLogKey=function(){return this.m_logKey||""
};
this.isConnected=function(){return this.m_isConnected
};
this.isAttached=function(){return this.m_isAttached
};
this.isConnecting=function(){return this.m_isConnecting
};
this.isAttaching=function(){return this.m_isAttaching
};
this.getServerAttachTime=function(){return this.m_serverAttachTime
};
this.getStartTime=function(){return this.m_startTime
};
this.getLocalizedDate=function(b){if(typeof b!="number"){return null
}return new Date(b*1000-this.m_serverTimeOffset)
};
this.setEventsRev=function(b){this.m_eventsRev=b
};
this.getEventsRev=function(){return this.m_eventsRev
};
this.getLocation=function(){return this.m_locations[this.m_locationId]
};
this.getLocationId=function(){return this.m_locationId
};
this.setLocationId=function(b){this.m_locationId=b
};
this.getPushClient=function(){return this.m_pushClient
};
this.setPushClient=function(b){if(b==this.m_pushClient){return
}var c=this.m_pushClient;
this.m_pushClient=b;
this.publish("PushClient",b,c)
};
this.getPushCondition=function(){return this.m_pushCondition
};
this.setPushCondition=function(b){if(b==this.m_pushCondition){return
}this.m_pushCondition=b;
this.publish("PushCondition",b)
};
this.getCmdUrl=function(c,b){var d=(c in this.m_both&&this.isConnected()||c in this.m_mcmds?this.m_modulePath:this.m_commandPath);
return this.m_client.constructCmdUrl(d,c,b)
};
this.getLocations=function(){return objectToArray(this.m_locations)
};
this.addLocation=function(c){var e=this.m_locations,f=c.locationId;
var b=e[f];
if(b){return b
}var d=this.getLocalizedDate(c.startTime);
return(e[f]=new events.GatewayLocation(f,d))
};
this.removeClientFromLocation=function(c){var b=c.getLocation(),d=this.m_locations;
b.removeClient(c);
if(!b.getClients().length){delete d[b.getId()];
this.publish("RemoveLocation",b)
}};
this.getClientById=function(b){return this.m_clients[b]
};
this.getClients=function(d){var c=[],g=d||{};
for(var b in this.m_clients){var e=this.m_clients[b];
if("type" in g&&g.type!=e.getType()){continue
}c.push(e)
}return c
};
this.addClient=function(d){var c=this.m_clients,e,f=d.clientId;
var b=this.addLocation(d);
e=c[f]=new events.GatewayClient(d,b);
b.addClient(e);
if(b.getClients().length==1){this.publish("AddLocation",b)
}this.publish("ClientAttach",e)
};
this.removeClient=function(b){var c=this.m_clients,d=c[b];
this.removeClientFromLocation(d);
delete c[b];
this.publish("ClientDetach",d)
};
this.setClientLocationId=function(c){var d=this.m_clients[c.clientId];
this.removeClientFromLocation(d);
var b=this.addLocation(c);
b.addClient(d);
if(c.clientId==this.m_clientId){this.m_locationId=c.locationId
}if(b.getClients().length==1){this.publish("AddLocation",b)
}this.publish("ClientLocationId",d)
};
this.setClients=function(b){this.m_clients={};
this.m_locations={};
this.publish("ClientsClear");
for(var d=0,e;
(e=b[d]);
d++){this.addClient(e)
}};
this.detachLocation=function(b){var c=b.getId();
this.cmd("detach",{locationId:c});
if(c==this.getLocationId()){this.stop()
}};
this.removeRequest=function(c){for(var b=this.m_activeRequests.length-1;
b>=0;
b--){if(this.m_activeRequests[b]==c){this.m_activeRequests.splice(b,1)
}}};
this.clearRequests=function(){var b=this.m_activeRequests;
for(var c=0;
c<b.length;
c++){var d=b[c];
if(d.cmd=="quit"||d.cmd=="detach"){continue
}net.abort(d);
b.splice(c,1);
c-=1
}};
this.cmd=function(d,k,l,h,o,b){if(!k){k={}
}if(this.m_client.isTesting()){return this.cmdErrorCallback(gLang.ajaxConnectError,21,l)
}var c=d;
if(/^([^:\/?#]+:)?\/\//.test(c)){d=""
}else{c=this.getCmdUrl(d,b)
}if(d&&!(d in this.m_noSession)){if(!this.isConnected()){if(!(d in this.m_both)){return this.cmdErrorCallback(gLang.ajaxLogoutError,20,l)
}}else{if(!k.sessionKey){k.sessionKey=this.m_sessionKey;
k.clientId=this.m_clientId
}}}var m=false;
for(var n in k){m=m||(k[n]&&k[n].nodeName)
}var f=new net.Request();
f.responseType="application/json";
f.cmd=d;
f.url=c;
f.args=k;
f.sync=h;
f.method=(d in this.m_both||d in this.m_isGetRequest?"GET":"POST");
f.ig=(d in this.m_mcmds);
if(m||b){f.transport=net.FormTransport;
f.noRequestId=(!d||d in this.m_cmds)
}if(typeof o=="number"){f.timeout=o
}try{networklog("cmd: "+(d||c));
net.request(f,d=="attach"?hitch(this,l,f):hitch(this,"cmdCallback",f,l));
this.m_activeRequests.push(f)
}catch(g){this.cmdErrorCallback(gLang.ajaxError,24,l)
}};
this.cmdCallback=function(d,g,c,f){this.removeRequest(d);
if(f){if(f.code==net.EVAL_ERROR){this.publish("evalError",f.e,g,f.response)
}if(d.ig&&(f.code==net.SERVER_ERROR||f.code==net.EVAL_ERROR)){this.test()
}this.cmdErrorCallback(gLang.ajaxError,f.msg,g);
return
}if(typeof c=="undefined"){return this.cmdErrorCallback(gLang.ajaxError,7,g)
}try{var b=(typeof c!="object"||c.stat!="fail");
if(g){g(c,b,0)
}}catch(f){this.publish("evalError",f,g,c);
this.cmdErrorCallback(gLang.ajaxError,10,g)
}};
this.cmdErrorCallback=function(b,f,d){if(d){try{d(b,false,f)
}catch(c){}}};
this.start=function(d){if(this.m_isConnecting||this.m_isConnected){this.stop()
}this.publish("connecting");
this.m_isConnecting=true;
var b={type:this.m_client.getClientType(),bcookie:this.m_client.getBCookie(),ts:new Date().getTime()};
if(this.m_sessionType=="eg"){b.sessionType=this.m_sessionType
}var e=this.m_client.getIPAddress(),c=this.m_client.getNetwork();
if(e){b.ip=e
}if(c){b.network=c
}this.cmd("start",b,hitch(this,"startCallback",d))
};
this.startCallback=function(d,c,b){this.m_isConnecting=false;
if(b){this.onStartAttach(c);
this.m_client.addGateway(this)
}else{this.stop(true)
}d(c,b)
};
this.onStartAttach=function(c){this.m_isConnected=true;
if("sessionKey" in c){this.m_sessionKey=c.sessionKey
}this.m_clientId=c.clientId;
this.m_locationId=c.locationId;
this.m_logKey=c.logkey;
var b=c.servertime;
this.m_serverAttachTime=b;
this.m_serverTimeOffset=b*1000-new Date().getTime();
this.m_startTime=c.start_time;
this.publish("connect",c)
};
this.attach=function(b,f){if(this.m_isConnecting||this.m_isConnected){this.stop()
}if(!b){return f(null,false)
}this.publish("connecting");
this.m_sessionKey=b;
this.m_isAttaching=true;
var c={sessionKey:this.m_sessionKey,type:this.m_client.getClientType(),bcookie:this.m_client.getBCookie()};
var e=this.m_client.getNetwork(),d=this.m_locationId;
if(e){c.network=e
}if(d!=null){c.locationId=d
}this.cmd("attach",c,hitch(this,"attachCallback",f))
};
this.attachCallback=function(f,c,b,d){this.removeRequest(c);
this.m_isAttaching=false;
if(d||b=="success"||b.stat=="fail"){if(d&&d.code==net.REQUEST_ERROR){setTimeout(hitch(this,"attach",this.m_sessionKey,f),5000)
}else{this.stop(true);
setTimeout(hitch(this,f,b,false),0)
}return
}this.onAttach(f,b);
this.m_client.addGateway(this)
};
this.onAttach=function(f,c){this.m_isAttached=true;
this.m_eventsRev=0;
this.setClients(c.clients||[]);
var b=c.session_state||c.sessionState;
if(b&&b.push_client){this.setPushClient(b.push_client)
}this.onStartAttach(c);
if(f){try{f(c,true)
}catch(d){}}};
this.test=function(){if(!this.isConnected()){return
}var b=new net.Request();
b.responseType="application/json";
b.url=this.getCmdUrl("test");
b.args={sessionKey:this.getSessionKey(),clientId:this.getClientId(),ts:new Date().getTime()};
try{net.get(b,hitch(this,"testCallback",b));
this.m_activeRequests.push(b)
}catch(c){}};
this.testCallback=function(c,b,d){this.removeRequest(c);
if(d&&d.code==net.SERVER_ERROR||b&&b.stat=="fail"){this.stop(true)
}};
this.detach=function(){this.cmd("detach");
this.stop()
};
this.quit=function(){this.cmd("quit");
this.stop()
};
this.terminate=function(b){this.publish(this,"terminate",b);
this.stop()
};
this.stop=function(b){this.publish("stop",b);
this.clearRequests();
this.setClients([]);
this.setPushClient(null);
this.m_client.removeGateway(this);
this.m_isConnecting=false;
this.m_isAttaching=false;
this.m_isConnected=false;
this.m_isAttached=false;
this.m_eventsRev=0;
this.m_sessionKey=null;
this.m_clientId=null;
this.m_locationId=null;
this.m_logKey=null;
this.m_pushClient=null;
this.m_pushCondition=false
}
});
Class("events.IMGateway",events.Gateway,function(a){this.m_sessionType="ig";
this.m_cmds=["mstart","gaimlog","getip","meeboembed","trackurl","trackcategory","drads","share_yahoo","exists","create","addacc","removeacc","setacc","gmeeboinfo","smeeboinfo","sicon","gpref","emailverified","gwid","mmc","mmd","mmw","cl","dcl","crl","mccreate","mcfetchspillovers","init_ft.py","majoin","mainfo","mafulllist","mauserlist","mauserinfo","maguestjoin","invite","contacts.php","share_email","oauth_get_request_token","oauth_exchange_token"];
this.m_mcmds=this.m_mcmds.concat(["joinexisting","clientidle","clientnotidle","devicetokenclear","login","relogin","logout","sacctinfo","setstatus","accountsetstatus","nick","setuserprofile","deleteuserinfo","prefset","prefget","acctprefset","acctprefdelete","accountdelete","accountremove","add","rbs","importbuddies","move","blks","alias","info","auth","buddysearch","arefriends","reportabuse","rename","rgs","send","conv","chat","fetchconversation","mcjoin","mcflag","mcwarn","msend","mcaffiliate","malaunch","arv","clearnotifications","clearunreadcounter","genauthtoken","fetchpoll","setfact","fetchad","sharelink","publish"]);
this.m_both=["getrotate","drads"];
this.m_noSession=["start","attach","gaimlog","getip","exists","share_email","share_yahoo","meeboembed","trackurl","trackcategory","emailverified","oauth_get_request_token","oauth_exchange_token","adshare"];
this.m_isGetRequest=this.m_isGetRequest.concat(["gaimlog","dbg","clearnotifications","clearunreadcounter","conv","publish","share_email","share_yahoo","meeboembed","trackurl","oauth_get_request_token","oauth_exchange_token"]);
this.manageEvent=function(b,c){if(gEventMgr.getState()=="done"){return
}if(!("twitter" in gProtocols)&&c&&c.protocol&&c.protocol=="twitter"){return
}switch(b.split("::")[0]){case"im":gEventMgr.handleMsgEvent(b,c);
break;
case"buddy":gEventMgr.handleBuddyEvent(b,c);
break;
case"mc":gEventMgr.handleMeeboChatEvent(b,c);
break;
case"user":gEventMgr.handleUserEvent(b,c);
break;
case"account":gEventMgr.handleAccountEvent(b,c);
break;
case"info":gEventMgr.handleInfoEvent(b,c);
break
}}
});
Class("events.EventGateway",events.Gateway,function(a){this.m_sessionType="eg";
this.m_cmds=[];
this.m_mcmds=this.m_mcmds.concat(["clientpublish","subscribe","fetchhistory","follow","unfollow","login"]);
this.m_both=[];
this.m_noSession=["start","attach"];
this.m_isGetRequest=this.m_isGetRequest.concat(["clientpublish","subscribe","fetchhistory","follow","unfollow"]);
this.m_sessions=0;
this.initialize=function(b){a(this,"initialize",[b]);
b.subscribe("AddGateway",this,function(c){if(c!=this){return
}b.subscribe("EventsReceived",this,"saveSessionKey");
this.saveSessionKey()
});
b.subscribe("RemoveGateway",this,function(c){if(c!=this){return
}b.unsubscribe("EventsReceived",this)
})
};
this.setStorage=function(b){this.m_storage=b
};
this.startSession=function(b){++this.m_sessions;
this.connect(b)
};
this.endSession=function(){--this.m_sessions;
if(!this.m_sessions){this.detach()
}};
this.connect=function(f,b){if(!f){f=function(){}
}if(this.m_isConnected){f()
}else{if(this.m_isConnecting||this.m_isAttaching){this.m_connectingCallbacks.push(f)
}else{this.m_connectingCallbacks=[f];
var c;
try{c=this.m_storage&&JSON.parse(this.m_storage.load("egsession"))
}catch(d){}if(c&&c[1]>new Date().getTime()){this.attach(c[0],hitch(this,"onConnected"))
}else{if(!b){this.start(hitch(this,"onConnected"))
}}}}};
this.m_authState="initial";
this.isLoggingIn=function(){return this.m_authState=="loggingin"
};
this.isLoggedIn=function(){return this.m_authState=="loggedin"
};
this.login=function(){if(this.isLoggingIn()||this.isLoggedIn()){return
}this.m_authState="loggingin";
var c=gLogon.getMeeboAccount(),e=c.getMeeboAuthToken(),b=c.getPartnerAuthToken(),d={num:1,username0:c.getName()};
if(e&&b){d.meeboauthtoken0=e;
d.partnerauthtoken0=b
}else{if(this.m_client.isSSL()){d.password0=c.getPassword()
}else{return
}}this.startSession(hitch(this,"cmd","login",d))
};
this.logout=function(b){if(!this.isLoggedIn()&&!this.isLoggingIn()){return
}};
this.manageEvent=function(b,c){switch(b){case"user::online":this.m_authState="loggedin";
this.publish("UserLogin");
break
}};
this.stop=function(){a(this,"stop",arguments);
if(this.m_storage){this.m_storage.erase("egsession")
}};
this.onConnected=function(d,b){if(!b){if(d&&d.stat=="fail"&&d.msg=="Bad SessionKey"){this.start(hitch(this,"onConnected"))
}return
}if(d.session_state&&d.session_state.accounts&&d.session_state.accounts.length){this.m_authState="loggedin"
}var c=this.m_connectingCallbacks;
this.m_connectingCallbacks=null;
doFunctions(c)
};
this.saveSessionKey=function(){if(!this.m_storage){return
}this.m_storage.save("egsession",JSON.stringify([this.m_sessionKey,new Date().getTime()+2*60*1000]))
}
});
meebo={};
meebo.config=function(){this.m_meeboAppImagePath="/skin/default/img/";
this.m_imageServer="/skin/default/img/";
this.m_version="88_9";
this.m_releaseT="prod";
this.m_timeStamp="1277507952";
this.m_soundPath="/skin/default/sound/";
this.getCDN=function(a){var b=(typeof gCIM=="object"&&gCIM.protocol||window.location.protocol);
return typeof gCDNs=="object"&&gCDNs[a]?b+"//"+gCDNs[a]:""
};
this.getVersion=function(){return this.m_version
};
this.getTimeStamp=function(){return this.m_timeStamp
};
this.getReleaseType=function(){return this.m_releaseT
};
this.getImageServer=function(){return this.getCDN("img")+this.m_imageServer
};
this.getImageURL=function(a){return(a.substr(0,1)=="/"?a:this.getImageServer()+a)
};
this.getSoundPath=function(){return this.getCDN("img")+this.m_soundPath
};
this.getMeeboAppImageURL=function(a){return this.getCDN("img")+this.m_meeboAppImagePath+a
}
};
var gConfig=new meebo.config();
Class("meebo.Protocol",function(){this.initialize=function(c,a,b){this.m_id=c;
this.m_isJabberBased=a;
this.m_defaultGroup=b||"Buddies"
};
this.toJSON=this.getId=this.toString=function(){return this.m_id
};
this.toLowerCase=function(){return this.m_id.toLowerCase()
};
this.isJabberBased=function(){return this.m_isJabberBased
}
});
gProtocols={msn:new meebo.Protocol("msn",false,"Individuals"),aim:new meebo.Protocol("aim"),icq:new meebo.Protocol("icq"),yahoo:new meebo.Protocol("yahoo",false,"Friends"),jabber:new meebo.Protocol("jabber",true),gtalk:new meebo.Protocol("gtalk",true),facebook:new meebo.Protocol("facebook"),myspace:new meebo.Protocol("myspace"),twitter:new meebo.Protocol("twitter")};
Class("meebo.Network",function(){this.initialize=function(a){this.m_id=a.id;
this.m_protocol=gProtocols[a.protocol];
this.m_name=a.name;
this.m_cimPartner=a.cimPartner||false;
this.m_domains=a.domains||[];
this.m_live="live" in a?a.live:true;
this.m_profileUrl=a.profileUrl||"";
this.m_forgotPasswordUrl=a.forgotPasswordUrl;
this.m_loginIsEmail=a.loginIsEmail||false;
this.m_loginUrl=a.loginUrl||null;
var b=a.supports||{};
this.m_supports={add:("add" in b?b.add:true),remove:("remove" in b?b.remove:true),groups:("groups" in b?b.groups:true),block:("block" in b?b.block:true),invisible:("invisible" in b?b.invisible:true),groupchat:("groupchat" in b?b.groupchat:true),chatrooms:("groupchat" in b&&!b.groupchat?false:("chatrooms" in b?b.chatrooms:true)),customalias:("customalias" in b?b.customalias:true),chatlogs:("chatlogs" in b?b.chatlogs:true),icon:("icon" in b?b.icon:true)}
};
this.getId=this.toString=function(){return this.m_id
};
this.getProtocol=function(){return this.m_protocol
};
this.getName=function(){return this.m_name
};
this.getIcon=function(b,a,c){b="."+(b||"gif");
a="_"+(a||14);
c=c?"_"+c:"";
return gConfig.getMeeboAppImageURL("network/"+this.m_id+a+c+b)
};
this.isCIMPartner=function(){return this.m_cimPartner
};
this.isCIMJabberSite=function(){return this.m_cimPartner&&this.m_domains.length
};
this.getDomains=function(){return this.m_domains
};
this.loginIsEmail=function(){return this.m_loginIsEmail
};
this.getForgotPasswordUrl=function(){return this.m_forgotPasswordUrl
};
this.getProfileUrl=function(){return this.m_profileUrl
};
this.getLoginUrl=function(){return this.m_loginUrl
};
this.isLive=function(){return this.m_live
};
this.makeLive=function(){return this.m_live=true
};
this.supports=function(a){return this.m_supports[a]
};
this.getIconUrl=function(){return"network/"+this.getId()+"_14_online.gif"
}
});
Class("meebo.CIMNetwork",meebo.Network,function(a){this.initialize=function(b){b.protocol="jabber";
a(this,"initialize",arguments);
this.m_cimPartner=true;
this.m_supports.remove=false;
this.m_supports.groups=false;
this.m_supports.block=true;
this.m_supports.invisible=false;
this.m_supports.groupchat=false;
this.m_supports.chatrooms=false;
this.m_supports.customalias=false;
this.m_hasHideBtn="hideBtn" in b?b.hideBtn:false;
this.m_singleSubdomain="singleSubdomain" in b?b.singleSubdomain:false;
this.m_isBarVisible="imBarVisible" in b?b.imBarVisible:false;
this.m_friendsSafetyBar="friendsSafetyBar" in b?b.friendsSafetyBar:false;
this.m_imFriendsOnly="imFriendsOnly" in b?b.imFriendsOnly:false;
this.m_noTooltips="noTooltips" in b?b.noTooltips:false;
this.m_showAds="showAds" in b?b.showAds:false;
this.m_controlsAds="controlsAds" in b?b.controlsAds:false;
this.m_fbKey="fbKey" in b?b.fbKey:false;
this.m_revenueId="revenueId" in b?b.revenueId:null
};
this.hasHideBtn=function(){return this.m_hasHideBtn
};
this.singleSubdomain=function(){return this.m_singleSubdomain
};
this.isBarVisible=function(){return this.m_isBarVisible
};
this.friendsSafetyBar=function(){return this.m_friendsSafetyBar
};
this.imFriendsOnly=function(){return this.m_imFriendsOnly
};
this.tooltipsDisabled=function(){return this.m_noTooltips
};
this.getRevenueId=function(){return this.m_revenueId
};
this.getFbKey=function(){return this.m_fbKey
}
});
gNetworks={};
meebo.Network.reload=function(){if(typeof gNetworksData!="undefined"){for(var d in gNetworksData){var a=gNetworksData[d];
if(!(a.protocol in gProtocols)||d in gNetworks){continue
}a.id=d;
gNetworks[d]=new meebo.Network(a)
}}else{new meebo.Network({id:"jabber",name:"Jabber",protocol:"jabber",supports:{block:false,invisible:false,icon:false},domains:["jabber.org"]})
}if(typeof gCIM!="undefined"&&gCIM.networkDefs){for(var c=0,b;
(b=gCIM.networkDefs[c]);
c++){if(!(b.id in gNetworks)){gNetworks[b.id]=new meebo.CIMNetwork(b)
}}}};
meebo.Network.reload();
Class("meebo.Account",function(a){this.m_id="";
this.m_isPartnerLogin=false;
this.m_password=null;
this.m_meeboAuthToken=null;
this.m_partnerAuthToken=null;
this.m_lastError=null;
this.m_fbconnectPartner=null;
this.initialize=function(b,c){this.m_name=b;
this.m_state=c||"pending"
};
this.getId=function(){return this.m_id
};
this.getName=function(){return this.m_name
};
this.getPassword=function(){return this.m_password
};
this.setPassword=function(b){this.m_password=b
};
this.getMeeboAuthToken=function(){return this.m_meeboAuthToken
};
this.setMeeboAuthToken=function(b){this.m_meeboAuthToken=b
};
this.getPartnerAuthToken=function(){return this.m_partnerAuthToken
};
this.setPartnerAuthToken=function(b){this.m_partnerAuthToken=b
};
this.getState=function(){return this.m_state
};
this.setState=createSetter("state","meebo.Account::changeState");
this.getLastError=function(){return this.m_lastError
};
this.setLastError=function(b){this.m_lastError=b||{}
};
this.getFbConnectPartner=function(){return this.m_fbConnectPartner
};
this.setFbConnectPartner=function(b){this.m_fbConnectPartner=b
}
});
Class("meebo.Logon",meebo.Account,function(a){this.m_isAuthToken=false;
this.m_alias="";
this.m_profile=null;
this.m_age=null;
this.m_statusMsg="";
this.m_status="available";
this.m_isMeeboChild=false;
this.m_isAutoStart=false;
this.m_isAutoInvisible=false;
this.m_hasPassword=true;
this.initialize=function(b,c,d){a(this,"initialize",[b,d]);
this.m_network=c;
this.m_id=getLogonId(b,this.getProtocol());
this.m_hasCustomStatusMessage=false;
this.m_isUserSpecifiedAlias=false;
this.m_iconUrl=""
};
this.getAccountType=function(){return"meebo.Logon"
};
this.getUser=function(){return this.m_name
};
this.setName=function(b){this.m_name=b
};
this.getNetwork=function(){return this.m_network
};
this.getProtocol=function(){return this.m_network.getProtocol()
};
this.isJabberBased=function(){return this.getProtocol().isJabberBased()
};
this.isAuthToken=function(){return this.m_isAuthToken
};
this.getDisplayName=function(){if(this.m_network.isCIMPartner()||this.m_network=="meebome"){return this.m_alias||meebo.util.stripJabber(this.m_name)
}else{if(this.isJabberBased()){return meebo.util.stripJabber(this.getName())
}else{if(this.m_network=="facebook"){return this.m_alias||gLang.facebookAccount
}else{return this.getName()
}}}};
this.getAlias=function(){return this.m_alias||this.getDisplayName()
};
this.setAlias=createSetter("alias","meebo.Logon::changeAlias");
this.getState=function(){return this.m_state
};
this.setState=createSetter("state","meebo.Logon::changeState");
this.isMeeboChild=function(){return this.m_isMeeboChild
};
this.setMeeboChild=function(b){this.m_isMeeboChild=b
};
this.isMeeboLogon=function(){return(this.m_network=="meebome"&&normalizeString(this.m_name.substr(0,this.m_name.indexOf("@")))==normalizeString(gLogon.getMeeboUser()))
};
this.getAutoStart=function(){return this.m_isAutoStart
};
this.setAutoStart=function(b){this.m_isAutoStart=b
};
this.getAutoInvisible=function(){return this.m_isAutoInvisible
};
this.setAutoInvisible=function(b){this.m_isAutoInvisible=b
};
this.hasPassword=function(){return this.m_hasPassword
};
this.setHasPassword=function(b){this.m_hasPassword=b
};
this.isOnline=function(){return this.m_state=="online"||this.m_state=="signingoff"
};
this.setOnline=function(b){if(this.isOnline()==b){return
}this.setState(b?"online":"offline")
};
this.getStatus=function(){return this.m_status
};
this.setStatus=function(c){if(!(c in arrayToObject(["available","away","invisible","unavailable"]))){return
}if(c=="invisible"&&!this.getNetwork().supports("invisible")){c="unavailable"
}var b=this.m_status;
this.m_status=c;
gPubSub.publish(this,"meebo.Logon::changeStatus",this.m_status,b)
};
this.getStatusMessage=function(){return this.m_statusMsg
};
this.setStatusMessage=createSetter("statusMsg","meebo.Logon::changeStatusMessage");
this.hasCustomStatusMessage=function(){return this.m_hasCustomStatusMessage
};
this.setHasCustomStatusMessage=createSetter("hasCustomStatusMessage","meebo.Logon::changeHasCustomStatusMessage");
this.setPassword=function(b){this.m_password=b;
this.m_isAuthToken=false
};
this.setAuthToken=function(b){this.m_password=b;
this.m_isAuthToken=true
};
this.isUserSpecifiedAlias=function(){return this.m_isUserSpecifiedAlias
};
this.setUserSpecifiedAlias=function(b){this.m_isUserSpecifiedAlias=b
};
this.getProfile=function(){return this.m_profile
};
this.setProfile=function(b){this.m_profile=b
};
this.getAge=function(){return this.m_age
};
this.setAge=function(b){this.m_age=b
};
this.isAnonymous=function(){return/@gc\d*.meebo.org/i.test(this.m_name)
};
this.getIconUrl=function(){return this.m_iconUrl
};
this.setIconUrl=createSetter("iconUrl","meebo.Logon::changeIcon")
});
Class("meebo.MeeboAccount",meebo.Account,function(a){this.initialize=function(c,b){a(this,"initialize",[c]);
this.m_password=b;
this.m_email=null;
this.m_firstName=""
};
this.getAccountType=function(){return"meebo.MeeboAccount"
};
this.setName=function(b){this.m_name=b
};
this.getEmail=function(){return this.m_email
};
this.setEmail=function(b){this.m_email=b
};
this.getFirstName=function(){return this.m_firstName
};
this.setFirstName=function(b){this.m_firstName=b
};
this.setState=createSetter("state","meebo.MeeboAccount::changeState")
});
Class("meebo.CIMAccount",meebo.Account,function(a){this.m_isPartnerLogin=true;
this.m_lastError=null;
this.m_logon=null;
this.m_isMeeboChild=false;
this.m_isAutoStart=false;
this.m_isAutoInvisible=false;
this.initialize=function(c,b,d){a(this,"initialize",[c]);
this.m_id=getCIMAccountId(c,d);
this.m_password=b;
this.m_network=d
};
this.getAccountType=function(){return"meebo.CIMAccount"
};
this.getAlias=function(){return this.m_name
};
this.getDisplayName=function(){return this.m_name
};
this.getNetwork=function(){return this.m_network
};
this.setState=createSetter("state","meebo.CIMAccount::changeState");
this.getLogon=function(){return this.m_logon
};
this.setLogon=function(b){this.m_logon=b
};
this.getLastError=function(){return this.m_lastError
};
this.setLastError=function(b){this.m_lastError=b||{}
};
this.isOnline=function(){return false
};
this.getAutoStart=function(){return this.m_isAutoStart
};
this.setAutoStart=function(b){this.m_isAutoStart=b
};
this.getAutoInvisible=function(){return this.m_isAutoInvisible
};
this.setAutoInvisible=function(b){this.m_isAutoInvisible=b
};
this.isMeeboChild=function(){return this.m_isMeeboChild
};
this.setMeeboChild=function(b){this.m_isMeeboChild=b
};
this.isMeeboLogon=function(){return false
};
this.getProtocol=function(){return"jabber"
}
});
meebo.NetworkMgr=function(){this.m_loginWithSsl=false;
this.m_sslTestIframe;
this.m_lastIframeRequest=-1;
this.m_uiLogFilters={}
};
meebo.NetworkMgr.prototype.init=function(){if(!util.RSA){this.m_loginWithSsl=true
}else{if(!this.m_loginWithSsl){this.doSslCheck()
}}};
meebo.NetworkMgr.prototype.getProtocol=function(){return(typeof window!="undefined"?window.location.protocol:"http:")
};
meebo.NetworkMgr.prototype.doSslCheck=function(){net.doSslCheck()
};
meebo.NetworkMgr.prototype.enableLoginWithSsl=function(){this.m_loginWithSsl=true
};
meebo.NetworkMgr.prototype.requestURL=function(a,d){try{var b=new net.Request();
b.url=a;
b.transport=net.XHRTransport;
net.get(b,d)
}catch(c){gWindowMgr.createNotifyDlg({id:getUniqueId()+"networkError",caption:gLang.meeboMessage},gLang.disruption+gLang.pleaseCheck)
}};
meebo.NetworkMgr.prototype.doRequest=function(e,c,f,d,a,b){if(gDebug){return
}gIMGateway.cmd(e,c,f,d,a,b)
};
meebo.NetworkMgr.prototype.encryptPassword=function(a){if(!a){return""
}return util.RSA.rsaEncrypt(gIMGateway.getSessionKey().substring(0,44)+a)
};
meebo.NetworkMgr.prototype.requestLogin=function(f,k,l){if(!gIMGateway.isConnected()){var t=callee.call(this,arguments);
return gIMGateway.start(function(v,n){if(n){t()
}})
}if(typeof gCIM!="undefined"&&gCIM.connectURL&&typeof gApp!="undefined"){k=gApp.requestLogin(f,k);
if(!k.length){return
}}var d=!this.m_loginWithSsl;
var o={sessionKey:gIMGateway.getSessionKey(),clientId:gIMGateway.getClientId(),gmt:-(new Date().getTimezoneOffset())};
if(!gLogon.getLogons({online:true}).length){o.state=gLogon.getStatus();
o.message=gLogon.getStatusMessage()
}if(typeof document=="undefined"||typeof MeeboExtension!="undefined"){o.ext="ff"
}if(this.getProtocol()=="https:"){o.ssl=true
}o.num=0;
for(var h=0,c;
(c=k[h]);
h++){if(c.getAccountType()=="meebo.MeeboAccount"){break
}}if(c){var e=o.num++;
var u=c.getPassword(),m;
o["username"+e]=c.getName();
o["protocol"+e]="meebo";
if(f=="relogin"||l){o["autologin"+e]=false
}var s=c.getMeeboAuthToken();
var q=c.getPartnerAuthToken();
if(s&&q){o["meeboauthtoken"+e]=s;
o["partnerauthtoken"+e]=q
}else{o[(d?"encrypted_":"")+"password"+e]=d?this.encryptPassword(u):u
}if((m=gLogon.getMeeboMeLogon())&&m.isMeeboLogon()){o["state"+e]=m.getStatus();
o["message"+e]=m.getStatusMessage()
}}for(var h=0,b;
(b=k[h]);
h++){if(b.getAccountType()=="meebo.MeeboAccount"){continue
}var e=o.num++;
o["username"+e]=b.getName();
var a=(b.getAccountType()=="meebo.CIMAccount");
var p=b.getProtocol();
var g=b.isMeeboChild();
o["protocol"+e]=p.toString();
if(!a){o["state"+e]=b.getStatus();
o["message"+e]=b.getStatusMessage();
o["isauthtoken"+e]=b.isAuthToken()?"true":"false";
if(g){o["mep"+e]=true
}}o["network"+e]=b.getNetwork().getId();
o["ispartnerlogin"+e]=a;
if(b.getFbConnectPartner()){o["fbconnectpartner"+e]=b.getFbConnectPartner()
}if(b.getMeeboAuthToken&&b.getMeeboAuthToken()){this.enableLoginWithSsl();
var s=b.getMeeboAuthToken();
var q=b.getPartnerAuthToken();
if(s&&q){o["meeboauthtoken"+e]=s;
o["partnerauthtoken"+e]=q;
o["mep"+e]=true;
o["ispartnerlogin"+e]=false
}}else{var u=g?gLogon.getMeeboAccount().getPassword():b.getPassword();
if(!d){o["password"+e]=u
}else{o["encrypted_password"+e]=this.encryptPassword(u)
}}}if(typeof gJoinExisting!="undefined"){switch(gJoinExisting){case JOIN_EXISTING_NONE:f=(l?"relogin":"login");
break;
case JOIN_EXISTING_MEEBO_ACCOUNTS:if(!c){f=(l?"relogin":"login")
}break
}}this.doRequest(f,o,hitch(gLogon,"receiveVerifyUser"),null,null,this.m_loginWithSsl)
};
meebo.NetworkMgr.prototype.requestAddAccounts=function(e,d){var b={numLogins:0,muser:gLogon.getMeeboUser()};
for(var c=0,a;
(a=e[c]);
c++){var f=++b.numLogins;
b[f+"user"]=a.getName();
b[f+"protocol"]=a.getProtocol();
b[f+"password2"]=this.encryptPassword(a.getPassword());
b[f+"state"]=a.getAutoInvisible()?"invisible":"online";
b[f+"autologin"]=a.getAutoStart();
b[f+"alias"]=a.getAlias();
b[f+"ispartnerlogin"]=(a.getAccountType()=="meebo.CIMAccount");
b[f+"network"]=a.getNetwork().getId()
}if(b.numLogins){this.doRequest("addacc",b,d)
}};
meebo.NetworkMgr.prototype.doUILog=function(m,h,c,n,g,l){var f={element:m,name:h,action:c,bForce:n,comment:g};
var e=m+"-"+h+"-"+c;
for(var a in this.m_uiLogFilters){var k=this.m_uiLogFilters[a];
if(e.search(k[0])!=-1){k[1](f)
}}var o=(typeof gUILoggingPercent!="undefined"?gUILoggingPercent:0);
var p=(Math.floor(Math.random()*100)<o);
if(!p&&!f.bForce){return
}var d=gIMGateway.isConnected();
var b=f.element+"-"+f.name+"="+f.action+(f.comment?"|"+g:"");
this.doRequest(d?"dbg":"gaimlog",{cat:"javascript",m:b},null,l)
};
meebo.NetworkMgr.prototype.addUILogFilter=function(c,b,a){this.m_uiLogFilters[c]=[b,a]
};
meebo.NetworkMgr.prototype.doLog=function(a){this.doRequest("dbg",{m:a})
};
meebo.NetworkMgr.prototype.requestChatLog=function(d,c,a){var b={muser:gLogon.getMeeboUser(),p:c.getProtocol(),bu:c.getName(),u:c.getUser()};
if(a){b.l=a
}this.doRequest("cl_proxy",b,d,null,0)
};
meebo.NetworkMgr.prototype.deleteChatLog=function(a,c){var b={muser:gLogon.getMeeboUser(),p:c.getProtocol(),bu:c.getName(),u:c.getUser()};
this.doRequest("dcl_proxy",b,a)
};
meebo.NetworkMgr.prototype.requestMeeboChatLog=function(a,f,d,b,e,g){var c={muser:gLogon.getMeeboUser()||"",r:f.getChatName(),t:d};
if(b){c.l=Math.max(b,100)
}if(e){c.ds=e
}if(g){c.de=g
}this.doRequest("crl",c,a)
};
meebo.NetworkMgr.prototype.requestInfo=function(b,c){var a={};
this.buddyToQueryString(a,b);
this.doRequest("info",a,c)
};
meebo.NetworkMgr.prototype.requestSetProfile=function(a,f,b,e,d){if(ui.isIE){e=e.replace(/<EM>/ig,"<i>");
e=e.replace(/<\/EM>/ig,"</i>");
e=e.replace(/<STRONG>/ig,"<b>");
e=e.replace(/<\/STRONG>/ig,"</b>")
}var c={protocol:f,accountname:b,info:e};
this.doRequest("sacctinfo",c,a)
};
meebo.NetworkMgr.prototype.requestRoomsPrefs=function(a,c,e){var b={muser:e,nprefs:0};
for(var d=0;
d<c.length;
d++){if(!c[d]){continue
}b[++b.nprefs+"pn"]=c[d]
}if(b.nprefs){this.doRequest("gpref",b,a)
}};
meebo.NetworkMgr.prototype.requestPrefs=function(b){var a={num:0};
for(var c=0;
c<b.length;
c++){if(!b[c]){continue
}a["name"+a.num++]=b[c]
}if(a.num){this.doRequest("prefget",a)
}};
meebo.NetworkMgr.prototype.requestRemoveBuddies=function(b,c){var a=this.buildMultiBuddyRequest(b);
if(!a){return
}a.uiT=c;
this.doRequest("rbs",a,hitch(this,"receiveRemoveBuddies"))
};
meebo.NetworkMgr.prototype.receiveRemoveBuddies=function(b,a,c){if(a||!gWindowMgr){return
}gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.removeErrorHeader},gLang.removeNetError)
};
meebo.NetworkMgr.prototype.receiveSetAcc=function(b,a,c){if(a||!gWindowMgr){return
}gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.ajaxError},gLang.netError)
};
meebo.NetworkMgr.prototype.requestRemoveBuddyGroups=function(d){var b={n:0};
for(var c in d){if(!d[c]||!d[c].getExtra){continue
}var a=d[c].getExtra();
if(!a||!a.getName||!a.getName()||!a.getType||a.getType()!="buddygroup"){continue
}b[++b.n+"g"]=d[c].getExtra().getName()
}if(b.n){this.doRequest("rgs",b,hitch(this,"receiveRemoveBuddyGroups"))
}};
meebo.NetworkMgr.prototype.receiveRemoveBuddyGroups=function(b,a,c){if(a||!gWindowMgr){return
}gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.removeErrorHeader},gLang.removeNetError)
};
meebo.NetworkMgr.prototype.requestRenameGroup=function(c,a,b){this.doRequest("rename",{g:a,ng:b},c)
};
meebo.NetworkMgr.prototype.requestAddBuddy=function(f,d,g,e,b,a){var c={user:b,protocol:g,group:e,buddy:d};
if(a){c.subscr=0
}this.doRequest("add",c,f)
};
meebo.NetworkMgr.prototype.requestImportBuddies=function(c,b){var a={user:b.getName(),protocol:b.getProtocol()};
this.doRequest("importbuddies",a,c)
};
meebo.NetworkMgr.prototype.requestMoveBuddy=function(a,f,e){if(!f||!e){return
}var b={};
var d=0;
for(var c=0;
c<f.length;
c++){this.buddyToQueryString(b,f[c],++d);
b[d+"g"]=e
}b.n=d;
if(d){this.doRequest("move",b,a)
}};
meebo.NetworkMgr.prototype.receiveAddBuddy=function(b,a,c){if(a){return
}if(gWindowMgr){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.addErrorHeader},gLang.addNetError+" "+gLang.pleaseCheck)
}};
meebo.NetworkMgr.prototype.receiveImportBuddies=function(b,a,c){if(a||!gWindowMgr){return
}gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.addErrorHeader},gLang.addNetError+" "+gLang.pleaseCheck)
};
meebo.NetworkMgr.prototype.receiveAddChat=function(a,d,c,f){if(c){var b=a.getYourself();
if(b){a.addMember(b.getBuddy());
var e=gWindowMgr.getConvWindow(a);
if(e){e.moveBuddy(b)
}}return
}if(gWindowMgr){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.addErrorHeader},gLang.addNetError+" "+gLang.pleaseCheck)
}};
meebo.NetworkMgr.prototype.requestBlockBuddies=function(d,a){for(var c=d.length-1;
c>=0;
c--){if(!d[c].getNetwork().supports("block")){d.splice(c,1)
}}var b=this.buildMultiBuddyRequest(d);
if(!b){return
}b.block=a?"true":"false";
this.doRequest("blks",b,hitch(this,"receiveBlockBuddies"))
};
meebo.NetworkMgr.prototype.receiveBlockBuddies=function(b,a,d){if(a){return
}if(gWindowMgr){var c=gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.removeErrorHeader},gLang.removeNetError)
}};
meebo.NetworkMgr.prototype.requestSetAffiliation=function(a,d,b,e){if(!d||!b){return
}var c={buddy:d.getAlias(),room:b.getName(),ch:b.getChatId(),affiliation:e};
this.doRequest("mcaffiliate",c,a)
};
meebo.NetworkMgr.prototype.requestChatAction=function(c,b,e,d,h,a,g){var f=new Array();
if(e){f.push(e)
}this.requestChatActionFull(c,b,f,d.getProtocol(),d.getUser(),h,a,g)
};
meebo.NetworkMgr.prototype.requestChatActionFull=function(l,e,a,k,f,b,d,c){var h={};
if(e){h.a=e
}if(a&&a.length){h.nbuddies=a.length;
for(var g=0;
g<a.length;
g++){h[(g+1)+"b"]=a[g]
}}if(f){h.u=f
}if(k){h.p=k
}if(b){h.i=b
}if(d){h.d1=d
}if(c){h.d2=c
}this.doRequest("chat",h,l)
};
meebo.NetworkMgr.prototype.requestJoinRoom=function(h,g,a,d,f,e,c){var b={room:g};
if(a){b.nick=a
}if(d){b.password=d
}if(f){b.invitee=f
}if(e){b.invitee_protocol=e
}if(c){b.platform_instance_id=c
}this.doRequest("mcjoin",b,h)
};
meebo.NetworkMgr.prototype.requestSetStatus=function(e,d,f){if(!e){return
}var b={num:e.length};
for(var c=0,a;
(a=e[c]);
c++){b["username"+c]=a.getName();
b["protocol"+c]=a.getProtocol();
b["state"+c]=(d===null?a.getStatus():d);
b["message"+c]=(f===null?a.getStatusMessage():f)
}if(c){this.doRequest("accountsetstatus",b,hitch(this,"receiveSetStatus"))
}};
meebo.NetworkMgr.prototype.receiveSetStatus=function(b,a){if(a||!gWindowMgr){return
}gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.ajaxError},gLang.awayDisruption+" "+gLang.pleaseCheck)
};
meebo.NetworkMgr.prototype.requestSetConversationClose=function(a){runInMainContext(this,"doRequest","conv",{rec:a.getName(),proto:a.getProtocol(),send:a.getUser(),data:"close"})
};
meebo.NetworkMgr.prototype.requestSetTypingNotification=function(a,b){this.doRequest("conv",{rec:b.getName(),proto:b.getProtocol(),send:b.getUser(),data:(a==1?"typ":(a==2?"stoptyp":"cleartyp"))})
};
meebo.NetworkMgr.prototype.requestInappropriate=function(a,c,b){this.doRequest("mcflag",{url:a,room:c},b)
};
meebo.NetworkMgr.prototype.requestWarn=function(c,a,b){this.doRequest("mcwarn",{room:c,buddy:a},b)
};
meebo.NetworkMgr.prototype.requestSetAlias=function(b,c,d){var a={a:c};
this.buddyToQueryString(a,b);
this.doRequest("alias",a,d)
};
meebo.NetworkMgr.prototype.requestMultiSend=function(a,f,g,e,l,b){if(!a.length){return
}var k={numReceivers:a.length};
for(var h=0,d=1;
h<a.length;
h++,d++){k[d+"sender"]=a[h].getUser();
k[d+"protocol"]=a[h].getProtocol();
k[d+"receiver"]=a[h].getName();
var c=a[h].getChatId&&a[h].getChatId();
if(c){k[d+"ch"]=c
}}if(b){k.type="app"
}k.msg=f;
if(g){k.room=e||g;
k.roomname=g
}var m=l?hitch(this,"doUILog","invite-msg-sent",l,a.length,true):null;
this.doRequest("msend",k,m)
};
meebo.NetworkMgr.prototype.requestSetIcon=function(d,a,c){var b={sessionKey:gIMGateway.getSessionKey(),clientId:gIMGateway.getClientId(),muser:gLogon.getMeeboUser()};
if(c){b.url=c
}else{if(a){b.file=a
}else{b.stock=d.substr(d.lastIndexOf("/")+1)
}}this.doRequest("sicon",b,hitch(this,"receiveSetIcon",c||d||"custom-upload"))
};
meebo.NetworkMgr.prototype.receiveSetIcon=function(b,c){if(c=="success"){gPubSub.publish(this,"meebo.NetworkMgr::iconSet",b);
return true
}var a=gLang.buddyIconErrorGeneral;
switch(c){case"failed:imagesize":a=gLang.buddyIconErrorImageSize;
break;
case"failed:filesize":a=gLang.buddyIconErrorSize;
break;
case"failed:filetype":a=gLang.buddyIconErrorFiletype;
break
}gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.buddyIconErrorHeader},a)
};
meebo.NetworkMgr.prototype.receiveAuthBuddy=function(b,a,c){if(!a&&gWindowMgr){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.authHeader},gLang.authCheck)
}};
meebo.NetworkMgr.prototype.buddyToQueryString=function(e,d,h){if(typeof h!="number"){h=""
}var f=d.getType()=="chat";
var b=gLogon.getMeeboUser();
var a=(f&&b)?b+"@meebo.org":d.getUser();
var g=f?gProtocols.jabber:d.getProtocol();
var c=d.getName();
if(g.isJabberBased()){c=meebo.util.stripJabber(c)
}e[h+"u"]=a;
e[h+"p"]=g;
e[h+"b"]=c
};
meebo.NetworkMgr.prototype.buildMultiBuddyRequest=function(e){var d=0;
var c={};
for(var a in e){if(!e[a]){continue
}var b=e[a];
if(b.m_control=="uiTree"){b=b.getExtra()
}if(b.getType()!="buddy"&&b.getType()!="chat"){continue
}this.buddyToQueryString(c,b,++d)
}if(d==0){return null
}c.n=d;
return c
};
meebo.NetworkMgr.prototype.requestNotificationRead=function(e,a,d,c){var b={numCleared:1,"0user":a,"0protocol":d,"0notificationid":e};
runInMainContext(this,"doRequest","clearnotifications",b,function(f){if(f=="success"&&c){c()
}})
};
meebo.NetworkMgr.prototype.requestAreFriends=function(e){var c={};
for(var d=0,b;
b=e[d];
++d){var f=b.getLogin().getId();
var a=c[f];
if(!a){a=c[f]={username:b.getUser(),protocol:b.getProtocol(),num:0}
}c[f]["buddyname"+(a.num++)]=b.getName()
}for(var f in c){this.doRequest("arefriends",c[f],hitch(this,"onAreFriends",c[f].username,c[f].protocol))
}};
meebo.NetworkMgr.prototype.onAreFriends=function(e,f,c,a){if(!a){return
}for(var b=0,d;
d=c.result[b];
++b){gBuddyList.getBuddy(d.buddyname,f,e).setIsFriend(d.isbuddy)
}};
meebo.EventMgr=function(){this.m_state="logon";
this.m_inNetworkInterrupt=false;
this.m_roomPrefsToRequest=[];
gClient.subscribe("fail",this,"onFailTest");
gClient.subscribe("resume",this,"onResume");
gIMGateway.subscribe("connecting",this,"onConnecting");
gIMGateway.subscribe("connect",this,"onConnect");
gIMGateway.subscribe("stop",this,"onStop");
gIMGateway.subscribe("evalError",this,"onEvalError");
gClient.subscribe("EventsReceived",this,"onEventsReceived");
gClient.subscribe("EventsProcessed",this,"onEventsProcessed")
};
meebo.EventMgr.prototype.getState=function(){return this.m_state
};
meebo.EventMgr.prototype.setState=createSetter("state","meebo.EventMgr::changeState");
meebo.EventMgr.prototype.buddyIconURL=function(a){var c=(typeof gCIM=="object"&&gCIM.protocol||window.location.protocol);
var b=(typeof gCIM=="object"&&gCIM.hostname||window.location.host);
if(c=="https:"){a=a.replace(/^http:\/\/icons/i,"https://origin-icons");
a=a.replace(/^http:\/\/bacon/i,"https://origin-bacon")
}return(b?util.query.relativeTo(a,c+"//"+b):a)
};
meebo.EventMgr.prototype.inNetworkInterrupt=function(){return this.m_inNetworkInterrupt
};
meebo.EventMgr.prototype.onConnecting=function(){gEventMgr.setState(this.m_state=="logon"||this.m_state=="connecting"?"connecting":"reconnecting")
};
meebo.EventMgr.prototype.onConnect=function(k){var m=k.session_state||k;
if(!("events" in k)){return
}this.setState("im");
if(k.session_state||("sessionState" in m)){gBuddyList.setLarge((k.session_state?m:m.sessionState).large_buddylist)
}gClient.manageEvents(k.events,gIMGateway);
if("convs" in m){for(var l=0,q;
q=m.convs[l];
++l){var h=q.u,t=q.p,d=q.b,g=q.unread,n=q.a,e=q.i;
var u=meebo.util.normalizeLogon(h,t);
var p=gLogon.addLogon(h,u.network);
if(!e){var o=gBuddyList.addBuddy(d,p);
o.setAlias(n);
o.getConversation(true).setUnreadCount(g);
gPubSub.publish(o,"meebo.Buddy::conversation")
}else{var v=q.room?gBuddyList.addRoom(d,n,p):gBuddyList.addProtocolChat(d,e,n,p);
var a=q.room?d:n;
if(p.isJabberBased()){gBuddyList.addJabberGroup(a)
}v.setFromAttach(true);
v.setChatId(e);
for(var l=0,s;
(s=q.bl[l]);
l++){var o=gBuddyList.addBuddy(s.n,p);
var f=o.getPresence(v,s.a);
if(s.s){o.setYourself(true)
}f.setOnline(true);
o.setOnline(true)
}}}}if(m.targeting){gTargeting.setTargetingFromEvents(m.targeting)
}};
meebo.EventMgr.prototype.onFailTest=function(a){this.m_inNetworkInterrupt=true;
gPubSub.publish(this,"meebo.EventMgr::networkInterrupt",a)
};
meebo.EventMgr.prototype.onStop=function(e){if(e){this.m_inNetworkInterrupt=true
}var c=this.getState();
if(c=="connecting"){this.setState("logon")
}else{if(c=="im"||c=="reconnecting"){this.setState("done");
var d=gLogon.getLogons();
for(var b=0,a;
(a=d[b]);
b++){if(a.isOnline()||(c=="reconnecting"&&a.getState()=="pending")){a.setState("disconnected")
}}gBuddyList.clearBuddyList()
}}this.m_inNetworkInterrupt=false
};
meebo.EventMgr.prototype.onResume=function(){this.m_inNetworkInterrupt=false;
gPubSub.publish(this,"meebo.EventMgr::networkResume")
};
meebo.EventMgr.prototype.onEvalError=function(h,a,f){function k(p){var n=p.name;
var o=p.message||p.description;
var m=p.fileName?p.fileName+":"+p.lineNumber:"";
var l=p.number;
return n+(o?": "+o:"")+(m?"; "+m:"")+(l?"; "+l:"")
}var c=navigator.userAgent.replace(/\s/g,"_").replace(/\|/g,"");
var d="host="+document.domain+" url="+(typeof location!="undefined"?location:"unknown")+" https="+(typeof ui!="undefined"?ui.isHttps:"unknown")+" ua="+c;
if(gLogon.getMeeboUser()){d+=" meebousername="+gLogon.getMeeboUser()
}var b=k(h).replace(/[\n\r\t]/g,"");
var g="";
if(a){if(a.methodName&&typeof a.methodName=="string"){g="["+a.methodName+"] "+g
}else{g=a.toString().replace(/[\n\r\t]/g,"").substring(0,25)
}}gNetworkMgr.doLog("error=ajaxEvalError | function="+g+" | "+d+" | message="+b+" | string="+String(f).replace(/[\n\r]/g,""))
};
meebo.EventMgr.prototype.onEventsReceived=function(a){if(a.length>80){gBuddyList.buddies().flushCaches()
}};
meebo.EventMgr.prototype.onEventsProcessed=function(a){if(!gLogon.getMeeboUser()||!this.m_roomPrefsToRequest.length||gClient.getClientType()=="cim-imbar"||gClient.getClientType()=="none"){return
}prefNames=[];
for(var b=0;
b<this.m_roomPrefsToRequest.length;
b++){prefNames.push("room:"+this.m_roomPrefsToRequest[b].getChatName())
}gNetworkMgr.requestRoomsPrefs(hitch(this,"receiveRoomPrefs",this.m_roomPrefsToRequest),prefNames,gLogon.getMeeboUser());
this.m_roomPrefsToRequest=[]
};
meebo.EventMgr.prototype.receiveRoomPrefs=function(f,c,b,d){if(!b){return
}gPrefs.receiveRoomPrefs(f,c,b,d);
for(prefId in c){if(prefId.indexOf("room:")!=0){continue
}var a=c[prefId];
if(!a.lastAccess){continue
}var e=gBuddyList.getRoomByName(prefId.split("room:")[1]);
if(!e){continue
}e.setLastReadMsg(a.lastAccess)
}};
meebo.EventMgr.prototype.handleBuddyEvent=function(b,q){if(!q||!b){return false
}if(b=="buddy::rg"){gBuddyList.removeGroup(q.data);
return true
}else{if(b=="buddy::unusual_subscription"){return
}}var y=q.user,z=q.protocol;
var m=gLogon.getLogon(y,z);
if(!m){if(z!="meebo"){var x=("network" in q)&&gNetworks[q.network]||meebo.util.normalizeLogon(q.user,q.protocol).network;
m=gLogon.addLogon(y,x)
}}if(b=="buddy::online"&&!m.isOnline()){m.setOnline(true)
}var d={};
switch(b){case"buddy::online":d.online=true;
d.statusMessage=q.data2;
case"buddy::login":if(q.data){d.friend=true
}d.alias=q.buddyalias;
break
}var t=q.room;
var p=!t?gBuddyList.addBuddy(q.buddy,m,d):gBuddyList.addRoom(q.buddy,q.buddyalias,m);
switch(b){case"buddy::online":case"buddy::login":if(t){this.m_roomPrefsToRequest.push(p);
p.setOnline(true)
}var a=t&&meebo.util.isDefaultGroupChatGroup(q.data)?gLang.meeboChats:q.data;
gBuddyList.addBuddyToGroup(p,a);
if(q.buddyiconurl){p.setIconURL(this.buddyIconURL(q.buddyiconurl))
}break;
case"buddy::offline":if(!m.isOnline()){break
}if(p instanceof meebo.Buddy){p.setOnline(false)
}gBuddyList.addBuddyToGroup(p,q.data);
break;
case"buddy::removed":case"buddy::logout":gBuddyList.removeBuddyFromGroup(p,q.data);
break;
case"buddy::busy":p.setBusy(true);
p.setStatusMessage(q.data);
break;
case"buddy::away":p.setAway(true);
p.setStatusMessage(q.data);
break;
case"buddy::backi":p.setIdle(false,-1);
break;
case"buddy::backa":p.setAway(false);
p.setStatusMessage(q.data2);
break;
case"buddy::backb":p.setBusy(false);
p.setStatusMessage(q.data2);
break;
case"buddy::idle":if(p.isOnline()){p.setIdle(true,q.data)
}break;
case"buddy::typing":p.setTyping(1);
break;
case"buddy::stoppedtyping":p.setTyping(2);
break;
case"buddy::cleartyp":p.setTyping(0);
break;
case"buddy::info":p.setInfo(q.data);
if(p.getType()=="buddy"){p.setStatusMessage(q.data2)
}p.setAlias(q.buddyalias);
break;
case"buddy::infoaim":p.setInfoAim(q.data);
break;
case"buddy::m2m":if(q.data=="1"){p.setOnMeeboStatus("OnMeebo")
}else{if(q.data=="0"&&q.data2=="0"){p.setOnMeeboStatus("NeverOnMeebo")
}else{p.setOnMeeboStatus("NotOnMeebo")
}}break;
case"buddy::icon":if(q.data){if(q.data.charAt(0)=='"'){q.data=JSON.parse(q.data)
}p.setIconURL(this.buddyIconURL(q.data))
}else{p.setIconURL("")
}break;
case"buddy::mobile":p.setAway(false);
p.setMobile(true);
break;
case"buddy::backm":p.setMobile(false);
break;
case"buddy::blocked":p.setBlocked(true);
gBuddyList.addBuddyToGroup(p,q.data);
break;
case"buddy::unblk":p.setBlocked(false);
break;
case"buddy::chi":var v=p.getName();
var e=function(A,w){runInMainContext(gNetworkMgr,gNetworkMgr.requestChatAction,hitch(gNetworkMgr,"receiveAuthBuddy"),"a",q.buddy,p,q.data,A)
};
var k=sprintf(gLang.inviteToChat,v+" ("+z+")",m.getUser(),q.data);
if(typeof meeboApp=="undefined"){e(false);
if(typeof cim=="undefined"){alert(k+"  "+gLang.groupsUnsupported)
}return
}if(q.data2){k+=" "+sprintf(gLang.inviteMsg,v,q.data2)
}var h=gWindowMgr.createAcceptDenyDlg({id:getUniqueId()+"-accept",caption:gLang.chatAcceptHeader},{buddy:v,logon:m,message:k,joinButtonText:gLang.acceptBtn},e);
if(meeboApp.util.hasMeeboExtension()){var g=hitch(this,function(A){if(!A.isPoppedOut()){MeeboExtension.showMeeboTab();
A.callActivate()
}else{A.m_win.focus()
}},h);
MeeboExtension.showNotification(gLang.chatAcceptHeader,removeHTML(k),null,"invitation",g)
}break;
case"buddy::chj":this.handleChatJoin(p,q);
break;
case"buddy::chjo":var u=gBuddyList.getRoomByName(q.data);
u.addMember(p);
var s=u.getPresences();
if(s[p.getId()]){this.handleChatJoin(p,q)
}break;
case"buddy::chl":this.handleChatLeave(p,q);
break;
case"buddy::nick":var o=q.data;
var n=o.substring(0,o.indexOf("/"));
var u=gBuddyList.getRoomByName(n);
var c=p.getPresence(u);
var l=c.getAlias();
var f=o.substring(o.indexOf("/")+1);
c.setAlias(f);
if(p.isYourself()){gPrefs.saveRoomPref(u,"nick",f);
if(!gLogon.getMeeboUser()){p.getLogin().setAlias(f)
}}if(u&&u.constructor==meebo.ApplicationRoom&&isDefined(q.data2.app_args)){c.setAppArgs(q.data2.app_args);
meeboApp.platform.changeAlias(u.getChatName(),c)
}break;
default:return false
}return true
};
meebo.EventMgr.prototype.handleChatLeave=function(e,f){var g=f.protocol;
var b=f.user;
var d=gLogon.getLogon(b,g);
var a=(meebo.util.isMeeboGroupChat(f.data,d.getNetwork())?gBuddyList.addRoom(f.data,null,d):gBuddyList.addProtocolChat(null,f.data2.chatid,f.data,d));
var c=e.getPresence(a);
if(isDefined(f.data2.app_args)){c.setAppArgs(f.data2.app_args)
}c.setOnline(false)
};
meebo.EventMgr.prototype.handleChatJoin=function(n,q){if(!q.data2){return
}var w=q.buddy;
var y=q.protocol;
var l=q.buddyalias;
var x=q.user;
var m=gLogon.getLogon(x,y);
if(m.isJabberBased()){gBuddyList.addJabberGroup(q.data)
}var c=q.data2.p;
var b=q.data2.i;
var a=q.data2.m;
var p=q.data2.s||w==x;
var g=q.data2.secret;
var k=q.data2.priv;
var f=q.data2.mod_url;
var d=q.data2.warn;
var o=q.data2.app_args;
var s=q.data2.app_id;
var t=q.data2.guest_only_user;
var u,v;
if(meebo.util.isMeeboGroupChat(q.data,m.getNetwork())){if(s&&(s>0)){v=u=gBuddyList.addApplicationRoom(q.data);
var h=v.getApplication();
if(!h||h.app_id!=s){v.setApplication(meebo.applicationMgr.getApplication(s)||new meebo.Application({app_id:s}))
}if(t&&!p){v.setGuestOnly(true)
}}else{v=u=gBuddyList.addRoom(q.data,null,m)
}v.setLogin(m);
if(isDefined(k)||g){v.setPrivate(Boolean(k||g));
if(g){v.setPassword(g)
}if(isDefined(k)){v.setPasswordLength(k)
}}if(typeof f!="undefined"){v.setModeratedUrls(Boolean(f))
}}else{u=gBuddyList.addProtocolChat(c,b,q.data,m)
}if(v&&v.constructor==meebo.ApplicationRoom){v.setAbandoned(p&&v&&!v.hasPresences()&&!v.getInvites())
}if(q.data){u.setName(q.data)
}u.setChatId(b);
if(v&&v.constructor==meebo.Room&&!v.isInChat()){gPrefs.updateRoomLastAccess(v);
if(!v.isOnlist()){if(v.m_shouldAddToBuddylist){gNetworkMgr.requestAddBuddy(hitch(gNetworkMgr,"receiveAddChat",v),v.getName(),"jabber",gLang.meeboChats,v.getLogin().getName());
v.m_shouldAddToBuddylist=false
}else{if(!v.isSpillover()){this.m_roomPrefsToRequest.push(v)
}}}}var e=n.getPresence(u,l);
if(l){e.setAlias(l)
}if(q.data2.u&&q.data2.up){e.m_joiner=normalizeString(q.data2.u);
e.m_joinerProtocol=q.data2.up
}if(p){n.setYourself(true)
}if(typeof a!="undefined"){e.setOwner(a==1);
e.setSubModerator(a==2)
}e.setWarnCount(d);
if(typeof o!="undefined"){e.setAppArgs(o)
}if(q.type!="buddy::chjo"){e.setOnline(true);
n.setOnline(true)
}};
meebo.EventMgr.prototype.handleMsgEvent=function(c,p){var k=gLogon.getLogon(p.receiver,p.protocol);
if(k.isJabberBased()){p.sender=meebo.util.stripJabber(p.sender)
}var x=p.sender;
var h=p.d.a;
var n=gBuddyList.addBuddy(x,k);
if(h&&(!n.isGuestUser()||meebo.util.stripJabber(h)!=n.getName())){n.setAlias(h)
}if(p.d.i&&k.isJabberBased()){var l=x.indexOf("/");
var g=l==-1?x:x.substr(0,l);
if(meebo.util.isMeeboGroupChat(g,k.getNetwork())){var u=gBuddyList.addRoom(g,null,k)
}}if(p.d.i&&!u){var u=gBuddyList.addProtocolChat(null,p.d.i,null,k)
}var b=typeof gWindowMgr!="undefined"&&gWindowMgr.getConvWindow(u);
switch(c){case"im::ft":case"im::received":if(u&&(n.isYourself()||n.getPresence(u).isMuted())){break
}if("timeSentUTC" in p&&p.timeSentUTC<gIMGateway.getServerAttachTime()){var q=gIMGateway.getLocalizedDate(p.timeSentUTC)
}if(!u&&n.getType()=="buddy"){var e=new meebo.IM(n,p.message,q||new Date());
n.getConversation(true).addMessage(e)
}gPubSub.publish(this,"meebo.EventMgr::IM",n,p.message,u,q,p.d.fileid,p.d.muser,p.d.msgId,p.d.delayed);
if(u&&u.getType()=="chat"){u.setLastMsg()
}if(!u){n.setTyping(0)
}break;
case"im::unreadcounter_cleared":var w=n.getConversation();
if(w){w.setUnreadCount(0)
}break;
case"im::sent":gPubSub.publish(this,"meebo.EventMgr::sentIM",n,p.message,u,q,p.d.fileid,p.d.muser,p.d.msgId);
break;
case"im::urls":if(!b){break
}var v=meeboApp.MediaListItem.fromEvent(p);
b.addToMediaList(v,n);
b.queueGroupChatMedia(v);
break;
case"im::kick":u.setChatId(null);
if(u.constructor==meebo.ApplicationRoom){break
}u.m_isLeaving=false;
if(b){var s=gLogon.getMeeboMeLogon();
var d=s&&(u.getLogin()!=s);
if(b.isVisible()){b.addHistoryIM(gLang.meeboMessage,gLang.leftRoomMessage,true,true)
}if(d){u.setLogin(s);
meeboApp.joinRoom(u)
}}gPrefs.updateRoomLastAccess(u);
if(p.d.reason=="kick"&&gNotice.m_flashEnabled){gNotice.add(u.getChatName(),k.getName(),k.getAlias());
var t=gNotice.getNoticeCount();
var f=gNotice.getLockoutLimit();
if(t+1==f){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.bannedTitle},gLang.bannedWarning)
}else{if(t>=f){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.bannedTitle},gLang.bannedFinal)
}else{gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.bannedTitle},gLang.bannedFromRoom)
}}}gBuddyListDlg.updateBuddyRows(u);
break;
case"im::appinvite":case"im::roominvite":var m=p.d.r;
var o=p.d.ra;
var a=p.d.pass;
var k=gLogon.getLogon(p.receiver,p.protocol);
var n=gBuddyList.addBuddy(p.sender,k);
gPubSub.publish(this,(c=="im::roominvite"?"meebo.EventMgr::roomInvite":"meebo.EventMgr::appInvite"),n,p.message,m,o,a);
break;
case"im::urldata":gPubSub.publish(this,"meebo.EventMgr::urlData",p.d);
break;
default:break
}};
meebo.EventMgr.prototype.handleMeeboChatEvent=function(k,a){var h=(!a.user||!a.protocol?gLogon.getMeeboMeLogon():gLogon.getLogon(a.user,a.protocol));
var p=a.info&&a.info.app_instance_id?gBuddyList.addApplicationRoom(a.info.app_instance_id):gBuddyList.addRoom(a.room,a.alias,h);
var l=typeof gWindowMgr!="undefined"&&gWindowMgr.getConvWindow(p);
switch(k){case"mc::update":var f=a.lastmsg2?Math.floor(new Date().getTime()/1000)-a.lastmsg2:a.lastmsg;
if(typeof a.count=="number"){p.setCount(a.count)
}if(typeof f=="number"){p.setLastMsg(f)
}break;
case"mc::sync":gPubSub.publish(p,"meebo.Room::sync",a.info.url,a.info.nitems);
break;
case"mc::icon":p.setIconURL(this.buddyIconURL(a.info));
if(l){l.updateChatInfo()
}break;
case"mc::password":if(l){l.showPasswordPrompt()
}break;
case"mc::widget":p.setWidgetHash(a.info);
break;
case"mc::noads":p.setPartner(true);
break;
case"mc::personal":var o=hitch(p,function(s,q,t){if(q){this.setWidgetHash(s)
}});
var e={o:gLogon.getMeeboUser(),i:p.getAlias(),link:p.getChatName(),d:0,npairs:3,"1n":"w","1v":430,"2n":"h","2v":300,"3n":"rmjid","3v":p.getName()};
gNetworkMgr.doRequest("mmc",e,o);
break;
case"mc::warn":if(!p){break
}var b=getBuddyId(a.info,gLogon.getMeeboMeLogon());
var n=p.getPresences();
if(!n||!n[b]){break
}var d=n[b];
var g=d.getBuddy();
d.setWarnCount(d.getWarnCount()+1);
if(g.isYourself()){gNotice.addWarn(p.getName(),p.getName()+"/"+d.getAlias());
gNotice.checkProbation()
}if(l){var c=d.getWarnCount()==1?sprintf(gLang.hasBeenWarned,d.getAlias()):sprintf(gLang.hasBeenWarnedPlural,d.getAlias(),d.getWarnCount());
l.addHistoryIM("",c,true,true)
}break;
case"mc::data":var m=parseGET(a.info.data);
if(!isDefined(m.msg)||!isDefined(m.msgType)){break
}p.receiveMsg(m.msg,parseInt(m.msgType,10),a.info.from);
break;
case"mc::appcreated":gPubSub.publish(this,"meebo.EventMgr::appCreated",p,a.info.chat_id);
break;
case"mc::appregister":gPubSub.publish(this,"meebo.EventMgr::appRegister",p,a.info);
break;
case"mc::error":gPubSub.publish(p,"meebo.Chat::error",a.info.error);
break
}};
meebo.EventMgr.prototype.handleUserEvent=function(o,c){var h=c.user,p=c.protocol;
var g=("network" in c)&&gNetworks[c.network]||meebo.util.normalizeLogon(h,p).network;
var m=(h&&p&&p in gProtocols)&&gLogon.getLogon(h,p);
switch(o){case"user::connecting":if(!m.isOnline()){m.setState("pending")
}break;
case"user::online":var l=c.data;
this.setState("im");
if(p=="meebo"){var f=gLogon.addMeeboAccount(h);
f.setFirstName(c.data.firstname);
f.setState("online");
break
}m=gLogon.addLogon(h,g);
m.setName(h);
m.setOnline(true);
if(typeof l=="string"){m.setAlias(l)
}break;
case"user::offline":if(p=="meebo"){g=gNetworks.meebome
}var k=c.data,e,n=null;
if("partnerusername" in k){e=gLogon.getCIMAccount(k.partnerusername,k.partner);
if(!e){break
}}else{e=gLogon.getCIMAccount(h,g);
n=k
}if(e){e.setLastError(n);
e.setState("error");
break
}m=gLogon.addLogon(h,g);
var d=m.getState();
switch(d){case"signingoff":m.setState("offline");
break;
case"pending":case"online":m.setLastError(k);
m.setState(k.type?"error":"offline");
if(d=="pending"&&!m.isMeeboChild()){gLogon.removeLogon(m)
}break;
case"error":case"offline":case"disconnected":default:break
}if(m.getNetwork()=="meebome"&&m!=gLogon.getMeeboMeLogon()){gLogon.removeLogon(m)
}gBuddyList.getBuddies({protocol:p,user:h}).foreach(function(s,q){gBuddyList.removeBuddy(q)
});
break;
case"user::idle":break;
case"user::away":break;
case"user::warned":break;
case"user::request":gPubSub.publish(this,"meebo.EventMgr::buddyAddRequest",c.data,p,h);
break;
case"user::notify":gPubSub.publish(this,"meebo.EventMgr::notify",c.data);
break;
case"user::icon":var b=this.buddyIconURL(c.data);
if(m){m.setIconUrl(b)
}else{if(p=="meebo"){gPrefs.setIcon(b)
}}break;
case"user::alias_changed":m.setAlias(c.data);
break;
case"user::info":m.setProfile(c.data);
break;
case"user::status":m.setStatusMessage(c.data.status);
m.setStatus(c.data.state);
break;
case"user::myspace_age":m.setAge(c.data);
break;
case"user::sharedlink":gPubSub.publish(this,"meebo.EventMgr::sharedlink",m,c.data);
break;
case"user::removed":if(m){gLogon.removeLogon(m)
}else{if(p=="meebo"){var f=gLogon.getMeeboAccount();
if(f&&f.getName()==c.user){gLogon.removeMeeboAccount()
}}}break;
case"user::pref":var a=c.data.name;
if("value" in c.data){gPrefs.saveAccountPref(m,a,c.data.value)
}else{gPrefs.deleteAccountPref(m,a)
}break
}};
meebo.EventMgr.prototype.handleAccountEvent=function(e,g){var b=g.user,h=g.protocol;
var f=("network" in g)&&gNetworks[g.network]||meebo.util.normalizeLogon(b,h).network;
if(!f){return
}switch(e){case"account::info":if(h=="meebo"){if(!gLogon.getMeeboUser()){gLogon.addMeeboAccount(b).setState("online")
}break
}var d=gLogon.addLogon(b,f);
if("partnerusername" in g){var a=gLogon.getCIMAccount(g.partnerusername,g.network);
if(a){d.setPassword(a.getPassword());
gLogon.removeCIMAccount(a)
}}d.setMeeboChild(g.meebochild);
d.setAutoInvisible(g.loginstatus=="invisible");
d.setAutoStart(g.autologin=="true");
if(g.meebochild&&"havepassword" in g){d.setHasPassword(g.havepassword)
}if(typeof g.alias=="string"){d.setAlias(g.alias)
}if("buddyiconurl" in g){var c=this.buddyIconURL(g.buddyiconurl);
d.setIconUrl(c);
if(d.isMeeboLogon()){gPrefs.setIcon(c)
}}if("state" in g){d.setStatus(g.state)
}else{if(g.loginstatus=="invisible"){d.setStatus("invisible")
}}if("isonline" in g){d.setState(g.isonline?"online":"offline")
}else{if(g.meebochild&&d.getState()=="pending"&&!d.getAutoStart()){d.setState("offline")
}}if("message" in g){d.setStatusMessage(g.message)
}break
}};
meebo.EventMgr.prototype.handleInfoEvent=function(a,b){switch(a){case"info::load_apps":gPubSub.publish(this,"meebo.EventMgr::loadApps");
break;
case"info::large_buddylist":gBuddyList.setLarge(true);
break;
case"info::group_renamed":var c=gBuddyList.getGroupByName(b.group);
gBuddyList.setGroupName(c,b.name);
break;
case"info::status":gLogon.setStatus(b.state,b.status);
break
}};
meebo.EventMgr.prototype.logout=function(a){gPrefs.doPreferenceSync();
runInMainContext(function(){if(a=="detach"){gIMGateway.detachLocation(gIMGateway.getLocation())
}else{gIMGateway.quit()
}})
};
Class("meebo.LogonMgr",function(){this.initialize=function(){this.m_logons={};
this.m_logonsCache={};
this.m_accounts={};
this.m_meeboAccount=null;
this.m_status="available";
this.m_statusMessage=""
};
this.addLogon=function(b,c,d){var a=this.getLogon(b,c.getProtocol());
if(!a){a=new meebo.Logon(b,c,d);
this.m_logons[a.getId()]=a;
this.m_logonsCache[c.getProtocol()+"/"+b]=a;
gPubSub.publish(this,"meebo.LogonMgr::addLogon",a)
}return a
};
this.getLogon=function(a,c){var b=c+"/"+a;
return this.m_logonsCache[b]||(this.m_logonsCache[b]=this.m_logons[getLogonId(a,c)])
};
this.getUserHash=function(){return util.sha.sha256(this.getMeeboName()||this.getLogons()[0].getId())
};
this.getLogons=function(a){a=a||{};
var c=[];
for(var d in this.m_logons){var b=this.m_logons[d];
if("state" in a&&b.getState()!=a.state){continue
}if("status" in a&&b.getStatus()!=a.status){continue
}if("protocol" in a&&b.getProtocol()!=a.protocol){continue
}if("network" in a&&b.getNetwork()!=a.network){continue
}if("anonymous" in a&&b.isAnonymous()!=a.anonymous){continue
}if("name" in a&&b.getName()!=a.name){continue
}if("online" in a&&b.isOnline()!=a.online){continue
}if("meeboChild" in a&&b.isMeeboChild()!=a.meeboChild){continue
}if("cimPartner" in a&&b.getNetwork().isCIMPartner()!=a.cimPartner){continue
}if("supports" in a&&!b.getNetwork().supports(a.supports)){continue
}if("statusMessage" in a&&!b.getStatusMessage()){continue
}if("customStatusMessage" in a&&b.hasCustomStatusMessage()!=a.customStatusMessage){continue
}if("autostart" in a&&b.getAutoStart()!=a.autostart){continue
}if("haspassword" in a&&b.hasPassword()!=a.haspassword){continue
}c.push(b);
c[d]=b
}return c
};
this.removeLogon=function(a){if(meebo.CIMAccount&&a instanceof meebo.CIMAccount){return this.removeCIMAccount(a)
}for(var b in this.m_logonsCache){if(this.m_logonsCache[b]==a){delete this.m_logonsCache[b]
}}a.setState("offline");
delete this.m_logons[a.getId()];
gPubSub.publish(this,"meebo.LogonMgr::removeLogon",a)
};
this.addCIMAccount=function(c,b,d){var a=this.getCIMAccount(c,d)||new meebo.CIMAccount(c,b,d);
this.m_accounts[a.getId()]=a;
gPubSub.publish(this,"meebo.LogonMgr::addCIMAccount",a);
return a
};
this.getCIMAccount=function(a,b){return this.m_accounts[getCIMAccountId(a,b)]
};
this.removeCIMAccount=function(a){delete this.m_accounts[a.getId()];
gPubSub.publish(this,"meebo.LogonMgr::removeCIMAccount",a)
};
this.getMeeboMeLogon=function(){var a=this.getLogons({network:"meebome"});
if(a.length>1){var d=null;
for(var c=0,b;
(b=a[c]);
c++){if(b.isMeeboLogon()){d=b;
break
}if(b.getState()!="online"){if(a.length>1){a.splice(c--,1)
}}}}return d||(a.length?a[0]:null)
};
this.getMeeboName=function(){return this.m_meeboAccount?this.m_meeboAccount.getName():""
};
this.getMeeboUser=function(a){return this.m_meeboAccount&&(this.m_meeboAccount.getState()=="online"||a)?this.m_meeboAccount.getName():""
};
this.hasMeeboAccount=function(){return !!this.m_meeboAccount
};
this.getMeeboAccount=function(){return this.m_meeboAccount
};
this.addMeeboAccount=function(b,a){if(!this.m_meeboAccount||normalizeString(this.m_meeboAccount.getName())!=normalizeString(b)){this.m_meeboAccount=new meebo.MeeboAccount(b)
}else{this.m_meeboAccount.setName(b)
}if(a){this.m_meeboAccount.setPassword(a)
}return this.m_meeboAccount
};
this.removeMeeboAccount=function(){var a=this.m_meeboAccount;
this.m_meeboAccount=null;
gPubSub.publish(this,"meebo.LogonMgr::removeMeeboAccount",a)
};
this.removeAccounts=function(){for(var a in this.m_accounts){this.removeCIMAccount(this.m_accounts[a])
}this.removeMeeboAccount()
};
this.receiveVerifyUser=function(b,a){logSpeed("server login returned");
if(gDebug){gEventMgr.setState("im");
return
}if(!a){gEventMgr.setState(gEventMgr.getState()=="connecting"?"logon":"done");
if(typeof gWindowMgr!="undefined"){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.netErrorHeader},gLang.netError)
}if(typeof gWait!="undefined"){gWait.hideWait()
}return false
}if(this.m_meeboAccount&&b.muser&&normalizeString(b.muser)==normalizeString(this.m_meeboAccount.getName())){gPrefs.onReceivePrefs(b.prefs)
}return true
};
this.reconnect=function(a){if(!a){return
}if(a.isMeeboChild()&&!this.getMeeboUser()){return
}a.setState("pending");
gNetworkMgr.requestLogin("relogin",[a])
};
this.reconnectAll=function(){var c=this.getLogons({state:"disconnected",anonymous:false});
for(var b=0,a;
(a=c[b]);
b++){a.setState("pending")
}if(!c.length&&!this.m_meeboAccount){gLogon.receiveVerifyUser("success",true,0)
}else{if(this.m_meeboAccount){c.push(this.m_meeboAccount)
}runInMainContext(gNetworkMgr,"requestLogin","joinexisting",c,true)
}};
this.signoff=function(b){if(!b){return
}if(gDebug){b.setState("offline");
return
}if(gLogon.getLogons({online:true}).length==1){gEventMgr.logout()
}else{b.setState("signingoff");
var a={numLogouts:1,"1protocol":b.getProtocol(),"1user":b.getName()};
gNetworkMgr.doRequest("logout",a,hitch(this,"receiveSignoff"))
}};
this.receiveSignoff=function(b,a,c){if(a||typeof gWindowMgr=="undefined"){return
}gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.netErrorHeader},gLang.netError)
};
this.toggleOnline=function(a){if(a.isOnline()){this.signoff(a)
}else{this.reconnect(a)
}};
this.getStatus=function(){return this.m_status
};
this.getStatusMessage=function(){return this.m_statusMessage
};
this.setStatus=function(b,a){if((b==null||b==this.m_status)&&(a==null||a==this.m_statusMessage)){return
}if(b!=null){this.m_status=b
}if(a!=null){this.m_statusMessage=a
}gPubSub.publish(this,"meebo.LogonMgr::changeStatus",this.m_status,this.m_statusMessage)
}
});
Class("meebo.BuddyList",function(){this.initialize=function(){this.m_groups={};
this.m_buddies=new lib.Filterable({type:"getType",protocol:"getProtocol",user:"getUser",logon:"getLogin",online:"isOnline",onlist:"isOnlist",friend:"isFriend"},true);
gPubSub.subscribe("meebo.IMObject::changeOnline",this,"onBuddyChange");
gPubSub.subscribe("meebo.IMObject::changeIsFriend",this,"onBuddyChange");
this.m_jabberGroups={};
this.m_groupNames={}
};
this.getRoomByName=function(a){if(a.indexOf("@")!=-1){return this.getBuddyById(getMeeboChatId(a))
}else{var b=null;
this.m_buddies.foreach(function(d,c){if(c.getType()=="chat"&&c.getChatName()==a){b=c;
return true
}});
return b
}};
this.getBuddyById=function(a){return this.m_buddies.get(a)
};
this.getBuddy=function(c,d,a){var b=gLogon.getLogon(a,d);
var e=(meebo.util.isMeeboGroupChat(c,b.getNetwork())?getMeeboChatId(c):getBuddyId(c,b));
return this.m_buddies.get(e)
};
this.buddies=function(){return this.m_buddies
};
this.getBuddies=function(a){return this.m_buddies.getItems(a)
};
this.addRoom=function(b,c,a){if(!b){return null
}if(!a){a=gLogon.getMeeboMeLogon()
}var e=getMeeboChatId(b);
var d=this.m_buddies.get(e);
if(!d){d=new meebo.Room(b,c,a);
this.m_buddies.add(e,d)
}if(typeof c=="string"){d.setAlias(c)
}return d
};
this.addApplicationRoom=function(b,a){var d=getMeeboChatId(b);
var c=this.m_buddies.get(d);
if(!c){c=new meebo.ApplicationRoom(b,a);
this.m_buddies.add(d,c)
}return c
};
this.addProtocolChat=function(e,d,c,b){if(!d||!b){return null
}var f=getGroupChatId(b.getProtocol(),b.getName(),d);
var a=this.m_buddies.get(f)||this.m_buddies.add(f,new meebo.ProtocolChat(e,c,b));
return a
};
this.addBuddy=function(b,h,c){if(!b||!h){return null
}if(h.isJabberBased()){b=meebo.util.stripJabber(b);
if(b.indexOf("/")!=-1){var m=b.substring(0,b.indexOf("/"));
var f=b.substring(b.indexOf("/")+1);
if(this.isJabberGroup(m)){var a=this.getRoomByName(m);
var k=a.getPresences();
for(var l in k){var e=k[l];
if(e.isOnline()&&e.getAlias()==f){return this.m_buddies.get(l)
}}}}}var d=getBuddyId(b,h);
var g=this.m_buddies.get(d);
if(!g){g=this.m_buddies.add(d,new meebo.Buddy(b,h,d,c))
}else{if(c){if("online" in c){g.setOnline(c.online)
}if("statusMessage" in c){g.setStatusMessage(c.statusMessage)
}if("friend" in c){g.setIsFriend(c.friend)
}if("alias" in c){g.setAlias(c.alias)
}}}g.m_logon=h;
return g
};
this.onBuddyChange=function(a){this.m_buddies.onItemChange(a.getId(),a)
};
this.addBuddyToGroup=function(a,b){if(!a||!b){return null
}if(typeof b=="string"){b=this.createGroup(b)
}if(b.appendBuddy(a)){this.onBuddyChange(a);
gPubSub.publish(this,"meebo.BuddyList::addBuddyToGroup",a,b)
}};
this.removeBuddyFromGroup=function(a,b){if(!a||!b){return
}if(typeof b=="string"){b=this.getGroupByName(b);
if(!b){return
}}if(b.removeBuddy(a)){this.onBuddyChange(a);
gPubSub.publish(this,"meebo.BuddyList::removeBuddyFromGroup",a,b)
}if(a instanceof meebo.Buddy&&!a.isOnlist()){a.setOnline(false)
}if(!b.getBuddies().length){this.removeGroup(b)
}};
this.removeBuddy=function(a){var c=a.getGroups();
for(var b=0,d;
(d=c[b]);
b++){this.removeBuddyFromGroup(a,d)
}};
this.getGroupByName=function(a){return this.m_groupNames[a]||(this.m_groupNames[a]=this.getGroupById(getBuddyGroupId(a)))
};
this.getGroupById=function(a){return this.m_groups[a]
};
this.createGroup=function(b){var a=this.getGroupByName(b);
if(a){return a
}var a=new meebo.BuddyGroup(b);
this.m_groups[a.getId()]=this.m_groupNames[b]=a;
gPubSub.publish(this,"meebo.BuddyList::createGroup",a);
return a
};
this.getGroups=function(){var b=[];
for(var a in this.m_groups){var c=this.m_groups[a];
b.push(c);
b[a]=c
}b.sort();
return b
};
this.addJabberGroup=function(a){this.m_jabberGroups[a]=a
};
this.isJabberGroup=function(a){return a in this.m_jabberGroups
};
this.withGroups=function(a){for(var b in this.m_groups){if(this.m_groups[b]&&a(this.m_groups[b])=="break"){break
}}};
this.setGroupName=function(c,a){for(var b in this.m_groupNames){if(this.m_groupNames[b]!=c){continue
}delete this.m_groupNames[b]
}delete this.m_groups[c.getId()];
c.setName(a);
this.m_groups[c.getId()]=c
};
this.removeGroup=function(e){if(typeof e=="string"){e=this.getGroupByName(e)
}if(!e){return
}var d=e.getBuddies();
for(var b=0,a;
(a=d[b]);
b++){this.removeBuddyFromGroup(a,e)
}for(var c in this.m_groupNames){if(this.m_groupNames[c]!=e){continue
}delete this.m_groupNames[c]
}delete this.m_groups[e.getId()];
gPubSub.publish(this,"meebo.BuddyList::removeGroup",e)
};
this.clearBuddyList=function(){gPubSub.publish(this,"meebo.BuddyList::beforeClearBuddyList");
var a=this.getBuddies();
a.foreach(function(d,c){var e=c.getGroups();
for(var b=0,f;
(f=e[b]);
b++){f.removeBuddy(c)
}if(c instanceof meebo.Buddy){c.setOnline(false)
}});
this.m_groups={};
this.m_groupNames={}
};
this.setLarge=function(a){this.m_isLargeBuddyList=a;
gPubSub.publish(this,"meebo.BuddyList::isLarge",a)
};
this.isLarge=function(){return this.m_isLargeBuddyList
}
});
Class("meebo.BuddyGroup",function(){this.initialize=function(a){this.m_name=a;
this.m_id=getBuddyGroupId(a);
this.m_buddies=[]
};
this.getType=function(){return"buddygroup"
};
this.getId=function(){return this.m_id
};
this.getName=function(){return this.m_name
};
this.setName=function(b){if(b==this.m_name){return
}var a=this.m_name,c=this.m_id;
this.m_name=b;
this.m_id=getBuddyGroupId(b);
gPubSub.publish(this,"meebo.BuddyGroup::changeName",this.m_name,a,this.m_id,c)
};
this.toString=function(){return this.m_name.toLowerCase()
};
this.removeBuddy=function(a){var d=a.getId();
if(!this.m_buddies[d]){return false
}a.removeGroup(this);
var c=this.m_buddies;
for(var b=c.length-1;
b>=0;
b--){if(c[b]==a){c.splice(b,1);
break
}}delete this.m_buddies[d];
return true
};
this.appendBuddy=function(a){if(this.m_buddies[a.getId()]){return false
}this.m_buddies[a.getId()]=a;
this.m_buddies.push(a);
a.addGroup(this);
return true
};
this.getBuddies=function(a){a=a||{};
var d=[];
d.totalLength=0;
for(var c=0,b;
(b=this.m_buddies[c]);
c++){d.totalLength++;
if("online" in a&&b.isOnline()!=a.online){continue
}if("type" in a&&b.getType()!=a.type){continue
}d[d.length]=b
}d.sort();
return d
}
});
Class("meebo.IM",function(a){this.initialize=function(c,d,b){this.m_buddy=c;
this.m_message=d;
this.m_date=b
};
this.getMessage=function(){return this.m_message
};
this.getDate=function(){return this.m_date
};
this.getTime=function(){return this.m_date.getTime()
}
});
Class("meebo.Conversation",function(a){this.initialize=function(b){this.m_buddy=b;
this.m_messages=[];
this.m_unreadCount=0
};
this.getBuddy=function(){return this.m_buddy
};
this.getMessages=function(){return this.m_messages
};
this.addMessage=function(b){this.m_messages.push(b);
this.incrementUnreadCount()
};
this.getUnreadCount=function(){return this.m_unreadCount
};
this.setUnreadCount=function(b){b=b||0;
if(this.m_unreadCount==b){return
}this.m_unreadCount=b;
gPubSub.publish(this,"meebo.Conversation::changeUnreadCount",b)
};
this.incrementUnreadCount=function(){this.setUnreadCount(this.m_unreadCount+1)
};
this.resetUnreadCount=function(){if(this.m_unreadCount!=0){this.setUnreadCount(0);
var b=this.m_buddy;
gNetworkMgr.doRequest("clearunreadcounter",{username:b.getUser(),buddyname:b.getName(),protocol:b.getProtocol()})
}}
});
Class("meebo.IMObject",function(){this.m_type=null;
this.m_unavailableInfoTimer=-1;
this.m_id=null;
this.m_info="";
this.m_iconURL="";
this.m_alias="";
this.m_protocol=null;
this.m_network=null;
this.m_user=null;
this.m_bPendingInfo=false;
this.m_infoRequestTime=null;
this.m_bOnline=false;
this.m_loginTime=0;
this.m_persistTime=0;
this.m_onlineTime=0;
this.m_profileURL="";
this.m_wentOnlistTime=0;
this.m_isFriend=false;
this.m_checkedFriendship=false;
this.initialize=function(b,a){this.m_groups=[];
this.m_name=b;
this.m_logon=a
};
this.getId=function(){return this.m_id
};
this.getGroupId=function(a){return this.m_id
};
this.getType=function(){return this.m_type
};
this.getName=function(){return this.m_name
};
this.getLogin=function(){return this.m_logon
};
this.getNetwork=function(){return this.m_network||(this.m_network=this.m_logon.getNetwork())
};
this.getProtocol=function(){return this.m_protocol||(this.m_protocol=this.m_logon.getProtocol())
};
this.getUser=function(){return this.m_logon.getUser()
};
this.getResource=function(){if(!this.getProtocol().isJabberBased()){return""
}var a=this.getName();
if(a.indexOf("/")==-1){return""
}return a.substring(a.indexOf("/")+1)
};
this.getGroups=function(){return this.m_groups.slice(0)
};
this.hasGroup=function(b){for(var a=0;
a<this.m_groups.length;
a++){if(this.m_groups[a]==b){return true
}}return false
};
this.addGroup=function(a){if(!this.m_groups.length){this.m_wentOnlistTime=new Date().getTime()
}this.m_groups.push(a);
this.setIsFriend(true)
};
this.removeGroup=function(b){for(var a=this.m_groups.length-1;
a>=0;
a--){if(this.m_groups[a]==b){this.m_groups.splice(a,1)
}}if(!this.m_groups.length){this.m_wentOnlistTime=0
}};
this.getIconURL=function(){return this.m_iconURL
};
this.setIconURL=createSetter("iconURL","meebo.IMObject::changeIcon");
this.hasAlias=function(){return this.m_alias
};
this.getAlias=function(){return this.m_alias||this.m_name
};
this.setAlias=createSetter("alias","meebo.IMObject::changeAlias");
this.getWentOnlistTime=function(){return this.m_wentOnlistTime
};
this.isOnlist=function(){return Boolean(this.m_groups.length)
};
this.isOnline=function(){return this.m_bOnline
};
this.setOnline=function(b){if(this.m_bOnline==b){return
}this.setIsFriend(true);
var a=this.m_bOnline;
this.m_bOnline=b;
gPubSub.publish(this,"meebo.IMObject::changeOnline",b,a)
};
this.isMeebome=function(){if(this.getType()!="buddy"||this.getNetwork()!="meebome"){return false
}for(var a in this.m_presences){return false
}return true
};
this.getCaptionImage=function(){return(this.getNetwork()=="yahoo"?"yahoo_logo_small_title.gif":"network/"+this.getNetwork()+"_14_online.gif")
};
this.getCaption=function(){var a=this.getAlias();
if(gLogon.getLogons({protocol:this.getProtocol()}).length>1){a+=" ("+this.m_logon.getAlias()+")"
}return a
};
this.getOnlineStatus=this.getStatus=function(){if(this.m_bOnline){status=sprintf(gLang.isOnline,this.getAlias())
}else{status=sprintf(gLang.isOffline,this.getAlias())
}};
this.stampLoginTime=function(){this.m_loginTime=new Date().getTime()
};
this.calcOnlineTime=function(){if(!this.isMeebome()){return 0
}if(!this.m_info){if(!this.m_bPendingInfo){this.requestInfo()
}this.m_onlineTime=0;
return 0
}var a=new Date().getTime();
var c=Math.floor((a-this.m_loginTime)/1000);
var b=this.getPersistenceInfo();
this.m_onlineTime=c+b;
return this.m_onlineTime
};
this.getOnlineTime=function(){return this.m_onlineTime
};
this.getPersistenceInfo=function(){var b=0;
if(this.isMeebome()){if(this.m_persistTime){b=this.m_persistTime
}else{var c=/<b>Description:<\/b> ([\d]+)/;
var a=c.exec(this.m_info);
if(a){this.m_persistTime=parseInt(a[1]);
b=this.m_persistTime
}}}return b
};
this.verifyInfo=function(b,a,c){if(c==404||c==500){return
}if(b!="success"){this.m_bPendingInfo=false
}else{this.m_unavailableInfoTimer=setTimeout(hitch(this,function(){this.setUnavailableInfo()
}),45000)
}this.m_bHaveRequestedInfo=true
};
this.setUnavailableInfo=function(){};
this.requestInfo=function(){if(this.isInfo()||this.m_bPendingInfo||!this.isOnline()){return
}gNetworkMgr.requestInfo(this,hitch(this,"verifyInfo"));
this.m_bPendingInfo=true;
this.m_infoRequestTime=new Date()
};
this.setInfo=function(e){if(this.m_unavailableInfoTimer!=-1){clearTimeout(this.m_unavailableInfoTimer);
this.m_unavailableInfoTimer=-1
}this.m_bPendingInfo=false;
if(!e){return e
}var c=/(<b>Online Since:<\/b> )([^\n]+)/;
var d=e.match(c);
if(d){e=e.replace(c,"$1"+new Date(d[2]).toLocaleString())
}var b=/(<b>Profile URL<\/b>: <a href=\")([^\n\"]+)\">/;
var a=e.match(b);
if(a&&a[2]){this.setProfileURL(a[2])
}this.m_info=insertTargets(e);
this.calcOnlineTime();
gPubSub.publish(this,"meebo.IMObject::changeInfo",e);
return this.m_info
};
this.isInfo=function(){return Boolean(this.m_infoRequestTime&&new Date().getTime()-this.m_infoRequestTime.getTime()<900000)
};
this.getInfo=function(){var a=this.m_info;
if(this.isMeebome()){a=gInfoDlg.updatePersistenceInfo(a,this.getOnlineTime())
}return gInfoDlg.updateIdleInfo(a,this.m_bIdle,this.m_idleTime)
};
this.isFriend=function(){if(!this.isOnlist()&&!this.m_bOnline&&gBuddyList.isLarge()&&!this.m_checkedFriendship){this.m_checkedFriendship=true;
meebo.IMObject.pendingFriendChecks.push(this);
setTimeout(meebo.IMObject.checkFriends,10)
}return this.m_isFriend
};
this.setIsFriend=createSetter("isFriend","meebo.IMObject::changeIsFriend");
this.setProfileURL=createSetter("profileURL","meebo.IMObject::changeProfileURL");
this.getProfileURL=function(){switch(this.getNetwork().getId()){case"aim":return"http://profiles.aim.com/"+this.getName();
case"yahoo":return"http://profiles.yahoo.com/"+this.getName();
case"facebook":return"http://www.facebook.com/profile.php?id="+this.getName()+"&v=info";
case"myspace":return"http://www.myspace.com/"+this.getName();
case"icq":return"http://people.icq.com/people/about_me.php?uin="+this.getName();
default:return this.m_profileURL
}}
});
meebo.IMObject.pendingFriendChecks=[];
meebo.IMObject.checkFriends=function(){gNetworkMgr.requestAreFriends(meebo.IMObject.pendingFriendChecks);
meebo.IMObject.pendingFriendChecks=[]
};
Class("meebo.Buddy",meebo.IMObject,function(a){this.m_type="buddy";
this.m_statusMessage=null;
this.m_bOnline=false;
this.m_isBusy=false;
this.m_isAway=false;
this.m_isIdle=false;
this.m_idleTime=0;
this.m_typingT=0;
this.m_isMobile=false;
this.m_isBlocked=false;
this.m_isYourself=false;
this.m_numWarnsUsed=0;
this.m_mostRecentWarn=0;
this.m_infoAim="";
this.m_conversation=null;
this.m_unreadMessageCount=0;
this.m_activityTime=0;
this.m_sortIndex="";
this.initialize=function(c,b,e,d){a(this,"initialize",[c,b]);
this.m_id=e||getBuddyId(this.m_name,b);
this.m_rawStatusMessage=(d&&d.statusMessage)||"";
if(d&&"online" in d){this.m_bOnline=d.online
}if(d&&"friend" in d){this.m_isFriend=d.friend
}this.m_alias=(d&&d.alias)||"";
this.m_presences={}
};
this.updateSortIndex=function(){var b=this.m_sortIndex;
this.m_sortIndex="";
if(this.toString()!=b){gPubSub.publish(this,"meebo.Buddy::updateSortIndex")
}};
this.toString=function(){return this.m_sortIndex||(this.m_sortIndex=(this.m_bOnline?"0"+(!this.m_isAway?"0":"1")+(!this.m_isBusy?"0":"1"):"1")+(this.m_alias||this.m_name).toLowerCase()+this.m_name)
};
this.getAlias=function(){return this.m_alias||(this.getNetwork()=="meebome"?this.m_name.substr(0,this.m_name.indexOf("@")):this.m_name)
};
this.setAlias=function(b){if(b==this.m_alias){return
}this.m_alias=b;
gPubSub.publish(this,"meebo.IMObject::changeAlias",b);
this.updateSortIndex()
};
this.getGroupId=function(b){return this.m_id+"--"+b.getId()
};
this.getPresence=function(b,d){if(!b){return
}var c=b.getId();
if(this.m_presences[c]){return this.m_presences[c]
}return new meebo.Presence(this,b,d)
};
this.getPresences=function(){return this.m_presences
};
this.hasPresences=function(){for(var b in this.m_presences){return true
}return false
};
this.setInfoAim=function(b){this.m_infoAim=b
};
this.getInfoAim=function(){return this.m_infoAim
};
this.setUnavailableInfo=function(){this.setInfo(gLang.buddyUnavailable)
};
this.getActivityTime=function(){return this.m_activityTime
};
this.updateActivityTime=function(){this.m_activityTime=Math.floor(new Date().getTime()/1000)
};
this.getOnlineStatus=function(){var b=sprintf(this.isOnline()?(this.isMobile()?gLang.isMobile:gLang.isOnline):(this.isWidgetUser()?gLang.hasLeftYourPage:gLang.isOffline),this.getAlias());
return b
};
this.setOnline=function(b){if(this.m_bOnline==b){return
}if(b&&this.isMeebome()){this.stampLoginTime()
}if(!b){this.m_isBusy=false;
this.m_isAway=false;
this.m_isIdle=false;
this.m_typingT=0;
this.m_isMobile=false
}this.m_bOnline=b;
gPubSub.publish(this,"meebo.IMObject::changeOnline",b);
this.updateSortIndex()
};
this.getConversation=function(b){return this.m_conversation||(b?this.m_conversation=new meebo.Conversation(this):null)
};
this.getTyping=function(){return this.m_typingT
};
this.setTyping=createSetter("typingT","meebo.Buddy::changeTyping");
this.isAway=function(){return this.m_isAway
};
this.setAway=function(b){if(this.m_isAway==b){return
}this.m_isAway=b;
if(b){this.setOnline(true)
}gPubSub.publish(this,"meebo.Buddy::changeAway",b);
this.updateSortIndex()
};
this.isBusy=function(){return this.m_isBusy
};
this.setBusy=function(b){if(this.m_isBusy==b){return
}this.m_isBusy=b;
if(b){this.setOnline(true);
this.setAway(false)
}gPubSub.publish(this,"meebo.Buddy::changeBusy",b);
this.updateSortIndex()
};
this.getStatusMessage=function(){if(this.m_statusMessage!=null){return this.m_statusMessage
}this.m_statusMessage=unescapeHTML(this.m_rawStatusMessage);
return this.m_statusMessage
};
this.setStatusMessage=function(b){if(!isString(b)){return
}if(this.m_rawStatusMessage==b){return
}this.m_rawStatusMessage=b;
this.m_statusMessage=null;
gPubSub.publish(this,"meebo.Buddy::changeStatusMessage")
};
this.setIdleTime=function(b){this.m_idleTime=b
};
this.getIdleTime=function(){return this.m_idleTime
};
this.isIdle=function(){return this.m_isIdle
};
this.setIdle=function(c,d){if(c){this.setOnline(true)
}this.m_isIdle=c;
if(c){var b=new Date().getTime()/1000;
this.m_idleTime=b-parseInt(d)
}gPubSub.publish(this,"meebo.Buddy::changeIdle",c,this.m_idleTime)
};
this.isMobile=function(){return this.m_isMobile
};
this.setMobile=createSetter("isMobile","meebo.Buddy::changeMobile");
this.isBlocked=function(){return this.m_isBlocked
};
this.setBlocked=createSetter("isBlocked","meebo.Buddy::changeBlocked");
this.isYourself=function(){return this.m_isYourself
};
this.setYourself=function(b){this.m_isYourself=b
};
this.isMeeboUser=function(){return/@meebo\.org$/.test(this.m_name)
};
this.isWidgetUser=function(){return/@guest[0-9]*\.meebo\.org$/.test(this.m_name)
};
this.isGuestUser=function(){return/guest\d*@gc\d*\.meebo\.org$/.test(this.m_name)
};
this.removeExpiredWarns=function(){if(((new Date()).getTime()-this.m_mostRecentWarn)>=(5*60*1000)){this.m_numWarnsUsed=0
}};
this.canWarn=function(){this.removeExpiredWarns();
return this.m_numWarnsUsed<5
};
this.addWarn=function(){this.m_numWarnsUsed++;
this.m_mostRecentWarn=(new Date()).getTime()
};
this.getRemainingWarns=function(){this.removeExpiredWarns();
return 5-this.m_numWarnsUsed
}
});
Class("meebo.Chat",meebo.IMObject,function(a){this.initialize=function(c,b){a(this,"initialize",arguments);
this.m_chatId=null;
this.m_fromAttach=false;
this.m_presences={}
};
this.isInChat=function(){for(var b in this.m_presences){var c=this.m_presences[b];
if(c&&c.isOnline()){return true
}}return false
};
this.isFromAttach=function(){return this.m_fromAttach
};
this.setFromAttach=function(b){this.m_fromAttach=b
};
this.addPresence=function(b){if(b.getBuddy().getId() in this.m_presences){return
}this.m_presences[b.getBuddy().getId()]=b;
gPubSub.publish(this,"meebo.Chat::addPresence",b)
};
this.removePresence=function(b){if(!(b.getBuddy().getId() in this.m_presences)){return
}delete this.m_presences[b.getBuddy().getId()];
gPubSub.publish(this,"meebo.Chat::removePresence",b)
};
this.getPresences=function(){return this.m_presences
};
this.hasPresences=function(){for(var b in this.m_presences){return true
}return false
};
this.getYourself=function(){for(var c in this.m_presences){var b=this.m_presences[c].getBuddy();
if(b&&b.isYourself()){return this.m_presences[c]
}}return null
};
this.getChatId=function(){return this.m_chatId
};
this.setChatId=function(b){if(this.m_chatId==b){return
}this.m_chatId=b;
if(b==null){this.m_fromAttach=false
}gPubSub.publish(this,"meebo.Chat::changeChatId",b)
}
});
Class("meebo.Room",meebo.Chat,function(a){this.initialize=function(c,d,b){if(!b){b=new meebo.Logon("",gNetworks.meebome)
}a(this,"initialize",[c,b]);
this.m_type="chat";
this.m_alias=d;
this.m_count=0;
this.m_userLastMsg=this.setLastReadMsg();
this.m_lastmsg=-1;
this.m_isPrivate=false;
this.m_passwordLength=0;
this.m_password=null;
this.m_bOnline=true;
this.m_isModeratedUrls=true;
this.m_isPersonal=c.substring(0,2)=="__";
this.m_isPartner=false;
this.m_members={};
this.m_isGuestOnly=false;
this.m_isLeaving=false;
this.m_chatName=meebo.util.splitGroupChatName(c).id||c;
this.m_isSpillover=this.m_chatName.indexOf("___spill___")>-1;
this.m_description="";
this.m_application=null;
this.m_applicationId="";
this.m_shouldAddToBuddylist=false;
this.m_widgetHash=null;
this.m_invites=null;
this.m_id=getMeeboChatId(this.m_name)
};
this.isSpillover=function(){return this.m_isSpillover
};
this.setInvites=function(d,c,b){this.m_invites={invitees:d,msg:c,msgIdx:b}
};
this.getInvites=function(){return this.m_invites
};
this.clearInvites=function(){this.m_invites=null
};
this.getGroupId=function(b){return this.m_id+"--"+b.getId()
};
this.setName=function(b){if(this.m_name==b){return
}if(this.m_name.indexOf("@")!=-1){return
}this.m_name=b;
this.m_chatName=meebo.util.splitGroupChatName(b).id;
this.m_id=getMeeboChatId(this.m_name)
};
this.setLogin=function(b){if(b==this.m_logon){return
}var e=gWindowMgr.getConvWindow(this);
if(e&&e.getImObject()==this){var c=getIMId(this.getName(),b);
var d=e.m_id;
if(c!=d){gWindowMgr.reregisterWindow(d,c);
e.m_id=c
}}this.m_logon=b;
this.m_protocol=b.getProtocol();
this.m_user=b.getName()
};
this.isModeratedUrls=function(){return this.m_isModeratedUrls
};
this.setModeratedUrls=createSetter("isModeratedUrls","meebo.Room::changeModeratedUrls");
this.isPrivate=function(){return this.m_isPrivate
};
this.setPrivate=function(b){this.m_isPrivate=b
};
this.getPasswordLength=function(){return this.m_passwordLength
};
this.setPasswordLength=function(b){this.m_passwordLength=b
};
this.getPassword=function(){return this.m_password
};
this.setPassword=function(b){this.m_password=b
};
this.setLastReadMsg=function(b){if(!b){b=Math.floor(new Date().getTime()/1000)
}if(this.m_userLastMsg==b){return
}this.m_userLastMsg=b;
gPubSub.publish(this,"meebo.Room::changeLastReadTime",b);
return this.m_userLastMsg
};
this.setLastMsg=function(b){if(!b){b=Math.floor(new Date().getTime()/1000)
}if(b==this.m_lastMsgTime){return
}this.m_lastMsg=b;
gPubSub.publish(this,"meebo.Room::changeLastMessageTime",b);
return this.m_lastMsg
};
this.getCount=function(){var d=0;
for(var b in this.m_presences){var c=this.m_presences[b];
if(c&&c.isOnline()){d++
}}return d||this.m_count
};
this.setCount=function(b){if(typeof b!="number"||b==this.m_count){return
}this.m_count=b;
gPubSub.publish(this,"meebo.Room::changeCount",b)
};
this.hasNewMessage=function(){return(this.m_userLastMsg<this.m_lastMsg)
};
this.getChatlogURL=function(){var b="http://chatlogs.meebo.com/";
var c=encodeURIComponent(this.getChatName());
if(c.substr(0,2)=="__"){b+="user/"+c.substring(2)+"/room/"
}else{b+="room/"+c+"/"
}return b+"logs/today/"
};
this.getChatName=function(){return this.m_chatName
};
this.getAlias=function(){if(this.m_isPersonal){var b=this.getChatName().substring(2).split("___spill___");
return sprintf(gLang.myRoom,b[0])+(b.length==2?" #"+b[1]:"");
return sprintf(gLang.myRoom,this.getChatName().substring(2))
}else{return this.m_alias||(this.m_chatName||"").replace("___spill___"," #")||this.m_name;
return this.m_alias||this.m_chatName||this.m_name
}};
this.getCaption=function(){return this.getAlias()
};
this.setInfo=function(c){c=a(this,"setInfo",[c]);
if(c){var b=(/<b>Description:<\/b>\s*([^<]*)\s*<br\/>/).exec(c);
this.m_description=b?b[1]:""
}};
this.getChatDescription=function(){return this.m_description
};
this.getWidgetHash=function(){return this.m_widgetHash
};
this.setWidgetHash=createSetter("widgetHash","meebo.Room::changeWidgetHash");
this.isPartner=function(){return this.m_isPartner
};
this.setPartner=createSetter("isPartner","meebo.Room::changePartner");
this.addMember=function(b){this.m_members[b.getName()]=true;
gPubSub.publish(this,"meebo.Room::addMember",b)
};
this.isMember=function(b){return this.m_members[b.getName()]
};
this.isGuestOnly=function(){return this.m_isGuestOnly
};
this.setGuestOnly=function(b){this.m_isGuestOnly=b
};
this.inviteBuddies=function(f,h,g,b){if(!f){return
}if(!(f instanceof Array)){f=[f]
}var d;
for(var e=f.length-1;
(d=f[e]);
e--){var c=this.m_presences[d.getId()];
if(c&&c.isOnline()&&!h){f.splice(e,1);
continue
}gPubSub.publish(this,"meebo.Room::invite",d)
}gNetworkMgr.requestMultiSend(f,g,this.getChatName(),this.getAlias(),b,this.constructor==meebo.ApplicationRoom)
}
});
Class("meebo.ApplicationRoom",meebo.Room,function(supr){this.initialize=function(name,application){if(!application){var app_id=parseInt(name.split("_")[1],10);
application=meebo.applicationMgr.getApplication(app_id)||new meebo.Application({app_id:app_id})
}supr(this,"initialize",[name,application&&application.alias||null,gLogon.getMeeboMeLogon()]);
this.m_application=application;
this.m_joinParams={};
this.m_launchId=null;
this.m_launchTime=0;
this.m_bAbandoned=false;
this.m_htmlSanitizeRegexps=[];
for(var i=0,htmlTagBlacklist=["script","applet","object","embed"];
i<htmlTagBlacklist.length;
i++){var tag=htmlTagBlacklist[i];
var regexp=new RegExp("<W*"+tag+".*/?>(.*</"+tag+">)?","gim");
this.m_htmlSanitizeRegexps.push(regexp)
}};
this.getAlias=function(){return this.m_alias||(this.getApplication()&&this.getApplication().getAlias())||supr(this,"getAlias")
};
this.setAlias=function(alias){if(this.m_name==alias){return
}supr(this,"setAlias",[alias])
};
this.getApplication=function(){return this.m_application
};
this.setApplication=function(application){this.m_application=application
};
this.isInfo=function(){return true
};
this.requestInfo=function(){return
};
this.getInfo=function(){var app=this.getApplication();
return'<div class="tooltipUserName"><img align=left src="'+gImages.getPath()+"network/"+this.getNetwork()+'_14_online.gif"><b>'+escapeHTML(this.getAlias())+"</b> from "+escapeHTML(app.owner_name)+"<p>"+app.info+"</p></div><br>"
};
this.sendMsg=function(msg,msgType,to){msg="msg="+encodeURIComponent(msg)+"&msgType="+encodeURIComponent(msgType||0);
var args={sender:this.getUser(),receiver:to||this.getName(),protocol:this.getProtocol(),msg:msg,mt:"a",ch:this.getChatId()};
gNetworkMgr.doRequest("send",args)
};
this.receiveMsg=function(msg,msgType,from){switch(msgType){case meebo.ApplicationRoom.MSG_TYPE_APP:try{var args=eval("("+msg+")")
}catch(e){break
}args.from=from;
gPubSub.publish(this,"meebo.ApplicationRoom::receiveAppMsg",args);
break;
case meebo.ApplicationRoom.MSG_TYPE_IM:gPubSub.publish(this,"meebo.ApplicationRoom::receiveIMMsg",msg);
break;
case meebo.ApplicationRoom.MSG_TYPE_HTML_IM:msg=this.sanitizeHtml(msg);
gPubSub.publish(this,"meebo.ApplicationRoom::receiveIMMsg",msg);
break
}};
this.sanitizeHtml=function(html){for(var i=0;
i<this.m_htmlSanitizeRegexps.length;
i++){html=html.replace(this.m_htmlSanitizeRegexps[i],"")
}html=html.replace(/<.*on\w+=('|")?.*('|")?\W>/gim,"");
html=html.replace(/<.*href=(?!http|"http|'http|https|"https|'https|mailto|"mailto|'mailto).*>/gim,"");
return html
};
this.getCaption=function(){var caption=this.getAlias();
var aliases=[];
for(var buddyId in this.m_presences){var presence=this.m_presences[buddyId];
if(presence.getBuddy().isYourself()||presence.isPending()||!presence.isOnline()){continue
}aliases.push(presence.getAlias())
}if(aliases.length){caption+=" ("+aliases.join(", ")+")"
}return caption
};
this.setJoinParams=function(time,hash){this.m_joinParams={time:time,hash:hash}
};
this.getJoinParams=function(){return this.m_joinParams
};
this.setLaunchTime=function(launchTime){this.m_launchTime=launchTime
};
this.getLaunchTime=function(){return this.m_launchTime
};
this.getLaunchId=function(){return this.m_launchId
};
this.setLaunchId=function(launchId){this.m_launchId=launchId
};
this.getAbandoned=function(){return this.m_bAbandoned
};
this.setAbandoned=function(abandoned){this.m_bAbandoned=abandoned
};
this.logLoadTime=function(name){var timeDelta=Math.floor((new Date().getTime()-this.getLaunchTime())/1000);
gNetworkMgr.doUILog("apps",(this.getInvites()?"launch":"join")+name,timeDelta,true,this.getApplication().app_id)
}
});
meebo.ApplicationRoom.MSG_TYPE_APP=0;
meebo.ApplicationRoom.MSG_TYPE_IM=1;
meebo.ApplicationRoom.MSG_TYPE_HTML_IM=2;
Class("meebo.ProtocolChat",meebo.Chat,function(a){this.initialize=function(d,c,b){a(this,"initialize",[c||d,b]);
this.m_type="protocolchat";
this.m_buddyParent=d;
this.m_alias=c
};
this.getId=function(){return getGroupChatId(this.getProtocol(),this.getUser(),this.m_chatId)
};
this.setName=function(c){if(this.m_name==c){return
}var e=gWindowMgr.getConvWindow(this);
if(e){var b=getIMId(c,this.m_logon);
var d=e.m_id;
if(b!=d){gWindowMgr.reregisterWindow(d,b);
e.m_id=b
}}this.m_name=c
};
this.getBuddyParent=function(){return this.m_buddyParent
};
this.getCaption=function(){return this.m_alias
};
this.isOnlist=function(){return true
};
this.isMember=function(){return false
}
});
Class("meebo.Presence",function(){this.initialize=function(b,a,c){this.m_buddy=b;
this.m_chat=a;
if(b&&a){b.m_presences[a.getId()]=this;
a.addPresence(this)
}this.m_alias=c;
this.m_joiner=null;
this.m_joinerProtocol=null;
this.m_isPending=false;
this.m_isOnline=false;
this.m_isOwner=false;
this.m_isSubModerator=false;
this.m_isMuted=false;
this.m_warnCount=0;
this.m_media=[];
this.m_appArgs={};
this.m_tree
};
this.getChat=function(){return this.m_chat
};
this.getBuddy=function(){return this.m_buddy
};
this.getAlias=function(){return this.m_alias||this.m_buddy.getAlias()
};
this.setAlias=createSetter("alias","meebo.Presence::changeAlias");
this.isPending=function(){return this.m_isPending
};
this.setPending=function(a){this.m_isPending=a
};
this.isOnline=function(){return this.m_isOnline
};
this.setOnline=createSetter("isOnline","meebo.Presence::changeOnline");
this.isOwner=function(){return this.m_isOwner
};
this.setOwner=createSetter("isOwner","meebo.Presence::changeOwner");
this.isSubModerator=function(){return this.m_isSubModerator
};
this.setSubModerator=createSetter("isSubModerator","meebo.Presence::changeSubModerator");
this.isMuted=function(){return this.m_isMuted
};
this.setMuted=function(a){this.m_isMuted=a
};
this.isMember=function(){return this.m_chat?this.m_chat.isMember(this.m_buddy):false
};
this.addMedia=function(a){this.m_media.push(a);
while(this.m_media.length>5){this.m_media.shift()
}};
this.getMedia=function(){return this.m_media
};
this.setWarnCount=function(a){this.m_warnCount=a>0?a:0
};
this.getWarnCount=function(){return this.m_warnCount
};
this.setAppArgs=function(a){this.m_appArgs=a
};
this.getAppArgs=function(){return this.m_appArgs
}
});
meebo.Prefs=function(){this.m_defaultIcon="defaultbuddyicon.gif";
this.m_icon;
this.m_savedPrefs={privacy:"allow_all",emoticons:true,audioSend:true,audioReceive:true,gchatlog:true,buddySort:"alias",font:{type:"Arial",size:11,color:"#000000",bBold:false,bItalics:false,bUnderline:false},nAwayMessages:4,awayMessage0:gLang.rightBack,awayMessage1:gLang.busy,awayMessage2:gLang.sleeping,awayMessage3:gLang.awayComputer,lastCustomAwayMessage:""};
this.m_dirtyPrefs={};
this.m_savedAccountPrefs={};
this.m_dirtyAccountPrefs={};
this.m_accounts={};
this.m_saveTimer=null;
gClient.subscribe("info::prefs",this,"onReceivePrefs");
gPubSub.subscribe("meebo.NetworkMgr::iconSet",this,hitch(this,"logBrandChange","buddy_icons"));
gPubSub.subscribe("meeboApp.ConsolePageMain::setWallpaper",this,hitch(this,"logBrandChange","wallpapers"))
};
meebo.Prefs.prototype.logBrandChange=function(h,c,a,e){var g;
var f;
if(e=="custom"){g="custom-upload";
f=false
}else{if(e&&(e.indexOf("http://")==0||e.indexOf("url")==0)){var b=this.extractShareIdFromUrl(e,h);
g=b[0],e=b[1];
f=true
}else{g="stock/"+e;
f=false
}}if(!f||(h!="buddy_icons"&&h!="wallpapers")){gNetworkMgr.doUILog(h,(f?"branded":"unbranded"),g,true)
}else{var d=(h=="buddy_icons"?"buddyicon":"wallpaper");
meebo.util.createTrackingPixel({component:"MediaBar",type:d,group:d,shareId:g,item:e},gLogon.getLogons())
}};
meebo.Prefs.prototype.extractShareIdFromUrl=function(b,e){var d=b?b.split("/"+e+"/"):null;
var c=d&&d[0]?d[0].split("/").pop():"";
if(d[1]&&d[1].indexOf("/")!=-1){d[1]=d[1].split("/")[1]
}var a=d&&d[1]?d[1].split(".")[0]:"";
return[c,a]
};
meebo.Prefs.prototype.setIcon=function(a){if(this.m_icon==a){return
}this.m_icon=a;
gPubSub.publish(this,"meebo.Prefs::changeIcon",this.getIcon())
};
meebo.Prefs.prototype.getDefaultIcon=function(){return this.m_defaultIcon
};
meebo.Prefs.prototype.getIcon=function(){return this.m_icon||this.m_defaultIcon
};
meebo.Prefs.prototype.getAccountPref=function(b,a,c){var d=b.getId();
if(!(d in this.m_accounts)){return c
}else{return(a in this.m_dirtyAccountPrefs[d]?this.m_dirtyAccountPrefs[d][a]:(a in this.m_savedAccountPrefs[d]?this.m_savedAccountPrefs[d][a]:c))
}};
meebo.Prefs.prototype.getPref=function(a,b){if(a.length>256){a=a.substr(0,256)
}return(a in this.m_dirtyPrefs?this.m_dirtyPrefs[a]:(a in this.m_savedPrefs?this.m_savedPrefs[a]:b))
};
meebo.Prefs.prototype.saveAccountPref=function(b,a,c){var e=b.getId();
if(!(e in this.m_accounts)){this.m_accounts[e]={user:b.getName(),protocol:b.getProtocol(),id:e};
this.m_savedAccountPrefs[e]={};
this.m_dirtyAccountPrefs[e]={}
}var d=false;
if(typeof c!="object"&&this.m_savedAccountPrefs[e][a]===c){d=a in this.m_dirtyAccountPrefs[e];
delete this.m_dirtyAccountPrefs[e][a]
}else{d=typeof c=="object"||c!==this.m_dirtyAccountPrefs[e][a];
this.m_dirtyAccountPrefs[e][a]=c
}if(d){gPubSub.publish(this,"meebo.Prefs::accountPref",b,a,c)
}return d
};
meebo.Prefs.prototype.deleteAccountPref=function(b,a){var c=b.getId();
if(c in this.m_accounts&&(a in this.m_savedAccountPrefs[c]||a in this.m_dirtyAccountPrefs[c])){delete this.m_savedAccountPrefs[c][a];
delete this.m_dirtyAccountPrefs[c][a];
gPubSub.publish(this,"meebo.Prefs::accountPref",b,a)
}};
meebo.Prefs.prototype.savePref=function(a,b){var c=false;
if(a.length>256){a=a.substr(0,256)
}if(typeof b=="string"&&b.length>256){b=b.substr(0,256)
}if(typeof b!="object"&&this.m_savedPrefs[a]===b){c=a in this.m_dirtyPrefs;
delete this.m_dirtyPrefs[a]
}else{c=typeof b=="object"||b!==this.m_dirtyPrefs[a];
this.m_dirtyPrefs[a]=b
}if(c){clearTimeout(this.m_saveTimer);
this.m_saveTimer=setTimeout(hitch(this,"doPreferenceSync"),3000)
}return c
};
meebo.Prefs.prototype.doPreferenceSync=function(b){var a=this.serialiseLatestPrefs();
if(a){gNetworkMgr.doRequest("prefset",a,null,b)
}};
meebo.Prefs.prototype.serialiseLatestPrefs=function(){if(!gLogon.getMeeboUser()){return""
}if(this.m_saveTimer){clearTimeout(this.m_saveTimer);
this.m_saveTimer=null
}var d={muser:gLogon.getMeeboUser(),num:0};
for(var b in this.m_dirtyPrefs){var e=d.num++;
var c=this.m_dirtyPrefs[b];
var a=JSON.stringify(c);
if(typeof c=="string"){while(a.length>256){c=c.substring(0,c.length-2);
a=JSON.stringify(c)
}}d["name"+e]=b;
d["value"+e]=a;
this.m_savedPrefs[b]=c;
delete this.m_dirtyPrefs[b]
}return d.num?d:null
};
meebo.Prefs.prototype.onReceivePrefs=function(c){var e={};
var a=0;
for(var b in c){var d=c[b];
switch(b){case"wallpapers0":this.savePref(b,d);
if(d){gPubSub.publish(this,"meebo.Prefs::loadWallpaper",d.fullUrl)
}break;
case"meeboSkin":this.saveSkinPref(d);
break;
case"buddySort":this.saveBuddySortPref(d);
break;
case"audioSend":this.saveSoundPref(d,null);
break;
case"audioReceive":this.saveSoundPref(null,d);
break;
case"nAwayMessages":this.receiveAwayMessagePrefs(d);
break;
case"longPrefs":this.requestLongPrefs(d);
break;
case"enableWallpaper":this.savePref(b,d);
if(d){break
}gPubSub.publish(this,"meebo.Prefs::loadWallpaper",null);
break;
default:this.savePref(b,d)
}if(b in this.m_dirtyPrefs){this.m_savedPrefs[b]=this.m_dirtyPrefs[b];
delete this.m_dirtyPrefs[b]
}}gPubSub.publish(this,"meebo.Prefs::receivePrefs",c)
};
meebo.Prefs.prototype.receiveRoomPrefs=function(k,m,d,a){if(!d){return
}var g=[];
for(var e=0;
e<k.length;
e++){var q=k[e];
var f="room:"+q.getChatName();
if(!q.isOnlist()){g.push(q)
}var l=m[f];
if(!l){continue
}var o=this.getPref(f,{});
var p=false;
for(var c in o){if(!(c in l)||o[c]!=l[c]){p=true
}}for(var c in l){if(!(c in o)){o[c]=l[c]
}}if(!p){this.m_savedPrefs[f]=o;
delete this.m_dirtyPrefs[f]
}else{this.m_dirtyPrefs[f]=o;
delete this.m_savedPrefs[f]
}}if(g.length){var b=[];
var n=gBuddyList.getGroupByName(gLang.recentRooms);
if(n){b=n.getBuddies({type:"chat"});
b.sort(function(v,s){var t=gPrefs.getRoomPref(v.getChatName(),"lastAccess",0);
var u=gPrefs.getRoomPref(s.getChatName(),"lastAccess",0);
return t-u
})
}for(var e=0;
e<g.length;
e++){if(b.length>=5){var h=b.shift();
gNetworkMgr.requestRemoveBuddies({chat:h})
}var q=g[e];
gNetworkMgr.requestAddBuddy(hitch(gNetworkMgr,"receiveAddBuddy"),q.getName(),"jabber",gLang.recentRooms,q.getLogin().getName(),true)
}}};
meebo.Prefs.prototype.receiveAwayMessagePrefs=function(b){var a=this.getPref("nAwayMessages");
for(a--;
a>=b;
a--){delete this.m_savedPrefs["awayMessage"+b];
delete this.m_dirtyPrefs["awayMessage"+b]
}delete this.m_dirtyPrefs.nAwayMessages;
this.m_savedPrefs.nAwayMessages=b;
gPubSub.publish(this,"meebo.Prefs::changeAwayMessages")
};
meebo.Prefs.prototype.saveAwayMessagePrefs=function(c,a){var d=this.getPref("nAwayMessages");
if(a<0||a>=d){if(!c){return
}this.savePref("nAwayMessages",d+1);
this.savePref("awayMessage"+d,c)
}else{if(c==""){for(var b=a;
b<(d-1);
b++){this.savePref("awayMessage"+b,this.getPref("awayMessage"+(b+1)))
}this.savePref("nAwayMessages",d-1)
}else{this.savePref("awayMessage"+a,c)
}}gPubSub.publish(this,"meebo.Prefs::changeAwayMessages")
};
meebo.Prefs.prototype.getCustomAwayMessages=function(){var c=this.getPref("nAwayMessages");
var a=[];
for(var b=0;
b<c;
b++){a.push(stripWhitespace(this.getPref("awayMessage"+b)))
}return a
};
meebo.Prefs.prototype.saveFontPref=function(a,b){var c=this.getPref("font");
c[a]=b;
this.savePref("font",c)
};
meebo.Prefs.prototype.saveBuddySortPref=function(a){if(this.savePref("buddySort",a)&&typeof gBuddyListDlg!="undefined"&&gBuddyListDlg){gBuddyListDlg.sortGroups(a)
}};
meebo.Prefs.prototype.saveSkinPref=function(a){if(this.savePref("meeboSkin",a)){gSkins.setSkin(a);
gNetworkMgr.doUILog("prefs","skin",a,false)
}};
meebo.Prefs.prototype.getLongPref=function(d){var c=this.getPref("longPrefs",{});
if(!(d in c)){return[]
}var b=[];
for(var a=0;
a<c[d];
a++){b.push(this.getPref(d+a))
}return b
};
meebo.Prefs.prototype.saveLongPref=function(d,c){for(var a=0;
a<c.length;
a++){if(this.m_savedPrefs[d+a]!=c[a]){this.savePref(d+a,c[a])
}}var b=this.getPref("longPrefs",{});
b[d]=c.length;
this.savePref("longPrefs",b)
};
meebo.Prefs.prototype.requestLongPrefs=function(c){var a=[];
for(prefName in c){for(var b=0;
b<c[prefName];
b++){a.push(prefName+b)
}}if(a.length>0){gNetworkMgr.requestPrefs(a)
}this.savePref("longPrefs",c)
};
meebo.Prefs.prototype.saveWallpaperPref=function(f,c,d){var a={thumbUrl:f,fullUrl:c};
if(d){a.title=d
}var e=this.getLongPref("wallpapers");
for(var b=e.length-1;
b>=0;
b--){if(!e[b]||(e[b].thumbUrl==f||e[b].fullUrl==c)){if(!a.title&&e[b]&&e[b].title){a.title=e[b].title
}e.splice(b,1)
}}e.unshift(a);
e=e.slice(0,6);
this.saveLongPref("wallpapers",e)
};
meebo.Prefs.prototype.getWallpaperPref=function(){return this.getLongPref("wallpapers")
};
meebo.Prefs.prototype.saveBuddyIconPref=function(c){var b=this.getLongPref("buddyIcons");
for(var a=b.length-1;
a>=0;
a--){if(b[a]==c){b.splice(a,1)
}}b.unshift(c);
b=b.slice(0,6);
this.saveLongPref("buddyIcons",b)
};
meebo.Prefs.prototype.getBuddyIconPref=function(){return this.getLongPref("buddyIcons")
};
meebo.Prefs.prototype.saveSoundPref=function(c,b){if(typeof c!="boolean"){c=this.getPref("audioSend")
}if(typeof b!="boolean"){b=this.getPref("audioReceive")
}var d=!(this.getPref("audioSend")||this.getPref("audioReceive"));
var a=(this.getPref("audioSend")!=c||this.getPref("audioReceive")!=b);
if(typeof gAudioBtn!="undefined"&&gAudioBtn&&a){if(!(c||b)){gAudioBtn.m_element.sound=false;
util.cookie.save("sound",gAudioBtn.m_element.sound);
gAudioBtn.m_imageBase="buttons/noaudio";
gSounds.mute();
gAudioBtn.refreshImage()
}else{if(d){gAudioBtn.m_element.sound=true;
util.cookie.save("sound",gAudioBtn.m_element.sound);
gAudioBtn.m_imageBase="buttons/audio";
gSounds.unmute();
gAudioBtn.refreshImage()
}}}this.savePref("audioSend",c);
this.savePref("audioReceive",b)
};
meebo.Prefs.prototype.getRoomPref=function(d,a,c){var b="room:"+d;
var e=this.getPref(b,{});
return(a in e?e[a]:c)
};
meebo.Prefs.prototype.saveRoomPref=function(d,a,c){if(!d||d.constructor!=meebo.Room){return
}var b="room:"+d.getChatName();
var e=this.getPref(b,{});
e[a]=c;
return this.savePref(b,e)
};
meebo.Prefs.prototype.updateRoomLastAccess=function(a){this.saveRoomPref(a,"lastAccess",Math.floor(new Date().getTime()/1000))
};
meebo.Widgets=function(){this.m_widgets=null;
this.m_defParams={d:false}
};
meebo.Widgets.prototype.requestWidgets=function(){gNetworkMgr.doRequest("gwid",{muser:gLogon.getMeeboUser()},hitch(this,"receiveWidgets"))
};
meebo.Widgets.prototype.receiveWidgets=function(b,a,c){if(!b){return false
}this.m_widgets=b;
for(var d in this.m_widgets){this.m_widgets[d].a=null;
this.m_widgets[d].blc=null;
this.m_widgets[d].bfc=null;
this.m_widgets[d].tbc=null;
this.m_widgets[d].tbc2=null;
this.m_widgets[d].tbc3=null;
this.m_widgets[d].tbc4=null;
this.m_widgets[d].tbtc=null;
this.m_widgets[d].hbfc=null;
this.m_widgets[d].ibfc=null;
this.m_widgets[d].sbfc=null;
this.m_widgets[d].dtc=null
}return true
};
meebo.Widgets.prototype.addWidget=function(d,a,e,f){var b=gLogon.getMeeboUser();
if(!b){return
}var c={o:b,i:d,d:0,npairs:2,"1n":"w","1v":a,"2n":"h","2v":e};
gNetworkMgr.doRequest("mmc",c,hitch(this,"onAdd",{n:d,w:a,h:e,c:f}))
};
meebo.Widgets.prototype.onAdd=function(e,c,b,f){var d=false;
if(b&&c.length==10){d=true;
var a=new Object();
a.n=e.n;
a.w=e.w;
a.h=e.h;
a.d=false;
a.a=null;
a.blc=null;
a.bfc=null;
a.tbc=null;
a.tbc2=null;
a.tbc3=null;
a.tbc4=null;
a.tbtc=null;
a.hbfc=null;
a.ibfc=null;
a.sbfc=null;
a.dtc=null;
if(!this.m_widgets){this.m_widgets=new Object()
}this.m_widgets[c]=a
}if(e.c){e.c(d,d?"":c,d?c:"",e.n,e.w,e.h)
}};
meebo.Widgets.prototype.deleteWidgets=function(f,g){if(!f||!f.length||!this.m_widgets){if(g){g(true,"")
}return
}var b=gLogon.getMeeboUser();
if(!b){return
}var c={o:b};
var e=0;
for(var d=0;
d<f.length;
d++){var a=this.m_widgets[f[d]];
if(!a){continue
}e++;
c[e+"h"]=f[d];
c[e+"i"]=a.n
}c.nhs=e;
if(e>0){gNetworkMgr.doRequest("mmd",c,hitch(this,"onDelete",{hl:f,c:g}))
}};
meebo.Widgets.prototype.onDelete=function(e,a,c,f){var d=false;
if(!c.length){d=true;
for(var b=0;
b<e.hl.length;
b++){if(this.m_widgets[e.hl[b]]){delete this.m_widgets[e.hl[b]]
}}}if(e.c){e.c(d,d?"":c)
}};
meebo.Widgets.prototype.modifyWidget=function(d,c){var a=getMyMeeboId();
if(gWindows[a]){var b=gWindows[a];
if(b.m_delegate.m_meeboMePaneContent){b.m_delegate.m_meeboMePaneContent.updateWidget(d,c)
}}};
meebo.Widgets.prototype.updateWidgets=function(l,m){if(!l||!this.m_widgets){if(m){m(true,"")
}return
}var h=gLogon.getMeeboUser();
if(!h){return
}var g={o:h};
var k=1;
var a=this.copyWidgets();
for(var e in l){if(!this.m_widgets[e]){continue
}var b=l[e];
var f=this.m_widgets[e];
var n=0;
var d=false;
for(var c in f){if(isDefined(b[c])&&b[c]!=f[c]){d=true;
if(c!="d"&&c!="n"){n++;
g[k+"n"+n]=c;
g[k+"v"+n]=b[c]
}a[e][c]=b[c]
}}if(d){g[k+"i"]=b.n;
g[k+"d"]=b.d?"true":"false";
g[k+"h"]=e;
g[k+"npairs"]=n;
k++
}}if(k>1){g.nhs=k-1;
gNetworkMgr.doRequest("mmw",g,hitch(this,"onUpdate",{wi:a,c:m}))
}else{if(m){m(true,"")
}}};
meebo.Widgets.prototype.onUpdate=function(d,b,a,e){var c=false;
if(!b.length){c=true;
this.m_widgets=d.wi
}if(d.c){d.c(c,c?"":b)
}};
meebo.Widgets.prototype.getWidgets=function(){return this.m_widgets
};
meebo.Widgets.prototype.copyWidgets=function(){if(!this.m_widgets){return null
}var b=new Object();
for(var c in this.m_widgets){if(!this.m_widgets[c]){continue
}var a=this.m_widgets[c];
b[c]=new Object();
for(var d in a){b[c][d]=a[d]
}}return b
};
meebo.Widgets.prototype.hasWidgets=function(){if(!this.m_widgets){return false
}return !isEmpty(this.m_widgets)
};
meebo.util={};
meebo.util.isICQ=function(b){if(!b||!b.length||isEmail(b)){return false
}var c=b.charAt(0);
var a=parseInt(c,10);
if(isNaN(a)){return false
}return true
};
meebo.util.padRoomName=function(a){return a+decToHex(String(new Date().getTime())+String(Math.ceil(Math.random()*1000)))
};
meebo.util.accessByIP=function(){var b=String(document.location.host);
var a=/.+\.meebo\.com/i;
return a.exec(b)==null
};
meebo.util.normalizeRoomName=function(a){if(a){return a.replace(/[^\w]+/g,"").toLowerCase()
}};
meebo.util.getDefaultGroup=function(e){var d;
switch(String(e)){case"yahoo":d="Friends";
break;
case"msn":d="Individuals";
break;
case"meebome":d="meebome";
break;
default:d="Buddies"
}var b=gBuddyList.getGroups();
for(var a=0,c;
(c=b[a]);
a++){if(c.getName().toLowerCase()==d.toLowerCase()){d=c.getName();
break
}}return d
};
meebo.util.stripJabber=function(a){if(!a){return""
}var b=a.indexOf("/");
if(b!=-1){var c=a.substr(0,b);
if(!gBuddyList.isJabberGroup(c)){a=c
}}return a
};
meebo.util.stripMeebo=function(b){var a=b.indexOf("@meebo.org");
if(a>-1){return b.substr(0,a)
}return b
};
meebo.util.isMeeboGroupChat=function(a,b){return b=="meebome"&&/@conference.gc\d*.meebo.org$/i.test(a)
};
meebo.util.splitGroupChatName=function(b){var a=b.split("@");
return{id:a[0],server:a[1]}
};
meebo.util.isDefaultGroupChatGroup=function(a){return(a=="meebo chatrooms")
};
meebo.util.getMeeboGroupChatLink=function(c){var b=/https?\:\/\/(.+\.meebo\.com|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\/room\/([^\/]+)\/(#.*)?([^a-zA-Z]|$)/i;
var a=b.exec(c);
if(a&&a[2]){return a[2]
}b=/https?\:\/\/(.+\.meebo\.com|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\/user\/([^\/]+)\/room\/(#.*)?([^a-zA-Z]|$)/i;
a=b.exec(c);
if(a&&a[2]){return"__"+a[2]
}return null
};
meebo.util.getMeeboApplicationLink=function(c){var b=/https?\:\/\/(.+\.meebo\.com|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\/app\/([^\/]+)\/(#.*)?([^a-zA-Z]|$)/i;
var a=b.exec(c);
if(a&&a[2]){return a[2]
}return null
};
meebo.util.getMeeboShareLink=function(c){var b=/^https?:\/\/[^\/]*\.meebo\.com\/share\/([^\/#\?]*)\/?(\?.*)?/;
var a=b.exec(c);
if(a&&a[1]){return{share:a[1],query:(a[2]||"").substr(1)}
}return null
};
meebo.util.generateMeeboShareLink=function(b,a){return util.query.addParams("http://www.meebo.com/share/"+b,a||{})
};
meebo.util.getOriginContentPath=function(){return"http"+(ui.isHttps?"s":"")+"://"+((ui.isHttps||meebo.util.accessByIP())?"origin-":"")+"share.meebo.com/content/"
};
meebo.util.getWallpaperUrl=function(c,a,b){b=b||"1024x768";
return meebo.util.getOriginContentPath()+c+"/wallpapers/"+b+"/"+a+".jpg"
};
meebo.util.getWallpaperThumbUrl=function(b,a){return meebo.util.getWallpaperUrl(b,a,"67x50")
};
meebo.util.getWallpaperPreviewUrl=function(b,a){return meebo.util.getWallpaperUrl(b,a,"130x98")
};
meebo.util.createAccount=function(c,e,b){c=stripWhitespace(c);
if(!c){return gLang.noName
}if(!b){return gLang.noPass
}if(e=="meebo"){e="meebome"
}e=gNetworks[e];
if(e.isCIMPartner()){return gLogon.addCIMAccount(c,b,e)
}var d=meebo.util.normalizeLogon(c,e,b);
if(d.error){return error
}c=d.name,e=d.network;
if(e=="meebome"){c=meebo.util.stripMeebo(c);
return gLogon.addMeeboAccount(c,b)
}var a=gLogon.addLogon(c,e);
a.setPassword(b);
return a
};
meebo.util.normalizeLogon=function(d,e,c){if(e=="meebo"){e="meebome"
}e=gNetworks[e];
if(e){switch(e.getId()){case"gtalk":case"jabber":case"meebome":var a=(d||"").replace(/^[^@]*@/,"").replace(/\/.*$/,"");
for(var f in gNetworks){f=gNetworks[f];
if(f.getProtocol().isJabberBased()&&a in arrayToObject(f.getDomains())){e=f;
break
}}break
}}if(!d){var b=gLang.noName
}else{if(d.indexOf("@")==-1&&e.getDomains().length){d=normalizeString(d+"@"+e.getDomains()[0])
}if(e=="yahoo"){d=d.replace(/@yahoo\.com$/i,"")
}}if(!b&&typeof c=="string"&&!c){b=gLang.noPass
}return{error:b,name:d,network:e}
};
meebo.util.createTrackingPixel=function(b,e,f){if(e){if(!(e instanceof Array)){e=[e]
}for(var d=0;
d<e.length;
d++){b["ln"+d]=e[d].getName();
b["lp"+d]=e[d].getProtocol()
}}if(f){if(!(f instanceof Array)){f=[f]
}for(var d=0;
d<f.length;
d++){b["bn"+d]=f[d].getName();
b["bp"+d]=f[d].getProtocol()
}}if("gTargeting" in window){var a=gTargeting.getTargeting();
for(var c in a){b[c]=a[c]
}}new ui.TrackingPixel(b).create()
};
function getMeeboChatId(a){return a&&normalizeString(a.split("@")[0]).replace(/["&\\\/:<>@]/g,"")
}function getBuddyId(b,a){return normalizeString(b)+"-"+a.getId()+"brow"
}function parseBuddyId(c){var b=c.indexOf("-");
var a=parseLogonId(c.substring(b+1,c.length-4));
if(a==null){return null
}a.name=c.substring(0,b);
return a
}function getCIMAccountId(b,a){return a+"-"+meebo.util.stripJabber(b)
}function getGroupChatId(c,a,b){return normalizeString(c)+"@"+a+"@"+b
}function getBuddyGroupId(a){return compressSpaces(a).toLowerCase()+"bgroup"
}function getIMId(b,a){var c=a.getProtocol();
if(meebo.util.isMeeboGroupChat(b,a.getNetwork())){b=meebo.util.splitGroupChatName(b).id
}else{if(c=="msn"){if(b.indexOf("@")==-1){b+="@hotmail.com"
}}else{if(c.isJabberBased()){b=meebo.util.stripJabber(b)
}}}return normalizeString(b)+":"+a.getId()+"-im"
}function getLogonId(a,b){if(b=="msn"){if(a.indexOf("@")==-1){a+="@hotmail.com"
}}else{if(gProtocols[b].isJabberBased()){a=meebo.util.stripJabber(a)
}}return normalizeString(a)+"-"+normalizeString(b)
}function parseLogonId(c){var b=c.indexOf("-");
var a=c.substring(b+1);
return a in gProtocols?{user:c.substring(0,b),protocol:a}:null
}function getFeedId(a,b){return a+"::"+encodeURIComponent(b)
}function parseFeedId(b){var a=b.split("::");
return{type:a[0],url:decodeURIComponent(a[1])}
}function getNotificationId(a,b){return a.getId()+"::"+b
}meebo.util.message={};
meebo.util.message.parseIMHistory=function(l){var g=new RegExp("<br/><hr size=1><div class='ImChatHeader'>([a-zA-Z]+), (\\d{4}) ([a-zA-Z]+) (\\d+) &#40;(\\d{2}):(\\d{2}):(\\d{2})&#41;</div><hr size=1>");
var k={January:0,February:1,March:2,April:3,May:4,June:5,July:6,August:7,September:8,October:9,November:10,December:11};
var d=[];
while(true){var h=l.match(g);
if(!h){if(l){d.push(l)
}break
}var c=new Date(parseInt(h[2],10),k[h[3]],parseInt(h[4],10),parseInt(h[5],10),parseInt(h[6],10),parseInt(h[7],10));
var b=l.substr(0,h.index);
var n=l.substr(h.index+h[0].length);
if(b){d.push(b)
}d.push(c);
l=n
}var e=new RegExp("<span class='([a-zA-Z]+)'>\\[(\\d{2}):(\\d{2})\\] ([^>]+)</span>: (.+)<br/>\\n");
for(var f=0;
f<d.length;
f++){var l=d[f];
if(typeof l!="string"){continue
}d.splice(f,1);
while(true){var h=l.match(e);
if(!h){if(l){d.splice(f++,0,l)
}break
}var m=h[1]=="ImSend";
var c=new Date(0);
c.setHours(parseInt(h[2],10));
c.setMinutes(parseInt(h[3],10));
var a=h[4];
var o=h[5];
var b=l.substr(0,h.index);
var n=l.substr(h.index+h[0].length);
if(b){d.splice(f++,0,b)
}d.splice(f++,0,{isSender:m,nick:a,date:c,message:o});
l=n
}}return d
};
meebo.util.message.fixRoomHistoryDates=function(h){var f=/\[(\d*)-(\d*)-(\d*) (\d*):(\d*):(\d*)\]/g;
var c;
var e=new Date(0);
while(c=f.exec(h)){var g=new Date(0);
g.setUTCFullYear(parseInt(c[1],10),parseInt(c[2],10)-1,parseInt(c[3],10));
g.setUTCHours(parseInt(c[4],10));
g.setUTCMinutes(parseInt(c[5],10));
g.setUTCSeconds(parseInt(c[6],10));
var b="";
if(g.getFullYear()!=e.getFullYear()||g.getMonth()!=e.getMonth()||g.getDate()!=e.getDate()){b='<span><hr><div class="ImChatHeader">'+sprintf(gLang.dateFormat,getDayOfTheWeekString(g.getDay()),getMonthString(g.getMonth()),g.getDate(),g.getFullYear())+"</div><hr></span>";
e.setTime(g.getTime())
}var a=g.getHours()<10?"0"+g.getHours():g.getHours();
var d=g.getMinutes()<10?"0"+g.getMinutes():g.getMinutes();
b+="["+a+":"+d+"]";
h=h.substr(0,f.lastIndex-c[0].length)+b+h.substr(f.lastIndex);
f.lastIndex-=c[0].length-b.length
}return h
};
meebo.util.message.fixRoomHistoryMessages=function(a){a=a.replace(/(\[\d{2}:\d{2}\]) --- (.*) has joined/g,gLang.buddyJoinChatRegExp);
a=a.replace(/(\[\d{2}:\d{2}\]) --- (.*) has left/g,gLang.buddyLeaveChatRegExp);
a=a.replace(/(\[\d{2}:\d{2}\]) --- (.*) is now known as (.*)/g,gLang.buddyNameChangeRegExp);
return a
};
meebo.util.emoticons={regex:/\/(\/\:\||\:(\-\)|\)))|b\-\(|8(\(\|\)|\)|\-\))|\:(\^(o|O)|arrow\:|b|meebo\:|\?|\@\)|o|B|p(irate\:)?|s|D|x|\||O|P|\!\:|S|T|\&(apos\;(\(|D)|lt\;|gt\;)|\'(\(|D)|\((\(|\|\))?|\)(\)|\&gt\;\-)?|X|\*|\-(b|\?|o|p|B|s|D|x|\||P|\#|S|T|\&(amp\;|lt\;|gt\;)|\((\()?|X|\)|\*|\\)|\\)|\;(\-(P|\)|p)|p|P|\))|\=(\-(P|\))|\)|P)|o\:(\-\)|\))|\@\}\;\-|B(\-\)|\))|x(\(|\-(\(|D))|L\-\)|\|\-\)|O\:(\-\)|\))|P\)|\$(\-\)|\))|\&(lt\;\:(\-(P|p)|o\))|gt\;(\&gt\;\:(\-(\(|\))|\)|\()|\:(\-(o|O|\(|\))|o|O|D\&lt\;|\(|\))))|\((a(ng(el\)|ry\))|rr(\)|r\)))|b(e(nder\)|aten\))|omb\)|rainslug\))|c(ry\)|ool\)|h(icago\)|eezburger\)))|d(oraemon\)|evil\))|e(ek\)|vil\)|mo\))|f(ingerblaster\)|oursquare\)|ail\))|g(host\)|e(nderbender\)|lato\))|ri(n\)|llz\)))|h(ug\)|mm\))|3d\)|jj\)|l(o(ser\)|ve\)|l(\)|wut\)))|etsgogiants\)|iar\)|\))|m(o(n(ey\)|keyking\))|to\)|m\))|eebo(simon\)|\))|ikey\)|\)|ad\))|n(e(utral\)|rd(\)|pirate\)))|inja\)|utella\)|\))|o\.O\)|p(nb\)|rosopagnosiac\)|H\)|i(lot\)|rate\))|a(c(\-(run\)|ghost\)|man\))|man\))|nda\)|rty\)|ulh\))|laxo\))|\?\)|r(o(ll(\)|eyes\))|ckyou\))|2d2\)|\)|apper\))|s(tanford\)|a(d(\)|panda\))|rcasm\))|chroedinger\)|h(ock\)|aka\))|i(ck\)|mon\))|kull\)|leepy\)|mile\)|o\))|tarepanda\)|u(nlove\)|\)|ltimatefrisbee\))|vw\)|w(ink\)|\))|y(ikes\)|\)|oga\))|L\)|O(_O\)|\.(o\)|O\)))|U\)|\*\))|X(\(|\-(\(|D))|\*meebo\*|\+o\(|(&.*?;)/g,emoticons:{"&gt;&gt;:)":"evil.gif","(genderbender)":"genderbender.gif",":s":"confused.gif",":x":"oops.gif","(yikes)":"yikes.gif","(jj)":"jj.gif",":|":"neutral.gif","$)":"money.gif","O:)":"angel.gif","&gt;:O":"angry.gif","(O_O)":"omg.gif","(nerd)":"nerd.gif","(unlove)":"unlove.gif","(r2d2)":"r2d2.gif","=)":"smile.gif","(shaka)":"shaka.gif","(pnb)":"pnb.gif",":)&gt;-":"peace.gif",":arrow:":"arrow.gif",";p":"wink_tongue.gif","$-)":"money.gif","(grillz)":"grillz.gif","(O.O)":"omg.gif","(liar)":"liar.gif",":-&amp;":"sick.gif","/:-)":"sarcasm.gif","(mom)":"mom.gif","(w)":"rose-dead.gif","&gt;:o":"angry.gif",":&gt;":"smug.gif","(yoga)":"yoga.gif","=P":"tongue.gif","(o.O)":"oogly.gif","(vw)":"beetle.gif","O:-)":"angel.gif","(hmm)":"hmm.gif","(rolleyes)":"roll.gif","(sadpanda)":"sadpanda.gif","(neutral)":"neutral.gif","(l)":"love.gif","(pacman)":"pacman.gif","o:-)":"angel.gif","X(":"mad.gif","(wink)":"wink.gif","(pac-ghost)":"pac-ghost.gif","(lol)":"lol.gif","(mad)":"mad.gif","(loser)":"loser.gif","(schroedinger)":"schroedinger.gif","(sleepy)":"sleepy.gif","8-)":"cool.gif",":-#":"ssssh.gif","(y)":"thumb-up.gif","(bender)":"bender.gif",":-(":"sad.gif",":-)":"smile.gif",":-*":"kiss.gif","(pH)":"paulh.gif","(ninja)":"ninja.gif","(pilot)":"pilot.gif","(m)":"monkey.gif","(devil)":"evil.gif","o:)":"angel.gif",":-?":"confused.gif","(tarepanda)":"tare.gif","(nerdpirate)":"nerd-pirate.gif",":-B":"nerd.gif",":^O":"liar.gif",":-D":"big_smile.gif","B-)":"cool.gif","(U)":"unlove.gif","&lt;:-P":"party.gif",":!:":"exclaim.gif","8(|)":"monkey.gif","(n)":"thumb-down.gif",":-P":"tongue.gif",":-S":"confused.gif",":-T":"disappoint.gif","(pac-man)":"pac-man.gif",":&apos;(":"cry.gif",":-X":"oops.gif","*meebo*":"meebo.gif",":-\\":"hmm2.gif","(love)":"love.gif",":-b":"nerd.gif",":^o":"liar.gif","(meebo)":"meebo.gif","&lt;:-p":"party.gif","L-)":"loser.gif",":-&gt;":"smug.gif","B)":"cool.gif",":-o":"yikes.gif",":-p":"tongue.gif","(panda)":"panda.gif","(grin)":"big_smile.gif",":-s":"confused.gif",":&apos;D":"happy_tear.gif","(stanford)":"stanford.gif",":-x":"oops.gif","(moto)":"moto.gif","(pac-run)":"pac-run.gif",":-|":"neutral.gif","(3d)":"3d.gif",":pirate:":"pirate.gif","(prosopagnosiac)":"prosopagnosiac.gif","(angry)":"angry.gif","(sick)":"sick.gif","(lolwut)":"lolwut.gif","(cheezburger)":"cheezburger.gif","&gt;:-(":"mad.gif","&gt;:-)":"evil.gif","X-(":"mad.gif","(smile)":"smile.gif","(rapper)":"rapper.gif","(?)":"question.gif","(sarcasm)":"sarcasm.gif","(eek)":"yikes.gif","P)":"pirate.gif","(roll)":"roll.gif","(paulh)":"paulh.gif","&lt;:o)":"party.gif","(mikey)":"mikey.gif","(monkeyking)":"monkeyking.gif","(foursquare)":"foursquare.gif","(L)":"love.gif","X-D":"lol.gif","(meebosimon)":"meebosimon.gif","(arr)":"pirate.gif","(ghost)":"ghost.gif","8)":"cool.gif","(nutella)":"nutella.gif","(money)":"money.gif","&gt;:-O":"angry.gif",":&lt;":"upset.gif","&gt;:D&lt;":"hug.gif","b-(":"beaten.gif","@};-":"rose.gif","(O.o)":"oogly.gif",":-((":"cry.gif","(party)":"party.gif","(arrr)":"pirate.gif","(r)":"rose.gif","(plaxo)":"plaxo.gif","(fail)":"fail.gif","/:)":"sarcasm.gif","&gt;:-o":"angry.gif","(rockyou)":"rockyou.gif","(shock)":"yikes.gif","(letsgogiants)":"letsgogiants.gif","(hug)":"hug.gif","//:|":"emo.gif","(cry)":"cry.gif","(bomb)":"bomb.gif",";-)":"wink.gif",":'(":"cry.gif",":(":"sad.gif",":)":"smile.gif",":*":"kiss.gif","=-)":"smile.gif","(beaten)":"beaten.gif","(simon)":"meebosimon.gif","x(":"mad.gif",":@)":"pig.gif","(ultimatefrisbee)":"frisbee.gif","(angel)":"angel.gif","&gt;&gt;:-(":"mad.gif","x-(":"mad.gif",":meebo:":"meebo.gif","&gt;&gt;:-)":"evil.gif","(gelato)":"gelato.gif",":?":"confused.gif",":'D":"happy_tear.gif",":B":"nerd.gif",":((":"cry.gif",":D":"big_smile.gif","(evil)":"evil.gif","(*)":"star.gif",";)":"wink.gif","(cool)":"cool.gif","|-)":"sleepy.gif",";-P":"wink_tongue.gif",":O":"yikes.gif",":P":"tongue.gif","=-P":"tongue.gif",":S":"confused.gif",":T":"disappoint.gif","x-D":"lol.gif","&gt;:(":"mad.gif","&gt;:)":"evil.gif",":X":"oops.gif","(pirate)":"pirate.gif",":\\":"hmm2.gif","(chicago)":"chicago.gif","(brainslug)":"brainslug.gif",":(|)":"monkey.gif","(u)":"unlove.gif","(fingerblaster)":"fingerblaster.gif",":b":"nerd.gif","(sad)":"sad.gif","(skull)":"skull.gif",":))":"lol.gif","(so)":"soccer.gif",";-p":"wink_tongue.gif","(emo)":"emo.gif","+o(":"sick.gif",":o":"yikes.gif",":p":"tongue.gif",";P":"wink_tongue.gif",":-&lt;":"upset.gif","(doraemon)":"doraemon.gif","&gt;&gt;:(":"mad.gif"}};
meebo.util.emoticons.insertMeeboEmoticons=function(b){var d=[];
var c;
if((c=b.match(/^\<.*?\>\(auto\-response from .*?\)/))!=null){d.push("");
d.push(c[0]);
b=b.substring(c.index+c[0].length)
}while((c=b.match(/(\<a.*?\<\/a\>)|(\<.*?\>)/))!=null){d.push(b.substring(0,c.index));
d.push(c[0]);
b=b.substring(c.index+c[0].length)
}d.push(b);
for(var a=0;
a<d.length;
a+=2){d[a]=d[a].replace(this.regex,function(e){if(e in meebo.util.emoticons.emoticons){return meebo.util.emoticons.getMeeboEmoticon(meebo.util.emoticons.emoticons[e],e)
}return e
})
}b=d.join("");
return b
};
meebo.util.emoticons.getMeeboEmoticon=function(a,b){return'<img height="18" style="height: 18px;"		alt="'+b.replace("'","&apos;").replace('"',"&quot;")+'"		src="'+gConfig.getMeeboAppImageURL("emoticons/"+a)+'">'
};
meebo.util.platform={getChannelId:function(b,a){a=a||"";
return"meebo"+a+"Channel"+b
},getAppChannelBase:function(a){return meebo.util.platform.getChannelId(a,"App")
},getTrayChannelBase:function(){return"SecureMeeboTrayChannel"
},getPlatformChannelBase:function(a){return meebo.util.platform.getChannelId(a,"Platform")
},getSecureChannelBase:function(){return"SecureMeeboChannel"
},generateAuthenticityHash:function(){return"hash"
},blastChannels:function(c,e,b,d){for(var a=1;
a<=5;
a++){e.sendMessage(c+"_"+a,b,d)
}},APP_TYPE_SINGLE:"APP_TYPE_SINGLE",APP_TYPE_MULTI:"APP_TYPE_MULTI",CMD_ECHO:"CMD_ECHO",CMD_APP_MSG:"CMD_APP_MSG",CMD_IM_MSG:"CMD_IM_MSG",CMD_IM_HTML_MSG:"CMD_IM_HTML_MSG",CMD_REQG_BUDDY_ICON:"CMD_REQG_BUDDY_ICON",CMD_REQG_WALLPAPER:"CMD_REQG_WALLPAPER",CMD_REQG_STATUS_MESSAGE:"CMD_REQG_STATUS_MESSAGE",CMD_REQG_ALIAS:"CMD_REQG_ALIAS",CMD_REQG_SHARE_LIST:"CMD_REQG_SHARE_LIST",CMD_REQG_PROTOCOL_LIST:"CMD_REQG_PROTOCOL_LIST",CMD_REQS_BUDDY_ICON:"CMD_REQS_BUDDY_ICON",CMD_REQS_WALLPAPER:"CMD_REQS_WALLPAPER",CMD_REQS_STATUS_MESSAGE:"CMD_REQS_STATUS_MESSAGE",CMD_REQS_SHARE_ITEM:"CMD_REQS_SHARE_ITEM",CMD_ADD_BUDDY:"CMD_ADD_BUDDY",CMD_REQP_SHARE:"CMD_REQP_SHARE",CMD_REQP_INVITE:"CMD_REQP_INVITE",CMD_TRACK_AD:"CMD_TRACK_AD",CMD_SEND_MSG:"CMD_SEND_MSG",EVT_APP_MSG:"EVT_APP_MSG",EVT_IM_MSG:"EVT_IM_MSG",EVT_IM_HTML_MSG:"EVT_IM_HTML_MSG",EVT_JOIN:"EVT_JOIN",EVT_LEAVE:"EVT_LEAVE",EVT_OPEN:"EVT_OPEN",EVT_DEACTIVE:"EVT_DEACTIVE",EVT_CLOSE:"EVT_CLOSE",SCMD_REQG_SESSION_INFO:"SCMD_REQG_SESSION_INFO",SCMD_ATTACH:"SCMD_ATTACH",SCMD_PING:"SCMD_PING",SCMD_ADD_BUDDY:"SCMD_ADD_BUDDY",SEVT_SESSIONKEY_CHANGE:"SEVT_SESSIONKEY_CHANGE",SEVT_MEEBO_ACCOUNT_CREATED:"SEVT_MEEBO_ACCOUNT_CREATED",SEVT_LOCATIONID:"SEVT_LOCATIONID"};
Class("meebo.util.FlashMessageBridge",function(){var b=document.location.protocol;
var a=(document.location.protocol=="https:"?"origin-platformapi":"platformapi")+".meebo.com";
this.swfUrl=b+"//"+a+"/js/JsToLocalConnectionBridge.2.swf";
this.initialize=function(e,d,c){this.m_id="flashBridge_"+getUniqueId();
meebo.util.FlashMessageBridge.bridges[this.m_id]=this;
this.m_channelBase=e;
this.m_readyCallbacks=[];
this.m_ready=false;
this.m_callbackManager=new lib.CallbackManager();
this.m_messageHandler=d;
this.m_context=c?"document.getElementById('"+c+"').contentWindow":"window"
};
this.getFlashInterface=function(){return this.m_flashInterface
};
this.create=function(c,f){if(util.flash.getVersion().major<8){return
}var d=this.swfUrl;
if(f){d+="?"+new Date().getTime()
}var e=this.m_context+".meebo.util.FlashMessageBridge.bridges."+this.m_id+".";
this.m_flashInterface=util.flash.embed({id:this.m_id,swfUrl:d,flashVars:{readyHandlerName:e+"onInterfaceReady",messageHandlerName:e+"giveMessage",responseHandlerName:e+"giveResponse",channelBase:this.m_channelBase},style:{position:"absolute",bottom:"1px",left:"1px",zIndex:99999999},parent:c})
};
this.getChannel=function(){return this.m_channelId
};
this.onInterfaceReady=function(c){this.m_channelId=c;
this.m_ready=true;
doFunctions.call(this,this.m_readyCallbacks);
this.m_readyCallbacks=[]
};
this.ensureReady=function(c){if(this.m_ready){c.call(this)
}else{this.m_readyCallbacks.push(c)
}};
this.sendMessage=function(e,d,c){this.ensureReady(function(){var f;
if(c){f=this.m_callbackManager.scheduleCallback(c)
}setTimeout(hitch(this,function(){try{this.getFlashInterface().giveMessage(e,d,f)
}catch(g){this.m_ready=false;
this.m_readyCallbacks.push(hitch(this,"sendMessage",e,d,c))
}}),0)
})
};
this.giveResponse=function(d,c){setTimeout(hitch(this.m_callbackManager,"executeCallback",d,c),0)
};
this.giveMessage=function(d,e){var c;
if(e){c=hitch(this,function(f){this.getFlashInterface().giveResponse(e,f)
})
}setTimeout(hitch(this,this.m_messageHandler,d,c),0)
}
});
meebo.util.FlashMessageBridge.bridges={};
Class("meebo.util.SecureFlashMessageBridge",meebo.util.FlashMessageBridge,function(){this.swfUrl=window.location.protocol+"//"+window.location.hostname+"/flash/SecureFlashBridgeJs.2.swf"
});
Class("meebo.Platform",function(){this.initialize=function(a){this.m_instanceId="Platform"+Math.floor(Math.random()*100000);
this.m_commandHandlers={};
this.initBridge(a);
this.initCommandHandlers()
};
this.initBridge=function(a){var b=meebo.util.platform.getPlatformChannelBase(this.getPlatformInstanceId());
this.m_bridge=new meebo.util.FlashMessageBridge(b,hitch(this,"handleCommand"),a)
};
this.openBridge=function(a){this.m_bridge.create(a)
};
this.initCommandHandlers=function(){this.setCommandHandler(meebo.util.platform.CMD_ECHO,hitch(this,function(b,c,a){a(b)
}))
};
this.launchApplication=function(b,a){if(this.m_appInfos[b]){var c=this.createAppFromInfo(this.m_appInfos[b]);
c.launch();
a(c)
}else{gNetworkMgr.doRequest("mainfo",{app_id:b},hitch(this,"onAppInfo",function(d,f){this.m_appInfos[b]=d;
var e=this.createAppFromInfo(this.m_appInfos[b]);
e.launch();
a(e)
}))
}};
this.createAppFromInfo=function(a){if(a.type==meebo.util.platform.APP_TYPE_SINGLE){var b=new meebo.ApplicationSingle(a)
}else{var b=new meebo.Application(a);
gPubSub.subscribe(room,"meebo.ApplicationRoom::receiveAppMsg",this,"handleAppMessageFromServer",b)
}return b
};
this.getPlatformInstanceId=function(){return this.m_instanceId
};
this.getChannel=function(){return this.m_bridge.getChannel()
};
this.setCommandHandler=function(b,a){if(!meebo.util.platform[b]){throw ("No such command "+b)
}this.m_commandHandlers[b]=a
};
this.setResponseHandler=function(b,a){this.setCommandHandler(b,function(d,c){c(a(d))
})
};
this.handleCommand=function(c,b){var d=c.command;
var a=c.appInstanceId;
if(this.m_commandHandlers[d]){this.m_commandHandlers[d](c.data,b)
}};
this.handleAppMessageFromApp=function(b,a){a.getRoom().sendMsg(b.msg,meebo.util.platform.APP_MSG,b.to)
};
this.handleAppMessageFromServer=function(e,d,a,c){var b=meebo.util.platform.getAppChannelId(e.getInstanceId());
this.m_bridge.sendMessage(b,{m_event:meebo.util.platform.EVT_APP_MSG,message:c})
}
});
Class("meebo.SecurePlatform",meebo.Platform,function(){this.initBridge=function(b){var a=meebo.util.platform.getSecureChannelBase();
this.m_bridge=new meebo.util.SecureFlashMessageBridge(a,hitch(this,"handleCommand"))
};
this.initCommandHandlers=function(){var a=meebo.util.platform;
this.setCommandHandler(a.SCMD_REQG_SESSION_INFO,hitch(this,"handleGetSessionInfo"));
this.setCommandHandler(a.SCMD_ATTACH,hitch(this,"handleAttachRequest"));
this.setCommandHandler(a.SEVT_LOCATIONID,hitch(this,"locationId"));
this.setCommandHandler(a.SCMD_PING,hitch(this,"sendToTray",{response:"PONG"}));
this.setCommandHandler(a.SCMD_ADD_BUDDY,hitch(this,"handleAddBuddyRequest"))
};
this.sendToTray=function(b,c){var a=meebo.util.platform;
a.blastChannels(a.getTrayChannelBase(),this.m_bridge,b,c)
};
this.notifyMeeboAccountCreated=function(b,a){this.sendToTray({event:meebo.util.platform.SEVT_MEEBO_ACCOUNT_CREATED,username:b,password:a,sessionkey:gIMGateway.getSessionKey()})
};
this.handleGetSessionInfo=function(e,d){var c=gLogon.getMeeboAccount();
var b=c?gLogon.getMeeboMeLogon():gLogon.getLogons()[0];
var a=c?c.getPassword():b.getPassword();
d({username:b.getName(),network:b.getNetwork().getId(),password:a,sessionkey:gIMGateway.getSessionKey(),locationId:gIMGateway.getLocationId()})
};
this.handleAttachRequest=function(a){if(a.sessionkey!=gIMGateway.getSessionKey()){var b="k="+a.sessionkey;
if("locationId" in a){b+="&locationId="+a.locationId
}window.location.hash="#"+b;
meeboApp.dontShowWarning=true;
window.location.reload()
}};
this.locationId=function(b){var a=parseInt(b.locationId,10);
if(a!=gIMGateway.getLocationId()){gIMGateway.cmd("setlocationid",{locationId:a})
}};
this.handleAddBuddyRequest=function(a){meeboApp.share.handleAddBuddyLinkClick(a.buddy)
};
this.sendSessionKey=function(a){var c=gLogon.getMeeboName()||gLogon.getLogons()[0].getName();
var b=gLogon.hasMeeboAccount()?"meebome":gLogon.getLogons()[0].getNetwork().getId();
this.sendToTray({event:meebo.util.platform.SEVT_SESSIONKEY_CHANGE,sessionkey:a,username:c,network:b,locationId:gIMGateway.getLocationId()})
};
this.getSessionInfoFromTray=function(a){var b={command:meebo.util.platform.SCMD_REQG_SESSION_INFO};
this.sendToTray(b,hitch(this,"onSessionInfoFromTray"))
};
this.onSessionInfoFromTray=function(d){var a=meebo.util.normalizeLogon(d.username,d.network);
if(!a.network){return
}var b=gLogon.getLogon(a.name,a.network.getProtocol());
if(b){b.setPassword(d.password);
if(b.isMeeboLogon()){gLogon.getMeeboAccount().setPassword(d.password)
}}if(typeof d.clientId!="undefined"){var c=gIMGateway.getClientById(parseInt(d.clientId,10)).getLocation().getId()
}if(typeof c=="number"&&c!=gIMGateway.getLocationId()){gIMGateway.cmd("setlocationid",{locationId:c})
}}
});
Class("meebo.ApplicationSingle",function(){this.initialize=function(b,a){this.m_instanceId=Math.floor(Math.random()*100000)+"-"+(new Date().getTime());
this.m_platform=a||meeboApp.platform;
this.parseArgs(b)
};
this.parseArgs=function(b){b=b||{};
var c={owner_name:"",app_id:"",engagedAppId:"",category_id:0,description:"",resizable:0,width:20,height:20,alias:"",delta:0,location:"",domain:"meeboapis.com",icon_location:"",max_participants:0,intalled:0,name:"",enabled:1,info:"",multi_instance:0,invite:null,screenshot_location:"",num_times_launched:0,revenue_type:0,featured:0,favorite:0,type:meebo.util.platform.APP_TYPE_MULTI,platform_version:1,share:""};
for(var a in c){this[a]=b[a]||this[a]||c[a]
}};
this.getAlias=function(){return this.alias||this.name
};
this.getInstanceId=function(){return this.m_instanceId
}
});
meebo.APP_COMMUNICATION_CATEGORY=4;
meebo.APP_TYPE_MediaBar="MediaBar";
meebo.APP_TYPE_IM="IM";
meebo.APP_TYPE_LeaderBoard="LeaderBoard";
Class("meebo.Application",meebo.ApplicationSingle,function(a){this.launch=function(e,b,d,g,f){var c={nick:b,app_id:this.app_id,chat_id:e,platform_instance_id:this.m_platform.getPlatformInstanceId()};
gNetworkMgr.doRequest("malaunch",c,g)
};
this.setRoom=function(b){this.m_room=b
};
this.getRoom=function(){return this.m_room
};
this.join=function(c,e){if(!this.app_id){return
}var b={app_id:this.app_id,app_instance_id:c,platform_instance_id:meeboApp.platform.getPlatformInstanceId()};
var d=gLogon.getMeeboUser();
if(d){b.muser=d
}gNetworkMgr.doRequest("majoin",b,hitch(this,"onJoin",e))
};
this.onJoin=function(d,c,b){if(!b){return
}this.parseArgs(c);
if(d){d(c.time,c.hash,this)
}};
this.getInfo=function(d,c){if(!c&&!this.app_id){return
}var b=(c?{app_instance_id:c}:{app_id:this.app_id});
gNetworkMgr.doRequest("mainfo",b,hitch(this,"onGetInfo",d))
};
this.onGetInfo=function(d,c,b){if(!b){return
}this.parseArgs(c);
if(d){d(this)
}};
this.createIframe=function(d){var e=getUniqueId();
var c=gWin().document.createElement("div");
c.id=e+"-appFrame";
addClassName(c,"appFrame");
c.style.width=d.width;
c.style.height=d.height;
var b='<iframe src="'+this.location+"?app_instance_id="+encodeURIComponent(this.app_instance_id)+"&platform_instance_id="+meeboApp.platform.getPlatformInstanceId()+"&time="+encodeURIComponent(d.joinParams.time)+"&hash="+encodeURIComponent(d.joinParams.hash)+'" ';
if(this.resizable==1||!this.width||!this.height||this.width<=0||this.height<=0){b+='width="100%" height="100%" frameborder="0" style="top: 0px; left: 0px;"></iframe>'
}else{b+='width="'+this.width+'" height="'+this.height+'" frameborder="0" style="margin-left: -'+Math.round(this.width/2)+"px; margin-top: -"+Math.round(this.height/2)+'px;"></iframe>'
}c.innerHTML=b;
return c
}
});
Class("meebo.ApplicationMgr",function(){this.initialize=function(){this.m_applications=[];
this.m_categories=[];
this.m_featured=null;
this.m_favorites=null
};
this.loadList=function(b){var a={rank_key:"installed"};
if(gLogon.getMeeboUser()){a.muser=gLogon.getMeeboUser()
}gNetworkMgr.doRequest("mafulllist",a,hitch(this,"onLoad",b))
};
this.loadUser=function(b){var a={muser:gLogon.getMeeboUser()};
gNetworkMgr.doRequest("mauserlist",a,hitch(this,"onLoad",b))
};
this.loadApplication=function(a){var b=this.getApplication(a.app_id);
if(!b){b=new meebo.Application(a)
}else{b.parseArgs(a)
}this.addApplication(b);
return b
};
this.onLoad=function(g,d,a,h){if(!a){return
}var f=d.applications||d;
for(var c=0;
c<f.length;
c++){this.loadApplication(f[c])
}if(d.categories){for(var b in d.categories){var e=d.categories[b];
if(this.getCategory(e.category_id)){continue
}this.addCategory(e)
}}if(typeof g=="function"){g(this.m_applications,this.m_categories)
}this.m_favorites=null;
this.m_featured=null;
this.saveFavorites()
};
this.loadGuest=function(d,a,c){var b={};
if(a){b.muser=a
}if(c){b.app_instance_id=c
}gNetworkMgr.doRequest("maguestjoin",b,hitch(this,"onLoadGuest",d))
};
this.onLoadGuest=function(e,c,a,g){if(!a){return
}var f=null;
if(c.app_info){f=new meebo.Application(c.app_info);
this.addApplication(f)
}this.m_favorites={};
var d=null;
if(c.user_info){for(var b=0;
b<c.user_info.app_id.length;
b++){this.m_favorites[c.user_info.app_id[b]]=true
}d=c.user_info.icon_url
}if(e){e(f,d)
}this.saveFavorites()
};
this.getApplications=function(){return this.m_applications
};
this.getApplication=function(b){var c=null;
for(var a=0;
(c=this.m_applications[a]);
a++){if(c.app_id==b){break
}}return c||null
};
this.addApplication=function(a){for(var b=0,c;
(c=this.m_applications[b]);
b++){if(a.app_id==c.app_id){this.m_applications.splice(b,1,a);
return
}}this.m_applications.push(a)
};
this.getCategories=function(){return this.m_categories
};
this.getCategory=function(c){var b=null;
for(var a=0;
(b=this.m_categories[a]);
a++){if(b.category_id==c){break
}}return b||null
};
this.addCategory=function(a){this.m_categories.push(a)
};
this.getFeatured=function(){if(!this.m_featured){this.m_featured={};
var b=this.getApplications();
for(var a=0;
a<b.length;
a++){if(!b[a].featured){continue
}this.m_featured[b[a].app_id]=true
}}return this.m_featured
};
this.addFavorite=function(a){if(this.getFavorites()[a]){return
}this.m_favorites[a]=true;
this.sendFavoriteRequest(a,true);
this.saveFavorites()
};
this.removeFavorite=function(a){if(!this.getFavorites()[a]){return
}delete this.m_favorites[a];
this.sendFavoriteRequest(a,false);
this.saveFavorites()
};
this.sendFavoriteRequest=function(c,d){var a=gLogon.getMeeboUser();
if(!a){return
}var b={muser:a,nfavorites:1,"1app_id":c,"1fav":d?1:0};
gNetworkMgr.doRequest("mauserinfo",b)
};
this.saveFavorites=function(){gPubSub.publish(this,"meebo.ApplicationMgr::updateFavorites")
};
this.getFavorites=function(){if(!this.m_favorites){this.m_favorites={};
var b=this.getApplications();
for(var a=0;
a<b.length;
a++){if(!b[a].favorite){continue
}this.m_favorites[b[a].app_id]=true
}}return this.m_favorites
}
});
meebo.applicationMgr=new meebo.ApplicationMgr();
Class("meebo.UIState",lib.Publisher,function(a){this.initialize=function(){a(this,"initialize");
this.m_state={};
this.m_needsFlush=false;
this.m_clearOnFlush={};
this.m_pending={};
gIMGateway.subscribe("connect",this,"onGatewayConnect",gIMGateway);
if(typeof gEventGateway!="undefined"){gEventGateway.subscribe("connect",this,"onGatewayConnect",gEventGateway)
}gPubSub.subscribe("meebo.EventMgr::networkResume",this,"onNetworkResume");
gClient.subscribe("info::ui_state",this,"handleSetEvent");
gClient.subscribe("info::ui_clear",this,"handleClearEvent")
};
this.onGatewayConnect=function(d,c){if(d==gEventGateway&&(gIMGateway.isConnecting()||gIMGateway.isConnected())){return
}var b=c.session_state||c;
if(b.ui_state){this.handleSetEvent(b.ui_state,true);
this.flush()
}};
this.set=function(g,d,b,c){var f=false;
if(!this.m_state[g]){this.m_state[g]={}
}for(var e in d){if(this.m_state[g][e]!=d[e]){this.m_state[g][e]=d[e];
f=true
}}if(f&&!b){this.requestSet(g)
}if(c){this.publish("ChangeState",g,this.m_state[g])
}};
this.clear=function(c,b){if(!this.m_state.hasOwnProperty(c)){return
}delete this.m_state[c];
if(!b){this.requestClear(c)
}};
this.handleSetEvent=function(c,b){for(var d in c){this.m_state[d]=c[d]
}for(var d in c){this.publish("ChangeState",d,c[d],b)
}};
this.handleClearEvent=function(b){delete this.m_state[b];
this.publish("ChangeState",b,null)
};
this.get=function(b){return shallowCopy(this.m_state[b])
};
this.getGateway=function(){return(gEventMgr.getState()=="im"&&gIMGateway||typeof gEventGateway=="object"&&gEventGateway)
};
this.isActive=function(){var b=this.getGateway();
return b&&b.isConnected()&&!gClient.isTesting()
};
this.requestSet=function(b){if(!this.isActive()){this.m_needsFlush=true;
delete this.m_clearOnFlush[b]
}else{if(!this.flush()){this.m_pending[b]=true;
this.sync()
}}};
this.requestClear=function(b){if(!this.isActive()){this.m_needsFlush=true;
this.m_clearOnFlush[b]=true
}else{this.flush();
this.sync();
this.clearUIState(b)
}};
this.onNetworkResume=function(){this.flush()
};
this.setUIState=function(d){var c=0,b={};
for(var e in d){b["uid"+c]=e;
b["state"+c]=JSON.stringify(d[e]);
++c
}if(c==0){return
}b.num=c;
this.getGateway().cmd("uiset",b)
};
this.clearUIState=function(b){this.getGateway().cmd("uiclear",{uid:b})
};
this.syncNow=function(){var b={};
for(var c in this.m_pending){if(c in this.m_state){b[c]=this.m_state[c]
}}this.m_pending={};
this.setUIState(b)
};
this.sync=createDelayedMethod("sync",this.syncNow,1000);
this.flush=function(){if(!this.m_needsFlush||!this.isActive()){return false
}this.setUIState(this.m_state);
for(var b in this.m_clearOnFlush){this.clearUIState(b)
}this.m_needsFlush=false;
this.m_clearOnFlush={};
this.m_pending={};
this.sync.cancel();
return true
}
});
Quantcast={m_qacct:"p-93vmRJG_BQlqo",m_tracked:false,track:function(c){if(this.m_tracked||!gConfig.getReleaseType().length){return
}this.m_tracked=true;
c=c||window;
c._qoptions={qacct:this.m_qacct};
var b=(("https:"==c.document.location.protocol)?"https://secure.":"http://pixel.");
var a=c.document.createElement("script");
a.src=b+"quantserve.com/quant.js";
var e=c.document;
(e.getElementsByTagName("head")[0]||e.body).appendChild(a)
}};
Class("ads.Server",function(){this.initialize=function(a,b){this.m_defaultCallbackId="unspecifiedShareCallback";
this.m_pendingCallbacks={};
this.m_loadProfiles=a;
this.m_defaultTrackingParams=b||{};
this.m_ads={}
};
this.load=function(c){if(!(c instanceof Array)){c=[c]
}var a=(new Date()).getTime();
var e=c.length>1;
for(var b=0,d=c.length;
b<d;
b++){if(!c[b].type in this.m_loadProfiles){continue
}if(e){copyProperties(c[b],{tile:b+1,ord:a})
}var f=c[b].shareId&&c[b].shareId!="static"?c[b].shareId+this.m_loadProfiles[c[b].type].location:this.m_defaultCallbackId+this.m_loadProfiles[c[b].type].location;
this.m_pendingCallbacks[f]=c[b].callback||this.m_loadProfiles[c[b].type].callback;
if(c[b].shareId&&c[b].shareId.length==32){this.loadFromAdShare(this.m_loadProfiles[c[b].type].location,c[b].shareId)
}else{this.m_loadProfiles[c[b].type].load(c[b])
}}};
this.getAd=function(a,b){return a in this.m_ads?this.m_ads[a][b]:null
};
this.loadFromAdShare=function(a,c){var b=hitch(this,function(e,d){if(!d||e.stat!="ok"||!e.data){return
}else{this.onAdLoaded(a,this.filterRawPayload(e.data))
}});
gNetworkMgr.doRequest("adshare",{shareid:c},b)
};
this.loadDoubleClickAd=function(a,b){DoubleClick.loadAd(a,b)
};
this.getTrackingParams=function(){return this.m_defaultTrackingParams
};
this.onAdLoaded=function(b,c){if(b=="MediaBar"){this.normalize(c)
}if(document.location.protocol == 'https:'){this.requireHttps(c)
}c.isSharable=!c.notSharable;
var a=new ads.Ad(b,c);
if(!(b in this.m_ads)){this.m_ads[b]={}
}this.m_ads[b][c.share]=a;
var d=this.m_pendingCallbacks[c.share+b]||this.m_pendingCallbacks[this.m_defaultCallbackId+b];
delete this.m_pendingCallbacks[this.m_defaultCallbackId+b];
delete this.m_pendingCallbacks[c.share+b];
if(d){d(a)
}};
this.shareClick=function(e,b,f,d){if(e.share.length!=32){return d()
}var c={site:b,shareid:e.share};
var a=hitch(this,function(h,g){if(!g||h.stat!="ok"||!h.data){d()
}else{f(this.filterRawPayload(h.data))
}});
gNetworkMgr.doRequest("adshare",c,a)
};
this.filterRawPayload=function(a){delete a.click;
delete a.clickUrl;
delete a.impression;
delete a.impressionUrl;
delete a.partnerImpression;
delete a.partnerImpression_engaged;
delete a.link;
return a
};
this.doesAdRequireHttps=function(){return((ui.isIE||ui.isFirefox)&&document.location.protocol=="https:")
};
this.requireHttps=function(d){var c=/^http:\/\/share.meebo.com/i;
var e=/^http:\/\//gi;
for(var a in d){if(d[a] instanceof Array){for(var b=0;
b<d[a].length;
b++){if(!d[a][b].replace){continue
}d[a][b]=d[a][b].replace(c,"https://origin-share.meebo.com/");
d[a][b]=d[a][b].replace(e,"https://")
}}else{if(typeof d[a]=="string"){d[a]=d[a].replace(c,"https://origin-share.meebo.com");
d[a]=d[a].replace(e,"https://")
}}}};
this.normalize=function(a){a.impression=a.impression||a.impressionUrl;
a.leaderboard=a.leaderboard||a.leaderboardUrl;
a.engaged=a.engaged||a.engagedUrl;
a.buddyIcons=a.buddyIcons||a.buddyIconUrls;
a.wallpapers=a.wallpapers||a.wallpaperUrls;
a.wallpaperThumbnails=a.wallpaperThumbnails||a.wallpaperThumbnailUrls;
a.click=a.click||a.clickUrl
}
});
Class("ads.DoubleClick",function(){this.MEDIABAR="MediaBar";
this.SPARK="Spark";
this.MEDIAALERT="MediaAlert";
this.MOBILE="Mobile";
this.m_sizes={Spark:"47x47",MediaBar:"728x90",MediaAlert:"24x24",Mobile:"3x3"};
this.m_positions={Spark:1,MediaBar:1,MediaAlert:1,Mobile:1};
this.initialize=function(){this.m_url=document.location.protocol+"//ad.doubleclick.net/";
this.m_dcParams="/%1/;%2;dcmt=text/html;ord=%3?"
};
this.getAdTypes=function(){return[this.SPARK,this.MEDIABAR,this.MEDIAALERT]
};
this.setPosition=function(b,a){this.m_positions[b]=a
};
this.getPosition=function(a){return this.m_positions[a]
};
this.loadAd=function(e,b){var g=this.getUrl(e,b);
var a="DoubleClickAd"+e;
if($(a)){removeElement($(a))
}var f=document,c=f.createElement("script");
c.src=g;
c.type="text/javascript";
c.id=a;
(f.getElementsByTagName("head")[0]||f.body).appendChild(c)
};
this.getUrl=function(m,l,e){if(!e){e="pfadx"
}var c=this.m_url+e+this.m_dcParams;
l=l||{};
var f=l.shareId,o=shallowCopy(gTargeting.getTargeting()),b=l.site,d=l.ord||new Date().getTime(),k=l.tile,h=l.keyValuePairs||{};
if(l.targeting){copyProperties(o,l.targeting)
}if(!b){if(m==this.MOBILE){b="meebomobile"
}else{if(m==this.MEDIABAR&&util.flash.getVersion().major<7){b="meebostatic"
}else{if(f){b="meeboshare"
}else{if(window.location.protocol=="https:"){b="meebo.comsecure"
}else{b="meebo.com"
}}}}}var n;
if(f){n="dcove=o;share="+f
}else{var a=[];
for(var p in h){a.push(p+"="+h[p])
}var g=this.m_positions[m]>4?"other":this.m_positions[m];
a.push(["position="+encodeURIComponent(g)]);
this.m_positions[m]++;
for(var p in o){a.push(p+"="+encodeURIComponent(o[p]))
}n=a.join(";")
}if(k){n+=";tile="+encodeURIComponent(k)
}n+=";sz="+this.m_sizes[m];
return sprintf(c,b,n,d||new Date().getTime())
};
this.onAdLoaded=function(){gAdServer.onAdLoaded.apply(gAdServer,arguments)
}
});
Class("ads.Mindset",function(){this.initialize=function(a,b){this.m_cookieName="ARMM";
this.m_cookieTTL=30*24*60*60*1000;
this.m_mindsetLoaded=false;
this.m_cookieDomain=a;
this.m_referrer=b||""
};
this.create=function(d){if(this.m_mindsetLoaded){return
}var b=gWin(window.parent).location.toString();
var a=(new Date()).getTimezoneOffset();
this.m_mindsetLoaded=true;
var e=util.query.url((document.location.protocol=="https:"?"https://ssl.":"http://")+"syndication.mmismm.com/tntwo.php");
e.addToSearch({mm_pub:7333,u:b,r:this.m_referrer,t:a});
var c=gDoc().createElement("script");
c.setAttribute("src",e.toString());
d.appendChild(c)
};
this.handleResponse=function(f){var a=f.split(";");
var e={};
if(f.length>0){for(var c=0;
c<a.length;
c++){var d=a[c].split("=");
e[d[0]]=d[1]
}}var b=JSON.stringify(e);
util.cookie.save(this.m_cookieName,b,this.m_cookieTTL,this.m_cookieDomain);
gTargeting.setTargeting(e,true)
};
this.getTargeting=function(){if(this.isCookieSet()){try{return JSON.parse(util.cookie.load(this.m_cookieName))
}catch(a){}}return{}
};
this.isCookieSet=function(){return util.cookie.load(this.m_cookieName)!==null
}
});
Class("ads.Targeting",lib.Publisher,function(a){this.initialize=function(){a(this,"initialize");
this.m_targeting={};
gPubSub.subscribe("meebo.EventMgr::changeState",this,"onChangeState");
gClient.subscribe("info::targeting",this,"setTargetingFromEvents")
};
this.setTargeting=function(c,e){for(key in c){if(key in this.m_targeting){continue
}this.m_targeting[key]=c[key]
}if("age" in this.m_targeting&&!("age_bucket" in this.m_targeting)){var b=this.m_targeting.age,d=null;
if(b>=55){d="55over"
}else{if(b>=50){d="50-54"
}else{if(b>=45){d="45-49"
}else{if(b>=35){d="35-44"
}else{if(b>=25){d="25-34"
}else{if(b>=21){d="21-24"
}else{if(b>=18){d="18-20"
}else{if(b>=16){d="16-17"
}else{if(b>=13){d="13-15"
}}}}}}}}}if(!d){delete this.m_targeting.age
}else{this.m_targeting.age_bucket=d
}}if(!e){this.publish("ready")
}};
this.getTargeting=function(){return this.m_targeting
};
this.trackCategory=function(c,b,f){var e=util.cookie.load("cdata");
if(e){this.setTargeting(JSON.parse(e),f);
return
}var d={};
if(c){d.bcookie=c
}if(b){d.partner=b
}gNetworkMgr.doRequest("trackcategory",d,hitch(this,"onTrackCategory",f))
};
this.onTrackCategory=function(f,d,b,e){if(!b){this.setTargeting({},f);
return
}var c=d.data.categories;
util.cookie.save("cdata",JSON.stringify(c),-1);
this.setTargeting(c,f)
};
this.onChangeState=function(d,b,e,c){if(c=="connecting"&&e=="im"){gPubSub.unsubscribe("meebo.EventMgr::changeState",this);
this.m_targetingTimeout=setTimeout(hitch(this,"setTargetingFromEvents",{}),4000)
}};
this.setTargetingFromEvents=function(b){clearTimeout(this.m_targetingTimeout);
this.setTargeting(b);
gNetworkMgr.doUILog("meebo","demographic","age:"+this.m_targeting.age+",gender:"+this.m_targeting.gender,true)
}
});
Class("ads.Ad",function(){this.initialize=function(a,b){this.m_location=a;
this.m_props=b;
if(this.m_props.type=="bulk"&&a=="MediaAlert"){this.m_location="DRMediaAlert"
}this.m_defaultArgs={component:this.m_location};
if(this.m_props.share){this.m_defaultArgs.shareId=this.m_props.share
}};
this.getProp=function(a){return this.m_props[a]
};
this.setProp=function(a,b){this.m_props[a]=b
};
this.pushToArrProp=function(a,b){if(!this.m_props[a]){this.m_props[a]=[]
}this.m_props[a]=this.m_props[a].concat(b)
};
this.track=function(a,b,c){var d=shallowCopy(this.m_defaultArgs);
copyProperties(d,gAdServer.getTrackingParams());
copyProperties(d,a);
meebo.util.createTrackingPixel(d,b||gLogon.getLogons(),c)
};
this.trackImpression=function(a){var c={type:"impression"};
copyProperties(c,a);
if(this.m_props.type!="DRMediaAlert"){this.track(c)
}var b=this.m_props.impressionUrl||this.m_props.impression;
if(b){new ui.TrackingPixel({},b,true).create()
}if(this.m_props.partnerImpression){new ui.TrackingPixel({},this.m_props.partnerImpression,true).create()
}};
this.hasProps=function(){return !!this.m_props
};
this.saveAsActiveAd=function(a){this.m_props.expiration=new Date().getTime()+a;
util.storage.save("meebo-activeAd",JSON.stringify({click:this.m_props.clickUrl||this.m_props.click,link:this.m_props.link,text:this.m_props.text,title:this.m_props.title,icon:this.m_props.icon,engaged:this.m_props.engagedUrl||this.m_props.engaged,partnerImpression_engaged:this.m_props.partnerImpression_engaged||[],share:this.m_props.share,type:this.m_props.type,loadTime:this.m_props.loadTime,expiration:this.m_props.expiration}))
}
});
var ui={};
ui.KEY_BACKSPACE=8;
ui.KEY_TAB=9;
ui.KEY_RETURN=13;
ui.KEY_ESC=27;
ui.KEY_LEFT=37;
ui.KEY_UP=38;
ui.KEY_RIGHT=39;
ui.KEY_DOWN=40;
ui.KEY_DELETE=46;
ui.KEY_SPACEBAR=32;
ui.m_isEnabled=true;
ui.enableEvents=function(){ui.m_isEnabled=true
};
ui.disableEvents=function(){ui.m_isEnabled=false
};
ui.globalEvents={};
ui.connectGlobalEvent=function(c,a,b){var d=ui.retrieveEventId(c.documentElement);
if(!this.globalEvents[d]){this.globalEvents[d]={}
}if(this.globalEvents[d][a]){ui.disconnectGlobalEvent(c,a)
}this.globalEvents[d][a]=b;
ui.attachEvent(c.documentElement,a,b,true)
};
ui.disconnectGlobalEvent=function(c,a){var e=ui.retrieveEventId(c.documentElement);
if(!this.globalEvents[e]||!this.globalEvents[e][a]){return
}var b=gWin(c),d=c.documentElement;
if(ui.isIE&&!arguments.callee.disconnecting&&b.event&&b.event.type==a&&b.event.srcElement!=d){arguments.callee.disconnecting=true;
this.globalEvents[e][a](b.event);
arguments.callee.disconnecting=false
}ui.detachEvent(d,a,this.globalEvents[e][a],true);
delete this.globalEvents[e][a]
};
ui.retrieveEventId=function(a){if(!a){return
}var b;
if(!a.getAttribute){b=ui.getElementEventId(a)
}else{b=a.getAttribute("ev_id");
if(!b){b=String(getUniqueId());
a.setAttribute("ev_id",b)
}}if(!ui.connectedEvents[b]){ui.connectedEvents[b]={el:a}
}return b
};
ui.getElementEventId=function(a){for(var b=0,c;
c=ui.elementIdMap[b];
++b){if(c.el==a){return c.id
}}var d=String(getUniqueId());
ui.elementIdMap[ui.elementIdMap.length]={el:a,id:d};
return d
};
ui.elementIdMap=[];
ui.hookEvents=new lib.Publisher();
ui.connectedEvents={};
ui.connectEvent=function(e,a,c,l,d,k){if(!e||!a||!c||!l){return
}var h=Array.prototype.slice.call(arguments,6);
var g=function(n){if(typeof ui=="undefined"||!ui.m_isEnabled){return
}var o=n||gWin(e).event;
var m=(d?(k?[o,e]:[o]):(k?[e]:[])).concat(h);
var f=hitch(c,l).apply(c,m);
eventlog(e.id+" "+n);
return f
};
var b=ui.retrieveEventId(e);
if(ui.connectedEvents[b][a]){ui.disconnectEvent(e,a,ui.connectedEvents[b][a])
}ui.connectedEvents[b][a]=g;
ui.attachEvent(e,a,g)
};
ui.disconnectEvent=function(a,b){if(!a||!b){return
}var d=ui.retrieveEventId(a);
var c=ui.connectedEvents[d][b];
if(!c){return
}delete ui.connectedEvents[d][b];
ui.detachEvent(a,b,c)
};
ui.disconnectAllEvents=function(a){var f=ui.retrieveEventId(a);
for(var b in ui.connectedEvents[f]){if(b=="el"){continue
}try{ui.detachEvent(a,b,ui.connectedEvents[f])
}catch(d){}}delete ui.connectedEvents[f];
var c=gDoc(a);
if(a==c){for(var f in ui.connectedEvents){var a=ui.connectedEvents[f].el;
if(c==document||c==gDoc(a)){arguments.callee(a)
}}}};
ui.USE_CAPTURE=false;
ui.normaliseEvent=function(a,b,c){if(b!="focus"&&b!="blur"&&b!="focusie7"){return{element:a,event:b,useCapture:c}
}var e=gWin(a);
if(a==e){var d=gDoc(a);
switch(b){case"focus":if(isDefined(d.onfocusin)){b="focusin";
a=d
}else{if(isDefined(e.onfocus)){b="focus"
}else{b="focus";
a=d;
c=true
}}break;
case"blur":if(isDefined(d.onfocusout)){b="focusout";
a=d
}else{if(isDefined(e.onblur)){b="blur"
}else{b="blur";
a=d;
c=true
}}break;
case"focusie7":b="focus";
a=e;
break
}}return{element:a,event:b,useCapture:c}
};
ui.attachEvent=function(c,d,f,e){if(!c||!d||!f){return
}var b=ui.normaliseEvent(c,d,e);
c=b.element;
d=b.event;
e=b.useCapture;
if(c.addEventListener){if(d.toLowerCase()=="mousewheel"){d="DOMMouseScroll"
}if(d=="contextmenu"&&ui.isFirefox&&ui.isMac){d="mouseup";
var a=f;
f=function(g){if(g.button==2){a(g)
}}
}if(ui.isWebKit&&d.toLowerCase()=="dblclick"){c.ondblclick=f
}else{c.addEventListener(d,f,typeof e=="boolean"?e:ui.USE_CAPTURE)
}}else{if(c.attachEvent){c.attachEvent("on"+d,f)
}}};
ui.detachEvent=function(b,c,e,d){if(!b||!c||!e){return
}var a=ui.normaliseEvent(b,c,d);
b=a.element;
c=a.event;
d=a.useCapture;
if(b.detachEvent){b.detachEvent("on"+c,e)
}else{if(b.removeEventListener){if(c.toLowerCase()=="mousewheel"){c="DOMMouseScroll"
}if(ui.isWebKit&&c.toLowerCase()=="dblclick"){delete b.ondblclick
}else{b.removeEventListener(c,e,typeof d=="boolean"?d:ui.USE_CAPTURE)
}}}};
ui.setEventHandled=function(b,a){if(!b){b=window.event
}if(!a){ui.hookEvents.publish(b.type,b)
}if(b&&b.preventDefault){b.stopPropagation()
}else{b.cancelBubble=true
}ui.preventDefault(b)
};
ui.preventDefault=function(a){if(a.preventDefault){a.preventDefault()
}else{a.returnValue=false
}};
ui.isCursorInClient=function isCursorInClient(b){var c=ui.getClientRect();
var a=ui.getCursorX(b);
if(a<0||a>=c.w){return false
}var d=ui.getCursorY(b);
if(d<0||d>=c.h){return false
}return true
};
ui.getCursorPos=function getCursorPos(a){return{x:ui.getCursorX(a),y:ui.getCursorY(a)}
};
ui.getCursorX=function getCursorX(b){if(ui.isWebKit&&b&&!isDefined(b.clientX)){return(b.target)?0:-1
}var d=gDoc(b&&(b.target||b.srcElement));
if(ui.isIE&&ui.isIE<=5.5){d=gDoc()
}var c=gWin(d);
var a=0;
if(ui.isIE||ui.isOpera){a=c.event.clientX+d.documentElement.scrollLeft+d.body.scrollLeft-(d.documentElement.clientLeft+d.body.clientLeft)
}else{a=b.clientX+c.scrollX
}return a
};
ui.getCursorY=function getCursorY(a){if(ui.isWebKit&&a&&!isDefined(a.clientY)){return(a.target)?0:-1
}var c=gDoc(a&&(a.target||a.srcElement));
if(ui.isIE&&ui.isIE<=5.5){c=gDoc()
}var b=gWin(c);
var d=0;
if(ui.isIE||ui.isOpera){d=b.event.clientY+c.documentElement.scrollTop+c.body.scrollTop-(c.documentElement.clientTop+c.body.clientTop)
}else{d=a.clientY+b.scrollY
}return d
};
ui.getMouseButton=function(b){var c=gWin(b);
if(!b){b=c.event
}var a=b.button;
if(ui.isIE||ui.isWebKit){if(a&1){a=0
}else{if(a&2){a=2
}else{if(a&4){a=1
}}}}return a
};
ui.getClientRect=function getClientRect(a){var b=gWin(a),c=b.document.documentElement;
return new ui.rect(0,0,b.innerWidth||c.clientWidth,b.innerHeight||c.clientHeight)
};
ui.getClientCenter=function(a){var b=ui.getClientRect(a);
return{x:parseInt(b.w/2),y:parseInt(b.h/2)}
};
ui.cleanUp=function(a){var d=gDoc(a);
ui.disconnectAllEvents(d);
var c=d.getElementsByTagName("DIV");
for(var b=0;
b<c.length;
b++){if(c[b].ptr){c[b].ptr=null
}}};
if(typeof ui=="undefined"){ui={}
}(function(){function a(c){var e=navigator.userAgent,d=e.indexOf(c);
return d>=0&&(ui.m_version=parseFloat(e.substr(d+c.length+1)))
}function b(c){return navigator.userAgent.toLowerCase().indexOf(c)>=0
}ui.isWebKit=a("WebKit");
ui.isChrome=a("Chrome");
ui.isSafari=!ui.isChrome&&a("Safari")&&(ui.m_version=a("Version")||2);
ui.isFluid=(window.fluid!=null);
ui.isPrism=(window.platform!=null);
ui.isIPhone=navigator.userAgent.indexOf("iPhone")>=0;
ui.isIE=a("MSIE");
ui.isOpera=a("Opera");
ui.isNS=a("Netscape6/");
ui.isGecko=!ui.isWebKit&&a("Gecko");
ui.isFirefox=a("Firefox");
ui.isMac=b("mac");
ui.isWin=b("win");
ui.isLinux=b("linux")||b("x11");
ui.isHttps=(document.location.protocol=="https:")
})();
ui.isQuirksMode=function(a){return !a.compatMode||a.compatMode=="BackCompat"
};
ui.isBorderBox=function(c,b){var a=c.compatMode;
var d=(ui.isGecko?"-moz-":ui.isWebKit?"-webkit-":"")+"box-sizing";
return ui.isIE&&(a=="BackCompat"||a=="QuirksMode"||ui.isIE<6)||b&&getCSSProp(b,d)=="border-box"
};
ui.getVersion=function(){return ui.m_version
};
ui.getClient=function(){return ui.isChrome?"Chrome":ui.isSafari?"Safari":ui.isIPhone?"iPhone":ui.isIE?"MSIE":ui.isOpera?"Opera":ui.isNS?"Netscape":ui.isFirefox?"Firefox":ui.isGecko?"Gecko":ui.isWebKit?"WebKit":"unknown"
};
ui.getOS=function(){return ui.isMac?"Mac":ui.isWin?"Windows":ui.isLinux?"Linux":"unknown"
};
if(!ui.isIE){ui.innerHTML=function(a,b){a.innerHTML=b;
return a
}
}else{ui.getDisplayNoneEl=function(){if(ui.getDisplayNoneEl.m_el){return ui.getDisplayNoneEl.m_el
}var a=ui.getDisplayNoneEl.m_el=document.createElement("div");
a.style.display="none";
util.dom.insertBefore(document.body,a,document.body.firstChild);
return a
};
ui.innerHTML=function(c,e){var d=c.parentNode;
while(d&&d.id!="meebo"){d=d.parentNode
}if(!d){var b=c.parentNode,a=c.nextSibling;
if(!ui.getDisplayNoneEl.m_el){ui.getDisplayNoneEl()
}ui.getDisplayNoneEl.m_el.appendChild(c)
}c.innerHTML=e;
if(b){util.dom.insertBefore(b,c,a)
}return c
}
}ui.rect=function(a,d,b,c){this.x=a;
this.y=d;
this.w=b;
this.h=c;
this.x2=a+b;
this.y2=d+c
};
Class("ui.element",function(){this.m_visDisplay="block";
this.m_className="";
this.m_element=null;
this.m_id="";
this.m_title="";
this.m_win=window;
this.initialize=function(a){if(a){this.m_win=gWin(a);
this.m_element=a;
this.m_id=a.id
}};
this.getId=function(){return this.m_id||(this.m_element&&this.m_element.id)||""
};
this.getElement=function(){return this.m_element||$(String(this.getId()))
};
this.getTitle=function(){return this.m_title
};
this.setTitle=function(a){this.m_title=a||"";
if(this.getElement()){this.getElement().title=this.m_title
}};
this.setPos=function(a,e,b,d){if(!this.getElement()){return
}var c=this.getElement().style;
if(a!=null&&parseInt(c.right)){c.right=a+"px"
}else{if(a!=null){c.left=a+"px"
}}if(e!=null&&parseInt(c.bottom)){c.bottom=e+"px"
}else{if(e!=null){c.top=e+"px"
}}if(b!=null&&b>=0){c.width=b+"px"
}if(d!=null&&d>=0){c.height=d+"px"
}};
this.getPos=function(){var a=this.getElement();
return{w:a.offsetWidth,h:a.offsetHeight,x:a.offsetLeft,y:a.offsetTop}
};
this.getAbsolutePos=function(){return getElementPosition(this.getElement())
};
this.setVisibility=function(a){if(this.getElement()){this.getElement().style.visibility=a?"visible":"hidden"
}};
this.getVisibility=function(){return Boolean(this.getElement()&&this.getElement().style.visibility!="hidden")
};
this.setDisplay=function(a){if(!this.getElement()){return
}if(typeof(a)=="string"){this.getElement().style.display=a
}else{this.getElement().style.display=a?"block":"none"
}};
this.getDisplay=function(){if(this.getElement()){return this.getElement().style.display
}};
this.setStyle=function(a,b){if(this.getElement()){this.getElement().style[a]=b
}};
this.addClassName=function(a){this.m_className=addClassName(this.m_className,a);
var b=this.getElement();
if(b){addClassName(b,a)
}};
this.removeClassName=function(a){this.m_className=removeClassName(this.m_className,a);
var b=this.getElement();
if(b){removeClassName(b,a)
}};
this.hasClassName=function(a){return hasClassName(this.getElement()||this.m_className,a)
};
this.createHandler=createHandler;
this.onRender=function(){this.connectEvents()
};
this.setInnerHTML=function(a){if(!this.getElement()){return
}this.getElement().innerHTML=a
};
this.connectEvents=function(){if(!this.getElement()){return
}for(var a in this.eventHash){ui.connectEvent(this.getElement(),a,this,this.eventHash[a])
}}
});
Class("ui.Element",lib.Publisher,function(a){this.initialize=function(){a(this,"initialize",arguments);
this.m_win=null;
this.m_parent=null;
this.m_element=null
};
this.create=function(b,c){this.m_parent=b||this.m_parent;
var d=this.m_parent.m_win||this.m_parent;
if(this.m_win!=d||!this.m_element){this.m_win=d;
this.uncreate();
this.m_element=c||this.m_win.document.createElement("m");
this.createContent()
}return this
};
this.uncreate=function(){if(!this.m_element){return
}this.uncreateContent();
removeElement(this.m_element);
this.m_element=null;
this.m_parent=null;
this.m_win=null
};
this.dom=function(b,c){var d=this.m_win.document.createElement(c||"m");
if(c&&c!="m_span"){d.className="meeboClass-reset"+(b?" "+b:"")
}else{if(b){d.className=b
}}return d
};
this.createContent=function(){throw new Error("abstract method")
};
this.uncreateContent=function(){};
this.setParent=function(b){if(this.m_parent!=b){if(this.m_element){this.create(b)
}else{this.m_parent=b;
this.m_win=b.m_win
}}};
this.getWindow=function(){return this.m_win
};
this.getElement=function(){return this.m_element
};
this.getId=function(){return this.m_id||(this.m_element&&this.m_element.id)||""
};
this.getParent=function(){return this.m_parent
};
this.setTitle=function(b){this.m_element.title=b;
return this
};
this.getTitle=function(){return this.m_title
};
this.addClassName=function(b){addClassName(this.m_element,b);
return this
};
this.removeClassName=function(b){removeClassName(this.m_element,b);
return this
};
this.hasClassName=function(b){return hasClassName(this.m_element,b)
};
this.setDisplay=function(b){if(this.m_element){this.m_element.style.display=b?"block":"none"
}return this
};
this.getDisplay=function(){return this.m_element&&this.m_element.style.display!="none"
}
});
Class("ui.Animation",function(){this.initialize=function(a){a=a||{};
this.m_duration=a.duration||500;
this.m_timeDelta=a.delta||40;
this.m_transition=a.transition||ui.Animation.linear;
this.onfinished=a.onFinish||a.finished;
this.m_alwaysJump=a.alwaysJump||false;
this.m_onToOne=a.onToOne;
this.m_onToZero=a.onToZero;
this.m_onOne=a.onOne;
this.m_onZero=a.onZero;
this.m_scale=a.scale||1;
this.m_offset=a.offset||0;
this.m_state=this.m_target=0;
this.m_subjects=a.subject?[a.subject]:[];
this.m_interval=null
};
this.setTransition=function(a){this.m_transition=a||ui.Animation.linear
};
this.setDuration=function(a){this.m_duration=a
};
this.addSubject=function(a){this.m_subjects.push(a);
return this
};
this.removeSubject=function(a){if(!a){this.m_subjects=[]
}else{for(var b=this.m_subjects.length-1;
b>=0;
b--){if(this.m_subjects[b]==a){this.m_subjects.splice(b,1)
}}}};
this.getState=function(){return this.m_state
};
this.removeAllSubjects=function(){this.m_subjects=[]
};
this.isAnimating=function(){return Boolean(this.m_interval)
};
this.atTarget=function(){return this.m_state===this.m_target
};
this.seekFromTo=function(b,a){b=(b>1?1:(b<0?0:b));
a=(a>1?1:(a<0?0:a));
if(a==0&&this.m_onToZero){this.m_onToZero()
}if(a==1&&this.m_onToOne){this.m_onToOne()
}this.m_state=this.m_alwaysJump?a:b;
this.m_target=a;
this.animate()
};
this.seekTo=function(a){this.seekFromTo(this.m_state,a)
};
this.seek=function(){this.seekFromTo(this.m_state,this.m_target)
};
this.jumpTo=function(a){this.seekFromTo(a,a)
};
this.play=function(){this.seekFromTo(0,1)
};
this.reverse=function(){this.seekFromTo(1,0)
};
this.toggle=function(){this.seekTo(1-this.m_target)
};
this.animate=function(){this.m_startTime=new Date().getTime();
this.m_startState=this.m_state;
if(this.m_interval){return
}if(this.m_state==this.m_target){var b=this.m_transition(this.m_state);
try{for(var a=0;
a<this.m_subjects.length;
a++){this.m_subjects[a](b*this.m_scale+this.m_offset,this.m_state)
}}catch(c){}this.finished()
}else{this.m_interval=setInterval(hitch(this,"onInterval"),this.m_timeDelta)
}};
this.onInterval=function(){var c=((new Date().getTime()-this.m_startTime)/this.m_duration);
if(this.m_target>this.m_state){c+=this.m_startState;
if(this.m_target<c){c=this.m_target
}}else{c=this.m_startState-c;
if(this.m_target>c){c=this.m_target
}}try{var b=this.m_transition(c);
for(var a=0;
a<this.m_subjects.length;
a++){this.m_subjects[a](b*this.m_scale+this.m_offset,c)
}if(ui.isWebKit){document.body.offsetWidth
}}catch(d){}this.m_state=c;
if(this.m_state==this.m_target){clearInterval(this.m_interval);
this.m_interval=null;
this.finished()
}};
this.finished=function(){if(this.onfinished){this.onfinished()
}if(this.m_state==0&&this.m_onZero){this.m_onZero()
}else{if(this.m_state==1&&this.m_onOne){this.m_onOne()
}}};
this.pause=function(){if(this.m_interval){clearInterval(this.m_interval);
this.m_interval=null
}}
});
ui.Animation.linear=function(a){return a
};
ui.Animation.easeIn=function(a){return a*a
};
ui.Animation.easeInOut=function(a){if((a*=2)<1){return 0.5*a*a*a
}else{return 0.5*((a-=2)*a*a+2)
}};
ui.Animation.easeOut=function(a){return a*(2-a)
};
ui.Animation.easeOutBounce=function(a){if(a<(1/2.75)){return(7.5625*a*a)
}else{if(a<(2/2.75)){return(7.5625*(a-=(1.5/2.75))*a+0.75)
}else{if(a<(2.5/2.75)){return(7.5625*(a-=(2.25/2.75))*a+0.9375)
}else{return(7.5625*(a-=(2.625/2.75))*a+0.984375)
}}}};
ui.colorMgr=function(){this.debugErrorColor="#FF0000";
this.debugObjectColor="#339900";
this.debugUserCmdColor="#0000FF";
this.getColorByType={};
this.getColorByType.buddy="#dde4f5";
this.getColorByType.chat="#dde4f5";
this.getColorByType.buddygroup="#d7e0f5";
this.getColorByType.none="#dde4f5"
};
Class("ui.button",ui.Element,function(a){this.initialize=function(h,b,f,d,e,c,g){a(this,"initialize");
this.m_control="ui.Button";
this.m_className="uiButton";
this.m_id=h;
this.m_title=f;
this.m_tabIndex=d;
this.m_img=c;
this.m_imageType=g;
this.m_bPreload=false;
this.m_isLegacy=false;
this.m_label=new ui.label();
this.m_labelText=b;
this.m_isDisabled=false;
this.m_hasDisabledImage=true;
this.m_bHover=false;
this.m_onMouseOver=new Array();
this.m_onMouseUp=new Array();
this.m_onMouseDown=new Array();
this.m_skin=e||"";
this.m_state="normal"
};
this.createContent=function(){var b=this.getElement();
this.m_isLegacy=Boolean(this.m_imageType);
b.id=this.m_id;
if(this.m_title){b.title=this.m_title
}if(this.m_tabIndex){b.tabIndex=this.m_tabIndex
}b.control=this.m_control;
if(this.m_isLegacy){this.m_imageBase=this.m_img;
this.m_imgW=b.getAttribute("imgW");
this.m_imgH=b.getAttribute("imgH");
this.m_imgAlt=b.getAttribute("imgAlt");
this.m_bPreload=b.getAttribute("imgPreload")!=false;
this.m_isPng=b.getAttribute("png")=="true"
}else{this.setSkin(this.m_skin)
}if(this.constructor==ui.button){this.createDOMNode()
}return this
};
this.createDOMNode=function(){var b=this.m_element;
if(this.m_isLegacy){this.addClassName("uiButtonLegacy");
this.m_img=createImg(b.id+"img",b,this.m_imgW,this.m_imgH,this.m_imageBase+"."+this.m_imageType,this.m_imgAlt,this.m_bPreload,null,this.m_isPng);
b.appendChild(this.m_img)
}else{this.addClassName(this.m_className);
this.setSkin(this.m_skin,true);
var c=this.m_win.document;
this.m_leftDiv=c.createElement("div");
this.m_leftDiv.className="uiButtonLeft uiButtonLeft-normal";
this.m_centerDiv=c.createElement("div");
this.m_centerDiv.className="uiButtonCenter uiButtonCenter-normal";
this.m_label.create(this.m_id+"_label"+getUniqueId(),this.m_centerDiv,this.m_img,this.m_labelText);
this.m_rightDiv=c.createElement("div");
this.m_rightDiv.className="uiButtonRight uiButtonRight-normal";
b.appendChild(this.m_leftDiv);
b.appendChild(this.m_centerDiv);
b.appendChild(this.m_rightDiv);
var d=c.createElement("div");
d.style.position="absolute";
d.style.top="0";
d.style.left="0";
if(ui.isIE){d.style.width=b.offsetWidth;
d.style.height=b.offsetHeight
}else{d.style.bottom="0";
d.style.right="0"
}if(!ui.isWebKit){d.className="blankBackground"
}b.appendChild(d);
this.m_eventsDiv=d
}b.ptr=this;
disableSelection(b,true);
ui.connectEvent(b,"mouseover",this,"onMouseAction",true,true,"over");
ui.connectEvent(b,"mouseout",this,"onMouseAction",true,true,"out");
ui.connectEvent(b,"mouseup",this,"onMouseAction",true,true,"up");
ui.connectEvent(b,"mousedown",this,"onMouseAction",true,true,"down");
ui.connectEvent(b,"keypress",this,"onKeyPress",true,true,"keypress")
};
this.destroy=function(){ui.disconnectAllEvents(this.m_element);
removeElement(this.m_element)
};
this.getLabel=function(){return this.m_label
};
this.onKeyPress=function(d,b){if(d){var c=d.keyCode;
if(c!=13){return true
}ui.setEventHandled(d)
}doFunctions(this.m_onMouseUp,d,b);
if(d){return false
}};
this.onMouseAction=function(e,c,d){if(this.m_isDisabled){return
}ui.setEventHandled(e);
var f="";
var g="";
switch(d){case"over":if(!this.m_isLegacy&&ui.isIE){this.m_eventsDiv.style.display="inline";
this.m_eventsDiv.style.width=this.m_element.offsetWidth;
this.m_eventsDiv.style.height=this.m_element.offsetHeight;
this.m_eventsDiv.style.display="block"
}if(this.m_state=="down"){return
}f="_hot";
this.m_bHover=true;
g=this.m_onMouseOver;
this.setState("hot");
break;
case"out":f="";
this.m_bHover=false;
g=this.m_onMouseOut;
this.setState("normal");
break;
case"up":f="";
this.m_bHover=true;
g=this.m_onMouseUp;
this.setState("hot");
break;
case"down":f="_down";
g=this.m_onMouseDown;
this.setState("down");
break
}if(this.m_isLegacy){var b=this.m_imageBase+f+"."+this.m_imageType;
this.swapImage(b)
}if(g){doFunctions(g,e,c)
}};
this.setSkin=function(b,c){if(!c&&b==this.m_skin){return
}var d=this.m_control.replace(/\./g,"");
this.removeClassName(d+"-"+this.m_skin);
this.removeClassName(d+"-"+this.m_skin+"-"+this.m_state);
this.m_skin=b;
if(this.m_skin){this.addClassName(d+"-"+this.m_skin);
this.addClassName(d+"-"+this.m_skin+"-"+this.m_state)
}};
this.setState=function(b){if(this.m_isLegacy||this.m_state==b){return
}var c=this.m_control.replace(/\./g,"");
this.removeClassName(c+"-"+this.m_state);
this.removeClassName(c+"-"+this.m_skin+"-"+this.m_state);
this.m_state=b;
this.addClassName(c+"-"+this.m_state);
this.addClassName(c+"-"+this.m_skin+"-"+this.m_state);
if(this.m_element){this.m_leftDiv.className="uiButtonLeft uiButtonLeft-"+b;
this.m_centerDiv.className="uiButtonCenter uiButtonCenter-"+b;
this.m_rightDiv.className="uiButtonRight uiButtonRight-"+b
}};
this.refreshImage=function(){this.swapImage(this.m_imageBase+"."+this.m_imageType)
};
this.swapImage=function(b){if(this.m_bPreload&&window.gImages){gImages.requestImage(b,this.m_img)
}else{this.m_img.src=b
}};
this.addOnMouseUp=function(b){this.m_onMouseUp.push(b)
};
this.addOnMouseDown=function(b){this.m_onMouseDown.push(b)
};
this.setHasDisabledImage=function(b){this.m_hasDisabledImage=b
};
this.enable=function(){this.setDisabled(false)
};
this.disable=function(){this.setDisabled(true)
};
this.setDisabled=function(b){b=Boolean(b);
if(this.m_isDisabled==b){return
}this.m_isDisabled=b;
if(this.m_isLegacy){this.swapImage(this.m_imageBase+(b?"_disabled":"")+"."+this.m_imageType)
}else{this.setState(b?"disabled":"normal");
var c=this.getImage();
if(c){this.setImage(c.replace(/(?:_disabled)?\.([a-zA-Z]+)$/,(this.m_hasDisabledImage&&b?"_disabled":"")+".$1"))
}}};
this.isDisabled=function(){return this.m_isDisabled
};
this.setTabIndex=function(b){this.m_element.tabIndex=b
};
this.getImage=function(){return this.m_label.getPreImg()
};
this.setImage=function(c,b,d){this.m_label.setPreImg(c,b,d)
};
this.getText=function(){return this.m_label.getText()
};
this.setText=function(b){this.m_label.setText(b)
}
});
Class("ui.FileUploadButton",ui.button,function(a){this.initialize=function(c,b){a(this,"initialize",[c,b]);
this.m_fileInput
};
this.createContent=function(){a(this,"createContent");
if(this.constructor==ui.FileUploadButton){this.createDOMNode()
}};
this.createDOMNode=function(){a(this,"createDOMNode");
this.m_eventsDiv.style.overflow="hidden";
util.css.setOpacity(this.m_eventsDiv,0);
this.createFileInput()
};
this.createFileInput=function(){if(this.m_fileInput){removeElement(this.m_fileInput)
}var b=this.m_win.document.createElement("input");
this.m_fileInput=b;
b.type="file";
b.name="file";
b.accept="image/jpeg,image/gif,image/png";
ui.connectEvent(b,"change",this,"selectFile",true,true);
b.style.position="absolute";
if(!ui.isWebKit){b.style.fontSize="60pt";
b.style.top=b.style.right="0"
}else{b.style.top=b.style.right="-999px"
}this.m_eventsDiv.appendChild(b);
this.m_eventsDiv.style.zIndex=gWindowMgr.getNextZIndex()
};
this.onMouseAction=function(d,b,c){if(c!="up"){a(this,"onMouseAction",arguments)
}else{if(ui.isWebKit){this.m_fileInput.click()
}else{}}};
this.isFileExtensionAllowed=function(){if(!ui.isWin){return true
}var b=this.m_fileInput.value;
if(b&&b.lastIndexOf(".")!=-1){var c=b.substring(1+b.lastIndexOf(".")).toLowerCase();
return(c=="jpg"||c=="gif"||c=="png"||c=="bmp"||c=="jpeg")
}return true
};
this.selectFile=function(){this.setState("normal");
if(this.isFileExtensionAllowed()){if(this.m_onMouseUp){doFunctions(this.m_onMouseUp,this.m_fileInput);
this.createFileInput()
}}else{gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.buddyIconErrorHeader},gLang.buddyIconErrorExt)
}}
});
ui.checkbox=function(){this.create=function(h,d,g,e,f,b){this.m_win=gWin(d);
var a=this.m_win.document.createElement("input");
a.setAttribute("type","checkbox");
a.id=h;
a.tabIndex=e;
if(g){a.checked=true;
a.defaultChecked=true
}if(b){this.addOnMouseUp(b);
this.m_changeHandler=b
}var c=this.m_win.document.createElement("span");
c.setAttribute("descr",f);
c.className="checkboxDescr";
d.appendChild(a);
d.appendChild(c);
this.init(a,c)
};
this.init=function(a,c){this.m_check=a;
this.m_span=c;
this.m_bChecked=a.defaultChecked;
this.m_descr=this.m_span.getAttribute("descr");
if(this.m_descr){this.m_span.innerHTML=this.m_descr
}this.m_span.style.verticalAlign="20%";
var b=this;
this.m_check.onclick=function(d){return b.onCheckMouseUp(d,this)
};
this.m_span.onmouseover=function(d){return b.onMouseOver(d,this)
};
this.m_span.onmouseout=function(d){return b.onMouseOut(d,this)
};
this.m_span.onclick=function(d){return b.onMouseUp(d,this)
};
this.m_check.ptr=this
};
this.getCheckElem=function(){return this.m_check
};
this.setDescr=function(a){if(a){this.m_span.setAttribute("descr",a);
this.m_descr=a;
this.m_span.innerHTML=this.m_descr
}return this.m_descr
};
this.setCheck=function(a){this.m_bChecked=this.m_check.defaultChecked=this.m_check.checked=a;
return this.m_bChecked
};
this.onCheckMouseUp=function(b,a){this.m_bChecked=this.m_check.defaultChecked=a.checked?true:false;
if(this.m_changeHandler){this.m_changeHandler(this.m_bChecked,b,a)
}return true
};
this.onMouseOver=function(b,a){if(!this.m_span){return
}this.m_span.style.textDecoration="underline";
ui.setEventHandled(b)
};
this.onMouseOut=function(b,a){if(!this.m_span){return
}this.m_span.style.textDecoration="none";
ui.setEventHandled(b)
};
this.onMouseUp=function(b,a){this.m_bChecked=this.m_check.defaultChecked=this.m_check.checked=(this.m_check.checked)?false:true;
ui.setEventHandled(b);
if(this.m_onMouseUp){doFunctions(this.m_onMouseUp,this.m_bChecked,b,a)
}};
this.addOnMouseUp=function(a){this.m_onMouseUp.push(a)
};
this.isChecked=function(){return this.m_bChecked
};
this.m_win=window;
this.m_onMouseUp=new Array();
this.m_bChecked=true;
this.m_descr;
this.m_span;
this.m_check
};
Class("ui.toolbar",ui.Element,function(a){this.initialize=function(b){a(this,"initialize");
this.m_control="ui.toolbar";
this.m_win=window;
this.m_element=null;
this.m_marginLeft=2;
this.m_hSpace=1;
this.m_pos=this.m_marginLeft;
this.m_size="large";
this.m_height;
this.m_buttons=[];
this.m_selectedButton=null;
this.m_selectIndicator=null;
this.m_sizes={small:20,large:26,xlarge:32};
this.m_size=b;
this.m_height=this.m_sizes[b]
};
this.createContent=function(){var c=this.m_element.firstChild;
while(c){if(c.getAttribute&&(c.getAttribute("control")=="ui.toolbarButton")){var b=new ui.toolbarButton(this);
this.addButton(b)
}c=c.nextSibling
}this.m_element.control=this.m_control;
this.addClassName("uiToolbar")
};
this.resize=function(c){if(!c){c=this.m_element.offsetWidth
}this.m_element.style.width=c+"px";
var h=0;
var f=0;
for(var e=this.m_buttons.length-1;
e>=0;
e--){var d=this.m_buttons[e];
if(d.constructor==ui.toolbarFlexibleSpace){h++
}else{f+=d.getWidth()
}}var g=(c-f)/h;
if(g<0){g=0
}var b=0;
for(var e=0;
e<this.m_buttons.length;
e++){var d=this.m_buttons[e];
if(d.constructor==ui.toolbarFlexibleSpace){d.setWidth(g)
}d.m_element.style.position="absolute";
d.m_element.style.left=b+"px";
d.m_element.style.top="0";
b+=d.getWidth()
}};
this.addButton=function(h,c,g,e,f,b){var d=h;
if(arguments.length>1){if(e){d=new ui.toolbarButton(this,h,c,this.m_size,g,e,f).create(this.m_win);
if(b){this.getElement().insertBefore(d.getElement(),b.getElement())
}else{this.getElement().appendChild(d.getElement())
}}else{d=new ui.ToolbarImageButton();
d.create(h,this.m_element,c,this.m_size,g,f)
}}this.appendButton(d,b);
return d
};
this.indexOfButton=function(c){var b=0;
for(;
b<this.m_buttons.length;
b++){if(this.m_buttons[b]==c){return b
}}return 0
};
this.appendButton=function(c,b){if(b){this.m_buttons.splice(this.indexOfButton(b),0,c)
}else{this.m_buttons.push(c)
}this.m_buttons[c.m_element.id]=c
};
this.getButton=function(b){return this.m_buttons[b]
};
this.removeButtons=function(){while(this.m_buttons.length){var b=this.m_buttons[0];
this.removeButton(b)
}};
this.removeButton=function(b){b.destroy();
this.m_buttons.splice(0,1);
delete this.m_buttons[b.getId()]
};
this.select=function(b){this.m_selectedButton=b;
if(!this.m_selectIndicator){this.m_selectIndicator=this.m_win.document.createElement("div");
this.m_selectIndicator.className="selectIndicator"
}this.m_selectIndicator.style.height=(this.m_height+4)+"px";
this.m_selectIndicator.style.width=b.getWidth()-2+"px";
this.m_selectIndicator.style.left=b.getElement().offsetLeft+"px";
this.m_element.insertBefore(this.m_selectIndicator,this.m_element.firstChild)
};
this.getSelected=function(){return this.m_selectedButton
};
this.destroy=function(){this.removeButtons();
this.m_element.ptr=null;
this.m_element=null
}
});
Class("ui.toolbarButton",ui.button,function(a){this.initialize=function(b,h,c,e,g,d,f){a(this,"initialize",[h,d]);
this.m_control="ui.ToolbarButton";
this.m_className="uiToolbarButton";
this.m_toolbar=b;
this.m_img=c;
this.m_size=e||"large";
this.m_title=g;
this.m_width=32;
this.m_height=26;
this.m_isDisabled=f
};
this.createContent=function(){a(this,"createContent");
this.setImage(this.m_img);
this.setSkin(this.m_size);
this.setDisabled(this.m_isDisabled);
if(this.constructor==ui.toolbarButton){this.createDOMNode()
}};
this.createDOMNode=function(){a(this,"createDOMNode");
if(this.getText()){addClassName(this.m_label.getTextO(),"hasText")
}};
this.getWidth=function(){if(this.m_label&&this.m_label.getElement()){return this.m_label.getPreImgWidth()+this.m_label.getTextO().offsetWidth
}return 0
};
this.setDepressed=function(b){this.setSkin(this.m_size+(b?"-depressed":""))
};
this.isDepressed=function(){return this.m_skin.substring(this.m_skin.length-10)=="-depressed"
};
this.setText=function(b){if(b){addClassName(this.m_label.getTextO(),"hasText")
}else{removeClassName(this.m_label.getTextO(),"hasText")
}a(this,"setText",arguments);
this.m_toolbar.resize()
};
this.setImage=function(d){var b,c;
switch(this.m_size){case"small":b=25;
c=20;
break;
case"large":b=32;
c=26;
break;
case"xlarge":b=32;
c=32;
break
}a(this,"setImage",[d,b,c])
}
});
Class("ui.toolbarFlexibleSpace",ui.toolbarButton,function(a){this.createContent=function(){var b=this.m_win.document.createElement("div");
b.setAttribute("control","ui.toolbarButton");
this.addClassName("uiToolbarButton");
return this
};
this.getWidth=function(){return this.m_width||0
};
this.setWidth=function(b){this.m_width=b
}
});
Class("ui.ToolbarImageButton",ui.element,function(a){this.initialize=function(){this.m_size;
this.m_img;
this.m_title;
this.m_isDisabled=false;
this.m_isDepressed=false;
this.m_hover=false;
this.m_bgImageSrc;
this.m_bgDownImageSrc;
this.m_bgHoldImageSrc;
this.m_onMouseUp=[];
this.m_onMouseOver=[];
this.m_onMouseClick=[];
this.m_width=32;
this.m_height=27;
this.m_imageElement
};
this.init=function(c){this.m_element=c;
var h=c.id||"";
var f=c.parentNode;
var b=c.getAttribute("img");
var d=c.getAttribute("buttonsize");
var g=c.getAttribute("title");
var e=c.getAttribute("disabled")=="true";
this.create(h,f,b,d,g,e)
};
this.create=function(g,e,b,c,f,d){this.m_size=c;
this.m_img=b;
this.m_title=f;
switch(this.m_size){case"small":this.m_width=25;
this.m_height=20;
this.m_bgImageSrc="buttons/btnBack-small.png";
this.m_bgHoldImageSrc="buttons/btnBackHold-small.png";
this.m_bgDownImageSrc="buttons/btnBackDown-small.png";
break;
case"large":this.m_width=32;
this.m_height=27;
this.m_bgImageSrc="buttons/btnBack.png";
this.m_bgHoldImageSrc="buttons/btnBackHold.png";
this.m_bgDownImageSrc="buttons/btnBackDown.png";
break;
case"xlarge":this.m_width=32;
this.m_height=32;
this.m_bgImageSrc="buttons/btnBack-xlarge.gif";
this.m_bgHoldImageSrc="buttons/btnBackDown-xlarge.gif";
this.m_bgDownImageSrc="buttons/btnBackHold-xlarge.gif";
break
}this.m_win=gWin(e);
this.m_element=this.m_win.document.createElement("div");
e.appendChild(this.m_element);
this.m_element.title=this.m_title;
this.m_element.setAttribute("control","ui.toolbarButton");
this.m_element.className="uiToolbarButton uiToolbarImageButton-"+this.m_size;
this.m_element.style.height=this.m_height+"px";
this.m_element.style.width=this.m_width+"px";
this.m_imageElement=this.m_win.document.createElement("div");
this.m_imageElement.className=b+(d?"-disabled":"");
this.m_imageElement.title=f;
this.m_element.appendChild(this.m_imageElement);
ui.connectEvent(this.m_element,"mouseover",this,"onMouseOver",true,true);
ui.connectEvent(this.m_element,"mouseout",this,"onMouseOut",true,true);
ui.connectEvent(this.m_element,"mousedown",this,"onMouseDown",true,true);
ui.connectEvent(this.m_element,"mouseup",this,"onMouseUp",true,true);
ui.connectEvent(this.m_element,"click",this,"onMouseClick",true,true);
this.setImgPos(0,0);
this.setDisabled(d)
};
this.addArrow=function(b){this.m_arrow=this.m_win.document.createElement("span");
addClassNames(this.m_arrow,"arrow","arrow"+(b?"Up":"Down"));
this.m_element.appendChild(this.m_arrow)
};
this.getWidth=function(){return this.m_width
};
this.setImgPos=function(b,d){var c=this.m_element.firstChild;
if(!c){return
}c.style.position="absolute";
c.style.left=b+"px";
c.style.top=d+"px"
};
this.setBackgroundImage=function(b){this.m_element.style.backgroundImage=!b?"":("url("+gImages.getPath()+b+")")
};
this.setImage=function(b){this.m_img=b;
this.m_imageElement.className=b+(this.m_isDisabled?"-disabled":"")
};
this.setTitle=function(b){this.m_title=b;
this.m_imageElement.title=this.m_title;
this.m_element.title=this.m_title
};
this.onMouseOver=function(b){ui.setEventHandled(b);
if(this.m_isDisabled){return
}this.m_hover=true;
this.setBackgroundImage(this.m_isDepressed?this.m_bgDownImageSrc:this.m_bgImageSrc);
if(this.m_arrow){this.m_arrow.style.display="block"
}doFunctions(this.m_onMouseOver,b)
};
this.onMouseOut=function(b){ui.setEventHandled(b);
if(this.m_isDisabled){return
}this.m_hover=false;
this.setBackgroundImage(this.m_isDepressed?this.m_bgHoldImageSrc:"");
if(this.m_arrow&&!this.m_isDepressed){this.m_arrow.style.display="none"
}this.setImgPos(0,0)
};
this.onMouseDown=function(b){if(ui.getMouseButton(b)==2){return
}if(this.m_isDisabled){return
}ui.setEventHandled(b);
this.setBackgroundImage(this.m_bgDownImageSrc);
this.setImgPos(1,1)
};
this.onMouseUp=function(b){if(ui.getMouseButton(b)==2){return
}if(this.m_isDisabled){return
}this.setBackgroundImage(this.m_isDepressed?this.m_bgHoldImageSrc:this.m_bgImageSrc);
this.setImgPos(0,0);
doFunctions(this.m_onMouseUp,b)
};
this.onMouseClick=function(b){if(ui.getMouseButton(b)==2){return
}if(this.m_isDisabled){return
}doFunctions(this.m_onMouseClick,b)
};
this.addOnMouseClick=function(b){this.m_onMouseClick.push(b)
};
this.addOnMouseUp=function(b){this.m_onMouseUp.push(b)
};
this.removeOnMouseUp=function(c){for(var b=this.m_onMouseUp.length-1;
b>=0;
b--){if(this.m_onMouseUp[b]==c){this.m_onMouseUp.splice(b,1)
}}};
this.addOnMouseOver=function(b){this.m_onMouseOver.push(b)
};
this.removeOnMouseOver=function(c){for(var b=this.m_onMouseOver.length-1;
b>=0;
b--){if(this.m_onMouseOver[b]==c){this.m_onMouseOver.splice(b,1)
}}};
this.removeAllOnMouseOver=function(){this.m_onMouseOver=[]
};
this.setDepressed=function(b){if(this.m_isDepressed==b){return
}this.m_isDepressed=b;
this.setBackgroundImage(b?this.m_bgHoldImageSrc:"");
if(this.m_arrow){this.m_arrow.style.display=b?"block":"none"
}};
this.isDepressed=function(){return this.m_isDepressed
};
this.setDisabled=function(b){b=Boolean(b);
if(this.m_isDisabled==b){return
}this.m_isDisabled=b;
this.m_imageElement.className=this.m_img+(b?"-disabled":"");
this.m_element.style.cursor=b?"default":((ui.isIE&&ui.isIE<=5.5)?"hand":"pointer");
this.m_element.disabled=b
};
this.destroy=function(){ui.disconnectAllEvents(this.m_element);
removeElement(this.m_element)
}
});
ui.tabbar=function(){this.create=function(e,c,b,d){this.m_win=gWin(c);
var a=this.m_win.document.createElement("div");
if(d){a.style.height=d+"px"
}if(!a){return
}a.id=e;
a.control="ui.tabbar";
a.className="uiTabBar";
if(b){a.setAttribute("tabW",b)
}if(d){a.setAttribute("tabH",d)
}a.id=e;
this.init(c.appendChild(a))
};
this.init=function(b){if(!b){return
}this.m_element=b;
var a=parseInt(this.m_element.getAttribute("tabW"));
if(a){this.m_barW=a
}var c=this.m_element.getAttribute("tabH");
if(c){c-=1;
this.m_element.style.height=c+"px";
this.m_barH=c
}var d=this.m_element.firstChild;
while(d){if(d.getAttribute&&(d.getAttribute("control")=="ui.tab")){this.initTab(d)
}d=d.nextSibling
}this.m_element.ptr=this
};
this.initTab=function(b){var a=new ui.tab();
a.init(b);
this.layoutTab(a);
this.m_tabs[a.m_element.id]=a
};
this.addTab=function(c,e,n,k,a,m,g,l,f,h,b){var o;
if(!this.m_tabs[c]){o=new ui.tab();
o.create(c,this.m_element,e,n,k,a,m,g,l,f,h,b);
var d=this;
o.addOnMouseUp(function(){d.selectTab(c)
});
this.m_tabs[o.m_element.id]=o
}else{o=this.m_tabs[c]
}this.layoutTab(o,b);
return o
};
this.selectTab=function(b){var a=null;
for(var c in this.m_tabs){if(!c||!this.m_tabs[c]||(c==b)){continue
}a=this.m_tabs[c].m_element;
removeClassName(a,"uiTabSelected");
a.style.height=this.m_barH-this.m_marginTop+"px";
this.m_tabs[c].removeCorners()
}a=this.m_tabs[b].m_element;
addClassName(a,"uiTabSelected");
a.style.height=(this.m_barH-this.m_marginTop-1)+"px";
this.m_tabs[b].addCorners()
};
this.getTab=function(a){return this.m_tabs[a]
};
this.resetLayout=function(){this.m_pos=this.m_marginLeft
};
this.layoutTab=function(a,b){a.m_element.style.left=this.m_pos+"px";
a.m_element.style.top=this.m_marginTop+"px";
a.m_element.style.width=b+"px";
a.m_element.style.height=(this.m_barH-this.m_marginTop)+"px";
this.m_pos+=(b+this.m_hSpace)
};
this.m_win=window;
this.m_element=null;
this.m_barW=0;
this.m_barH=20;
this.m_marginLeft=5;
this.m_marginTop=5;
this.m_hSpace=4;
this.m_pos=this.m_marginLeft;
this.m_tabs=new Array()
};
ui.tab=function(){this.create=function(c,l,d,n,k,a,m,f,h,e,g,b){this.m_win=gWin(l);
var o=this.m_win.document.createElement("div");
if(!o){return
}o.id=c;
o.setAttribute("inactiveTextColor",f);
o.setAttribute("activeTextColor",h);
o.setAttribute("inactiveBgColor",a);
o.setAttribute("activeBgColor",m);
o.setAttribute("leftCorner",e);
o.setAttribute("rightCorner",g);
if(d&&d.length){o.setAttribute("tabimg",d)
}if(k&&k.length){o.setAttribute("postImg",k)
}o.setAttribute("label",n);
o.setAttribute("width",b);
o.id=c;
o.className="uiTab";
o.setAttribute("control","uiTab");
o.ptr=this;
this.init(l.appendChild(o))
};
this.init=function(a){this.m_element=a;
this.m_activeTextColor=a.getAttribute("activeTextColor");
this.m_inactiveTextColor=a.getAttribute("inactiveTextColor");
this.m_activeBgColor=a.getAttribute("activeBgColor");
this.m_inactiveBgColor=a.getAttribute("inactiveBgColor");
this.m_leftCorner=a.getAttribute("leftCorner");
this.m_rightCorner=a.getAttribute("rightCorner");
this.m_img=a.getAttribute("tabimg");
this.m_postImg=a.getAttribute("postImg");
this.m_postImgW=a.getAttribute("postImgW");
this.m_text=a.getAttribute("label");
this.m_width=parseInt(a.getAttribute("width"));
if(this.m_width%2){this.m_width+=1;
this.m_element.setAttribute("width",this.m_width)
}this.m_label=new ui.label();
this.m_label.create(this.m_element.id+"label",this.m_element,this.m_img,this.m_text,this.m_postImg,this.m_postImgW,this.m_width);
this.m_label.m_element.style.position="relative";
this.m_label.m_element.style.top="3px";
ui.connectEvent(this.m_element,"mouseover",this,"onMouseOver",true,true);
ui.connectEvent(this.m_element,"mouseout",this,"onMouseOut",true,true);
ui.connectEvent(this.m_element,"mouseup",this,"onMouseUp",true,true);
ui.connectEvent(this.m_element,"mousedown",this,"onMouseDown",true,true)
};
this.removeCorners=function(){var a=getPartFromElement(this.m_element,"nwcorner");
if(a){this.m_element.removeChild(a)
}a=getPartFromElement(this.m_element,"necorner");
if(a){this.m_element.removeChild(a)
}};
this.addCorners=function(){var c=getPartFromElement(this.m_element,"nwcorner");
if(c){return
}var a=this.m_win.document.createElement("div");
a.id="nwcorner";
addClassName(a,"roundedTab-nw");
this.m_element.appendChild(a);
var b=this.m_win.document.createElement("div");
b.id="necorner";
addClassName(b,"roundedTab-ne");
this.m_element.appendChild(b)
};
this.onMouseOver=function(b,a){ui.setEventHandled(b);
this.m_bHover=true;
this.m_label.m_element.style.textDecoration="underline"
};
this.onMouseOut=function(b,a){ui.setEventHandled(b);
this.m_bHover=false;
this.m_label.m_element.style.textDecoration="none"
};
this.onMouseDown=function(b,a){this.m_bHover=true;
this.m_label.m_element.style.textDecoration="underline";
if(this.m_onMouseDown){doFunctions(this.m_onMouseDown,b,a)
}};
this.onMouseUp=function(b,a){ui.setEventHandled(b);
this.m_bHover=false;
this.m_label.m_element.style.textDecoration="none";
if(this.m_onMouseUp){doFunctions(this.m_onMouseUp,b,a)
}};
this.addOnMouseUp=function(a){this.m_onMouseUp.push(a)
};
this.addOnMouseDown=function(a){this.m_onMouseDown.push(a)
};
this.m_win=window;
this.m_element=null;
this.m_label=null;
this.m_bHover=false;
this.m_text="";
this.m_width=100;
this.m_activeTextColor="#000000";
this.m_inactiveTextColor="#000000";
this.m_activeBgColor="#FFFFFF";
this.m_inactiveBgColor="#CCCCCC";
this.m_img=null;
this.m_postImg=null;
this.m_postImgW=0;
this.m_onMouseOver=new Array();
this.m_onMouseUp=new Array();
this.m_onMouseDown=new Array()
};
Class("uiDlgButton",ui.element,function(a){this.initialize=function(){a(this,"initialize");
this.m_state;
this.m_element=null;
this.m_imgElem=null;
this.m_bHover=false;
this.m_bDisabled=false;
this.m_onMouseUp=new Array();
this.m_onMouseDown=new Array()
};
this.create=function(g,d,c,f){this.m_win=gWin(d);
var b=this.m_win.document.createElement("div");
if(!b){return
}b.id=g;
b.className="uiDlgButton";
b.setAttribute("state",f);
b.setAttribute("control","uiDlgButton");
b.ptr=this;
b.state=f;
b=d.appendChild(b);
var e=this.m_win.document.createElement("div");
e.className="uiDlgButton"+c;
e.style.width="19px";
e.style.height="19px";
this.m_imgElem=b.appendChild(e);
this.init(b)
};
this.init=function(b){this.m_element=b;
this.m_state=this.m_element.getAttribute("state");
if(this.m_state=="disable"){this.m_bDisabled=true
}ui.connectEvent(this.m_element,"mouseover",this,"onMouseOver",true,true);
ui.connectEvent(this.m_element,"mouseout",this,"onMouseOut",true,true);
ui.connectEvent(this.m_element,"mouseup",this,"onMouseUp",true,true);
ui.connectEvent(this.m_element,"mousedown",this,"onMouseDown",true,true)
};
this.changeType=function(b){this.m_imgElem.className="uiDlgButton"+b
};
this.refreshImage=function(){if(this.m_state=="disable"){addClassName(this.m_element,"disable")
}else{removeClassName(this.m_element,"disable")
}};
this.onMouseOver=function(c,b){ui.setEventHandled(c);
this.m_bHover=true;
if(!this.m_bDisabled){addClassName(this.m_element,"hot")
}};
this.onMouseOut=function(c,b){ui.setEventHandled(c);
this.m_bHover=false;
if(!this.m_bDisabled){removeClassName(this.m_element,"hot");
removeClassName(this.m_element,"down")
}};
this.onMouseDown=function(c,b){this.m_bHover=true;
if(!this.m_bDisabled){addClassName(this.m_element,"down");
if(this.m_onMouseDown){doFunctions(this.m_onMouseDown,c,b)
}}};
this.onMouseUp=function(c,b){ui.setEventHandled(c);
this.m_bHover=false;
if(!this.m_bDisabled){removeClassName(this.m_element,"down");
removeClassName(this.m_element,"hot");
if(this.m_onMouseUp){doFunctions(this.m_onMouseUp,c,b)
}}};
this.addOnMouseUp=function(b){this.m_onMouseUp.push(b)
};
this.addOnMouseDown=function(b){this.m_onMouseDown.push(b)
}
});
uiDlgButtons=function(){this.create=function(f,e,c,b,a){this.m_win=gWin(e);
var d=this.m_win.document.createElement("div");
if(!d){return
}d.id=f;
d.setAttribute("control","uiDlgButtons");
d.className="uiDlgButtons";
d.setAttribute("close",a);
d.setAttribute("minimize",c);
d.setAttribute("maximize",b);
d.ptr=this;
e.appendChild(d);
this.m_element=getPartFromElement(e,f);
if(c!="none"){this.m_minimizeBtn=new uiDlgButton();
this.m_minimizeBtn.create(f+"-min",this.m_element,"Min",c)
}if(b!="none"){this.m_maximizeBtn=new uiDlgButton();
this.m_maximizeBtn.create(f+"-max",this.m_element,"Max",b)
}if(a!="none"){this.m_closeBtn=new uiDlgButton();
this.m_closeBtn.create(f+"-close",this.m_element,"Close",a)
}this.init(d)
};
this.init=function(b){this.m_element=b;
this.m_win=gWin(b);
var a=this.m_element.getAttribute("img");
if(!a){return
}var c=this.m_win.document.createElement("img");
if(!c){return
}c=this.m_element.appendChild(c);
c.src=gImages.requestImage(a,c)
};
this.updateButtons=function(a){switch(a){case"min":if(this.m_minimizeBtn){this.m_minimizeBtn.changeType("Min")
}break;
case"max":if(this.m_maximizeBtn){this.m_maximizeBtn.changeType("Max")
}break;
case"minrestore":if(this.m_minimizeBtn){this.m_minimizeBtn.changeType("Restore")
}break;
case"maxrestore":if(this.m_maximizeBtn){this.m_maximizeBtn.changeType("Restore")
}break
}};
this.addOnCloseUp=function(a){if(this.m_closeBtn){this.m_closeBtn.addOnMouseUp(a)
}};
this.addOnMinimizeUp=function(a){if(this.m_minimizeBtn){this.m_minimizeBtn.addOnMouseUp(a)
}};
this.addOnMaximizeUp=function(a){if(this.m_maximizeBtn){this.m_maximizeBtn.addOnMouseUp(a)
}};
this.addOnCloseDown=function(a){if(this.m_closeBtn){this.m_closeBtn.addOnMouseDown(a)
}};
this.addOnMinimizeDown=function(a){if(this.m_minimizeBtn){this.m_minimizeBtn.addOnMouseDown(a)
}};
this.addOnMaximizeDown=function(a){if(this.m_maximizeBtn){this.m_maximizeBtn.addOnMouseDown(a)
}};
this.getWidth=function(){return this.m_element.offsetWidth
};
this.getHeight=function(){return this.m_element.offsetHeight
};
this.m_win=window;
this.m_minimizeBtn;
this.m_maximizeBtn;
this.m_closeBtn;
this.m_element=null;
this.m_hover=false
};
Class("ui.deferredDlg",lib.deferred,function(a){this.initialize=function(o,f){a(this,"initialize");
this.m_framePadding=4;
var n=argsToArray(f);
var c=n[0];
var q=n[4];
var p=n[5];
var s=n[6];
var l=n[7];
var k="favicon";
if(n[3]){var b;
if((b=n[3].lastIndexOf("."))!=-1){k=n[3].substring(0,b)
}else{k=n[3]
}}var g=this;
var e=-1;
function t(h){g.addBoth(hitch(g,"removeDlgFromPendingList"),1);
g.addBoth(h,1);
var u=g.openWindow(o,q,p,s,l);
o.m_poppedOut=!!u;
if(!u){g.displayPopupError();
g.errback(o,window);
return
}gBrowser.setFavIconSrc(k,u);
e=gTimerMgr.addTimer(function(){if(u.closed){o.m_poppedOut=false;
gTimerMgr.removeTimer(e);
g.errback(o,window)
}},125)
}function d(u,h){gTimerMgr.removeTimer(e);
gWin.remember(h);
$.remember(h.document);
n[1]=h.document.body;
if(h===window){var v=gWindowMgr.getVisibleWindowPos(n[6],n[7],false);
n[4]=v.x;
n[5]=v.y
}u.create.apply(u,n)
}function m(u,h){gTimerMgr.removeTimer(e);
if(gWindows[c]){gWindows[c].m_bPoppingOut=false
}}this.addCb(d,-1);
this.addEb(m,-1);
this.addCb(hitch(this,"resizePopupToWindow"),-1);
this.addCb(hitch(this,"hookupWinClose"),1);
this.addCb(hitch(this,"hookupWinRename"),1);
this.addCb(hitch(this,"hookupWinResize"),1);
this.addCb(hitch(this,"hookupWinEvents"),1);
this.addCb(hitch(this,"mergeIntoRealWindow"),1);
ui.deferredDlg.pendingWindows[c]=this;
gSerializer.serialize(t)
};
this.openWindow=function(m,p,o,s,k){var n=calcWinPos(window);
var e=calcWinChrome(window);
var c={menubar:"no",location:navigator.userAgent.indexOf("Camino")!=-1?"no":"yes",toolbar:"no",scrollbars:"no",status:"no",width:s,height:k-m.m_minimizeH,left:n.x+e.w+p,top:n.y+e.h+o,resizable:"yes"};
var g=[];
for(var f in c){g.push(f+"="+c[f])
}var q=g.join(",");
var d=this,b=getUniqueId()+"";
var l=window.open("/popup.html#",b,q);
if(l){l.id=b;
window._popOutCbs=window._popOutCbs||{};
window._popOutCbs[b]=[l,function(){d.callback(m,l);
delete window._popOutCbs[b]
}]
}return l
};
window._fetchCb=function(d){function c(h,g){if(window._popOutCbs[h][0]===g){var f=window._popOutCbs[h][1];
delete window._popOutCbs[h];
if(g[h]){delete g[h]
}return f
}else{return false
}}for(var e in window._popOutCbs){var b;
if(d.id&&(b=c(d.id,d))){return b
}if((b=c(e,d))){return b
}}return function(){d.close()
}
};
this.displayPopupError=function(){if(!ui.deferredDlg.m_bBlockedFlag){var b="";
if(ui.isIE){b="ie"
}else{if(ui.isFirefox){b="firefox"
}}var d=gLang.popupBlockedMsg;
if(b){var c=(b=="ie"?gLang.popupie:gLang.popupfirefox);
d+="<br><br>"+c+'<br><br><img src="'+gImages.getPath()+"popup_"+b+'.png"></img>'
}gWindowMgr.createNotifyDlg({id:getUniqueId(),caption:gLang.popupBlocked,w:d?300:275,h:d?200:130},d);
ui.deferredDlg.m_bBlockedFlag=true
}};
this.removeDlgFromPendingList=function(c,b){for(var d in ui.deferredDlg.pendingWindows){if(ui.deferredDlg.pendingWindows[d]==this){delete ui.deferredDlg.pendingWindows[d];
break
}}};
this.resizePopupToWindow=function(f,e){var d=ui.getClientRect(e),b=d.w,c=d.h;
c+=f.m_marginH-(this.m_framePadding*2);
f.resizeContent(f.m_contentArea,Math.max(b,f.m_minX),Math.max(c,f.m_minY))
};
this.hookupWinRename=function(d,c){if(!d.m_captionChangeListeners){d.m_captionChangeListeners=[]
}function b(e){gBrowser.setTitle(c,e)
}d.m_captionChangeListeners.push(b);
b(d.getWindowCaption())
};
this.hookupWinResize=function(c,b){if(!c.m_onCallbackMoveToTop){c.m_onCallbackMoveToTop=[]
}c.m_onCallbackMoveToTop.push(function(){b.focus()
});
var e;
function d(){clearTimeout(e);
e=setTimeout(hitch(this,function(){try{this.resizePopupToWindow(c,b)
}catch(f){}}),50)
}ui.connectEvent(b,"resize",{fn:hitch(this,d)},"fn",true)
};
this.hookupWinClose=function(d,c){function b(){d.closeWindow()
}d.m_onClose=d.m_onClose||[];
d.m_onClose.push(function(){ui.cleanUp(d.m_element);
if(gWindows[d.m_id]===d){gWindowMgr.unregisterWindow(d.m_id)
}$.forget(c.document);
gWin.forget(c);
if(ui.isIE){ui.deferredDlg.m_closingWindows.push(c);
if(!ui.deferredDlg.m_closingWindows.m_timerId){ui.deferredDlg.m_closingWindows.m_timerId=gTimerMgr.addTimer(hitch(ui.deferredDlg,"checkForClosedWindows"),125)
}}c.close()
});
ui.connectEvent(c,"unload",{fn:b},"fn")
};
this.hookupWinEvents=function(c,b){gBrowser.connectEventsToWin(b)
};
this.mergeIntoRealWindow=function(f,e){var d=ui.getClientRect(e),b=d.w,c=d.h;
this.showNonContent(f,false);
f.m_contentArea.style.top=this.m_framePadding+"px";
f.resizeContent(f.m_contentArea,b,c+f.m_marginH-(this.m_framePadding*2))
};
this.showNonContent=function(d,b){if(typeof(b)=="undefined"){b=true
}var c=b?"visible":"hidden";
var e=d.m_element.firstChild;
while(e){if(b||e!==d.m_contentArea){e.style.visibility=c
}e=e.nextSibling
}getPartFromElement(d.m_element,"se").style.visibility=c
}
});
ui.deferredDlg.pendingWindows={};
ui.deferredDlg.m_bBlockedFlag=false;
ui.deferredDlg.m_closingWindows=[];
ui.deferredDlg.getWndOpening=function(a){return this.pendingWindows[a]||null
};
ui.deferredDlg.checkForClosedWindows=function(){if(!this.m_closingWindows.length){gTimerMgr.removeTimer(this.m_closingWindows.m_timerId);
this.m_closingWindows.m_timerId=null
}for(var a=0;
a<this.m_closingWindows.length;
a++){if(this.m_closingWindows[a].closed){this.m_closingWindows.splice(a,1);
a--
}else{this.m_closingWindows[a].close()
}}};
Class("ui.dlg",function(){this.initialize=function(){this.m_win=window;
this.m_classNamePrefix=this.m_classNamePrefix||"uiDlg";
this.m_bDisplayActive=false;
this.m_bFlashing=false;
this.m_element=null;
this.m_parent=null;
this.m_bActive=false;
this.m_bVisible=true;
this.m_minimizeW=150;
this.m_minimizeH=28;
this.m_state="normal";
this.m_lastMinPos;
this.m_lastMaxPos;
this.m_lastPos;
this.m_bResizable=false;
this.m_resizeHandle;
this.m_dr=new ui.drag.dragObject();
this.m_minX=100;
this.m_minY=100;
this.m_maxX=99999;
this.m_maxY=99999;
this.m_marginX=4;
this.m_marginY=30;
this.m_marginW=8;
this.m_marginH=40;
this.m_centerRowH=38;
this.m_caption=null;
this.m_contentArea=null;
this.m_windowButtons=null;
this.m_skin="";
this.m_chromelessMaxDragY=0;
this.m_chromelessVersion=2;
this.m_id;
this.m_poppedOut=false;
this.m_bPoppingOut=false;
this.m_onMouseDown=[];
this.m_onDragStart=[];
this.m_onStopResize=[];
this.m_onStopMove=[];
this.m_onMinimize=[];
this.m_onCallbackRestoreMinimize=[];
this.m_onMaximize=[];
this.m_onRestoreMaximize=[];
this.m_onCallbackRestoreMaximize=[];
this.m_onClose=[];
this.m_onFocus=[];
this.m_onKeyPress=[];
this.m_onBlur=[];
this.m_onMoveToTop=[];
this.m_onCallbackMoveToTop=[];
this.m_onWindowFocus=[];
this.m_onWindowUnfocus=[];
this.m_delegate;
this.m_isRestoring=false
};
this.create=function(b,n,o,p,k,g,l,c,d,f){if(!n&&ui.deferredDlg){return new ui.deferredDlg(this,arguments)
}else{if(!n){n=window.document.body
}}this.m_win=gWin(n);
if(this.isPoppedOut()){this.m_win.m_windowId=b
}var e=this.m_win.document.createElement("div");
e.setAttribute("type",f);
if(d){e.setAttribute("resizable",d)
}e.setAttribute("caption",o);
e.ptr=this;
this.m_id=e.id=b;
e.className=this.m_classNamePrefix;
e.setAttribute("captionImg",p);
var m=(this.getTemplate?this.getTemplate():null);
if(m){e.innerHTML=m
}var a=ui.getClientRect(this.m_win);
l=Math.min(l,a.w);
c=Math.min(c,a.h);
k=Math.min(k,a.w-l);
g=Math.min(g,a.h-c);
if(k<0||this.isPoppedOut()){k=0
}if(g<0||this.isPoppedOut()){g=0
}e.style.left=k+"px";
e.style.top=g+"px";
e.style.width=l+"px";
e.style.height=c+"px";
if(ui.isMac&&ui.isFirefox){e.style.position="fixed"
}if(!n){n=this.m_win.document.body
}e=n.appendChild(e);
return this.init(e)
};
this.initContent=function(){if(!this.m_delegate){var a=this.m_win.document.createElement("span");
a.className="unselectable";
a.unselectable="on";
a.style.lineHeight="1";
a.style.fontSize="11px";
setText(a,gLang.oneMoment);
getPartFromElement(this.m_element,"bg").appendChild(a);
this.m_loadingMessage=a
}return true
};
this.connectContentEvents=function(){};
this.init=function(c){var e=new lib.deferred().callback(this);
if(!c){return e
}this.m_element=c;
this.m_parent=this.m_element.parentNode;
this.m_bResizable=(getbAttribute(this.m_element,"resizable"))?true:false;
if(this.m_bResizable){this.m_marginH=36;
addClassName(this.m_element,"resizable")
}var f=this.createWindowTable();
var b=this.m_element.getAttribute("caption");
var d=this.m_element.getAttribute("captionImg");
this.addWindowButtons();
this.setWindowCaption(b,d);
this.createContentArea(f);
if(this.m_bResizable){var a=this.m_win.document.createElement("img");
a.className=this.m_classNamePrefix+"Handle";
a.id="handle";
gImages.requestImage("handle.gif",a);
a.style.position="absolute";
a.style.bottom=(ui.isIE==6?1-this.m_element.offsetHeight%2:1)+"px";
a.style.right=(ui.isIE==6?1-this.m_element.offsetWidth%2:1)+"px";
this.m_element.appendChild(a);
this.m_resizeHandle=a
}this.m_element.ptr=this;
if(this.onRender){this.onRender()
}this.connectEvents();
return e
};
this.setId=function(a){this.m_id=a;
this.m_element.id=a;
this.m_caption.getElement().id=a+"caption";
this.m_caption.m_id=a+"caption"
};
this.getDelegate=function(){return this.m_delegate
};
this.setDelegate=function(a,b){if(this.m_delegate){return
}this.m_delegate=a;
if(this.m_element){a.m_dlg=this;
a.m_element=this.getBody();
a.m_win=this.m_win;
a.m_id=this.m_id+"-delegate";
if(this.m_loadingMessage){removeElement(this.m_loadingMessage);
this.m_loadingMessage=null
}if(a.setDelegateParams){a.setDelegateParams.apply(a,b)
}if(a.getTemplate){a.m_element.innerHTML=a.getTemplate()
}a.initContent();
if(a.m_minX){this.m_minX=a.m_minX
}if(a.m_minY){this.m_minY=a.m_minY
}if(a.m_maxX){this.m_maxX=a.m_maxX
}if(a.m_maxY){this.m_maxY=a.m_maxY
}}};
this.isPoppedOut=function(){return this.m_poppedOut
};
this.onGlobalKeyPress=function(b,a){if(this.m_onKeyPress){doFunctions(this.m_onKeyPress,b,a)
}};
this.onGlobalKeyDown=function(b,a){if(this.m_onKeyDown){doFunctions(this.m_onKeyDown,b,a)
}};
this.onKeyPress=function(a){if(this.m_onKeyPress){doFunctions(this.m_onKeyPress,a)
}};
this.addOnKeyPress=function(b,a){this.m_onKeyPress.push(function(d,c){if(b[a]){b[a](d,c)
}})
};
this.addOnKeyDown=function(b,a){this.m_onKeyDown.push(function(d,c){if(b[a]){b[a](d,c)
}})
};
this.addOnClose=function(b,a){this.m_onClose.push(function(d,c){if(b[a]){b[a](d,c)
}})
};
this.addOnFocus=function(b,a){this.m_onFocus.push(function(d,c){if(b[a]){b[a](d,c)
}})
};
this.addOnMouseDown=function(b,a){this.m_onMouseDown.push(function(d,c){if(b[a]){b[a](d,c)
}})
};
this.addOnMoveToTop=function(b,a){this.m_onMoveToTop.push(function(d,c){if(b[a]){b[a](d,c)
}})
};
this.addOnStopResize=function(a){this.m_onStopResize.push(a)
};
this.addOnBlur=function(b,a){this.m_onBlur.push(function(d,c){if(b[a]){b[a](d,c)
}})
};
this.getZIndex=function(){return parseInt(this.m_element.style.zIndex)
};
this.setZIndex=function(a){this.m_element.style.zIndex=Math.max(a,1)
};
this.getElement=function(){return this.m_element
};
this.createWindowTable=function(){var b=this.m_element.innerHTML;
var a='<table id="windowFrame" class="'+this.m_classNamePrefix+'Frame">			<tr class="'+this.m_classNamePrefix+'RowN">				<td id="nw" class="'+this.m_classNamePrefix+'NW">&nbsp;<br>				<td id="n" class="'+this.m_classNamePrefix+'N">&nbsp;<br>				<td id="ne" class="'+this.m_classNamePrefix+'NE">&nbsp;<br>			</tr>			<tr class="'+this.m_classNamePrefix+'RowBar">				<td id="barw" class="'+this.m_classNamePrefix+'BarW">&nbsp;<br>				<td id="barn" class="'+this.m_classNamePrefix+'BarN">&nbsp;<br>				<td id="bare" class="'+this.m_classNamePrefix+'BarE">&nbsp;<br>			</tr>			<tr class="'+this.m_classNamePrefix+'RowBody">				<td id="w" class="'+this.m_classNamePrefix+'W">&nbsp;<br>				<td id="bg" class="'+this.m_classNamePrefix+'Bg" align="center" valign="center">				<td id="e" class="'+this.m_classNamePrefix+'E">&nbsp;<br>			</tr>			<tr class="'+this.m_classNamePrefix+'RowS">				<td id="sw" class="'+this.m_classNamePrefix+'SW">&nbsp;<br>				<td id="s" class="'+this.m_classNamePrefix+'S">&nbsp;<br>				<td id="se" class="'+this.m_classNamePrefix+'SE">&nbsp;<br>			</tr>		</table>';
this.m_element.innerHTML=a;
this.m_windowFrame=this.m_element.getElementsByTagName("table")[0];
if(ui.isIE){this.m_centerEl=this.m_windowFrame.childNodes[0].childNodes[2].childNodes[1];
this.m_centerEl.style.height=this.m_element.offsetHeight-this.m_centerRowH+"px"
}this.setSkin(this.m_skin);
addClassName(this.m_windowFrame,"inactive");
return b
};
this.setSkin=function(a){if(!this.m_windowFrame){this.m_skin=a;
return
}var b=gDoc(this.m_element).documentElement;
if(this.isPoppedOut()){removeClassName(b,this.m_skin)
}removeClassName(this.m_element,this.m_skin);
this.m_skin=a;
addClassName(this.m_element,this.m_skin);
if(this.isPoppedOut()){addClassName(b,this.m_skin)
}if(this.m_skin=="chromeless"){this.m_marginW=8;
this.m_marginH=this.m_bResizable?14:18;
this.m_centerRowH=68
}else{this.m_marginW=8;
this.m_marginH=this.m_bResizable?36:40;
this.m_centerRowH=38
}if(this.m_centerEl){this.m_centerEl.style.height=Math.max(1,this.m_element.offsetHeight-this.m_centerRowH)+"px"
}};
this.setWindowCaption=function(g,d){if(!this.m_windowFrame){return
}var h=this.m_windowFrame.rows.length;
var b=this.m_windowFrame.rows[h-3].cells[1];
var f=this.m_windowFrame.rows[1].cells[2];
if(!b){return
}if(!this.m_caption){if(ui.isIE){var a=b.offsetWidth;
if(this.m_windowButtons){a-=this.m_windowButtons.m_element.offsetWidth
}}else{var a=(this.m_windowButtons?this.m_windowButtons.m_element.offsetLeft:f.offsetLeft)
}if(ui.isWebKit&&(a>56)){a-=56
}this.m_caption=new ui.label();
this.m_caption.create(this.m_id+"caption",b,d,g,"","",a);
this.m_caption.addClassName(this.m_classNamePrefix+"Caption");
this.m_caption.m_cssProperties={fontSize:"12px",fontWeight:"bold",fontFamily:"Tahoma, Arial, sans-serif"}
}else{this.m_caption.setText(g);
if(d){this.m_caption.setPreImg(d)
}}var e=this.m_captionChangeListeners;
for(var c=0;
e&&c<e.length;
++c){e[c](stripWhitespace(g))
}};
this.getWindowCaption=function(){if(this.m_caption&&this.m_caption.getText){return this.m_caption.getText()
}};
this.addWindowButtons=function(){var b=this.m_element.getAttribute("type");
if(b=="none"){return
}this.m_windowButtons=new uiDlgButtons();
var a=getPartFromElement(this.m_element,"barn");
switch(b){case"close":this.m_windowButtons.create(this.m_id+"-windowbtns",a,"none","none","enable");
break;
case"onlymin":this.m_windowButtons.create(this.m_id+"-windowbtns",a,"enable","none","none");
break;
case"noclose":this.m_windowButtons.create(this.m_id+"-windowbtns",a,"enable","enable","none");
break;
case"nominmax":this.m_windowButtons.create(this.m_id+"-windowbtns",a,"disable","disable","enable");
break;
case"none":break;
default:this.m_windowButtons.create(this.m_id+"-windowbtns",a,"enable","enable","enable");
break
}this.m_windowButtons.addOnCloseUp(hitch(this,"closeWindow"));
this.m_windowButtons.addOnMinimizeUp(hitch(this,"minimizeWindow"));
this.m_windowButtons.addOnMaximizeUp(hitch(this,"maximizeWindow"));
this.m_windowButtons.addOnCloseDown(hitch(this,"onMouseDown"));
this.m_windowButtons.addOnMinimizeDown(hitch(this,"onMouseDown"));
this.m_windowButtons.addOnMaximizeDown(hitch(this,"onMouseDown"))
};
this.createContentArea=function(b){var a=this.m_win.document.createElement("div");
a.innerHTML=b;
a.id="content";
addClassName(a,this.m_classNamePrefix+"ContentArea");
this.resizeContent(a,this.m_element.offsetWidth,this.m_element.offsetHeight);
this.m_contentArea=this.m_element.insertBefore(a,this.m_windowFrame)
};
this.connectBorderMouseDown=function(a){if(a){ui.connectEvent(a,"mousedown",this,"onBorderMouseDown",true,true)
}};
this.connectEvents=function(){var a=this.toHash(this.m_element.getElementsByTagName("td"));
ui.connectEvent(a.barn,"dblclick",this,"restoreWindow");
if(this.m_element.getAttribute("resizable")=="false"){return
}this.connectBorderMouseDown(a.barn);
this.connectBorderMouseDown(a.bare);
this.connectBorderMouseDown(a.barw);
this.connectBorderMouseDown(a.nw);
this.connectBorderMouseDown(a.n);
this.connectBorderMouseDown(a.ne);
this.connectBorderMouseDown(a.w);
this.connectBorderMouseDown(a.e);
this.connectBorderMouseDown(a.sw);
this.connectBorderMouseDown(a.s);
this.connectBorderMouseDown(a.se);
this.connectBorderMouseDown(this.m_resizeHandle);
this.connectBorderMouseDown(this.getBody());
this.addOnMouseDown(this,"callActivate");
this.addOnFocus(this,"handleFocus")
};
this.toHash=function(a){var c={};
for(var b=0;
b<a.length;
b++){var d=a[b];
if(d&&d.id){c[d.id]=d
}}return c
};
this.onBlur=function(){if(this.m_onBlur){doFunctions(this.m_onBlur)
}};
this.onFocus=function(){if(this.m_win.m_focus){try{if(!this.isPoppedOut()){$("focuser").focus()
}}catch(a){}this.m_win.focus()
}if(this.m_onFocus){doFunctions(this.m_onFocus)
}};
this.handleFocus=function(){this.moveToTop();
this.stopFlashWindow()
};
this.onWindowFocus=function(){doFunctions(this.m_onWindowFocus)
};
this.onWindowUnfocus=function(){doFunctions(this.m_onWindowUnfocus)
};
this.onMouseDown=function(b,a){if(this.m_onMouseDown){doFunctions(this.m_onMouseDown)
}};
this.onStopResize=function(a,b){doFunctions(this.m_onStopResize)
};
this.callActivate=function(b,a){if(!this.isActive()){gWindowMgr.activateWindow(this)
}};
this.onBorderMouseDown=function(b,a){this.onMouseDown(b,a);
if(!a||!a.id||!b){return true
}if(a.getAttribute("control")=="uiDlgButton"){return true
}var f=a.id;
if(f=="barn"){var e=getElementPosition(a);
if(this.m_windowButtons&&(ui.getCursorX(b)>(e.left+a.offsetWidth-this.m_windowButtons.getWidth()))){return true
}}else{if(f=="handle"&&this.m_bResizable){f="se"
}}if(f!="content"){ui.setEventHandled(b)
}if(hasClassName(a,"draggable")&&this.m_state!="min"&&this.m_state!="max"){this.m_dr.init(this,b);
this.m_dr.startMove();
return
}switch(f){case"content":if(this.m_skin=="chromeless"){var d=b.target||b.srcElement;
if(this.m_state!="min"&&this.m_state!="max"&&ui.getCursorPos(b).y-this.getWindowPos().y<=this.m_chromelessMaxDragY){this.m_dr.init(this,b);
this.m_dr.startMove()
}}break;
case"barn":if(this.m_state!="min"&&this.m_state!="max"){this.m_dr.init(this,b);
this.m_dr.startMove()
}break;
case"n":case"ne":case"nw":if((this.m_state!="min")&&this.m_state!="max"&&(!this.m_bResizable)){this.m_dr.init(this,b);
this.m_dr.startMove();
break
}default:if((this.m_state!="min")&&this.m_state!="max"&&(this.m_bResizable)){this.m_dr.init(this,b);
var c=f;
if(f=="bare"){c="e"
}if(f=="barw"){c="w"
}this.m_dr.startResize(c,this.m_minX,this.m_minY,this.m_maxX,this.m_maxY)
}break
}return
};
this.isActive=function(){return this.m_bActive
};
this.restoreWindow=function(){if(this.m_state=="min"){this.restoreMinimizeWindow()
}else{if(this.m_bResizable&&this.m_windowButtons.m_maximizeBtn){this.maximizeWindow()
}}};
this.minimizeWindow=function(){if(this.m_state=="min"){this.restoreMinimizeWindow();
return
}if(this.m_onMinimize){doFunctions(this.m_onMinimize)
}this.saveLastMinimizePos();
if(this.m_windowButtons){this.m_windowButtons.updateButtons("minrestore");
this.m_windowButtons.updateButtons("max")
}this.m_state="min";
this.getBody().style.visibility="hidden";
addClassName(this.m_windowFrame,"minimize");
if(this.m_bResizable){this.m_resizeHandle.style.visibility="hidden";
removeClassName(this.m_element,"resizable")
}var a=ui.getClientRect(document);
this.setWindowPos(0,a.h-this.m_minimizeH,this.m_minimizeW,this.m_minimizeH);
this.m_element.setAttribute("tileIndex",gWindowMgr.getNextTileIndex());
this.m_element.style.zIndex=1;
gWindowMgr.tileMinWindows();
gWindowMgr.deactivateWindows();
this.activateWindow();
if(ui.isWebKit){removeClassName(this.m_windowFrame,this.m_classNamePrefix+"Frame");
setTimeout(hitch(this,function(){addClassName(this.m_windowFrame,this.m_classNamePrefix+"Frame")
}),0)
}};
this.maximizeWindow=function(){removeClassName(this.m_windowFrame,"minimize");
if(this.m_onMaximize){doFunctions(this.m_onMaximize)
}if(this.m_state=="max"){this.restoreMaximizeWindow();
return
}this.saveLastMaximizePos();
if(this.m_windowButtons){this.m_windowButtons.updateButtons("maxrestore");
this.m_windowButtons.updateButtons("min")
}var a=gWindowMgr.getNumMinWindows();
if(this.m_state=="min"){a--;
this.m_state="max";
this.getBody().scrollTop=this.getBody().scrollLeft=0;
this.getBody().style.visibility="visible";
if(this.m_bResizable){this.m_resizeHandle.style.visibility="visible";
addClassName(this.m_element,"resizable")
}gWindowMgr.tileMinWindows()
}if(this.m_bResizable){this.m_resizeHandle.style.visibility="hidden";
removeClassName(this.m_element,"resizable")
}this.onFocus();
var b=ui.getClientRect(this.m_win.document);
if(a>0){b.h=b.h-(gWindowMgr.getNumMinRows()*this.m_minimizeH)
}this.setWindowRect(b);
this.m_state="max"
};
this.updateMaximize=function(){if(!this.isMaximized()){return
}var a=gWindowMgr.getNumMinWindows();
var b=ui.getClientRect(this.m_win.document);
if(a>0){b.h=b.h-(gWindowMgr.getNumMinRows()*this.m_minimizeH)
}this.setWindowRect(b)
};
this.restoreMinimizeWindow=function(){if(this.m_state!="min"){return
}if(this.m_onRestoreMinimize){doFunctions(this.m_onRestoreMinimize)
}this.m_state="normal";
this.setWindowRect(this.m_lastMinPos);
this.m_lastMinPos=null;
if(this.m_windowButtons){this.m_windowButtons.updateButtons("min")
}this.getBody().scrollTop=this.getBody().scrollLeft=0;
this.getBody().style.visibility="visible";
removeClassName(this.m_windowFrame,"minimize");
if(this.m_bResizable){this.m_resizeHandle.style.visibility="visible";
addClassName(this.m_element,"resizable")
}this.onFocus();
gWindowMgr.tileMinWindows();
if(this.m_onCallbackRestoreMinimize){doFunctions(this.m_onCallbackRestoreMinimize)
}};
this.restoreMaximizeWindow=function(){if(this.m_onRestoreMaximize){doFunctions(this.m_onRestoreMaximize)
}this.setWindowRect(this.m_lastMaxPos);
if(this.m_windowButtons){this.m_windowButtons.updateButtons("max")
}this.m_state="normal";
this.m_lastMaxPos=null;
if(this.m_bResizable){this.m_resizeHandle.style.visibility="visible";
addClassName(this.m_element,"resizable")
}if(this.m_onCallbackRestoreMaximize){doFunctions(this.m_onCallbackRestoreMaximize)
}};
this.isMinimized=function(){return(this.m_state=="min")
};
this.isMaximized=function(){return(this.m_state=="max")
};
this.saveLastMinimizePos=function(){if(this.isMaximized()){this.m_lastMinPos=this.m_lastMaxPos;
return
}this.m_lastMinPos=this.getWindowPos()
};
this.saveLastMaximizePos=function(){if(this.isMinimized()){this.m_lastMaxPos=this.m_lastMinPos;
return
}this.m_lastMaxPos=this.getWindowPos()
};
this.startFlashWindow=function(){if(this.m_bFlashing){return
}gWindowMgr.addFlashingWindow(this,true);
this.m_bFlashing=true
};
this.stopFlashWindow=function(){if(!this.m_bFlashing){return
}gWindowMgr.addFlashingWindow(this,false);
this.m_bFlashing=false
};
this.flashWindow=function(){if(this.m_bDisplayActive){removeClassName(this.m_windowFrame,"inactive")
}else{addClassName(this.m_windowFrame,"inactive")
}this.m_bDisplayActive=!this.m_bDisplayActive
};
this.inactivateWindow=function(){if(!this.m_bActive&&!this.m_bDisplayActive){return
}addClassName(this.m_windowFrame,"inactive");
this.onBlur();
this.m_bActive=this.m_bDisplayActive=false
};
this.activateWindow=function(){if(this.m_bActive){return
}removeClassName(this.m_windowFrame,"inactive");
this.m_bActive=this.m_bDisplayActive=true;
if(this.m_state!="min"){this.onFocus()
}};
this.moveToTop=function(){if(this.m_onMoveToTop){doFunctions(this.m_onMoveToTop)
}if(!this.isMinimized()){this.setZIndex(gWindowMgr.getNextZIndex())
}if(this.m_onCallbackMoveToTop){doFunctions(this.m_onCallbackMoveToTop)
}};
this.getWindowPos=function(){if(this.isPoppedOut()){var d=this.m_win;
var a=calcWinPos(d);
var e=calcWinPos(window);
var c=calcWinChrome(window);
if(ui.isIE){var b=calcWinChrome(d);
a.x-=b.w;
a.y-=b.h
}return{x:a.x-e.x-c.w,y:a.y-e.y-c.h,w:a.w,h:a.h,z:this.getZIndex()}
}if(this.isVisible()){return{x:this.m_element.offsetLeft,y:this.m_element.offsetTop,w:this.m_element.offsetWidth,h:this.m_element.offsetHeight,z:this.getZIndex()}
}else{if(this.m_lastPos){return this.m_lastPos
}}return{x:0,y:0,w:0,h:0,z:0}
};
this.showWindow=function(){if(this.m_bVisible){return
}this.m_element.style.visibility="visible";
this.m_element=this.m_parent.appendChild(this.m_element);
this.m_bVisible=true;
if(this.onShow){this.onShow()
}};
this.closeWindow=function(){if(!this.m_bVisible){return
}this.stopFlashWindow();
if(this.m_onClose){doFunctions(this.m_onClose)
}this.m_bVisible=false;
if(!this.isPoppedOut()){this.m_lastPos=this.getWindowPos();
if(this.m_element.parentNode){removeElement(this.m_element)
}else{this.m_element.style.visibility="hidden"
}if(this.m_state=="min"){gWindowMgr.tileMinWindows()
}}gWindowMgr.handleWindowClose(this)
};
this.isVisible=function(){return this.m_bVisible
};
this.moveWindow=function(a,c){if(this.m_poppedOut){a=c=0
}var b=ui.getClientRect(this.m_win);
a=Math.max(75-this.m_element.offsetWidth,Math.min(a,b.w-this.m_minimizeH));
c=Math.max(0,Math.min(c,b.h-this.m_minimizeH));
this.m_element.style.left=a+"px";
this.m_element.style.top=c+"px"
};
this.setWindowRect=function(a){this.setWindowPos(a.x,a.y,a.w,a.h)
};
this.setWindowPos=function(k,g,l,d,b){var c=l-this.m_element.offsetWidth;
var e=d-this.m_element.offsetHeight;
if(this.isPoppedOut()&&ui.isGecko){this.m_element.style.position="fixed"
}else{if(this.isPoppedOut()){this.m_element.style.position="absolute";
k=g=0
}}if(!b&&this.isPoppedOut()){var f=this.getWindowPos();
this.m_win.resizeBy(l>=0?l-f.w:0,d>=0?d-f.h:0)
}if(k!=null&&k>=0){this.m_element.style.left=k+"px"
}if(g!=null&&g>=0){this.m_element.style.top=g+"px"
}if(l>=0&&c){this.m_element.style.width=l+"px";
if(this.m_resizeHandle){this.m_resizeHandle.style.right=(ui.isIE==6?1-l%2:1)+"px"
}}if(d>=0&&e){this.m_element.style.height=d+"px";
if(this.m_resizeHandle){this.m_resizeHandle.style.bottom=(ui.isIE==6?1-d%2:1)+"px"
}if(this.m_centerEl){this.m_centerEl.style.height=Math.max(1,d-this.m_centerRowH)+"px"
}}if(l>0&&c){var a=(this.m_windowButtons)?(l-this.m_windowButtons.m_element.offsetWidth):l;
a-=10;
if(a<0){a=0
}if(this.m_caption){this.m_caption.resize(a)
}}if(c||e){this.resizeContent(this.m_contentArea,l,d)
}};
this.resizeContent=function(b,a,d){if(this.m_poppedOut&&ui.isGecko){b.style.position="fixed"
}var c;
var e;
if(a&&(a>=0)){c=a-this.m_marginW;
if(c<0){c=0
}b.style.width=c+"px"
}if(d&&(d>=0)){e=d-this.m_marginH;
if(e<0){e=0
}b.style.height=e+"px"
}if(b.ptr&&b.ptr.resize){b.ptr.resize(c,e)
}};
this.resizeTo=function(a,b,d){var e=this.getWindowPos();
a=a||e.w;
b=b||e.h;
var c=new ui.Animation({duration:300,transition:ui.Animation.easeInOut,subject:hitch(this,function(f){this.setWindowPos(null,null,e.w+(a-e.w)*f,e.h+(b-e.h)*f)
}),onOne:d});
if(this.isPoppedOut()){c.jumpTo(1)
}else{c.play()
}};
this.resizeBy=function(a,b,c){var d=this.getWindowPos();
this.resizeTo(d.w+a,d.h+b,c)
};
this.getBody=function(){return this.m_contentArea
};
this.getId=function(){return this.m_id
};
this.saveState=function(){return{}
};
this.restoreState=function(a){this.m_isRestoring=false
};
this.setCreateFnc=function(b,c,a){this.m_createFnc={c:b,f:c,a:a}
};
this.reversePop=function(a){if(!this.m_isRestoring){this.popOutDlg(!this.isPoppedOut(),a)
}};
this.popOutDlg=function(c,b){if(this.m_bPoppingOut){return
}this.m_bPoppingOut=true;
var a=function(){if(!this.m_createFnc){return
}var g=this.getWindowPos();
if(this.isPoppedOut()){g.h+=this.m_minimizeH
}var e=this;
function d(k){var h=e.saveState();
e.closeWindow();
k.restoreState(h);
gWindowMgr.activateWindow(k);
if(b){b(k)
}}var f=this.m_createFnc.f.apply(this.m_createFnc.c,this.m_createFnc.a.concat(d,c,g,true));
f.m_isRestoring=true
};
runInMainContext(this,a)
}
});
ui.drag={};
Class("ui.drag.dragObject",function(){this.m_obj;
this.m_event;
this.m_active=false;
this.m_minW;
this.m_minH;
this.m_maxW;
this.m_maxH;
this.m_startX;
this.m_startY;
this.m_startRect;
this.m_didMoveX;
this.m_didMoveY;
this.m_actionType;
this.m_direction;
this.m_currentDropOver=null;
this.m_dropCargo=null;
this.m_bDropSuccess=false;
this.m_bDragStartCalled=false;
this.m_callback;
this.initialize=function(){this.m_win=window;
this.m_dropCoordList=[]
};
this.init=function(c,a,b){this.m_win=gWin(c.m_element||c);
this.m_callback=b;
this.m_obj=c;
this.m_event=a;
this.m_startX=ui.getCursorX(this.m_event);
this.m_startY=ui.getCursorY(this.m_event);
if(!this.m_obj.m_element&&this.m_obj.getPos){this.m_startRect=this.m_obj.getPos()
}else{if(this.m_obj.m_element){this.m_startRect=this.getPos(this.m_obj.m_element)
}else{if(this.m_obj){this.m_startRect=this.getPos(this.m_obj)
}}}this.m_bDragStartCalled=false;
this.m_bDropSuccess=false
};
this.getPos=function(a){if(!a){return null
}return new ui.rect(a.offsetLeft,a.offsetTop,a.offsetWidth,a.offsetHeight)
};
this.setDropCargo=function(a){this.m_dropCargo=a
};
this.clearDropCargo=function(){this.m_dropCargo=null
};
this.startResize=function(e,a,c,d,b){eventlog("start resize");
this.m_active=true;
this.m_actionType="resize";
this.m_direction=e;
this.m_minW=a;
this.m_minH=c;
this.m_maxW=d;
this.m_maxH=b;
this.m_didMoveX=false;
this.m_didMoveY=false;
ui.setEventHandled(this.m_event);
ui.connectGlobalEvent(gDoc(this.m_win),"mousedown",hitch(this,"onDragStop"));
ui.connectGlobalEvent(gDoc(this.m_win),"mousemove",hitch(this,"onDrag"));
ui.connectGlobalEvent(gDoc(this.m_win),"mouseup",hitch(this,"onDragStop"));
gPubSub.publish(this,"ui.drag::startResize")
};
this.startMove=function(){eventlog("start move");
this.m_active=true;
this.m_actionType="move";
var c=gDragManager.getDropTargets();
if(this.m_dropCargo&&c.length>0){this.setupDragListCoords();
if(c.length>1){for(var a=0;
a<this.m_dropCoordList.length;
a++){var b=this.m_dropCoordList[a].dropTarget.m_element;
b.zSort=parseInt(getCSSProp(b,"z-index"));
if(isNaN(b.zSort)){b.zSort=0
}}this.m_dropCoordList.sort(function(e,d){return(d.dropTarget.m_element.zSort-e.dropTarget.m_element.zSort)
})
}}ui.setEventHandled(this.m_event);
ui.connectGlobalEvent(gDoc(this.m_win),"mousedown",hitch(this,"onDragStop"));
ui.connectGlobalEvent(gDoc(this.m_win),"mousemove",hitch(this,"onDrag"));
ui.connectGlobalEvent(gDoc(this.m_win),"mouseup",hitch(this,"onDragStop"));
gPubSub.publish(this,"ui.drag::startMove")
};
this.setupDragListCoords=function(){var b=gDragManager.getDropTargets();
this.m_dropCoordList=[];
for(var a=0;
a<b.length;
a++){var d=b[a];
if(!d||(d.control=="imdlg"&&d.isPoppedOut())||!d.m_element||gWin(d.m_element)!=this.m_win){continue
}var c=posWithRespectTo(d.m_element);
c.dropTarget=d;
this.m_dropCoordList.push(c)
}};
this.onDrag=function(a){if(this.m_actionType=="move"){this.onDragMove(a)
}else{if(this.m_actionType=="resize"){this.onResize(a)
}}ui.setEventHandled(a)
};
this.onDragStop=function(a){eventlog("stopping drag");
this.m_active=false;
ui.setEventHandled(a);
ui.disconnectGlobalEvent(gDoc(this.m_win),"mousedown");
ui.disconnectGlobalEvent(gDoc(this.m_win),"mousemove");
ui.disconnectGlobalEvent(gDoc(this.m_win),"mouseup");
if(this.m_currentDropOver!=null){if(this.m_currentDropOver.dropHandle){if(this.m_dropCargo){this.m_bDropSuccess=this.m_currentDropOver.dropHandle(this.m_dropCargo);
this.m_dropCargo=null
}if(this.m_currentDropOver.dropHover){this.m_currentDropOver.dropHover(false)
}}this.m_currentDropOver=null
}if(this.m_actionType=="resize"&&this.m_obj.m_onStopResize){doFunctions(this.m_obj.m_onStopResize,a,this.m_didMoveX,this.m_didMoveY);
gPubSub.publish(this,"ui.drag::stopResize")
}else{if(this.m_actionType=="move"&&this.m_obj.m_onStopMove){doFunctions(this.m_obj.m_onStopMove);
gPubSub.publish(this,"ui.drag::stopMove")
}}this.m_bDragStartCalled=false
};
this.getCurrentDropOver=function(){return this.m_currentDropOver
};
this.isDropSuccessful=function(){return this.m_bDropSuccess
};
this.onResize=function(e){var b=ui.getCursorX(e)-this.m_startX;
var a=ui.getCursorY(e)-this.m_startY;
if((b==0)&&(a==0)){return
}if(b){this.m_didMoveX=true
}if(a){this.m_didMoveY=true
}if((this.m_direction.indexOf("w")!=-1)&&(this.m_startRect.x+b<0)){b=0-this.m_startRect.x
}if((this.m_direction.indexOf("n")!=-1)&&(this.m_startRect.y+a<0)){a=0-this.m_startRect.y
}if(!this.m_bDragStartCalled){if(this.m_obj&&this.m_obj.m_onDragStart){doFunctions(this.m_obj.m_onDragStart);
this.m_bDragStartCalled=true
}}var d;
if(this.m_obj&&this.m_obj.m_element){d=this.getPos(this.m_obj.m_element)
}else{if(this.m_obj&&this.m_obj.getElement){d=this.getPos(this.m_obj.getElement())
}else{if(this.m_obj){d=this.getPos(this.m_obj)
}else{return
}}}var c=new ui.rect(this.m_startRect.x,this.m_startRect.y,this.m_startRect.w,this.m_startRect.h);
switch(this.m_direction){case"n":c.y=(this.m_startRect.y+a);
c.h=(this.m_startRect.h-a);
break;
case"ne":c.y=(this.m_startRect.y+a);
c.h=(this.m_startRect.h-a);
c.w=(this.m_startRect.w+b);
break;
case"nw":c.y=(this.m_startRect.y+a);
c.h=(this.m_startRect.h-a);
c.x=(this.m_startRect.x+b);
c.w=(this.m_startRect.w-b);
break;
case"e":c.w=(this.m_startRect.w+b);
break;
case"w":c.x=(this.m_startRect.x+b);
c.w=(this.m_startRect.w-b);
break;
case"s":c.h=(this.m_startRect.h+a);
break;
case"se":c.w=(this.m_startRect.w+b);
c.h=(this.m_startRect.h+a);
break;
case"sw":c.h=(this.m_startRect.h+a);
c.x=(this.m_startRect.x+b);
c.w=(this.m_startRect.w-b);
break
}if(this.m_minW&&(c.w<this.m_minW)){if(this.m_direction.indexOf("w")!=-1){c.x=this.m_startRect.x+this.m_startRect.w-this.m_minW
}c.w=this.m_minW
}if(this.m_minH&&(c.h<this.m_minH)){if(this.m_direction.indexOf("n")!=-1){c.y=this.m_startRect.y+this.m_startRect.h-this.m_minH
}c.h=this.m_minH
}if(this.m_maxW&&(c.w>this.m_maxW)){c.w=this.m_maxW
}if(this.m_maxH&&(c.h>this.m_maxH)){c.h=this.m_maxH
}if((!this.m_minW||(c.w>=this.m_minW))&&(!this.m_maxW||(c.w<=this.m_maxW))){d.w=c.w;
d.x=c.x
}if((!this.m_minH||(c.h>=this.m_minH))&&(!this.m_maxH||(c.h<=this.m_maxH))){d.h=c.h;
d.y=c.y
}if(this.m_callback){this.m_callback(d.x,d.y,d.w,d.h)
}else{if(this.m_obj&&this.m_obj.setWindowPos){this.m_obj.setWindowPos(d.x,d.y,d.w,d.h)
}else{if(this.m_obj&&this.m_obj.setElementPos){this.m_obj.setElementPos(d.x,d.y,d.w,d.h)
}else{if(this.m_obj&&this.m_obj.style){this.m_obj.style.top=d.y+"px";
this.m_obj.style.left=d.x+"px";
this.m_obj.style.width=d.w+"px";
this.m_obj.style.height=d.h+"px"
}}}}};
this.onDragMove=function(c){var a=ui.getCursorX(c);
var e=ui.getCursorY(c);
var d=(this.m_startRect.x+a-this.m_startX);
var b=(this.m_startRect.y+e-this.m_startY);
if(d!=this.m_startRect.x||b!=this.m_startRect.y){if(!this.m_bDragStartCalled){if(this.m_obj&&this.m_obj.m_onDragStart){doFunctions(this.m_obj.m_onDragStart);
this.m_bDragStartCalled=true
}}}if(this.m_obj.moveWindow){this.m_obj.moveWindow(d,b)
}if(this.m_dropCargo!=null){this.query(a,e)
}};
this.query=function(a,d){var c=false;
for(var b=0;
b<this.m_dropCoordList.length;
b++){if(isInRect(a,d,this.m_dropCoordList[b].x,this.m_dropCoordList[b].y,this.m_dropCoordList[b].w,this.m_dropCoordList[b].h)){c=true;
if(this.m_currentDropOver==this.m_dropCoordList[b].dropTarget){break
}if(this.m_currentDropOver!=null&&this.m_currentDropOver.dropHover){this.m_currentDropOver.dropHover(false)
}this.m_currentDropOver=this.m_dropCoordList[b].dropTarget;
if(this.m_currentDropOver.dropHover){this.m_currentDropOver.dropHover(true)
}if(this.m_obj&&this.m_obj.m_element){this.m_obj.m_element.style.cursor="default"
}break
}}if(!c&&this.m_currentDropOver!=null){if(this.m_currentDropOver.dropHover){this.m_currentDropOver.dropHover(false)
}this.m_currentDropOver=null;
if(ui.isIE>5.5&&this.m_obj&&this.m_obj.m_element){this.m_obj.m_element.style.cursor="not-allowed"
}}return this.m_currentDropOver
};
this.activate=this.setupDragListCoords
});
ui.drag.DragManager=function(){this.m_dropTargets=[];
this.getDropTargets=function(){return this.m_dropTargets
};
this.addDropTarget=function(a){this.m_dropTargets.push(a)
};
this.removeDropTarget=function(b){for(var a=this.m_dropTargets.length-1;
a>=0;
a--){if(this.m_dropTargets[a]==b){this.m_dropTargets.splice(a,1)
}}}
};
Class("ui.Drag",lib.Publisher,function(a){this.m_startX;
this.m_startY;
this.initialize=function(c,d,b){a(this,"initialize");
this.m_win=c;
this.m_params=null;
this.m_isActive=false;
this.m_addInScroll=!d;
this.m_thresholdSqrd=b*b||0;
this.m_cancelDragMouseEvent=false;
this.m_startDragFns={};
this.onMove=hitch(this,this.onMove);
this.onDrag=hitch(this,this.onDrag);
this.onDragStop=hitch(this,this.onDragStop)
};
this.isDrag=function(){return this.m_isDrag
};
this.addElement=function(b,c){if(!("dragId" in b)){b.dragId=getUniqueId()
}if(b.dragId in this.m_startDragFns){this.removeElement(b,this.m_startDragFns[b.dragId])
}this.m_startDragFns[b.dragId]=hitch(this,function(d){this.startDrag(d,c)
});
ui.attachEvent(b,"mousedown",this.m_startDragFns[b.dragId]);
if(b.attachEvent){ui.connectEvent(b,"dragstart",ui,"setEventHandled",true)
}};
this.removeElement=function(b){if(!b||!(b.dragId in this.m_startDragFns)){return
}ui.detachEvent(b,"mousedown",this.m_startDragFns[b.dragId]);
delete this.m_startDragFns[b.dragId]
};
this.setCancelDragMouseEvent=function(b){this.m_cancelDragMouseEvent=b
};
this.startDrag=function(b,c){if(b.button==2){return
}if(this.m_cancelDragMouseEvent){ui.setEventHandled(b)
}this._start(true,b,c)
};
this.startClick=function(c,b){this._start(false,b,c)
};
this._start=function(b,c,d){this.m_isDrag=b;
this.m_params=d;
if(c){if(this.m_addInScroll){this.m_startX=ui.getCursorX(c);
this.m_startY=ui.getCursorY(c)
}else{this.m_startX=c.clientX;
this.m_startY=c.clientY
}}else{this.m_startX=this.m_startY=undefined
}this._connectEvents(c)
};
this.endClick=function(b){this.onDragStop(b)
};
this.getParams=function(){return this.m_params
};
this._connectEvents=function(c){if(this.m_isDrag){setTimeout(hitch(this,function(){if(!this.m_isActive){return
}ui.attachEvent(this.m_win.document,"mousedown",this.onDragStop)
}),0);
ui.attachEvent(this.m_win.document,"mouseup",this.onDragStop)
}if(this.m_thresholdSqrd>0&&this.m_isDrag){ui.attachEvent(this.m_win.document,"mousemove",this.onMove)
}else{ui.attachEvent(this.m_win.document,"mousemove",this.onDrag);
this.m_isActive=true;
var b=c?this.getCoords(c):{x:-9999,y:-9999};
this.m_startX=b.x;
this.m_startY=b.y;
this.publish("DragStart",this.m_params,b)
}};
this._disconnectEvents=function(){ui.detachEvent(this.m_win.document,"mousedown",this.onDragStop);
ui.detachEvent(this.m_win.document,"mouseup",this.onDragStop);
ui.detachEvent(this.m_win.document,"mousemove",this.onDrag);
ui.detachEvent(this.m_win.document,"mousemove",this.onMove)
};
this.isActive=function(){return this.m_isActive
};
this.getCoords=function(e){var b,f;
if(this.m_addInScroll){b=ui.getCursorX(e);
f=ui.getCursorY(e)
}else{b=e.clientX;
f=e.clientY
}var d=b-this.m_startX,c=f-this.m_startY;
return{x:b,y:f,dx:d,dy:c,isDrag:this.m_isDrag}
};
this.onMove=function(c){var b=this.getCoords(c);
if(b.dx*b.dx+b.dy*b.dy>this.m_thresholdSqrd){ui.detachEvent(this.m_win.document,"mousemove",this.onMove);
ui.attachEvent(this.m_win.document,"mousemove",this.onDrag);
this.m_isActive=true;
if(typeof this.m_startX=="undefined"){this.m_startX=b.x;
this.m_startY=b.y
}this.publish("DragStart",this.m_params,{x:this.m_startX,y:this.m_startY,dx:0,dy:0});
this.publish("Drag",this.m_params,b)
}};
this.onDrag=function(b){ui.setEventHandled(b);
this.publish("Drag",this.m_params,this.getCoords(b))
};
this.onDragStop=function(b){if(b){ui.setEventHandled(b)
}this._disconnectEvents();
if(this.m_isActive){this.m_isActive=false;
this.publish("DragStop",this.m_params,b?this.getCoords(b):null)
}}
});
Class("ui.DropTargets",function(){this.m_isActive=false;
this.m_win=null;
this.m_list=[];
this.m_dropTargets=[];
this.getDropTargets=function(){return this.m_dropTargets
};
this.addDropTarget=function(a){this.m_dropTargets.push(a);
if(this.m_isActive){this._addToList(a)
}};
this.updateDropTarget=function(a){if(this.m_isActive){this._removeFromList(a);
this._addToList(a)
}};
this.removeDropTarget=function(b){for(var a=this.m_dropTargets.length-1;
a>=0;
a--){if(this.m_dropTargets[a]==b){this.m_dropTargets.splice(a--,1)
}}if(this.m_isActive){this._removeFromList(b)
}};
this.activate=function(c,a){this.m_locator=a||posWithRespectTo;
this.m_win=c;
this.m_list=[];
this.m_isActive=true;
for(var b=0,d;
d=this.m_dropTargets[b];
b++){this._addToList(d,true)
}this._sortList()
};
this.query=function(a,d){for(var b=0,c;
c=this.m_list[b];
++b){if(a>=c.x&&a<=c.x+c.w&&d>=c.y&&d<=c.y+c.h){return c.dropTarget
}}return null
};
this.deactivate=function(){this.m_isActive=false;
this.m_list=[]
};
this._addToList=function(d,c){if(!d||!d.getElement()||d.getWindow()!=this.m_win){return
}var a;
if(d.getDropDescription){a=d.getDropDescription()
}else{var b=d.getDropTargetElement&&d.getDropTargetElement()||d.getElement();
var a=this.m_locator(b);
a.zSort=parseInt(getCSSProp(d.m_element,"z-index"))
}a.zSort=a.zSort||0;
a.dropTarget=d;
this.m_list.push(a);
if(!c){this._sortList()
}};
this._removeFromList=function(c){for(var a=0,b;
b=this.m_list[a];
++a){if(c==b.dropTarget){this.m_list.splice(a--,1)
}}};
this._sortList=function(){this.m_list.sort(function(d,c){return(c.zSort-d.zSort)
})
}
});
Class("ui.label",ui.element,function(a){this.m_preImgO;
this.m_postImg;
this.m_postImgW=0;
this.m_postImgPadding=0;
this.m_textO;
this.m_text="";
this.m_width=0;
this.m_height=0;
this.m_control="uiLabel";
this.m_className="uiLabel";
this.m_bShrinkToSize=false;
this.m_paddingLeft=3;
this.m_paddingRight=2;
this.m_padding=4;
this.m_customizeInProgress=null;
this.m_force=false;
this.m_textTruncate=truncateEnd;
this.initialize=function(){a(this,"initialize");
this.m_preImg={id:""};
this.m_cssProperties={}
};
this.init=function(f){this.m_element=f;
var c=f.id||"";
var l=f.label||f.getAttribute("label")||null;
var g=f.img||f.getAttribute("img")||null;
var h=f.postimg||f.getAttribute("postimg")||null;
var d=f.postimgw||f.getAttribute("postimgw")||null;
var b=parseInt(f.width)||parseInt(f.getAttribute("width"));
var k=parseInt(f.height)||parseInt(f.getAttribute("height"));
var e=f.parentNode;
if(g=="null"){g=null
}this.create(c,e,g,l,h,d,b,k)
};
this.create=function(k,g,c,h,e,b,d,f){this.m_win=gWin(g||this.m_element);
this.m_id=k;
this.m_preImg.id="preimg"+getUniqueId();
if(isNumber(d)&&!isNaN(d)){this.m_width=d
}if(isNumber(f)&&!isNaN(f)){this.m_height=f
}if(h){this.setText(h)
}if(c){this.setPreImg(c)
}if(e){this.setPostImg(e,b)
}if(g&&this.constructor==ui.label){this.createDOMNode(g)
}};
this.createDOMNode=function(b){this.m_win=gWin(b||this.m_win);
if(!this.m_element){this.m_element=this.m_win.document.createElement("div");
if(b){b.appendChild(this.m_element)
}}this.m_element.id=this.getId();
this.m_element.className=this.m_className;
this.m_element.setAttribute("control",this.m_control);
this.m_element.title=this.m_title;
this.m_element.style.width=this.m_width?this.m_width+"px":"auto";
this.m_element.style.height=this.m_height?this.m_height+"px":"auto";
this.m_textO=this.m_win.document.createElement("span");
this.m_element.appendChild(this.m_textO);
this.m_force=true;
this.setText(this.m_text);
this.setPreImg(this.m_preImg);
this.setPostImg(this.m_postImg,this.m_postImgW);
this.m_force=false;
return this.m_element
};
this.getHTMLString=function(){return('<div id="'+this.m_id+'" class="'+this.m_className+'" control="uiLabel" title="'+escapeHTML(this.m_title)+'" style="width: '+(this.m_width?this.m_width+"px":"auto")+";height: "+(this.m_height?this.m_height+"px":"auto")+(this.m_preImg.src?';"><img path="'+this.m_preImg.src+'" align="top">':';">')+'<span style="">'+escapeHTML(this.m_text)+"</span></div>")
};
this.onRender=function(b){this.m_element=b||$(this.m_id)||this.m_element;
this.m_win=gWin(this.m_element)
};
this.setShrinkToSize=function(b){if(b==this.m_bShrinkToSize){return
}this.m_bShrinkToSize=b;
if(this.m_bShrinkToSize&&this.getTextO()){this.getTextO().style.width=""
}if(b){this.setText(this.m_text,true)
}};
this.shrinkToSize=function(g){if(!this.m_bShrinkToSize||!this.getElement()||!this.getTextO().offsetWidth){return
}if(arguments.length==0){return this.setText(this.m_text,true)
}if(this.getTextO().offsetWidth&&!this.m_postImg){var c=this.getTextO().offsetWidth;
if(this.m_preImg.w){c+=this.m_preImg.w+this.m_paddingLeft+this.m_paddingRight
}this.getElement().style.width=c+"px"
}else{var b=this.getPreImgO();
var d=g+this.m_paddingLeft+this.m_paddingRight;
var f=b?b.offsetWidth:this.m_preImg.w;
if(f<=1){f=this.m_preImg.w
}var h=this.m_postImgW+this.m_postImgPadding;
var e=d+f+h+this.m_padding;
this.getElement().style.width=e+"px";
this.getTextO().style.width=d+"px";
if(this.m_postImg&&this.m_postImgW){this.setPostImg(this.m_postImg,this.m_postImgW)
}}};
this.setTrunctation=function(b){this.m_textTruncate=b
};
this.getTextO=function(){return this.m_textO||(this.getElement()&&(this.m_textO=this.getElement().getElementsByTagName("span")[0]))
};
this.show=function(b){b=(typeof(b)=="undefined"?true:!!b);
this.getElement().style.visibility=(b?"visible":"hidden")
};
this.getPreImgWidth=function(){return this.m_preImg.w
};
this.getPostImg=function(){return this.m_postImg
};
this.getPostImgWidth=function(){return this.m_postImgW
};
this.setPostImgPadding=function(b){this.m_postImgPadding=b
};
this.getPreImg=function(){return this.m_preImg.src
};
this.getPreImgO=function(){return this.m_preImgO||(this.getElement()&&(this.m_preImgO=this.getElement().getElementsByTagName("img")[0]))
};
this.setPreImg=function(c,d,e){if(c&&typeof c=="object"){d=c.w;
e=c.h;
c=c.src
}if(c=="null"){c=null
}if(!this.m_force&&c==this.m_preImg.src){return
}this.m_preImg.src=c;
if(d){this.m_preImg.w=d
}if(e){this.m_preImg.h=e
}var b=this.getPreImgO();
if(!this.m_preImg.src){if(b){removeElement(b);
this.m_preImgO=null
}this.m_preImg.w=this.m_preImg.h=0;
return
}if(!this.getElement()||this.m_win!=gWin(this.getElement())){return
}if(!b){this.m_preImgO=b=createImg(this.m_preImg.id,this.getElement(),this.m_preImg.w,this.m_preImg.h,this.m_preImg.src,"",true,null,/png$/i.test(c));
b.align="top";
if(this.getElement().firstChild){this.getElement().insertBefore(b,this.getElement().firstChild)
}else{this.getElement().appendChild(b)
}}else{gImages.requestImage(this.m_preImg.src,b);
if(this.m_preImg.w){b.style.width=this.m_preImg.w+"px"
}if(this.m_preImg.h){b.style.height=this.m_preImg.h+"px"
}}};
this.setPostImg=function(c,d,b){if(!c||!c.length||(c=="null")){return
}if(c&&d){this.m_postImg=c;
this.m_postImgW=d||0
}if(this.m_postImg!=undefined&&this.getElement()){this.m_element.style.backgroundImage=this.m_postImg?"url("+util.query.relativeTo(gImages.getPath()+this.m_postImg,window.location)+")":"";
this.m_element.style.backgroundRepeat="no-repeat";
this.getElement().style.backgroundPosition="center right"
}};
this.getText=function(){return this.m_text
};
this.setText=function(g,e){g=g||"";
if(!this.m_force&&!e&&this.m_text==g){return
}this.m_text=g;
if(!this.getTextO()){return
}var d=this.getTextO().parentNode;
if(!d){return
}var b=4;
var c=this.m_width-(this.m_preImg.w||0)-this.m_postImgW-b;
var f=0;
if(c<=0){setText(this.getTextO(),g);
f=this.getTextO().offsetWidth
}else{f=setTruncatedTextContent(this.getTextO(),g,c,this.m_textTruncate,this.m_cssProperties)
}if(this.m_bShrinkToSize){this.shrinkToSize(f)
}};
this.setPosition=function(e,d,b,c){if(e){this.m_element.style.left=e+"px"
}if(d){this.m_element.style.top=d+"px"
}this.resize(b,c)
};
this.resize=function(b,d){if(!b){return
}var c=this.m_width;
if(b>0){b-=4;
this.m_width=this.m_element.width=b;
if(b>0){this.m_element.style.width=b+"px"
}c=b-this.m_preImg.w-this.m_postImgW
}if(d>0){this.m_height=this.m_element.height=d;
this.m_element.style.height=d+"px"
}this.setText(this.m_text,true);
if(this.m_postImg&&this.m_postImgW){this.setPostImg(this.m_postImg,this.m_postImgW)
}}
});
Class("ui.menu",function(){this.initialize=function(){this.m_win=window;
this.m_selectedItem=null;
this.m_element=null;
this.m_marginLeft=0;
this.m_marginTop=0;
this.m_hSpace=4;
this.m_orientation=null;
this.m_pos=this.m_marginTop;
this.m_parent=null;
this.m_items=new Object();
this.m_numItems=0;
this.m_width=0;
this.m_topBorderHeights=0;
this.m_bMouseEnabled=true;
this.m_bPruned=false
};
this.create=function(e,b,d,c){this.m_win=gWin(c);
var a=this.m_win.document.createElement("div");
if(!a){return
}a.id=e;
a.className="uiMenu";
a.setAttribute("width",d);
a.ptr=this;
this.init(a,b)
};
this.init=function(b,a){if(!b){return
}this.m_win=gWin(b);
this.m_parent=a;
this.m_element=b;
this.m_orientation=this.m_parent.m_orientation;
this.m_width=parseInt(b.getAttribute("width"),10);
if(this.m_width){this.m_element.style.width=this.m_width+"px"
}this.m_element.ptr=this
};
this.resize=function(a,b){this.m_width=a;
this.m_element.style.width=this.m_width-2+"px";
if(this.m_element.parentNode&&this.m_element.parentNode.nodeName=="#document-fragment"){this.m_element.style.top=this.m_element.style.left="-999px";
this.m_win.document.body.appendChild(this.m_element);
var c=true
}for(var d in this.m_items){if(this.m_items[d]){this.m_items[d].resize(a-2,b)
}}if(c){removeElement(this.m_element)
}};
this.removeAllItems=function(){this.m_pos=this.m_marginTop;
this.m_numItems=0;
var a=this.m_element;
if(!a){return
}if(!a.hasChildNodes()){return
}var d=a.firstChild;
while(d){var b=d.nextSibling;
a.removeChild(d);
d=b
}this.m_items=new Object()
};
this.showAllMenuItems=function(){if(!this.m_bPruned){return
}this.m_pos=0;
this.m_numItems=0;
for(var b in this.m_items){if(!b||!this.m_items[b]||!this.m_items[b].getText){continue
}var a=this.m_items[b];
this.m_items[b].m_element.style.display="block";
this.layoutMenuItem(this.m_items[b]);
this.m_numItems++
}this.setMenuHeight();
this.m_bPruned=false
};
this.selectPrev=function(){var c=this.getSelectedItem();
if(!c){for(var d in this.m_items){if(!d||!this.m_items[d]||!this.m_items[d].m_element){continue
}if(this.m_items[d].m_element.style.display!="none"){var b=this.m_items[d].m_element.nextSibling;
if(!b||!b.ptr||!b.ptr.select||b.style.display=="none"){this.m_items[d].m_element.ptr.select();
return
}}}}var a=c.m_element.previousSibling;
if(!a||!a.ptr||!a.ptr.select||a.style.display=="none"){this.clearSelected();
return
}if(a.style.display!="none"){a.ptr.select()
}};
this.selectNext=function(){var b=this.getSelectedItem();
if(!b||!b.m_element||!b.m_element){for(var c in this.m_items){if(!c||!this.m_items[c]||!this.m_items[c].m_element){continue
}if(this.m_items[c].m_element.style.display!="none"){if(this.m_items[c].m_element.ptr&&this.m_items[c].m_element.ptr.select){this.m_items[c].m_element.ptr.select();
return
}}}}var a=b.m_element.nextSibling;
if(!a||!a.ptr||!a.ptr.select||a.style.display=="none"){this.clearSelected();
return
}if(a.style.display!="none"){a.ptr.select()
}};
this.pruneMenuItems=function(a){if(!a||!a.length){this.showAllMenuItems();
return
}this.m_bPruned=true;
this.m_pos=0;
this.m_numItems=0;
var d=normalizeString(a);
for(var e in this.m_items){if(!e||!this.m_items[e]||!this.m_items[e].getText){continue
}var c=this.m_items[e];
var b=normalizeString(this.m_items[e].getText());
if(b.indexOf(d)==0){this.m_items[e].m_element.style.display="block";
this.layoutMenuItem(this.m_items[e]);
this.m_numItems++
}else{this.m_items[e].m_element.style.display="none"
}}this.setMenuHeight()
};
this.calculateMenuHeight=function(){this.m_numItems=0;
this.m_pos=0;
for(var a in this.m_items){if(!a||!this.m_items[a]||!this.m_items[a].getText){continue
}if(this.m_items[a].m_element.style.display!="none"){this.layoutMenuItem(this.m_items[a]);
this.m_numItems++
}}this.setMenuHeight()
};
this.setMenuHeight=function(){var a=0;
if(this.m_numItems==0){this.m_element.style.visibility="hidden";
return
}else{this.m_element.style.visibility="visible"
}if(this.m_numItems>this.m_parent.m_menuMax){a=(this.m_parent.m_menuMax*this.m_parent.m_rowHeight);
this.m_element.style.overflowY="auto"
}else{a=this.m_pos;
this.m_element.style.overflowY="hidden"
}a+=this.m_topBorderHeights;
this.m_element.style.height=a+"px"
};
this.removeMenuItem=function(a){if(typeof a!="string"&&a.m_element){a=a.m_element.id
}if(!this.m_items[a]){return
}removeElement(this.m_items[a].m_element);
delete this.m_items[a];
this.m_numItems--;
this.layoutMenuItems()
};
this.getMenuItem=function(a){return this.m_items[a]
};
this.addMenuItem=function(h,b,g,e,a,d){if(!this.m_width){return
}this.m_element.style.top=this.m_element.style.left="-999px";
this.m_win.document.body.appendChild(this.m_element);
var f=new ui.menuItem();
var c=this.m_width;
f.create(h,this.m_element,b,g,c,a,e);
this.appendMenuItem(f,d);
removeElement(this.m_element);
return f
};
this.appendMenuItem=function(a,b){a.setParent(this);
if(b){this.m_element.insertBefore(a.m_element,b.m_element);
this.layoutMenuItems()
}else{this.layoutMenuItem(a)
}this.m_items[a.getId()]=a;
this.m_numItems++;
if(ui.isGecko){this.m_element.style.overflow="-moz-scrollbars-"+(this.m_numItems<=this.m_parent.m_menuMax?"none":"vertical")
}};
this.layoutMenuItem=function(a){this.m_pos+=a.m_height||this.m_parent.m_rowHeight
};
this.layoutMenuItems=function(){this.m_pos=0;
var b=this.m_element.childNodes;
for(var a=0,c;
(c=b[a]);
a++){this.m_pos+=Number(c.ptr.m_height)||0
}this.setMenuHeight()
};
this.connectMenuItemEvents=function(){for(var a in this.m_items){if(this.m_items[a]&&this.m_items[a].connectEvents){this.m_items[a].connectEvents()
}}};
this.disconnectMenuItemEvents=function(){for(var a in this.m_items){if(this.m_items[a]&&this.m_items[a].disconnectEvents){this.m_items[a].disconnectEvents()
}}};
this.onMouseMove=function(b,a){if(!this.m_bMouseEnabled){this.clearSelected();
this.enableMouse(true)
}};
this.isMouseEnabled=function(){return this.m_bMouseEnabled
};
this.enableMouse=function(a){this.m_bMouseEnabled=a
};
this.onMouseOver=function(){this.m_hover=true
};
this.onMouseOut=function(){this.m_hover=false
};
this.onMouseDown=function(){this.m_element.style.visibility="hidden";
if(!this.m_parent){return
}this.m_parent.m_bMenuShow=false
};
this.onParentMouseUp=function(b,c,a){if(!this.m_parent){return
}this.m_parent.onParentMouseUp(b,c,a)
};
this.onParentMouseDown=function(b,a){if(!this.m_parent){return true
}return this.m_parent.onParentMouseDown(b,a)
};
this.clearSelected=function(){var a=this.getSelectedItem();
if(a){a.unselect()
}};
this.getSelectedItem=function(){return this.m_selectedItem
};
this.setSelectedItem=function(a){this.m_selectedItem=a
}
});
Class("ui.menuheader",ui.button,function(a){this.initialize=function(e,m,d,g,l,b,k,n,f,h,c){a(this,"initialize",[e,m]);
this.m_control="ui.MenuHeader";
this.m_className="uiMenuHeader";
this.m_borderLeftColor;
this.m_borderRightColor;
this.m_borderTopColor;
this.m_borderBottomColor;
this.m_selectedTitle=m;
this.m_selectedValue=n;
this.m_selectedImg;
this.m_bDelayMenu=false;
this.m_bMenuCreated=false;
this.m_menuItems=new Array();
this.m_dropDownImgSrc="arrow-drop.gif";
this.m_menuMax=10;
this.m_bStatic=false;
this.m_bCustomize=false;
this.m_verticalOffset=0;
this.m_horizontalOffset=0;
this.m_customizeElement=null;
this.m_numItems=0;
this.m_menuBody=null;
this.m_menuBodyId="";
this.m_menuParent=null;
this.m_menuOrientation=null;
this.m_onSelects=new Array();
this.m_onShow=new Array();
this.m_onClose=new Array();
this.m_bOpen=false;
this.m_width=d;
this.m_menuWidth=g||100;
this.m_menuAlign=l||"left";
this.m_bShrinkToSize=h||false;
this.m_maxW=c||100;
this.m_popMenuUp=k;
if(k){this.m_dropDownImgSrc="arrow-lift.gif"
}this.m_orientation=k?"up":"down";
this.m_rowHeight=b||16;
this.m_bStatic=f;
this.m_arrowGap=10;
this.m_edit;
this.m_isCustom=false;
this.m_previous;
this.m_lastCustom;
this.m_preventReselect=true
};
this.createContent=function(){a(this,"createContent");
if(this.constructor==ui.menuheader){this.createDOMNode()
}};
this.createDOMNode=function(){a(this,"createDOMNode");
if(this.m_dropDownImgSrc){this.m_label.m_postImg="blank.gif";
this.m_label.m_postImgW=6
}if(this.m_bShrinkToSize){this.m_label.setShrinkToSize(true)
}if(!this.m_bDelayMenu){this.createMenuBody()
}this.connectEvents(this.m_element);
if(this.m_width){this.resize(this.m_width,null,this.m_menuWidth)
}};
this.setShrinkToSize=function(b){this.m_bShrinkToSize=b;
if(this.m_label){this.m_label.setShrinkToSize(b)
}};
this.shrinkToSize=function(){var d=this.m_rightDiv.offsetWidth||parseInt(getCSSProp(this.m_rightDiv,"width"))||0;
var c=this.m_leftDiv.offsetWidth||parseInt(getCSSProp(this.m_leftDiv,"width"))||0;
if(!this.m_label.m_bShrinkToSize){this.m_label.setShrinkToSize(true)
}this.m_label.m_width=this.m_maxW-(d+c);
this.m_label.setText(this.m_selectedTitle,true);
var b=this.m_centerDiv.offsetWidth||parseInt(getCSSProp(this.m_centerDiv,"width"))||0;
var e=d+c+b;
if(e>this.m_maxW){this.resize(this.m_maxW,null,this.m_maxW);
this.m_label.setPos(null,null,this.m_maxW-d-c)
}else{this.resize(e,null,e)
}};
this.resize=function(d,f,e){if(!d){return
}if(ui.isOpera){d+=6
}var c=this.m_rightDiv.offsetWidth||parseInt(getCSSProp(this.m_rightDiv,"width"))||0;
var b=this.m_leftDiv.offsetWidth||parseInt(getCSSProp(this.m_leftDiv,"width"))||0;
this.m_label.resize(d-b-c,f);
this.m_menuWidth=e?e:d;
if(e&&this.m_bMenuCreated){if(e==d){var g=this.m_element;
var k=this.m_menuBody;
setTimeout(function(){try{k.resize(g.offsetWidth||e)
}catch(h){}},50)
}else{this.m_menuBody.resize(this.m_menuWidth)
}}if(ui.isIE){this.m_eventsDiv.style.width=this.m_element.offsetWidth;
this.m_eventsDiv.style.height=this.m_element.offsetHeight
}};
this.setSelected=function(g,e,c,b,d){var f=d||(this.m_preventReselect&&g==this.getImage()&&e==this.getTitle()&&c==this.getItemValue());
this.m_previous={text:this.getTitle(),img:this.getImage(),val:this.getItemValue(),isCustom:this.m_isCustom};
if(this.m_isCustom){this.m_lastCustom=this.m_previous
}this.m_isCustom=Boolean(b);
this.setImage(g);
this.setTitle(e,c,f)
};
this.connectEvents=function(b){ui.connectEvent(b,"mouseover",this,"onMouseOver",true,true);
ui.connectEvent(b,"mouseout",this,"onMouseOut",true,true);
ui.connectEvent(b,"mousedown",this,"onMouseDown",true,true);
ui.connectEvent(b,"mouseup",this,"onMouseUp",true,true)
};
this.disconnectEvents=function(){ui.disconnectAllEvents(this.m_element)
};
this.createMenuBody=function(){this.m_menuBody=new ui.menu();
this.m_menuBodyId=String(getUniqueId());
this.m_menuBody.create(this.m_menuBodyId,this,this.m_menuWidth,this.m_element);
this.m_menuBody.m_element.style.zIndex=gWindowMgr.getTopZIndex();
this.m_bMenuCreated=true;
if(this.m_menuBodyClassName){addClassName(this.m_menuBody.m_element,this.m_menuBodyClassName)
}for(var c=0;
c<this.m_menuItems.length;
c++){var d=this.m_menuItems[c];
this.m_numItems--;
var b=this.addMenuItem(d.text,d.img,d.val,undefined,undefined,d.id,!d.display)
}this.m_menuBody.setMenuHeight();
this.m_menuItems=new Array();
return this.m_menuBody
};
this.addShowFunc=function(b){this.m_onShow.push(b)
};
this.addCloseFunc=function(b){this.m_onClose.push(b)
};
this.addSelectFunc=function(b){this.m_onSelects.push(b)
};
this.removeAllItems=function(){var b=this.hasVisibleItems();
if(this.m_menuBody){this.m_menuBody.removeAllItems();
this.m_menuBody.setMenuHeight()
}this.m_numItems=0;
if(this.hasVisibleItems()!=b){this.updateDropDownImg()
}};
this.hasVisibleItems=function(){var b=false;
if(!this.m_menuBody){for(var c=0;
c<this.m_menuItems.length;
c++){b=b||this.m_menuItems[c].display
}}else{for(var e in this.m_menuBody.m_items){var d=this.m_menuBody.m_items[e];
b=b||d.getDisplay()!="none"
}}return b
};
this.setMenuItemDisplay=function(d,c){var b=this.hasVisibleItems();
if(!this.m_menuBody&&typeof(d)=="string"){d=this.getMenuItem(d)
}if(!d){return
}if(d.setDisplay){d.setDisplay(c)
}else{d.display=c
}if(this.hasVisibleItems()!=b){this.updateDropDownImg()
}};
this.removeMenuItem=function(c){if(!this.m_menuBody&&typeof(c)=="string"){var d=c;
for(var b=0;
b<this.m_menuItems.length;
b++){if(this.m_menuItems[b]&&this.m_menuItems[b].id==d){this.m_menuItems.splice(b,1);
return
}}this.m_numItems--;
return
}if(typeof(c)=="string"){c=this.m_menuItems[c]
}this.m_menuBody.removeMenuItem(c);
this.m_numItems--;
this.m_menuBody.setMenuHeight()
};
this.replaceMenuItem=function(l,f,d,g,h){if(!l){return
}var k=this.hasVisibleItems();
if(!this.m_menuBody&&typeof(l)=="string"){var b=l;
for(var e=0;
e<this.m_menuItems.length;
e++){if(this.m_menuItems[e]&&this.m_menuItems[e].id==b){var c=this.createDelayMenuItem(f,d,g,h);
this.m_menuItems.splice(e,1,c);
l=c.id;
break
}}}else{if(typeof(l)=="string"){l=this.m_menuBody.getMenuItem(l)
}l.setPreImg(d);
l.setText(f);
l.setValue(g);
l.setDisplay(!h)
}if(this.hasVisibleItems()!=k){this.updateDropDownImg()
}return l
};
this.getMenuItem=function(c){if(!this.m_menuBody){for(var b=0;
b<this.m_menuItems.length;
b++){if(this.m_menuItems[b]&&this.m_menuItems[b].id==c){return this.m_menuItems[b]
}}return
}return this.m_menuBody.getMenuItem(c)
};
this.createDelayMenuItem=function(b,d,e,c){return{id:"menuItem"+getUniqueId()+"-"+b,text:b,img:d,val:e,display:!c}
};
this.updateDropDownImg=function(){if(this.hasVisibleItems()){this.m_label.setPostImgPadding(this.m_arrowGap);
this.m_label.setPostImg(this.m_dropDownImgSrc,6,4)
}else{this.m_label.setPostImgPadding(0);
this.m_label.setPostImg("blank.gif",1,1)
}if(this.m_bShrinkToSize){this.shrinkToSize()
}else{this.resize(this.m_width,null,this.m_menuWidth)
}};
this.addMenuItem=function(l,h,d,g,e,b,f){var k=this.hasVisibleItems();
if(!this.m_menuBody){var c=this.createDelayMenuItem(l,h,d,f);
this.m_menuItems.push(c);
var m=c.id
}else{if(this.m_numItems==0&&!this.m_selectedTitle&&!this.m_bStatic){this.setSelected(h,l,d)
}var m=this.m_menuBody.addMenuItem(b||"menuItem"+getUniqueId()+"-"+l,h,l,this.m_rowHeight,d,e);
m.setDisplay(!f)
}this.m_numItems++;
if(this.hasVisibleItems()!=k){this.updateDropDownImg()
}if(g){this.setSelected(h,l,d)
}return m
};
this.getItemValue=function(){return this.m_selectedValue
};
this.setItemValue=function(b){this.m_selectedValue=b
};
this.setImage=function(b,c,d){this.m_selectedImg=b;
this.m_label.setPreImg(b,c,d)
};
this.getImage=function(){return this.m_selectedImg
};
this.setTitle=function(d,b,c){if(!this.m_label){return
}if(b){this.setItemValue(b)
}this.m_selectedTitle=d;
if(this.m_bShrinkToSize){this.shrinkToSize()
}else{this.m_label.setText(d)
}if(!c){doFunctions(this.m_onSelects,d,b,this)
}};
this.getTitle=function(){return this.m_selectedTitle
};
this.onMouseOver=function(){if(this.m_isDisabled){return
}if(ui.isIE){this.m_eventsDiv.style.display="inline";
this.m_eventsDiv.style.width=this.m_element.offsetWidth;
this.m_eventsDiv.style.height=this.m_element.offsetHeight;
this.m_eventsDiv.style.display="block"
}if(this.m_hover){return
}this.m_hover=true;
if(this.m_state!="down"){this.setState("hot")
}};
this.onMouseOut=function(b){if(this.m_isDisabled||!this.m_hover){return
}this.m_hover=false;
if(this.m_state!="down"){this.setState("normal")
}};
this.onMouseUp=function(c){if(this.m_isDisabled||ui.getMouseButton(c)!=0){return
}if(!this.m_bMenuCreated){this.createMenuBody()
}var l=$(this.m_menuBodyId);
if(!l&&this.m_menuBody&&this.m_menuBody.m_element){l=this.m_menuBody.m_element
}if(!l){return
}var f=this.hasClassName("uiMenuHeader-chromeless");
var m=getElementPosition(this.m_element);
var b=this.m_menuBody.m_numItems>this.m_menuMax?this.m_menuMax:this.m_menuBody.m_numItems;
var g=b*this.m_rowHeight;
var d=ui.getClientRect(this.m_win);
var e=d.h-(m.top+this.m_element.offsetHeight+g);
var k=m.top-g;
if(this.m_orientation=="down"&&(e>0||e>k)){l.style.top=(m.top+this.m_element.offsetHeight+this.m_verticalOffset)+"px";
l.style.bottom=""
}else{var n=d.h-this.m_verticalOffset-getElementPosition(this.m_element).top;
l.style.top="";
l.style.bottom=n+"px"
}if(this.m_menuAlign=="left"){l.style.left=m.left+this.m_horizontalOffset+"px"
}else{var h=m.left-(this.m_menuWidth-this.m_rightDiv.offsetLeft+this.m_rightDiv.offsetWidth);
l.style.left=h+"px"
}if(!this.m_bOpen&&this.m_menuBody.m_numItems>0){this.showMenu(l);
this.m_bOpen=true;
ui.connectGlobalEvent(gDoc(this.m_win),"mousedown",hitch(this,"onBodyMouseDown"));
ui.connectGlobalEvent(gDoc(this.m_win),"mouseup",hitch(this,"onBodyMouseUp"));
this.m_menuBody.connectMenuItemEvents()
}else{if(this.m_bCustomize){this.handleCustomize()
}this.closeMenu()
}ui.setEventHandled(c)
};
this.onMouseDown=function(c,b){if(this.m_isDisabled){return
}if(this.m_bOpen){ui.setEventHandled(c);
return false
}else{return true
}};
this.setCustomize=function(b){this.m_bCustomize=b
};
this.showMenu=function(c){if(!this.m_bMenuCreated){this.createMenuBody()
}c.style.zIndex=gWindowMgr.getTopZIndex();
c.style.visibility="visible";
this.m_bOpen=true;
this.setState("down");
this.m_menuBody.setMenuHeight();
if(this.m_menuParent){this.m_menuBody.m_element=this.m_menuParent.appendChild(c)
}else{this.m_win.document.body.appendChild(c)
}var e=ui.getClientRect(this.m_win);
var d=0;
if(c.offsetTop<0){d=-c.offsetTop
}if(c.offsetTop+c.offsetHeight>e.h){d=c.offsetTop+c.offsetHeight-e.h
}if(d){var b=this.m_menuMax;
this.m_menuMax-=Math.round(d/this.m_rowHeight);
this.m_menuBody.setMenuHeight();
this.m_menuMax=b
}if(this.m_bCustomize){this.doCustomize()
}doFunctions(this.m_onShow,this)
};
this.closeMenu=function(){if(!this.m_bOpen){return
}this.setState("normal");
var b=$(this.m_menuBodyId);
if(!b){return
}if(!b.parentNode){return
}b.style.visibility="hidden";
this.m_menuBody.showAllMenuItems();
this.m_menuBody.setMenuHeight();
this.m_menuParent=b.parentNode;
try{this.m_menuBody.m_element=this.m_menuParent.removeChild(b)
}catch(c){}this.m_bOpen=false;
ui.disconnectEvent(this.m_win.document.body,"mousedown");
ui.disconnectEvent(this.m_win.document.body,"mouseup");
ui.disconnectGlobalEvent(gDoc(this.m_win),"mousedown");
ui.disconnectGlobalEvent(gDoc(this.m_win),"mouseup");
this.closeCustomize();
doFunctions(this.m_onClose)
};
this.onBodyMouseUp=function(b){if(isCursorInElement(this.m_menuBody.m_element,b)){return true
}ui.setEventHandled(b);
if(!this.m_bOpen){return
}this.closeMenu()
};
this.onBodyMouseDown=function(b){if(isCursorInElement(this.m_menuBody.m_element,b)){return true
}if(this.m_customizeElement&&isCursorInElement(this.m_customizeElement,b)){return true
}if(!isCursorInElement(this.m_element,b)){this.closeMenu();
return true
}ui.setEventHandled(b);
return false
};
this.onParentMouseUp=function(c,d,b){if(!this.m_bStatic){this.setSelected(c,d,b)
}else{if(b){this.setItemValue(b);
doFunctions(this.m_onSelects,d,b,this)
}}this.closeMenu()
};
this.onParentMouseDown=function(c,b){this.onBodyMouseDown(c);
ui.setEventHandled(c);
return false
};
this.isArrowKey=function(b){if(b>=37&&b<=40){return true
}return false
};
this.getCaretPos=function(d){var f=0;
var e;
if(!ui.isIE&&d.selectionEnd){return d.selectionEnd
}if(!ui.isIE){return
}var b=this.m_win.document.selection.createRange();
var c=b.getBookmark();
return c.charCodeAt(2)-2
};
this.handleArrow=function(b){if(b==37||b==39){return
}if(b==38){this.m_menuBody.selectPrev()
}if(b==40){this.m_menuBody.selectNext()
}this.m_menuBody.enableMouse(false)
};
this.onCustomizeKeyDown=function(d){if(!d){return
}var c=(d.which)?d.which:d.keyCode;
if(isArrowKey(c)){this.handleArrow(c);
return true
}var b=this.m_customizeElement.value;
var e=this.getCaretPos(this.m_customizeElement);
if(c==8){if(b.length&&e>0){this.m_menuBody.pruneMenuItems(deleteChar(b,e))
}return true
}if(c==46){if(b.length&&e<b.length){this.m_menuBody.pruneMenuItems(deleteChar(b,e+1))
}return true
}return true
};
this.onCustomizeKeyPress=function(d){if(!d){return true
}var c=(d.which)?d.which:d.keyCode;
if(!this.m_customizeElement){return
}if(c==27){this.closeMenu();
ui.setEventHandled(d);
return false
}var b=this.m_customizeElement.value;
if(c==13){if(this.m_menuBody.m_selectedItem){this.m_menuBody.m_selectedItem.onMouseUp()
}else{this.handleCustomize()
}ui.setEventHandled(d);
return false
}if(isArrowKey(c)){this.handleArrow(c);
return true
}if((c==33)||(c==34)||(c==255)){ui.setEventHandled(d);
return false
}if(this.m_menuBody.m_selectedItem){this.m_menuBody.m_selectedItem.unselect()
}switch(c){case 35:case 36:case 16:case 17:case 18:case 20:case 9:case 255:return true
}var e=this.getCaretPos(this.m_customizeElement);
if(c==8){if(b.length&&e>0){this.m_menuBody.pruneMenuItems(deleteChar(b,e))
}return true
}if(c==46){if(b.length&&e<b.length){this.m_menuBody.pruneMenuItems(deleteChar(b,e+1))
}return true
}if(String.fromCharCode(c).length){this.m_menuBody.pruneMenuItems(insertChar(b,String.fromCharCode(c),e))
}return true
};
this.handleCustomize=function(){if(!this.m_customizeElement){return
}var b=this.m_customizeElement.value;
if(b.length){this.setSelected(null,b,b)
}this.closeMenu()
};
this.closeCustomize=function(){if(!this.m_customizeElement){return
}this.m_menuBody.clearSelected();
ui.disconnectEvent(this.m_customizeElement,"keypress");
ui.disconnectEvent(this.m_win.document.body,"mouseup");
ui.disconnectGlobalEvent(gDoc(this.m_win),"mouseup");
if(this.m_customizeElement){removeElement(this.m_customizeElement)
}this.m_customizeElement=null;
this.m_element.style.display=""
};
this.doCustomize=function(){var d=this.m_element;
var b=this.m_customizeElement=this.m_win.document.createElement("input");
b.className=d.className;
var e=d.style,c=b.style;
c.backgroundColor="#FFFFFF";
if((e.position=="absolute")||e.left||e.top||e.right||e.bottom){if(e.position){c.position=e.position
}if(e.top){c.top=e.top
}if(e.left){c.left=e.left
}if(e.bottom){c.bottom=e.bottom
}if(e.right){c.right=e.right
}}c.width=d.offsetWidth-4+"px";
c.height=d.offsetHeight-6+"px";
b.setAttribute("autocomplete","off");
if(d.parentNode){d.parentNode.appendChild(b);
c.zIndex=gWindowMgr.getTopZIndex()
}b.focus();
b.select();
if(ui.isIE){ui.connectEvent(b,"keydown",this,"onCustomizeKeyDown",true,true)
}ui.connectEvent(b,"keypress",this,"onCustomizeKeyPress",true,true);
ui.connectEvent(b,"mouseup",this,"closeMenu",true,true);
e.display="none"
};
this.setDelayMenu=function(b){this.m_bDelayMenu=b
};
this.getCustomizeElement=function(){return this.m_customizeElement
};
this.getPreviousValue=function(){return this.m_previous.val
};
this.revertToPrevious=function(b){this.setSelected(this.m_previous.img,this.m_previous.text,this.m_previous.val,this.m_previous.isCustom,b)
};
this.customizeMessage=function(b){if(this.m_edit){return
}this.m_edit=this.m_win.document.createElement("input");
if(b){this.m_edit.value=b
}else{if(this.m_lastCustom){this.m_edit.value=this.m_lastCustom.text
}}this.m_edit.style.position="absolute";
this.m_edit.setAttribute("autocomplete","off");
this.m_edit.style.left=this.m_element.offsetLeft+"px";
this.m_edit.style.top=this.m_element.offsetTop+"px";
this.m_edit.style.width=this.m_element.offsetWidth+"px";
this.m_edit.style.height=this.m_element.offsetHeight+"px";
this.m_edit.style.zIndex=gWindowMgr.getTopZIndex();
this.m_edit=this.m_element.parentNode.appendChild(this.m_edit);
this.m_edit.focus();
this.m_edit.select();
ui.connectEvent(this.m_edit,"keypress",this,"onKeyPress",true,true);
ui.connectEvent(this.m_edit,"blur",this,"handleCustomizeMessage");
ui.connectGlobalEvent(gDoc(this.m_win),"mouseup",hitch(this,"handleCustomizeMessage"))
};
this.onKeyPress=function(c){if(!c||!this.m_edit){return
}var b=c.keyCode;
if(b!=13&&b!=27){return true
}if(b==13){this.handleCustomizeMessage()
}if(b==27){this.m_edit.value="";
this.handleCustomizeMessage()
}ui.setEventHandled(c);
return false
};
this.handleCustomizeMessage=function(){if(!this.m_edit){return
}var b=this.m_edit.value;
if(b.length){this.setSelected(this.getImage(),b,this.getItemValue(),true)
}else{this.revertToPrevious(true)
}ui.disconnectEvent(this.m_edit,"keypress");
ui.disconnectEvent(this.m_win.document.body,"mouseup");
ui.disconnectGlobalEvent(gDoc(this.m_win),"mouseup");
removeElement(this.m_edit);
this.m_edit=null
};
this.setMenuMax=function(b){this.m_menuMax=b;
if(this.m_menuBody){this.m_menuBody.setMenuHeight()
}};
this.isCustom=function(){return this.m_isCustom
};
this.getWidth=function(){return(this.m_element?this.m_element.offsetWidth:this.m_width)
};
this.setMenuBodyClassName=function(b){this.m_menuBodyClassName=b
};
this.setVerticalOffset=function(b){this.m_verticalOffset=b
};
this.setHorizontalOffset=function(b){this.m_horizontalOffset=b
};
this.setPreventReselect=function(b){this.m_preventReselect=b
}
});
Class("ui.menuItem",ui.label,function(a){this.initialize=function(){a(this,"initialize");
this.m_control="uiMenuItem";
this.m_itemValue=null;
this.m_parent;
this.m_height=16
};
this.create=function(h,f,c,g,d,b,e){a(this,"create",[h,f,c,g,"","",d,e]);
this.m_itemValue=b;
if(f&&this.constructor==ui.menuItem){this.createDOMNode(f)
}};
this.createDOMNode=function(b){a(this,"createDOMNode",arguments);
this.addClassName("uiMenuItem");
this.m_textO.style.position="relative";
this.m_textO.style.top="2px";
this.m_element.ptr=this
};
this.addTopBorder=function(){if(!hasClassName(this.m_element,"borderTop")){this.addClassName("borderTop");
this.m_height-=1;
this.m_element.style.height=this.m_height+"px"
}};
this.setParent=function(b){this.m_parent=b
};
this.getHeight=function(){return this.m_element.offsetHeight
};
this.setValue=function(b){this.m_itemValue=b
};
this.connectEvents=function(){ui.connectEvent(this.m_element,"mousemove",this.m_parent,"onMouseMove",true,true);
ui.connectEvent(this.m_element,"mouseover",this,"onMouseOver",true,true);
ui.connectEvent(this.m_element,"mouseout",this,"onMouseOut",true,true);
ui.connectEvent(this.m_element,"mousedown",this,"onMouseDown",true,true);
ui.connectEvent(this.m_element,"mouseup",this,"onMouseUp",true,true)
};
this.disconnectEvents=function(){ui.disconnectAllEvents(this.m_element)
};
this.setDisplay=function(b){a(this,"setDisplay",arguments);
this.m_parent.calculateMenuHeight()
};
this.select=function(){this.m_parent.clearSelected();
if(this.m_highlightColor){this.m_element.style.backgroundColor=this.m_highlightColor
}addClassName(this.m_element,"uiMenuItemHot");
scrollToItem(this.m_parent.m_element,this.m_element);
this.m_parent.setSelectedItem(this)
};
this.unselect=function(){removeClassName(this.m_element,"uiMenuItemHot");
this.m_element.style.backgroundColor="";
this.m_parent.setSelectedItem(null)
};
this.onMouseOver=function(){if(!this.m_parent.isMouseEnabled()){return false
}this.m_hover=true;
this.select();
return true
};
this.onMouseOut=function(){if(!this.m_parent.isMouseEnabled()){return false
}this.m_hover=false;
this.unselect();
return true
};
this.onMouseDown=function(c,b){if(this.m_parent){this.m_parent.onParentMouseDown(c,b)
}};
this.onMouseUp=function(c,b){if(!this.m_parent){return true
}this.m_element.style.backgroundColor="";
this.m_parent.onParentMouseUp(this.m_preImg.src,this.m_text,this.m_itemValue);
if(c){ui.setEventHandled(c)
}return false
}
});
ui.contextmenu=function(){this.init=function(c,a,b){this.m_win=gWin(b);
this.m_menuId=c;
this.m_menuWidth=a;
this.createMenuBody()
};
this.setContextObject=function(a){this.m_contextObject=a
};
this.getContextObject=function(a){return this.m_contextObject
};
this.createMenuBody=function(){this.m_menuBody=new ui.menu();
this.m_menuBody.create(this.m_menuId+"body",this,this.m_menuWidth,this.m_win.document);
this.m_menuBody.m_element.style.zIndex=gWindowMgr.getTopZIndex();
this.m_menuBody.setMenuHeight();
return this.m_menuBody
};
this.addSelectFunc=function(a){this.m_onSelects.push(a)
};
this.addCloseFunc=function(a){this.m_onClose.push(a)
};
this.removeAllItems=function(a){this.m_menuBody.removeAllItems();
this.m_numItems=0;
this.m_menuBody.setMenuHeight();
if(a){this.m_onSelects=new Array()
}};
this.addMenuItem=function(e,c,b,d){if(!this.m_menuBody){return
}var a=this.m_menuBody.addMenuItem(e+".menuitem",c,e,this.m_rowHeight,b);
this.m_numItems++;
this.m_menuBody.setMenuHeight();
return a
};
this.showMenu=function(d,b){this.closeMenu();
if(b){this.m_contextObject=b
}this.m_menuBody.m_element.style.visibility="hidden";
if(this.m_menuParent){this.m_menuBody.m_element=this.m_menuParent.appendChild(this.m_menuBody.m_element)
}else{this.m_menuBody.m_element=this.m_win.document.body.appendChild(this.m_menuBody.m_element)
}var a=isDefined(d.left)?d.left:ui.getCursorX(d);
var c=isDefined(d.top)?d.top:ui.getCursorY(d);
this.positionMenu(a,c);
this.m_menuBody.m_element.style.zIndex=gWindowMgr.getTopZIndex();
this.m_menuBody.m_element.style.visibility="visible";
this.m_menuBody.m_element.style.overflow="hidden";
this.m_bOpen=true;
ui.connectGlobalEvent(gDoc(this.m_win),"mousedown",hitch(this,"onBodyMouseDown"));
ui.connectGlobalEvent(gDoc(this.m_win),"mouseup",hitch(this,"onBodyMouseUp"));
this.m_menuBody.connectMenuItemEvents()
};
this.positionMenu=function(b,a){r=ui.getClientRect(this.m_menuBody.m_element);
var c=this.m_menuBody.m_element.offsetWidth;
if((b+c)>r.w){b-=c-1
}var d=this.m_menuBody.m_element.offsetHeight;
if((a+d)>r.h){a-=d-1
}if(b<0){b=0
}if(a<0){a=0
}this.m_menuBody.m_element.style.left=b+"px";
this.m_menuBody.m_element.style.top=a+"px"
};
this.closeMenu=function(){if(!this.m_bOpen){return
}var a=$(this.m_menuId+"body");
if(!a){return
}if(!a.parentNode){return
}a.style.visibility="hidden";
this.m_menuParent=a.parentNode;
try{this.m_menuBody.m_element=this.m_menuParent.removeChild(a)
}catch(b){}this.m_bOpen=false;
ui.disconnectGlobalEvent(gDoc(this.m_win),"mousedown");
ui.disconnectGlobalEvent(gDoc(this.m_win),"mouseup");
doFunctions(this.m_onClose)
};
this.onBodyMouseUp=function(a){if(isCursorInElement(this.m_menuBody.m_element,a)){return true
}this.closeMenu()
};
this.onBodyMouseDown=function(a){if(isCursorInElement(this.m_menuBody.m_element,a)){return true
}this.closeMenu();
return false
};
this.onParentMouseUp=function(b,c,a){this.closeMenu();
if(a){doFunctions(this.m_onSelects,c,a)
}};
this.onParentMouseDown=function(b,a){this.onBodyMouseDown(b);
ui.setEventHandled(b);
return false
};
this.isOpen=function(){return this.m_bOpen
};
this.m_win=window;
this.m_contextObject=null;
this.m_menuMax=10;
this.m_rowHeight=16;
this.m_numItems=0;
this.m_menuBody=null;
this.m_menuParent=null;
this.m_onSelects=new Array();
this.m_onClose=new Array();
this.m_bOpen=false;
this.m_menuWidth=0
};
ui.image=function(){this.setFilename=function(a){this.m_filename=a
};
this.copyToObjects=function(){if(!this.m_requests){return
}for(var b in this.m_requests){if(this.m_requests[b]){try{this.copyToObject(this.m_requests[b])
}catch(a){}}}this.m_requests=null
};
this.copyToObject=function(a){if(!a){return
}if(this.m_bIECachingBug){return
}if(String(a.png)=="true"&&ui.isIE&&typeof a.style.filter=="string"&&/\.png$/i.test(this.m_image.src)){a.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.m_image.src+"', sizingMethod='scale')";
a.src=gImages.getPath()+"blank.gif";
a.height=this.m_image.height;
a.width=this.m_image.width
}else{a.src=this.m_image.src;
if(ui.isIE){a.style.filter=""
}}if(typeof ui!="undefined"&&(ui.isIE&&a.readyState!="complete")&&this.isWindowObject(a)){this.m_bIECachingBug=true
}};
this.isWindowObject=function(a){if(a.id&&a.id.indexOf("wimg")&&a.src&&(a.src.indexOf("dis")!=-1)){return true
}return false
};
this.onload=function(){this.m_bLoaded=true;
this.copyToObjects();
if(this.m_finishCallback){this.m_finishCallback(this.m_filename)
}this.m_finishCallback=null;
return true
};
this.reloadAllImages=function(b,a){this.m_finishCallback=a;
if(!this.m_requests){this.m_requests=new Object()
}for(var c in this.m_objects){this.m_requests[c]=this.m_objects[c]
}this.load(b)
};
this.load=function(a){this.m_bLoaded=false;
this.m_image.onload=hitch(this,"onload");
try{this.m_image.src=a
}catch(b){}};
this.removeObject=function(a){if(this.m_objects&&this.m_objects[a]){this.m_objects[a]=null
}if(this.m_requests&&this.m_requests[a]){this.m_requests[a]=null
}};
this.getURL=function(){return this.m_image.src
};
this.addObject=function(a,b){if(!a){return
}if(this.m_objects){this.m_objects[b]=a
}if(this.m_bLoaded){this.copyToObject(a)
}else{if(this.m_requests){this.m_requests[b]=a
}}};
this.m_bLoaded=false;
this.m_requests=new Object();
this.m_objects=new Object();
this.m_image=new Image();
this.m_bIECachingBug=false;
this.m_filename=null;
this.m_finishCallback=null
};
Class("ui.imagemap",ui.element,function(a){this.initialize=function(){a(this,"initialize");
this.m_bShow=false;
this.m_region=new Array();
this.m_image=null;
this.m_element=null;
this.m_parentElement=null;
this.m_headerElement=null;
this.m_bHover=false;
this.createHandler("Close")
};
this.create=function(k,g,f,c,b,e){this.m_win=gWin(g);
var d=createImg(k,g,b,e,c,"",true);
d.id=k;
d.className="uiImageMap";
d.setAttribute("img",c);
d.setAttribute("width",b);
d.setAttribute("height",e);
d.header=f;
d.setAttribute("control","uiImageMap");
d.ptr=this;
d=g.appendChild(d);
this.init(d)
};
this.init=function(b){this.m_headerElement=b.header;
this.m_element=b;
this.m_parentElement=b.parentNode;
this.m_image=this.m_element.getAttribute("img");
this.m_element.style.cursor="default";
this.m_element.style.zIndex=gWindowMgr.getNextZIndex();
this.m_bShow=true
};
this.show=function(){if(!this.m_element||!this.m_parentElement){return
}this.m_element=this.m_parentElement.appendChild(this.m_element);
this.m_element.style.zIndex=gWindowMgr.getNextZIndex();
this.m_bShow=true;
ui.connectGlobalEvent(gDoc(this.m_win),"mousedown",hitch(this,"onMouseDown"));
ui.connectGlobalEvent(gDoc(this.m_win),"mouseup",hitch(this,"onMouseUp"))
};
this.hide=function(){if(!this.m_bShow){return
}this.onClose();
if(this.m_element&&this.m_parentElement&&this.m_element.parentNode){this.m_element=this.m_parentElement.removeChild(this.m_element)
}this.m_bShow=false;
ui.disconnectGlobalEvent(gDoc(this.m_win),"mousedown");
ui.disconnectGlobalEvent(gDoc(this.m_win),"mouseup")
};
this.isShowing=function(){return this.m_bShow
};
this.onMouseUp=function(d){if(!this.m_bShow){return
}if(this.m_element&&this.m_element.parentNode==this.m_parentElement&&!isCursorInElement(this.m_element,d)){this.hide();
ui.setEventHandled(d);
return false
}var b=ui.getCursorX(d)-this.m_element.offsetLeft;
var e=ui.getCursorY(d)-this.m_element.offsetTop;
for(var c=0;
c<this.m_region.length;
c++){if((b>=this.m_region[c].left)&&(b<=this.m_region[c].right)){if((e>=this.m_region[c].top)&&(e<=this.m_region[c].bottom)){this.m_region[c].func();
this.hide()
}}}ui.setEventHandled(d);
return false
};
this.onMouseDown=function(c){if(!this.m_bShow){return true
}var d=isCursorInElement(this.m_element,c);
var b=isCursorInElement(this.m_headerElement,c);
if(!d&&!b){if(this.m_bShow){this.hide()
}return true
}ui.setEventHandled(c);
return false
};
this.addRegion=function(c,e,b,d,g){this.m_region.push({left:c,top:e,right:b,bottom:d,func:g})
}
});
Class("ui.imagecache",function(){this.initialize=function(){this.m_ctrlname="uiimgcache";
this.m_currentSkin="default";
if(typeof gTakeover!="undefined"&&gTakeover){this.m_currentSkin=gTakeover.skin
}this.m_path="/skin/"+this.m_currentSkin+"/img/";
this.m_images={};
this.m_directory={};
this.m_loadQueue=[];
this.m_cssQueue=[]
};
this.requestImage=function(a,d){if(!d||!a){return
}var b=a.replace(/^(https?:\/\/)?.*[\/]?skin\/[^\/]*\/img\//,"");
if(a.toLowerCase().indexOf("http://")==-1&&a.toLowerCase().indexOf("https://")==-1&&a.substr(0,1)!="/"){a=this.getPath()+a
}if(!d.getAttribute){return
}var c=d.getAttribute(this.m_ctrlname);
if(c&&this.m_directory[c]){if(this.m_directory[c].getURL().indexOf(a)!=-1){return
}this.m_directory[c].removeObject(c)
}else{c=this.stampObject(d)
}if(!this.m_images[b]){if(gWin(d)!=window){runInMainContext(this,this.loadImage,a,d,c)
}else{this.loadImage(a,d,c)
}return
}this.m_directory[c]=this.m_images[b];
this.m_images[b].addObject(d,c)
};
this.stampObject=function(b){var a=getUniqueId();
b.setAttribute(this.m_ctrlname,a);
return a
};
this.loadImage=function(b,e,d){var c=b.replace(/^(https?:\/\/)?.*[\/]?skin\/[^\/]*\/img\//,"");
var a=new ui.image();
a.setFilename(c);
this.m_images[c]=a;
this.m_directory[d]=this.m_images[c];
a.addObject(e,d);
a.load(b)
};
this.getPath=function(){return this.m_path
};
this.setPath=function(a){this.m_path=a
};
this.setIEPNG=function(b,a,c){if(!c||!c.length){c="image"
}if(ui.isIE){b.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+a+"', sizingMethod='"+c+"')"
}};
this.getStylesheet=function(){var a=document.getElementsByTagName("link");
for(var b=0,c;
(c=a[b]);
b++){if(c.rel=="stylesheet"){return c
}}};
this.getSkinId=function(a){return a+"-stylesheet"
};
this.setSkin=function(g){if(this.m_currentSkin==g){return
}var e=/skin\/[^\/]*(\/.*)/;
this.setPath(this.m_path.replace(e,"skin/"+g+"$1"));
this.m_currentSkin=g;
if($(this.getSkinId(g))){removeElement($(this.getSkinId(g)))
}var a=this.getStylesheet();
var d=document.createElement("link");
d.rel="stylesheet";
d.id=this.getSkinId(g);
d.href=a.href.replace(e,"skin/"+g+"$1");
a.parentNode.appendChild(d);
for(var c in this.m_images){var b=c;
if(b.toLowerCase().indexOf("http://")==-1&&b.toLowerCase().indexOf("https://")==-1&&b.substr(0,1)!="/"){b=this.getPath()+b
}this.m_images[c].reloadAllImages(b,null)
}var f=hitch(gPubSub,"publish",this,"ui.imagecache::skinLoaded",g);
if(ui.isIE){d.onload=f;
d.onerror=f
}else{setTimeout(f,2000)
}}
});
var gImages=new ui.imagecache();
gImages.setPath(gConfig.getImageServer());
ui.soundmanager=function(){this.m_isMuted=false;
this.m_isDisabled=false;
this.m_isReady=false;
this.m_flashElem=null;
this.m_path=gConfig.getSoundPath();
this.m_sounds={send:this.m_path+"send_4",receive:this.m_path+"recv_4",room:this.m_path+"room_d"};
this.m_ext=".mp3";
this.m_html5=false;
this.m_audios={};
this.m_pending=[];
this.init=function(d){if(this.m_isDisabled){return
}if(typeof Audio!="undefined"){try{var b=new Audio();
if(b.canPlayType){var f=b.canPlayType("audio/ogg"),a=b.canPlayType("audio/mpeg");
if(f&&f!="no"){this.m_ext=".oga";
this.m_html5=true
}else{if(a&&a!="no"){this.m_ext=".mp3";
this.m_html5=true
}}}}catch(c){}}if(!this.m_html5){if(util.flash.getVersion().major>=9){if(!d){d={}
}d.win=d.win||window;
d.swfUrl=this.m_path+"SoundPlayer.swf";
d.onReady=hitch(this,"onFlashReady");
this.m_flashElem=util.flash.embed(d)
}else{this.m_isDisabled=true
}}return this
};
this.onFlashReady=function(){this.m_isReady=true;
var c=this.m_pending;
this.m_pending=[];
for(var a=0,b;
b=c[a];
++a){this.playSample(b)
}};
this.playSample=function(b){if(this.m_isDisabled||this.m_isMuted||!(b in this.m_sounds)){return
}if(this.m_flashElem&&!this.m_isReady){this.m_pending.push(b);
return
}try{if(this.m_html5){if(!(b in this.m_audios)||this.m_ext==".oga"){this.m_audios[b]=new Audio(this.m_sounds[b]+this.m_ext)
}this.m_audios[b].play()
}else{if(this.m_isReady){this.m_flashElem.playSample(this.m_sounds[b]+this.m_ext)
}}}catch(a){}};
this.isDisabled=function(){return this.m_isDisabled
};
this.setDisabled=function(a){this.m_isDisabled=a
};
this.isMuted=function(){return this.m_isMuted
};
this.mute=function(){this.m_isMuted=true;
this.setMediaMute()
};
this.unmute=function(){this.m_isMuted=false;
this.setMediaMute()
};
this.toggleMute=function(){this.m_isMuted=!this.m_isMuted;
this.setMediaMute();
return this.m_isMuted
};
this.setMediaMute=function(){if(typeof gWindows=="undefined"){return
}for(var a in gWindows){var b=gWindows[a];
if(b&&b.isMeeboGroupChat&&b.isMeeboGroupChat()){b.setMediaMute(this.m_isMuted)
}}}
};
ui.notice=function(){this.m_isReady=false;
this.m_flashEnabled=false;
if(!util.flash||util.flash.getVersion().major<8){return
}this.m_flashEnabled=true;
var d="notice";
this.m_path="http://widget.meebo.com/";
if(ui.isHttps){this.m_path=window.location.protocol+"//"+window.location.hostname+"/flash/"
}var b=document.createElement("div");
b=document.body.appendChild(b);
var c=1;
var e=1;
var f=Math.floor(Math.random()*1000000);
var a='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="'+d+'" width="'+c+'" height="'+e+'" align="middle">';
a+='<param name="allowScriptAccess" value="always" />';
a+='<param name="movie" value="'+this.m_path+"notice.swf?"+f+'" />';
a+='<param name="quality" value="high" />';
a+='<param name="wmode" value="transparent" />';
a+='<embed src="'+this.m_path+"notice.swf?"+f+'" quality="high" width="'+c+'" height="'+e+'" swLiveConnect=true id="'+d+'" name="'+d+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" />';
a+="</object>";
b.innerHTML=a;
if(ui.isIE){this.m_flashElem=window[d]
}else{this.m_flashElem=document[d]
}if(!this.m_flashElem){this.m_flashEnabled=false
}this.onProbation=0;
this.probationCheckInterval=-1;
this.probationCallback=null
};
ui.notice.prototype.onReady=function(){this.m_isReady=true;
if(this.m_readyCallback){setTimeout(hitch(this,"m_readyCallback"),0)
}};
ui.notice.prototype.executeWhenReady=function(a){if(this.m_isReady){setTimeout(hitch(this,a),0)
}else{this.m_readyCallback=a
}};
ui.notice.prototype.onNotice=function(a){if(!this.m_flashEnabled||!this.m_flashElem.onNotice){return false
}return this.m_flashElem.onNotice(a)
};
ui.notice.prototype.add=function(a,c,b){if(!this.m_flashEnabled||!this.m_flashElem.add){return
}this.m_flashElem.add(a,c,b)
};
ui.notice.prototype.isLockedOut=function(){if(!this.m_flashEnabled||!this.m_flashElem.isLockedOut){return false
}return this.m_flashElem.isLockedOut()
};
ui.notice.prototype.getNoticeCount=function(){if(!this.m_flashEnabled||!this.m_flashElem.getNoticeCount){return 0
}return this.m_flashElem.getNoticeCount()
};
ui.notice.prototype.getLockoutLimit=function(){if(!this.m_flashEnabled||!this.m_flashElem.getLockoutLimit){return 100
}return this.m_flashElem.getLockoutLimit()
};
ui.notice.prototype.addWarn=function(a,b){if(!this.m_flashEnabled||!this.m_flashElem.addWarn){return
}return this.m_flashElem.addWarn(a,b)
};
ui.notice.prototype.getMuteTimeLeft=function(){if(!this.m_flashEnabled||!this.m_flashElem.getMuteTimeLeft){return 0
}return this.m_flashElem.getMuteTimeLeft()
};
ui.notice.prototype.canWarn=function(a,b){if(!this.m_flashEnabled||!this.m_flashElem.canWarn){return false
}return this.m_flashElem.canWarn(a,b)
};
ui.notice.prototype.checkProbation=function(){var a=this.getMuteTimeLeft();
if(a>0){a=Math.round(a/1000);
this.onProbation=a;
if(this.probationCheckInterval==-1){clearInterval(this.probationCheckInterval);
this.probationCheckInterval=setInterval(hitch(this,"checkProbation"),30000)
}if(this.probationCallback){this.probationCallback(true,this.onProbation)
}}else{this.onProbation=0;
clearInterval(this.probationCheckInterval);
if(this.probationCheckInterval!=-1){this.probationCheckInterval=-1
}if(this.probationCallback){this.probationCallback(false)
}}};
ui.notice.prototype.registerProbationCallback=function(a){this.probationCallback=a
};
ui.notice.prototype.isLocalStorageEnabled=function(){if(!this.m_flashEnabled){return false
}var a=false;
try{a=this.m_flashElem.isLocalStorageEnabled()
}catch(b){gNetworkMgr.doUILog("notice","failedLocalStorageCall","isLocalStorageEnabled",true,b.toString())
}return a
};
ui.Uid=function(){this.m_isReady=false;
this.m_flashEnabled=false;
this.m_uid;
if(!util.flash||util.flash.getVersion().major<8){return
}this.m_flashEnabled=true;
var d="uid";
if(window.location.href.indexOf("dev.meebo.com")>=0){this.m_path=window.location.protocol+"//"+window.location.hostname+"/"
}else{if(window.location.href.indexOf("stage.meebo.com")>=0){this.m_path="http://stage-widget.meebo.com/"
}else{this.m_path="http://widget.meebo.com/"
}}if(ui.isHttps){this.m_path=window.location.protocol+"//"+window.location.hostname+"/flash/"
}var b=document.createElement("div");
b=document.body.appendChild(b);
var c=1;
var e=1;
var f=Math.floor(Math.random()*1000000);
var a='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="'+d+'" width="'+c+'" height="'+e+'" align="middle">';
a+='<param name="allowScriptAccess" value="always" />';
a+='<param name="movie" value="'+this.m_path+"uid.swf?"+f+'" />';
a+='<param name="quality" value="high" />';
a+='<param name="wmode" value="transparent" />';
a+='<embed src="'+this.m_path+"uid.swf?"+f+'" quality="high" width="'+c+'" height="'+e+'" swLiveConnect=true id="'+d+'" name="'+d+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" />';
a+="</object>";
b.innerHTML=a;
this.m_flashElem=(ui.isIE)?window[d]:document[d];
this.m_flashEnabled=Boolean(this.m_flashElem)
};
ui.Uid.prototype.onReady=function(){this.m_isReady=true;
if(this.m_readyCallback){setTimeout(hitch(this,"m_readyCallback"),0)
}};
ui.Uid.prototype.executeWhenReady=function(a){if(!this.m_flashEnabled||this.m_isReady){setTimeout(hitch(this,a),0)
}else{this.m_readyCallback=a
}};
ui.Uid.prototype.makeUid=function(){var b=new Date().getTime()*Math.random();
var a=b.toString();
var c=util.sha.sha256(a).substr(0,40);
util.cookie.save("meebo_unique_id",c);
this.m_uid=c
};
ui.Uid.prototype.onUid=function(){if(this.m_uid){return this.m_uid
}if(!this.m_flashEnabled||"undefined"==typeof(this.m_flashElem.onUid)){var a=util.cookie.load("meebo_unique_id");
if(a){this.m_uid=a
}else{this.makeUid()
}}else{try{this.m_uid=this.m_flashElem.onUid()
}catch(b){this.makeUid()
}}return this.m_uid
};
ui.Uid.prototype.isLocalStorageEnabled=function(){if(!this.m_flashEnabled){return false
}var a=false;
try{a=this.m_flashElem.isLocalStorageEnabled()
}catch(b){gNetworkMgr.doUILog("uid","failedLocalStorageCall","isLocalStorageEnabled",true,b.toString())
}return a
};
function spanNodeCreator(a){var b=gDoc(a);
return function(c){var d=b.createElement("span");
d.innerHTML=c;
return d
}
}function createImg(c,k,b,h,a,e,l,g,f){var d=gDoc(k).createElement("img");
if(!d){return
}if(c){d.id=c
}if(e){d.setAttribute("alt",e);
d.setAttribute("title",e)
}if(g){d.setAttribute("align",typeof g=="boolean"?"top":g)
}if(!l&&a){if(f){d.onload=hitch(d,fixPng);
addClassName(d,"fixPng")
}d.src=a
}else{if(a){if(f){d.png=true
}gImages.requestImage(a,d)
}}if(b){d.width=b
}if(h){d.height=h
}return d
}function cacheImgs(a){if(a.tagName.toLowerCase()=="img"){gImages.requestImage(a.getAttribute("src"),a)
}else{var e=a.getElementsByTagName("img");
for(var c=0,b;
(b=e[c]);
c++){var d=b.getAttribute("path")||b.getAttribute("src");
gImages.requestImage(d,b)
}}}ui.pane=function(){this.create=function(e,a,b,c){this.m_win=gWin(a);
var d=this.m_win.document.createElement("div");
if(!d){return
}d.id=e;
d.control="ui.pane";
d.className="uiPane";
d.setAttribute("width",b);
d.setAttribute("height",c);
this.init(a.appendChild(d))
};
this.init=function(a){if(!a){return
}this.m_element=a;
this.m_element.setAttribute("ptr",this);
this.m_width=parseInt(this.m_element.getAttribute("width"));
this.m_height=parseInt(this.m_element.getAttribute("height"));
var b=this.m_element.firstChild;
while(b){if(b.getAttribute&&(b.getAttribute("control")=="ui.paneContent")){this.initContent(b)
}b=b.nextSibling
}this.m_element.ptr=this
};
this.initContent=function(a){if(!a){return
}a.initContent(this.m_element,this.m_width,this.m_height);
this.m_contents[a.m_element.id]=a
};
this.addContent=function(c,a){var b=new ui.paneContent();
b.create(c,this.m_element,a);
this.m_contents[contentO.m_element.id]=contentO;
return b
};
this.showContent=function(a){if(this.m_activePane&&(this.m_activePane.m_element.id==a)){return
}if(this.m_activePane){this.hideContent(this.m_activePane.m_element.id)
}if(this.m_contents[a]){this.m_activePane=this.m_contents[a];
this.m_activePane.m_element=this.m_contents[a].m_element=this.m_element.appendChild(this.m_contents[a].m_element);
this.m_activePane.resize(this.m_width,this.m_height)
}if(this.m_activePane.onRender){this.m_activePane.onRender()
}};
this.hideContent=function(a){if(this.m_contents[a]&&this.m_contents[a].onHide){this.m_contents[a].onHide()
}if(this.m_contents[a]){this.m_contents[a].m_element=this.m_element.removeChild(this.m_contents[a].m_element)
}};
this.getActivePane=function(){if(this.m_activePane){return this.m_activePane
}else{for(var a in this.m_contents){if(this.m_contents[a]){this.m_activePane=this.m_contents[a];
return this.m_activePane
}}}};
this.getContent=function(a){return this.m_contents[a]
};
this.resize=function(a,b){if(a<0){a=0
}if(b<0){b=0
}this.m_element.style.width=a+"px";
this.m_element.style.height=b+"px";
this.m_width=a;
this.m_height=b;
var c=this.getActivePane();
if(c){c.resize(a,b)
}};
this.m_win=window;
this.m_activePane=null;
this.m_element=null;
this.m_width=0;
this.m_height=0;
this.m_contents=new Array()
};
ui.paneContent=function(){this.m_id;
this.m_element=null;
this.m_onMouseUp=new Object();
this.m_win=window;
this.create=function(c,a){this.m_win=gWin(a);
var b=this.m_win.document.createElement("div");
if(!b){return
}this.id=c;
b.id=c;
b.control="ui.paneContent";
b.className="uiPaneContent";
this.init(b)
};
this.init=function(a){this.m_element=a
};
this.resize=function(a,b){if(a<0){a=0
}if(b<0){b=0
}this.m_element.style.width=a+"px";
this.m_element.style.height=b+"px";
this.m_width=a;
this.m_height=b;
if(this.resizePane){this.resizePane(a,b)
}}
};
ui.reset=function(e,c){var f=ui.reset.tagNames;
var b=[e],a=1;
while(a--&&(e=b.pop())){if(e.childNodes){var d=e.childNodes.length;
while(d--){var g=e.childNodes[d];
if(g.nodeType==1){b[a++]=g
}}}if(!(e.tagName in f)){addClassName(e,"meeboClass-reset");
if(c){addClassName(e,c)
}}}return e
};
ui.reset.tagNames={m:1,M:1,m_span:1,M_SPAN:1};
Class("ui.Tree",ui.Element,function(a){this.initialize=function(b){a(this,"initialize");
if(!b){b={}
}this.buildDragTree=b.buildDragTree;
b.eventModel=b.eventModel||ui.TreeEventModel;
this.setEventModel(new b.eventModel(this));
this.m_selectionModel=new ui.TreeSelection(this);
this.m_children=[];
this.m_root=null;
this.m_dragTree=null;
this.m_isDragEnabled=false;
this.m_useProgressiveUpdate=false;
this.m_dropTargets=null;
this.m_uncreatedHTML=null
};
this.createContent=function(){this.m_drag=new ui.Drag(this.m_win,false,3);
this.m_drag.subscribe("DragStart",this,"onDragStart");
this.m_drag.subscribe("Drag",this,"onDrag");
this.m_drag.subscribe("DragStop",this,"onDragStop");
if(this.m_uncreatedHTML){this.m_element.innerHTML=this.m_uncreatedHTML;
this.m_uncreatedHTML=null;
setTimeout(hitch(this,"onRender"),0)
}};
this.onRender=function(){this.m_root.onRender(this.m_win);
this.m_eventModel.connectContentEvents(this.m_root.getElement())
};
this.uncreateContent=function(){if(this.m_root&&this.m_root.getElement()){this.m_eventModel.disconnectContentEvents(this.m_root.getElement())
}this.m_uncreatedHTML=this.m_element.innerHTML
};
this.applyToRange=function(l,k,g){var b=this.m_root;
if(!l){l=this.m_root.getNextTree()
}if(!k){k=this.m_root.getLastDescendant()
}if(!l){return
}var e=l.compareTo(k);
var c=e<0?"getNextTree":"getPreviousTree";
var d=l[c]();
g(l);
if(e==0){return
}for(var h=d;
h!=k&&h;
h=d){d=h[c]();
g(h)
}g(k)
};
this.applyToVisibleRange=function(d){var e=this.m_element.scrollTop-10;
var b=e+this.m_element.offsetHeight+20;
var c=this.m_root;
while(c&&(c=c.getNextVisibleTree())){if(c.isVisible()&&c.m_element.offsetTop+20>=e){d(c);
c=c.getNextVisibleTree();
while(c&&c.m_element.offsetTop<=b){d(c);
c=c.getNextVisibleTree()
}return
}}};
this.enableProgressiveUpdate=function(){this.m_useProgressiveUpdate=true;
ui.connectEvent(this.m_element,"scroll",this,"updateVisible")
};
this.getSelectionModel=function(){return this.m_selectionModel
};
this.setEventModel=function(b){if(b==this.m_eventModel){return
}if(this.m_eventModel&&this.m_element){this.m_eventModel.disconnectContentEvents(this.m_element)
}this.m_eventModel=b;
if(this.m_element){this.m_eventModel.connectContentEvents(this.m_element)
}};
this.getEventModel=function(){return this.m_eventModel
};
this.setRoot=function(b){if(this.m_element){if(this.m_root&&this.m_root.m_element.parentNode==this.m_element){var c=this.m_root.getElement();
removeElement(c);
this.m_eventModel.disconnectContentEvents(c)
}this.m_root=b;
this.m_redrawChildren={};
this.m_root.m_isRoot=true;
this.m_root.setTree(this);
this.m_root.create(this);
var c=this.m_root.getElement();
this.m_element.appendChild(c);
if(this.m_eventModel){this.m_eventModel.connectContentEvents(c)
}}else{this.m_root=b
}return b
};
this.getRoot=function(){return this.m_root
};
this.getCount=function(){return this.m_root.getCount.apply(this.m_root,arguments)
};
this.getChildren=function(){return this.m_root.getChildren.apply(this.m_root,arguments)
};
this.insertItem=function(){return this.m_root.insertItem.apply(this.m_root,arguments)
};
this.deleteItem=function(){return this.m_root.deleteItem.apply(this.m_root,arguments)
};
this.getDescendantItem=function(){return this.m_root.getDescendantItem.apply(this.m_root,arguments)
};
this.getSelections=function(){return this.m_selectionModel.getSelections()
};
this.setDropTargets=function(b){this.m_dropTargets=b
};
this.getDropTargets=function(){return this.m_dropTargets
};
this.setDragEnabled=function(){};
this.startDrag=function(c,b){if(c.button==2||(ui.isMac&&c.ctrlKey)){return
}this.m_dragNode=b;
this.m_drag.startDrag(c,this.m_selectionModel.getSelections())
};
this.handleDragStop=function(){if(this.m_dragTree){this.m_dragTree.style.display="none"
}};
this.getPos=function(){return posWithRespectTo(this.m_element,this.m_globalParent)
};
this.onDragStart=function(e,h){if(!this.buildDragTree){return
}if(!this.m_dragTree){this.m_dragTree=this.buildDragTree()
}this.m_dragTree.style.width=this.m_element.offsetWidth+"px";
var f=this.m_dragTree.childNodes[0];
f.innerHTML="";
var d=this.m_dragNode;
if(!d.isSelected()){this.m_selectionModel.selectOnly(d)
}var g=this.m_selectionModel.getSelections();
this.m_drag.m_params=g;
for(var b in g){var c=g[b].getExtra();
if(c.getType()!="chat"&&(c.getType()!="buddy"||c.isWidgetUser())){continue
}var k=g[b].getElement().cloneNode(true);
ui.disconnectAllEvents(k);
f.appendChild(k);
var l=posWithRespectTo(g[b].m_element);
k.style.position="absolute";
k.style.top=l.top-h.y+"px";
k.style.left=l.left-h.x+"px";
k.style.width=g[b].m_element.offsetWidth+"px";
k.firstChild.style.backgroundColor="transparent";
if(!ui.isWebKit){util.css.setOpacity(k,0.5)
}}this.m_dragTree.style.left=h.x+"px";
this.m_dragTree.style.top=h.y+"px";
this.m_dragTree.style.display="block";
if(this.m_dropTargets){this.m_dropTargets.activate(this.m_win)
}};
this.onDrag=function(c,b){if(this.m_dragTree){this.m_dragTree.style.left=b.x+"px";
this.m_dragTree.style.top=b.y+"px"
}if(this.m_dropTargets){this.m_currentTarget=this.m_dropTargets.query(b.x,b.y)
}};
this.onDragStop=function(d,b){var c=false;
if(this.m_currentTarget){if(this.m_currentTarget.dropHandle){if(d){c=this.m_currentTarget.dropHandle(d)
}if(this.m_currentTarget.dropHover){this.m_currentTarget.dropHover(false)
}}this.m_currentTarget=null
}if(this.m_dragTree){if(c){this.handleDragStop()
}else{new ui.Animation({duration:100,transition:ui.Animation.easeOut,subject:hitch(this,function(f){var e=this.m_dragTree.style;
e.top=b.y-b.dy*f+"px";
e.left=b.x-b.dx*f+"px"
}),onOne:hitch(this,"handleDragStop")}).play()
}}};
this.scrollToNodeHeader=function(c){var b=c.m_element.offsetTop;
var e=c.getHeader();
var d=e&&e.offsetHeight||20;
if(b<this.m_element.scrollTop){this.m_element.scrollTop=b
}else{if(b>this.m_element.scrollTop+this.m_element.offsetHeight-d){this.m_element.scrollTop=b-this.m_element.offsetHeight+d
}}};
this.scrollToNode=function(d,f){var c=d.m_element.offsetTop+(f&&f.top?f.top:0);
var b=d.m_element.offsetTop+d.m_element.offsetHeight+(f&&f.bottom?f.bottom:0);
var e=this.m_element.scrollTop;
if(b>e+this.m_element.offsetHeight){e=b-this.m_element.offsetHeight
}if(c<e){e=c
}this.m_element.scrollTop=e
};
this.markRedraw=function(b){this.m_redrawChildren[b.m_id]=b
};
this.unmarkRedraw=function(b){delete this.m_redrawChildren[b.m_id]
};
this.redrawChildren=function(){var b=this.m_element.parentNode;
while(b&&b!=this.m_win.document){b=b.parentNode
}if(!b){return
}for(var c in this.m_redrawChildren){this.m_redrawChildren[c].redraw();
delete this.m_redrawChildren[c]
}this.updateVisible()
};
this.updateVisible=createDelayedMethod("updateVisible",function(){if(!this.m_useProgressiveUpdate){return
}var b=this.applyToVisibleRange(function(c){c.update()
})
},100)
});
ui.Tree.compareTreeAncestorPaths=function(c,b){for(var a=0;
a<c.length&&a<b.length&&c[a]==b[a];
a++){}if(a==c.length){if(a==b.length){return 0
}return -1
}if(a==b.length){return 1
}return c[a]<b[a]?-1:1
};
Class("ui.TreeNode",ui.Element,function(a){this.m_control="uiTree";
this.m_extra;
this.m_headerDiv;
this.m_className="uiTree";
this.m_headerClassName="header";
this.m_baseHeaderClassName="";
this.m_text="";
this.m_childrenDiv;
this.m_tree=null;
this.m_isRoot=false;
this.m_index=0;
this.m_level=0;
this.m_indentation=16;
this.m_sortFunc;
this.m_sortIndex;
this.m_bToggleHandle;
this.m_bToggleOpen=true;
this.m_display=true;
this.m_needsUpdate=false;
this.m_isSelected=false;
this.m_isSelectionEnabled=true;
this.m_selectionModifiers=modifier.CTRL|modifier.SHIFT;
this.initialize=function(b){a(this,"initialize");
this.m_id=b||getUniqueId();
this.m_children=[]
};
this.setDisplay=function(b){a(this,"setDisplay",arguments);
this.m_display=b
};
this.setTree=function(b){this.m_tree=b
};
this.getTree=function(){return this.m_tree
};
this.setSelectionEnabled=function(b){this.m_isSelectionEnabled=b
};
this.isSelectionEnabled=function(){return this.m_isSelectionEnabled
};
this.selectAllChildren=function(){var b=this.m_tree.getSelectionModel();
for(var c=0,d;
(d=this.m_children[c]);
c++){b.addNode(d)
}};
this.selectAllSiblings=function(d){var c=this.m_tree.getSelectionModel();
for(var b=this[d]();
b!=null;
b=b[d]()){c.addNode(b)
}};
this.isSelected=function(){return this.m_isSelected
};
this.setSelected=function(b){if(this.m_isSelected==b){return
}this.m_isSelected=b;
this.toggleHeaderClassName(b,ui.TreeNode.classNames.selected)
};
this.getSiblingAncestors=function(d){if(this.m_level==d.m_level&&this.m_parent==d.m_parent){return[this,d]
}else{var c=this,b=d;
if(this.m_level>d.m_level){c=this.m_parent
}else{if(this.m_level<d.m_level){b=d.m_parent
}else{c=this.m_parent;
b=d.m_parent
}}return c.getSiblingAncestors(b)
}};
this.getNextSiblingTree=function(){return(this.m_parent instanceof ui.TreeNode?this.m_parent.m_children[this.m_index+1]:null)
};
this.getPreviousSiblingTree=function(){return(this.m_parent instanceof ui.TreeNode?this.m_parent.m_children[this.m_index-1]:null)
};
this.getNextTree=function(){if(this.m_children.length&&this.m_bToggleOpen){return this.m_children[0]
}if(this.m_parent instanceof ui.Tree||!this.m_parent){return null
}if(this.m_index<this.m_parent.m_children.length-1){return this.getNextSiblingTree()
}return this.m_parent.getNextSiblingTree()
};
this.getPreviousTree=function(){var b=this.getPreviousSiblingTree();
if(b){var c=b.getLastDescendant();
return(c?c:b)
}else{return(this.m_parent==this.m_tree.getRoot())?null:this.m_parent
}};
this.getPreviousVisibleTree=function(){var b=this;
do{b=b.getPreviousTree()
}while(b&&!b.isVisible());
return b
};
this.getNextVisibleTree=function(){var b=this;
do{b=b.getNextTree()
}while(b&&!b.isVisible());
return b
};
this.getLastDescendant=function(b){if(!this.m_children.length||!this.m_bToggleOpen){return(b?this:null)
}else{return this.m_children[this.m_children.length-1].getLastDescendant(true)
}};
this.getLastVisibleDescendant=function(){var b=this.getLastVisibleChild();
if(b&&b.m_children.length){var c=b.getLastVisibleDescendant();
if(c){return c
}}return b
};
this.getLastVisibleChild=function(){for(var b=this.m_children.length-1,c;
c=this.m_children[b];
--b){if(c.isVisible()){return c
}}return null
};
this.isVisible=function(){var b=this;
while((b=b.m_parent)&&b instanceof ui.TreeNode){if(!b.m_bToggleOpen){return false
}}return this.getElement()&&getCSSProp(this.getElement(),"display")!="none"
};
this.getElement=function(){return this.m_element||(this.m_element=this.m_win&&this.m_win.document.getElementById(this.m_id))
};
this.getType=function(){var b=this.getExtra();
if(!b){return"none"
}return b.getType()
};
this.getCount=function(){return this.m_children.length
};
this.getDescendantItem=function(e){if(!this.m_children.length){return null
}var c=this.getItem(e);
if(c){return c
}for(var b=0,d;
(d=this.m_children[b]);
b++){var c=d.getDescendantItem(e);
if(c){return c
}}return null
};
this.getHeader=function(){return this.m_headerDiv||(this.m_element?(this.m_headerDiv=this.m_element.firstChild):null)
};
this.getChildrenDiv=function(c){var b=this.m_childrenDiv||(this.m_element?(this.m_childrenDiv=this.m_element.childNodes[this.m_isRoot?0:1]):null);
if(!b&&this.m_element&&c){b=this.dom(ui.TreeNode.classNames.children);
if(!this.m_bToggleOpen){b.style.display="none"
}this.m_element.appendChild(b);
this.m_childrenDiv=b
}return b
};
this.getItem=function(b){return this.m_children[b]
};
this.highlight=function(b){this.toggleHeaderClassName(b,ui.TreeNode.classNames.highlight)
};
this.addHeaderClassName=function(b){this.toggleHeaderClassName(true,b)
};
this.removeHeaderClassName=function(b){this.toggleHeaderClassName(false,b)
};
this.toggleHeaderClassName=function(c,b){var e=(c?addClassName:removeClassName)(this.m_headerClassName,this.m_baseHeaderClassName+b);
if(e==this.m_headerClassName){return
}this.m_headerClassName=e;
var d=this.getHeader();
if(d){d.className=this.m_headerClassName
}};
this.isToggled=function(){return !this.m_bToggleOpen
};
this.setToggled=function(b){if(this.m_bToggleOpen==b){this.toggle()
}};
this.toggle=function(){this.m_bToggleOpen=!this.m_bToggleOpen;
this.publish("Toggle",this,!this.m_bToggleOpen);
this.toggleHeaderClassName(this.m_bToggleOpen,ui.TreeNode.classNames.toggleOpen);
this.toggleHeaderClassName(!this.m_bToggleOpen,ui.TreeNode.classNames.toggleClose);
if(this.getChildrenDiv()){this.getChildrenDiv().style.display=this.m_bToggleOpen?"":"none"
}else{if(this.m_bToggleOpen&&this.m_children.length){removeElement(this.getElement());
this.m_element=null;
this.redraw()
}}if(this.m_tree){this.m_tree.updateVisible()
}};
this.getText=function(){return this.m_text
};
this.setText=function(b){if(b==this.m_text){return
}this.m_text=b;
this.markRedraw()
};
this.showEditInput=function(n,o,e){o=stripWhitespace(typeof o=="string"?o:this.getText());
if(!this.m_element){this.redraw()
}var f=this.m_tree.m_element;
var d=this.getHeader().firstChild;
var k=posWithRespectTo(d,f);
var l=k.x+d.offsetWidth,g=k.y-1,m=f.offsetWidth-l-8,c=this.getHeader().offsetHeight-2;
var b=ui.innerHTML(this.dom(),'<input class="uiLabelEditField" type="text" 			autocomplete="off" value="'+escapeHTML(o)+'" style="top:'+g+"px; left:"+l+"px; width:"+m+"px; height:"+c+'px;z-index: 2000000000">');
this.m_editInput=b.firstChild;
f.style.overflow="hidden";
f.onselectstart=null;
f.appendChild(this.m_editInput);
this.m_editInput.focus();
this.m_editInput.select();
if(e){this.m_editInput.maxLength=e
}ui.connectEvent(this.m_editInput,"keypress",this,"onEditEvent",true);
ui.connectGlobalEvent(this.m_win.document,"mousedown",hitch(this,"onEditEvent"));
this.m_editCallback=n;
if(ui.isIE&&typeof gWindowMgr!="undefined"){gWindowMgr.redraw()
}};
this.onEditEvent=function(c){var f=c.target||c.srcElement,b=c.type,d=c.keyCode;
if(b!="keypress"&&f==this.m_editInput){return false
}else{if(d==ui.KEY_ESC){this.cancelEdit()
}else{if(this.m_editInput&&(b=="mousedown"||d==ui.KEY_RETURN)){this.cancelEdit(this.m_editInput.value)
}}}};
this.cancelEdit=function(b){if(!this.m_editInput){return
}this.m_tree.m_element.style.overflow="";
this.m_tree.m_element.onselectstart=function(){return false
};
removeElement(this.m_editInput);
this.m_editInput=null;
ui.disconnectGlobalEvent(this.m_win.document,"mousedown");
if(this.m_editCallback){this.m_editCallback(this,typeof b=="string"?b:null);
this.m_editCallback=null
}};
this.sort=function(){if(!this.m_sortFunc||this.m_children.length<=1){return
}if(this.m_element){var c=this.getChildrenDiv(true)
}this.m_children.sort();
for(var d=0,e;
(e=this.m_children[d]);
d++){e.m_index=d;
var b=c&&c.childNodes[d];
if(b&&b!=e.m_element&&e.m_element){c.insertBefore(e.m_element,b)
}}};
this.getItemIndex=function(g){var e=this.m_children;
var f=g.m_sortIndex,d=e.length;
if(this.m_sortFunc&&d){var c=0,b=d;
while(b-c>1){d=Math.floor((b+c)/2);
if(f<e[d].m_sortIndex){b=d
}else{c=d
}}d=(f<e[c].m_sortIndex?c:b)
}return d
};
this.getIndex=function(){return this.m_index
};
this.insertItem=function(d){if(this.m_children[d.getId()]){return d.m_index
}if(d.m_parent instanceof ui.TreeNode){d.m_parent.deleteItem(d,true)
}d.m_parent=this;
d.m_level=this.m_level+1;
d.m_tree=this.m_tree;
d.setSortIndex();
var b=this.getItemIndex(d);
this.m_children[d.getId()]=d;
this.m_children.splice(b,0,d);
for(var c=b;
c<this.m_children.length;
c++){this.m_children[c].m_index=c
}this.insertChildDOMNode(d);
return d
};
this.reinsertItem=function(f){var d=this.m_children;
var e=f.m_index;
d.splice(e,1);
var c=this.getItemIndex(f);
d.splice(c,0,f);
for(var b=Math.min(e,c);
b<d.length;
b++){d[b].m_index=b
}this.insertChildDOMNode(f);
return f
};
this.insertChildDOMNode=function(d){d.m_parent=this;
if(!d.m_element){d.markRedraw()
}else{if(this.getChildrenDiv()||this.m_bToggleOpen){d.getHeader().style.paddingLeft=(this.m_level*d.m_indentation)+"px";
for(var c=d.m_index+1,b;
(b=this.m_children[c]);
c++){if(!b.m_element){continue
}this.getChildrenDiv(true).insertBefore(d.m_element,b.m_element);
break
}if(!b){this.getChildrenDiv(true).appendChild(d.m_element)
}}}return d
};
this.deleteAll=function(){this.m_element.removeChild(this.getChildrenDiv())
};
this.deleteItem=function(e,d){if(!e||!this.m_children.length){return
}if(this.m_tree){this.m_tree.unmarkRedraw(e);
this.m_tree.publish("DeleteNode",e)
}var b=e.m_index;
if(this.m_children[b]==e){this.m_children.splice(b,1);
for(var c=b;
c<this.m_children.length;
c++){this.m_children[c].m_index=c
}}removeElement(e.m_element);
if(!d){e.m_element=null;
e.m_headerDiv=null
}delete this.m_children[e.m_id];
e.m_parent=null;
e.m_tree=null;
e.m_index=0;
return e
};
this.renameChildItemId=function(b,c){if(b==c){return
}var d=this.m_children[b];
if(!d){return
}delete this.m_children[b];
d.setId(c);
this.m_children[c]=d
};
this.getLevel=function(){return this.m_level
};
this.getChildren=function(){return this.m_children
};
this.hasChildren=function(){return Boolean(this.m_children.length)
};
this.getExtra=function(){return this.m_extra
};
this.setExtra=function(b){this.m_extra=b
};
this.getId=function(){return this.m_id||this.m_element&&this.m_element.id||""
};
this.setId=function(b){this.m_id=b;
if(this.m_element){this.m_element.id=b
}};
this.createContent=function(){this.m_element.id=this.m_id;
this.m_element.setAttribute("control","uiTree");
this.m_element.className=this.m_className;
ui.innerHTML(this.m_element,this.getHTMLString(true));
if(!this.m_display){this.m_element.style.display="none"
}};
this.getHTMLString=function(e){var d=(e?"":'<m id="'+this.m_id+'" class="'+this.m_className+'" control="uiTree">')+(this.m_isRoot?"":'<m class="'+this.m_headerClassName+'" style="padding-left: '+((this.m_level-1)*this.m_indentation)+'px;">'+this.getHeaderHTMLString()+"</m>");
if(this.m_children.length&&this.m_bToggleOpen){var b=['<m class="'+ui.TreeNode.classNames.children+'"',(this.m_bToggleOpen?">":' style="display: none;">')];
for(var c=0;
c<this.m_children.length;
c++){b[b.length]=this.m_children[c].getHTMLString()
}b[b.length]="</m>";
d+=b.join("")
}if(!e){d+="</m>"
}this.markUpdate();
return d
};
this.getHeaderHTMLString=function(){return'<m_span class="'+ui.TreeNode.classNames.img+'">'+(ui.isWebKit||ui.isOpera?"&nbsp;":"")+'<m class="'+ui.TreeNode.classNames.img+'"></m></m_span><m_span class="'+ui.TreeNode.classNames.label+'">'+this.getText()+"</m_span>"
};
this.onRender=function(c){this.m_win=c;
this.m_headerDiv=null;
this.m_childrenDiv=null;
this.m_element=null;
this.m_element=this.getElement();
for(var b=0,d;
(d=this.m_children[b]);
b++){d.onRender(this.m_win)
}};
this.markRedraw=function(){if(!this.m_parent){return
}if(!this.m_parent.m_element){this.setSortIndex();
this.m_parent.markRedraw()
}else{if(this.m_tree){this.m_tree.markRedraw(this)
}}};
this.redraw=function(){if(this.setSortIndex()){this.m_parent.reinsertItem(this)
}if(this.m_element){ui.innerHTML(this.getHeader(),this.getHeaderHTMLString())
}else{if(!this.m_parent||this.m_parent.m_element){this.sort();
this.create(this.m_parent);
if(this.m_parent){this.m_parent.insertChildDOMNode(this)
}if(this.m_children.length){this.onRender(this.m_win)
}}else{this.m_parent.redraw()
}}if(this.m_tree){this.m_tree.unmarkRedraw(this)
}this.markUpdate()
};
this.markUpdate=function(){this.m_needsUpdate=true
};
this.update=function(){this.m_needsUpdate=false
};
this.show=function(){this.setDisplay(true);
this.m_tree.publish("ShowNode",this)
};
this.hide=function(){this.setDisplay(false);
this.m_tree.publish("HideNode",this)
};
this.setNewParent=function(b){if(b==this.m_parent){return
}if(this.m_parent){this.m_parent.deleteItem(this,true)
}if(b.insertItem){b.insertItem(this)
}};
this.setSortFunc=function(c){this.m_sortFunc=c;
for(var b=0;
b<this.m_children.length;
b++){this.m_children[b].setSortIndex()
}this.sort()
};
this.setSortIndex=function(){if(!this.m_parent||!this.m_parent.m_sortFunc){return false
}var d=this.m_parent.m_sortFunc(this);
if(this.m_sortIndex==d){return false
}this.m_sortIndex=d;
var c=this.getPreviousSiblingTree(),b=this.getNextSiblingTree();
if(c&&!(d>c.m_sortIndex)){return true
}if(b&&!(d<b.m_sortIndex)){return true
}return false
};
this.toString=function(){return this.m_sortIndex
};
this.compareTo=function(b){return b&&ui.Tree.compareTreeAncestorPaths(this.getTreeAncestorPath(),b.getTreeAncestorPath())
};
this.getTreeAncestorPath=function(){var b=[];
for(var c=this;
c;
c=c.m_parent){b.unshift(c.m_index)
}return b
}
});
ui.TreeNode.classNames={children:"children",highlight:"highlight",img:"img",label:"label",selected:"selected",toggleOpen:"toggle-open",toggleClose:"toggle-close"};
Class("ui.TreeSelection",lib.Publisher,function(a){this.initialize=function(b){a(this,"initialize");
this.m_tree=b;
this.m_tree.subscribe("HideNode",this,"onHideNode");
this.m_tree.subscribe("DeleteNode",this,"onDeleteNode");
this.m_selections={};
this.m_pivot=null;
this.m_focus=null;
this.m_numSelections=0;
this.directions={TOP:"Top",BOTTOM:"Bottom",PREVIOUS:"Previous",NEXT:"Next",UP:"Previous",DOWN:"Next"}
};
this.getSelections=function(){return this.m_selections
};
this.setSelections=function(b){this.m_selections=b
};
this.getPivot=function(){return this.m_pivot
};
this.setPivot=function(b){this.m_pivot=b
};
this.setFocus=function(b){this.m_focus=b
};
this.getFocus=function(){return this.m_focus
};
this.getNumSelections=function(){return this.m_numSelections
};
this.setNumSelections=function(b){this.m_numSelections=b
};
this.extendSelection=function(c){if(this.m_pivot==null&&this.m_numSelections==1){this.m_pivot=this.getFirstSelection()
}var b=this.getNextVisibleFrom(this.m_pivot,c);
if(b){if(b.isSelected()){this.removeNode(this.m_pivot)
}else{this.addNode(b)
}this.m_pivot=b;
this.m_tree.scrollToNodeHeader(b)
}return b
};
this.addNode=function(b){if(b.isSelected()){return
}this.m_selections[b.getId()]=b;
this.m_numSelections++;
if(!this.m_pivot){this.m_pivot=b
}b.setSelected(true);
this.publish("SelectionChanged")
};
this.removeNode=function(b){if(!b){return false
}b.setSelected(false);
if(b.getId() in this.m_selections){delete this.m_selections[b.getId()];
this.m_numSelections--;
this.publish("SelectionChanged");
return true
}return false
};
this.selectOnly=function(b){this.unselectAll();
this.addNode(b)
};
this.unselectAll=function(){for(var b in this.m_selections){this.m_selections[b].setSelected(false)
}this.m_selections={};
this.m_pivot=null;
this.m_numSelections=0
};
this.resetSelections=function(){this.unselectAll();
this.m_focus=null
};
this.unselectAllButPivot=function(){for(var b in this.m_selections){if(this.m_selections[b]!=this.m_pivot){this.m_selections[b].setSelected(false)
}}this.m_selections={};
this.m_selections[this.m_pivot.m_id]=this.m_pivot;
this.m_numSelections=1
};
this.getTopSelection=function(){return this.getSelectionBy(function(d,c){if(d.m_parent==c||c.m_parent==d){return d.m_level-c.m_level
}var e=d.getSiblingAncestors(c);
return e[0].m_index-e[1].m_index
})
};
this.getBottomSelection=function(){return this.getSelectionBy(function(d,c){if(d.m_parent==c||c.m_parent==d){return c.m_level-d.m_level
}var e=d.getSiblingAncestors(c);
return e[1].m_index-e[0].m_index
})
};
this.getSelectionBy=function(b,c){c=c||this.m_selections;
var e=null;
for(var d in c){e=e||c[d];
if(b(e,c[d])>=0){e=c[d]
}}return e
};
this.getFirstSelection=function(){for(var b in this.m_selections){return this.m_selections[b]
}return null
};
this.getNextVisibleFrom=function(b,c){return b?b["get"+c+"VisibleTree"]():this.m_tree.getRoot().getNextVisibleTree()
};
this.selectOnlyNext=function(d){var b=this.getFirstSelection();
var c=this.getNextVisibleFrom(b,d);
if(c){this.removeNode(b);
this.addNode(c);
this.m_pivot=c;
this.m_tree.scrollToNodeHeader(c)
}return c
};
this.selectFromSelection=function(b){var c=this["get"+b+"Selection"]();
if(c){this.unselectAll();
this.addNode(c)
}return c
};
this.onHideNode=function(b){this.removeNode(b);
if(this.m_pivot==b){this.m_pivot=this.getFirstSelection()
}};
this.onDeleteNode=function(b){if(b.isSelected()){this.removeNode(b)
}};
this.handleKeyEvent=function(d){if(!d){return true
}var c=d.keyCode||d.charCode;
var b=d.shiftKey;
switch(c){case ui.KEY_UP:case 63232:ui.setEventHandled(d);
if(b){return this.extendSelection(this.directions.UP)
}else{if(this.m_numSelections<=1){return this.selectOnlyNext(this.directions.UP)
}else{return this.selectFromSelection(this.directions.TOP)
}}break;
case ui.KEY_DOWN:case 63233:ui.setEventHandled(d);
if(b){return this.extendSelection(this.directions.DOWN)
}else{if(this.m_numSelections<=1){return this.selectOnlyNext(this.directions.DOWN)
}else{return this.selectFromSelection(this.directions.BOTTOM)
}}break;
case ui.KEY_RIGHT:case 63235:if(this.m_pivot&&this.m_pivot.m_bToggleHandle&&!this.m_pivot.m_bToggleOpen){this.m_pivot.toggle()
}return;
case ui.KEY_LEFT:case 63234:if(this.m_pivot&&this.m_pivot.m_bToggleHandle&&this.m_pivot.m_bToggleOpen){this.m_pivot.toggle()
}else{if(this.m_pivot&&this.m_pivot.m_parent.m_bToggleHandle&&this.m_pivot.m_parent.m_bToggleOpen){this.m_pivot.m_parent.toggle();
this.selectOnly(this.m_pivot.m_parent)
}}return;
case ui.KEY_RETURN:if(this.m_numSelections==1&&this.m_pivot.m_bToggleHandle){this.m_pivot.toggle()
}else{for(var c in this.m_selections){this.m_selections[c].publish("Activate")
}}break;
case ui.KEY_ESC:this.unselectAll();
break;
default:return true
}ui.setEventHandled(d);
return false
}
});
Class("ui.TreeEventModel",function(){this.m_element=null;
this.initialize=function(a){this.m_tree=a
};
this.getWindow=function(){return this.m_tree.getWindow()
};
this.getElement=function(){return this.m_element
};
this.connectContentEvents=function(a){this.m_element=a;
var b=hitch(this,function(c,d){ui.connectEvent(a,c,this,"delegateEvent",true,false,d)
});
a.onselectstart=function(){return false
};
a.oncontextmenu=function(){return false
};
b("mouseover","onMouseOver");
b("mousedown","onMouseDown");
b("mouseout","onMouseOut");
b("click","onClick");
b("contextmenu","onContextMenu");
b("dblclick","onDblClick");
ui.connectEvent(a,"keyup",this,"onKeyUp",true)
};
this.disconnectContentEvents=function(a){ui.disconnectEvent(a,"mouseover");
ui.disconnectEvent(a,"mouseout");
ui.disconnectEvent(a,"mousedown");
ui.disconnectEvent(a,"click");
ui.disconnectEvent(a,"contextmenu");
ui.disconnectEvent(a,"dblclick");
ui.disconnectEvent(a,"keyup");
a.onselectstart=null;
a.oncontextmenu=null;
this.m_element=null
};
this.onMouseOver=function(b,a){a.highlight(true);
a.publish("MouseOver",a,b)
};
this.onMouseOut=function(b,a){a.highlight(false);
a.publish("MouseOut",a,b)
};
this.onClick=function(b,a){a.publish("Click",a,b)
};
this.onDblClick=function(b,a){a.publish("DblClick",a,b)
};
this.onContextMenu=function(b,a){a.publish("ContextMenu",a,b)
};
this.onMouseDown=function(b,a){a.publish("MouseDown",a,b)
};
this.onKeyUp=function(b){var a=this.m_tree.getSelectionModel();
if(a){a.handleKeyEvent(b)
}};
this.delegateEvent=function(e,d){var g=e.target||e.srcElement;
var a=null;
while(g.parentNode){if(this.m_classNameList&&!a){for(var b=0,f;
(f=this.m_classNameList[b]);
b++){if(hasClassName(g,f)){a=f
}}}if(d=="onClick"&&g.tagName=="A"){return
}if(g.nodeType!=3&&(g.getAttribute("control")||g.control)=="uiTree"){var c=this.m_tree.getDescendantItem(g.id);
if(c){return this[d](e,c,a)
}}g=g.parentNode
}}
});
Class("ui.Panel",ui.dlg,function(a){this.initialize=function(){a(this,"initialize");
this.m_classNamePrefix="uiPanel";
this.m_centerRowH=31
};
this.handleFocus=function(){this.m_element.style.zIndex=gWindowMgr.getNextZIndex()
};
this.initContent=function(){a(this,"initContent");
if(this.m_contentArea){this.makeContentAndBordersDraggable();
this.m_element.style.zIndex=gWindowMgr.getNextZIndex()
}return true
};
this.createWindowTable=function(){var c=this.m_element.innerHTML;
var b='<table id="windowFrame" class="'+this.m_classNamePrefix+'Frame">			<tr class="'+this.m_classNamePrefix+'RowBar">				<td id="barw" class="'+this.m_classNamePrefix+'BarW">&nbsp;<br>				<td id="barn" class="'+this.m_classNamePrefix+'BarN">&nbsp;<br>				<td id="bare" class="'+this.m_classNamePrefix+'BarE">&nbsp;<br>			</tr>			<tr class="'+this.m_classNamePrefix+'RowBody">				<td id="w" class="'+this.m_classNamePrefix+'W">&nbsp;<br>				<td id="bg" class="'+this.m_classNamePrefix+'Bg" align="center" valign="center">				<td id="e" class="'+this.m_classNamePrefix+'E">&nbsp;<br>			</tr>			<tr class="'+this.m_classNamePrefix+'RowS">				<td id="sw" class="'+this.m_classNamePrefix+'SW">&nbsp;<br>				<td id="s" class="'+this.m_classNamePrefix+'S">&nbsp;<br>				<td id="se" class="'+this.m_classNamePrefix+'SE">&nbsp;<br>			</tr>		</table>';
this.m_element.innerHTML=b;
this.m_windowFrame=this.m_element.getElementsByTagName("table")[0];
if(ui.isIE){this.m_centerEl=this.m_windowFrame.childNodes[0].childNodes[1].childNodes[1];
this.m_centerEl.style.height=this.m_element.offsetHeight-this.m_centerRowH+"px"
}this.setSkin(this.m_skin);
addClassName(this.m_windowFrame,"inactive");
return c
};
this.makeContentAndBordersDraggable=function(){addClassName(this.m_contentArea,"draggable");
ui.connectEvent(this.m_contentArea,"mousedown",this,function(e,d){this.onBorderMouseDown(e,d)
},true,true);
var b=this.m_element.getElementsByTagName("td");
var c=this.toHash(b);
addClassName(c.w,"draggable");
addClassName(c.e,"draggable");
addClassName(c.s,"draggable");
addClassName(c.se,"draggable");
addClassName(c.sw,"draggable");
addClassName(c.barw,"draggable");
addClassName(c.bare,"draggable")
};
this.isPoppedOut=function(){return false
}
});
Class("ui.edit",ui.Element,function(a){this.initialize=function(k,g,f,b,e,h,d,c){a(this,"initialize");
this.m_onKeyPress=null;
this.m_onKeyDown=null;
this.m_fontFamily="Arial";
this.m_fontSize=10;
this.m_fontColor="#000000";
this.m_defaultFontFamily="";
this.m_defaultFontSize="";
this.m_defaultFontColor="";
this.m_fontSizeToHTMLSizeMapping=Array(8,10,12,16,24,34,48);
this.m_HTMLSizeToHTMLSizeMapping=Array(1,2,3,4,5,6,7);
this.m_editId=k;
this.m_editClass=c;
this.m_fontSize=f;
this.m_fontColor=String(b);
this.m_fontFamily=String(g);
this.m_isBold=e;
this.m_isItalics=h;
this.m_isUnderline=d
};
this.setFontFamily=function(b){};
this.setFontSize=function(b){};
this.setFontColor=function(b){};
this.setEditorColor=function(b){};
this.setUnderline=function(b){};
this.setBold=function(b){};
this.setItalics=function(b){};
this.replaceSelectionWithText=function(b){};
this.clear=function(){};
this.getText=function(){};
this.setText=function(b){};
this.getHtml=function(b){};
this.focus=function(){};
this.select=function(){};
this.blur=function(){};
this.getValue=function(){};
this.onKeyPress=function(b){this.m_onKeyPress=b
};
this.keyPress=function(b){if(this.m_onKeyPress){return this.m_onKeyPress(b)
}else{return true
}};
this.onKeyUp=function(b){this.m_onKeyUp=b
};
this.keyUp=function(b){if(this.m_onKeyUp){return this.m_onKeyUp(b)
}else{return true
}};
this.onKeyDown=function(b){this.m_onKeyDown=b
};
this.keyDown=function(b){if(this.m_onKeyDown){return this.m_onKeyDown(b)
}else{return true
}};
this.formatMessage=function(b){if(this.m_isBold){b="<b>"+b+"</b>"
}if(this.m_isUnderline){b="<u>"+b+"</u>"
}if(this.m_isItalics){b="<i>"+b+"</i>"
}if(this.m_fontFamily){b='<font face="'+this.m_fontFamily+'">'+b+"</font>"
}if(this.m_fontColor){b='<font color="'+this.m_fontColor+'">'+b+"</font>"
}if(this.m_fontSize){b='<font size="'+this.pixelsToFontSize(this.m_fontSize)+'">'+b+"</font>"
}return b
};
this.pixelsToFontSize=function(b){if(b>39){return 7
}else{if(b>=29){return 6
}else{if(b>=21){return 5
}else{if(b>=17){return 4
}else{if(b>=13){return 3
}else{if(b>=11){return 2
}}}}}}return 1
};
this.fontToHTMLSize=function(d,b){if(!b){b=this.m_fontSizeToHTMLSizeMapping
}for(var c=0;
c<b.length;
c++){if(d<=b[c]){return(c+1)
}}return b.length
};
this.HTMLToFontSize=function(b,c){if(!c){c=this.m_fontSizeToHTMLSizeMapping
}if(b-1<c.length){return c[b-1]
}return c[c.length-1]
};
this.setHTMLMapping=function(b){this.m_HTMLSizeToHTMLSizeMapping=b
};
this.getId=function(){return this.m_element.id
}
});
Class("ui.simpleEdit",ui.edit,function(a){this.createContent=function(){this.m_element.innerHTML=ui.isIPhone?"<input>":"<textarea></textarea>";
this.m_element.id=this.m_editId;
this.m_element=this.m_element.firstChild;
this.m_element.ptr=this;
this.m_element.setAttribute("control","ui.simpleEdit");
this.m_element.className=this.m_editClass;
this.m_defaultFontFamily=this.m_fontFamily;
this.m_defaultFontSize=parseInt(this.m_fontSize);
this.m_defaultFontColor=this.m_fontColor;
this.setFontFamily(this.m_defaultFontFamily);
this.setFontSize(this.m_defaultFontSize);
this.setFontColor(this.m_defaultFontColor);
this.setBold(this.m_isBold);
this.setItalics(this.m_isItalics);
this.setUnderline(this.m_isUnderline);
ui.connectEvent(this.m_element,"keypress",this,"keyPress",true,false);
ui.connectEvent(this.m_element,"keyup",this,"keyUp",true,false);
ui.connectEvent(this.m_element,"keydown",this,"keyDown",true,false)
};
this.setFontFamily=function(b){this.m_fontFamily=b;
this.m_element.style.fontFamily=b
};
this.setFontSize=function(b){this.m_fontSize=b;
this.m_element.style.fontSize=b+"px"
};
this.setFontColor=function(b){this.m_fontColor=b;
this.m_element.style.color=b
};
this.setEditorColor=function(b){this.m_element.style.backgroundColor=b
};
this.setDisabled=function(b){this.m_element.readOnly=b;
this.m_element.value=""
};
this.setUnderline=function(b){this.m_isUnderline=b;
this.m_element.style.textDecoration=(this.m_isUnderline?"underline":"none")
};
this.setBold=function(b){this.m_isBold=b;
this.m_element.style.fontWeight=this.m_isBold?"bold":"normal"
};
this.setItalics=function(b){this.m_isItalics=b;
this.m_element.style.fontStyle=this.m_isItalics?"italic":"normal"
};
this.focus=function(){try{this.m_element.focus()
}catch(b){}moveToEnd(this.m_element);
this.publish("Focused")
};
this.blur=function(){this.m_element.blur()
};
this.reinit=function(){this.clear()
};
this.replaceSelectionWithText=function(e){if(ui.isIE){if(this.m_element!==this.m_win.document.activeElement){this.focus()
}var d=this.m_win.document.selection.createRange();
d.text=e;
d.select()
}else{var f=this.m_element.selectionStart;
var c=this.m_element.selectionEnd;
var b=c-f;
this.m_element.value=this.m_element.value.slice(0,f)+e+this.m_element.value.slice(c);
this.focus();
this.m_element.selectionStart=f+e.length;
this.m_element.selectionEnd=this.m_element.selectionStart
}};
this.clear=function(){this.m_element.value=""
};
this.getText=function(){return this.m_element.value
};
this.setText=function(b){this.m_element.value=b
};
this.getHtml=function(b){return this.formatMessage(b,this.m_element.value)
}
});
Class("ui.richEdit",ui.edit,function(a){this.initialize=function(k,g,f,b,e,h,d,c){a(this,"initialize",[k,g,f,b,e,h,d,c]);
this.m_defaultFontFamily="";
this.m_defaultFontColor="";
this.m_defaultFontSize="";
this.m_defaultHtml="";
this.m_iframe=null;
this.m_frameDoc=null;
this.m_range=null;
this.m_onKeyPress=[]
};
this.createContent=function(){this.m_defaultFontFamily=this.m_fontFamily;
this.m_defaultFontColor=this.m_fontColor;
this.m_defaultFontSize=this.m_fontSize;
this.m_element.innerHTML='<iframe frameborder="0" class="uiRichEdit"></iframe>';
this.m_element.className=this.m_editClass;
this.m_element.ptr=this;
this.m_element.setAttribute("control","ui.richEdit");
this.m_iframe=this.m_element.getElementsByTagName("iframe")[0];
var b=this;
if(!ui.isIE){this.m_iframe.onload=function(){this.onload=null;
b.initIframe()
}
}else{this.m_iframe.onreadystatechange=function(){if(b.m_iframe.contentWindow.document.readyState=="complete"){this.onreadystatechange=null;
b.initIframe()
}}
}this.m_iframe.src="blank.html"
};
this.initIframe=function(){if(ui.isIE){this.initIframeIE()
}else{var b=this;
setTimeout(function(){b.initIframeNS()
},0)
}};
this.initIframeIE=function(){this.m_frameDoc=this.m_iframe.contentWindow.document;
if(this.m_frameDoc){this.m_frameDoc.designMode="on";
this.m_frameDoc=this.m_iframe.contentWindow.document;
this.initRichEdit(this.m_defaultHtml);
if(this.m_frameDoc.body){this.m_frameDoc.body.focus()
}}};
this.setSize=function(b,c){this.m_element.style.width=b+"px";
this.m_element.style.height=c+"px";
if(ui.isIE){this.m_iframe.style.width=(b-1)+"px";
this.m_iframe.style.height=(c-1)+"px"
}};
this.initIframeNS=function(){this.m_iframe.contentDocument.designMode="on";
this.m_frameDoc=this.m_iframe.contentDocument;
this.initRichEdit(this.m_defaultHtml);
this.command("useCSS",false)
};
this.initRichEdit=function(b){if(!b){b=""
}var c='<html>					<head>					<style>					body {						margin: 2px;						word-wrap: break-word;						font-family: Tahoma, Arial, sans serif;						font-size: 11px;						color: #000000;						background-color: #FFFFFF;					}					</style>					<!--[if IE]><style type="text/css">p { margin: 0; }</style><![endif]-->					</head>					<body>'+b+"</body>					</html>";
if(this.m_frameDoc){this.m_frameDoc.open();
this.m_frameDoc.write(c);
this.m_frameDoc.close();
this.connectEvents()
}else{this.m_defaultHtml=b
}};
this.connectEvents=function(){attachIframeMouseHandlers(this.m_iframe,hitch(this,"mouseMove"),hitch(this,"mouseDown"),null);
ui.connectEvent(this.m_frameDoc,"keyup",this,"keyUp",true,false);
if(ui.isIE){ui.connectEvent(this.m_frameDoc.body,"beforedeactivate",this,"onBlur",true,false)
}};
this.command=function(f,c){var b=this.m_iframe.contentWindow;
if(!c){c=""
}try{b.focus();
b.document.execCommand(f,false,c);
b.focus()
}catch(d){}};
this.queryCommand=function(d){var b=this.m_iframe.contentWindow;
try{if(d=="bold"||d=="italic"||d=="underline"){return b.document.queryCommandState(d)
}else{return b.document.queryCommandValue(d)
}}catch(c){}};
this.setFontType=function(b,c){this.m_fontType=c;
this.setFontFamily(c)
};
this.setFontFamily=function(b){if(this.m_range){this.m_range.select()
}this.m_fontFamily=b;
this.command("fontname",b);
this.updateFormatting()
};
this.setFontSize=function(b){if(this.m_range){this.m_range.select()
}this.m_fontSize=b;
this.command("fontsize",this.fontToHTMLSize(this.m_fontSize));
this.updateFormatting()
};
this.setFontColor=function(b){this.m_fontColor=b;
this.command("forecolor",b);
this.updateFormatting()
};
this.setUnderline=function(b){this.command("underline","");
this.updateFormatting()
};
this.setBold=function(b){this.command("bold","");
this.updateFormatting()
};
this.setItalics=function(b){this.command("italic","");
this.updateFormatting()
};
this.replaceSelectionWithText=function(d){if(ui.isIE){if(!this.m_range){this.m_range=this.m_frameDoc.selection.createRange()
}this.m_range.select();
this.m_range.pasteHTML(d);
this.m_range.moveStart("character",-d.length);
this.setFormatting();
this.m_range.collapse(false);
this.m_range.select()
}else{this.command("insertHTML",d);
var c=this.m_iframe.contentWindow.getSelection();
if(c.getRangeAt){var b=this.m_iframe.contentWindow.getSelection().getRangeAt(0);
b.setStart(b.startContainer,b.startOffset-d.length);
this.setFormatting();
var b=this.m_iframe.contentWindow.getSelection().getRangeAt(0);
this.m_iframe.contentWindow.getSelection().collapse(b.endContainer,b.endOffset)
}}};
this.setFormatting=function(){if(this.m_isBold){this.command("bold")
}if(this.m_isItalics){this.command("italic")
}if(this.m_isUnderline){this.command("underline")
}this.setFontFamily(this.m_fontFamily);
this.setFontColor(this.m_fontColor);
this.setFontSize(this.m_fontSize)
};
this.getValue=function(){if(!this.m_frameDoc){return""
}var b=this.m_frameDoc.body.innerHTML;
if(ui.isIE){b=b.replace(/<\/p>/ig,"<br>").replace(/<p>/ig,"")
}return b
};
this.setValue=function(b){if(!b){b=""
}if(ui.isIE){b=b.replace(/<\/p>/ig,"<br><br>").replace(/<p>/ig,"")
}this.initRichEdit(b)
};
this.getFormattingFromSelection=function(){var b={};
b.fontFamily=this.queryCommand("fontname");
if(!b.fontFamily){b.fontFamily=this.m_defaultFontFamily
}b.fontSize=this.queryCommand("fontsize");
if(!b.fontSize){b.fontSize=this.m_defaultFontSize
}else{b.fontSize=this.HTMLToFontSize(parseInt(b.fontSize))
}b.fontColor=this.queryCommand("forecolor");
if(!b.fontColor){b.fontColor=this.m_defaultFontColor
}b.bUnderline=this.queryCommand("underline");
b.bBold=this.queryCommand("bold");
b.bItalics=this.queryCommand("italic");
return b
};
this.updateFormatting=function(){var b=this.getFormattingFromSelection(this);
this.publish("FormatChange",b.fontFamily,b.fontSize,b.fontColor,b.bBold,b.bItalics,b.bUnderline)
};
this.mouseMove=function(b){this.updateFormatting();
return true
};
this.mouseDown=function(b){this.updateFormatting();
return true
};
this.keyUp=function(b){this.updateFormatting();
if(this.m_onKeyPress){doFunctions(this.m_onKeyPress,b,this)
}return true
};
this.onBlur=function(){this.m_range=this.m_frameDoc.selection.createRange()
}
});
Class("ui.timerMgr",function(){this.initialize=function(){this.m_msec=125;
this.m_timerFncs={};
this.m_timerId=0;
this.m_timerInterval=setInterval(hitch(this,"timerFnc"),this.m_msec)
};
this.addTimer=function(b,a){var c=this.m_timerId++;
this.m_timerFncs[String(c)]={f:b,t:Math.round(a/this.m_msec),et:0};
return c
};
this.removeTimer=function(a){delete this.m_timerFncs[String(a)]
};
this.timerFnc=function(){for(var a in this.m_timerFncs){this.m_timerFncs[a].et++;
if(this.m_timerFncs[a].et>=this.m_timerFncs[a].t){try{this.m_timerFncs[a].et=0;
this.m_timerFncs[a].f()
}catch(b){}}}}
});
Class("ui.ImageChooser",ui.menuheader,function(a){this.initialize=function(h,d,f,b,e,g,c){a(this,"initialize",[h]);
this.m_control="uiImageChooser";
this.m_img=d;
this.m_imageWidth=f;
this.m_imageHeight=b;
this.m_numColumns=g.length<e?g.length:e;
this.m_numRows=Math.ceil(g.length/this.m_numColumns);
this.m_images=g;
this.m_className=c||"";
this.m_bShrinkToSize=true;
this.m_menuWidth=(this.m_numColumns*this.m_imageWidth)+((this.m_numColumns+1)*4)-2
};
this.createContent=function(){a(this,"createContent");
this.m_bStatic=true;
this.createDOMNode();
this.m_label.m_force=true;
this.setImage(this.m_img||this.m_images[0],this.m_imageWidth,this.m_imageHeight);
this.m_label.getTextO().style.padding="0";
this.m_centerDiv.style.overflow="hidden"
};
this.createDOMNode=function(){a(this,"createDOMNode");
this.removeClassName("uiMenuHeader");
this.addClassName("uiImageChooser "+this.m_className);
this.m_dropDownImg=createImg(getUniqueId(),this.m_centerDiv,10,10,this.m_dropDownImgSrc,"",true);
this.m_dropDownImg.className="dropDownImg";
this.m_centerDiv.appendChild(this.m_dropDownImg)
};
this.createMenuBody=function(){var c=a(this,"createMenuBody");
var b=new ui.ImagePaletteMenuItem(this.m_imageWidth,this.m_imageHeight);
b.create(this.getId()+"-images",c.m_element,"",this.m_images,this.m_numRows,this.m_numColumns);
c.appendMenuItem(b);
return c
}
});
Class("ui.ImagePaletteMenuItem",ui.menuItem,function(a){this.initialize=function(b,c){a(this,"initialize");
this.m_iconWidth=b;
this.m_iconHeight=c;
this.m_descriptionHeight=13;
this.m_rows=0;
this.m_columns=0;
this.m_icons=[];
this.m_iconSpacing=3
};
this.create=function(h,f,g,d,e,c,b){a(this,"create",[h,f,null,g,null]);
this.m_rows=e;
this.m_columns=c;
this.m_icons=d;
this.m_description=b||"";
this.m_highlightColor=null;
this.m_width=(this.m_iconWidth*this.m_columns)+(this.m_iconSpacing*(this.m_columns+1));
this.m_height=(this.m_iconHeight*this.m_rows)+(this.m_iconSpacing*(this.m_rows+1))+2;
if(this.m_description){this.m_height+=this.m_descriptionHeight
}if(f&&this.constructor==ui.ImagePaletteMenuItem){this.createDOMNode(f)
}};
this.createDOMNode=function(c){this.m_win=gWin(c);
if(!this.m_element){this.m_element=this.m_win.document.createElement("table");
this.m_element.ptr=this;
c.appendChild(this.m_element)
}this.addClassName("uiIconMenuItem");
var g=this.m_win.document.createElement("tbody");
this.m_element.appendChild(g);
if(this.m_description){var n=this.m_win.document.createElement("tr");
var k=this.m_win.document.createElement("td");
addClassName(k,"itemDescription");
k.colSpan=this.m_columns;
k.appendChild(setText(this.m_win.document.createElement("div"),this.m_description));
n.appendChild(k);
g.appendChild(n)
}for(var h=0,m=0;
h<this.m_rows;
h++){var l=this.m_win.document.createElement("tr");
for(var e=0;
e<this.m_columns;
e++){var o=this.m_icons[m];
if(!o){break
}var d=this.m_win.document.createElement("td");
var f=this.m_win.document.createElement("img");
f.src=o;
f.width=this.m_iconWidth;
f.height=this.m_iconHeight;
var b=d.appendChild(this.m_win.document.createElement("div"));
b.appendChild(f);
l.appendChild(d);
m++
}g.appendChild(l)
}};
this.unselect=function(){a(this,"unselect");
var c=this.m_element.getElementsByTagName("td");
for(var b=0,d;
(d=c[b]);
b++){removeClassName(d,"selected")
}};
this.aquireTarget=function(b){var c=b.target||b.srcElement;
while(c&&c!=this.m_element&&c.nodeName!="TD"){c=c.parentNode
}return(c&&c.nodeName=="TD"?c:null)
};
this.onMouseOver=function(b){if(!a(this,"onMouseOver")){return
}var c=this.aquireTarget(b);
if(c){addClassName(c,"selected")
}};
this.onMouseOut=function(b){if(!a(this,"onMouseOut")){return
}var c=this.aquireTarget(b);
if(c){removeClassName(c,"selected")
}};
this.onMouseUp=function(d,c){var g=this.aquireTarget(d);
if(!g){return
}var b=g.firstChild.firstChild;
var f=b.src.replace(/^http:\/\/icons\.meebo\.com\/stock\//,"");
removeClassName(g,"selected");
this.m_element.style.backgroundColor="";
this.m_parent.onParentMouseUp(this.m_preImg.src,this.m_text,f);
if(d){ui.setEventHandled(d)
}return false
}
});
Class("ui.IconChooser",ui.ImageChooser,function(a){this.initialize=function(e,b){var d=[];
for(var c=0;
c<gDefaultBuddyIcons.length;
c++){d[c]=(window.location.protocol=="https:"?"https://origin-":"http://")+"icons.meebo.com/stock/"+gDefaultBuddyIcons[c]
}a(this,"initialize",[e,b,48,48,3,d]);
this.m_control="uiIconChooser";
this.m_recentIconsItem=null;
this.m_clearIconItem=null;
this.m_bDelayMenu=true;
this.m_hasDisabledImage=false;
this.m_dropDownImgSrc=null
};
this.createDOMNode=function(){a(this,"createDOMNode");
this.m_dropArrow=this.m_win.document.createElement("div");
addClassName(this.m_dropArrow,"dropArrow");
this.m_element.appendChild(this.m_dropArrow);
ui.connectEvent(this.m_dropArrow,"mouseover",this,"onMouseOver",true,true);
ui.connectEvent(this.m_dropArrow,"mouseout",this,"onMouseOut",true,true);
ui.connectEvent(this.m_dropArrow,"mousedown",this,"onMouseDown",true,true);
ui.connectEvent(this.m_dropArrow,"mouseup",this,"onMouseUp",true,true)
};
this.onMouseOver=function(){if(this.m_isDisabled){return
}a(this,"onMouseOver",arguments);
addClassName(this.m_dropArrow,"dropArrow-hot")
};
this.onMouseOut=function(){a(this,"onMouseOut",arguments);
removeClassName(this.m_dropArrow,"dropArrow-hot")
};
this.setDisabled=function(b){a(this,"setDisabled",arguments);
toggleClassName(this.m_dropArrow,b,"dropArrow-disabled")
};
this.createMenuBody=function(){var c=a(this,"createMenuBody");
this.addRecentIcons(c);
this.m_clearIconItem=new ui.menuItem();
this.m_clearIconItem.create(this.getId()+"-clearIconItem",c.m_element,null,"Clear Icon",null,this.m_menuWidth,"clear");
c.appendMenuItem(this.m_clearIconItem);
var b=new ui.FileUploadMenuItem();
b.create(this.getId()+"-fileUploadItem",c.m_element,null,"Custom Icon...",this.m_menuWidth);
c.appendMenuItem(b)
};
this.addRecentIcons=function(c){if(this.m_recentIconsItem){return
}var b=gPrefs.getLongPref("buddyIcons");
if(b&&b.length){this.m_recentIconsItem=new ui.ImagePaletteMenuItem(48,48);
this.m_recentIconsItem.create(this.getId()+"-recentIconsItem",c.m_element,"Recent Icons",b,Math.ceil(b.length/this.m_numColumns),this.m_numColumns,gLang.recentIcons);
c.appendMenuItem(this.m_recentIconsItem,this.m_clearIconItem||null)
}};
this.onMouseUp=function(b){if(gLogon.getMeeboUser()){a(this,"onMouseUp",arguments)
}else{this.m_tooltip=this.m_tooltip||new meeboApp.AccountUpsellTooltip(gLang.BuddyIcon,gLang.youNeedMeeboAccount);
this.m_tooltip.showAt(this.getElement(),this.m_tooltip.BELOW);
ui.setEventHandled(b)
}};
this.showMenu=function(b){this.addRecentIcons(this.m_menuBody);
a(this,"showMenu",arguments)
};
this.closeMenu=function(){a(this,"closeMenu");
if(this.m_recentIconsItem){this.m_menuBody.removeMenuItem(this.m_recentIconsItem.getId());
this.m_recentIconsItem=null
}}
});
Class("ui.FileUploadMenuItem",ui.menuItem,function(a){this.initialize=function(){a(this,"initialize");
this.m_clipDiv;
this.m_fileInput
};
this.create=function(e,d,b,c){a(this,"create",arguments);
if(d&&this.constructor==ui.FileUploadMenuItem){this.createDOMNode(d)
}};
this.createDOMNode=function(d){a(this,"createDOMNode",arguments);
this.m_element.style.overflow="hidden";
this.m_element.style.position="relative";
var b=this.m_win.document.createElement("div");
b.style.position="absolute";
b.style.overflow="hidden";
if(ui.isWebKit){b.style.width=b.style.height="0";
b.style.left=b.style.top="-999px"
}else{b.style.width=this.m_width+"px";
b.style.height=this.m_height+"px";
b.style.left=b.style.top="0";
util.css.setOpacity(b,0)
}this.m_clipDiv=b;
var c=this.createFileInput();
this.m_element.appendChild(b)
};
this.createFileInput=function(){if(this.m_fileInput&&this.m_fileInput.parentNode==this.m_clipDiv){this.m_clipDiv.removeChild(this.m_fileInput)
}var b=this.m_win.document.createElement("input");
this.m_fileInput=b;
b.type="file";
b.name="file";
b.accept="image/jpeg,image/gif,image/png";
ui.connectEvent(b,"change",this,"submitIcon",true,true);
b.style.fontSize="60pt";
b.style.position="absolute";
b.style.top=b.style.right="0";
this.m_clipDiv.appendChild(b);
return b
};
this.onMouseUp=function(c,b){if(ui.isWebKit){this.m_fileInput.click()
}else{}};
this.isFileExtensionAllowed=function(){if(!ui.isWin){return true
}var b=this.m_fileInput.value;
if(b&&b.lastIndexOf(".")!=-1){var c=b.substring(1+b.lastIndexOf(".")).toLowerCase();
return(c=="jpg"||c=="gif"||c=="png"||c=="bmp"||c=="jpeg")
}return true
};
this.submitIcon=function(){var b=null;
if(this.isFileExtensionAllowed()){b=this.m_fileInput;
this.createFileInput()
}else{gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.buddyIconErrorHeader},gLang.buddyIconErrorExt)
}this.m_parent.onParentMouseUp(this.m_preImg.src,this.m_text,b)
}
});
Class("ui.Form",ui.element,function(a){this.initialize=function(b,c){c=c||{};
var d=this.m_win.document.createElement("div");
addClassName(d,"uiForm");
a(this,"initialize",[d]);
b.appendChild(d);
this.m_handler=c.handler;
this.m_items=[];
if(c.items){this.addItems(c.items)
}};
this.addItems=function(b){for(var c=0;
c<b.length;
c++){this.addItem(b[c])
}};
this.addItem=function(b){if(b){this.m_items.push(b)
}};
this.initContent=function(){a(this,"initialize");
for(var b=0;
b<this.m_items.length;
b++){this.createField(this.m_items[b])
}};
this.createField=function(f){if(f.type=="radio"){var h=this.createWrapper("options field","",f.label);
for(var e=0;
e<f.options.length;
e++){var g="radio"+getUniqueId();
var d=this.m_win.document.createElement("span");
d.innerHTML='<input type="radio" name="'+f.name+'" value="'+f.options[e]+'" id="'+g+'"></input>';
var b=this.createWrapper("radio",f.options[e],null,g);
b.insertBefore(d,b.firstChild);
h.appendChild(b)
}}else{if(f.type=="text"){var h=this.createWrapper("text field",f.name,f.label);
var c=this.m_win.document.createElement("input");
c.type="text";
h.appendChild(c);
h.name=f.name
}else{if(f.type=="submitlink"){var h=this.m_win.document.createElement("div");
addClassName(h,"submitlink field");
setText(h,f.text);
ui.connectEvent(h,"click",this,"onSubmit");
ui.attachEvent(h,"mouseover",hitch(this.m_win,"addClassName",h,"underline"));
ui.attachEvent(h,"mouseout",hitch(this.m_win,"removeClassName",h,"underline"))
}}}f.m_element=h;
this.m_element.appendChild(h)
};
this.createWrapper=function(c,d,e,g){var f=this.m_win.document.createElement("div");
addClassName(f,c);
var b=escapeHTML(e?e:d);
f.innerHTML='<label for="'+g+'">'+b+"</label>";
return f
};
this.onSubmit=function(){var d={};
var e=true;
for(var b=0;
b<this.m_items.length;
b++){var c=this.getItemValue(this.m_items[b]);
if(this.m_items[b].verify&&!this.m_items[b].verify(c)){addClassName(this.m_items[b].m_element,"invalid");
e=false
}else{removeClassName(this.m_items[b].m_element,"invalid")
}d[this.m_items[b].name]=c
}if(e){this.m_handler(d)
}};
this.getItemValue=function(d){var c=d.m_element.getElementsByTagName("input");
if(d.type=="radio"){for(var b=0;
b<c.length;
b++){if(c[b].checked){return c[b].value
}}}else{if(d.type=="text"){return c[0].value
}}return
}
});
Class("ui.WizardPage",ui.element,function(a){this.initialize=function(b){a(this,"initialize");
this.m_parent=b
};
this.getElement=function(){var c=!this.m_element;
var b=this.m_element||(this.m_element=$(String(this.getId())));
if(c){this.initContent()
}return b
};
this.getBody=function(){return this.getElement()
};
this.setId=function(b){this.m_id=b
};
this.showPage=function(b){this.getBody().style.display=b?"block":"none"
};
this.isVisible=function(){return this.getBody().style.display=="block"
};
this.getTemplate=function(){return""
};
this.initContent=function(){};
this.getValues=function(){return{}
};
this.validateInputs=function(b){return true
}
});
Class("ui.WizardDlg",ui.element,function(a){this.initialize=function(){a(this,"initialize");
this.m_okText=gLang.okBtn;
this.m_pages=[];
this.m_visiblePage=0
};
this.setOkText=function(b){this.m_okText=b
};
this.addPage=function(b){this.m_pages.push(b)
};
this.getPages=function(){return this.m_pages
};
this.getCurrentPage=function(){return this.m_visiblePage
};
this.initContent=function(){this.initButtons();
this.showPage(0);
return true
};
this.getTemplate=function(){var e=this.getId();
var b=[];
for(var d=0;
d<this.m_pages.length;
d++){this.m_pages[d].setId(this.getPageId(d))
}for(var d=0;
d<this.m_pages.length;
d++){b.push('<div id="'+this.getPageId(d)+'" class="createGroupChatPage">'+this.m_pages[d].getTemplate()+"</div>")
}var c='</div><div id="'+e+'-buttonContainer" 			style="position: absolute; bottom: 0px; right: 8px;"></div>';
return b.join("")+c
};
this.getPageId=function(b){return this.getId()+"-page"+b
};
this.initButtons=function(){var c=this.getId();
var b=getPartFromElement(this.m_element,c+"-buttonContainer");
this.m_backBtn=new ui.button(c+"-backbutton",gLang.backTT).create(this.m_win).addClassName("createBuddyListBackBtn");
this.m_backBtn.addOnMouseUp(hitch(this,"onBack"));
b.appendChild(this.m_backBtn.getElement());
this.m_nextBtn=new ui.button(c+"-nextbutton",gLang.nextTT).create(this.m_win);
this.m_nextBtn.addOnMouseUp(hitch(this,"onNext"));
b.appendChild(this.m_nextBtn.getElement())
};
this.showPage=function(b){this.m_backBtn.setDisplay(Boolean(b));
if(b!=this.m_pages.length-1){this.m_nextBtn.setText(gLang.nextTT)
}else{this.m_nextBtn.setText(this.m_okText)
}this.m_pages[this.m_visiblePage].showPage(false);
this.m_pages[b].showPage(true);
this.m_visiblePage=b
};
this.onBack=function(){if(!this.m_visiblePage){return
}this.showPage(this.m_visiblePage-1)
};
this.onNext=function(){var b=this.m_pages[this.m_visiblePage].getValues();
if(this.m_pages[this.m_visiblePage].validateInputs(b)){if(this.m_visiblePage==this.m_pages.length-1){this.onOK()
}else{this.showPage(this.m_visiblePage+1)
}}};
this.onOK=function(){}
});
Class("ui.TrackingPixel",function(){this.initialize=function(a,e,c,d){a=a||{};
if(!e&&"gBucketMgr" in window&&gBucketMgr.isActive&&gBucketMgr.bckt){a.bckt=gBucketMgr.bckt
}keyValues=[];
for(var b in a){keyValues.push(b+"="+encodeURIComponent(a[b]))
}if(!c){keyValues.push("tm="+Math.floor(Math.random()*1000000))
}this.m_keyValues=keyValues;
this.m_baseUrls=(!e?[document.location.protocol+"//rd.meebo.com/b.gif"]:(!isArray(e)?[e]:e));
this.m_useScriptTag=d
};
this.setParent=function(a){this.m_parent=a;
return this
};
this.create=function(a){this.m_win=a||window;
this.applyToUrls(hitch(this,this.m_useScriptTag?"createScript":"createPixel"))
};
this.createPixel=function(c){var b=this.m_win.document;
var a=b.createElement("img");
a.style.position="absolute";
a.style.top="-1000px";
a.style.left="-1000px";
a.onload=hitch(this,function(){a.onload=null;
removeElement(a)
});
a.src=c;
(this.m_parent||b.body).appendChild(a)
};
this.createScript=function(c){var b=this.m_win.document;
var a=b.createElement("script");
a.type="text/javascript";
a.src=c;
(this.m_parent||b.body).appendChild(a)
};
this.applyToUrls=function(c){var e=window.document;
for(var b=0,a;
(a=this.m_baseUrls[b]);
b++){if(e.location.protocol=="https:"){a=a.replace("http:","https:")
}var d=(this.m_keyValues.length?("?"+this.m_keyValues.join("&")):"");
c(a+d)
}};
this.getUrls=function(){var a=[];
this.applyToUrls(hitch(a,"push"));
return a
}
});
Class("ui.Lightbox",ui.element,function(a){this.m_width=520;
this.m_height=300;
this.initialize=function(){this.createHandler("Hide")
};
this.initContent=function(){this.m_element=this.m_win.document.createElement("div");
this.m_content=this.m_win.document.createElement("div");
addClassName(this.m_element,"uiLightbox");
addClassName(this.m_content,"content");
this.resize();
this.createOverlayBackground();
this.createContent();
this.updatePosition();
this.m_win.document.body.appendChild(this.m_element)
};
this.resize=function(){this.m_content.style.height=this.m_height+"px";
this.m_content.style.width=this.m_width+"px"
};
this.createOverlayBackground=function(){var b=this.m_win.document.createElement("div");
addClassName(b,"overlayBackground");
util.css.setOpacity(b,0.8);
this.m_element.appendChild(b)
};
this.createContent=function(){this.m_content=this.m_win.document.createElement("div");
this.m_element.appendChild(this.m_content)
};
this.updatePosition=function(){var b=ui.getClientRect(this.m_win);
this.m_content.style.top=Math.floor(b.h/2-this.m_height/2)+"px";
this.m_content.style.left=Math.floor(b.w/2-this.m_width/2)+"px";
this.setStyle("zIndex",gWindowMgr.getTopZIndex())
};
this.hide=function(){this.m_element.style.display="none";
this.onHide()
}
});
ui.Wallpaper=Singleton(function(){this.initialize=function(){this.m_currentWallpaper=null
};
this.setWallpaper=function(b,g){this.setConsoleGradient(Boolean(b)&&!g);
var a=(b&&window.location.protocol=="https:")?b.replace(/^http:\/\/share/i,"https://origin-share"):b,f=b&&b.indexOf(".swf")==b.length-4;
var e=$("BackgroundImage");
if(!b||(e&&(e.tagName.toLowerCase()!=(f?"object":"img")))){removeElement(e);
e=null;
document.body.style.backgroundImage="";
document.body.style.backgroundRepeat=""
}this.m_currentWallpaper=null;
if(!b||f&&(ui.isLinux||!util.flash||util.flash.getVersion().major<7)){return
}if(f){if(!e){e=document.createElement("div");
e.id="BackgroundImage";
var d=e.style;
d.position="absolute";
d.left=d.right="0px";
d.width="100%";
d.height="100%"
}document.body.insertBefore(e,document.body.firstChild);
var h={};
h.win=window;
h.parent=e;
h.swfUrl=a;
h.id="LivePaper";
h.onReady=hitch(this,"onFlashReady");
h.width="100%";
h.height="100%";
this.m_currentWallpaper={url:b,el:util.flash.embed(h)};
var c=util.flash.getParent(this.m_currentWallpaper.el);
c.style.width=c.style.height="100%"
}else{if(ui.isSafari>=3||ui.isFirefox>=3||ui.isOpera>=9||ui.isChrome){if(!e){e=document.createElement("img");
e.id="BackgroundImage";
var d=e.style;
d.position="absolute";
d.left=d.right="0px";
d.width="100%";
d.height="auto";
d.maxWidth="2056px";
d.minWidth="1024px";
d.display="none"
}document.body.insertBefore(e,document.body.firstChild);
e.style.display=b?"block":"none";
e.src=b?a:"";
this.m_currentWallpaper={url:b,el:e}
}else{document.body.style.backgroundImage=b?"url("+a+")":"";
document.body.style.backgroundRepeat=b?"repeat":"repeat-x"
}}};
this.setConsoleGradient=function(a){var b=$("ConsoleGradient");
if(!b){b=document.createElement("div");
b.id="ConsoleGradient";
addClassName(b,"ConsoleBlackGradient")
}document.body.insertBefore(b,document.body.firstChild);
b.style.display=a?"block":"none"
};
this.getCurrentUrl=function(){return this.m_currentWallpaper?this.m_currentWallpaper.url:null
};
this.getCurrentEl=function(){return this.m_currentWallpaper?this.m_currentWallpaper.el:null
}
});
Class("ui.Tooltip",ui.Element,function(a){this.m_fadeInDuration=300;
this.m_fadeOutDuration=100;
this.m_arrowOffset=26;
this.ON_RIGHT="onRight";
this.BELOW="below";
this.createContent=function(){this.addClassName("Tooltip");
var b=this.m_element.appendChild(this.m_win.document.createElement("table"));
this.m_tbody=b.appendChild(this.m_win.document.createElement("tbody"));
this.createBorderRow("top");
this.createContentRow();
this.createBorderRow("bottom");
this.createCloseButton();
this.createArrow();
this.setOpacity(0)
};
this.createBorderRow=function(c){var b=this.m_tbody.appendChild(this.m_win.document.createElement("tr"));
addClassName(b,c);
var f=b.insertCell(-1);
var e=b.insertCell(-1);
var d=b.insertCell(-1);
addClassName(f,"left");
addClassName(e,"middle");
addClassName(d,"right")
};
this.createContentRow=function(){var d=this.m_tbody.appendChild(this.m_win.document.createElement("tr"));
var e=d.insertCell(-1);
var c=d.insertCell(-1);
var b=d.insertCell(-1);
addClassName(d,"contentRow");
addClassName(e,"left");
addClassName(c,"middle");
addClassName(b,"right");
this.m_content=c.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_content,"content")
};
this.createCloseButton=function(){var c=this.m_content.appendChild(this.m_win.document.createElement("div"));
addClassName(c,"close");
var b=hitch(this,function(d){ui.setEventHandled(d);
addClassName(c,"close-down")
});
ui.connectEvent(c,"mouseover",this.m_win,"addClassName",false,true,"close-hot");
ui.connectEvent(c,"mouseout",this.m_win,"removeClassNames",false,true,"close-hot","close-down");
ui.connectEvent(c,"click",this,"hide");
ui.connectEvent(c,"mouseup",this.m_win,"removeClassName",false,true,"close-down");
ui.connectEvent(c,"mousedown",this,b,true)
};
this.createArrow=function(){this.m_arrow=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_arrow,"arrow")
};
this.getContent=function(){return this.m_content
};
this.setArrowOffset=function(b){this.m_arrowOffset=b
};
this.isVisible=function(){return this.m_visible||false
};
this.showAt=function(d,e){this.create(this.m_win||window);
this.m_element.style.visibility="hidden";
this.setDisplay(true);
this.m_win.document.body.appendChild(this.m_element);
this.setPositionClassName(e);
var b=posWithRespectTo(d);
switch(e){case this.BELOW:var c=b.x+b.w/2;
this.m_arrow.style.top=0;
this.m_arrow.style.left=Math.floor((this.m_arrowOffset-this.m_arrow.offsetWidth/2))+"px";
this.m_element.style.top=(b.y+b.h)+"px";
this.m_element.style.left=(c-this.m_arrowOffset)+"px";
break;
case this.ON_RIGHT:default:var c=b.y+b.h/2;
this.m_arrow.style.left=0;
this.m_arrow.style.top=Math.floor((this.m_arrowOffset-this.m_arrow.offsetHeight/2))+"px";
this.m_element.style.left=(b.x+b.w)+"px";
this.m_element.style.top=(c-this.m_arrowOffset)+"px";
break
}this.m_element.style.visibility="visible";
this.checkWindowOverflow(e);
this.show()
};
this.setPositionClassName=function(b){this.removeClassName("Tooltip-"+this.ON_RIGHT);
this.removeClassName("Tooltip-"+this.BELOW);
this.addClassName("Tooltip-"+b)
};
this.getAnimation=function(){if(this.m_animation){return this.m_animation
}this.m_animation=new ui.Animation();
this.m_animation.addSubject(hitch(this,"setOpacity"));
return this.m_animation
};
this.show=function(){if(ui.Tooltip.currentTooltip&&ui.Tooltip.currentTooltip!=this){ui.Tooltip.currentTooltip.hide()
}ui.Tooltip.currentTooltip=this;
this.m_element.style.zIndex=gWindowMgr.getNextZIndex();
this.setDisplay(true);
if(!ui.isIE){var b=this.getAnimation();
b.setDuration(this.m_fadeInDuration);
b.seekTo(1)
}this.connectGlobalEvents();
gPubSub.subscribe("meebo.EventMgr::changeState",this,"onEventMgrChangeState");
this.m_visible=true
};
this.hide=function(){if(ui.isIE){this.setOpacity(0)
}else{var b=this.getAnimation();
b.setDuration(this.m_fadeOutDuration);
b.seekTo(0)
}this.disconnectGlobalEvents();
gPubSub.unsubscribe("meebo.EventMgr::changeState",this);
this.m_visible=false
};
this.setOpacity=function(b){if(b==0){this.setDisplay(false);
removeElement(this.m_element);
if(ui.Tooltip.currentTooltip==this){ui.Tooltip.currentTooltip=null
}}if(ui.isIE){return
}util.css.setOpacity(this.m_element,b)
};
this.checkWindowOverflow=function(c){var h=9;
var g=ui.getClientRect();
var k=posWithRespectTo(this.m_element);
var f=k.x+k.w+h;
if(f>g.w){var e=g.w-k.w-h;
this.m_element.style.left=e+"px";
if(c==this.BELOW){this.m_arrow.style.left=parseInt(this.m_arrow.style.left)-(e-k.x)+"px"
}}var d=k.y+k.h+h;
if(d>g.h){var b=g.h-k.h-h;
this.m_element.style.top=b+"px";
if(c==this.ON_RIGHT){this.m_arrow.style.top=parseInt(this.m_arrow.style.top)-(b-k.x)+"px"
}}if(k.x<h){this.m_element.style.left=h+"px"
}if(k.y<h){this.m_element.style.top=h+"px"
}};
this.connectGlobalEvents=function(){if(!this.m_isSticky){ui.connectGlobalEvent(gDoc(this.m_win),"mousedown",hitch(this,"onGlobalMouseAction"));
ui.hookEvents.subscribe("mousedown",this,"onGlobalMouseAction")
}};
this.disconnectGlobalEvents=function(){ui.hookEvents.unsubscribe("mousedown",this,"disconnectGlobalEvents");
ui.disconnectGlobalEvent(gDoc(this.m_win),"mousedown")
};
this.onEventMgrChangeState=function(d,b,e,c){if(e!="im"){this.hide()
}};
this.onGlobalMouseAction=function(b){if(isCursorInElement(this.m_element,b)){return true
}this.hide()
};
this.setSticky=function(b){if(this.m_isSticky==b){return
}this.m_isSticky=b;
toggleClassName(this.m_element,b,"Tooltip-sticky");
if(b){this.disconnectGlobalEvents()
}else{this.connectGlobalEvents()
}}
});
ui.Tooltip.currentTooltip=null;
var meeboApp={};
meeboApp.setupRemote=function(){var h=["lgvtk`gq,amo","emkleml,amo","qajogfng{,amo","qgcfpktg,lgv"];
var c=document.location.hostname;
for(var a=0;
a<h.length;
a++){var k=de(h[a]);
var b=k.length+1;
if(c.length<=b){continue
}var g=c.length-b;
var d=c.substr(g).toLowerCase();
if(d=="."+k){document.domain=k;
gRemote.domain=document.domain;
gRemote.setup=true;
if(parent){try{if(parent.meeboConnected){parent.meeboConnected()
}}catch(f){}}break
}}};
meeboApp.dontShowWarning=false;
meeboApp.addNavigateAwayWarnings=function(){window.onbeforeunload=function(b){b=b||window.event;
gPrefs.doPreferenceSync();
if(ui.isIE&&window.__flash_unloadHandler&&window.onunload==window.__flash_unloadHandler){window.onunload=null
}if(b&&gBuddyListDlg&&!gIsGuestGroupChat&&!meeboApp.dontShowWarning&&gEventMgr&&!gIMGateway.getClients({type:"trayicon"}).length&&!gIMGateway.getClients({type:"cim-imbar"}).length&&gLogon&&((gLogon.getLogons({online:true}).length>0)||(gLogon.getLogons({state:"pending"}).length>0)||(gLogon.getLogons({state:"signingoff"}).length>0))){var c=(!meeboApp.isCIMPopout()?gLang.navigateAway:sprintf(gLang.popoutNavigateAway,meeboApp.getPartnerNetwork().getName()));
if(ui.isIE){b.returnValue=c
}return c
}};
var a=function(f){gWindowMgr.closeNonIMWindows();
if(gBuddyListDlg&&gBuddyListDlg.isPoppedOut()){gBuddyListDlg.closeWindow()
}gWindowMgr.updateOfflineWindows();
ui.cleanUp();
if(meeboApp.isCIMPopout()){gUIState.set("popout",{isPoppedOut:false},false,true)
}else{if(gEventMgr.getState() in arrayToObject(["im","reconnecting"])){gPrefs.doPreferenceSync(true);
gNetworkMgr.doRequest("detach",{},null,true)
}}if(ui.isIE){var b=document.getElementsByTagName("OBJECT");
for(var c=0;
c<b.length;
c++){var d=b[c];
for(var g in d){try{if(typeof(d[g])=="function"){d[g]=null
}}catch(f){}}d.style.display="none"
}}net.XHRTransport.destroy()
};
if(ui.isIE){window.attachEvent("onunload",a)
}else{window.onunload=a
}};
meeboApp.serveBigNotifierUpsell=function(){if(ui.isWin&&!this.m_bigNotifierUpsold&&!gIMGateway.getClients({type:"trayicon"}).length&&gConsoleMgr.getMainPage().getMainContainer()){this.m_bigNotifierUpsold=true;
var a=new meeboApp.ConsoleExtensionNotifier();
gConsoleMgr.getMainPage().getMainContainer().addExtension(a);
gIMGateway.subscribe("ClientAttach",this,function(b){if(b.clientType=="trayicon"){gConsoleMgr.getMainPage().getMainContainer().removeExtension(a)
}})
}};
meeboApp.upsellTrayNotifier=function(){var b=util.storage.load("noNotifierThanks");
var a=gPrefs.getPref("noNotifierThanks")&&gLogon.hasMeeboAccount();
if(!b&&!a){meeboApp.serveBigNotifierUpsell()
}};
meeboApp.onEventMgrChangeState=function(c,a,d,b){if(d!="im"&&d!="done"){return
}if(d=="done"){meeboApp.m_seenIM={}
}if(d=="im"){if(util.cookie.load("attachKey")!=gIMGateway.getSessionKey()){util.cookie.save("attachKey",gIMGateway.getSessionKey())
}if(b=="connecting"||b=="logon"){removeElement($("frontPageStyle"));
document.body.style.overflow="hidden";
ui.connectEvent(document,"scroll",meeboApp,"onScroll");
if(!meeboApp.isPopout()&&!gIsGuestGroupChat){gSecurePlatform.sendSessionKey(gIMGateway.getSessionKey())
}if((!gLogon.hasMeeboAccount()||gConsoleMgr.getMainPage().getRegistrationMode())&&window.gTakeover){gConsoleMgr.getMainPage().setTakeoverWallpaper();
if(!gConsoleMgr.getMainPage().getRegistrationMode()){meeboApp.upsellTrayNotifier()
}}else{gPubSub.subscribe("meebo.Prefs::receivePrefs",this,function(f,e,g){if(!("meeboSkin" in g)&&!("enableWallpaper" in g)){gConsoleMgr.getMainPage().setTakeoverWallpaper()
}meeboApp.upsellTrayNotifier();
gPubSub.unsubscribe("meebo.Prefs::receivePrefs",this)
})
}if(gCountry=="US"){Mindset.create(document.documentElement.firstChild)
}}if(b=="reconnecting"&&!gIsGuestGroupChat){gSecurePlatform.sendSessionKey(gIMGateway.getSessionKey())
}gWindowMgr.createBuddyWindow(gLang.buddylist);
if(!gIsGuestGroupChat&&!gWindows["email-import"]&&!gWindows.upsell&&b=="connecting"&&!gConsoleMgr.getMainPage().getRegistrationMode()&&(!meeboApp.isPopout()||util.query.getHashVariable(util.query.SHOW_BLOG)=="true")){gWindowMgr.createWelcomeWindow()
}if(gWait){gWait.hideWait()
}if(b=="connecting"||b=="logon"){if(!gIsGuestGroupChat){window.setTimeout(function(){gApplicationPlatform.openBridge(document.body);
if(!ui.isIE){gSecurePlatform.openBridge(document.body)
}},500)
}}}meeboApp.updateStatusPanelIcon()
};
meeboApp.onMeeboAccountChangeState=function(c,b,d){if(d=="online"){function a(){var g=gLogon.getLogons({meeboChild:true});
if(g.length==1){return
}for(var f=0,e;
(e=g[f]);
f++){if(!e.isMeeboLogon()&&e.hasPassword()){return
}}gWindowMgr.createResetPasswordDlg()
}gPubSub.subscribe("meebo.Logon::changeState",this,function(){setTimeout(a,0);
gPubSub.unsubscribe("meebo.Logon::changeState",this,arguments.callee)
});
if(meebo.applicationMgr){meebo.applicationMgr.loadUser(null)
}if(gWidgets){gWidgets.requestWidgets()
}}};
meeboApp.href=document.location.href;
meeboApp.handleIMNotifications=function(w,buddy,msg,chat,senderString){var isReopen=!w.isVisible();
if(isReopen){gWindowMgr.reopenIMWindow(w)
}senderString=senderString||buddy.getAlias();
if(chat&&w){senderString=w.getWindowCaption()+" - "+senderString
}gBrowser.setFlash(w.m_win,senderString,unescapeHTML(removeHTML(msg)));
var shouldShowNotifier=!w.m_win.m_focus;
if(!w.isActive()||(w.isPoppedOut()&&!w.m_win.m_focus)){w.startFlashWindow();
if(!chat){shouldShowNotifier=true;
gBuddyListDlg.showBuddyMessageFeedback(buddy,true)
}}else{if(buddy.getType()=="buddy"&&w.m_win.m_focus){var conversation=buddy.getConversation();
if(conversation){conversation.resetUnreadCount()
}}}if(!chat||chat.getType()!="chat"){if(!shouldShowNotifier||meeboApp.hasTrayNotifier()){}else{if(ui.isFluid||ui.isPrism){var clickCallback=hitch(this,function(){gWindowMgr.activateWindow(w);
w.restoreMinimizeWindow()
});
util.notifications.displayMessage(senderString,removeHTML(msg),buddy.getIconURL(),"message",clickCallback)
}else{if(meeboApp.util.hasMeeboExtension()){var callback=hitch(this,function(buddy){var w=gWindowMgr.createIMWindow(buddy,true);
if(!w||!w.isPoppedOut||!w.isPoppedOut()){MeeboExtension.showMeeboTab()
}},buddy);
MeeboExtension.showNotification(buddy.getAlias(),removeHTML(msg),buddy.getIconURL(),"message",callback);
if(w){MeeboExtension.showBlink(w.m_win)
}meeboApp.updateStatusPanelIcon()
}}}}if(gPrefs.getPref("audioReceive")||(!gPrefs.getPref("audioSend")&&!gPrefs.getPref("audioReceive")&&!gSounds.isMuted())){gSounds.playSample(w.isMeeboGroupChat()?"room":"receive")
}if(gRemote&&gRemote.setup&&gRemote.callback){if(parent){var mO={msg:removeHTML(msg),sender:buddy.getName(),protocol:buddy.getNetwork()};
try{if(typeof gRemote.callback=="string"){eval("parent."+gRemote.callback+"(mO);")
}else{if(typeof gRemote.callback=="function"){gRemote.callback(mO)
}}}catch(e){}}}return isReopen
};
meeboApp.m_seenIM=[];
meeboApp.dispatchIM=function(a,q,l,c,s,k,h,o,b){var n=gWindowMgr.getConvWindow(s||l);
if(!n){gWindowMgr.createIMWindow(s||l,false,false,callee.call(this,arguments));
return
}if(isNumber(b)){if(meeboApp.m_seenIM[b]){return
}meeboApp.m_seenIM[b]=true
}var m=(q=="meebo.EventMgr::sentIM");
var e=s&&l.getPresence(s);
var d=(m?l.getLogin():(e||l)).getAlias();
if(!m){var g=this.handleIMNotifications(n,l,c,s,d)
}this.moveWindowFromUnderMediaBar(n);
var p=n.m_trees[l.getId()];
var f=n.isGroupChat()&&p&&p.getColor();
n.addHistoryIM(d,c,!m,false,false,f,g,k,h,o);
if(l.updateActivityTime){l.updateActivityTime()
}};
meeboApp.moveWindowFromUnderMediaBar=function(b){var c=b.getWindowPos();
if(gMediaBar.isMaximized()){var a=parseInt(getCSSProp(gMediaBar.getElement(),"z-index"),10)||0;
mediaBarPos=gMediaBar.getPos();
if(c.y+30>mediaBarPos.y&&c.z<a){c.y=mediaBarPos.y-30
}b.setWindowPos(-1,c.y,-1,-1)
}};
meeboApp.updateStatusPanelIcon=function(){if(meeboApp.util.hasMeeboExtension()){if(gEventMgr&&gEventMgr.getState()=="im"){MeeboExtension.setStatus("online");
if(gBuddyListDlg){var a=gBuddyListDlg.getTotalUnreadMessageCount()
}if(a){MeeboExtension.setStatus("unread",a)
}else{if(gBuddyListDlg&&gBuddyListDlg.m_statusMenu){if(gBuddyListDlg.m_statusMenu.getItemValue()=="available"){MeeboExtension.setStatus("online")
}else{MeeboExtension.setStatus("away")
}}}}else{if(gEventMgr&&gEventMgr.inNetworkInterrupt()){MeeboExtension.setStatus("error")
}else{MeeboExtension.setStatus("offline")
}}}};
meeboApp.joinRoom=function(b,m,e,k,l){if(typeof b=="string"){var d=b;
b=gBuddyList.addRoom(d,null,gLogon.getMeeboMeLogon())
}else{d=b.getChatName()
}if(gIsGuestGroupChat&&gNotice.m_flashEnabled&&(gNotice.onNotice(d)||gNotice.isLockedOut())){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.bannedTitle},gLang.bannedFromRoom);
if(l){l(null,false,null)
}return
}b.m_isLeaving=false;
if(m){b.setPassword(m)
}var h=true;
var g=gWindowMgr.getConvWindow(b);
if(!g){var c=gWindowMgr.createIMWindow(b,true)
}else{if(!g.m_isShowingPasswordPrompt){gWindowMgr.createIMWindow(b,true);
if(!g.isOffline()){h=false
}else{g.clearHistory();
g.clearBuddyList();
g.clearMediaList();
g.m_bMediaRequested=false
}}}var f=function(o,n,p){if(l){l(o,n,p)
}if(!n||!o){if(c){c._("showOverlayMessage",gLang.disabledRoom)
}else{if(g){g.showOverlayMessage(gLang.disabledRoom)
}}}};
if(h){var a=gPrefs.getRoomPref(d,"nick")||b.getLogin().getAlias();
runInMainContext(gNetworkMgr,gNetworkMgr.requestJoinRoom,f,d,a,m,e,k)
}return b
};
meeboApp.onChatChangeChatId=function(k,h,c){if(!c){return
}var d=k.getType()=="protocolchat"&&k.getBuddyParent();
var f=gWindowMgr.getConvWindow(k);
if(!f){var b=ui.deferredDlg.getWndOpening(getIMId(d,k.getLogin()));
var e=argsToArray(arguments);
var a=callee;
var g=hitch(this,function(l){a.call(this,e);
l.onChatChangeChatId(k,h,c)
});
if(b){b.addBoth(g)
}else{if(k.constructor==meebo.ApplicationRoom){meeboApp.Application.onAppLoaded(k)
}else{if(k.getType()=="chat"){k.setLastMsg()
}}gWindowMgr.createIMWindow(k,true,false,g)
}}else{if(k.constructor==meebo.ApplicationRoom){if(k.getAbandoned()){if(k&&k.getChatId()){gNetworkMgr.requestChatAction(null,"l",null,k,k.getChatId(),null);
gWindowMgr.unregisterGroupChat(getGroupChatId(k.getProtocol(),k.getUser(),k.getChatId()))
}f.setApplicationRoom(null);
f.onAbandonedApp();
return
}f.setApplicationRoom(k);
k.getApplication().join(k.getChatName())
}else{if(k.getType()=="protocolchat"){f.setImObject(k)
}}}};
meeboApp.onChatInvite=function(b,m,f,o,a,c,k){var n=gBuddyList.getRoomByName(a);
if(m=="meebo.EventMgr::roomInvite"){var h=hitch(this,function(q,p){if(q){n=meeboApp.joinRoom(n||a,k,f.getUser(),f.getProtocol());
n.m_shouldAddToBuddylist=p
}gNetworkMgr.doUILog("roomsinvite",f.getNetwork(),q?"1":"0",true)
});
var e=gLogon.getMeeboMeLogon();
var l=o.length>1?sprintf(gLang.inviteToChatWithMessage,f.getName(),f.getUser(),c,o):sprintf(gLang.inviteToChat,f.getName(),f.getUser(),c);
gWindowMgr.createAcceptDenyDlg({id:getUniqueId()+"-accept",caption:gLang.roomInvite},{buddy:a,protocol:gNetworks.meebome.getProtocol(),logon:e,message:l,joinButtonText:gLang.joinRoom,joinAndAddButtonText:(!n||!n.isOnlist())&&(gLogon.getMeeboUser()?gLang.joinRoomAndAdd:"")},h)
}else{var g=gWindowMgr.getConvWindow(f);
if(!g){gWindowMgr.createIMWindow(f,false,false,callee.call(this,arguments));
return
}var d=this.handleIMNotifications(g,f,o);
g.addAppRoomInvite(o,a,d)
}};
meeboApp.onAppRegister=function(b,a,e,d){var f=gWindowMgr.getConvWindow(e);
if(!f){var c=hitch(this,function(g){g.setApplicationRoom(e);
meeboApp.onAppRegister(b,a,e,d)
});
gWindowMgr.createIMWindow(e,true,false,c);
return
}e.logLoadTime("tojoin");
meeboApp.platform.createAppInstance(e.getChatName(),e);
e.setJoinParams(d.time,d.hash);
f.initApp(e.getApplication())
};
meeboApp.onBuddyAddRequest=function(a,l,e,f,b){var h=function(o,m){var n={user:b,protocol:f,buddy:e,authorized:o};
if(m||(o&&f=="jabber")){n.ad=meebo.util.getDefaultGroup(f)
}gNetworkMgr.doRequest("auth",n,hitch(gNetworkMgr,"receiveAuthBuddy"))
};
var c=f!="jabber"?gLang.acceptBtn:gLang.acceptAndAddBtnTT;
joinAndAdd=f!="jabber"?gLang.acceptAndAddBtnTT:null;
var d=gLogon.getLogon(b,f);
var g=gWindowMgr.createAcceptDenyDlg({id:getUniqueId()+"-accept",caption:gLang.acceptHeader},{buddy:e,logon:d,message:sprintf(gLang.wantsAdd,e+" ("+f+")",b),joinButtonText:c,joinAndAddButtonText:joinAndAdd},h);
if(meeboApp.util.hasMeeboExtension()){var k=hitch(this,function(m){if(!m.isPoppedOut()){MeeboExtension.showMeeboTab();
m.callActivate()
}else{m.m_win.focus()
}},g);
MeeboExtension.showNotification(gLang.acceptHeader,sprintf(gLang.wantsAdd,e+" ("+f+")",b),null,"invitation",k)
}};
meeboApp.preloadImages=function(){var c=["notifyBuddy.gif","buttons/button.hot.center.png","buttons/button.hot.right.png","buttons/button.hot.left.png","buttons/button.down.center.png","buttons/button.down.right.png","buttons/button.down.left.png","buttons/button.disabled.center.png","buttons/button.disabled.right.png","buttons/button.disabled.left.png"];
for(var b=0;
b<c.length;
b++){var a=document.createElement("img");
gImages.requestImage(c[b],a)
}};
meeboApp.initGlobals=function(){gWindows=[];
gTimerMgr=new ui.timerMgr();
gWindowMgr=new meeboApp.WindowMgr();
gConsoleMgr=new meeboApp.consoleMgr();
gInfoDlg=new meeboApp.info();
gSerializer=new lib.serializer();
gSkins=new meeboApp.skins();
gWidgets=new meebo.Widgets();
gDragManager=new ui.drag.DragManager();
gColorMgr=new ui.colorMgr();
gWait=new meeboApp.logonWaitDlg();
gSounds=new ui.soundmanager();
gSounds.init();
DoubleClick=new ads.DoubleClick();
Mindset=new ads.Mindset(".meebo.com",document.referrer);
gTargeting.setTargeting(Mindset.getTargeting());
gNotice=new ui.notice();
gNotice.registerProbationCallback(hitch(gWindowMgr,"checkMuteRooms"));
gUid=new ui.Uid();
gFrontPage=new meeboApp.FrontPage();
gFrontPage.initAudioButton();
gBrowser=new meeboApp.browser();
gBrowser.init();
gBrowser.setFavIconSrc("favicon",window);
gRemote={};
meeboApp.setupRemote();
gIsGuestApplication=meebo.util.getMeeboApplicationLink(document.location)!=null;
gIsGuestGroupChat=meebo.util.getMeeboGroupChatLink(document.location)!=null||gIsGuestApplication;
gIsGuestFileTransfer=Boolean(util.query.getHashVariable(util.query.FILE_ID));
var a=ui.isMac&&isNumber(ui.isFirefox)&&ui.isFirefox<3;
if(!a){gMediaBar=new meeboApp.MediaBar();
gAdTimer=new meeboApp.AdTimer();
gMediaBar.create(document.body)
}gInfoDlg.create();
if(gLog||gEventLog||gNetworkLog){try{gWindowMgr.createDebugDlg()
}catch(b){}}meeboApp.share=new meeboApp.Share();
gApplicationPlatform=new meeboApp.ApplicationPlatform();
gSecurePlatform=new meebo.SecurePlatform();
if(ui.isIE){gSecurePlatform.openBridge(document.body)
}if("twitter" in gProtocols){delete gProtocols.twitter
}if("twitter" in gNetworks){delete gNetworks.twitter
}gAdServer=new ads.Server({MediaBarHouse:{load:function(c){if(!c.keyValuePairs){c.keyValuePairs={}
}c.keyValuePairs["default"]="true";
gAdServer.loadDoubleClickAd("MediaBar",c)
},location:"MediaBar"},MediaBarPartnerOkay:{load:function(c){if(!c.keyValuePairs){c.keyValuePairs={}
}c.keyValuePairs.partner_okay=!c.shareId&&!gSounds.isMuted();
gAdServer.loadDoubleClickAd("MediaBar",c)
},location:"MediaBar"},MediaBar:{load:function(c){gAdServer.loadDoubleClickAd("MediaBar",c)
},location:"MediaBar"},Spark:{load:function(c){gAdServer.loadDoubleClickAd("Spark",c)
},location:"Spark"}});
gFBConnect=new util.FacebookConnect("7c8faedaa52b1651c64f039fb6e4d33c",window,["xmpp_login"],["name"])
};
meeboApp.setBuddyIconUrl=function(b,a){if(gEventMgr.getState()!="im"){return gWindowMgr.createReconnectDlg()
}var c=hitch(this,function(){if(b.type=="file"){gNetworkMgr.requestSetIcon(null,b,null)
}else{if(b.match(/https?:\/\//)){gNetworkMgr.requestSetIcon(null,null,b)
}else{gNetworkMgr.requestSetIcon(b,null,null)
}}});
if(!gLogon.getMeeboUser()){gWindowMgr.createCreateMeeboAccountDlg({caption:gLang.meeboBuddyIconUpsell},"console-icon","upsell_buddyicons.png",c);
if(a){a()
}}else{c()
}};
meeboApp.launchSandbox=function(a){gMediaBar.launchAd({engagedUrl:a,title:"Sandbox",share:"Sandbox"},"sandbox")
};
meeboApp.setStatusMessage=function(a){meeboApp.statusInput.setValue(a)
};
meeboApp.getDisplayName=function(){return gLogon.getLogons()[0].getDisplayName()
};
meeboApp.getBuddyIcon=function(){return document.location.protocol+"//"+document.location.hostname+"/"+gPrefs.getIcon()
};
meeboApp.setWallpaper=function(a,c,b){if(gEventMgr.getState()!="im"){return gWindowMgr.createReconnectDlg()
}gPrefs.savePref("enableWallpaper",true);
gConsoleMgr.getMainPage().setWallpaper(a);
if(c&&b){gPrefs.saveWallpaperPref(c,a,b)
}};
meeboApp.setDontShowWarning=function(a){meeboApp.dontShowWarning=a
};
meeboApp.getPartnerLogon=function(){return meeboApp.m_partnerLogon
};
meeboApp.setPartnerLogon=function(a){meeboApp.m_partnerLogon=a
};
meeboApp.getPartnerNetwork=function(){return meeboApp.m_partnerNetwork
};
meeboApp.setPartnerNetwork=function(a){meeboApp.m_partnerNetwork=a
};
meeboApp.initBasicMeebo=function(){var b=util.query;
meeboApp.mediaBarAdId=b.getHashVariable(b.MEDIABAR_SHARE_ID);
meeboApp.sparkAdId=b.getHashVariable(b.SPARK_SHARE_ID);
if(b.getHashVariable(b.NETWORK) in gNetworks){util.cookie.save("morenetworks",b.getHashVariable(b.NETWORK))
}var c=b.getHashVariable(b.SESSION_KEY);
gClient.setClientType(b.getHashVariable(b.CLIENT_TYPE)||"core");
if(gEventMgr.getState()=="im"){gFrontPage.updateInnerMeebo();
if(gMediaBar){gMediaBar.initContent();
gMediaBar.setDisplay(true)
}gSkins.setSkin(gPrefs.getPref("meeboSkin"));
meeboApp.onEventMgrChangeState(gEventMgr,"meebo.EventMgr::changeState","im")
}else{if(b.getHashVariable(b.FIREFOX_EXTENSION)){window.location.hash="#";
addClassName(document.body,"extensionloggingin");
gWait.showWait(gLang.signOnWait,gImages.getPath()+"wait_ax.gif",document.body);
var a=function(e,d,f){removeClassName(document.body,"extensionloggingin");
if(gWait){gWait.hideWait()
}gPubSub.unsubscribe("meebo.Logon::changeState",this);
gPubSub.unsubscribe("meebo.MeeboAccount::changeState",this);
if(d=="meebo.Logon::changeState"&&f=="error"){gFrontPage.init();
return
}else{if(d!="meebo.Logon::changeState"||f=="online"){if(meeboApp.util.hasMeeboExtension()){MeeboExtension.markSuccessfulLogin()
}gFrontPage.updateInnerMeebo()
}}};
gPubSub.subscribe("meebo.Logon::changeState",meeboApp,a);
gPubSub.subscribe("meebo.MeeboAccount::changeState",meeboApp,a);
gPubSub.subscribe("meebo.EventMgr::changeState",meeboApp,function(e,d,f){if(f=="done"&&gEventMgr.inNetworkInterrupt()){if(gWait){gWait.hideWait()
}removeClassName(document.body,"extensionloggingin");
gPubSub.unsubscribe("meebo::EventMgr::changeState",this)
}})
}else{if(c){meeboApp.initPopoutMeebo(c)
}else{gFrontPage.init()
}}}if(b.getHashVariable(b.PROMPT_SIGNUP)){gWindowMgr.createCreateMeeboAccountDlg({},"frontpage-url","upsell_access.png")
}};
meeboApp.onUIChangeState=function(c,a,b){switch(c){case"popout":if(!a.isPoppedOut){if(b){gUIState.set("popout",{isPoppedOut:true})
}else{meeboApp.dontShowWarning=true;
window.close()
}}break
}};
meeboApp.initPopoutMeebo=function(c){meeboApp.setIsPopout(true);
gUIState.subscribe("ChangeState",meeboApp,"onUIChangeState");
var e=util.query,f=e.getHashVariable(e.AUTH_TOKEN),k=e.getHashVariable(e.USER),h=e.getHashVariable(e.NETWORK),g=e.getHashVariable("locationId");
if(!c){window.location="/";
return true
}if(h){gClient.setClientType("cim-popout");
var a=gNetworks[h];
a.makeLive();
meeboApp.setPartnerNetwork(a);
if(k){var d=gLogon.addLogon(k,a);
if(f){d.setAuthToken(f)
}meeboApp.setPartnerLogon(d)
}util.session.setPartnerAuthToken(e.getHashVariable(e.PARTNER_AUTH_TOKEN))
}if(g){gIMGateway.setLocationId(parseInt(g,10))
}gIMGateway.attach(c,function(o,l){if(l){gPubSub.publish(this,"meeboApp::attached");
gFrontPage.updateInnerMeebo();
gSecurePlatform.getSessionInfoFromTray();
if(meeboApp.isCIMPopout()&&util.session.getMeeboAuthToken()&&util.session.getPartnerAuthToken()){var q=util.session.getPartnerAuthToken();
var u=util.session.getMeeboAuthToken().mat;
var n=gLogon.getLogons();
for(var p=0,t;
t=n[p];
++p){if(t.isMeeboChild()){t.setMeeboAuthToken(u);
t.setPartnerAuthToken(q)
}}var m=gLogon.getMeeboAccount();
m.setMeeboAuthToken(u);
m.setPartnerAuthToken(q)
}}else{if(t){try{window.close()
}catch(s){}}else{gFrontPage.init()
}}});
if(h&&!util.cookie.load("interstitial")){var b=new meeboApp.CIMInterstitial(h);
b.addOnHide(hitch(util.cookie,"save","interstitial","1"));
b.addOnHide(hitch(util.cookie,"save","morenetworks",meeboApp.getPartnerLogon().getNetwork()));
meeboApp.showInterstitial(b)
}};
meeboApp.showInterstitial=function(a){if(gMediaBar){gMediaBar.minimize();
a.addOnHide(hitch(gMediaBar,"midimize"))
}meeboApp.setDontShowWarning(true);
a.addOnHide(hitch(meeboApp,"setDontShowWarning",false));
a.initContent();
gOverlay=a
};
meeboApp.initGuestMeebo=function(){gClient.setClientType("core");
var d=util.query;
var b=d.getHashVariable(d.USER);
var e=d.getHashVariable(d.PROTOCOL);
gWindowMgr.createBuddyWindow(gLang.buddyList);
gBuddyListDlg.setUpsell(e||"aim",b||"");
gFrontPage.updateInnerMeebo();
var c=meebo.util.getMeeboGroupChatLink(document.location)!=null;
var a=meebo.util.getMeeboApplicationLink(document.location)!=null;
if(a){gBuddyListDlg.m_element.style.visibility="hidden"
}gIMGateway.start(hitch(this,function(g,f){if(!f){return
}if(c){this.initGroupChat(b,e)
}else{if(a){this.initApplication(b,e)
}else{this.initFileTransfer()
}}}));
gPubSub.subscribe("meebo.Logon::changeState",meeboApp,function(h,f,k){if(h.isAnonymous()||!h.isOnline()){return
}gIsGuestGroupChat=false;
gIsGuestFileTransfer=false;
gBuddyListDlg.m_element.style.visibility="visible";
gWindowMgr.rightAlignBuddy();
gPubSub.unsubscribe("meebo.Logon::changeState",this);
var g=$("guestDownload");
if(g){g.parentNode.removeChild(g);
if(!meeboApp.GuestDownload.m_errorCode){gWindowMgr.createOkDlg({id:"acceptFile",caption:gLang.fileTransfer},meeboApp.GuestDownload.getHeaderText(),hitch(meeboApp.GuestDownload,"acceptFile"),null,gLang.acceptBtn,null,"file_download.gif")
}gNetworkMgr.doUILog("filetransfer","login","true",true)
}})
};
meeboApp.initGroupChat=function(c,h){var g=util.query;
var k=g.getHashVariable(g.GROUPCHAT_PASSWORD);
var b=g.getHashVariable(g.GROUPCHAT_INVITE_RECEIVED);
if(String(document.location).indexOf("#")!=-1){document.location="#?"
}var a=meebo.util.getMeeboGroupChatLink(document.location);
if(isDefined(b)){gNetworkMgr.doUILog("invite-msg-receive",b,"true",true)
}gEventMgr.setState("im");
var d=hitch(this,function(){if(!gNotice.isLocalStorageEnabled()){var l='<a href="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager03.html" target="_blank">';
gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.sorry,h:160},sprintf(gLang.flashLocalStorageRequired,a,"<br><br>",l,"</a>"));
gNetworkMgr.doUILog("guestroomsinvite",h||"none","nolocalstorage");
return
}meeboApp.joinRoom(a,k,c,h,function(){gNetworkMgr.doUILog("guestroomsinvite",h||"none","1")
})
});
var e=function(){gNetworkMgr.doUILog("meebo","load",(gUILogging?"stats":"nostats")+"-ggc",true,"uid:"+gUid.onUid())
};
if(!gNotice.m_flashEnabled){var f='<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">';
gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.sorry},sprintf(gLang.flashRequiredToJoinRoom,a,f,"</a>"));
gNetworkMgr.doUILog("guestroomsinvite",h||"none","noflash")
}else{gNotice.executeWhenReady(d)
}gUid.executeWhenReady(e)
};
meeboApp.initApplication=function(a,d){var c=util.query;
var e=c.getHashVariable(c.MEEBO_USER);
if(String(document.location).indexOf("#")!=-1){document.location="#?"
}gEventMgr.setState("im");
var b=meebo.util.getMeeboApplicationLink(document.location);
meebo.applicationMgr.loadGuest(hitch(this,function(h,f){if(f){gPubSub.publish(this,"meeboApp::loadGuestIcon",f)
}var g=meeboApp.Application.joinApp(a||null,a||null,d,b,h);
gWindowMgr.createIMWindow(g,true,false,function(k){k.setApplicationRoom(g)
})
}),e,b)
};
meeboApp.initFileTransfer=function(){var a=util.query;
gNetworkMgr.doUILog("filetransfer","guest","true",true);
gWindowMgr.rightAlignBuddy();
meeboApp.GuestDownload.create("guestDownload",document.body,a.getHashVariable(a.FILE_ID),a.getHashVariable(a.MEEBO_USER));
meeboApp.GuestDownload.addClassName("downloadPage");
removeElement($("frontPageStyle"))
};
meeboApp.onInput=function(){if(gAdTimer){gAdTimer.checkInterval()
}};
meeboApp.onScroll=function(){document.documentElement.scrollTop=0
};
meeboApp.onConversation=function(c,a){var d=c.getConversation().getUnreadCount();
var b=gWindowMgr.getConvWindow(c);
if(!b){gWindowMgr.createIMWindow(c,false,false,hitch(this,function(){b=gWindowMgr.getConvWindow(c);
if(d){b.startFlashWindow()
}}))
}else{if(d){if(b.startFlashWindow){b.startFlashWindow()
}else{b._("startFlashWindow")
}}}if(d){gBuddyListDlg.showBuddyMessageFeedback(c,true)
}};
meeboApp.onUnreadMessageCountChange=function(c,a,e){if(window.fluid){var d=gBuddyListDlg.getTotalUnreadMessageCount();
window.fluid.dockBadge=d?String(d):""
}if(e==0){var b=gWindowMgr.getConvWindow(c.getBuddy());
if(b){b.stopBuddyMessageFeedback()
}}};
meeboApp.m_isPopout=false;
meeboApp.setIsPopout=function(a){meeboApp.m_isPopout=a
};
meeboApp.isPopout=function(){return meeboApp.m_isPopout
};
meeboApp.isCIMPopout=function(){return gClient.getClientType()=="cim-popout"
};
meeboApp.hasTrayNotifier=function(){return gIMGateway.getClients({type:"trayicon"}).length
};
meeboApp.initializeTakeover=function(){if(gIsGuestGroupChat||gIsGuestFileTransfer){return
}new ui.TrackingPixel({},gTakeover.impression_front).create();
if(gTakeover.fgimage){var a=document.createElement("div");
addClassName(a,"TakeoverContainer");
var c=$("languagelinks");
c.parentNode.insertBefore(a,c);
c.style.paddingTop="0px";
var b=createImg("TakeoverImage",document.body,728,90,gTakeover.fgimage,"",true,"",true);
addClassName(b,"TakeoverImage");
a.appendChild(b)
}};
meeboApp.downloadNotifier=function(b){b=b||"unknown";
var a="http://download.meebo.com/notifier/MeeboNotifierSetup-Beta.exe";
if(Math.floor(Math.random()*100)<gNotifierChromePercentage){a=gNotifierChromeUrl
}if(!meeboApp.m_notifierIframe){var c=window.document;
meeboApp.m_notifierIframe=c.createElement("iframe");
meeboApp.m_notifierIframe.style.position="absolute";
meeboApp.m_notifierIframe.style.top=meeboApp.m_notifierIframe.style.left="-999px";
meeboApp.m_notifierIframe.src=a;
c.body.appendChild(meeboApp.m_notifierIframe)
}else{meeboApp.m_notifierIframe.src=a
}gNetworkMgr.doUILog("notifierupsell","download",b,true)
};
Class("meeboApp.TreeEventModel",ui.TreeEventModel,function(a){this.onClick=function(d,c){if(c.m_bToggleHandle){var f=d.target||d.srcElement;
if(f.className==ui.TreeNode.classNames.img){c.toggle()
}}b.call(c,getFunctionKeysFromKeyEvent(d),false);
a(this,"onClick",arguments)
};
function b(f,h){var e=this.m_tree.getSelectionModel();
if(!e||!this.m_isSelectionEnabled){return
}f&=this.m_selectionModifiers;
var g=f&modifier.CTRL;
var d=f&modifier.SHIFT;
if(h&&this.toggle){this.toggle()
}if(!e.getPivot()){d=false
}if(!g){if(d){e.unselectAllButPivot()
}else{e.unselectAll()
}}var c=e.getPivot();
if(!d){e.setPivot(this);
if(g&&this.isSelected()){e.removeNode(this);
return
}}else{if(c&&c!=this){this.m_tree.applyToRange(e.getPivot(),this,hitch(e,"addNode"))
}}if(this){e.addNode(this)
}}this.onContextMenu=function(f,d){var c=this.m_tree.getSelectionModel();
if(!c||!d.m_isSelectionEnabled){return
}if(c.getNumSelections()<=1||!d.isSelected()){c.unselectAll();
c.addNode(d)
}a(this,"onContextMenu",arguments)
};
this.onDblClick=function(d,c){c.publish("Activate",c,d)
};
this.onMouseDown=function(d,c){this.m_tree.startDrag(d,c);
if(!ui.isSafari||ui.isSafari>=3){ui.preventDefault(d)
}}
});
Class("meeboApp.consoleMgr",function(){this.initialize=function(){this.m_pageMain=new meeboApp.ConsolePageMain();
this.m_pageGuest=new meeboApp.ConsolePageGuest()
};
this.getMainPage=function(){return this.m_pageMain
};
this.onResize=function(){this.m_pageMain.onResize()
}
});
Class("meeboApp.WindowMgr",function(){this.initialize=function(){this.m_groupChats={};
this.m_meeboGroupChats={};
this.m_numWindows=0;
this.m_numMinRows=0;
this.m_posIter=0;
this.m_flashIter=0;
this.m_flashTime=0;
this.m_totalFlashIters=8;
this.m_flashArr=[];
this.m_perWindow=-1;
this.m_maxIterMsec=40;
this.m_minIterMsec=20;
this.m_minFlashIters=8;
this.m_bFirstPopOut=true;
this.m_popOutQueue=[];
this.m_currentZindex=2;
this.m_currentTileIndex=0;
this.m_focusQueue=[];
this.m_isFocusQueueActive=false;
this.m_canCyclePopouts=!ui.isFirefox;
this.m_timerFlash=gTimerMgr.addTimer(hitch(this,"doFlash"),125);
gPubSub.subscribe("meebo.EventMgr::changeState",this,"onEventMgrChangeState");
gPubSub.subscribe("meebo.EventMgr::notify",this,"onEventMgrNotify");
gPubSub.subscribe("meebo.Logon::changeState",this,"onLogonChangeState");
gPubSub.subscribe("meebo.CIMAccount::changeState",this,"onLogonChangeState");
gUIState.subscribe("ChangeState",this,"onUIChangeState");
this.m_dlgTemplates={defaultDlg:{id:"",caption:"",img:null,x:null,y:null,w:300,h:200,parent:null,bResize:false,bTopmost:true,buttonType:"close",bReconnectDlg:true,ctorName:"",deps:null,uiType:"dlg"},createMeeboAccountDlg:{id:"upsell",caption:gLang.createAccountHeader,w:600,h:390,ctorName:"meeboApp.createMeeboAccountDlg",creationFunction:"createCreateMeeboAccountDlg"},EmailInviteDlg:{id:"email-import",caption:gLang.emailImportHeader2,w:360,h:260,ctorName:"meeboApp.EmailInviteDlg",creationFunction:"createEmailInviteDlg",deps:["meeboApp.emailInvite.inc"]},signOnDlg:{id:getSignOnDlgId(),caption:gLang.newConnectionHeader,w:275,h:250,ctorName:"meeboApp.signOnDlg",deps:["meeboApp.signOnControl","meeboApp.signOnDlg"],creationFunction:"createSignOnWindow"},resetPasswordDlg:{id:"reset-password-dlg",caption:gLang.resetPasswords,w:275,h:207,ctorName:"meeboApp.ResetPasswordDlg",deps:["meeboApp.resetPasswordDlg.inc"],creationFunction:"createResetPasswordDlg"},addBuddyDlg:{id:getAddBuddyDlgId(),caption:gLang.addBuddyHeader,w:275,h:278,ctorName:"meeboApp.addBuddyDlg",creationFunction:"createAddBuddyDlg"},profileDlg:{w:360,h:230,bResize:true,buttonType:"all",ctorName:"meeboApp.profileDlg",creationFunction:"createProfileDlg"},blogDlg:{id:getWelcomeDlgId(),caption:gLang.blogHeader,x:355,y:72,w:300,h:300,bResize:true,bTopmost:false,buttonType:"all",ctorName:"meeboApp.BlogDlg",creationFunction:"createWelcomeWindow"},myMeeboDlg:{id:getMyMeeboId(),caption:gLang.welcomeHeader,w:575,h:390,bResize:true,buttonType:"all",ctorName:"meeboApp.myMeeboDlg",deps:["meeboApp.myMeebo.inc","meeboApp.signOnControl","meeboApp.signOnDlg"],creationFunction:"createMyMeeboWindow"},Settings:{id:"settings",uiType:"Panel",caption:gLang.settings,w:270,h:260,ctorName:"meeboApp.SettingsPanel",deps:["meeboApp.SectionsPanel","meeboApp.SettingsPanel"],creationFunction:"createSettingsPanel"},Preferences:{id:"preferences",uiType:"Panel",caption:gLang.IMSettings,w:270,h:260,ctorName:"meeboApp.PreferencesPanel",deps:["meeboApp.SectionsPanel","meeboApp.PreferencesPanel"],creationFunction:"createPreferencesPanel"},Appearance:{id:"appearance",uiType:"Panel",caption:gLang.appearancePanel,w:260,h:252,ctorName:"meeboApp.AppearancePanel",deps:["meeboApp.appearancePanel.inc"],creationFunction:"createAppearancePanel"},FeatureTest:{id:"featureTest",caption:gLang.testingNewFeatures,w:300,h:250,ctorName:"meeboApp.FeatureTestDlg",deps:["meeboApp.InputDlg","meeboApp.FeatureTestDlg"],creationFunction:"createFeatureTestDlg"},chatLogDlg:{id:getChatLogDlgId(),caption:gLang.welcomeHeader,w:450,h:360,bResize:true,buttonType:"all",ctorName:"meeboApp.chatLogDlg",deps:["meeboApp.chatLog.inc"],creationFunction:"createChatLogWindow"},failSignOnDlg:{id:getFailSignOnDlgId(),caption:gLang.miniLogonHeader,w:300,h:225,ctorName:"meeboApp.failSignOnDlg",creationFunction:"createMiniLogonWindow"},addWidgetDlg:{id:getAddWidgetDlgId(),w:300,h:195,ctorName:"meeboApp.addWidgetDlg",creationFunction:"createAddWidgetDlg"},notifyDlg:{w:275,h:130,ctorName:"meeboApp.notifyDlg",creationFunction:"createNotifyDlg"},noAccountsDlg:{id:getNoAccountsDlgId(),w:275,h:130,ctorName:"meeboApp.NoAccountsDlg",creationFunction:"createNoAccountsDlg"},okDlg:{w:275,h:130,ctorName:"meeboApp.OkDlg",creationFunction:"createOkDlg"},inputDlg:{w:260,h:150,ctorName:"meeboApp.InputDlg",creationFunction:"createInputDlg"},setDisplayNameDlg:{w:260,h:150,deps:["meeboApp.InputDlg","meeboApp.SetDisplayNameDlg"],ctorName:"meeboApp.SetDisplayNameDlg",creationFunction:"createSetDisplayNameDlg"},textAreaDlg:{w:300,h:210,bResizable:true,deps:["meeboApp.InputDlg","meeboApp.TextAreaDlg"],ctorName:"meeboApp.TextAreaDlg",creationFunction:"createTextAreaDlg"},setProfileDlg:{w:300,h:210,bResize:true,deps:["meeboApp.InputDlg","meeboApp.TextAreaDlg","meeboApp.SetProfileDlg"],ctorName:"meeboApp.SetProfileDlg",creationFunction:"createSetProfileDlg"},addMediaDlg:{caption:gLang.addMedia,w:260,h:170,deps:["meeboApp.InputDlg","meeboApp.AddMediaDlg"],ctorName:"meeboApp.AddMediaDlg",creationFunction:"createAddMediaDlg"},roomCreateDlg:{w:327,h:400,deps:["meeboApp.roomCreate.inc"],ctorName:"meeboApp.RoomCreateDlg",creationFunction:"createRoomCreateDlg"},inviteDlg:{w:327,h:475,deps:["meeboApp.InviteBuddiesPage","meeboApp.InviteDlg"],ctorName:"meeboApp.InviteDlg",creationFunction:"createInviteDlg"},acceptDenyDlg:{w:300,h:130,ctorName:"meeboApp.AcceptDenyDlg",creationFunction:"createAcceptDenyDlg"},statusMenuDlg:{id:getStatusMenuDlgId(),caption:gLang.awayMessages,w:250,h:175,bResize:true,ctorName:"meeboApp.StatusMenuDlg",creationFunction:"createStatusMenuDlg"},roomWidgetDlg:{caption:gLang.roomWidgetHeader,w:300,h:280,ctorName:"meeboApp.RoomWidgetDlg",creationFunction:"createRoomWidgetDlg"},groupChatDlg:{id:getGroupChatDlgId(),caption:gLang.groupChatHeader,w:295,h:175,ctorName:"meeboApp.GroupChatDlg",creationFunction:"createGroupChatDlg"},imBuddyDlg:{id:getIMBuddyDlgId(),caption:gLang.imBuddyHeader,w:275,h:175,ctorName:"meeboApp.IMBuddyDlg",creationFunction:"createIMBuddyDlg"},addBuddyGroupDlg:{id:getAddBuddyGroupDlgId(),caption:gLang.addBuddyGroupHeader,w:275,h:160,ctorName:"meeboApp.AddBuddyGroupDlg",creationFunction:"createAddBuddyGroupDlg"},dateDlg:{w:275,h:125,buttonType:"none",ctorName:"meeboApp.DateDlg",creationFunction:"createDateDlg",caption:gLang.birthday},debugDlg:{id:getDebugDlgId(),x:50,y:100,w:550,h:450,bResize:true,buttonType:"all",ctorName:"meeboApp.debugDlg",creationFunction:"createDebugDlg",caption:"Debugger"},notifierUpsellDlg:{id:"notifierUpsellDlg",w:350,h:241,ctorName:"meeboApp.NotifierUpsellDlg",creationFunction:"createNotifierUpsellDlg",caption:"Meebo Notifier"},locationsDlg:{id:"locationsDlg",w:275,h:184,ctorName:"meeboApp.LocationsDlg",creationFunction:"createLocationsDlg",caption:gLang.Locations}};
for(var d in this.m_dlgTemplates){var c=this.m_dlgTemplates[d];
if(!c.creationFunction){continue
}this[c.creationFunction]=hitch(this,"createDelegatedDlg",c)
}};
this.createDelegatedDlg=function(d,c){function l(p,o){var m={};
for(var n in p){m[n]=isDefined(o[n])?o[n]:p[n]
}return m
}c=l(l(this.m_dlgTemplates.defaultDlg,d),c||{});
var e=Array.prototype.slice.call(arguments,2);
var f=ui.deferredDlg.getWndOpening(c.id);
if(f){return f
}if(gWindows[c.id]){var h=gWindows[c.id].m_delegate;
if(h&&h.restoreDelegate){h.restoreDelegate.apply(h,e)
}return this.restoreDlg(gWindows[c.id])
}var f=this.createDlgFromTemplate(c);
var k=c.deps||[c.ctorName];
this.loadObjects(k,function g(){var n=Class.getObject(c.ctorName);
var m=new n();
f._("setDelegate",m,e)
});
return f
};
this.requestObject=function(d,c,h){try{var f=new net.Request();
f.url=d;
f.transport=net.XHRTransport;
net.get(f,hitch(this,function(k,l){if(!l){c()
}else{this.createNotifyDlg({id:getUniqueId()+"networkError",caption:gLang.meeboMessage},gLang.disruption+gLang.pleaseCheck);
h()
}}))
}catch(g){h()
}};
this.loadObject=function(c,l,d){var k=gConfig.getTimeStamp(),e=gConfig.getVersion();
var f=callee.call(this,arguments);
if(!c.length){d();
if(l){l()
}}else{var g=c.shift();
var h="/script/"+g.replace(/\.(?!inc$)/g,"/")+(e?"_v"+e:"")+".js"+(k?"?"+k:"");
if(Class.objectExists(g)){f()
}else{runInMainContext(this,"requestObject",h,f,d)
}}};
this.loadObjects=function(c,e){for(var d=c.length-1;
d>=0;
d--){if(Class.objectExists(c[d])){c.splice(d,1)
}}if(!c.length){if(e){e()
}}else{gSerializer.serialize(hitch(this,"loadObject",c,e))
}};
this.getNextTileIndex=function(){return ++this.m_currentTileIndex
};
this.getNextZIndex=function(){return ++this.m_currentZindex
};
this.getTopZIndex=function(){return this.m_currentZindex+100
};
this.nextParent=function(){var c=this.getActiveWindow();
if(c&&c.isPoppedOut()){return null
}return document.body
};
this.getConvWindow=function(c){if(!c){return null
}else{if(c.getType()=="protocolchat"){return this.m_groupChats[c.getId()]||gWindows[getIMId(c.getName(),c.getLogin())]||gWindows[getIMId(c.m_buddyParent,c.getLogin())]
}else{if(c.constructor==meebo.ApplicationRoom){var f=gWindows[getGroupChatId(c.getProtocol(),c.getUser(),c.getChatId())];
if(f){return f
}var e=this.getConvWindows();
for(var d=0,f;
(f=e[d]);
d++){if(f.getImObject()!=c&&f.getApplicationRoom()!=c){continue
}return f
}}else{var f=gWindows[getIMId(c.getName(),c.getLogin())];
if(f){return f
}var e=this.getConvWindows();
for(var d=0,f;
(f=e[d]);
d++){if(f.m_buddy==c){return f
}}}}}return null
};
this.loadDebugCases=function(){if(!gDebug){return
}var c=new Date().getTime();
try{}catch(d){alert("Couldn't find the debug events function.")
}log("loadDebugCases: "+(new Date().getTime()-c))
};
this.createBuddyWindow=function(o,p,h,g,e){var l=getBuddyListId();
var f=ui.deferredDlg.getWndOpening(l);
if(f){if(p){f.addBoth(function(s,q){p(s)
})
}return f
}if(gWindows[l]&&(!isDefined(h)||h==gWindows[l].isPoppedOut())){this.loadDebugCases();
return gWindows[l]
}var n=this.focusQueueAdd(new meeboApp.buddyListDlg());
var k;
if(isDefined(g)){k=g
}else{k=ui.getClientRect();
var c=ui.getClientRect();
k.x=k.w-240;
k.y=gIsGuestGroupChat?60:5;
k.w=235;
k.h=gIsGuestGroupChat?Math.min(c.h-150,522):k.h-10
}var m=h?null:document.body;
var d=n.create(l,m,o,null,k.x,k.y,k.w,k.h,true,"onlymin");
return d.addBoth(hitch(this,function(q){q.setCreateFnc(this,this.createBuddyWindow,Array(o));
gBuddyListDlg=q;
gBuddyListDlg.m_element.style.zIndex="3";
gBuddyListDlg.initContent(e);
this.loadDebugCases();
this.registerWindow(gBuddyListDlg);
if(p){p(q)
}}))
};
this.addFlashingWindow=function(d,e){if(e){this.m_flashArr.push(d)
}else{for(var c=0;
c<this.m_flashArr.length;
c++){if(this.m_flashArr[c]===d){this.m_flashArr.splice(c,1);
return
}}}};
this.doFlash=function(){var g=this.m_flashArr;
var d=0;
var c=(new Date()).getTime();
for(var f=this.m_flashIter;
f<g.length;
f+=this.m_totalFlashIters){g[f].flashWindow();
d++
}var h=(new Date()).getTime();
if(this.m_perWindow==-1&&d){this.m_perWindow=(h-c)/d
}this.m_flashTime+=(h-c);
if(this.m_flashIter==this.m_totalFlashIters-1){if(this.m_perWindow<=0){this.m_perWindow=1
}var k=Math.floor(this.m_flashTime/this.m_flashIter);
if(k>this.m_maxIterMsec){this.m_totalFlashIters+=Math.ceil(((k-this.m_maxIterMsec)/this.m_perWindow))
}else{if(this.m_totalFlashIters>this.m_minFlashIters&&k<this.m_minIterMsec){this.m_totalFlashIters-=Math.ceil(((this.m_minIterMsec-k)/this.m_perWindow))
}}this.m_flashIter=0;
this.m_flashTime=0;
this.m_perWindow=-1
}else{this.m_flashIter++
}};
this.reopenIMWindow=function(d,c){this.focusQueueAdd(d,1);
if(d.isMaximized()){d.restoreMaximizeWindow()
}else{if(d.isMinimized()&&!d.isMeeboGroupChat()){d.restoreMinimizeWindow()
}}this.moveWindowToVisiblePos(d);
if(!c){d.showWindow(true)
}d.greyText();
d.recalcLayout()
};
this.createIMWindow=function(x,v,c,z,D,f){var k=x.constructor==meebo.ApplicationRoom;
var y=x.getType()=="chat"&&!k;
var B=x.getType()=="protocolchat";
if(y&&x.m_isLeaving){return
}var E=x.getName();
var u=x.getLogin();
var t=x.getAlias();
var n=getIMId(E,x.getLogin());
var e=ui.deferredDlg.getWndOpening(n);
if(e){if(z){e.addBoth(function(w,h){z(w)
})
}return e
}var C=gWindows[n];
if(!C&&y&&this.m_meeboGroupChats[n]){C=gWindows[n]=this.m_meeboGroupChats[n];
delete this.m_meeboGroupChats[n]
}if(C&&(!isDefined(D)||D==C.isPoppedOut())){var m=C&&!C.isVisible()&&!this.nextParent()&&!C.isPoppedOut();
if(!C.isVisible()){if(y){C.m_element.style.visibility="hidden"
}this.reopenIMWindow(C,m);
if(y&&ui.isIE){C.reuseChatWindow();
C.m_element.style.visibility="visible"
}}if(v&&!m){this.activateWindow(C)
}C.m_history.scrollTop=C.m_history.scrollHeight;
if(m){C.popOutDlg(true,z)
}return C
}logSpeed("creating im window");
var C=this.focusQueueAdd(new meeboApp.imDlg(x));
if(k){C.setApplicationRoom(x)
}if(y){C.setSkin("chromeless")
}var d;
if(!isDefined(D)){d=this.nextParent();
D=(d==null)
}else{d=D?null:document.body
}var p=(y?700:(B?400:300));
var A=(y?522:275);
if(y&&gIsGuestGroupChat){var s=ui.getClientRect();
A=Math.min(s.h-150,522);
var g=(this.getConvWindows().length>0?this.getVisibleWindowPos(p,A,D):{x:20,y:60,w:p,h:A})
}else{if(isDefined(f)){var g=f
}else{var g=gPrefs.getAccountPref(u,"wd:"+n);
if(!g){if(k&&x.getApplication()){var o=x.getApplication();
p+=o.width+C.m_vertSliderSize-2;
A=Math.max(o.height+119,A)
}if(c){g=this.getDlgPos(null,p,A)
}else{g=this.getVisibleWindowPos(p,A,D)
}g.w=p;
g.h=A;
if(gIsGuestGroupChat){g.x=350;
g.y=75
}}}}var q=C.create(n,d,x.getCaption(),x.getCaptionImage(),g.x,g.y,g.w,g.h,"true","all");
var l=isDefined(gWindows[n]);
q._("initContent",l);
if(!gWindows[n]){gNetworkMgr.doUILog(C.control,(y?"room-":"")+"general","load")
}q.addBoth(hitch(this,function(h){h.setCreateFnc(this,this.createIMWindow,[x,v,c]);
if(v){this.activateWindow(h);
h.focusOnMessage()
}else{h.setZIndex(g.z)
}this.registerWindow(h);
gDragManager.addDropTarget(h);
if(z){z(h)
}logSpeed("im window drawn")
}));
return q
};
this.createReconnectDlg=function(){var c=this.createOkDlg({id:getReconnectDlgId(),caption:gLang.disconnected,bReconnectDlg:false},gLang.thanks+gLang.logout+"<br><br>"+gLang.comeBack,hitch(gLogon,"reconnectAll"),null,gLang.reconnectionBtn,null,"notifyBuddy.gif");
c._("moveToTop");
return c
};
this.createDlgFromTemplate=function(c){if(!gEventMgr){return
}if(c.bReconnectDlg&&gEventMgr.getState()=="done"){return this.createReconnectDlg({},gLang.logoffStatus+"<br><br>"+gLang.reconnectPrompt)
}var f=this.focusQueueAdd(new ui[c.uiType]());
var e=this.createDlg(f,c.id,c.caption,c.img,c.parent,c.x,c.y,c.w,c.h,c.bResize,c.bTopmost,c.buttonType);
return this.connectDlgEvents(e,c.id)
};
this.getNumWindows=function(){return this.m_numWindows
};
this.getNumMinWindows=function(){var c=0;
for(var e in gWindows){var d=gWindows[e];
if(!d||!d.isMinimized||!d.isMinimized()){continue
}c++
}return c
};
this.moveWindowToBottom=function(c,e){if(!c){return
}var d=c.getElement();
if(!d){return
}var k=c.getZIndex(),g=k;
for(var f=0;
f<e.length;
f++){if(!e[f]||!e[f].getZIndex){continue
}k=Math.min(k,parseInt(e[f].getZIndex()));
g=Math.max(k,parseInt(e[f].getZIndex()))
}if(k>2){c.setZIndex(k-2);
return
}for(f=0;
f<e.length;
f++){if(!e[f]||!e[f].setZIndex){continue
}var h=parseInt(e[f].getZIndex())+2;
e[f].setZIndex(h);
g=Math.max(g,h)
}c.setZIndex(k);
if(gMediaBar&&parseInt(gMediaBar.getElement().style.zIndex)<=g){gMediaBar.getElement().style.zIndex=g+2
}};
this.resizeMaxWindows=function(){var c=[];
for(var d in gWindows){if(gWindows[d]&&gWindows[d].isMaximized&&gWindows[d].isMaximized()){gWindows[d].updateMaximize()
}}};
this.tileMinWindows=function(){var l=new Array();
var g=0;
for(var k in gWindows){var d=gWindows[k];
if(!d||!d.isMinimized||!d.isMinimized()||!d.isVisible||!d.isVisible()){continue
}l[d.m_id]=d;
g++
}l=objectToArray(l);
l.sort(this.sortByTileIndex);
var c=ui.getClientRect(document),m=0,e=0;
var h=0;
if(gMediaBar&&gMediaBar.getDisplay()!="none"){h=gMediaBar.getGalleryTop()
}for(var f=0;
f<l.length;
f++){var d=l[f];
if(!d){continue
}if(((e+1)*150)>=c.w){m++;
e=0
}d.moveWindow(e*150+8,c.h-h-((m+1)*28));
if(m){this.moveWindowToBottom(d,l)
}e++
}if(l.length){this.m_numMinRows=m+1
}else{this.m_numMinRows=0
}};
this.getNumMinRows=function(){return this.m_numMinRows
};
this.sortByTileIndex=function(f,d){var e=f.getElement().getAttribute("tileIndex");
var c=d.getElement().getAttribute("tileIndex");
return e-c
};
this.rightAlignBuddy=function(){if(!gBuddyListDlg||gBuddyListDlg.isMinimized()||gBuddyListDlg.isPoppedOut()||gIsGuestGroupChat){return
}var c=ui.getClientRect();
var n=gBuddyListDlg.getWindowPos();
var l=c.w-n.w-5;
var k=5;
var m=n.w;
var e=c.h-10;
if(ui.isIPhone){var g=gBuddyListDlg.getTree().getElement();
var d=g.scrollHeight;
var f=n.h-g.offsetHeight;
e=Math.max(e,d+f)
}gBuddyListDlg.setWindowPos(l,k,m,e)
};
this.redraw=function(c){if(gEventMgr.getState()=="logon"){return
}this.tileMinWindows();
this.resizeMaxWindows();
this.rightAlignBuddy();
if(gMediaBar&&gEventMgr.getState()=="im"){gMediaBar.onResize()
}};
this.registerGroupChat=function(d,c){if(!this.m_groupChats){this.m_groupChats=new Object()
}this.m_groupChats[d]=c
};
this.unregisterGroupChat=function(c){delete this.m_groupChats[c]
};
this.unregisterWindow=function(c){delete gWindows[c];
this.m_numWindows--
};
this.reregisterWindow=function(d,c){if(c==d){return
}gWindows[c]=gWindows[d];
delete gWindows[d]
};
this.registerWindow=function(c){gWindows[c.m_id]=c;
this.m_numWindows++
};
this.moveWindowUnderTop=function(c){var d=this.getActiveWindow();
if(gMediaBar&&!d&&gMediaBar.isMaximized()){d=gMediaBar
}var e=d?d.getZIndex()-1:this.getNextZIndex();
c.setZIndex(e)
};
this.moveWindowToVisiblePos=function(c){if(!c||!c.getWindowPos){return
}if(this.isWindowPosVisible(c)){this.moveWindowUnderTop(c);
return
}var e=c.getWindowPos();
var d=this.getVisibleWindowPos(e.w,e.h,c.isPoppedOut());
c.moveWindow(d.x,d.y);
c.setZIndex(d.z)
};
this.isWindowPosVisible=function(d){var e=80,h=50;
var f=this.getActiveConvWindow();
if(!f){return true
}var g=d.getWindowPos();
var c=f.getWindowPos();
if(g.z>c.z){return true
}if((c.x-g.x)>=e){return true
}if(((g.x+g.w)-(c.x+c.w))>=e){return true
}if((c.y-g.y)>=h){return true
}if(((g.y+g.h)-(c.y+c.h))>=h){return true
}return false
};
this.getVisibleWindowPos=function(x,C,k){var A=320,E=100;
var g=5,l=5,o=5;
var F=40;
var d=28;
var v=4;
var t=3;
var w=0,s=0,q=0;
var B=false,p=false,m=false,u=false;
var c=this.getActiveConvWindow();
var f=null;
var e=[];
if(c&&c.isPoppedOut()==k){q=c.getZIndex()-1;
f=c.getWindowPos();
for(var y in gWindows){if(gWindows[y].getZIndex()==q){e.push(gWindows[y])
}}}else{c=null;
q=this.getNextZIndex()
}var D=ui.getClientRect();
if(f){B=(f.x-F)>g;
p=(f.y-d)>l;
m=(f.x+f.w+F)<D.w-g;
u=(f.y+f.h+d)<D.h-o
}if(!c||c.isMaximized()||(!B&&!p&&!m&&!u)){var z=this.m_posIter++;
var h=Math.floor(z/v);
var w=A+((z%v)*F)+((h%t)*F);
var s=E+((z%v)*d);
return{x:w,y:s,w:x,h:C,z:q}
}if(B){var z=e.length;
var h=Math.floor(z/v);
w=f.x-F-((z%v)*F)+((h%t)*F)
}else{if(m){var z=e.length;
var h=Math.floor(z/v);
w=f.x+f.w+F-x+((z%v)*F)+((h%t)*F)
}else{var z=this.m_posIter++;
var h=Math.floor(z/v);
w=A+((z%v)*F)+((h%t)*F)
}}if(u){s=f.y+f.h+d-C+((e.length%v)*d)
}else{if(p){s=f.y-d-+((e.length%v)*d)
}else{var z=this.m_posIter++;
s=E+((z%v)*d)
}}return{x:w,y:s,w:x,h:C,z:q}
};
this.restoreDlg=function(c){if(!c){return
}if(c.isMinimized&&c.isMinimized()){c.minimizeWindow(c.getElement())
}c.showWindow(true);
this.activateWindow(c);
return new lib.deferred().callback(c)
};
this.getDlgPos=function(o,m,d){var n=parseInt(m/2);
var l=parseInt(d/2);
if(o&&o.getWindowPos){var k=o.getWindowPos();
var g=k.x+parseInt(k.w/2);
var f=k.y+parseInt(k.h/2);
g-=n;
f-=l;
if(o.isPoppedOut&&!o.isPoppedOut()&&g<0){g=0
}if(o.isPoppedOut&&!o.isPoppedOut()&&f<0){f=0
}return{x:g,y:f}
}else{var e=ui.getClientCenter(o);
e.x-=n;
e.y-=l;
if(e.x<0){e.x=0
}if(e.y<0){e.y=0
}return{x:e.x,y:e.y}
}};
this.createDlg=function(n,d,u,v,l,q,p,s,g,e,t,m,f){var c=new lib.deferred().errback(),k;
if(l instanceof ui.dlg){k=l.isPoppedOut()?null:document.body
}else{if(l){k=l
}else{k=this.nextParent()
}}if(!n){return c
}if(q&&p&&s&&g){if(q<0){q=0
}if(p<0){p=0
}c=n.create(d,k,u,v,q,p,s,g,e,m)
}else{var o=this.getDlgPos(l,s,g);
c=n.create(d,k,u,v,o.x,o.y,s,g,e,m)
}return c.addBoth(hitch(this,function(w){if(!w.m_element){return
}this.registerWindow(w);
if(!w.initContent(f)){this.unregisterWindow(d);
return
}if(t){this.activateWindow(w)
}if(!l){return
}var h=l.m_id;
w.m_parent=l;
if(h&&w.m_onClose){w.m_onClose.push(function(){if(h&&gWindows[h]){gWindows[h].moveToTop()
}})
}}))
};
this.connectDlgEvents=function(e,c){var d=hitch(this,function(f){if(!f||!f.m_onClose){return
}f.m_onClose.push(hitch(this,"unregisterWindow",c))
});
if(e.addBoth){e.addBoth(d)
}else{d(e)
}return e
};
this.activateNextWindow=function(e,c){var d=-1;
var f,h,g;
if(e&&c){return
}for(var k in gWindows){if(k&&gWindows[k]){h=gWindows[k];
if((e&&!h.isPoppedOut())||(c&&h.isPoppedOut())){continue
}if(!h.isVisible||!h.isVisible()){continue
}if(h.control=="buddylistdlg"){g=1
}else{g=h.getZIndex()
}if(g>d){d=g;
f=h
}}}if(f&&f.moveToTop){this.activateWindow(f)
}if(!f&&e&&!c){window.focus()
}};
this.handleWindowClose=function(d){this.activateNextWindow(d.isPoppedOut(),!d.isPoppedOut());
if(meeboApp.isPopout()&&d.control=="imdlg"){var c="#"+d.getBuddy().getId();
gUIState.clear(c)
}this.focusQueueRemove(d)
};
this.activateWindow=function(c){gBrowser.setIgnoreBlurEvent(true);
this.deactivateWindows();
gBrowser.setIgnoreBlurEvent(false);
c.activateWindow();
this.focusQueueAdd(c)
};
this.deactivateWindows=function(){for(var d in gWindows){if(d){var c=gWindows[d];
if(c&&c.inactivateWindow&&c.isActive()){c.inactivateWindow(false)
}}}};
this.getActiveConvWindow=function(){var c=this.getActiveWindow();
return c&&c.control&&c.control=="imdlg"&&!c.isMinimized()?c:null
};
this.getActiveWindow=function(){for(var d in gWindows){if(d){var c=gWindows[d];
if(c&&c.isActive&&c.isActive()){return c
}}}};
this.getConvWindows=function(){var c=new Array();
for(var d in gWindows){if(gLog&&gDebugger&&gWindows[d]&&(gWindows[d].m_id==gDebugger.m_id)){continue
}if(d&&gWindows[d]&&gWindows[d].control&&(gWindows[d].control=="imdlg")){c.push(gWindows[d])
}}return c
};
this.getWindows=function(c){c=c||{};
var d=[];
for(var e in gWindows){var f=gWindows[e];
if("control" in c&&f.control!=c.control){continue
}if("app_id" in c){if(!f.getApplicationId||f.getApplicationId()!=c.app_id){continue
}}d.push(f);
d[e]=f
}return d
};
this.getApplicationWindows=function(c){if(!c){return[]
}return this.getWindows({app_id:c.app_id})
};
this.closeNonIMWindows=function(){for(var d in gWindows){if(!d){continue
}var c=gWindows[d];
if(!c){continue
}if(gLog&&gDebugger&&c.m_id==gDebugger.m_id||c.control=="imdlg"||c.control=="chatlogdlg"||c.m_id=="buddylistwin"||c.m_id==getWelcomeDlgId()||c.m_id==getReconnectDlgId()){continue
}if(c.closeWindow){c.closeWindow()
}}};
this.closeWindows=function(){for(var d in gWindows){if(!d){continue
}var c=gWindows[d];
if(!c){continue
}if(gLog&&c.m_id==gDebugger.m_id){continue
}if(c.closeWindow){c.closeWindow()
}}};
this.onEventMgrChangeState=function(e,c,f,d){if(f=="done"){this.closeNonIMWindows()
}else{var g=gWindows[getReconnectDlgId()];
if(g){g.closeWindow()
}}};
this.onEventMgrNotify=function(e,c,d){this.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.networkMessage},d)
};
this.onLogonChangeState=function(k,p,c,d){var g=d=="online"||d=="signingoff";
var h=k.isOnline(),f=k.getNetwork();
if(g!=h){if(h){this.updateOnlineWindows(k)
}else{this.updateOfflineWindows(k)
}}if(c=="online"){if(f=="myspace"){setTimeout(hitch(this,"checkMySpaceBuddyList",k),2000)
}}else{if(c=="error"){var m=k.getLastError(),l=m.type,n=m.description;
if(f=="myspace"&&l==2&&n=="No username set"){var o="http://profileedit.myspace.com/index.cfm?fuseaction=profile.username";
var e=gLang.needAMySpaceUsername+'<br><br><a href="'+o+'" target="_blank">'+gLang.setYourUsernameOnMySpace+"</a>";
this.createNotifyDlg({id:"myspace-username-notify",caption:gLang.setYourMySpaceUsername,w:300},e,{src:"network/myspace_24_online.png",w:24,h:24})
}else{if(l==16&&n=="AOL does not allow your screen name to authenticate here"){this.createNotifyDlg({id:"aol-authenticate-notify",caption:gLang.error},gLang.aolDoesntLikeYou)
}else{if(gEventMgr.getState()!="connecting"){this.createMiniLogonWindow(null,k)
}}}}}};
this.checkMySpaceBuddyList=function(c){if(!gBuddyList.getBuddies({logon:c}).length){this.createAddBuddyDlg(null,{logon:c})
}};
this.onUIChangeState=function(l,f){switch(l){case"cIM":break;
case"activePlt":if(f&&f.im){var c=f.im.substr(1);
var e=gBuddyList.getBuddyById(c);
var k=this.getConvWindow(e);
if(k){this.activateWindow(k);
k.restoreMinimizeWindow()
}}break;
default:if(l.charAt(0)=="#"){var c=l.substr(1);
if(f){var e=gBuddyList.getBuddyById(c);
if(!e){var h=parseBuddyId(c);
var g=meebo.util.normalizeLogon(h.user,h.protocol);
var d=gLogon.addLogon(h.user,g.network);
e=gBuddyList.addBuddy(h.name,d)
}var k=this.getConvWindow(e);
if(!k){k=this.createIMWindow(e,false);
if(meeboApp.isCIMPopout()){if(k._){k._("minimizeWindow")
}else{k.minimizeWindow()
}}}}}}};
this.updateOnlineWindows=function(d){var f=this.getConvWindows();
for(var e=0;
e<f.length;
e++){var g=f[e];
if(!g.m_bOffline){continue
}var c=g.m_imobject;
if(!d||c.getLogin()!=d){continue
}if(c.constructor==meebo.Room){if(!g.m_rejoinDiv){meeboApp.joinRoom(g.getImObject())
}else{g.m_rejoinDiv.style.display=""
}}else{g.setOffline(false)
}}};
this.updateOfflineWindows=function(d){var f=this.getConvWindows();
for(var e=0;
e<f.length;
e++){var g=f[e];
var c=g.m_imobject;
if(!d||c.getLogin()!=d){continue
}if(g.isAppAreaVisible()&&g.m_applicationRoom){if(!g.isGroupChat()){g.toggleAppArea()
}else{g.initAppLoadingOverlay(gLang.errorApplicationNotAvailable)
}}else{if(g.isGroupChat()){g.addHistoryIM(gLang.meeboMessage,gLang.meeboOffline+gLang.chatroomended,true,true)
}}g.setOffline(true)
}};
this.doHotKeys=function(d){var c=d.keyCode;
return true
};
this.checkMuteRooms=function(f,e){var d=this.getConvWindows();
for(var c=0;
c<d.length;
c++){if(d[c].isMeeboGroupChat()){if(f){d[c].showMuteControls()
}else{d[c].hideMuteControls()
}}}};
function a(c){return c&&c.isPoppedOut&&c.isPoppedOut()
}function b(c){if(!a(c)){window.focus()
}if(c.activateWindow){gWindowMgr.activateWindow(c)
}if(c.focus){c.focus()
}}this.focusNext=function(){var c=this.m_focusQueue.length;
if(!c||!this.m_canCyclePopouts&&a(this.m_focusQueue[0])){return
}this.m_isFocusQueueActive=true;
if(this.m_canCyclePopouts){this.m_focusQueue.push(this.m_focusQueue.shift());
b(this.m_focusQueue[0])
}else{for(var d=0;
d<c;
++d){this.m_focusQueue.push(this.m_focusQueue.shift());
if(!a(this.m_focusQueue[0])){b(this.m_focusQueue[0]);
break
}}}this.m_isFocusQueueActive=false
};
this.focusPrev=function(){var c=this.m_focusQueue.length;
if(!c||!this.m_canCyclePopouts&&a(this.m_focusQueue[0])){return
}this.m_isFocusQueueActive=true;
if(this.m_canCyclePopouts){this.m_focusQueue.unshift(this.m_focusQueue.pop());
b(this.m_focusQueue[0])
}else{for(var d=0;
d<c;
++d){this.m_focusQueue.unshift(this.m_focusQueue.pop());
if(!a(this.m_focusQueue[0])){b(this.m_focusQueue[0]);
break
}}}this.m_isFocusQueueActive=false
};
this.focusQueueAdd=function(g,c){var l=g instanceof meeboApp.imDlg,f=g instanceof meeboApp.buddyListDlg,h=false;
if(!l&&!f||this.m_isFocusQueueActive||g==this.m_focusQueue[0]){return g
}for(var e=0,k;
k=this.m_focusQueue[e];
++e){if(k==g){if(f){return g
}this.m_focusQueue.splice(e,1);
h=true;
break
}}if(!h&&this.m_focusQueue.length){this.m_focusQueue.push(this.m_focusQueue.shift())
}this.m_focusQueue.splice(c||0,0,g);
return g
};
this.focusQueueRemove=function(e){for(var c=0,f;
f=this.m_focusQueue[c];
++c){if(f==e){this.m_focusQueue.splice(c,1)
}}}
});
meeboApp.browser=function(){this.m_focusTime=0;
this.m_focusTimeStart=null;
this.m_ignoreBlurEvent=false;
this.init=function(){if(gTimerMgr){gTimerMgr.addTimer(function(){gBrowser.flashTitle()
},1000)
}this.setTitle(window,"meebo.com");
this.connectEventsToWin(window);
gPubSub.subscribe("meebo.EventMgr::changeState",this,"onEventMgrChangeState");
gClient.subscribe("beforeEvents",this,"onBeforeEvents")
};
function a(f,d,e){if(!d&&f.event){d=f.event
}var g=d.target?d.target:d.srcElement;
var c=true;
if((g.tagName.toLowerCase()!="input"&&g.tagName.toLowerCase()!="textarea")||(g.tagName.toLowerCase()=="input"&&g.id=="focuser")){var b;
if(f.m_windowId){b=gWindows[f.m_windowId]
}else{b=gWindowMgr.getActiveWindow();
if(b&&b.isPoppedOut()){b=null
}}if(b&&b.isVisible()){c=e(d,b,g)
}}gBrowser.setFocus(f);
return c
}this.connectEventsToWin=function(c){var b=c.document;
b.onkeydown=function(d){try{if(d.keyCode==ui.KEY_ESC){ui.preventDefault(d)
}return a(c,d,function(g,e,h){if(e.onGlobalKeyDown){return e.onGlobalKeyDown(g,h)
}return true
})
}catch(f){}};
b.onkeypress=function(d){try{return a(c,d,function(g,e,h){if(e.onGlobalKeyPress){return e.onGlobalKeyPress(g,h)
}return true
})
}catch(f){}};
b.onmousedown=function(d){try{meeboApp.onInput()
}catch(f){}};
ui.connectEvent(c,"focus",this,"setFocus",true,true);
ui.connectEvent(c,"blur",this,"setUnfocus",true,true);
if(ui.isIE==7){ui.connectEvent(c,"focusie7",this,"setFocus",true,true)
}c.m_focus=true
};
this.disconnectEventsFromWin=function(c){var b=c.document;
b.onkeydown=null;
b.onkeypress=null;
ui.disconnectEvent(c,"focus");
ui.disconnectEvent(c,"blur");
if(ui.isIE==7){ui.disconnectEvent(c,"focusie7")
}};
this.setFavIcon=function(f,e){var d=e.document;
var b=d.documentElement.firstChild;
var c=d.createElement("link");
c.type="image/x-icon";
c.rel="shortcut icon";
c.href=f;
if(e.m_favIcon){if(c.href==e.m_favIcon.href){return
}b.removeChild(e.m_favIcon)
}e.m_favIcon=b.appendChild(c)
};
this.setFavIconSrc=function(b,c){c.m_favIconSrc=b
};
this.setTitle=function(b,c){b.document.title=c;
b.m_title=c
};
this.setFlash=function(e,b,c,d){e.m_previousFlash=e.m_flash;
e.m_flash={message:c,sender:b,unflashAll:d}
};
this.clearFlash=function(f,b){if(!f.m_flash){return
}var d=f.m_flash.unflashAll;
if(b){f.m_flash=f.m_previousFlash
}else{f.m_flash=f.m_previousFlash=null
}if(d){try{gWin.map(function(e){if(!e.m_flash||!e.m_flash.unflashAll){return
}if(b){e.m_flash=e.m_previousFlash
}else{e.m_flash=e.m_previousFlash=null
}})
}catch(c){}}};
this.onFlashTitle=function(d){var b=!meeboApp.util.hasMeeboExtension()||!MeeboExtension.getNotificationPreference("blink");
var c=d.document;
if(!d.m_flash||(d.m_flash&&d.m_focus)){if(b){c.title=d.m_title
}d.m_iconIndex=d.m_flashIndex=0;
this.clearFlash(d);
gBrowser.setFavIcon(gImages.getPath()+d.m_favIconSrc+".ico",d);
return
}if(d.m_iconIndex++%2){gBrowser.setFavIcon(gImages.getPath()+d.m_favIconSrc+".ico",d)
}else{gBrowser.setFavIcon(gImages.getPath()+d.m_favIconSrc+"-rev.ico",d)
}var e;
if(d.m_flashIndex==0){e=d.m_title
}else{if(d.m_flashIndex==1&&d===window){e=d.m_flash.sender+"!"
}else{e='"'+d.m_flash.message+'"'
}}if(b){c.title=e
}d.m_flashIndex=(d.m_flashIndex+1)%((d===window)?3:2)
};
this.flashTitle=function(){if(!window.gImages){return
}gWin.map(hitch(gBrowser,"onFlashTitle"))
};
this.setIgnoreBlurEvent=function(b){this.m_ignoreBlurEvent=b
};
this.setFocus=function(d,b){eventlog("focus");
var e=b?gWin(b):d;
if(e.m_focus){return
}e.m_focus=true;
this.clearFlash(e);
if(e.m_windowId){var f=gWindows[e.m_windowId];
if(f){if(!f.isActive()){gWindowMgr.activateWindow(f)
}f.onWindowFocus()
}}else{var c=gWindowMgr.getActiveConvWindow();
if(c){c.stopBuddyMessageFeedback()
}}this.incrementFocusTime();
if(!this.m_focusTimeStart){this.m_focusTimeStart=new Date().getTime()
}gPubSub.publish(this,"meeboApp.browser::focus")
};
this.setUnfocus=function(c,b){if(this.m_ignoreBlurEvent){return
}eventlog("unfocus");
var d=b?gWin(b):c;
d.m_focus=false;
if(d.m_windowId){var e=gWindows[d.m_windowId];
if(e){e.onWindowUnfocus()
}}this.incrementFocusTime();
this.m_focusTimeStart=null;
if(gMediaBar){gMediaBar.onRollOutLeaderboard()
}};
this.incrementFocusTime=function(){if(this.m_focusTimeStart){var b=new Date().getTime();
var c=(b-this.m_focusTimeStart)||0;
this.m_focusTime+=c;
this.m_focusTimeStart=b
}};
this.onEventMgrChangeState=function(d,b,e){this.m_focusTime=0;
this.m_focusTimeStart=new Date().getTime();
if(e=="done"){var c=gEventMgr.inNetworkInterrupt()?gLang.reconnectHeader:gLang.goodbyeHeader;
gWin.map(function(f){gBrowser.setFlash(f,gLang.meeboMessage,c,true)
})
}else{if(e=="reconnecting"){this.clearFlash(window,true)
}}};
this.onBeforeEvents=function(b){this.incrementFocusTime();
b.focusTime=Math.floor(this.m_focusTime/1000)
}
};
meeboApp.util={};
meeboApp.util.hasMeeboExtension=function(){return(typeof MeeboExtension!="undefined"&&MeeboExtension.xpcom.window==window)
};
meeboApp.util.isMeeboExtensionCompatible=function(){return true
};
meeboApp.util.MeeboExtensionNewWindowHandler=function(){meeboApp.updateStatusPanelIcon()
};
meeboApp.util.MeeboExtensionAutoLogin=function(){var a=function(){var c=MeeboExtension.retrieveLogin();
if(c){var f=c.network;
var e=c.username;
var d=c.password;
gLogon.removeAccounts();
var b=meebo.util.createAccount(e,f,d);
if(typeof b!="string"){gNetworkMgr.requestLogin("joinexisting",[b])
}}};
runInMainContext(null,a)
};
meeboApp.util.tree={};
meeboApp.util.tree.getBuddySortIndex=function(a){var b=a.getExtra();
return[(b.isOnline()?"0":"1"),(b.getType()=="chat"?"0":"1"),b.getAlias().toLowerCase(),b.getProtocol(),b.getUser()].join("/")
};
meeboApp.util.tree.getBuddyProtocolSortIndex=function(a){var b=a.getExtra();
return[(b.getType()=="chat"?"0":"1"),b.getProtocol(),meeboApp.util.tree.getBuddySortIndex(a)].join("/")
};
meeboApp.util.tree.getBuddyStatusSortIndex=function(a){var b=a.getExtra();
return[(b.getType()=="chat"?"0":"1"),(b.isOnline()?"0":"1"),(!b.isBlocked||!b.isBlocked()?"0":"1"),(!b.isMobile||!b.isMobile()?"0":"1"),(!b.isAway||!b.isAway()?"0":"1"),(!b.isIdle||!b.isIdle()?"0":"1"),meeboApp.util.tree.getBuddySortIndex(a)].join("/")
};
meeboApp.util.tree.getBuddyGroupChatSortIndex=function(a){var c=a.getExtra();
var b=a.getPresence&&a.getPresence();
if(!b){return c
}return[(c.isYourself()?"0":"1"),(b.isOnline()&&!b.isPending()?"0":"1"),(b.isPending()?"0":"1"),(!b.isOnline()?"0":"1"),b.getAlias().toLowerCase()].join("/")
};
meeboApp.util.tree.getGroupSortIndex=function(a){var c=a.getExtra(),b=c.getName();
return[(b==gLang.meeboChats?"0":"1"),(b==gLang.recentRooms?"0":"1"),(c!=gBuddyListDlg.m_offlineGroup?"0":"1"),b.toLowerCase()].join("/")
};
Class("meeboApp.util.search",function(){this.initialize=function(){this.reset()
};
this.reset=function(){this.m_root=null;
this.m_oldHtml=null;
this.m_searchText="";
this.m_markings=null
};
this.find=function(b,a){var c;
if(!this.m_root||this.m_searchText!=a){this.unhighlightLast();
c=this.findFirst(b,a)
}else{c=this.findNext()
}return c
};
this.findFirst=function(h,l){var f="";
var m=[];
function a(o){if(o.data){f+=o.data;
for(var n=0;
n<o.data.length;
n++){m.push(o)
}}if(!o.childNodes){return
}for(var n=0;
n<o.childNodes.length;
n++){a(o.childNodes[n])
}}function d(o){var n=m[o];
while(o>0&&m[o-1]==n){o--
}return o
}function c(){a(h);
var q=new RegExp(l,"gi");
var p;
while(p=q.exec(f)){var o=document.createRange();
var t=q.lastIndex-p[0].length;
var n=q.lastIndex-1;
o.setStart(m[t],t-d(t));
o.setEnd(m[n],n-d(n)+1);
var s=document.createElement("span");
s.setAttribute("isMarkedNode","true");
o.surroundContents(s)
}}function b(){var n=document.body.createTextRange();
n.moveToElementText(h);
var o=n.duplicate();
while(n.findText(l,1,0)&&o.inRange(n)){n.pasteHTML('<span isMarkedNode="true">'+n.htmlText+"</span>");
n.collapse(false)
}}function k(){var n=h.innerHTML.split(l);
h.innerHTML=n.join('<span isMarkedNode="true">'+l+"</span>")
}this.m_root=h;
this.m_searchText=l;
this.m_markings=[];
this.m_lastFind=-1;
var g=h.getElementsByTagName("span");
for(var e=0;
e<g.length;
e++){if(g[e].getAttribute("isMarkedNode")=="true"){g[e].removeAttribute("isMarkedNode")
}}if(!ui.isWebKit&&document.createRange&&document.createRange().surroundContents){c()
}else{if(document.body.createTextRange&&document.body.createTextRange().findText){b()
}else{k()
}}var g=h.getElementsByTagName("span");
for(var e=0;
e<g.length;
e++){if(g[e].getAttribute("isMarkedNode")=="true"){this.m_markings.push(g[e])
}}return this.findNext()
};
this.findNext=function(){this.unhighlightLast();
return this.highlightNext()
};
this.unhighlightLast=function(){if(this.m_markings&&this.m_lastFind!=-1){removeClassName(this.m_markings[this.m_lastFind],"meeboChatLogViewerFind")
}};
this.highlightNext=function(){var a=null;
if(this.m_markings&&++this.m_lastFind<this.m_markings.length){addClassName(this.m_markings[this.m_lastFind],"meeboChatLogViewerFind");
a=this.m_markings[this.m_lastFind]
}else{this.reset()
}return a
}
});
function sortLogins(d,c){if(!d&&!c){return 0
}if(!d||!d.getName){return -1
}if(!c||!c.getName){return 1
}if(d.getNetwork()=="meebome"){return 1
}if(c.getNetwork()=="meebome"){return -1
}if(d.getName().toLowerCase()<c.getName().toLowerCase()){return -1
}if(d.getName()>c.getName()){return 1
}return 0
}function sortBuddies(e,d){if(!e&&!d){return 0
}if(!e||!e.getAlias||!e.isOnline){return -1
}if(!d||!d.getAlias||!d.isOnline){return 1
}if(e.isOnline()&&!d.isOnline()){return -1
}if(!e.isOnline()&&d.isOnline()){return 1
}var c=normalizeString(e.getAlias());
var f=normalizeString(d.getAlias());
if(c<f){return -1
}if(c>f){return 1
}return 0
}function getBuddyListId(){return"buddylistwin"
}function getMeeboChatProfileId(a){return normalizeString(a)+"-bprofile"
}function getChatGroupId(b,a){return normalizeString(a)+"-"+normalizeString(b)+"brow"
}function getFailSignOnDlgId(){return"failSignOnDlg"
}function getReconnectDlgId(){return"reconnectDlg"
}function getAddBuddyDlgId(){return"addBuddyDlg"
}function getAddBuddyGroupDlgId(){return"addBuddyGroupDlg"
}function getRemoveBuddyDlgId(){return"removeBuddyDlg"
}function getRemoveBuddyGroupDlgId(){return"removeBuddyGroupDlg"
}function getIMBuddyDlgId(){return"IMBuddyDlg"
}function getGroupChatDlgId(){return"GroupChatDlg"
}function getSignOnDlgId(){return"signOnDlg"
}function getMyMeeboId(){return"myMeeboId"
}function getCreateGroupChatDlgId(){return"createGroupChatDlg"
}function getStatusMenuDlgId(){return"statusMenuDlg"
}function getProfileId(a){return a.getId()+"-profile"
}function getJoinDlgId(){return"joinDlg"
}function getWelcomeDlgId(){return"welcomeWin"
}function getDebugDlgId(){return"debugWin"
}function getNoAccountsDlgId(){return"noAccountsDlg"
}function getAwayMenuId(){return"statusmenu"
}function getAwayEditMenuId(){return getAwayMenuId()+"edit"
}function getChatLogDlgId(){return"chatlogdlg"
}function getRoomInviteDlgId(a){return"roominvitedlg-"+a.getId()
}function getRoomWidgetDlgId(a){return"roomwidgetdlg-"+a.getId()
}function getAddWidgetDlgId(){return"addwidgetdlg"
}function getRoomGalleryDlgId(){return"roomgallerydlg"
}meeboApp.util.flashLoadMedia=function(b,a){if(gWindows[b]){gWindows[b].onFlashLoadMedia(a)
}};
meeboApp.util.flashShowAd=function(b,a){if(gWindows[b]){gWindows[b].onFlashShowAd(a)
}};
meeboApp.util.flashClickMedia=function(b,a){if(gWindows[b]){gWindows[b].onFlashClickMedia(a)
}};
meeboApp.util.flashClickRemove=function(b,a){if(gWindows[b]){gWindows[b].onClickRemove(a)
}};
meeboApp.util.flashClickAdd=function(b,a){if(gWindows[b]){gWindows[b].onMedia()
}};
meeboApp.util.flashHandleAdComplete=function(a){if(gWindows[a]){gWindows[a].onFlashAdComplete()
}};
meeboApp.util.protocol={};
function buildAccountMenu(o,d,p,k,g,l,t,f,h,b,u){var c=new ui.menuheader(o,"",p,k,g,18,false,0,false,false,0).create(gWin(d));
d.appendChild(c.getElement());
var m=c.m_element.style;
if(f&&h){m.top=f+"px";
m.left=h+"px"
}b=b||{};
b.online=true;
var a=gLogon.getLogons(b);
a.sort(sortLogins);
var e=0;
for(var q=0,n;
(n=a[q]);
q++){var x=n.getNetwork();
var w=n.getDisplayName();
if(n.isAnonymous()){continue
}var v="network/"+x+"_14_online.gif";
c.addMenuItem(w,v,n,n==u);
e++
}if(e==0){return
}return c
}meeboApp.util.protocol.getBuddyProtocolIcon=function(b,d){var c=b.getNetwork(),a;
if(d){a="network/"+c+"_14_online.gif"
}else{if(b.isBlocked()){a="blocked_logo_small.gif"
}else{if(!b.isOnline()){a="network/"+c+"_14_offline.gif"
}else{if(b.isMobile()){a="mobile_logo_small.gif"
}else{a="network/"+c+"_14_"+(b.isAway()?"away":"online")+".gif"
}}}}return a
};
meeboApp.logonWaitDlg=function(){this.m_numWait=0;
this.m_html;
this.m_element;
this.m_win=window;
this.setPos=function(a,e,b,d){var c=$("wait")||this.m_element;
if(!c){return
}c.style.position="absolute";
if(a){c.style.left=a+"px"
}if(e){c.style.top=e+"px"
}if(b){c.style.width=b+"px"
}if(d){c.getElementsByTagName("div")[0].style.height=d+"px"
}};
this.positionRelativeTo=function(b){var c=posWithRespectTo(b,this.m_win.document.body);
var a=c.x+((b.offsetWidth/2)-(this.m_element.offsetWidth/2));
var d=c.y+((b.offsetHeight/2)-(this.m_element.offsetHeight/2));
this.setPos(a,d)
};
this.showWait=function(h,k,g){this.m_win=gWin(g);
this.m_win.document.body.style.cursor="default";
var a=$("wait");
var b=false;
if(!a){b=true;
a=this.m_win.document.createElement("div");
a.innerHTML='<b class="corner waitcorner">				<b class="waitcorner1"></b><b class="waitcorner2"></b>				<b class="waitcorner3"></b><b class="waitcorner4"></b>				<b class="waitcorner5"></b></b>				<div id="waitcontent"></div>				<b class="corner waitcorner"><b class="waitcorner5"></b>				<b class="waitcorner4"></b><b class="waitcorner3"></b>				<b class="waitcorner2"></b><b class="waitcorner1"></b></b>';
a.id="wait"
}this.m_element=a;
var e="<table><tr><td>"+h+"</tr></table>";
a.getElementsByTagName("div")[0].innerHTML=this.m_html=e;
a.style.visibility="visible";
if(k){var d=document.createElement("img");
d.src=k;
if(d.height){fixPng(d)
}else{d.className="fixPng";
d.onload=function(){fixPng(d)
}
}var c=document.createElement("td");
c.appendChild(d);
var f=a.getElementsByTagName("tr")[0];
f.insertBefore(c,f.firstChild)
}this.setPos(null,null,200,null);
if(b){this.m_win.document.body.appendChild(a)
}if(g){this.positionRelativeTo(g)
}};
this.hideWait=function(){this.m_win.document.body.style.cursor="";
this.setPos(-999,-999,0,0);
this.m_numWait=0;
removeElement($("wait"))
};
this.isShowing=function(){return this.m_element&&this.m_win&&this.m_element.parentNode==this.m_win.document.body
};
this.updateWait=function(a){if(!this.isShowing()){return
}this.showWait(this.m_html+'<br><span class="fineprint">'+a+"</span>")
};
this.decrementWait=function(){this.m_numWait--;
if(this.m_numWait<=0){this.hideWait()
}};
this.incrementWait=function(){this.m_numWait++
}
};
Class("meeboApp.info",ui.element,function(a){this.initialize=function(){this.m_win=window;
this.m_id="infoTooltip";
this.m_infoTimer;
this.m_hideTimer;
this.m_treeWithHover;
gPubSub.subscribe("meebo.EventMgr::changeState",this,"onEventMgrChangeState")
};
this.create=function(){this.m_element=this.m_win.document.createElement("div");
this.m_element.style.display="none";
this.m_win.document.body.appendChild(this.m_element);
this.m_element.id=this.m_id;
this.m_element.innerHTML='			<b class="corner"><b class="corner1"><b></b></b>			<b class="corner2"><b></b></b><b class="corner3"></b>			<b class="corner4"></b><b class="corner5"></b></b>			<div id="infoTooltipContent"></div>			<b class="corner"><b class="corner5"></b>			<b class="corner4"></b><b class="corner3"></b>			<b class="corner2"><b></b></b><b class="corner1"><b></b></b></b>';
ui.connectEvent(this.m_element,"mouseover",this,"onMouseOver");
ui.connectEvent(this.m_element,"mouseout",this,"onMouseOut")
};
this.getBody=function(){return $("infoTooltipContent")
};
this.moveToTop=function(){this.m_element.style.zIndex=gWindowMgr.getNextZIndex()+2
};
this.hideInfo=function(){this.clearTimeout();
this.m_element.style.display="none";
this.setTreeWithHover(null)
};
this.showInfo=function(l){if(this.m_infoTimer!=-1){return
}var g=l.getExtra();
if(!g){return
}var c=l.getPresence?l.getPresence():null;
var d=this.m_element;
var f=this.getBody();
f.style.height="";
var k=l.getElement();
var e=posWithRespectTo(k);
var h=l.getTree().getElement();
var b=posWithRespectTo(h);
if(!this.isVisible()){this.setPos(-999,-999)
}this.m_element.style.display="";
this.setInfo(g,c);
this.positionRelativeTo(b.x,e.y-11,h.offsetWidth,k.offsetHeight);
this.makeVisible()
};
this.positionRelativeTo=function(c,l,d,f){var b=this.getBody();
var e=ui.getClientRect(b);
var k=c+d-10;
var g=l;
if(b.offsetHeight>e.h){b.style.height=(e.h-50)+"px";
g=5
}else{if(g+b.offsetHeight>e.h){g=e.h-(b.offsetHeight+5)
}}if(k+d>e.w){k=c-b.offsetWidth+10
}this.setPos(k,g)
};
this.makeVisible=function(){this.m_element.style.display="";
this.moveToTop()
};
this.setInfo=function(d,c){var b=this.setInfoHtml(this.getInfoForBuddy(d,c));
var f=d.getIconURL();
if(f){var e=createImg(this.m_id+"-icon",b,48,48,f,false,false);
if(e){e.className="buddyIcon";
if(!b.firstChild){b.appendChild(e)
}else{b.insertBefore(e,b.firstChild)
}}}};
this.setInfoHtml=function(d){var c=this.m_win.document.createElement("div");
c.innerHTML=d;
cacheImgs(c);
var b=this.getBody();
b.innerHTML='<div style="clear: both;"></div>';
b.insertBefore(c,b.firstChild);
return c
};
this.getInfoForBuddy=function(d,c){var h="";
if(c&&c.getChat()&&c.getChat().getType()=="chat"){h+="<b>"+d.getName().split("@")[0]+"</b><br><br>";
var g=c.getMedia();
if(g.length){h+=gLang.mostRecentShares;
h+="<table border=0 cellpadding=2 cellspacing=2>";
for(var e=g.length-1;
e>=0;
e--){h+='<tr><td><div style="position: relative;"><img src="'+escapeHTML(g[e].thumbnailUrl)+'"								style="width: 50px; height: 50px;"><img path="'+escapeHTML(g[e].type)+'-frame.gif"								style="position: absolute; top: -1px; left: -1px;"></div></td><td style="color: #667788">'+escapeHTML(g[e].description)+"</td></tr>"
}h+="</table>"
}else{h+=gLang.noRecentShares
}if(c.getWarnCount()){h+="<br><br>"+gLang.warnCount+": "+c.getWarnCount()
}}else{h=meebo.util.emoticons.insertMeeboEmoticons(d.getInfo());
h=h.replace(/src="emoticons\//g,'src="'+gImages.getPath()+"emoticons/");
var f=d.getGroups();
for(var e=0;
e<f.length;
e++){f[e]=f[e].getName()
}var b="<b>"+(f.length==1?gLang.group:gLang.groups)+"</b>: "+f.join(", ")+"<br><br>";
h=this.insertName(d,!d.isOnline()?b:h||"<b>"+gLang.fetchingInfo+"</b>");
if(gShowChatlogLinks&&d.getType()=="chat"&&!d.isPrivate()){h+='<hr><div><a href="'+d.getChatlogURL()+'" target="_blank">'+gLang.viewChatLogs+"</a></div>"
}}return h
};
this.clearTimeout=function(){clearTimeout(this.m_infoTimer);
this.m_infoTimer=-1
};
this.setTimeout=function(c,b){this.clearTimeout();
this.m_infoTimer=setTimeout(hitch(this,function(){this.m_infoTimer=-1;
c()
}),b)
};
this.setHideTimeout=function(b){this.clearHideTimeout();
b=b||0;
this.m_hideTimer=setTimeout(hitch(this,function(){this.m_hideTimer=-1;
this.hideInfo()
}),b)
};
this.clearHideTimeout=function(){clearTimeout(this.m_hideTimer);
this.m_hideTimer=-1
};
this.onMouseOver=function(){this.clearHideTimeout();
if(this.m_treeWithHover){this.m_treeWithHover.highlight(true)
}};
this.onMouseOut=function(){this.setHideTimeout(0);
if(this.m_treeWithHover){this.m_treeWithHover.highlight(false)
}};
this.isVisible=function(){return this.m_element.style.display!="none"
};
this.getTreeWithHover=function(){return this.m_treeWithHover
};
this.setTreeWithHover=function(b){this.clearHideTimeout();
if(this.m_treeWithHover==b){return
}if(this.m_treeWithHover){var c=this.m_treeWithHover.getExtra();
gPubSub.unsubscribe(c,"meebo.IMObject::changeInfo",this);
gPubSub.unsubscribe(c,"meebo.IMObject::changeIcon",this)
}this.m_treeWithHover=b;
if(!b){return
}var c=b.getExtra();
if(!c){return
}gPubSub.subscribe(c,"meebo.IMObject::changeInfo",this,"onBuddyChange");
gPubSub.subscribe(c,"meebo.IMObject::changeIcon",this,"onBuddyChange");
if(!this.isVisible()){this.setTimeout(hitch(this,function(){this.showInfo(b,true);
c.requestInfo()
}),500)
}else{this.clearTimeout();
this.showInfo(b);
this.setTimeout(hitch(c,"requestInfo"),500)
}};
this.clearTreeWithHover=function(){this.setHideTimeout(0)
};
this.handleGroupOn=function(){if(this.isVisible()){this.setPos(-999,-999);
this.setHideTimeout(500)
}};
this.onEventMgrChangeState=function(c,b,d){if(d=="done"){this.hideInfo()
}};
this.onBuddyChange=function(c,b){if(this.isVisible()){this.showInfo(this.m_treeWithHover)
}};
this.makeNameSplittable=function(b){b=b||"";
return ui.isGecko?makeTextSplittable(b):b
};
this.insertName=function(d,g){var c=d.getName();
var e=d.getNetwork();
var b=d.getLogin().getDisplayName();
var f="";
if(d.isMeebome()||d.getNetwork().isCIMPartner()||d.getNetwork()=="facebook"){c=d.getAlias()
}else{if(d.getType()=="chat"){c=d.getChatName()
}}if(e=="aim"){f='<a class="tooltipProfileLink" target="_blank" href="http://profiles.aim.com/'+c+'">('+gLang.profile.toLowerCase()+")</a>"
}return'<img align=left src="'+gImages.getPath()+"network/"+e+'_14_online.gif"><div class="tooltipUserName"><b>'+this.makeNameSplittable(escapeHTML(c))+"</b> "+f+"<br>("+this.makeNameSplittable(escapeHTML(b))+")</div>"+g
};
this.updateIdleInfo=function(e,d,f){if(!e||!f||(f==-1)){return e
}var m=e.indexOf("Idle:</b>");
var b=m+9;
if(m==-1){return e
}var h=e.indexOf("\n",m);
var q=e.slice(0,b);
q+="&nbsp;";
var c="";
if(!d){var o=e.indexOf("<b>Idle:");
if(o==-1){o=e.indexOf("<b> Idle:");
if(o==-1){return e
}}var n=e.slice(0,o);
if(h==-1){h=e.length
}var l=e.slice(h,e.length);
return n+l
}if(h!=-1){c=e.slice(h,e.length)
}var g=new Date().getTime();
g=g/1000;
var k=g-f;
var p=getTimeString(Math.floor(k));
return q+p+c
};
this.updatePersistenceInfo=function(d,c){var e=/<b>Description:<\/b> [\d]+/;
var b=getTimeString(Math.floor(c));
return d.replace(e,"<b>Time on page:</b> "+b)
}
});
Class("meeboApp.BuddyRow",ui.TreeNode,function(a){this.m_subscriptions={"meebo.IMObject::changeOnline":"onBuddyChangeOnline","meebo.IMObject::changeAlias":"markRedraw","meebo.Buddy::changeIdle":"onBuddyChangeIdle","meebo.Buddy::changeAway":"onBuddyChangeAway","meebo.Buddy::changeBusy":"onBuddyChangeBusy","meebo.Buddy::changeStatusMessage":"onBuddyChangeStatusMessage","meebo.Buddy::changeTyping":"markRedraw","meebo.Buddy::changeMobile":"markRedraw","meebo.Buddy::changeBlocked":"markRedraw"};
this.initialize=function(b,c){a(this,"initialize",[c]);
this.subscribe("Activate",this,"onActivate");
this.m_extra=b;
this.m_className+=" buddyRow";
this.m_headerClassName+=(b.isAway()?" away":"")+(b.isIdle()?" idle":"");
gPubSub.subscribeAll(this.m_extra,this,this.m_subscriptions)
};
this.getHeaderHTMLString=function(){var b=this.getImageClassName();
return'<m_span class="img '+b+(ui.isWebKit||ui.isOpera?'">&nbsp;':'">')+'<m class="img" style="background-image: url('+util.query.relativeTo(this.getBackgroundImage(b),window.location)+');"></m></m_span><m_span class="name">'+escapeHTML(this.m_extra.getAlias())+'</m_span> <m_span class="status">'+escapeHTML(this.getStatusText())+"</m_span>"
};
this.getStatusText=function(){var b=this.m_extra,c;
if(!b.isOnline()){c=""
}else{if(b.isBusy()){c=" - "+gLang.busyShort
}else{c=b.getStatusMessage();
if(c){c=" - "+c
}}}return c
};
this.getImageClassName=function(){var c=this.m_extra;
var b="";
if(c.isBlocked()){b="blocked"
}else{if(!c.isOnline()){b="offline"
}else{if(c.getTyping()==1){b="typing"
}else{if(c.getTyping()==2){b="typed"
}else{if(c.isMobile()){b="mobile"
}else{if(c.isAway()||c.isBusy()){b="away"
}else{b="online"
}}}}}}return b
};
this.getBackgroundImage=function(b){var c="";
switch(b){case"blocked":case"typed":case"typing":case"mobile":c=gImages.getPath()+"status-icons"+(this.m_showFeedback||b=="typing"?"-ax":"")+".gif";
break;
default:c=gImages.getPath()+"network/"+this.m_extra.getNetwork()+(this.m_showFeedback?"-ax":"_14")+".gif"
}return c
};
this.showFeedback=function(b){if(this.m_showFeedback==b){return
}this.m_showFeedback=b;
this.toggleHeaderClassName(b,"messageFeedback");
this.markRedraw()
};
this.onActivate=function(){var b=new Date().getTime();
runInMainContext(gWindowMgr,"createIMWindow",this.m_extra,true);
startlogtime(this.m_extra.getId(),b)
};
this.onBuddyChangeOnline=function(c,b,d){if(!d){this.removeHeaderClassName("away");
this.removeHeaderClassName("idle")
}this.markRedraw()
};
this.onBuddyChangeStatusMessage=function(c,b){this.markRedraw()
};
this.onBuddyChangeAway=function(c,b,d){this.toggleHeaderClassName(d,"away");
this.markRedraw()
};
this.onBuddyChangeBusy=function(d,c,b){this.toggleHeaderClassName(b,"away");
this.markRedraw()
};
this.onBuddyChangeIdle=function(d,b,c){this.toggleHeaderClassName(c,"idle");
this.markRedraw()
};
this.destroy=function(){for(var b in this.m_subscriptions){gPubSub.unsubscribe(this.m_extra,b,this)
}}
});
Class("meeboApp.ChatRow",ui.TreeNode,function(a){this.initialize=function(b,c){a(this,"initialize",[c]);
this.subscribe("Activate",this,"onActivate");
this.m_extra=b;
this.m_className+=" roomRow";
this.m_subscriptions={"meebo.IMObject::changeOnline":"markRedraw","meebo.IMObject::changeAlias":"markRedraw"};
gPubSub.subscribeAll(this.m_extra,this,this.m_subscriptions)
};
this.getHeaderHTMLString=function(){return'<m_span class="img">'+(ui.isWebKit||ui.isOpera?"&nbsp;":"")+'<m class="img" style="background-image: url('+gImages.getPath()+this.getImage()+');"></m></m_span><m_span class="name">'+escapeHTML(this.m_extra.getAlias())+"</m_span>"
};
this.getImage=function(){var c=this.m_extra;
var b="chats_logo_tiny";
if(!c.isOnline()){b+="_grayed.gif"
}else{var d=c.hasNewMessage()&&!c.isInChat();
b+=".gif"
}return b
};
this.getStatusText=function(){var c=this.m_extra;
var f=c.getCount();
var h=(f==1?gLang.onePerson:sprintf(gLang.multiPerson,f));
if(c.m_lastMsg>0){var g=(Math.floor(new Date().getTime()/1000))-c.m_lastMsg;
var k=Math.floor(g/86400);
var b=Math.floor(g/3600);
var d=Math.floor(g/60);
var e="";
if(k>0){e=k==1?gLang.lastMsgDayAgo:sprintf(gLang.lastMsgDaysAgo,k)
}else{if(b>0){e=b==1?gLang.lastMsgHourAgo:sprintf(gLang.lastMsgHoursAgo,b)
}else{if(d>0){e=d==1?gLang.lastMsgMinuteAgo:sprintf(gLang.lastMsgMinutesAgo,d)
}else{e=gLang.lastMsgLessMinuteAgo
}}}if(e){h+=", "+e
}}return h
};
this.onActivate=function(){meeboApp.joinRoom(this.m_extra);
gNetworkMgr.doUILog("buddylistdlg","roomrow","launch"+(this.m_extra.m_isPersonal?"-personal":""),true)
};
this.destroy=function(){for(var b in this.m_subscriptions){gPubSub.unsubscribe(this.m_extra,b,this)
}}
});
Class("meeboApp.imGroupRow",ui.TreeNode,function(a){this.initialize=function(b,c){a(this,"initialize",[c]);
this.m_extra=b;
this.m_bToggleHandle=true;
this.m_headerClassName+=" toggle-open"
};
this.createContent=function(){this.setToggled(gPrefs.getPref("gn:"+this.getExtra().getName(),false));
a(this,"createContent",arguments)
};
this.getText=function(){var b=this.m_extra.getBuddies({online:true});
return this.m_extra.getName()+" ("+b.length+"/"+b.totalLength+")"
};
this.dropHandle=function(c){if(typeof c!="object"){return
}var f=this.getExtra();
var e=f.getName();
var d=[];
for(var g in c){if(c[g].getType()!="buddy"&&c[g].getType()!="chat"){continue
}var b=c[g].getExtra();
if(b.hasGroup(f)||!b.getNetwork().supports("groups")){continue
}d.push(b)
}if(d.length){runInMainContext(gNetworkMgr,gNetworkMgr.requestMoveBuddy,hitch(gNetworkMgr,"receiveAddBuddy"),d,e);
return true
}};
this.dropHover=function(b){this.highlight(b)
}
});
Class("meeboApp.groupChatRow",ui.TreeNode,function(a){this.initialize=function(c,b){a(this,"initialize");
this.m_className+=" ImGroupChatRow";
this.m_indentation=0;
this.m_presence=b;
this.m_extra=c;
this.m_text=this.m_presence.getAlias();
this.m_badgeImg;
this.m_badgeSrc=null;
this.m_timeoutId=0;
this.m_id=this.generateId();
this.m_colors=["#D35900","#cccc00","#cc00cc","#00cccc","#00cc00","#cc0000","#0000cc","#000000","#88cc00","#00cc88","#cc0088","#f84","#f08","#44f","#f80","#08f"];
this.setColor()
};
this.createContent=function(){a(this,"createContent",arguments);
cacheImgs(this.getHeader());
this.updateBadgeImage()
};
this.getHeaderHTMLString=function(){return'<img path="'+this.getImage()+'" height="20" width="20" class="BuddyIcon" align="top" png="true"			><m_span class="label">'+escapeHTML(this.getText())+"</m_span>"
};
this.getPresence=function(){return this.m_presence
};
this.setExtra=function(b,c){this.m_presence=c;
this.m_extra=b;
this.setId(this.generateId());
this.setColor();
this.setText(this.getPresence().getAlias());
this.updateImage();
this.updateBadgeImage()
};
this.updateBadgeImage=function(){var b=null;
if(this.m_presence.isMuted()){b="muted.gif"
}else{if(this.m_presence.isOwner()||this.m_presence.isSubModerator()){b="moderator.gif"
}}if(this.m_badgeSrc==b){return
}this.m_badgeSrc=b;
if(b==null){removeElement(this.m_badgeImg)
}else{if(!this.m_badgeImg){this.m_badgeImg=createImg(this.m_id+"-badge",this.m_element,12,12,b,null,true);
this.m_badgeImg.className="BuddyBadge"
}else{gImages.requestImage(b,this.m_badgeImg)
}this.getHeader().appendChild(this.m_badgeImg)
}};
this.getColor=function(){return this.m_color
};
this.setColor=function(){var c=this.m_extra,b=c.getName();
for(var d=0,e=0;
d<b.length;
d++){e+=b.charCodeAt(d)
}this.m_color=this.m_colors[b==c.isYourself()?0:e%this.m_colors.length]
};
this.isPending=function(){return this.m_presence.isPending()
};
this.setPending=function(b){this.m_presence.setPending(b);
this.updateFont();
this.updateImage();
if(!b){if(this.m_timeoutId){clearTimeout(this.m_timeoutId)
}}else{this.m_timeoutId=setTimeout(hitch(this,"updateImage",true),30000)
}};
this.updateImage=function(b){if(!this.getHeader()){return
}gImages.requestImage(this.getImage(b),this.getHeader().firstChild)
};
this.getImage=function(e){var d=this.m_extra;
var c=this.m_presence;
var b="";
if(c.isPending()){if(!e){b+="miniwait_mid.gif"
}else{b+="miniwait_midstill.gif"
}}else{if(c.isMuted()){b+="blocked_logo_small.gif"
}else{if(d.getIconURL()){b=d.getIconURL()
}else{if(d.getNetwork()=="meebome"){b+="meebome_logo_"+(c.isOnline()?"bg":"off")+"_rooms.png"
}else{b+="network/"+d.getNetwork()+"_20_"+(c.isOnline()?"online":"offline")+".png"
}}}}return b
};
this.setText=function(b){this.m_text=b;
var c=this.getHeader().childNodes[1];
if(c){setText(c,b)
}};
this.updateFont=function(b){this.toggleHeaderClassName(b,"showFeedback");
this.toggleHeaderClassName(this.m_presence.isPending(),"pending");
this.toggleHeaderClassName(!this.m_presence.isOnline(),"offline");
this.getHeader().style.color=this.m_presence.isOnline()?this.m_color:"gray"
};
this.generateId=function(){var b=this.m_presence.getChat();
return(b?b.getId():getUniqueId())+"-"+this.m_extra.getId()
}
});
Class("meeboApp.groupChatRoomRow",ui.TreeNode,function(a){this.initialize=function(d,c){a(this,"initialize");
this.m_className+=" ImGroupChatRoomRow";
this.m_indentation=0;
this.m_roomSize=c;
this.m_extra=d;
var b=d.split("___spill___");
this.m_spillNum=parseInt(b[1]);
this.m_text="  "+b.shift()+" #"+b.shift()+"   ("+this.m_roomSize+")";
this.m_id=this.generateId();
this.m_timeoutId=0;
this.m_presence=null;
this.m_colors=["#D35900","#cccc00","#cc00cc","#00cccc","#00cc00","#cc0000","#0000cc","#000000","#88cc00","#00cc88","#cc0088","#f84","#f08","#44f","#f80","#08f"];
this.setColor()
};
this.createContent=function(b){a(this,"createContent",arguments);
cacheImgs(this.getHeader());
this.updateFont()
};
this.getHeaderHTMLString=function(){return'<img path="'+this.getImage()+'" height="20" width="20" class="BuddyIcon" align="top" png="true"			><m_span class="label">'+escapeHTML(this.getText())+"</m_span>"
};
this.getColor=function(){return this.m_color
};
this.setColor=function(){this.m_color=this.m_colors[this.m_spillNum%this.m_colors.length]
};
this.updateImage=function(b){gImages.requestImage(this.getImage(b),this.getHeader().firstChild)
};
this.getImage=function(){var b="chats_logo_small.gif";
return b
};
this.setText=function(b){this.m_text=b;
var c=this.getHeader().getElementsByTagName("span")[0];
if(c){setText(c,b)
}};
this.generateId=function(){return this.m_extra
};
this.updateFont=function(b){this.toggleHeaderClassName(b,"showFeedback");
this.getHeader().style.color=this.m_color
}
});
Class("meeboApp.imDlg",ui.dlg,function(a){this.initialize=function(b){a(this,"initialize");
this.control="imdlg";
this.m_resizeTimerLength=75;
this.m_minHistoryH=20;
this.m_minGroupChatHistoryH=250;
this.m_minHistoryW=185;
this.m_minMediaW=200;
this.m_fontbarH=25;
this.m_marginWidths=20;
this.m_statusH=15;
this.m_vertSliderSize=3;
this.m_horzSliderSize=4;
this.m_minMessageH=18;
this.m_wbrCount=8;
this.m_minX=this.m_minHistoryW;
this.m_minY;
this.setImObject(b);
this.m_applicationRoom=null;
this.m_buddy=null;
this.m_groupChatId=null;
this.m_isMeebome=b.isMeebome();
this.m_prevSystemMsg;
this.m_bBlock=!b.m_bBlocked;
var c=gPrefs.getPref("font");
this.m_bBold=c.bBold;
this.m_bItalics=c.bItalics;
this.m_bUnderline=c.bUnderline;
this.m_fontSize=c.size;
this.m_fontColor=c.color;
this.m_greyText="#677788";
this.m_fontType=this.m_defaultFontType=c.type;
this.m_topToolbar;
this.m_topToolbarH=30;
this.m_topToolbarType="";
this.m_fontbar;
this.m_mediaList=null;
this.m_pendingMedia={};
this.m_loadedMedia={};
this.m_bannedMedia={};
this.m_mediaQueue=[];
this.m_sliderTop;
this.m_sliderBottom;
this.m_message;
this.m_history;
this.m_inviteMenu;
this.m_contentHeight=0;
this.m_contentWidth=0;
this.m_buddyListContextMenu;
this.m_buddyList;
this.m_trees={};
this.m_buddyListW=110;
this.m_buddyListSlider;
this.m_buddyListSliderImage;
this.m_guestGroup;
this.m_memberGroup;
this.m_groupBuddies;
this.m_buddyListMinW=99;
this.m_isMorphing=false;
this.m_bGroupChatOffline=false;
this.m_bGroupChatHidden=true;
this.m_viewChatLogLink=null;
this.m_bMediaResize=false;
this.m_bMediaDrag=false;
this.m_historyMediaRatio=0.5;
this.m_lastMediaWidth=0;
this.m_historyMediaSlider=null;
this.m_historyMediaSliderImage=null;
this.m_appAreaW=300;
this.m_minGroupChatMediaW=100;
this.m_maxGroupChatHistoryLines=150;
this.m_mediaPlayer=null;
this.m_mediaContainer=null;
this.m_mediaAd=null;
this.m_bAdShowing=false;
this.m_initialMediaItems=[];
this.m_bMediaRequested=false;
this.m_bMediaPlayerLoading=false;
this.m_bPlayerFocused=true;
this.m_chatInfoW=280;
this.m_chatInfoDescrW=210;
this.m_chatInfoH=50;
this.m_chatInfoMargin=8;
this.m_chatImg=null;
this.m_chatImgMargin=20;
this.m_mediaCreateTimeoutId=null;
this.m_mediaChangeTimeoutId=null;
this.m_trackingPixel=null;
this.m_appArea=null;
this.m_appList=null;
this.m_appOverlay=null;
this.m_appFrame=null;
this.m_appBar=null;
this.m_appBarHeight=28;
this.m_appLoadingOverlay=null;
this.m_appLoadingTimeoutId=null;
this.m_appLoadingTimeoutSec=20;
this.m_acceptAppLinks={};
this.m_animationAppArea=new ui.Animation({transition:ui.Animation.easeInOut,duration:400});
this.m_animationResizeAppArea=new ui.Animation({transition:ui.Animation.easeInOut,duration:400});
this.m_animationBuddyListArea=new ui.Animation({transition:ui.Animation.easeInOut,duration:400});
this.m_toggleDlgStartWidth=0;
this.m_toggleDlgStartHeight=0;
this.m_dlgStartWidth=0;
this.m_dlgStartHeight=0;
this.m_appAreaStartWidth=0;
this.m_appAreaStartHeight=0;
this.m_appAreaWidthDelta=0;
this.m_appAreaHeightDelta=0;
this.m_toggleGroupChatCallback=null;
this.m_isAppResizeLeft=false;
this.m_isAppResizeTop=false;
this.m_buddyListWidthDelta=0;
this.m_chatTitle=null;
this.m_chatDescription=null;
this.m_mediaHelp=null;
this.m_mediaHelpText=null;
this.m_bSync=true;
this.m_installFlashLink="<a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' target='_blank' dontExpand='true'>";
this.m_bOffline=false;
this.m_temporaryRows={};
this.m_buddyBoldId={};
this.m_status;
this.m_overlay;
this.m_inputDiv;
this.m_inputPromptInput;
this.m_bBuddyIconTimerOverride=false;
this.m_buddyIconTimer;
this.m_buddyIconSrc;
this.m_buddyIcon;
this.m_buddyIconFloater;
this.m_maxBuddyIconW=50;
this.m_maxBuddyIconH=50;
this.m_scrollTimerInterval=80;
this.m_buddyIconTimerOverride;
this.m_resizeTimer=-1;
this.m_resizeTimerStart;
this.m_chatBtn;
this.m_profBtn;
this.m_addBtn;
this.m_blockBtn;
this.m_groupBtn;
this.m_popBtn;
this.m_inviteBtn;
this.m_time=0;
this.m_typingT=0;
this.m_typingTimer;
this.m_bHistoryAtBottom=false;
this.m_bRenamingBuddy=false;
this.m_isShowingPasswordPrompt=false;
this.m_isShowingAliasPrompt=false;
this.m_clickedMedia={};
gPubSub.subscribe("meebo.MeeboAccount::changeState",this,"updateTopToolbar");
gPubSub.subscribe("meebo.BuddyList::addBuddyToGroup",this,"onBuddyChangeGroup");
gPubSub.subscribe("meebo.BuddyList::removeBuddyFromGroup",this,"onBuddyChangeGroup");
gPubSub.subscribe("ui.drag::startResize",this,"showAppIFrameOverlay");
gPubSub.subscribe("ui.drag::startMove",this,"showAppIFrameOverlay");
gPubSub.subscribe("ui.drag::stopResize",this,"hideAppIFrameOverlay");
gPubSub.subscribe("ui.drag::stopMove",this,"hideAppIFrameOverlay");
gPubSub.subscribe("meebo.ApplicationMgr::updateFavorites",this,"updateAppBar");
gPubSub.subscribe(gPrefs,"meebo.Prefs::accountPref",this,"onAccountPrefChange");
gPubSub.subscribe(gPrefs,"meebo.Prefs::receivePrefs",this,"onReceivePrefs");
this.addOnMoveToTop(this,"onMoveToTop")
};
this.doSubscribe=function(c,f){if(!c||!this.m_element){return
}var e={"meebo.IMObject::changeOnline":"onBuddyChangeOnline","meebo.IMObject::changeAlias":"onBuddyChangeAlias","meebo.IMObject::changeIcon":"onBuddyChangeIcon","meebo.IMObject::changeInfo":"onBuddyChangeInfo","meebo.Buddy::changeMobile":"onBuddyChangeMobile","meebo.Buddy::changeBusy":"updateIMStatus","meebo.Buddy::changeAway":"updateIMStatus","meebo.Buddy::changeIdle":"updateIMStatus","meebo.Buddy::changeTyping":"updateIMStatus","meebo.Buddy::changeStatusMessage":"updateIMStatus","meebo.Chat::changeChatId":"onChatChangeChatId","meebo.Chat::addPresence":"onChatAddPresence","meebo.Chat::error":"onChatError","meebo.Room::changeWidgetHash":"updateTopToolbar","meebo.Room::sync":"handleSync","meebo.Room::changeModeratedUrls":"onRoomChangeModeratedUrls","meebo.Room::addMember":"onRoomAddMember","meebo.Room::invite":"onRoomInvite","meebo.ApplicationRoom::receiveIMMsg":"onReceiveAppIMMsg"};
var d=gPubSub[f?"subscribe":"unsubscribe"];
for(var b in e){d.call(gPubSub,c,b,this,e[b])
}};
this.getImObject=function(){return this.m_imobject
};
this.setImObject=function(c){if(this.m_imobject==c){return
}if(this.m_applicationRoom!=this.m_imobject){this.doSubscribe(this.m_imobject,false)
}if(this.m_imobject&&this.m_imobject.getType()=="buddy"){this.stopBuddyMessageFeedback()
}if(this.m_applicationRoom!=c){this.doSubscribe(c,true)
}if(this.getBody()){removeClassName(this.getBody(),this.control+"-"+this.m_imobject.getType());
addClassName(this.getBody(),this.control+"-"+c.getType())
}var b=this.m_imobject;
this.m_imobject=c;
if(this.m_createFnc){this.m_createFnc.a[0]=c
}if(b&&this.isGroupChat()&&this.m_imobject.getChatId()&&(this.m_imobject.constructor!=meebo.ApplicationRoom||this.m_applicationRoom)){this.onJoinGroupChat(this.m_imobject)
}};
this.getApplicationRoom=function(){return this.m_applicationRoom
};
this.setApplicationRoom=function(b){if(this.m_applicationRoom==b){return
}if(this.m_imobject!=this.m_applicationRoom){this.doSubscribe(this.m_applicationRoom,false)
}if(this.m_imobject!=b){this.doSubscribe(b,true)
}this.m_applicationRoom=b
};
this.getApplicationId=function(){var b=this.getApplicationRoom();
var c=b&&b.getApplication();
return(c&&c.app_id)
};
this.setId=function(b){gWindowMgr.reregisterWindow(this.m_id,b);
a(this,"setId",arguments)
};
this.isMeeboGroupChat=function(){return this.m_imobject.getType()=="chat"
};
this.isProtocolGroupChat=function(){return this.m_imobject.getType()=="protocolchat"
};
this.isGroupChat=function(){return this.isMeeboGroupChat()||this.isProtocolGroupChat()
};
this.isFlashInstalled=function(){return util.flash.getVersion().major>=8
};
this.isMediaFlaggable=function(){var b=this.m_imobject;
return !b.isModeratedUrls()||(b.isModeratedUrls()&&b.getYourself()&&b.getYourself().isOwner())
};
this.getSafeProtocol=function(b){if((b=="aim")&&meebo.util.isICQ(this.m_imobject.getName())){return"icq"
}return b
};
this.getIMChannels=function(){if(this.m_applicationRoom&&this.m_buddy&&this.m_applicationRoom.isGuestOnly()){var b=[this.m_applicationRoom,this.m_buddy]
}else{var b=[this.m_buddy||this.m_imobject]
}return b
};
this.sendIM=function(h){if(!this.m_message){return
}if(!stripWhitespace(this.m_message.getText())){this.m_message.clear();
return
}if(this.isMeeboGroupChat()&&!this.m_applicationRoom){var k=this.m_imobject.getLogin();
if(!gLogon.getMeeboUser()&&!k.isUserSpecifiedAlias()){this.showAliasPrompt(hitch(this,"sendIM",h));
return
}}var b=this.getIMChannels();
var l=[];
var c=escapeHTML(this.m_message.getText());
c=c.replace(/\r\n/g,"<br>").replace(/\n/g,"<br>");
var m=this.m_message.formatMessage(c);
this.m_message.clear();
eventlog("imDlg sendIM setFocus");
if(gPrefs.getPref("audioSend")||(!gPrefs.getPref("audioSend")&&!gPrefs.getPref("audioReceive")&&!gSounds.isMuted())){gSounds.playSample("send")
}try{var d=/(^|[^'\"])(\bhttps?:\/\/[^\s\"\<\>)]+)/ig,f=null;
while(f=d.exec(c)){this.logShare(f[2])
}}catch(g){gNetworkMgr.doUILog(this.control,"exception",true,true)
}this.addHistoryIM(this.m_imobject.getUser(),c);
if(b.length>1){gNetworkMgr.requestMultiSend(b,m)
}else{this.sendIMRequest(m,h,b[0])
}gPubSub.publish(this,"meeboApp.imDlg::sendIM",h);
this.m_typingT=0;
clearTimeout(this.m_typingTimer);
this.m_typingTimer=null
};
this.logShare=function(b){var c=meebo.util.getMeeboShareLink(b);
meebo.util.createTrackingPixel({component:"MediaBar",type:"share",shareId:(c&&c.share)||"link"},this.m_imobject.getLogin(),this.m_imobject)
};
this.verifyIMRequest=function(c,b){if(!b){if(c&&(c.msg!=this.m_prevSystemMsg)){this.addHistoryIM(gLang.meeboMessage,c.msg||gLang.imBuddyErrorHeader,true,true);
if(!(/unable to send message/i).test(c.msg)){this.m_prevSystemMsg=c.msg
}}}else{this.m_prevSystemMsg="";
if(this.isMeeboGroupChat()){this.m_imobject.setLastMsg()
}}};
this.sendIMRequest=function(f,e,b){b=b||this.m_imobject;
var c={sender:b.getUser(),receiver:b.getName(),protocol:b.getProtocol(),msg:f,mt:e};
var d=b.getChatId&&b.getChatId();
if(d){c.ch=d
}gNetworkMgr.doRequest("send",c,hitch(this,"verifyIMRequest"));
if(this.m_imobject.updateActivityTime){this.m_imobject.updateActivityTime()
}};
this.onBuddyChangeOnline=function(c,b,d){if(c.getType()!="buddy"){return
}if(this.isVisible()&&c.getLogin().isOnline()&&c.getWentOnlistTime()&&new Date().getTime()-c.getWentOnlistTime()>2000){this.addHistoryIM(gLang.meeboMessage,c.getOnlineStatus(),true,true)
}this.updateIMStatus()
};
this.onBuddyChangeGroup=function(d,b,c,e){if(this.m_imobject!=c){return
}this.updateTopToolbar();
this.updateIMStatus()
};
this.onPresenceChangeAlias=function(d,c,e,b){this.updateRow(this.m_trees[d.getBuddy().getId()]);
this.addHistoryIM(gLang.meeboMessage,sprintf(gLang.isNowKnownAs,escapeHTML(b),escapeHTML(e)),true,true)
};
this.onPresenceChangeModerator=function(d,c,b,e){this.updateRow(this.m_trees[d.getBuddy().getId()]);
gNetworkMgr.doRequest("mcfetchspillovers",{room:this.m_imobject.getChatName()},hitch(this,"populateSpilloverRooms"))
};
this.onBuddyChangeMobile=function(c,b,d){this.updateIMStatus();
if(this.isVisible()){this.addHistoryIM(gLang.meeboMessage,c.getOnlineStatus(),true,true)
}};
this.onBuddyChangeIcon=function(c,b,d){this.updateBuddyIcon(d);
this.updateBuddyIconPosition(this.isHistoryAtBottom())
};
this.onBuddyChangeAlias=function(c,b,d){if(c!=this.m_imobject){return
}this.setWindowCaption();
this.updateIMStatus();
if(this.m_chatTitle){this.m_chatTitle.setText(c.getAlias())
}};
this.onBuddyChangeInfo=function(c,b,d){if(this.isMeeboGroupChat()){this.updateChatInfo()
}};
this.onChatChangeChatId=function(c,b,d){if(this.isGroupChat()){this.setOffline(!d)
}if(d){this.onJoinGroupChat(c)
}else{if(c.constructor==meebo.ApplicationRoom){if(!this.isGroupChat()){if(this.getApplicationRoom()==c){this.addHistoryIM(gLang.meeboMessage,gLang.errorInApp,true,true)
}this.toggleAppArea(false)
}}}};
this.onJoinGroupChat=function(b){var d=b.getChatId();
if(!d||this.m_applicationRoom){return
}this.registerGroupChat(d);
if(this.isMeeboGroupChat()){this.clearOverlay();
this.updateTopToolbar();
gNotice.checkProbation();
if(b.getInvites()){var c=b.getInvites();
this.inviteBuddies(c.invitees,true,"roomCreateDlg",c.msg,c.msgIdx);
b.setInvites(null)
}if(b.isFromAttach()){this.requestRoomInfo()
}}else{this.clearBuddyIcon();
this.setWindowCaption();
this.showGroupChat(d)
}};
this.onChatAddPresence=function(c,b,e){var d=e.getBuddy();
gPubSub.subscribe(e,"meebo.Presence::changeOnline",this,"onPresenceChangeOnline");
if(!this.m_applicationRoom||!meeboApp.platform.isStarted(this.m_applicationRoom.getChatName())){return
}var f=this.m_applicationRoom.getInvites();
if(f){this.m_applicationRoom.clearInvites();
this.inviteBuddies(f.invitees,false,"onstart")
}};
this.onChatError=function(c,b,e){var h="";
var d=c.constructor==meebo.ApplicationRoom;
var g={notAvailable:d?gLang.errorApplicationNotAvailable:gLang.errorRoomNotAvailable,full:d?gLang.errorApplicationFull:gLang.errorRoomFull};
switch(e){case"noexist":h=g.notAvailable;
break;
case"full":h=g.full;
break;
case"empty":h=g.notAvailable;
break;
default:h=g.notAvailable;
break
}var f=c.constructor==meebo.Room;
if(f){gWindowMgr.createNotifyDlg({id:getUniqueId(),caption:gLang.error,parent:this},h);
return
}if(this.isAppAreaVisible()){this.initAppLoadingOverlay(h,null,true)
}else{this.addHistoryIM(gLang.meeboMessage,h,true,true)
}};
this.onRoomChangeModeratedUrls=function(d,b,c){if(this.m_applicationRoom){return
}this.initMediaPlayer();
this.initMediaHelpText(c?"":gLang.pasteAURLInConv)
};
this.onRoomAddMember=function(e,b,d){var c=d.getPresence(e);
if(c){this.moveBuddy(c)
}};
this.onRoomInvite=function(d,b,c){if(d.constructor==meebo.ApplicationRoom&&d.getApplication()){this.addAppUserInvite(c);
meeboApp.platform.invite(d.getChatName(),{alias:c.getAlias()})
}this.addBuddy(c,true)
};
this.onPresenceChangeOnline=function(c,o,h){var p=this.m_applicationRoom||this.m_imobject,g=c.getBuddy();
var e=(p.getType()=="chat"&&!g.isMeeboUser()&&(c.getAlias()==g.getName().split("@")[0]||g.isWidgetUser()));
var n=this.m_trees[g.getId()];
if(h){if(this.getApplicationRoom()){g.setAlias(c.getAlias());
if(g.isYourself()){g.getLogin().setAlias(c.getAlias())
}else{if(!this.m_buddy&&this.m_imobject.constructor!=meebo.ApplicationRoom){this.m_buddy=this.m_imobject
}else{if(!this.isGroupChat()){this.m_buddy=null;
this.makeApp()
}}}}var d=c.m_joiner,b=c.m_joinerProtocol;
if(d&&b){var k=p.getPresences();
for(var l in k){var f=k[l].getBuddy();
if(f.getProtocol()==b&&f.getName()==d){k[l].setPending(false);
this.moveBuddy(k[l]);
break
}}}this.addBuddy(g);
n=this.m_trees[g.getId()]
}else{this.setBuddyOnline(g,false)
}if(p.constructor==meebo.ApplicationRoom){if(this.m_imobject==p){this.setWindowCaption()
}if(h){meeboApp.platform.join(p.getChatName(),c)
}else{meeboApp.platform.leave(p.getChatName(),c)
}}if(!e&&(p.getType()!="chat"||p.isPrivate())){var m=sprintf((p.getType()=="chat"?(h?gLang.buddyJoinRoom:gLang.buddyLeaveRoom):(h?gLang.buddyJoinChat:gLang.buddyLeaveChat)),"");
this.addHistoryIM(c.getAlias(),m,true,true,false,n&&n.getColor())
}else{if(this.m_applicationRoom&&!g.isYourself()){var m=sprintf(h?gLang.buddyJoinApp:gLang.buddyLeaveApp,c.getAlias(),this.m_applicationRoom.getAlias());
this.addHistoryIM(gLang.meeboMessage,m,true,true)
}}if(g.isYourself()&&c.isOwner()&&h){this.updateTopToolbar();
if(!this.m_applicationRoom){this.initMediaPlayer();
this.initMediaHelpText(gLang.pasteAURLInConv);
gNetworkMgr.doRequest("mcfetchspillovers",{room:this.m_imobject.getChatName()},hitch(this,"populateSpilloverRooms"))
}}gBuddyListDlg.updateBuddyRows(p)
};
this.setWindowCaption=function(b,c){a(this,"setWindowCaption",[b||this.m_imobject.getCaption(),c||this.m_imobject.getCaptionImage()])
};
this.updateIMStatus=function(){var h=this.m_imobject;
var k=h.getLogin();
switch(h.getType()){case"buddy":var l="";
var d="";
if(!h.isOnline()){d=h.getOnlineStatus()
}else{if(h.isIdle()){d=gLang.isIdle
}else{if(h.getTyping()==1){l="typing-animated.gif";
d=gLang.isTyping
}else{if(h.getTyping()==2){l="typing-alone.gif";
d=gLang.hasTyped
}else{if(h.isAway()){d=gLang.isAway
}else{if(h.isBusy()){d=gLang.isBusy
}else{if(h.isMobile()){d=gLang.isMobile
}else{d=gLang.isOnline
}}}}}}var e=h.getStatusMessage();
if(e){d+=" - "+e
}d=sprintf(d,h.getAlias());
this.m_time=Math.floor(h.getOnlineTime()/60)
}var c=this.m_time;
if(c!=0&&h.isWidgetUser()){var b=(c==1?gLang.minute:gLang.minutes);
d+=" ("+c+" "+b+")"
}if(!k.isOnline()||!h.isOnlist()){d=""
}var g=getTruncatedText(d,this.m_minHistoryW+50,null,truncateEnd,this.m_ruler);
setText(this.m_status,g);
if(l){var f=createImg("",this.m_status,14,14,l,"",true);
f.style.marginRight="5px";
this.m_status.insertBefore(f,this.m_status.firstChild);
if(ui.isIE){this.m_status.style.lineHeight="16px"
}}break;
case"chat":if(this.m_applicationRoom){removeChildren(this.m_status);
break
}break;
default:removeChildren(this.m_status);
break
}};
this.populateSpilloverRooms=function(f){if(!f){f=this.m_spilloverRoomsGroup
}else{if(!f.length){return
}}var d=this.m_spilloverRoomsGroup;
for(var b=0;
b<f.length;
b++){var c=f[b];
var e=new meeboApp.groupChatRoomRow(c.node,c.num_members);
e.create(this.m_win);
this.connectRoomRowEvents(e);
d.insertItem(e)
}d.setDisplay(true)
};
this.connectRoomRowEvents=function(b){b.unsubscribe("DoubleClick");
b.subscribe("DoubleClick",this,"onSpilloverRoomsClick")
};
this.onSpilloverRoomsClick=function(b){meeboApp.joinRoom(b.m_extra);
gNetworkMgr.doUILog(this.m_control,"status","spilloverrooms")
};
this.updateBuddyIconPosition=function(l){if(!this.m_buddyIcon||!this.m_buddyIconSrc||!this.m_buddyIconSrc.src||this.m_buddyIconSrc.style.visibility=="hidden"||this.m_bBuddyIconTimerOverride){return
}var n=this.getWindowPos().w-this.m_history.offsetWidth-8;
if(this.m_history.scrollHeight>this.m_history.clientHeight){this.m_buddyIconSrc.style.right=n+20+"px"
}else{this.m_buddyIconSrc.style.right=n+2+"px"
}this.m_buddyIcon.style.visibility="visible";
var h=this.m_buddyIconSrc.naturalWidth||this.m_buddyIconSrc.offsetWidth;
var c=this.m_buddyIconSrc.naturalHeight||this.m_buddyIconSrc.offsetHeight;
var e=(h<this.m_maxBuddyIconW)?h:this.m_maxBuddyIconW;
var o=(c<this.m_maxBuddyIconH)?c:this.m_maxBuddyIconH;
this.m_buddyIcon.style.width=(e+4)+"px";
this.m_buddyIcon.style.height=(o+4)+"px";
var f=this.m_buddyIconSrc.complete||(this.m_buddyIconSrc.naturalWidth&&this.m_buddyIconSrc.naturalHeight);
if(f){this.m_buddyIconSrc.style.width=e+"px";
this.m_buddyIconSrc.style.height=o+"px"
}var d=2;
var g=12;
var k=0;
var b=0;
if(this.m_history.scrollTop<g){b=parseInt(this.m_buddyIcon.offsetWidth)
}else{if(d<d+g){d+=g
}k=this.m_history.scrollTop-g
}this.m_buddyIconFloater.style.height=k+"px";
this.m_buddyIconFloater.style.width=b+"px";
this.m_buddyIcon.style.height=(d+this.m_buddyIconSrc.offsetHeight)+"px";
if(l&&!this.isHistoryAtBottom()){var m=(this.m_history.scrollHeight-this.m_history.clientHeight)-this.m_history.scrollTop;
this.m_buddyIconFloater.style.height=(k+m)+"px";
this.m_bBuddyIconTimerOverride=true;
this.m_history.scrollTop=this.m_history.scrollHeight-this.m_history.clientHeight;
if(this.m_buddyIconTimerOverride){clearTimeout(this.m_buddyIconTimerOverride)
}this.m_buddyIconTimerOverride=setTimeout(hitch(this,function(){this.m_bBuddyIconTimerOverride=false
}),this.m_scrollTimerInterval+100)
}};
this.clipIcon=function(){if(this.m_buddyIconSrc&&(this.m_buddyIconSrc.style.visibility!="hidden")){this.m_buddyIconSrc.style.clip="rect(0px "+this.m_buddyIconSrc.offsetWidth+"px "+Math.min(this.m_buddyIconSrc.offsetHeight,this.m_history.clientHeight-4)+"px 0px)"
}};
this.setIconFromBuddyListBuddy=function(){if(!this.m_imobject.isOnlist()){}else{if(this.m_imobject.getIconURL()){this.updateBuddyIcon(this.m_imobject.getIconURL())
}else{if(!this.m_imobject.isInfo()){this.m_imobject.requestInfo()
}}}};
this.updateBuddyIcon=function(b){if(!this.m_buddyIconSrc){return
}if(b){this.m_buddyIconSrc.src=b;
this.m_buddyIconSrc.style.visibility="visible";
ui.connectEvent(this.m_buddyIconSrc,"load",this,"buddyIconOnLoad",false,false)
}else{this.m_buddyIconSrc.style.visibility="hidden"
}};
this.buddyIconOnLoad=function(){ui.disconnectEvent(this.m_buddyIconSrc,"load");
setTimeout(hitch(this,function(){this.updateBuddyIconPosition(this.isHistoryAtBottom());
this.clipIcon()
}),50)
};
this.addToMediaList=function(d,c){if(!this.m_mediaList||this.m_bannedMedia[d.itemUrl]){return
}var d=this.m_mediaList.addMedia(d);
this.updateHistoryMediaItem(d);
if(c){var b=c.getPresence(this.m_imobject);
b.addMedia(d)
}return d
};
this.queueMediaFromUrl=function(f){if(!this.m_mediaList){return
}f=f||this.m_mediaList.getMediaItemByIdx(0).itemUrl;
var e=this.m_mediaList.getMediaItemByUrl(f);
if(!e){return
}var b=[];
var c=this.m_mediaList.getNumMediaItems();
var g=e.idx;
g=0;
for(var d=g;
d<c;
d++){b.push(this.m_mediaList.getMediaItemByIdx(d))
}this.queueGroupChatMedia(b,e.idx)
};
this.initMediaEmbed=function(){var g="sessionKey="+encodeURIComponent(gIMGateway.getSessionKey())+"&sessionId="+encodeURIComponent(gIMGateway.getClientId())+"&windowId="+encodeURIComponent(this.m_id)+"&room="+encodeURIComponent(this.m_imobject.getName())+"&mute="+gSounds.isMuted()+"&sync="+this.m_bSync+"&playMode="+encodeURIComponent("loop")+"&currItem="+encodeURIComponent(this.m_initialCurrItem);
var c=this.m_initialMediaItems;
for(var f=0;
f<c.length;
f++){g+="&queueUrl"+f+"="+encodeURIComponent(c[f].mediaUrl)+","+encodeURIComponent(c[f].itemUrl)+","+encodeURIComponent(c[f].length)+","+encodeURIComponent(c[f].watermark)+","+encodeURIComponent(c[f].type)+","+encodeURIComponent(c[f].isDefaultMedia)+","+encodeURIComponent(c[f].clickUrl)
}var e='<embed src="/flash/mediaplayer.swf" width="100%" height="100%"			type="application/x-shockwave-flash" id="video" allowScriptAccess="always"			wmode="opaque" flashvars="'+g+'"></embed>';
e='<html>			<head></head>			<body style="margin: 0px; overflow: hidden; background-color: black;">'+e+"</body>			</html>";
this.m_mediaContainer.innerHTML='<iframe src="blank.html" width="100%"				height="100%" frameborder="0" class="mediaIframe"></iframe><img path="media_instructions_1.png" class="ImBgImage"><div id="ad" style="position: absolute; left: 0px; top: 0px;				width: 100%; height: 100%; display: none; background-color: white;"></div>';
cacheImgs(this.m_mediaContainer);
this.m_mediaAd=this.m_mediaContainer.getElementsByTagName("div")[0];
var b=this.m_mediaContainer.firstChild;
var d=b.contentWindow;
var h=hitch(this,function(){d=b.contentWindow;
d.document.open();
d.document.write(e);
d.document.close();
d.flashLoadMedia=meeboApp.util.flashLoadMedia;
d.flashShowAd=meeboApp.util.flashShowAd;
d.flashClickMedia=meeboApp.util.flashClickMedia;
d.flashClickRemove=meeboApp.util.flashClickRemove;
d.flashClickAdd=meeboApp.util.flashClickAdd;
this.m_mediaPlayer=d.document.body.firstChild;
ui.connectEvent(this.m_mediaPlayer,"mouseup",this,"focusOnMessage",false,false);
attachIframeMouseHandlers(b,null,null,null);
this.m_bMediaPlayerLoading=false;
setTimeout(hitch(this,function(){this.m_mediaPlayer.SetVariable(this.isAppAreaVisible()?"show":"hide","true")
}))
});
if(d){h()
}else{b.onload=h
}};
this.queueGroupChatMedia=function(c,b){if(!isArray(c)){c=[c]
}if(this.m_bGroupChatHidden||!this.isFlashInstalled()){return
}if(this.m_mediaContainer&&(!this.m_mediaPlayer||this.m_bMediaPlayerLoading)){this.m_initialCurrItem=b||0;
this.m_initialMediaItems=c;
if(!this.m_bMediaPlayerLoading){this.m_bMediaPlayerLoading=true;
this.m_mediaCreateTimeoutId=setTimeout(hitch(this,"initMediaEmbed"),0)
}}else{if(this.m_mediaPlayer){if(this.m_mediaPlayer.style.visibility!="visible"){this.m_mediaPlayer.style.visibility="visible"
}var d="";
var f="";
for(var e=0;
e<c.length;
e++){d+=f+"queueUrl"+e+"="+encodeURIComponent(c[e].mediaUrl+","+c[e].itemUrl+","+c[e].length+","+c[e].watermark+","+c[e].type+","+c[e].isDefaultMedia+","+c[e].clickUrl);
f="&"
}if(isDefined(b)){d+=f+"currItem="+b
}this.m_mediaPlayer.SetVariable("queueUrl",d)
}}};
this.onFlashLoadMedia=function(d){this.initMediaHelpTextItemUrl(d);
this.m_mediaList.selectItem(d);
var b=this.m_mediaList.getMediaItemByUrl(d);
if(b){if(b.trackingUrl){if(!this.m_trackingPixel){this.m_trackingPixel=this.m_win.document.createElement("img");
this.getBody().appendChild(this.m_trackingPixel)
}this.m_trackingPixel.src=b.trackingUrl
}var c=b.type+"-loaded";
if(!this.m_clickedMedia[c]){this.m_clickedMedia[c]=1
}else{this.m_clickedMedia[c]++
}}};
this.getAdHTML=function(){var d=this.m_mediaPlayer.offsetWidth;
var e=this.m_mediaPlayer.offsetHeight;
var b=Math.round(this.m_mediaPlayer.GetVariable("volume")*100);
var c="http://pl.yumenetworks.com/dynamic_preroll_iframe.html";
var f="domain=7xUBeLFSw&width="+encodeURIComponent(d)+"&height="+encodeURIComponent(e)+"&volume="+encodeURIComponent(b)+"&nextURL="+encodeURIComponent("http://"+document.domain+"/flash/adcomplete.html?id="+encodeURIComponent(this.m_id));
return'<iframe src="'+c+"?"+f+'" frameborder="0"			scrolling="no" marginheight="0" marginwidth="0" topmargin="0"			leftmargin="0" allowtransparency="true" width="'+d+'"			height="'+e+'" style="position: absolute; left: 50%; top: 50%;			margin-left: -'+(d/2)+"; margin-top: -"+(e/2)+';"></iframe>'
};
this.onFlashShowAd=function(b){if(this.m_imobject.isPartner()){this.m_mediaPlayer.SetVariable("adcomplete",true);
return
}this.initMediaHelpText(gLang.pleaseEnjoyAd,"groupchat_video.gif");
this.m_mediaList.selectItem();
this.m_bAdShowing=true;
this.m_mediaAd.style.display="block";
this.m_mediaAd.innerHTML=this.getAdHTML()
};
this.onFlashAdComplete=function(){this.m_bAdShowing=false;
var b=this.m_mediaAd.getElementsByTagName("iframe");
if(b.length){removeElement(b[0])
}this.m_mediaAd.style.display="none";
this.m_mediaPlayer.SetVariable("adcomplete",true)
};
this.onFlashClickMedia=function(b){gNetworkMgr.doUILog(this.control,"mediaPlayer","clicked",false,b)
};
this.setGroupChatMedia=function(b){if(!this.m_mediaChangeTimeoutId){if(this.m_bAdShowing){this.onFlashAdComplete()
}if(!this.isAppAreaVisible()){this.showHideMedia(true)
}if(this.m_mediaPlayer){this.m_mediaPlayer.SetVariable("clear",true)
}}else{clearTimeout(this.m_mediaChangeTimeoutId)
}this.m_mediaChangeTimeoutId=setTimeout(hitch(this,function(){this.queueMediaFromUrl(b.itemUrl);
this.m_mediaChangeTimeoutId=null
}),500)
};
this.setMediaMute=function(b){if(this.m_mediaPlayer){this.m_mediaPlayer.SetVariable("mute",b)
}};
this.dropHover=function(b){if(!this.m_bActive){this.m_bDisplayActive=b;
this.flashWindow()
}};
this.dropHandle=function(e){if(!this.isMeeboGroupChat()&&this.m_imobject.getNetwork()=="meebome"){return
}var c=false;
if(this.isMinimized()){this.restoreMinimizeWindow()
}gWindowMgr.activateWindow(this);
if(typeof e=="object"){var f=[];
for(var g in e){var b=e[g].getExtra();
var d=b.getNetwork().supports("groupchat")&&b.getProtocol()==this.m_imobject.getProtocol()&&b.getUser()==this.m_imobject.getUser();
if(!d&&!this.isMeeboGroupChat()){continue
}if(b.getType()=="chat"){continue
}if(this.m_bGroupChatHidden&&!this.m_isMorphing&&!this.m_applicationRoom){this.showGroupChat()
}f.push(b);
c=true
}this.inviteBuddies(f,false,"drag")
}return c
};
this.getTimestamp=function(c){var b=String(c.getHours());
var d=String(c.getMinutes());
if(b.length<2){b="0"+b
}if(d.length<2){d="0"+d
}return"["+b+":"+d+"]"
};
this.addHistoryIM=function(x,c,p,t,h,n,f,u,m,d,w){u=u||new Date();
c=String(c);
var g=this.isHistoryAtBottom()||f;
if(!t&&p&&!this.isActive()&&!this.isMinimized()){gWindowMgr.moveWindowUnderTop(this);
meeboApp.moveWindowFromUnderMediaBar(this)
}if(!t){c=insertTargets(c)
}if(!p){c=linkify(c)
}if(!t&&gPrefs.getPref("emoticons")){c=meebo.util.emoticons.insertMeeboEmoticons(c)
}if(ui.isIE){c=c.replace(/&apos;/gi,"'")
}if(ui.isGecko){c=appendWbrUrl(c,this.m_wbrCount)
}if(!h){c=c.replace(/\r\n/g,"<br>");
c=c.replace(/\n/g,"<br>");
c=c.replace(/\r/g,"")
}if(t&&c&&(c==this.m_prevSystemMsg)){return
}else{if(t&&c){this.m_prevSystemMsg=x+c
}}var s=this.m_win.document.createElement("span");
var o=this.m_win.document.createElement("span");
if(t&&(!this.isGroupChat()||x==gLang.meeboMessage)){s.style.color=n?n:this.m_greyText;
s.style.fontStyle="italic"
}else{if(t&&this.isGroupChat()){s.style.color=n?n:"#000000";
o.style.fontStyle=s.style.fontStyle="italic"
}else{if(p){s.style.color=n?n:"#0163B3";
o.style.color="#000000";
c.replace(/^<font color="?#ffffff"?/i,'<font color="#000000"')
}else{if(!h){if(gEventMgr.getState()=="done"){s.style.color=n?n:this.m_greyText
}else{if(!p&&this.isMeeboGroupChat()&&this.m_trees[this.getYourself().getId()]){n=this.m_trees[this.getYourself().getId()].getColor()
}s.style.color=n?n:"#D35900"
}if(this.m_bBold){c="<b>"+c+"</b>"
}if(this.m_bItalics){c="<i>"+c+"</i>"
}if(this.m_bUnderline){c="<u>"+c+"</u>"
}if(gEventMgr.getState()=="done"){o.style.color=this.m_greyText
}else{if(this.m_fontColor){o.style.color=this.m_fontColor
}}if(this.m_fontSize){c='<span style="font-size: '+this.m_fontSize+'px;">'+c+"</font>"
}if(this.m_fontType){c='<font face="'+this.m_fontType+'">'+c+"</font>"
}}}}}if(m){this.createFileMessage(u,s,o,x,m,d,p)
}if(!p){if(this.isGroupChat()){var b=this.getYourself().getPresence(this.m_imobject);
if(b){x=b.getAlias()
}}else{var k=gLogon.getLogon(this.m_imobject.getUser(),this.m_imobject.getProtocol());
if(k){x=k.getAlias()
}}}if(!m){if(c.toLowerCase().indexOf(">/me")!=-1&&removeHTML(c).toLowerCase().indexOf("/me")==0){var q=c.toLowerCase().indexOf("/me");
c=c.substring(0,q)+c.substring(q+3);
s.appendChild(this.m_win.document.createTextNode(this.getTimestamp(u)+" * "+x+" "));
o.appendChild(s)
}else{if(!h){s.appendChild(this.m_win.document.createTextNode(this.getTimestamp(u)+" "+x+": "));
o.appendChild(s)
}}o.innerHTML+=c
}if(!h&&!t){this.clearHistoryOverlay()
}var b=this.getPresenceByAlias(x);
if(h){this.recursiveColorText(o,this.m_greyText);
if(this.m_buddyIcon&&this.m_buddyIcon.nextSibling){this.m_history.insertBefore(this.m_win.document.createElement("br"),this.m_buddyIcon.nextSibling)
}while(o.childNodes.length){if(this.m_buddyIcon&&this.m_buddyIcon.nextSibling){this.m_history.insertBefore(o.childNodes[o.childNodes.length-1],this.m_buddyIcon.nextSibling)
}else{if(!this.m_buddyIcon&&this.m_history.firstChild){this.m_history.insertBefore(o.childNodes[o.childNodes.length-1],this.m_history.firstChild)
}else{this.m_history.appendChild(o.childNodes[o.childNodes.length-1])
}}}}else{if(w){w.appendChild(o)
}else{this.m_history.appendChild(o)
}}this.linkifyMessageContent(o,p);
if(this.isMeeboGroupChat()){while(this.m_history.childNodes.length>this.m_maxGroupChatHistoryLines){this.m_history.removeChild(this.m_history.firstChild)
}}if(!p&&!t&&gEventMgr.getState()=="done"){var e=this.m_win.document.createTextNode(" ("+gLang.messageNotSent+")");
var v=this.m_win.document.createElement("span");
v.style.color=this.m_greyText;
v.style.fontStyle="italic";
v.appendChild(e);
o.appendChild(v)
}if(!h){o.appendChild(this.m_win.document.createElement("br"))
}if(g){var l=o.getElementsByTagName("img");
for(var q=0;
q<l.length;
q++){ui.connectEvent(l[q],"load",this,"IMImageOnLoad",false,true)
}setTimeout(hitch(this,"scrollHistoryToBottom"),0)
}if(!p&&!t&&gEventMgr.getState()=="done"){gWindowMgr.createReconnectDlg({},gLang.imNetError)
}this.updateBuddyIconPosition(g);
if(islogtiming(this.m_imobject.getId())){if(!p){gNetworkMgr.doUILog("usability","imspeed","imWindowOpened",false,stoplogtime(this.m_imobject.getId()))
}clearlogtime(this.m_imobject.getId())
}};
this.IMImageOnLoad=function(b){ui.disconnectEvent(b,"load");
setTimeout(hitch(this,"scrollHistoryToBottom"),0)
};
this.linkifyMessageContent=function(e,b){var c=e.getElementsByTagName("a");
for(var d=0;
d<c.length;
d++){var g=meebo.util.getMeeboShareLink(c[d].href);
if(g&&b){var f={component:"MediaBar",type:"sharereceived",shareId:g.share};
meebo.util.createTrackingPixel(f,this.m_imobject.getLogin(),this.m_imobject)
}ui.connectEvent(c[d],"click",this,"onMessageLinkClick",true,false,c[d].href,g&&g.share)
}};
this.onMessageLinkClick=function(e,b,c){if(c){var d={component:"MediaBar",type:"shareclick",shareId:c};
meebo.util.createTrackingPixel(d,this.m_imobject.getLogin(),this.m_imobject)
}if(meeboApp.share.handleUrlClick(b)){ui.setEventHandled(e)
}};
this.createFileMessage=function(d,e,g,c,f,m,k){setText(e,this.getTimestamp(d)+" ");
e.style.fontStyle="italic";
g.appendChild(e);
msg=sprintf(k?gLang.sentYouFile:gLang.sendingFileTo,c);
var b=this.m_win.document.createElement("span");
setText(b,msg);
b.style.fontStyle="italic";
b.style.color=getCSSProp(e,"color");
g.appendChild(b);
g.appendChild(this.m_win.document.createElement("br"));
this.m_fileInfo=this.m_win.document.createElement("span");
addClassName(this.m_fileInfo,"fileInfo");
this.m_fileInfo.innerHTML=(k?gLang.retrievingFileInfo:gLang.sendingFile)+"&hellip;";
g.appendChild(this.m_fileInfo);
var h={username:m,fileid:f};
if(k){var l=hitch(this,"updateFileInfo",m,f,k);
meeboApp.fileTransfer.getDownloadFileInfo(f,m,{onGetDownloadFileInfo:l})
}};
this.updateFileInfo=function(o,h,m,g){if(!g||!this.m_fileInfo){return false
}var c=this.isHistoryAtBottom();
removeChildren(this.m_fileInfo);
var e=this.m_fileInfo.parentNode;
var n=this.m_win.document.createElement("img");
if(g.thumbnail_url){n.src=g.thumbnail_url
}else{gImages.requestImage("sendfile-small.gif",n);
addClassName(n,"sendFileIcon")
}var d=decodeURIComponent(g.filename);
var l=truncateMiddle(d,20);
var f=this.m_win.document.createElement("span");
f.title=d;
f.appendChild(n);
f.appendChild(this.m_win.document.createTextNode(l));
var b=this.m_win.document.createElement("span");
setText(b," ("+computeFileSize(g.filesize)+")");
this.m_fileInfo.style.marginLeft=e.firstChild.offsetWidth;
this.m_fileInfo.appendChild(f);
this.m_fileInfo.appendChild(b);
if(m){addClassName(f,"acceptLink");
var k=hitch(this,"requestFileDownload",g);
ui.connectEvent(f,"click",this,k,false,true)
}if(c){setTimeout(hitch(this,"scrollHistoryToBottom"),0)
}this.m_fileInfo=null
};
this.setTransferError=function(b,c){gNetworkMgr.doUILog("filetransfer","error",c,true);
setText(b,meeboApp.fileTransfer.getStringFromError(c));
addClassName(b,"fileError")
};
this.requestFileDownload=function(b){gNetworkMgr.doUILog("filetransfer","accept-imdlg","true",true,"protocol="+this.m_imobject.getNetwork()+" sender="+this.m_imobject.getUser()+" receiver="+this.m_imobject.getName());
meeboApp.fileTransfer.downloadFile(b)
};
this.getMediaBarHTML=function(b){return'		<table>		<tr>			<th rowspan="2" width="70px"><img border="0" class="uiImHistoryMediaImg" path="wait_big_ax.gif" id="previewImg"></th>			<td valign="bottom" style="height: 50%;"><a href="'+b+'" target="_blank" id="mediaLink">'+b+'</a></td>		</tr>		<tr>			<td valign="top" style="height: 50%;" id="playNow">'+gLang.loadingLink+"</td>		</tr>		</table>"
};
this.getDeletedMediaBarHTML=function(){return'<table>		<tr>			<td width="70px"><img border="0" class="uiImHistoryMediaImg" path="media_banned.png"></td>			<td valign="middle">'+gLang.itemMarkedAsRemoved+"</td>		</tr>		</table>"
};
this.insertMediaIntoHistory=function(h,g){if(!this.m_mediaList||this.m_imobject.getNetwork()!="meebome"){return
}var d=h.getElementsByTagName("a"),l=[];
for(var e=0,k;
(k=d[e]);
e++){if(!k.getAttribute("dontExpand")||!k.getAttribute("dontExpand").toLowerCase()=="true"){l.push(k)
}}for(var e=0;
e<l.length;
e++){if(!l[e].href||l[e].href.match(new RegExp("^w*mailto:","i"))){continue
}var c=l[e].href.replace(/\/$/,"");
var f=!!this.m_bannedMedia[c];
var m=this.m_mediaList.getMediaItemByUrl(l[e].href);
if(!m&&g){continue
}var b=this.m_win.document.createElement("div");
b.className="uiImHistoryMediaContainer";
b.innerHTML=f?this.getDeletedMediaBarHTML():this.getMediaBarHTML(c);
if(!f){if(!this.m_pendingMedia[c]){this.m_pendingMedia[c]=[]
}this.m_pendingMedia[c].push(b);
if(m){this.updateHistoryMediaItem(m)
}}l[e].parentNode.insertBefore(b,l[e]);
l[e].parentNode.removeChild(l[e]);
cacheImgs(b)
}};
this.addHistoryNotification=function(c,e){var b=this.isHistoryAtBottom();
var d=this.m_win.document.createElement("div");
d.className="uiImHistoryNotification";
if(e){d.id=e
}d.innerHTML=c;
this.m_history.appendChild(d);
if(b){setTimeout(hitch(this,"scrollHistoryToBottom"),0)
}this.updateBuddyIconPosition(b)
};
this.addAppUserInvite=function(b,d){var e=sprintf(gLang.youInvitedToAppBold,b.getAlias(),this.m_applicationRoom.getAlias());
var c=this.addIMInvite(this.m_applicationRoom.getApplication().icon_location,e,[{text:gLang.reinvite,clickFnc:hitch(this,function(){removeChildren(c);
setText(c,gLang.inviteSent);
this.inviteBuddies(b,true,"history","",0)
})}],d)
};
this.addIMInvite=function(f,d,n,l){var b=this.isHistoryAtBottom()||l;
var c=getUniqueId()+"-link";
var g=this.m_win.document.createElement("div");
addClassName(g,"appInviteLink");
g.innerHTML='				<table border="0" cellspacing="0" cellpadding="0">				<tr>					<th rowspan="2">						<img path="'+f+'" align="left" width="24" height="24">					</th>					<td class="message">'+d+'</td>				</tr><tr>					<td id="'+c+'"></td>				</tr>';
this.m_history.appendChild(g);
cacheImgs(g);
var k=$(c);
for(var e=0,h;
(h=n[e]);
e++){var m=this.m_win.document.createElement("span");
setText(m,h.text);
if(h.clickFnc){addClassName(m,"acceptLink");
ui.connectEvent(m,"click",this,h.clickFnc,false,false)
}k.appendChild(m);
if(e<n.length-1){k.appendChild(this.m_win.document.createTextNode(" | "))
}}if(b){setTimeout(hitch(this,"scrollHistoryToBottom"),0)
}this.updateBuddyIconPosition(b);
return k
};
this.addAdInvite=function(c,d){var b=this.addIMInvite(c.buddyIconUrls[0],c.description,[{text:gLang.viewInMeebo,clickFnc:hitch(this,function(){setText(b,gLang.viewingInMeebo);
gMediaBar.launchAd(c)
})}],d)
};
this.addAppRoomInvite=function(e,c,b){if(this.m_applicationRoom&&this.m_applicationRoom.getChatName()==c){var e=sprintf(gLang.hasInvitedYouToPlayAppBold,"<b>"+this.m_imobject.getAlias()+"<b>",d.alias);
var d=this.m_applicationRoom.getApplication();
this.addIMInvite(d.icon_location,e,[{text:gLang.appRunning,onClick:null}],b)
}else{var d=new meebo.Application();
d.getInfo(hitch(this,function(){var l=this.m_imobject.getLogin();
var p=(l.getNetwork()=="myspace"&&l.getAge()<18);
var g=d.icon_location;
var f=sprintf(gLang.hasInvitedYouToPlayAppBold,"<b>"+this.m_imobject.getAlias()+"<b>",d.alias);
var o=[];
if(p&&d.category_id==meebo.APP_COMMUNICATION_CATEGORY){o.push({text:sprintf(gLang.underageMySpaceNoInvited,d.alias,'<a href="http://www.myspace.com/index.cfm?fuseaction=misc.privacy">',"</a>")})
}else{var h=hitch(this,"onAcceptAppInvite",c),n=hitch(meeboApp.Application,"checkAppLaunch",true,this,h,null,d);
var k=hitch(this,"onDeclineAppInvite",c);
o.push({text:gLang.acceptBtn,clickFnc:n});
o.push({text:gLang.decline,clickFnc:k})
}var m=this.addIMInvite(g,f,o,b);
if(!this.m_acceptAppLinks[c]){this.m_acceptAppLinks[c]=[]
}this.m_acceptAppLinks[c].push(new ui.element(m))
}),c)
}};
this.clearAcceptAppLinks=function(d,e){if(!this.m_acceptAppLinks[d]){return
}var b=this.m_acceptAppLinks[d];
for(var c=0;
c<b.length;
c++){removeChildren(b[c].getElement());
setText(b[c].getElement(),e)
}delete this.m_acceptAppLinks[d]
};
this.onAcceptAppInvite=function(d,e){if(this.isPoppedOut()){this.reversePop(function(f){if(f.isPoppedOut()){return
}f.onAcceptAppInvite(d,e)
});
return
}if(this.isProtocolGroupChat()){return
}if(this.getApplicationRoom()){this.toggleAppArea()
}this.clearAcceptAppLinks(d,gLang.loadingApp);
var b=this.m_imobject.getLogin();
var c=meeboApp.Application.joinApp(b.getAlias(),b.getUser(),b.getProtocol(),d,e);
this.setApplicationRoom(c);
return false
};
this.onDeclineAppInvite=function(b){this.clearAcceptAppLinks(b,gLang.invitationDeclined)
};
this.updateHistoryMediaItem=function(o){var m=this.isHistoryAtBottom();
var b=o.itemUrl.replace(/\/$/,"");
var g=this.m_pendingMedia[b];
if(!g){return
}for(var d=0;
d<g.length;
d++){var n=getPartFromElement(g[d],"previewImg");
if(n){var l=o.type=="audio"?"audio-frame.gif":o.thumbnailUrl;
if(!l&&o.type=="video"){l="video-frame-missing.gif"
}n.setAttribute("path",l);
if(o.type=="audio"){n.className+=" uiImHistoryMediaImgAudio"
}}var k=getPartFromElement(g[d],"playNow");
if(!k){continue
}if(this.isFlashInstalled()){var e=gLang.playNow;
switch(o.type){case"video":case"audio":e=gLang.playNow;
break;
case"image":case"page":e=gLang.showNow;
break
}var f=this.isMediaFlaggable();
var c=!f?"":'<div><a href="" onclick="return false;" style="text-transform: lowercase;">					<img border="0" align=left style="margin-right: 10px;" valign=center 					path="media_banned_small.gif">'+gLang.removeBtn+"</a></div>";
k.innerHTML='<div><a href="javascript:void(0)" onclick="return false;"> 					<img border="0" align=left valign=center path="groupchat_'+o.type+'.gif">'+e+"</a></div>"+c;
var h=k.getElementsByTagName("a");
ui.connectEvent(h[0],"click",this,function(q){this.setGroupChatMedia(q);
var p=q.type+"-playNow";
if(!this.m_clickedMedia[p]){this.m_clickedMedia[p]=1
}else{this.m_clickedMedia[p]++
}},false,false,o);
if(f){ui.connectEvent(h[1],"click",this,"onClickRemove",false,false,b)
}}else{k.innerHTML=sprintf(gLang.flashRequiredToView,this.m_installFlashLink,"</a>")
}cacheImgs(g[d])
}if(!this.m_loadedMedia[b]){this.m_loadedMedia[b]=[]
}this.m_loadedMedia[b]=this.m_loadedMedia[b].concat(g);
delete this.m_pendingMedia[b];
if(m){this.m_history.scrollTop=this.m_history.scrollHeight
}};
this.scrollHistoryToBottom=function(){var b=this.m_history.scrollHeight-this.m_history.clientHeight;
this.m_history.scrollTop=b;
this.updateBuddyIconPosition(true)
};
this.setFontType=function(b,c){this.m_fontType=c;
this.m_message.setFontFamily(c);
gPrefs.saveFontPref("type",this.m_fontType);
gNetworkMgr.doUILog(this.control,"fontType",this.m_fontType);
this.focusOnMessage()
};
this.setFontSize=function(b){this.m_fontSize=parseInt(b);
this.m_message.setFontSize(this.m_fontSize);
gPrefs.saveFontPref("size",this.m_fontSize);
gNetworkMgr.doUILog(this.control,"fontSize",this.m_fontSize);
this.focusOnMessage()
};
this.setFontColor=function(b){this.m_fontColor=b;
this.m_message.setFontColor(b);
gPrefs.saveFontPref("color",this.m_fontColor);
gNetworkMgr.doUILog(this.control,"fontcolor",b);
this.focusOnMessage()
};
this.onEmoticon=function(b){this.m_message.replaceSelectionWithText(b);
gNetworkMgr.doUILog(this.control,"emoticons",b)
};
this.onMedia=function(){gNetworkMgr.doUILog(this.control,"media");
this.m_mediaDlg=gWindowMgr.createAddMediaDlg({id:this.getId()+"-addMedia",parent:this},hitch(this,"onAddMedia"))
};
this.onShare=function(b){var c=this.m_message.getText();
this.m_message.setText(b);
this.sendIM("k");
this.m_message.setText(c);
this.activateWindow()
};
this.onAddMedia=function(b){var c=b.getDelegate().getValue();
if(c&&this.isVisible()){gNetworkMgr.doUILog(this.control,"dlgadd");
this.addHistoryIM(this.m_imobject.getUser(),c);
this.sendIMRequest(c,"addMediaDlg")
}b.closeWindow()
};
this.toggleBlock=function(){if(!this.m_blockBtn){return
}this.m_bBlock=!this.m_bBlock;
this.m_blockBtn.setImage((this.m_bBlock?"":"un")+"blockbuddy");
this.m_blockBtn.setTitle(this.m_bBlock?gLang.blockBuddy:gLang.unblockBuddy)
};
this.setBold=function(c,b){if(!b){gNetworkMgr.doUILog(this.control,"midtoolbar",c?"bold":"unbold")
}this.m_bBold=c;
this.m_message.setBold(c);
gPrefs.saveFontPref("bBold",this.m_bBold);
eventlog("imDlg toggleBold setFocus")
};
this.setItalics=function(c,b){if(!b){gNetworkMgr.doUILog(this.control,"midtoolbar",c?"italics":"unitalics")
}this.m_bItalics=c;
this.m_message.setItalics(c);
gPrefs.saveFontPref("bItalics",this.m_bItalics);
eventlog("imDlg toggleItalics setFocus")
};
this.setUnderline=function(c,b){if(!b){gNetworkMgr.doUILog(this.control,"midtoolbar",c?"underline":"ununderline")
}this.m_bUnderline=c;
this.m_message.setUnderline(c);
gPrefs.saveFontPref("bUnderline",this.m_bUnderline);
eventlog("imDlg toggleUnderline setFocus")
};
this.initContent=function(e){addClassName(this.getBody(),this.control+"-"+this.m_imobject.getType());
this.doSubscribe(this.m_imobject,true);
this.initTopToolbar();
this.initFontbar();
this.initMessage();
this.initFontSliders();
this.initHistory();
this.initStatus();
var b=this.getBody();
this.m_contentWidth=b.offsetWidth;
this.m_contentHeight=b.offsetHeight;
b.ptr=this;
this.m_topToolbar.m_element=b.appendChild(this.m_topToolbar.m_element);
this.m_history=b.appendChild(this.m_history);
this.m_sliderTop=b.appendChild(this.m_sliderTop);
this.m_sliderBottom=b.appendChild(this.m_sliderBottom);
b.insertBefore(this.m_status,this.m_message.getElement().parentNode.parentNode);
this.m_minY=this.getMinHeight();
this.connectContentEvents();
if(!e){if(!this.isMeeboGroupChat()){this.initBuddyIcon(e)
}if(!this.isGroupChat()){this.requestHistory();
this.alertPrivacyIsOn()
}}if(this.m_imobject.isOnlist()){gBuddyListDlg.updateBuddyPersistence(this.m_imobject)
}if((this.isMeeboGroupChat()&&!this.m_applicationRoom)||this.isProtocolGroupChat()){this.initGroupChat();
if(this.isProtocolGroupChat()){var g=this.m_imobject.getPresences();
for(var c in g){var d=g[c];
this.onPresenceChangeOnline(d,"",d.isOnline())
}}}if(this.m_applicationRoom){this.initAppArea();
this.initAppList();
var f=this.m_applicationRoom.getApplication();
this.m_appArea.style.width=f.width+2+"px";
this.m_appArea.style.height=f.height+2+"px";
this.m_appArea.style.display="block"
}this.recalcLayout();
this.onShow();
return true
};
this.receiveConversations=function(f,c){if(!c){return
}if(!f.length){this.requestChatLog()
}var g;
for(var d=0,b;
b=f[d];
++d){if(meeboApp.m_seenIM[b.msgId]){continue
}meeboApp.m_seenIM[b.msgId]=true;
if(!g){g=this.m_win.document.createDocumentFragment()
}var e=(b.send?this.m_imobject.getLogin():this.m_imobject).getAlias();
this.addHistoryIM(e,b.msg,!b.send,false,false,null,true,new Date(b.ts*1000),null,null,g)
}if(!g){return
}if(this.m_buddyIcon){if(this.m_buddyIcon.nextSibling){this.m_history.insertBefore(g,this.m_buddyIcon.nextSibling)
}else{this.m_history.appendChild(g)
}}else{this.m_history.insertBefore(g,this.m_history.firstChild)
}};
this.initBuddyListSlider=function(){this.m_buddyListSlider=this.m_win.document.createElement("div");
addClassName(this.m_buddyListSlider,"buddylistSlider");
this.m_buddyListSlider=this.getBody().appendChild(this.m_buddyListSlider);
if(this.isMeeboGroupChat()){this.m_buddyListSliderImage=createImg(getUniqueId(),this.m_buddyListSlider,4,60,"left.gif","",true);
addClassName(this.m_buddyListSliderImage,"buddyListSliderImage");
this.m_buddyListSlider.appendChild(this.m_buddyListSliderImage);
this.m_buddyListSliderImage.style.display="none"
}var b=this.m_topToolbarH;
this.m_buddyListSlider.style.right=this.m_buddyListW+"px";
this.m_buddyListSlider.style.top=b+"px";
ui.connectEvent(this.m_buddyListSlider,"mousedown",this,"onGroupChatSliderResize",true,true)
};
this.createRoomGroup=function(c){var b=new ui.TreeNode(this.getId()+"-groupchat-"+normalizeString(c));
b.setSortFunc(this.isMeeboGroupChat()?meeboApp.util.tree.getBuddyGroupChatSortIndex:meeboApp.util.tree.getBuddyStatusSortIndex);
this.m_buddyList.insertItem(b);
b.setText(c);
b.addHeaderClassName("groupTreeHeader");
this.m_buddyList.redrawChildren();
b.setDisplay(false);
return b
};
this.initBuddyList=function(){this.m_buddyList=new ui.Tree({eventModel:meeboApp.TreeEventModel});
this.m_buddyList.create(this.m_win);
this.m_buddyList.addClassName("ImBuddyList");
var b=new ui.TreeNode("root");
this.m_buddyList.setRoot(b);
this.getBody().appendChild(this.m_buddyList.getElement());
this.m_spilloverRoomsGroup=this.createRoomGroup(gLang.spilloverRoomsGroup).create(this.m_win);
this.m_memberGroup=this.createRoomGroup(gLang.memberRoomGroup).create(this.m_win);
this.m_guestGroup=this.createRoomGroup(gLang.guestRoomGroup).create(this.m_win);
var c=this.m_topToolbarH;
this.m_buddyList.getElement().style.top=c+"px";
this.m_buddyList.getElement().style.width=this.m_buddyListW+"px";
this.m_minX+=this.m_buddyListW;
this.initContextMenu()
};
this.getPresenceByAlias=function(b){if(!this.isMeeboGroupChat()){return
}var d=this.m_imobject.getPresences();
for(var c in d){if(d[c].getAlias()==b){return d[c]
}}return null
};
this.initBuddyIcon=function(c){this.m_buddyIconSrc=createImg(null,this.getBody(),null,null,null,"",false,false);
this.m_buddyIconSrc=this.getBody().appendChild(this.m_buddyIconSrc);
addClassName(this.m_buddyIconSrc,"ImBuddyIcon");
if(c){return
}this.m_buddyIconFloater=this.m_win.document.createElement("div");
this.m_buddyIconFloater.id=this.m_id+"floater";
addClassName(this.m_buddyIconFloater,"ImBuddyIconFloater");
var b=this.m_history.firstChild;
if(b){this.m_buddyIconFloater=this.m_history.insertBefore(this.m_buddyIconFloater,b)
}else{this.m_buddyIconFloater=this.m_history.appendChild(this.m_buddyIconFloater)
}this.m_buddyIcon=this.m_win.document.createElement("div");
this.m_buddyIcon.id=this.m_id+"container";
addClassName(this.m_buddyIcon,"ImBuddyIconContainer");
var b=this.m_buddyIconFloater.nextSibling;
if(b){this.m_buddyIcon=this.m_history.insertBefore(this.m_buddyIcon,b)
}else{this.m_buddyIcon=this.m_history.appendChild(this.m_buddyIcon)
}this.setIconFromBuddyListBuddy();
this.updateBuddyIconPosition()
};
this.initFontSliders=function(){this.m_sliderTop=this.m_win.document.createElement("div");
this.m_sliderBottom=this.m_win.document.createElement("div");
addClassName(this.m_sliderTop,"topSlider");
addClassName(this.m_sliderBottom,"bottomSlider")
};
this.initHistory=function(){this.m_history=this.m_win.document.createElement("div");
addClassName(this.m_history,"uiImHistory");
var b=this.m_topToolbarH;
this.m_history.style.top=b+"px"
};
this.setHistoryOverlay=function(b){if(!this.m_historyOverlayDiv){this.m_historyOverlayDiv=this.m_history.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_historyOverlayDiv,"historyOverlay")
}this.clearHistoryOverlay();
this.m_historyOverlayDiv.appendChild(b.create(this.m_win).getElement())
};
this.clearHistoryOverlay=function(){removeChildren(this.m_historyOverlayDiv)
};
this.initMessage=function(){this.m_message=new ui.simpleEdit(getUniqueId()+"_message",this.m_fontType,this.m_fontSize,this.m_fontColor,this.m_bBold,this.m_bItalics,this.m_bUnderline,"uiImMessage").create(this.m_win);
this.m_message.subscribe("Focused",this,"callActivate");
this.getBody().appendChild(this.m_message.getElement().parentNode);
var c=this.isMeeboGroupChat()&&!this.m_applicationRoom;
if(c){this.m_message.getElement().style.height="36px"
}this.m_message.getElement().style.bottom=(this.m_statusH+(c?2:0))+"px";
var b=this.m_win.document.createElement("form");
b.onsubmit=hitch(this,function(d){this.sendIM("k");
return false
});
b.action="";
this.m_message.getElement().parentNode.appendChild(b);
b.appendChild(this.m_message.getElement())
};
this.initTopToolbar=function(){if(!this.getBody()){return
}var c=new ui.toolbar((this.isMeeboGroupChat()&&!this.m_applicationRoom?"xlarge":"large")).create(this.m_win);
this.getBody().appendChild(c.getElement());
c.addClassName("uiImTopToolbar");
this.m_topToolbarType=this.getTopToolbarState();
if(this.isMeeboGroupChat()&&!this.m_applicationRoom){this.initGroupChatTopToolbar(c)
}else{if(this.m_imobject==this.m_applicationRoom){this.initAppTopToolbar(c)
}else{this.initIMTopToolbar(c)
}}if(this.m_topToolbar&&this.m_topToolbar.m_element){var b=this.getBody();
if(b){b.replaceChild(c.getElement(),this.m_topToolbar.getElement());
this.connectTopToolbarEvents()
}}c.resize(this.m_topToolbar&&this.m_topToolbar.m_element?this.m_topToolbar.m_element.offsetWidth:null);
if(this.m_topToolbar&&ui.isIE&&this.isMeeboGroupChat()){this.m_topToolbar.destroy()
}this.m_topToolbar=c
};
this.initAppTopToolbar=function(b){var c=this.m_bOffline;
this.m_profBtn=b.addButton("profile","info",gLang.profile,null,c);
var d=false;
d=(this.m_appArea&&(this.m_appArea.style.display!="none"))||(this.m_appList&&(this.m_appList.getDisplay()!="none"));
this.m_appBtn=b.addButton("applications","app",gLang.games,null,true);
this.m_appBtn.setDepressed(d);
b.addButton(new ui.toolbarFlexibleSpace().create(this.m_win));
var e=this.getApplicationRoom()&&this.getApplicationRoom().getApplication();
if(e&&e.max_participants>2){this.m_inviteBtn=b.addButton("invitechat","invitebuddy",gLang.inviteHeader,null,c)
}this.m_popBtn=(this.isPoppedOut()?b.addButton("popin","popin",gLang.popInTT,null,true):b.addButton("popout","popout",gLang.popOutTT,null,true))
};
this.initGroupChatTopToolbar=function(b){var e=!this.m_imobject.getChatId()||this.m_bOffline;
var f=gBuddyList.getGroupByName(gLang.recentRooms);
if(!this.m_imobject.isOnlist()||this.m_imobject.hasGroup(f)){this.m_addBtn=b.addButton("addchat"+getUniqueId(),"addChat.png",gLang.addToBuddyList,gLang.addToBuddyList,e)
}this.m_inviteBtn=b.addButton("invitechat"+getUniqueId(),"inviteChat.png",gLang.inviteHeader,gLang.inviteHeader,e);
var d=this.getYourself();
var c=d&&d.getPresence(this.m_imobject).isOwner();
if(c){this.m_profBtn=b.addButton("profile"+getUniqueId(),"configureChat.png",gLang.configure,gLang.configure,e)
}if(!this.m_imobject.isPrivate()&&this.m_imobject.getWidgetHash()){this.m_embedBtn=b.addButton("embed"+getUniqueId(),"embedChat.png",gLang.roomWidgetHeader,gLang.roomWidgetHeader,e)
}b.addButton(new ui.toolbarFlexibleSpace().create(this.m_win));
this.m_popBtn=(this.isPoppedOut()?b.addButton("popin"+getUniqueId(),"popin",gLang.popInTT):b.addButton("popout"+getUniqueId(),"popout",gLang.popOutTT))
};
this.setToolbarButtonsDisabled=function(b){if(this.m_addBtn){this.m_addBtn.setDisabled(b)
}if(this.m_blockBtn){this.m_blockBtn.setDisabled(b)
}if(this.m_inviteBtn){this.m_inviteBtn.setDisabled(b)
}if(this.m_profBtn){this.m_profBtn.setDisabled(b)
}if(this.m_chatBtn){this.m_chatBtn.setDisabled(b)
}if(this.m_embedBtn){this.m_embedBtn.setDisabled(b)
}if(this.m_fileBtn){this.m_fileBtn.setDisabled(b);
this.setFileTransferOffline(b)
}if(this.m_videochatBtn){this.m_videochatBtn.setDisabled(b)
}if(this.m_groupBtn){this.m_groupBtn.setDisabled(b)
}if(this.m_appBtn){this.m_appBtn.setDisabled(b)
}if(this.m_popBtn){this.m_popBtn.setDisabled(b)
}};
this.initIMTopToolbar=function(n){var f=!this.m_imobject.isOnlist();
var l=this.isGroupChat();
var k=this.m_imobject.getType()!="buddy"||(!this.m_imobject.isGuestUser()&&!this.m_imobject.isWidgetUser());
var d=this.m_imobject.getNetwork();
if(d.supports("add")&&f&&!gIsGuestGroupChat&&k){this.m_addBtn=n.addButton("add","addbuddy",gLang.addBuddyTT,null,l)
}if(d.supports("block")&&f){var h=(this.m_bBlock?"":"un")+"blockbuddy";
var b=this.m_bBlock?gLang.blockBuddy:gLang.unblockBuddy;
this.m_blockBtn=n.addButton("block",h,b,null,l)
}this.m_profBtn=n.addButton("profile","info",gLang.profile,null,l);
var m=(d=="myspace"&&this.m_imobject.getLogin().getAge()<18);
if(gEnablePlatform&&gVideoChatId&&!m){this.m_videochatBtn=n.addButton("videochat","webcam","Video/Audio Chat",null,l||(this.isPoppedOut()||meebo.util.accessByIP()))
}if(d.supports("chatlogs")&&(d!="meebome"||(this.m_imobject.isOnlist()&&k))){var g=gPrefs.getPref("gchatlog",true)&&gPrefs.getAccountPref(this.m_imobject.getLogin(),"logging:"+this.m_imobject.getName(),true);
this.m_chatBtn=n.addButton("chat log",g?"chatlog":"chatlogoff",gLang.chatLogs,null,l)
}if(gEnableFileTransfer){var e=!gFileTransferId?l:(l||this.isPoppedOut()||meebo.util.accessByIP());
this.m_fileBtn=n.addButton("file transfer","sendfile",gLang.sendFile,null,e);
this.m_fileBtn.addOnMouseClick(hitch(this,"onFileTransferClick"));
if(gFileTransferId){this.m_fileBtn.addOnMouseUp(hitch(this,function(){this.launchApp(meebo.applicationMgr.getApplication(gFileTransferId),true)
}))
}else{this.addFileTransferBtn();
if(l){this.setFileTransferOffline(true)
}}}if(!meebo.util.isICQ(this.m_imobject.getName())&&!meebo.util.isICQ(this.m_imobject.getUser())&&d.supports("groupchat")){this.m_groupBtn=n.addButton("group","groupchat",gLang.chatTT,null,l);
if(this.isProtocolGroupChat()){this.m_groupBtn.setDepressed(true)
}}if(gEnablePlatform){this.m_appBtn=n.addButton("applications","app",gLang.games,null,l||(this.isPoppedOut()||meebo.util.accessByIP()))
}n.addButton(new ui.toolbarFlexibleSpace().create(this.m_win));
if(this.m_topToolbarType.indexOf("-app")!=-1){var c=this.getApplicationRoom()&&this.getApplicationRoom().getApplication();
if(c&&c.max_participants>2){this.m_inviteBtn=n.addButton("invitechat","invitebuddy",gLang.inviteHeader,null,l)
}if(c&&c.app_id==gVideoChatId){this.m_videochatBtn.setDepressed(true)
}if(this.m_appBtn){this.m_appBtn.setDepressed(true)
}}if(!ui.isIE||ui.isIE>5.5){this.m_popBtn=(this.isPoppedOut()?n.addButton("popin","popin",gLang.popInTT,null,this.m_applicationRoom):n.addButton("popout","popout",gLang.popOutTT,null,this.m_applicationRoom))
}};
this.setFileTransferOffline=function(b){if(this.m_fileInput){this.m_fileInput.style.display=b?"none":""
}};
this.addFileTransferBtn=function(){if(!gEnableFileTransfer){return
}if(this.m_fileEl){removeElement(this.m_fileEl)
}if(this.m_fileInput){removeElement(this.m_fileInput)
}this.m_fileEl=this.m_win.document.createElement("div");
this.m_fileEl.id=this.m_id+"-fileEl";
addClassName(this.m_fileEl,"ImFileTransfer");
util.css.setOpacity(this.m_fileEl,0);
var b=this.m_fileBtn.getElement();
b.appendChild(this.m_fileEl);
this.m_fileInput=this.m_win.document.createElement("input");
this.m_fileInput.type="file";
this.m_fileInput.name="file";
this.m_fileInput.id=this.m_id+"-fileInput";
addClassName(this.m_fileInput,"ImFileTransferInput");
this.m_fileInput.style.display=this.m_bOffline?"none":"";
ui.connectEvent(this.m_fileInput,"change",this,"sendFile",true,true);
this.m_fileInput=this.m_fileEl.appendChild(this.m_fileInput);
if(!this.m_fileInputWidth){this.m_fileInputWidth=this.m_fileInput.offsetWidth
}this.m_fileInput.style.left=(48-this.m_fileInputWidth+4)+"px";
this.m_fileInput.style.top="-4px";
if(ui.isWebKit){this.m_fileEl.style.left="-999px";
this.m_fileBtn.removeOnMouseUp(this.m_fileInputClick);
this.m_fileInputClick=hitch(this,"handleFileTransferClick");
this.m_fileBtn.addOnMouseUp(this.m_fileInputClick)
}};
this.onFileTransferClick=function(c){if(!gLogon.getMeeboUser()){ui.setEventHandled(c);
if(this.isPoppedOut()){gWindowMgr.createCreateMeeboAccountDlg({},"imdlg-filetransfer","upsell_accounts.png")
}else{var b=new meeboApp.AccountUpsellTooltip(gLang.fileTransfer,gLang.fileTransferDescription,"filetransfer");
b.showAt(this.m_fileBtn.getElement(),b.BELOW)
}}};
this.handleFileTransferClick=function(){this.m_fileInput.click()
};
this.sendFile=function(){var b=this.m_fileInput;
this.addFileTransferBtn();
meeboApp.fileTransfer.sendFile(b,{onBeforeSendFile:hitch(this,"onBeforeSendFile"),onSendFile:hitch(this,"onSendFile")},this.m_imobject)
};
this.onBeforeSendFile=function(){this.addHistoryIM(this.m_imobject.getAlias(),"",false,false,false,null,false,null,"temp",gLogon.getMeeboUser())
};
this.onSendFile=function(e,d,f){if(d){var b=gLogon.getMeeboUser();
this.updateFileInfo(b,e.fileid,false,e);
var c="http://"+document.domain+"/#mu="+encodeURIComponent(b)+"&amp;fileid="+encodeURIComponent(e.fileid)+"&amp;u="+encodeURIComponent(this.m_imobject.getName())+"&amp;p="+encodeURIComponent(this.m_imobject.getProtocol());
this.sendIMRequest(gLang.sendFileInvite+" "+c,"sendFile")
}else{this.setTransferError(this.m_fileInfo,f);
this.m_fileInfo.style.marginLeft=this.m_fileInfo.parentNode.firstChild.offsetWidth
}};
this.getTopToolbarState=function(){var c="offlist";
if(this.m_imobject.isOnlist()){var k=this.m_imobject.getProtocol()=="aim";
var l=gBuddyList.getGroupByName("Recent Buddies");
var h=l&&this.m_imobject.hasGroup(l);
var f=this.isMeeboGroupChat();
var m=gBuddyList.getGroupByName(gLang.recentRooms);
var e=m&&this.m_imobject.hasGroup(m);
if(!(k&&h)&&!(f&&e)){c="onlist"
}}c+=gLogon.getMeeboUser()?"-meebo":"";
if(this.isGroupChat()&&this.m_imobject.getChatId()){c+="-groupchat"
}if(this.m_applicationRoom){c+="-app";
if(this.isGroupChat()){c+="-groupapp"
}}else{if(this.isMeeboGroupChat()){var g=this.getYourself();
var d=g&&g.getPresence(this.m_imobject);
var b=d&&d.isOwner();
c+=b?"-owner":"";
if(this.m_imobject.isPrivate()){c+="-private"
}if(this.m_imobject.getWidgetHash()){c+="-widget"
}}}return c
};
this.initFontbar=function(){this.m_fontbar=new meeboApp.fontbar(getUniqueId(),this,"uiImFontbar",this.m_fontType,this.m_fontSize,this.m_bBold,this.m_bItalics,this.m_bUnderline).create(this.m_win);
this.getBody().appendChild(this.m_fontbar.getElement());
if(this.isMeeboGroupChat()){this.m_fontbar.m_fontSizes=[6,7,8,9,10,11,12,13,14]
}var b=this.m_fontbar.m_fontSizes[this.m_fontbar.m_fontSizes.length-1];
if(this.m_fontSize&&this.m_fontSize>b){this.m_fontSize=this.m_fontbar.m_fontSize=b
}this.m_fontbar.getElement().style.bottom="66px";
if(this.m_imobject.getType()=="buddy"){this.m_fontbar.createShareLink()
}this.m_fontbar.setImDlg(this);
this.m_fontbar.subscribe("Share",this,"onShare")
};
this.addMediaButton=function(){if(this.isMediaFlaggable()){this.m_fontbar.addMediaButton();
this.recalcLayout()
}};
this.initStatus=function(){this.m_status=this.m_win.document.createElement("div");
this.m_status.id="imstatus";
addClassName(this.m_status,"uiImStatus");
if(!this.isMeeboGroupChat()){this.m_status.unselectable="on";
addClassName(this.m_status,"unselectable")
}this.updateIMStatus()
};
this.initOverlay=function(){this.m_overlay=this.m_win.document.createElement("div");
this.m_overlay.style.position="absolute";
var b=this.isMeeboGroupChat()?(this.m_chatInfoH+this.m_chatInfoMargin):this.m_topToolbarH;
this.m_overlay.style.top=b+"px";
this.m_overlay.style.left="0";
this.m_overlay.style.backgroundColor="white";
this.m_overlay.style.overflow="auto";
this.getBody().appendChild(this.m_overlay)
};
this.showOverlayMessage=function(b){var c=this.m_win.document.createElement("div");
c.style.position="absolute";
c.unselectable="on";
c.className="unselectable";
c.appendChild(this.m_win.document.createTextNode(b||gLang.holdOnTightForRooms+"\u2026"));
removeElement(this.m_inputDiv);
if(this.m_overlay){this.m_overlay.innerHTML="";
this.m_overlay.appendChild(c)
}this.recalcLayout()
};
this.showInputPrompt=function(h,d,g,l){if(!this.m_overlay){this.initOverlay()
}else{this.m_overlay.innerHTML=""
}var c=this.getId();
var f='<div class="unselectable" class="unselectable">'+h+"</div>";
var k='<label for="'+c+'-input" 				class="unselectable" unselectable="on" 				style="line-height: 18px; width:80px; text-align:right; position:absolute; top:42px; font-weight: bold;">'+d+':</label><input type="text" id="'+c+'-input" 				style="position: absolute; top:42px; left:88px; width: 152px;">';
var m='<div id="'+c+'-buttonContainer" 			style="position:absolute; top:72px; width:100%;"></div>';
var b=this.m_win.document.createElement("div");
b.style.position="absolute";
b.style.height="100px";
b.style.width="240px";
b.innerHTML=[f,k,m].join("");
this.getBody().appendChild(b);
this.m_inputDiv=b;
this.m_inputPromptInput=$(c+"-input");
ui.connectEvent(this.m_inputPromptInput,"keypress",this,function(n){switch(n.keyCode){case ui.KEY_RETURN:l();
ui.setEventHandled(n);
break
}},true);
this.m_inputPromptInput.focus();
this.m_inputPromptInput.select();
var m=$(c+"-buttonContainer");
var e=new ui.button(c+"-joinButton",g).create(this.m_win);
m.appendChild(e.getElement());
e.addOnMouseUp(l);
e.m_element.style[ui.isIE?"styleFloat":"cssFloat"]="right";
this.recalcLayout()
};
this.showPasswordPrompt=function(){var b=hitch(this,function(){meeboApp.joinRoom(this.m_imobject,this.m_inputPromptInput.value);
this.showOverlayMessage();
this.m_isShowingPasswordPrompt=false
});
this.m_isShowingPasswordPrompt=true;
this.showInputPrompt(gLang.privateRoomEnterAccessCode,gLang.accessCode,gLang.joinRoom,b)
};
this.showAliasPrompt=function(e){var d=this.getYourself();
var c=d.getPresence(this.m_imobject);
var b=hitch(this,function(){this.clearOverlay();
this.m_imobject.getLogin().setUserSpecifiedAlias(true);
var h=this.m_inputPromptInput.value;
var f=c.getAlias();
if(h!=f){var g=this.m_imobject.getLogin();
gNetworkMgr.requestChatAction(null,"n",null,this.m_imobject,this.m_imobject.getChatId(),f,h)
}this.m_isShowingAliasPrompt=false;
e();
this.focusOnMessage()
});
this.m_isShowingAliasPrompt=true;
this.showInputPrompt(gLang.chooseNickMessage,gLang.nickname,gLang.startTalking,b);
util.css.setOpacity(this.m_overlay,0.85);
this.m_inputPromptInput.value=c.getAlias();
this.m_inputPromptInput.focus();
this.m_inputPromptInput.select()
};
this.clearOverlay=function(){removeElement(this.m_overlay);
this.m_overlay=null;
removeElement(this.m_inputDiv);
this.m_inputDiv=null
};
this.showRejoinControls=function(){this.showMessageControls(gLang.leftRoomMessage,gLang.rejoinRoom,hitch(meeboApp,"joinRoom",this.m_imobject,null,null,null,null));
this.m_rejoinDiv=this.m_messageDiv
};
this.showMuteControls=function(){if(this.m_rejoinDiv){return
}this.showMessageControls(gLang.youHaveBeenMuted)
};
this.hideMuteControls=function(){if(this.m_rejoinDiv||!this.m_messageDiv){return
}removeElement(this.m_messageDiv);
this.m_messageDiv=null;
this.m_message.setDisabled(false)
};
this.showMessageControls=function(c,d,b){if(this.m_messageDiv){removeElement(this.m_messageDiv)
}this.m_messageDiv=this.m_win.document.createElement("div");
var e=this.m_win.document.createElement("span");
e.unselectable="on";
e.className="unselectable";
e.style.position="absolute";
e.style.lineHeight="18px";
setText(e,c);
this.m_messageDiv.appendChild(e);
this.m_messageLabel=e;
if(d){this.m_messageButton=new ui.button(this.getId()+"-rejoinButton",d).create(this.m_win);
this.m_messageDiv.appendChild(this.m_messageButton.getElement());
this.m_messageButton.addOnMouseUp(b);
this.m_messageButton.getElement().style.position="absolute"
}else{this.m_messageButton=null
}this.m_message.setDisabled(true);
this.getBody().appendChild(this.m_messageDiv);
this.recalcLayout()
};
this.resize=function(c,d){var b=this.m_resizeTimerLength;
if(this.m_isMorphing){this.recalcLayout(c,d)
}else{if(this.m_resizeTimer==-1){this.recalcLayout(c,d);
this.m_resizeTimer=setTimeout(hitch(this,function(){this.recalcLayout();
this.m_resizeTimer=-1;
this.m_resizeTimerStart=null
}),b);
this.m_resizeTimerStart=new Date().getTime()
}}if(this.m_resizeTimerStart&&(new Date().getTime()-this.m_resizeTimerStart)>b){this.recalcLayout(c,d);
this.m_resizeTimerStart=new Date().getTime()
}};
this.resizeChatInfo=function(b,d,c){if(!c.isMeeboGroupChat){return
}var e=(this.isMinimized()?"none":"");
this.m_chatTitle.resize(b-this.m_chatImgMargin-this.m_windowButtons.getWidth()-this.m_chatImg.offsetWidth-this.m_marginWidths);
this.m_chatInfoContainer.style.display=e;
this.m_caption.setDisplay(this.isMinimized())
};
this.resizeTopToolbar=function(b,d,c){var f=0,e=2;
if(this.m_inviteMenu&&!this.m_bGroupChatHidden){b-=c.buddyListWidth+this.m_vertSliderSize
}if(c.isMeeboGroupChat){f=this.m_chatInfoW;
e+=this.m_chatInfoH-this.m_topToolbarH;
b-=this.m_chatInfoW
}this.m_topToolbar.getElement().style.left=f+"px";
this.m_topToolbar.getElement().style.top=e+"px";
this.m_topToolbar.getElement().style.width=b+"px";
this.m_topToolbar.resize(b)
};
this.resizeOverlay=function(b,d,c){var d=d-c.headerHeight-this.m_statusH;
this.m_overlay.style.width=b+"px";
this.m_overlay.style.height=d+"px";
var e=this.m_overlay.firstChild;
if(e){e.style.top=((d/2)-(e.offsetHeight/2))+"px";
e.style.left=((b/2)-(e.offsetWidth/2))+"px"
}var e=this.m_inputDiv;
if(e){e.style.top=c.headerHeight+((d/2)-(e.offsetHeight/2))+"px";
e.style.left=((b/2)-(e.offsetWidth/2))+"px"
}};
this.resizeFontbar=function(c,e,d){var b=parseInt(c-d.buddyListWidth-3);
this.m_fontbar.getElement().style.bottom=d.messageHeight+this.m_statusH+this.m_horzSliderSize+"px";
this.m_fontbar.getElement().style.width=b+"px";
this.m_fontbar.resize(b)
};
this.resizeFontbarSliders=function(b,d,c){if(this.m_buddyList){b-=c.buddyListWidth+this.m_vertSliderSize
}this.m_sliderBottom.style.bottom=this.m_statusH+c.messageHeight+"px";
this.m_sliderTop.style.bottom=this.m_statusH+c.messageHeight+this.m_fontbarH+this.m_horzSliderSize+"px";
this.m_sliderTop.style.width=this.m_sliderBottom.style.width=b+"px"
};
this.resizeMessageHistory=function(d,m,s){if(this.m_buddyList&&!this.m_bGroupChatHidden){d-=s.buddyListWidth+this.m_vertSliderSize
}var p=2+2+2;
var h=0;
if(this.isAppAreaVisible()||this.m_bMediaResize){h=s.groupChatMediaWidth+this.m_vertSliderSize
}var f=this.m_horzSliderSize+this.m_fontbarH+this.m_horzSliderSize;
var o=m-f-s.headerHeight-this.m_statusH-s.messageHeight;
var e=(s.isMeeboGroupChat?this.m_minGroupChatHistoryH:this.m_minHistoryH);
if(this.isMinimized()){o=0
}else{if(o<e){s.messageHeight-=e-o;
s.messageHeight=Math.max(s.messageHeight,this.m_minMessageH);
o=e
}}var g=d-(this.isAppMode()?h:0);
this.m_message.getElement().style.width=g-6+"px";
this.m_message.getElement().style.height=s.messageHeight-4+"px";
if(this.m_messageDiv){var n=18;
var b=this.m_messageLabel.offsetWidth;
var q=!this.m_messageButton?0:this.m_messageButton.m_element.offsetWidth;
var g=b+q+8;
var c=s.messageLeft+(s.messageWidth/2)-(g/2);
this.m_messageLabel.style.left=c+"px";
this.m_messageLabel.style.top=s.messageTop+(s.messageHeight/2)-(n/2)+"px";
if(this.m_messageButton){this.m_messageButton.m_element.style.top=this.m_messageLabel.style.top;
this.m_messageButton.m_element.style.left=c+b+8+"px"
}}var l=Math.max(this.m_minHistoryW,d-h);
this.m_history.style.top=s.headerHeight+"px";
this.m_history.style.width=l-p+"px";
this.m_history.style.height=o+"px";
var k=(o/2)+"px";
if(this.m_historyMediaSliderImage){this.m_historyMediaSliderImage.style.top=k
}if(this.m_buddyListSliderImage){this.m_buddyListSliderImage.style.top=k
}};
this.resizeBuddyListContents=function(d,f,e){if(!this.m_buddyList||!this.m_buddyListSlider){return
}var c=e.bodyHeight;
var b=this.m_buddyList.getElement();
b.style.top=e.headerHeight+"px";
b.style.height=c+"px";
if(e.isMeeboGroupChat){this.m_buddyListSlider.style.top=e.headerHeight+"px"
}this.m_buddyListSlider.style.height=c+"px";
this.m_buddyListSlider.style.right=e.buddyListWidth+"px"
};
this.resizeMediaContents=function(c,g,d){if(!this.isAppAreaVisible()){return
}var b=this.m_history.offsetHeight-2;
var k=this.m_history.offsetWidth;
var f=this.m_vertSliderSize+(!this.isAppMode()?this.m_vertSliderSize:0);
var e=(c-k-d.buddyListWidth-f-2);
d.groupChatMediaWidth=e;
this.m_appArea.style.top=this.m_history.style.top;
this.m_appArea.style.right=d.buddyListWidth+(!this.isAppMode()?this.m_vertSliderSize:0)+"px";
this.m_appArea.style.width=e+"px";
this.m_appArea.style.height=this.isAppMode()?d.bodyHeight+"px":this.m_history.style.height;
if(this.m_appList){var h=d.bodyHeight-(this.m_appBar.getPos().h||0);
this.m_appList.setPos(0,0,-1,h);
if(this.m_appFrame){this.m_appFrame.setPos(0,0,-1,h)
}if(this.m_appFrameOverlay){this.m_appFrameOverlay.style.height=h+"px";
this.m_appFrameOverlay.style.width=e+"px"
}}if(this.m_historyMediaSlider){this.m_historyMediaSlider.style.left=k+"px";
this.m_historyMediaSlider.style.height=(this.m_appArea?d.bodyHeight:b)+"px"
}if(this.m_mediaContainer){this.m_mediaContainer.style.height=(b-d.mediaListHeight-d.mediaHelpHeight)+"px"
}if(this.m_mediaList){this.m_mediaList.setPos(null,null,e,null)
}if(this.m_mediaHelpText){this.m_mediaHelpText.setPosition(null,null,e-(this.m_mediaFlag?this.m_mediaFlag.offsetWidth:0)-5,null)
}};
this.calculateMediaWidth=function(b,d){var f=0;
if(this.m_buddyList){f=this.m_buddyList.getPos().w
}if(this.isAppMode()){var c=this.m_appArea.offsetWidth
}else{var e=this.m_bMediaDrag||this.m_bMediaResize;
var c=e?this.m_appArea.offsetWidth:(b-this.m_marginWidths-f+(2*this.m_vertSliderSize))*this.m_historyMediaRatio
}c=Math.ceil(c);
c=c>this.m_minMediaW?c:this.m_minMediaW;
return c
};
this.resizeStatus=function(b,d,c){this.m_status.style.width=b+"px"
};
this.recalcLayout=function(e,h){if(!this.isVisible()){return
}var c=this.isHistoryAtBottom();
if(this.m_isMorphing&&this.m_state!="max"&&!this.isPoppedOut()){return
}if(!e){e=this.getBody().offsetWidth
}if(!h){h=this.getBody().offsetHeight
}var f={isMeeboGroupChat:this.m_imobject.constructor==meebo.Room};
var b=this.m_message.getElement();
f.messageWidth=b.offsetWidth;
f.messageHeight=b.offsetHeight;
f.messageTop=b.offsetTop;
f.messageLeft=b.offsetLeft;
if(this.m_buddyList){var d=this.m_buddyList.getPos();
f.buddyListWidth=d.w||0;
f.buddyListHeight=d.h||0
}else{f.buddyListWidth=f.buddyListHeight=0
}if(this.m_appArea){var g=this.calculateMediaWidth(e,h);
if(ui.isWebKit){g+=1
}f.groupChatMediaWidth=g;
f.mediaHelpHeight=this.m_mediaHelp?this.m_mediaHelp.offsetHeight:0;
f.mediaListHeight=this.m_mediaList?this.m_mediaList.getPos().h:0
}f.headerHeight=(f.isMeeboGroupChat?(this.m_chatInfoH+this.m_chatInfoMargin):this.m_topToolbarH);
f.bodyHeight=(h-f.headerHeight-this.m_statusH-3);
if(this.isMeeboGroupChat()){this.m_chromelessMaxDragY=f.headerHeight+parseInt(getCSSProp(this.getBody(),"top"))
}this.resizeChatInfo(e,h,f);
if(this.isMinimized()){return true
}this.resizeTopToolbar(e,h,f);
if(this.m_overlay){this.resizeOverlay(e,h,f)
}this.resizeMessageHistory(e,h,f);
this.resizeFontbar(e,h,f);
this.resizeFontbarSliders(e,h,f);
this.resizeBuddyListContents(e,h,f);
this.resizeMediaContents(e,h,f);
this.resizeStatus(e,h,f);
this.m_minX=this.getMinWidth();
if(c){this.m_history.scrollTop=this.m_history.scrollHeight
}this.updateBuddyIconPosition(c);
this.clipIcon();
if(c){this.scrollHistoryToBottom()
}return true
};
this.alertPrivacyIsOn=function(){if(("allow_buddylist"!=gPrefs.getPref("privacy"))||this.m_imobject.isOnlist()){return
}var b=sprintf(gLang.privacyPrefNotification,this.m_imobject.getAlias());
b=meebo.util.emoticons.insertMeeboEmoticons(b);
this.addHistoryNotification(b,this.getId()+"-privacyNotification")
};
this.requestHistory=function(){var b=this.m_imobject;
if(gIMGateway.isAttached()){gNetworkMgr.doRequest("fetchconversation",{username:b.getUser(),protocol:b.getProtocol(),buddyname:b.getName()},hitch(this,"receiveConversations"))
}else{this.requestChatLog()
}};
this.requestChatLog=function(){var c=this.m_imobject;
if(!c.getLogin().isMeeboChild()){return
}var b=gLogon.getMeeboUser();
if(!b){return
}if(c.getNetwork()=="meebome"&&!this.isMeeboGroupChat()&&(!c.isOnlist()||c.isGuestUser()||c.isWidgetUser())){return
}gNetworkMgr.requestChatLog(hitch(this,"receiveChatLog"),c,10)
};
this.receiveChatLog=function(c,b,d){if(b&&c&&c.length){this.addHistoryIM("",c,true,false,true,null,true)
}};
this.requestMediaChatLog=function(b,c){gNetworkMgr.requestMeeboChatLog(hitch(this,"receiveMediaChatLog",c),this.m_imobject,"u",b)
};
this.receiveMediaChatLog=function(e,d,b,c){if(isDefined(d.urls)&&d.urls.length){for(var f=0;
f<d.urls.length;
f++){var g=d.urls[f].click_url=="(null)"?d.urls[f].s:(d.urls[f].click_url||d.urls[f].s);
var l=meeboApp.MediaListItem.fromChatLog(d.urls[f]);
this.addToMediaList(l)
}this.queueMediaFromUrl(e);
this.m_mediaList.selectRoomItem(e)
}else{var h=[gImages.getPath()+"media_instructions_1.png",gImages.getPath()+"media_instructions_2.png",gImages.getPath()+"media_instructions_3.png"];
for(var f=0;
f<3;
f++){var k=[gLang.roomIntro1,gLang.roomIntro2,gLang.roomIntro3][f];
this.addToMediaList(new meeboApp.MediaListItem({thumbnailUrl:h[f],mediaUrl:h[f],itemUrl:h[f],clickUrl:h[f],type:"image",length:0,description:k,watermark:null,isDefaultMedia:true}))
}this.queueMediaFromUrl(h[0])
}if(gShowChatlogLinks&&!this.m_imobject.isPrivate()){var m=gLang.chatLogRecordedWarning;
if(Math.random()<gShowChatlogLinks){m+='<div style="text-align: right;"><a href="'+this.m_imobject.getChatlogURL()+'" target="_blank">'+gLang.chatLogsTT+"&hellip;</a></div>"
}this.addHistoryNotification(m,this.getId()+"-chatlogNotification")
}if(!this.m_imobject.isPrivate()&&this.isMediaFlaggable()){this.addHistoryNotification(gLang.useApprovedMedia,this.getId()+"-previewNotification")
}gNetworkMgr.requestMeeboChatLog(hitch(this,"receiveMeeboChatLog"),this.m_imobject,"c",150)
};
this.receiveMeeboChatLog=function(c,b,d){if(c){c=meebo.util.message.fixRoomHistoryDates(c);
c=meebo.util.message.fixRoomHistoryMessages(c);
c=linkify(c);
c="<span>"+c.replace(/<br\/>/g,"<br/></span><span>")+"</span>"
}this.addHistoryIM("",c,true,false,true,null,true)
};
this.updateTopToolbar=function(b){if(!b&&!this.m_imobject.getLogin().isOnline()){return
}if(this.getTopToolbarState()!=this.m_topToolbarType){this.initTopToolbar();
this.recalcLayout()
}};
this.setGreyFields=function(c){var b=c?"#f7f7f3":"#fff";
this.m_history.style.backgroundColor=b;
if(this.isMeeboGroupChat()){this.m_message.setEditorColor(c?"#f3f3f1":"#fff");
this.m_message.setDisabled(c)
}else{this.m_message.setEditorColor(b)
}if(this.m_buddyList){this.m_buddyList.getElement().style.backgroundColor=b
}};
this.greyText=function(){if(!this.m_history||!this.m_history.hasChildNodes||!this.m_history.hasChildNodes()){return
}this.recursiveColorText(this.m_history,this.m_greyText)
};
this.moveBuddiesOffline=function(){var c=this.m_imobject;
if(c.getType()=="buddy"||!this.m_buddyList){return
}var e=c.getPresences();
for(var b in e){var d=e[b];
d.setOnline(false)
}};
this.setOffline=function(b,d){if(b&&this.m_rejoinDiv&&!this.m_imobject.getLogin().isOnline()){this.m_rejoinDiv.style.display="none"
}if(this.m_bOffline==b){return
}this.m_bOffline=b;
if(this.isGroupChat()){this.m_bGroupChatOffline=b
}this.setGreyFields(b);
if(this.isMeeboGroupChat()&&this.m_imobject.constructor==meebo.Room){if(!b){if(this.m_rejoinDiv){removeElement(this.m_rejoinDiv);
this.m_rejoinDiv=this.m_messageDiv=null
}}else{if(this.m_imobject.getLogin().isOnline()&&!d){this.showRejoinControls()
}try{if(this.m_mediaPlayer&&this.isVisible()&&this.m_mediaPlayer.SetVariable){this.m_mediaPlayer.SetVariable("pause",true);
this.m_mediaPlayer.SetVariable("sync",false)
}}catch(c){}}}if(this.m_appList){this.m_appList.setDisabled(b)
}this.setFileTransferOffline(b);
this.m_fontbar.setDisabled(b);
this.setToolbarButtonsDisabled(b);
toggleClassName(this.m_history,b,"uiImHistory-offline");
if(b){this.stopFlashWindow();
this.moveBuddiesOffline();
this.updateIMStatus()
}if(this.m_chatImg){util.css.setOpacity(this.m_chatImg,b?0.6:1)
}};
this.isOffline=function(){return this.m_bOffline
};
this.recursiveColorText=function(b,c){if(!b||!c){return
}if(b&&b.style){b.style.color=c
}if(!b.hasChildNodes||!b.hasChildNodes()){return
}var e=b.firstChild;
while(e){if(e.style){e.style.color=c
}if(e.tagName=="FONT"){e.color=c
}var d=this.recursiveColorText(e,c);
e=e.nextSibling
}};
this.onShow=function(){if(meeboApp.isPopout()&&this.getBuddy()){var b="#"+this.getBuddy().getId();
gUIState.set(b,{sortIndex:0});
gUIState.set("activePlt",{im:b})
}gDragManager.addDropTarget(this)
};
this.onMessageKeyPress=function(d){if(!d){return
}var f=d.keyCode;
var e=d.ctrlKey;
var b=d.altKey;
var c=d.shiftKey;
if(gAdTimer){gAdTimer.delayLoadAds()
}if(d.keyCode==9&&!e){if(c){gWindowMgr.focusPrev()
}else{gWindowMgr.focusNext()
}ui.setEventHandled(d);
return false
}if((f!=13)&&(f!=27)||(f==13&&c)){if(ui.isIE){d.cancelBubble=true
}if(e||b||(f>=33&&f<=45)||(f>=16&&f<=20)||f==144||f==145){return true
}setTimeout(hitch(this,"handleTypingNotification"),0);
return true
}ui.setEventHandled(d);
if(d.keyCode==13){this.sendIM("k")
}else{if(d.keyCode==27){this.closeWindow()
}}return false
};
this.handleTypingNotification=function(){var b=hitch(this,function(){var d=2;
if(ui.isIE==7&&this.isPoppedOut()&&this.m_message.getText()==""){d=0
}this.onTypingNotification(d)
});
var c=(ui.isIE==7&&this.isPoppedOut())?c="not empty":this.m_message.getText();
if(c==""){if(this.m_typingT!=0){this.onTypingNotification(0)
}}else{if(this.m_typingT!=1){this.onTypingNotification(1)
}else{clearTimeout(this.m_typingTimer)
}this.m_typingTimer=setTimeout(b,4000)
}};
this.onMessageKeyDown=function(b){if(ui.isWebKit&&(b.keyCode==9||b.keyCode==27)||ui.isIE&&b.keyCode==9){this.onMessageKeyPress(b)
}if(ui.isIE){b.cancelBubble=true
}return true
};
this.onMessageKeyUp=function(b){if(b.keyCode==8){this.onMessageKeyPress(b)
}return true
};
this.onTypingNotification=function(b){if(this.isGroupChat()){return
}this.m_typingT=b;
if(this.m_typingTimer){clearTimeout(this.m_typingTimer);
this.m_typingTimer=null
}runInMainContext(gNetworkMgr,gNetworkMgr.requestSetTypingNotification,b,this.m_imobject)
};
this.onMessageDrag=function(b,f,c,e){var d=this.isHistoryAtBottom();
this.m_message.getElement().style.width=c+"px";
this.m_message.getElement().style.height=e+"px";
this.recalcLayout();
this.updateBuddyIconPosition(d);
this.clipIcon()
};
this.onSliderResize=function(b){this.moveToTop();
this.m_dr.init(this.m_message,b,hitch(this,"onMessageDrag"));
this.m_dr.startResize("n",null,this.m_minMessageH,null,this.getMaxMessageHeight(this.m_contentHeight))
};
this.onBuddyListDrag=function(b,e,c,d){if(this.m_inviteMenu){this.m_inviteMenu.resize(c,null,c)
}this.m_buddyList.getElement().style.width=c-2+"px";
this.recalcLayout()
};
this.getMaxBuddyListWidth=function(){var b=this.isAppAreaVisible();
return this.getBody().offsetWidth-(this.m_minHistoryW+2+(b?(this.m_minMediaW+this.m_vertSliderSize):0)+this.m_vertSliderSize)
};
this.onGroupChatSliderResize=function(d){var b=this.m_buddyListMinW;
var f=this.getMaxBuddyListWidth();
var g=d.target||d.srcElement;
var c=(g==this.m_buddyListSliderImage);
this.m_buddyList.m_onStopResize=[hitch(this,function(l,h,k){var m=l.target||l.srcElement;
c=(c&&m==this.m_buddyListSliderImage);
if(c&&!h){this.showHideMedia()
}this.m_buddyList.m_onStopResize=[]
})];
this.moveToTop();
this.m_dr.init(this.m_buddyList,d,hitch(this,"onBuddyListDrag"));
this.m_dr.startResize("w",b,null,f,null)
};
this.onGroupChatMediaDrag=function(b,e,c,d){this.m_bMediaDrag=true;
this.m_appArea.style.width=c+"px";
if(this.m_mediaList){this.m_mediaList.setPos(null,null,c,null)
}this.recalcLayout()
};
this.getMaxMediaWidth=function(){var c=0;
if(this.m_buddyList){c=this.m_buddyList.getPos().w||0
}var b=this.m_applicationRoom?this.m_vertSliderSize:(this.m_vertSliderSize+this.m_vertSliderSize);
return this.getBody().offsetWidth-(this.m_minHistoryW+c+2+b)
};
this.onHistoryMediaSliderDrag=function(d){var b=this.m_minMediaW;
if(this.isAppMode()&&this.m_applicationRoom){b=Math.max(b,this.m_applicationRoom.getApplication().width)
}var f=this.getMaxMediaWidth();
if(b==f){return
}var g=d.target||d.srcElement;
var c=(g==this.m_historyMediaSliderImage);
this.m_appArea.m_onStopResize=[hitch(this,function(l,h,k){var m=l.target||l.srcElement;
c=(c&&m==this.m_historyMediaSliderImage);
this.m_historyMediaRatio=(this.m_appArea.offsetWidth+this.m_vertSliderSize)/(this.m_appArea.offsetWidth+this.m_history.offsetWidth);
if(c&&!h){this.showHideMedia()
}this.m_bMediaDrag=false;
this.m_appArea.m_onStopResize=[]
})];
this.moveToTop();
this.m_dr.init(this.m_appArea,d,hitch(this,"onGroupChatMediaDrag"));
this.m_dr.startResize("w",b,null,f,null)
};
this.onMoveToTop=function(c,b){if(c&&ui.getMouseButton(c)!=1){ui.setEventHandled(c);
return true
}if(!b||!b.id||(b.id==this.m_message.getId())||b.id=="content"||b.id=="history"){return true
}if(c){ui.setEventHandled(c)
}return false
};
this.stopBuddyMessageFeedback=function(){var c=this.m_imobject;
if(c.getType()=="buddy"){var b=c.getConversation();
if(b){b.resetUnreadCount()
}}else{if(c.isOnlist()&&this.isMeeboGroupChat()){c.setLastReadMsg()
}}gBuddyListDlg.showBuddyMessageFeedback(c,false);
this.stopFlashWindow()
};
this.shouldHandleKeyEvent=function(d){var b=this.isMinimized();
var c=d==this.m_message.getElement();
var e=this.m_inviteMenu&&(d==this.m_inviteMenu.getCustomizeElement());
return !b&&!c&&!e
};
this.onGlobalKeyPress=function(c,b){if(!this.shouldHandleKeyEvent(b)){return true
}if(this.onMessageKeyPress(c)&&!c.ctrlKey&&!c.metaKey&&c.keyCode!=33&&c.keyCode!=34){if(!isSpecialKey(c.charCode)&&!ui.isWebKit){this.m_message.getElement().value+=(String.fromCharCode(c.charCode))
}this.focusOnMessage()
}return true
};
this.onGlobalKeyDown=function(c,b){if(this.shouldHandleKeyEvent(b)){if((c.ctrlKey&&c.keyCode==86)||(c.shiftKey&&c.keyCode==45)||c.keyCode==8||(c.metaKey&&c.keyCode==86)){this.focusOnMessage()
}}return true
};
this.getHistorySelection=function(){if(this.m_win.document.selection&&this.m_win.document.selection.createRange){var b=this.m_win.document.selection.createRange();
return b.text
}else{if(this.m_win.getSelection){if(ui.isWebKit){return this.m_win.getSelection()+""
}else{return this.m_win.getSelection().toString()
}}}return""
};
this.focusOnMessage=function(){if(!this.m_win.m_focus||this.m_overlay){return
}var c=this.getWindowPos();
var b=ui.getClientRect(this.m_win);
if(this.isPoppedOut()||c.y+c.h<b.h&&c.x+c.w<b.w){this.m_message.focus()
}};
this.blurMessageBox=function(){this.m_message.blur()
};
this.onScrollTimer=function(b){if(this.m_buddyIconTimer!=-1){clearTimeout(this.m_buddyIconTimer)
}if(this.m_bBuddyIconTimerOverride){this.m_bBuddyIconTimerOverride=false
}else{this.m_buddyIconTimer=setTimeout(hitch(this,function(){if(this.m_bPoppingOut){return
}if(this.m_bBuddyIconTimerOverride){return
}this.updateBuddyIconPosition(b||this.isHistoryAtBottom())
}),this.m_scrollTimerInterval)
}};
this.connectContentEvents=function(){ui.connectEvent(this.m_sliderTop,"mousedown",this,"onSliderResize",true,true);
ui.connectEvent(this.m_sliderBottom,"mousedown",this,"onSliderResize",true,true);
ui.connectEvent(this.m_sliderTop,"focus",this,"onSliderResize",true,true);
ui.connectEvent(this.m_sliderBottom,"focus",this,"onSliderResize",true,true);
ui.connectEvent(this.m_history,"scroll",this,"onScrollTimer",false,false);
this.m_message.m_onStopResize=this.m_onStopResize;
this.m_message.m_onDragStart=this.m_onDragStart;
this.m_message.onKeyDown(hitch(this,"onMessageKeyDown"));
this.m_message.onKeyPress(hitch(this,"onMessageKeyPress"));
this.m_message.onKeyUp(hitch(this,"onMessageKeyUp"));
this.m_onClose.push(hitch(this,"onClose"));
this.m_onFocus.push(hitch(this,function(){this.stopBuddyMessageFeedback();
if(isSelectionCollapsed(this.m_win)){this.focusOnMessage()
}if(this.isMeeboGroupChat()){removeClassName(this.m_chatInfoContainer,"inactive");
if(ui.isFirefox||ui.isWebKit){this.hideMediaOverlay();
this.showMediaOverlays()
}}this.hideAppIFrameOverlay();
if(meeboApp.isPopout()&&this.getBuddy()){var b="#"+this.getBuddy().getId();
gUIState.set("activePlt",{im:b})
}}));
this.m_onWindowFocus.push(hitch(this,function(){this.stopBuddyMessageFeedback();
if(isSelectionCollapsed(this.m_win)){this.focusOnMessage()
}}));
this.m_onBlur.push(hitch(this,function(){if(this.m_chatInfoContainer){addClassName(this.m_chatInfoContainer,"inactive")
}this.m_message.blur();
this.showAppIFrameOverlay()
}));
this.m_onMinimize.push(hitch(this,"onMinimize"));
this.m_onCallbackRestoreMinimize.push(hitch(this,"onRestoreMinimize"));
this.m_onMaximize.push(hitch(this,"focusOnMessage"));
this.m_onRestoreMaximize.push(hitch(this,"onRestoreMaximize"));
this.m_onCallbackRestoreMaximize.push(hitch(this,"onCallbackRestoreMaximize"));
this.m_onStopMove.push(hitch(this,function(){this.focusOnMessage();
this.saveWindowPosition()
}));
this.m_fontbar.subscribe("Emoticon",this,"onEmoticon");
this.m_fontbar.subscribe("Media",this,"onMedia");
this.m_onDragStart.push(hitch(this,"onStartResize"));
this.m_onStopResize.push(hitch(this,function(){this.onStopResize();
this.saveWindowPosition()
}));
this.m_onStopMove.push(hitch(this,function(){this.onStopMove()
}));
this.m_animationAppArea.addSubject(hitch(this,"animateAppArea"));
this.m_animationResizeAppArea.addSubject(hitch(this,"animateResizeAppArea"));
this.m_animationResizeAppArea.onfinished=hitch(this,"onFinishedResizeAppAreaAnimation");
this.m_animationBuddyListArea.addSubject(hitch(this,"animateBuddyList"));
this.m_animationBuddyListArea.onfinished=hitch(this,"onFinishedResizeBuddyListArea");
this.connectTopToolbarEvents()
};
this.getBuddy=function(){return this.m_buddy||this.m_imobject
};
this.hideMediaOverlay=function(){if(this.m_mediaPlayer&&this.isAppAreaVisible()&&!this.m_bPlayerFocused){removeClassName(this.m_appArea,"inactive");
this.m_mediaPlayer.SetVariable("show","true");
this.m_bPlayerFocused=true
}};
this.showMediaOverlays=function(){convAr=gWindowMgr.getConvWindows();
for(var b=0;
b<convAr.length;
b++){var c=convAr[b];
if(c.isMeeboGroupChat()&&c!=this&&c.m_chatInfoContainer&&c.isVisible()){if(c.m_mediaPlayer&&c.isAppAreaVisible()&&c.m_bPlayerFocused){c.m_mediaPlayer.SetVariable("hide","true");
c.m_bPlayerFocused=false;
addClassName(c.m_appArea,"inactive")
}}}};
this.showAppIFrameOverlay=function(){if(this.isPoppedOut()||!this.m_appFrame){return
}if(!this.m_appFrameOverlay){var c=this.m_win.document.createElement("div");
c.style.background="url("+gImages.getPath()+"blank.gif)";
c.style.position="absolute";
c.style.top=c.style.left="0";
c.style.width=this.m_appArea.offsetWidth+"px";
c.style.height=(this.m_appArea.offsetHeight-this.m_appBar.getPos().h)+"px";
this.m_appFrameOverlay=c
}var b=this.m_appFrame.getElement();
b.parentNode.appendChild(this.m_appFrameOverlay)
};
this.hideAppIFrameOverlay=function(){if(!this.isActive()&&(!this.m_appList||this.m_appList.getDisplay()=="none")){return
}if(this.m_appFrameOverlay){removeElement(this.m_appFrameOverlay)
}};
this.onMinimize=function(){if(this.m_mediaPlayer&&this.isAppAreaVisible()){this.m_mediaPlayer.SetVariable("hide","true")
}this.blurMessageBox()
};
this.isBuddyListVisible=function(){return(this.m_buddyList&&this.m_buddyList.getDisplay()!="none"&&this.m_buddyList.getElement().style.visibility!="hidden"&&(this.m_buddyList.getPos().w>0))
};
this.isAppAreaVisible=function(){return(this.m_appArea&&(!this.m_appArea.style.display||this.m_appArea.style.display=="block")&&(!this.m_appArea.style.visibility||this.m_appArea.style.visibility=="visible")&&(this.m_appArea.offsetWidth>0))
};
this.isAppListVisible=function(){return(this.m_appList&&(this.m_appList.getDisplay()!="none")&&this.m_appList.getVisibility()&&(this.m_appList.getPos().w>0))
};
this.saveLastMaximizePos=function(){a(this,"saveLastMaximizePos");
var b=this.isAppListVisible();
var d=!b&&this.isAppAreaVisible();
var c=0;
var e=0;
this.m_lastMaxPos.appListW=this.m_lastMaxPos.appListH=this.m_lastMaxPos.appAreaW=this.m_lastMaxPos.appAreaH=this.m_lastMaxPos.buddyListW=0;
if(d||b){c=this.m_appArea.offsetWidth;
e=this.m_appArea.offsetHeight
}if(d){this.m_lastMaxPos.appAreaW=c;
this.m_lastMaxPos.appAreaH=e
}else{if(b){this.m_lastMaxPos.appListW=c;
this.m_lastMaxPos.appListH=e
}}var f=0;
if(this.isBuddyListVisible()){this.m_lastMaxPos.buddyListW=f=this.m_buddyList.getPos().w
}if(this.m_applicationRoom){this.m_lastMaxPos.w-=(c+f)
}};
this.onRestoreMaximize=function(){var d=this.isAppListVisible();
var f=!d&&this.isAppAreaVisible();
var e=0;
var g=0;
if(this.m_lastMaxPos&&d){e=this.m_lastMaxPos.appListW||280;
g=this.m_lastMaxPos.appListH||410
}else{if(this.m_lastMaxPos&&f){var h=this.getApplicationRoom()?this.getApplicationRoom().getApplication():null;
var b=h?h.width+2:this.m_appArea.offsetWidth;
var c=h?h.height+2:this.m_appArea.offsetHeight;
e=this.m_lastMaxPos.appAreaW||b;
g=this.m_lastMaxPos.appAreaH||c
}}this.m_lastMaxPos.w+=e;
this.m_lastMaxPos.h=Math.max(g,this.m_lastMaxPos.h);
if(d||f){this.m_appArea.style.width=e+"px";
this.m_appArea.style.height=this.m_lastMaxPos.h+"px"
}this.m_lastMaxPos.w-=this.m_lastMaxPos.buddyListW||0;
if(this.isBuddyListVisible()){var k=this.m_buddyListW;
this.m_lastMaxPos.w+=k;
this.m_buddyList.getElement().style.width=k+"px";
if(this.m_inviteMenu&&k){this.m_inviteMenu.resize(k,null,k)
}}};
this.onCallbackRestoreMaximize=function(){var b=this.getWindowPos();
if(this.isBuddyListVisible()||this.isAppAreaVisible()){this.m_toggleDlgStartWidth=b.w;
this.m_toggleDlgStartHeight=b.h
}};
this.onRestoreMinimize=function(){this.updateBuddyIconPosition();
if(this.m_mediaPlayer&&this.isAppAreaVisible()){this.m_mediaPlayer.SetVariable("show","true")
}};
this.onClose=function(){this.m_fontbar.hideShareTooltip();
if(this.m_mediaDlg){if(this.m_mediaDlg._){this.m_mediaDlg._("closeWindow")
}else{this.m_mediaDlg.closeWindow()
}}for(var f in this.m_buddyBoldId){clearTimeout(this.m_buddyBoldId[f])
}this.m_buddyBoldId={};
this.m_fontbar.closeAll();
if(this.m_mediaPlayer){if(this.isPoppedOut()){ui.disconnectAllEvents(this.m_mediaPlayer)
}if(ui.isIE){if(this.m_bAdShowing){this.onFlashAdComplete()
}this.m_mediaPlayer.SetVariable("clear","true");
this.m_mediaPlayer.style.visibility="hidden"
}else{if(this.m_mediaPlayer.parentNode){ui.disconnectAllEvents(this.m_mediaPlayer);
this.m_mediaPlayer.parentNode.removeChild(this.m_mediaPlayer)
}}}if(this.m_bMediaPlayerLoading){this.m_bMediaPlayerLoading=false;
clearTimeout(this.m_mediaCreateTimeoutId)
}if(!this.isGroupChat()&&this.m_typingT!=0){this.onTypingNotification(0)
}if(!this.m_bPoppingOut){var c=this.isGroupChat()&&this.m_imobject.getChatId();
if(c){gWindowMgr.unregisterGroupChat(getGroupChatId(this.m_imobject.getProtocol(),this.m_imobject.getUser(),c));
runInMainContext(gNetworkMgr,gNetworkMgr.requestChatAction,null,"l",null,this.m_imobject,c,null);
if(this.isMeeboGroupChat()){this.m_imobject.m_isLeaving=true
}this.m_imobject.setChatId(null);
if(this.isMeeboGroupChat()&&!this.m_applicationRoom&&ui.isIE&&!this.isPoppedOut()){gWindowMgr.m_meeboGroupChats[this.m_id]=this
}gWindowMgr.unregisterWindow(this.m_id);
gDragManager.removeDropTarget(this);
this.clearBuddyList();
if(this.isMeeboGroupChat()){gPrefs.updateRoomLastAccess(this.m_imobject);
var e=[],d=0;
for(var b in this.m_clickedMedia){d+=this.m_clickedMedia[b];
e.push(b+"="+this.m_clickedMedia[b])
}gNetworkMgr.doUILog(this.control,"media",d,false,e.join(","));
this.m_clickedMedia={};
this.m_imobject.setLastReadMsg()
}}else{if(this.isMeeboGroupChat()){if(ui.isIE&&!this.isPoppedOut()){gWindowMgr.m_meeboGroupChats[this.m_id]=this
}gWindowMgr.unregisterWindow(this.m_id);
gDragManager.removeDropTarget(this)
}}this.stopBuddyMessageFeedback();
if(this.m_imobject.getType()=="buddy"){gBuddyListDlg.clearBuddyTypingNotification(this.m_imobject);
gNetworkMgr.requestSetConversationClose(this.m_imobject)
}gUIState.clear("#"+this.m_imobject.getId());
gNetworkMgr.doUILog(this.control,(this.isMeeboGroupChat()?"room-":"")+"general","unload")
}if(this.isGroupChat()||this.m_bPoppingOut){this.doSubscribe(this.m_imobject,false);
if(this.m_applicationRoom&&this.m_applicationRoom!=this.m_imobject){this.doSubscribe(this.m_applicationRoom,false);
gPubSub.unsubscribe(gPrefs,"meebo.Prefs::accountPref",this);
gPubSub.unsubscribe(gPrefs,"meebo.Prefs::receivePrefs",this)
}}if(!this.isGroupChat()&&this.getApplicationRoom()){this.hideAppIFrameOverlay();
this.toggleAppArea(false,true)
}};
this.reuseChatWindow=function(){this.doSubscribe(this.m_imobject,true);
this.clearHistory();
this.clearMediaList();
this.clearBuddyList();
this.clearOverlay();
this.m_bMediaRequested=false;
if(!this.m_imobject.getChatId()){this.initOverlay();
this.showOverlayMessage()
}if(this.m_mediaPlayer){this.m_mediaPlayer.SetVariable("clear",true)
}this.updateTopToolbar()
};
this.handleProfileButtonClick=function(){gWindowMgr.createProfileDlg({id:getProfileId(this.m_imobject),caption:this.m_imobject.getAlias(),parent:this},this.m_imobject);
gNetworkMgr.doUILog(this.control,"toptoolbar","prof")
};
this.handleChatButtonClick=function(){if(!this.m_chatBtn){return null
}if(gLogon.getMeeboUser()){if(gEventMgr.getState()=="done"){return this.showReconnectDlg()
}gWindowMgr.createChatLogWindow(null,this.m_imobject)
}else{if(this.isPoppedOut()){gWindowMgr.createCreateMeeboAccountDlg({caption:gLang.meeboChatlogUpsell},"imdlg-chatlog","upsell_chatlogs.png")
}else{var b=new meeboApp.AccountUpsellTooltip(gLang.chatLogs,gLang.chatLogsDescription,"chatlogs");
b.showAt(this.m_chatBtn.getElement(),b.BELOW)
}}gNetworkMgr.doUILog(this.control,"toptoolbar","chat"+(gLogon.getMeeboUser()?"-mu":""))
};
this.handleEmbedButtonClick=function(){if(!this.m_embedBtn){return
}if(gEventMgr.getState()=="done"){return this.showReconnectDlg()
}gWindowMgr.createRoomWidgetDlg({id:getRoomWidgetDlgId(this.m_imobject),parent:this},this.m_imobject);
gNetworkMgr.doUILog(this.control,"room-toptoolbar","embed")
};
this.handleInviteButtonClick=function(){if(!this.m_inviteBtn){return
}if(gEventMgr.getState()=="done"){return this.showReconnectDlg()
}this.openInviteDlg();
gNetworkMgr.doUILog(this.control,"room-toptoolbar","invite")
};
this.openInviteDlg=function(){if(!gBuddyList.getBuddies({type:"buddy",onlist:true}).length){gWindowMgr.createNotifyDlg({id:getUniqueId(),caption:gLang.invite,parent:this},gLang.inviteNoBuddies);
return
}gWindowMgr.createRoomCreateDlg({id:getCreateGroupChatDlgId()+"-"+this.m_imobject.getId(),caption:gLang.inviteHeader,parent:this},this.m_applicationRoom||this.m_imobject,true)
};
this.handleAddButtonClick=function(){if(!this.m_addBtn){return
}if(gEventMgr.getState()=="done"){return this.showReconnectDlg()
}if(this.isMeeboGroupChat()){var b=gLogon.getMeeboMeLogon();
if(!b.isMeeboLogon()){b=this.m_imobject.getLogin()
}if(this.m_imobject.isOnlist()){var c=hitch(gNetworkMgr,"requestMoveBuddy",hitch(gNetworkMgr,"receiveAddChat",this.m_imobject),[this.m_imobject],gLang.meeboChats)
}else{var c=hitch(gNetworkMgr,"requestAddBuddy",hitch(gNetworkMgr,"receiveAddChat",this.m_imobject),this.m_imobject.getName(),"jabber",gLang.meeboChats,b.getName())
}if(gLogon.getMeeboUser()){c()
}else{gWindowMgr.createCreateMeeboAccountDlg({},"imdlg-roomaddbl","upsell_addroom.png",c)
}gNetworkMgr.doUILog(this.control,"room-toptoolbar","add")
}else{gWindowMgr.createAddBuddyDlg({parent:this},{logon:this.m_imobject.getLogin(),buddy:this.m_imobject.getName(),group:meebo.util.getDefaultGroup(this.m_imobject.getProtocol())});
gNetworkMgr.doUILog(this.control,"toptoolbar","add")
}};
this.handleBlockButtonClick=function(){if(this.m_blockBtn){gNetworkMgr.doUILog(this.control,"toptoolbar",this.m_bBlock?"block":"unblock");
if(gEventMgr.getState()=="done"){return this.showReconnectDlg()
}if(this.m_bBlock){var b=hitch(this,function(){gNetworkMgr.requestBlockBuddies([this.m_imobject],this.m_bBlock);
this.toggleBlock()
});
gWindowMgr.createOkDlg({id:"blockbuddy",caption:gLang.blockBuddy,parent:this},sprintf(gLang.confirmBlock,this.m_imobject.getAlias()),b,null)
}else{gNetworkMgr.requestBlockBuddies([this.m_imobject],this.m_bBlock);
this.toggleBlock()
}}};
this.handleGroupButtonClick=function(){if(this.m_groupBtn){if(gEventMgr.getState()=="done"){return this.showReconnectDlg()
}if(!this.m_bGroupChatHidden&&this.m_buddyList&&!this.isGroupChat()&&!this.m_isMorphing){gNetworkMgr.doUILog(this.control,"toptoolbar","ungroup");
this.m_groupBtn.setDepressed(false);
this.hideGroupChat(this.isPoppedOut())
}else{if(this.m_bGroupChatHidden&&!this.m_isMorphing){gNetworkMgr.doUILog(this.control,"toptoolbar","group");
this.m_groupBtn.setDepressed(true);
this.showGroupChat(null,this.isPoppedOut())
}}}};
this.showHideMedia=function(c){if(this.isAppAreaVisible()){this.m_lastMediaWidth=this.m_appArea.offsetWidth
}var b=this.isAppAreaVisible();
if(gPrefs.getRoomPref(this.m_imobject.getChatName(),"mediaHidden",false)!=b){gPrefs.saveRoomPref(this.m_imobject,"mediaHidden",b)
}this.m_appArea.style.visibility=b?"hidden":"visible";
this.m_historyMediaSlider.style.display=b?"none":"";
this.m_buddyListSliderImage.style.display=b?"":"none";
this.m_historyMediaSliderImage.style.display=b?"none":"";
if(b&&this.m_mediaList){this.m_mediaList.saveScrollPos()
}this.m_bHistoryAtBottom=this.isHistoryAtBottom();
if(!c){gNetworkMgr.doUILog(this.control,"mediaShowHide",b?"hidden":"visible")
}var d="show";
if(!this.isAppAreaVisible()){this.m_historyMediaSlider.style.display="none";
d="hide"
}else{if(this.m_mediaList){this.m_mediaList.restoreScrollPos()
}}if(this.m_bHistoryAtBottom){this.m_history.scrollTop=this.m_history.scrollHeight
}if(this.m_mediaPlayer){this.m_mediaPlayer.SetVariable(d,"true")
}this.recalcLayout()
};
this.saveWindowPosition=function(){if(this.m_imobject.getNetwork()!="meebome"&&this.m_bGroupChatHidden&&!this.m_isMorphing&&!this.isAppAreaVisible()){var b=this.getWindowPos();
delete b.z;
gPrefs.saveAccountPref(this.m_imobject.getLogin(),"wd:"+this.m_id,b)
}};
this.saveState=function(){if(this.m_buddyList){this.m_buddyList.uncreate()
}return{h:this.m_history.innerHTML,hb:this.isHistoryAtBottom(),ht:this.m_history.scrollTop,hl:this.m_history.scrollLeft,m:this.m_message.getText(),mh:this.m_message.getElement().offsetHeight,gc:this.m_buddyList,trees:this.m_trees,gchidden:!this.m_bGroupChatHidden,gcid:this.m_groupChatId,gcw:this.m_buddyList?this.m_buddyListW:0,gcb:this.m_groupBuddies,gcq:this.m_mediaPlayer?this.m_mediaPlayer.GetVariable("queueStr"):"",gcmw:this.m_appArea?(!this.isAppAreaVisible()?this.m_lastMediaWidth:this.m_appArea.offsetWidth):0,gcmh:!this.isAppAreaVisible(),fb:this.m_bBold,fi:this.m_bItalics,fu:this.m_bUnderline,fc:this.m_fontColor,ft:this.m_fontType,fs:this.m_fontSize,ml:this.m_mediaList?this.m_mediaList.getMediaList():null,ms:this.m_mediaPlayer?this.m_mediaPlayer.GetVariable("sync"):true,bo:this.m_overlay!=null,isOffline:this.m_bOffline,showRejoinControls:Boolean(this.m_rejoinDiv),guestGroup:this.m_guestGroup,spilloverRoomsGroup:this.m_spilloverRoomsGroup,memberGroup:this.m_memberGroup}
};
this.restoreState=function(b){this.m_history.innerHTML=b.h;
this.m_message.setText(b.m);
setTimeout(hitch(this,function(){this.restoreHistory(b);
this.restoreMessage(b);
this.restoreGroupChat(b);
this.setOffline(b.isOffline);
this.updateTopToolbar();
if(!this.isMeeboGroupChat()&&!gFileTransferId){this.addFileTransferBtn()
}this.recalcLayout();
this.m_isRestoring=false
}),0)
};
this.restoreHistory=function(b){if(b.hb){this.m_history.scrollTop=this.m_history.scrollHeight
}else{this.m_history.scrollTop=b.ht
}this.m_history.scrollLeft=b.hl;
if(!this.isMeeboGroupChat()){this.initBuddyIcon(true);
this.m_buddyIconFloater=getPartFromElement(this.m_history,this.m_id+"floater");
this.m_buddyIcon=getPartFromElement(this.m_history,this.m_id+"container");
this.setIconFromBuddyListBuddy();
this.updateBuddyIconPosition();
this.clipIcon()
}};
this.restoreMessage=function(b){this.setBold(b.fb,true);
this.setItalics(b.fi,true);
this.setUnderline(b.fu,true);
this.m_fontType=b.ft;
this.m_fontSize=b.fs;
this.m_fontColor=b.fc;
this.m_message.setFontFamily(this.m_fontType);
this.m_message.setFontSize(this.m_fontSize);
this.m_message.setFontColor(this.m_fontColor);
this.m_message.getElement().style.height=b.mh+"px"
};
this.restoreGroupChat=function(b){if(!b.gchidden){return
}this.restoreBuddyList(b);
this.restoreMediaChat(b);
if(!b.bo){this.clearOverlay()
}if(b.showRejoinControls){this.showRejoinControls()
}};
this.restoreBuddyList=function(c){if(!this.m_buddyList){this.showGroupChat(c.gcid,true,true)
}else{this.registerGroupChat(c.gcid)
}this.m_trees=c.trees;
var b=this.m_buddyList.getElement();
b.parentNode.insertBefore(c.gc.create(this).getElement(),b);
removeElement(b);
this.m_buddyList=c.gc;
this.m_buddyList.addClassName("ImBuddyList");
this.m_buddyList.setDisplay(true);
this.m_buddyList.getElement().style.width=c.gcw+"px";
this.m_guestGroup=c.guestGroup;
this.m_memberGroup=c.memberGroup;
this.m_spilloverRoomsGroup=c.spilloverRoomsGroup
};
this.restoreMediaChat=function(h){if(!h.ml){return
}this.initMediaPlayer();
this.m_mediaList.restoreMediaList(h.ml);
this.m_bSync=h.ms;
var d=[];
var b=0;
if(h.gcq){var c=h.gcq.split("&");
for(var e=0;
e<c.length;
e++){var g=c[e].split("=");
var f=this.m_mediaList.getMediaItemByUrl(decodeURIComponent(g[1]));
if(f){d.push(f)
}if(f.isSelected){b=e
}}if(d.length){this.queueGroupChatMedia(d,b)
}}this.m_appArea.style.width=h.gcmw;
if(h.gcmh){this.showHideMedia(true)
}};
this.connectTopToolbarEvents=function(){var e=this;
if(this.m_profBtn){var b=false;
var d=this.getYourself();
var c=d&&d.getPresence(this.m_imobject);
var b=c&&c.isOwner();
if(this.m_imobject.getType()=="chat"&&b){this.m_profBtn.addOnMouseUp(hitch(this,function(){gWindowMgr.createRoomCreateDlg({id:getCreateGroupChatDlgId()+"-"+this.m_imobject.getId(),caption:sprintf(gLang.configureMeeboChat,this.m_imobject.getAlias())},this.m_imobject,false);
gNetworkMgr.doUILog(this.control,"room-toptoolbar","configure")
}))
}else{this.m_profBtn.addOnMouseUp(hitch(this,"handleProfileButtonClick"))
}}if(this.m_chatBtn){this.m_chatBtn.addOnMouseUp(hitch(this,"handleChatButtonClick"))
}if(this.m_addBtn){this.m_addBtn.addOnMouseUp(hitch(this,"handleAddButtonClick"))
}if(this.m_inviteBtn){this.m_inviteBtn.addOnMouseUp(hitch(this,"handleInviteButtonClick"))
}if(this.m_embedBtn){this.m_embedBtn.addOnMouseUp(hitch(this,"handleEmbedButtonClick"))
}if(this.m_blockBtn){this.m_blockBtn.addOnMouseUp(hitch(this,"handleBlockButtonClick"))
}if(this.m_groupBtn){this.m_groupBtn.addOnMouseUp(hitch(this,"handleGroupButtonClick"))
}if(this.m_popBtn){this.m_popBtn.addOnMouseUp(hitch(this,"logPopButton"));
this.m_popBtn.addOnMouseUp(hitch(this,"reversePop",null))
}if(this.m_appBtn){this.m_appBtn.addOnMouseUp(hitch(this,"toggleAppArea"))
}if(this.m_videochatBtn){this.m_videochatBtn.addOnMouseUp(hitch(this,function(){var f=meebo.applicationMgr.getApplication(gVideoChatId);
var g=hitch(this,"launchApp",f,true);
var h=this.getApplicationRoom()&&this.getApplicationRoom().getApplication();
if(h&&h.app_id==gVideoChatId){this.toggleAppArea(false)
}else{if(h){meeboApp.Application.checkAppLaunch(false,this,g,null,f)
}else{g()
}}}))
}};
this.initAppList=function(){if(this.m_appList){return
}this.m_appList=new meeboApp.Application.List();
var c=this.m_applicationRoom?this.m_applicationRoom.getApplication():null;
this.m_appList.create(this.getId()+"-applicationList",this.m_appArea,c,this);
this.m_appList.addClassName("appList");
var d=hitch(meeboApp.Application,"checkAppLaunch",false,this,hitch(this,"launchApp"),hitch(this.m_appList,"clearLoading"));
this.m_appList.addOnSelectApp(d);
var b=this.m_win.document.createElement("div");
b.id=this.getId()+"-appBar";
addClassName(b,"appBar");
b.innerHTML='			<div class="favorite" id="'+this.getId()+'-addToFavorites"><img path="app-favorite-no.png"				align="left" png="true">'+gLang.favorite+"</div>";
cacheImgs(b);
this.m_appArea.appendChild(b);
this.m_appBar=new ui.element(b);
this.m_appFavorite=new ui.element($(this.getId()+"-addToFavorites"));
ui.connectEvent($(this.getId()+"-addToFavorites"),"click",this,"toggleFavoriteStatus",false,false)
};
this.toggleFavoriteStatus=function(){var e=this.m_applicationRoom?this.m_applicationRoom.getApplication():null;
if(!e){return
}var c=e.app_id,b=gLogon.getMeeboUser();
if(meebo.applicationMgr.getFavorites()[c]){meebo.applicationMgr.removeFavorite(e.app_id);
var d=sprintf(gLang.removedFromFavorites,e.alias);
this.addHistoryIM(gLang.meeboMessage,d,true,true)
}else{if(b){this.addFavoriteApp(e)
}else{gWindowMgr.createCreateMeeboAccountDlg({},"console-meebome","upsell_meebome.png",hitch(this,"addFavoriteApp",e))
}}return false
};
this.addFavoriteApp=function(c){meebo.applicationMgr.addFavorite(c.app_id);
var b=sprintf(gLang.addedToFavorites,c.alias);
this.addHistoryIM(gLang.meeboMessage,b,true,true)
};
this.updateAppBar=function(){var c=this.m_applicationRoom?this.m_applicationRoom.getApplication():null;
if(!c){return
}var b="app-favorite-no.png";
if(meebo.applicationMgr.getFavorites()[c.app_id]){b="app-favorite-yes.png"
}gImages.requestImage(b,this.m_appFavorite.getElement().getElementsByTagName("img")[0])
};
this.toggleAppList=function(){this.m_appList.toggleDisplay();
var b=this.isAppListVisible();
var c=this.getApplicationRoom().getApplication()
};
this.toggleAppArea=function(g,c){if(this.m_isMorphing){return
}this.clearBuddyIcon();
var f=this.isAppAreaVisible();
if(typeof g!="undefined"&&g==f){return
}if(!this.m_appArea){this.initAppArea();
this.initAppList();
this.m_appArea.style.width="280px"
}var b=this.getWindowPos();
if(f){this.m_appBtn.setDepressed(false);
var e=0;
if(this.m_showGroupChatCallback){if(this.m_buddyList){this.m_buddyList.setDisplay(true);
e+=this.m_buddyList.getPos().w-this.m_vertSliderSize;
this.m_buddyList.setDisplay(false)
}else{e+=this.m_buddyListW
}}if(this.m_toggleDlgStartWidth){this.m_appAreaWidthDelta=b.w-this.m_toggleDlgStartWidth
}else{this.m_appAreaWidthDelta=0;
this.m_toggleDlgStartWidth=b.w-this.m_appArea.offsetWidth-this.m_vertSliderSize-e
}if(this.m_toggleDlgStartHeight){this.m_appAreaHeightDelta=b.h-this.m_toggleDlgStartHeight
}else{this.m_appAreaHeightDelta=0;
this.m_toggleDlgStartHeight=b.h
}this.m_appArea.style.display="none";
this.leaveApp();
gNetworkMgr.doUILog(this.control,"toptoolbar","unapp")
}else{if(this.m_groupBtn){this.m_groupBtn.setDepressed(false)
}this.m_appBtn.setDepressed(true);
var e=this.m_bGroupChatHidden?0:this.m_buddyList.getPos().w-2;
if(!this.m_bGroupChatHidden){this.hideGroupChatFurniture()
}this.m_toggleDlgStartWidth=b.w;
this.m_appArea.style.display="block";
this.m_appAreaWidthDelta=(this.m_appArea.offsetWidth||this.m_minMediaW)+this.m_vertSliderSize-e;
this.m_appArea.style.display="none";
this.m_toggleDlgStartHeight=b.h;
this.m_appAreaHeightDelta=-Math.min(b.h-50-360,0);
gNetworkMgr.doUILog(this.control,"toptoolbar","app")
}this.m_isMorphing=true;
if(!f){this.m_dlgStartX=b.x;
this.m_dlgStartY=b.y
}var d=ui.getClientRect();
this.m_isAppResizeLeft=(f&&this.m_isAppResizeLeft)||(!f&&b.x+b.w+this.m_appAreaWidthDelta>d.w);
this.m_isAppResizeTop=(f&&this.m_isAppResizeTop)||(!f&&b.y+b.h+this.m_appAreaHeightDelta>d.h);
this.m_animationAppArea.onfinished=hitch(this,"onFinishedAppAreaAnimation",!f);
if(c){this.m_animationAppArea.jumpTo(f?0:1)
}else{this.m_animationAppArea.seekTo(f?0:1)
}};
this.animateAppArea=function(g){this.clearBuddyIcon();
var f=(this.isMaximized()||this.isPoppedOut())?-1:1;
var b=this.m_isAppResizeLeft?(this.m_dlgStartX-Math.round(this.m_appAreaWidthDelta*g)):-1;
var e=this.m_isAppResizeTop?(this.m_dlgStartY-Math.round(this.m_appAreaHeightDelta*g)):-1;
var c=this.m_toggleDlgStartWidth+Math.round(this.m_appAreaWidthDelta*g);
var d=this.m_toggleDlgStartHeight+Math.round(this.m_appAreaHeightDelta*g);
this.setWindowPos(b,e,c*f,d*f)
};
this.onFinishedAppAreaAnimation=function(b){this.m_isMorphing=false;
if(b){this.m_appArea.style.display="block";
this.m_appList.setDisplay(true);
this.m_historyMediaSlider.style.display="block";
this.hideAppIFrameOverlay()
}this.recalcLayout();
this.m_minX=this.getMinWidth();
this.m_minY=this.getMinHeight();
if(this.m_showGroupChatCallback){this.m_showGroupChatCallback();
this.m_showGroupChatCallback=null
}else{if(!this.m_bGroupChatHidden){this.setIconFromBuddyListBuddy();
this.recalcLayout();
this.m_bGroupChatHidden=true
}}this.initBuddyIcon();
this.m_popBtn.setDisabled(b||this.m_bOffline);
this.m_appBtn.setDepressed(b)
};
this.initApp=function(f){if(this.m_appFrame||this.m_animationResizeAppArea.isAnimating()){return
}var c=this.isAppAreaVisible();
this.m_appBtn.setDepressed(c);
if(this.m_appLoadingOverlay){this.hideAppLoadingOverlay()
}if(!this.m_appArea){this.initAppArea();
this.m_appArea.style.display="none"
}else{this.m_appList.setDisplay("none");
this.m_appList.onAppLoaded(f)
}var b=this.getWindowPos();
this.m_dlgStartWidth=b.w;
this.m_dlgStartHeight=b.h;
this.m_appAreaStartWidth=c?this.m_appArea.offsetWidth:0;
this.m_appAreaStartHeight=c?this.m_appArea.offsetHeight:b.h-50-this.m_appBarHeight;
if(!c){this.m_toggleDlgStartWidth=b.w;
this.m_toggleDlgStartHeight=b.h
}var e=this.m_bGroupChatHidden?0:this.m_buddyList.getPos().w-2;
if(!this.m_bGroupChatHidden){this.hideGroupChatFurniture()
}var g=this.isAppAreaVisible()?0:this.m_vertSliderSize;
this.m_appAreaStartWidth=e||this.m_appAreaStartWidth;
this.m_appAreaWidthDelta=f.width+2-this.m_appAreaStartWidth;
this.m_appAreaHeightDelta=f.height+2-this.m_appAreaStartHeight+36;
var d=ui.getClientRect();
this.m_dlgStartX=b.x;
this.m_dlgStartY=b.y;
this.m_isAppResizeLeft=(b.x+b.w+this.m_appAreaWidthDelta>d.w);
this.m_isAppResizeTop=(b.y+b.h+this.m_appAreaHeightDelta>d.h);
this.m_isMorphing=true;
this.m_appArea.style.display="none";
this.m_animationResizeAppArea.onfinished=hitch(this,"onFinishedResizeAppAreaAnimation",f);
if(!this.isMaximized()&&this.isPoppedOut()){this.m_animationResizeAppArea.seekFromTo(0,1)
}else{if(!this.m_appAreaWidthDelta&&!this.m_appAreaHeightDelta){this.onFinishedResizeAppAreaAnimation(f)
}else{this.m_animationResizeAppArea.seekFromTo(0,1)
}}};
this.animateResizeAppArea=function(g){this.clearBuddyIcon();
var c=this.m_isAppResizeLeft?(this.m_dlgStartX-Math.round(this.m_appAreaWidthDelta*g)):-1;
var f=this.m_isAppResizeTop?(this.m_dlgStartY-Math.round(this.m_appAreaHeightDelta*g)):-1;
var e=Math.round(this.m_appAreaWidthDelta*g);
var b=Math.round(this.m_appAreaHeightDelta*g);
var d=(!this.isMaximized()&&!this.isPoppedOut());
if(d){this.setWindowPos(c,f,this.m_dlgStartWidth+e,this.m_dlgStartHeight+b)
}this.m_appArea.style.width=(this.m_appAreaStartWidth+e)+"px";
if(d){this.m_appArea.style.height=(this.m_appAreaStartHeight+b)+"px"
}};
this.onFinishedResizeAppAreaAnimation=function(h){this.m_isAppResizeLeft=this.m_isAppResizeTop=false;
this.m_appArea.style.display="block";
this.m_historyMediaSlider.style.display="block";
if(!this.m_bGroupChatHidden){this.setIconFromBuddyListBuddy();
this.m_bGroupChatHidden=true
}this.m_isMorphing=false;
this.m_minX=this.getMinWidth();
if(!this.m_appList){this.initAppList()
}var g=null,e=null;
if(!this.isFlashInstalled()){var c=util.flash.getVersion().major;
g=c?sprintf(gLang.flashOldApps,c,h.alias,this.m_installFlashLink,"</a>"):sprintf(gLang.flashRequiredToViewApps,h.alias,this.m_installFlashLink,"</a>")
}else{g=gLang.pleaseWaitWhileWeLoad;
e="'"+h.alias+"'"
}this.initAppLoadingOverlay(g,e,!this.isFlashInstalled(),h);
for(var b=0;
b<this.m_acceptAppLinks.length;
b++){setText(this.m_acceptAppLinks[b].getElement(),gLang.appRunning)
}this.m_acceptAppLinks={};
this.m_appArea.style.display="block";
this.clearBuddyIcon();
var d=this.getApplicationRoom();
if(d&&this.isFlashInstalled()){h.app_instance_id=d.getChatName();
var f=h.createIframe({height:this.m_appArea.offsetHeight-this.m_appBarHeight+"px",width:"100%",joinParams:d.getJoinParams()});
this.m_appArea.insertBefore(f,this.m_appArea.firstChild);
this.m_appFrame=new ui.element(f);
if(!gIsGuestGroupChat){this.updateAppBar();
this.m_appBar.setDisplay("block")
}this.m_minY=this.getMinHeight()
}this.recalcLayout();
this.updateTopToolbar()
};
this.initAppLoadingOverlay=function(d,c,g,h){var k=getUniqueId();
if(!this.m_appLoadingOverlay){var b=this.m_win.document.createElement("div");
b.id=k+"-appLoadingOverlay";
addClassName(b,"appLoadingOverlay");
this.m_appArea.appendChild(b);
this.m_appLoadingOverlay=new ui.element(b)
}else{removeChildren(this.m_appLoadingOverlay.getElement())
}var e=this.m_win.document.createElement("div");
addClassName(e,"msg");
if(g){addClassName(e,"error")
}else{removeClassName(e,"error")
}if(!h){h=this.m_applicationRoom.getApplication()
}var f='<img src="'+h.icon_location+'" class="appImg">';
if(d){f+='<div class="msgLine1">'+d+"</div>"
}if(c){f+='<div class="msgLine2">'+c+"</div>"
}e.innerHTML=f;
this.m_appLoadingOverlay.getElement().appendChild(e);
e.style.marginLeft="-"+Math.round(e.offsetWidth/2)+"px";
e.style.marginTop="-"+Math.round(e.offsetHeight/2)+"px";
e.style.visibility="visible";
disableSelection(this.m_appLoadingOverlay.getElement(),true)
};
this.hideAppLoadingOverlay=function(){if(this.m_appLoadingTimeoutId){clearTimeout(this.m_appLoadingTimeoutId);
this.m_appLoadingTimeoutId=null
}if(this.m_appLoadingOverlay){removeElement(this.m_appLoadingOverlay.getElement())
}this.m_appLoadingOverlay=null
};
this.leaveApp=function(){if(this.m_appFrame){var c=this.m_appFrame.getElement();
if(c){var d=c.firstChild;
if(d){d.setAttribute("src","about:blank");
d=null
}}removeElement(this.m_appFrame.getElement());
this.m_appFrame=null
}this.m_appList.onAppUnloaded();
this.hideAppLoadingOverlay();
this.m_appArea.style.width=this.m_appAreaW+"px";
this.m_appBar.setDisplay("none");
var b=this.m_applicationRoom;
if(!b){return
}if(b.getChatId()){gNetworkMgr.requestChatAction(null,"l",null,b,b.getChatId(),null);
gWindowMgr.unregisterGroupChat(getGroupChatId(b.getProtocol(),b.getUser(),b.getChatId()))
}if(!meeboApp.platform.isRegistered(b.getChatName())){gNetworkMgr.doUILog(this.control,"app-error",this.getApplicationId(),true)
}meeboApp.platform.removeApp(b.getChatName());
this.setApplicationRoom(null);
this.m_buddy=null;
this.addHistoryIM(gLang.meeboMessage,gLang.youLeftTheApp,true,true);
this.updateTopToolbar(true)
};
this.isAppMode=function(){return this.m_appList&&this.isAppAreaVisible()
};
this.launchApp=function(e,c){if(this.getApplicationRoom()){this.toggleAppArea(false,true)
}if(c){this.initApp(e)
}if(!this.m_applicationRoom){var g=this.m_imobject;
var b=this.getImObject().getLogin().getAlias()
}else{var g=[];
var f=this.m_applicationRoom.getPresences();
for(presenceId in f){var d=f[presenceId].getBuddy();
if(d.isYourself()){b=f[presenceId].getAlias();
continue
}g.push(d)
}}meeboApp.Application.launchApp(e,b,this,g)
};
this.makeApp=function(){var b=this.getApplicationRoom();
if(b&&this.m_imobject==b){return
}this.setImObject(b);
this.registerGroupChat(b.getChatId());
this.setId(getIMId(b.getName(),b.getLogin()));
this.updateIMStatus();
this.setWindowCaption();
this.clearBuddyIcon();
this.updateTopToolbar()
};
this.onReceiveAppIMMsg=function(c,b,d){this.addHistoryIM(c.getApplication().alias,d,true)
};
this.onAbandonedApp=function(d,b){this.addHistoryIM(gLang.meeboMessage,gLang.partyHasLeft,true,true);
for(var c=0;
c<this.m_acceptAppLinks.length;
c++){setText(this.m_acceptAppLinks[c].getElement(),"")
}};
this.logPopButton=function(){gNetworkMgr.doUILog(this.control,(this.isMeeboGroupChat()?"room-":"")+"toptoolbar",this.isPoppedOut()?"unpop":"pop")
};
this.showReconnectDlg=function(){var b=ui.getClientRect(document);
return gWindowMgr.createReconnectDlg({},gLang.logoffStatus+"<br><br>"+gLang.reconnectPrompt)
};
this.getMaxMessageHeight=function(c){var b=this.m_message.getElement();
c-=this.m_fontbar.getElement().offsetHeight;
c-=this.m_sliderTop.offsetHeight;
c-=this.m_sliderBottom.offsetHeight;
c-=this.m_contentHeight-b.offsetTop-b.offsetHeight;
c-=this.m_minHistoryH;
c-=this.m_topToolbarH;
return c
};
this.getMinWidth=function(){var e=parseInt(getCSSProp(this.getBody(),"left"));
var b=this.m_minHistoryW+e+e;
if((this.isMeeboGroupChat()&&!this.m_applicationRoom)||!this.m_bGroupChatHidden){var c=0;
if(this.isMeeboGroupChat()){var c=!this.isAppAreaVisible()?0:(this.m_minMediaW+this.m_vertSliderSize)
}var f=this.m_buddyList?this.m_buddyList.getPos().w:0;
b+=c+f+2+this.m_vertSliderSize
}if(this.isAppMode()){var d=this.m_appArea.offsetWidth;
if(this.m_applicationRoom){d=Math.max(d,this.m_applicationRoom.getApplication().width)
}b+=d+this.m_vertSliderSize+2
}return b
};
this.getMinHeight=function(){if(this.isAppMode()&&this.m_applicationRoom){var e=this.m_applicationRoom.getApplication().height
}var c=this.m_message.getElement();
var d=this.m_minMessageH+this.m_minHistoryH;
d+=this.m_sliderTop.offsetHeight;
d+=this.m_sliderBottom.offsetHeight;
d+=this.m_fontbar.getElement().offsetHeight;
var b=this.getBody();
this.m_contentHeight=b.offsetHeight;
d+=this.m_contentHeight-c.offsetTop-c.offsetHeight;
if(e&&e>d){d=e-3
}d+=this.m_marginH;
d+=this.isMeeboGroupChat()?this.m_chatInfoH:this.m_topToolbarH;
d+=this.m_statusH;
d+=3;
return d
};
this.isHistoryAtBottom=function(){return(this.m_history.scrollTop+this.m_history.clientHeight+2>=this.m_history.scrollHeight)
};
this.onStartResize=function(){this.m_bHistoryAtBottom=this.isHistoryAtBottom()
};
this.onStopResize=function(){if(this.m_bHistoryAtBottom){this.m_history.scrollTop=this.m_history.scrollHeight
}this.focusOnMessage();
this.updateBuddyIconPosition(this.isHistoryAtBottom());
if(!this.m_isMorphing){this.m_toggleDlgStartHeight=0;
this.m_toggleDlgStartWidth=0
}};
this.onStopMove=function(){this.m_isAppResizeLeft=this.m_isAppResizeTop=false
};
this.moveBuddy=function(c){if(!this.m_buddyList){return
}if(c.isPending()&&this.m_temporaryRows[c.getBuddy().getId()]){return
}var b=this.m_trees[c.getBuddy().getId()];
if(!b){return
}var d=b.getParent();
var e;
if(!c.isOnline()){this.removePresence(c)
}else{if(c.isMember()){e=this.m_memberGroup
}else{e=this.m_guestGroup
}b.setNewParent(e);
e.setDisplay(true);
this.updateRow(b);
if(d!=e){this.showBuddyChangeStatusFeedback(c.getBuddy())
}}if(d&&!d.hasChildren()){d.setDisplay(false)
}};
this.setBuddyOnline=function(d,e){var b=this.isGroupChat()?this.m_imobject:this.m_applicationRoom;
var c=d.getPresence(b);
if(!c){return
}var f=this.m_trees[c.getBuddy().getId()];
if(!f){return
}if(e){this.moveBuddy(c)
}else{if(c.isMember()){this.moveBuddy(c)
}else{this.removePresence(c);
this.m_guestGroup.setDisplay(this.m_guestGroup.hasChildren())
}}};
this.clearHistory=function(){this.m_pendingMedia={};
this.m_loadedMedia={};
if(this.m_buddyIcon){this.m_history.removeChild(this.m_buddyIcon)
}while(this.m_history.childNodes.length){this.m_history.removeChild(this.m_history.firstChild)
}if(this.m_buddyIcon){this.m_history.appendChild(this.m_buddyIcon)
}};
this.clearMediaList=function(){if(!this.m_mediaList){return
}while(this.m_mediaList.getNumMediaItems()){this.m_mediaList.deleteMediaItemByIdx(0)
}if(this.m_mediaHelp){removeChildren(this.m_mediaHelp)
}};
this.clearBuddyList=function(){if(!this.m_buddyList){return
}var c=this.m_imobject;
var d=c.getPresences();
for(var b in d){this.removePresence(d[b])
}this.m_guestGroup.setDisplay(false);
this.m_memberGroup.setDisplay(false);
this.m_spilloverRoomsGroup.setDisplay(false)
};
this.registerGroupChat=function(e){if(!e||this.m_groupChatId==e){return
}if(!this.isMeeboGroupChat()){if(this.m_imobject.getType()=="buddy"){var d=gBuddyList.addProtocolChat(this.m_imobject.getName(),e,null,this.m_imobject.getLogin());
this.setImObject(d)
}var b=getGroupChatId(this.m_imobject.getProtocol(),this.m_imobject.getUser(),e);
gWindowMgr.registerGroupChat(b,this);
this.setId(b)
}this.m_groupChatId=e;
for(var c in this.m_temporaryRows){this.updateRow(this.m_trees[c],true)
}if(!this.isMeeboGroupChat()){this.updateIMStatus();
this.updateTopToolbar()
}};
this.showBuddyChangeStatusFeedback=function(d){var b=this.m_imobject;
var c=d.getPresence(b);
var f=this.m_trees[d.getId()];
if(!f){return
}f.updateFont(true);
var e=setTimeout(hitch(this,function(){delete this.m_buddyBoldId[e];
f.updateFont(false)
}),5000);
this.m_buddyBoldId[e]=e
};
this.updateRow=function(d,c){if(!d){return
}var b=d.getPresence();
if(b.isPending()!=c){d.setPending(c);
if(!c){d.setDisplay(true)
}}if(d.getDisplay()!="block"){d.setDisplay(true)
}d.setText(b.getAlias());
d.updateImage();
d.updateFont();
d.updateBadgeImage();
d.getParent().sort()
};
this.getYourself=function(){if(this.m_imobject.getType()=="buddy"){return
}var d=this.m_imobject.getPresences();
for(var b in d){var c=d[b].getBuddy();
if(c.isYourself()){return c
}}};
this.addBuddy=function(f,b){if(!f){return
}var p=this.m_imobject;
if(p.getPresences){var c=p.getPresences()[f.getId()];
if(c&&this.m_trees[f.getId()]&&!this.m_temporaryRows[f.getId()]){this.moveBuddy(c);
return c
}}if(!this.m_buddyList){this.initBuddyList()
}var c;
if(p.getType()=="buddy"){if(this.m_temporaryRows[f.getId()]||this.m_applicationRoom){return
}var c=new meebo.Presence(f);
c.setOnline(true);
this.m_temporaryRows[f.getId()]=c
}else{if((c=this.m_temporaryRows[f.getId()])){var o=this.m_trees[f.getId()];
if(o.getParent()){o.getParent().deleteItem(o)
}delete this.m_temporaryRows[f.getId()]
}var c=f.getPresence(p);
if(f.isYourself()){c.setOnline(true)
}if(this.isMeeboGroupChat()&&!c.isOnline()){var d=c.getAlias();
var g=d.indexOf("@");
if(g!=-1){c.setAlias(d.substr(0,g))
}}var h=p.getPresences();
var l=this.m_imobject.getProtocol().isJabberBased();
for(var m in h){var e=h[m];
if(c==e){continue
}if(e.getAlias()==c.getAlias()){if((!l||!e.isOnline())&&this.m_trees[m]){this.m_trees[m].setText(e.getBuddy().getName())
}if(!l||!c.isOnline()){c.setAlias(f.getName())
}}}}if(p.getType()=="chat"){gPubSub.subscribe(c,"meebo.Presence::changeAlias",this,"onPresenceChangeAlias");
gPubSub.subscribe(c,"meebo.Presence::changeOwner",this,"onPresenceChangeModerator");
gPubSub.subscribe(c,"meebo.Presence::changeSubModerator",this,"onPresenceChangeModerator")
}if((!c.isOnline()&&!b)||this.m_applicationRoom){return
}var n=this.getCachedRow();
if(!n){var n=new meeboApp.groupChatRow(f,c);
n.create(this.m_win)
}else{n.setExtra(f,c)
}n.setPending(b);
this.m_trees[f.getId()]=n;
if(p.getType()!="buddy"){this.showBuddyChangeStatusFeedback(f)
}this.connectRowEvents(n);
var k=c.isMember()?this.m_memberGroup:this.m_guestGroup;
k.insertItem(n);
k.setDisplay(true);
this.m_buddyList.redrawChildren()
};
this.connectRowEvents=function(c){var b=c.m_extra;
c.unsubscribe("MouseOver");
c.subscribe("MouseOver",this,function(){if(this.isPoppedOut()||this.m_bRenamingBuddy||(this.m_groupContextMenu&&this.m_groupContextMenu.isOpen())){return
}gInfoDlg.setTreeWithHover(c)
});
c.unsubscribe("MouseOut");
c.subscribe("MouseOut",gInfoDlg,"clearTreeWithHover");
c.unsubscribe("ContextMenu");
c.subscribe("ContextMenu",this,hitch(this,function(e,d){gInfoDlg.hideInfo();
this.onContextMenuShow(e,d)
}));
c.unsubscribe("Activate");
c.subscribe("Activate",this,function(){gInfoDlg.hideInfo();
if(!b.isOnlist()&&this.isGroupChat()&&!b.isYourself()){b.setAlias(b.getPresence(this.m_imobject).getAlias())
}gWindowMgr.createIMWindow(b,true)
})
};
this.clearBuddyIcon=function(){if(!this.m_buddyIconFloater){return
}var b=this.isHistoryAtBottom();
this.updateBuddyIcon("");
this.m_buddyIconFloater.style.width="0px";
this.m_buddyIconFloater.style.height="0px";
this.m_buddyIcon.style.width="0px";
this.m_buddyIcon.style.height="0px";
this.m_buddyIconSrc="";
if(b){setTimeout(hitch(this,"scrollHistoryToBottom"),0)
}};
this.toggleBuddyList=function(d,c){if(this.m_isMorphing){return
}this.clearBuddyIcon();
var e=this.isBuddyListVisible();
var b=this.getWindowPos();
if(this.m_buddyList){this.m_buddyList.setDisplay(true)
}this.m_buddyListWidthDelta=this.m_vertSliderSize+(this.m_buddyList?this.m_buddyList.getPos().w:this.m_buddyListW+2);
if(this.m_buddyList){this.m_buddyList.setDisplay(false)
}if(c){this.m_buddyListWidthDelta=0
}if(e){this.m_toggleDlgStartWidth=b.w-this.m_buddyListWidthDelta
}else{if(this.m_appBtn){this.m_appBtn.setDepressed(false)
}this.m_toggleDlgStartWidth=b.w
}if(this.m_inviteMenu){this.m_inviteMenu.setDisplay(false)
}this.m_isMorphing=true;
this.m_bGroupChatHidden=e;
this.m_animationBuddyListArea.onfinished=hitch(this,"onFinishedResizeBuddyListArea",!e);
if(d){this.m_animationBuddyListArea.jumpTo(e?0:1)
}else{this.m_animationBuddyListArea.seekTo(e?0:1)
}};
this.animateBuddyList=function(d){var c=(this.isMaximized()||this.isPoppedOut())?-1:1;
var b=this.m_toggleDlgStartWidth+Math.round(this.m_buddyListWidthDelta*d);
this.setWindowPos(-1,-1,b*c,-1)
};
this.onFinishedResizeBuddyListArea=function(b){this.m_isMorphing=false;
if(!this.m_buddyList){this.initBuddyList()
}if(!this.m_buddyListSlider){this.initBuddyListSlider()
}if(!this.m_inviteMenu){this.initInviteMenu()
}this.m_buddyList.setDisplay(b);
this.m_buddyListSlider.style.display=(b?"block":"none");
this.m_inviteMenu.setDisplay(b);
this.m_minX=this.getMinWidth();
this.recalcLayout();
this.initBuddyIcon();
if(this.m_groupBtn){this.m_groupBtn.setDepressed(b)
}};
this.showGroupChat=function(c,d,b){if(!this.m_bGroupChatHidden||this.m_isMorphing){return
}if(this.m_animationAppArea.isAnimating()||this.m_animationResizeAppArea.isAnimating()){return
}var f=this.getWindowPos();
var e=0;
if(c){this.registerGroupChat(c)
}this.clearBuddyIcon();
if(this.m_appArea&&this.m_appArea.style.display&&this.m_appArea.style.display=="block"){this.m_showGroupChatCallback=hitch(this,"onFinishShowGroupChat");
this.toggleAppArea();
return
}if(this.m_buddyList&&!this.m_bGroupChatHidden&&!this.m_isMorphing){return
}if(this.m_bGroupChatHidden&&this.m_isMorphing){return
}this.toggleBuddyList(d,b)
};
this.hideGroupChat=function(b){if(this.m_isMorphing||!this.m_buddyList||!this.m_inviteMenu){return
}this.toggleBuddyList(b)
};
this.onFinishShowGroupChat=function(){this.initGroupChat()
};
this.onInvite=function(){if(this.m_bGroupChatOffline){this.resetInviteMenu();
return
}if(gEventMgr.getState()=="done"){this.resetInviteMenu();
return this.showReconnectDlg()
}var d=this.m_inviteMenu.getItemValue();
var c,e,b;
if(typeof d=="string"){d=meebo.util.normalizeLogon(d,this.m_imobject.getNetwork()).name;
d=gBuddyList.addBuddy(d,this.m_imobject.getLogin())
}c=d.getName();
e=d.getAlias();
b=d.getUser();
if(this.isMeeboGroupChat()){if(typeof d!="string"){this.invite(d)
}this.resetInviteMenu();
return
}if(!c){this.resetInviteMenu();
return
}if(d.getProtocol().isJabberBased()&&!isEmail(c)){this.resetInviteMenu();
gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.addErrorHeader,parent:this},sprintf(gLang.addError,c)+gLang.noBrEmail);
return
}if(this.addInvite(d)){var f=this.isGroupChat()&&this.m_imobject.getChatId();
gNetworkMgr.requestChatAction(null,"i",normalizeString(c),this.m_imobject,f,gLang.joinChatUpsell,f?null:normalizeString(this.m_imobject.getName()))
}this.resetInviteMenu()
};
this.resetInviteMenu=function(){if(!this.m_inviteMenu){return
}this.m_inviteMenu.setTitle(gLang.inviteBuddy,null,true);
this.m_inviteMenu.setImage(null,null,null);
this.m_inviteMenu.m_element.style.color="#677788"
};
this.addInvite=function(c){var b=this.m_imobject;
if(b.getProtocol()=="aim"&&meebo.util.isICQ(c.getName())){this.resetInviteMenu();
gWindowMgr.createNotifyDlg({id:getUniqueId()+"icqnotify",caption:gLang.chatTT},gLang.noICQGroupChat);
return false
}if(this.m_temporaryRows[c.getId()]){this.m_temporaryRows[c.getId()].setPending(true);
return true
}if(b.getType()!="buddy"&&c.getPresence(b).isOnline()){return false
}this.addBuddy(c,true);
return true
};
this.initGroupChat=function(){if(!this.m_buddyList){this.initBuddyList()
}if(!this.m_buddyListSlider){this.initBuddyListSlider()
}this.m_buddyList.setDisplay(true);
this.m_buddyList.getElement().style.width=this.m_buddyListW+"px";
this.m_buddyListSlider.style.display="block";
this.m_isMorphing=false;
if(!this.isMeeboGroupChat()){if(!this.m_inviteMenu){this.initInviteMenu()
}else{this.m_inviteMenu.setDisplay(true)
}}else{this.m_statusH=19;
this.initAppArea();
this.initHistoryMediaSliderThumbie();
this.initChatInfo();
var b=gPrefs.getRoomPref(this.m_imobject.getChatName(),"mediaHidden",false);
if(this.isAppAreaVisible()==b){this.showHideMedia(true)
}}this.m_bGroupChatHidden=false;
if(this.isMeeboGroupChat()&&!this.m_imobject.getChatId()){this.initOverlay();
this.showOverlayMessage()
}this.recalcLayout()
};
this.initContextMenu=function(){this.m_groupContextMenu=new ui.contextmenu();
this.m_groupContextMenu.init(getUniqueId()+"groupmenu",110,this.m_win.document);
this.m_groupContextMenu.addSelectFunc(hitch(this,"onContextSelect"))
};
this.onContextSelect=function(m,o){if(gEventMgr.getState()=="done"){var h=gWindowMgr.createReconnectDlg({},gLang.logoffStatus+"<br><br>"+gLang.reconnectPrompt);
return
}var p=this.m_groupContextMenu.getContextObject();
var g=p.getExtra();
if(!p||!g.getName()){return
}switch(o){case"hide":p.setDisplay(false);
break;
case"reinvite":this.invite(g,true);
p.setPending(true);
break;
case"message":if(!g.isOnlist()){g.setAlias(g.getPresence(this.m_imobject).getAlias())
}gWindowMgr.createIMWindow(g,true);
break;
case"profile":gWindowMgr.createProfileDlg({id:getProfileId(g),caption:g.getAlias(),parent:this},g);
break;
case"mute":var c=g.getPresence(this.m_imobject);
c.setMuted(!c.isMuted());
p.updateBadgeImage();
break;
case"alias":var l=hitch(this,function(q,u){this.m_bRenamingBuddy=false;
if(u==null){return
}var t=stripWhitespace(u);
var d=q.getPresence().getAlias();
if(t==d){return
}var s=this.m_imobject.getLogin();
s.setUserSpecifiedAlias(true);
gNetworkMgr.requestChatAction(null,"n",null,this.m_imobject,this.m_imobject.getChatId(),d,t)
});
var f=p.getPresence().getAlias();
p.showEditInput(l,f);
this.m_bRenamingBuddy=true;
break;
case"ban":var e=g.getPresence(this.m_imobject).getAlias();
gWindowMgr.createOkDlg({id:this.getId()+"-banBuddy",caption:gLang.banBuddy,parent:this},sprintf(gLang.confirmBanBuddy,e,this.m_imobject.getAlias()),hitch(this,"banBuddy",g),null,gLang.banBuddy,gLang.cancelTT);
break;
case"warn":var e=g.getPresence(this.m_imobject).getAlias();
var k=this.m_imobject.getYourself().getBuddy();
var n=k.getRemainingWarns();
if(!gNotice.canWarn(this.m_imobject.getName(),String(this.m_imobject.getName()+"/"+e))){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.cantWarnHeader,parent:this},gLang.youHaveAlreadyWarned);
break
}if(n==0){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.cantWarnHeader,parent:this},gLang.noWarnsRemaining);
break
}var b;
if(n==1){b=sprintf(gLang.confirmWarnBuddyWithCount,e)
}else{b=sprintf(gLang.confirmWarnBuddyWithCountPlural,e,n)
}gWindowMgr.createOkDlg({id:this.getId()+"-warnBuddy",caption:gLang.warnBuddy,parent:this},b,hitch(this,"warnBuddy",g),null,gLang.warnBuddy,gLang.cancelTT);
break;
case"addmod":var e=g.getPresence(this.m_imobject).getAlias();
gWindowMgr.createOkDlg({id:this.getId()+"-addModerator",caption:gLang.addModerator,parent:this},sprintf(gLang.confirmAddModerator,e,this.m_imobject.getAlias()),hitch(this,"addModerator",g),null,gLang.addModerator,gLang.cancelTT);
break;
case"delmod":var e=g.getPresence(this.m_imobject).getAlias();
gWindowMgr.createOkDlg({id:this.getId()+"-removeModerator",caption:gLang.removeModerator,parent:this},sprintf(gLang.confirmRemoveModerator,e,this.m_imobject.getAlias()),hitch(this,"deleteModerator",g),null,gLang.removeModerator,gLang.cancelTT);
break
}if(this.isMeeboGroupChat()){gNetworkMgr.doUILog(this.control,"room-context",o)
}};
this.onContextMenuShow=function(m,k){var c=this.m_groupContextMenu;
if(!c){return
}if(!m.getPresence().isOnline()&&!m.getPresence().isPending()){ui.setEventHandled(k);
return
}c.removeAllItems();
var h=m.getExtra().isYourself();
var b=false;
var l=false;
var e=true;
var f=this.isFlashInstalled();
var d=this.getYourself();
if(d){b=d.getPresence(this.m_imobject).isOwner();
l=d.getPresence(this.m_imobject).isSubModerator();
e=d.isGuestUser()
}var g=(this.m_imobject.getType()=="protocolchat"||this.m_imobject.getType()=="buddy");
if(h&&!g){c.addMenuItem(gLang.setNickname,null,"alias")
}if((!h&&this.isGroupChat())||g){c.addMenuItem(sprintf(gLang.imName,""),null,"message")
}if((b||l)&&!h&&!g&&!m.isPending()&&!m.getPresence().isOwner()&&!m.getPresence().isSubModerator()){c.addMenuItem(gLang.ban,null,"ban")
}if(b&&!h&&!g&&!m.isPending()&&m.getExtra().isMeeboUser()){if(m.getPresence().isSubModerator()){c.addMenuItem(gLang.removeModerator,null,"delmod")
}else{c.addMenuItem(gLang.addModerator,null,"addmod")
}}if(f&&!h&&!g&&!m.isPending()&&!m.getPresence().isOwner()&&!m.getPresence().isSubModerator()){if(gNotice.m_isReady){c.addMenuItem(gLang.warn,null,"warn")
}}if(!h&&m.isPending()){c.addMenuItem(sprintf(gLang.reinviteBuddyContext,""),null,"reinvite");
c.addMenuItem(sprintf(gLang.hideBuddyContext,""),null,"hide")
}if(g){c.addMenuItem(gLang.viewProfile,null,"profile")
}if(!h&&!g){c.addMenuItem(m.getPresence().isMuted()?gLang.unmute:gLang.mute,null,"mute")
}ui.setEventHandled(k);
c.showMenu(k,m)
};
this.initInviteMenu=function(){if(this.isMeeboGroupChat()){return
}if(this.m_inviteMenu){return
}var c=this.m_buddyListW+2;
this.m_inviteMenu=new ui.menuheader("invitebuddychat"+getUniqueId(),gLang.inviteBuddy,c,c,"left",18);
this.m_inviteMenu.setDelayMenu(true);
this.m_inviteMenu.setCustomize(true);
this.m_inviteMenu.create(this.m_win);
this.getBody().appendChild(this.m_inviteMenu.getElement());
var b=gBuddyList.getBuddies({protocol:this.m_imobject.getProtocol(),user:this.m_imobject.getUser()}).toArray();
b.sort(sortBuddies);
for(var h=0;
h<b.length;
h++){var k=b[h];
if(!k||k.getType()!="buddy"){continue
}if((k.getProtocol()=="aim")&&meebo.util.isICQ(k.getName())){continue
}var f=normalizeString(k.getName());
var l=k.getAlias();
if(k.getAlias()!=k.getName()){l+=" ("+k.getName()+")"
}var g=meeboApp.util.protocol.getBuddyProtocolIcon(k);
this.m_inviteMenu.addMenuItem(l,g,k,this.m_inviteMenu.m_rowHeight)
}this.m_inviteMenu.addSelectFunc(hitch(this,"onInvite"));
this.m_inviteMenu.addClassName("ImGroupInvite");
this.resetInviteMenu();
if(this.isProtocolGroupChat()){return
}var k=this.m_imobject;
var d=!this.m_guestGroup.hasChildren()||this.m_imobject.getProtocol()!="jabber";
if(d){var e=gBuddyList.addBuddy(k.getUser(),k.getLogin());
e.setOnline(true);
e.setAlias(k.getLogin().getAlias());
e.setYourself(true);
this.addBuddy(e);
if(!k.isYourself()){this.addBuddy(k)
}}};
this.initHistoryMediaSlider=function(){this.m_historyMediaSlider=this.m_win.document.createElement("div");
addClassName(this.m_historyMediaSlider,this.m_appArea?"appSlider":"historySlider");
ui.connectEvent(this.m_historyMediaSlider,"mousedown",this,"onHistoryMediaSliderDrag",true,true);
this.m_historyMediaSlider=this.getBody().appendChild(this.m_historyMediaSlider)
};
this.initHistoryMediaSliderThumbie=function(){this.m_historyMediaSliderImage=createImg(getUniqueId(),this.m_historyMediaSlider,4,60,"right.gif","",true);
addClassName(this.m_historyMediaSliderImage,"historySliderImage");
this.m_historyMediaSlider.appendChild(this.m_historyMediaSliderImage)
};
this.initMediaHelpText=function(e,d,b){removeChildren(this.m_mediaHelp);
var c=this.m_appArea.offsetWidth;
this.m_mediaHelpText=new ui.label();
this.m_mediaHelpText.create(getUniqueId(),this.m_mediaHelp,d);
this.m_mediaHelpText.addClassName("ImMediaHelpText");
this.m_mediaHelpText.setText(unescapeHTML(e));
if(b&&this.isMediaFlaggable()){this.m_mediaFlag=this.m_win.document.createElement("div");
addClassName(this.m_mediaFlag,"ImMediaHelpInappropriate");
this.m_mediaFlag.innerHTML='<a href="javascript:void(0)"><img				path="media_banned_small.gif" border=0 align=top></a>';
this.m_mediaHelp.appendChild(this.m_mediaFlag);
c-=this.m_mediaFlag.offsetWidth-10;
cacheImgs(this.m_mediaHelp)
}this.m_mediaHelpText.setPosition(null,null,c,null)
};
this.initMediaHelpTextItemUrl=function(c){var d=this.m_mediaList.getMediaItemByUrl(c);
if(d.description){this.initMediaHelpText(d.description,"groupchat_"+d.type+".gif",!d.isDefaultMedia)
}else{this.initMediaHelpText(c,"groupchat_"+d.type+".gif",!d.isDefaultMedia)
}if(this.m_mediaFlag){var b=this.m_mediaFlag.getElementsByTagName("a");
ui.connectEvent(b[0],"click",this,"onClickRemove",false,false,c)
}};
this.onClickRemove=function(b){gWindowMgr.createOkDlg({id:this.getId()+"-removeMedia",caption:capitalize(gLang.removeMedia),parent:this},gLang.confirmRemoveMedia,hitch(this,"deleteMediaItem",b),null,gLang.removeBtn,gLang.cancelTT);
return false
};
this.deleteMediaItem=function(b){if(this.m_mediaPlayer){this.m_mediaPlayer.SetVariable("inappropriate",b)
}this.m_mediaList.deleteMediaItemByUrl(b);
this.m_bannedMedia[b]=true;
var d=[];
if(this.m_pendingMedia[b]){d=d.concat(this.m_pendingMedia[b])
}if(this.m_loadedMedia[b]){d=d.concat(this.m_loadedMedia[b])
}for(var c=0;
c<d.length;
c++){d[c].innerHTML=this.getDeletedMediaBarHTML();
cacheImgs(d[c])
}this.initMediaHelpText(!this.m_imobject.isModeratedUrls()?gLang.pasteAURLInConv:"");
gNetworkMgr.requestInappropriate(b,this.m_imobject.getName(),null)
};
this.initAppArea=function(){if(this.m_appArea){return
}this.m_appArea=this.m_win.document.createElement("div");
this.getBody().appendChild(this.m_appArea);
this.m_appArea.style.top=this.m_history.style.top;
this.m_appArea.style.width=this.m_appAreaW+"px";
this.m_appArea.id="media";
addClassName(this.m_appArea,"ImMedia");
this.initHistoryMediaSlider()
};
this.initMediaPlayer=function(){if(this.m_mediaList){return
}this.m_minY+=(this.m_minGroupChatHistoryH-this.m_minHistoryH);
this.m_mediaHelp=this.m_appArea.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_mediaHelp,"ImMediaHelp");
this.m_mediaList=new meeboApp.mediaList();
this.m_mediaList.create(getUniqueId()+"mediaList",this.m_appArea);
this.m_mediaList.addClassName("ImMediaList");
this.addMediaButton();
if(this.isFlashInstalled()){this.m_mediaList.addOnMediaChange(hitch(this,function(d){if(d.isSelected){return
}if(!this.m_bAdShowing){this.initMediaHelpTextItemUrl(d.itemUrl)
}this.m_mediaList.selectItem(d.itemUrl);
this.setGroupChatMedia(d);
var c=d.type+"-mediaBar";
if(!this.m_clickedMedia[c]){this.m_clickedMedia[c]=1
}else{this.m_clickedMedia[c]++
}}))
}this.m_mediaContainer=this.m_win.document.createElement("div");
this.m_mediaContainer.className="ImMediaContainer";
this.m_mediaContainer=this.m_appArea.appendChild(this.m_mediaContainer);
if(!this.isFlashInstalled()){var b=this.m_win.document.createElement("div");
b.innerHTML="*** "+(util.flash.getVersion().major?sprintf(gLang.flashOld,gFlashVersion.major,this.m_installFlashLink,"</a>"):sprintf(gLang.flashRequiredToView,this.m_installFlashLink,"</a>"))+" ***";
addClassName(b,"ImInstallFlash");
this.m_mediaContainer.appendChild(b)
}this.recalcLayout()
};
this.handleSync=function(e,b,d,c){if(this.m_applicationRoom){return
}this.requestRoomInfo(d,c)
};
this.requestRoomInfo=function(c,b){this.initMediaPlayer();
if(!this.m_bMediaRequested){this.m_bMediaRequested=true;
gNetworkMgr.requestInfo(this.m_imobject,null);
this.requestMediaChatLog(Math.max(b||0,20),c)
}this.m_mediaList.selectRoomItem(c)
};
this.initChatInfo=function(){var b=this.m_imobject.getAlias();
this.m_chatInfoContainer=this.getBody().appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_chatInfoContainer,"ImChatInfoContainer");
this.m_chatImg=createImg(getUniqueId(),this.m_chatInfoContainer,0,0,"","",false,"left",false);
addClassName(this.m_chatImg,"ImChatImg");
this.m_chatInfoContainer.appendChild(this.m_chatImg);
var c=this.m_chatInfoContainer.appendChild(this.m_win.document.createElement("div"));
addClassName(c,"ImChatImgOverlay");
this.m_chatTitle=new ui.label();
this.m_chatTitle.create(getUniqueId(),this.m_chatInfoContainer,null,b,null,0,200,22);
this.m_chatTitle.addClassName("ImChatTitle");
this.m_chatTitle.setShrinkToSize(true);
disableSelection(this.m_chatTitle.getElement(),true);
this.m_chatDescription=this.m_chatInfoContainer.appendChild(this.m_win.document.createElement("span"));
addClassName(this.m_chatDescription,"ImChatDescription");
this.m_chatDescription.style.width=(this.m_chatInfoW-50-this.m_chatImgMargin)+"px";
disableSelection(this.m_chatDescription,false);
this.updateChatInfo()
};
this.updateChatInfo=function(){var b=this.m_imobject.getChatDescription();
if(b){this.m_chatDescription.innerHTML=getFittedHeightText(b,130,this.m_chatDescription,30)
}var c=this.m_imobject.getIconURL()||(window.location.protocol=="https:"?"https://origin-":"http://")+"icons.meebo.com/stock/meebo_bubble.png";
if(c&&this.m_chatImg){gImages.requestImage(c,this.m_chatImg);
this.m_chatImg.style.visibility="visible"
}};
this.shouldDrag=function(b){return(b==this.m_toolbar.getElement())
};
this.hideGroupChatFurniture=function(){this.m_buddyList.setDisplay(false);
this.m_buddyListSlider.style.display="none";
if(this.m_inviteMenu){this.m_inviteMenu.setDisplay(false)
}if(this.m_appArea){this.m_appArea.style.display="none";
this.m_historyMediaSlider.style.display="none"
}};
this.inviteSelectedBuddiesFromBuddyList=function(){if(!gBuddyListDlg){return
}var c=gBuddyListDlg.m_pendingInvites;
for(var b in c){if(!c[b]){continue
}this.invite(c[b][0],c[b][1])
}gBuddyListDlg.m_pendingInvites=null;
gBuddyListDlg.m_inviteChat=null
};
this.invite=function(b,c){this.inviteBuddies([b],c)
};
this.inviteBuddies=function(c,g,l,d,e){d=d||"";
e=e||0;
if(!d){if(this.m_applicationRoom){invite=this.m_applicationRoom.getApplication().invite;
d=invite?sprintf(gLang.appInviteMessage,invite):sprintf(gLang.comeJoinMeInApp,this.m_applicationRoom.getApplication().alias)
}else{if(this.isMeeboGroupChat()){e=Math.floor(Math.random()*gInviteMsgs.length);
d=sprintf(gInviteMsgs[e],this.m_imobject.getAlias())
}}}if(this.m_imobject.getNetwork()=="meebome"||this.m_applicationRoom){var b=this.m_applicationRoom||this.m_imobject;
b.inviteBuddies(c,g,d,e);
gNetworkMgr.doUILog(this.control,"invite"+(l?"-"+l:""),c.length||1,true)
}else{var k=[];
for(var h=0;
h<c.length;
h++){if(c[h].getProtocol()==this.m_imobject.getProtocol()&&c[h].getUser()==this.m_imobject.getUser()&&this.addInvite(c[h])){k.push(c[h].getName())
}}if(k.length){var f=this.isGroupChat()&&this.m_imobject.getChatId();
gNetworkMgr.requestChatActionFull(null,"i",k,this.m_imobject.getProtocol(),this.m_imobject.getUser(),f,gLang.joinChat,f?null:normalizeString(this.m_imobject.getName()))
}}};
this.checkForPendingInvites=function(){if(gBuddyListDlg&&gBuddyListDlg.m_pendingInvites!=null&&this.m_caption.m_text==" "+gBuddyListDlg.m_inviteChat){this.inviteSelectedBuddiesFromBuddyList()
}};
this.banBuddy=function(c){var b=this.m_imobject.getLogin();
gNetworkMgr.requestChatAction(null,"b",c.getName(),this.m_imobject,this.m_imobject.getChatId())
};
this.addModerator=function(b){var c=b.getPresence(this.m_imobject);
gNetworkMgr.requestSetAffiliation(null,c,this.m_imobject,"admin")
};
this.deleteModerator=function(b){var c=b.getPresence(this.m_imobject);
gNetworkMgr.requestSetAffiliation(null,c,this.m_imobject,"member")
};
this.warnBuddy=function(b){var d=this.m_imobject.getName();
var e=b.getPresence(this.m_imobject).getAlias();
var f=String(d+"/"+e);
var c=this.m_imobject.getYourself().getBuddy();
c.addWarn();
gNetworkMgr.requestWarn(d,f)
};
this.removePresence=function(e){var c=e.getBuddy().getId();
var f=this.m_trees[c];
if(f){f.getParent().deleteItem(f,!this.isPoppedOut()&&this.isMeeboGroupChat());
this.addCachedRow(f);
delete this.m_trees[c]
}var b=e.getChat();
var d=e.getBuddy();
delete d.m_presences[b.getId()];
b.removePresence(e);
if(!d.hasPresences()&&gBuddyList.getBuddyById(d.getId())&&!d.isOnlist()&&!gWindowMgr.getConvWindow(d)){delete gBuddyList.m_buddies[d.getId()]
}gPubSub.unsubscribe(e,"meebo.Presence::changeAlias",this);
gPubSub.unsubscribe(e,"meebo.Presence::changeModerator",this);
gPubSub.unsubscribe(e,"meebo.Presence::changeOnline",this)
};
this.getCachedRow=function(){if(gRoomBuddyListCache.length&&!this.isPoppedOut()){return gRoomBuddyListCache.pop()
}};
this.addCachedRow=function(b){if(!this.isPoppedOut()&&this.isMeeboGroupChat()){gRoomBuddyListCache.push(b)
}};
this.onAccountPrefChange=function(e,b,d,c,g){if(!this.m_chatBtn){return
}if(/^logging:/.test(c)&&c.substr(8)==this.m_imobject.getName()){var f=(g===undefined?true:g)&&gPrefs.getPref("gchatlog",true);
this.m_chatBtn.setImage(f?"chatlog":"chatlogoff")
}};
this.onReceivePrefs=function(c,b,d){if(!this.m_chatBtn){return
}if("gchatlog" in d){var e=d.gchatlog&&c.getAccountPref(this.m_imobject.getLogin(),"logging:"+this.m_imobject.getName(),true);
this.m_chatBtn.setImage(e?"chatlog":"chatlogoff")
}}
});
Class("meeboApp.IMDlgBuddyLinkOverlay",ui.Element,function(a){this.initialize=function(b){a(this,"initialize");
this.m_buddy=b
};
this.createContent=function(){this.addClassName("IMDlgBuddyLinkOverlay");
this.m_content=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_content,"content");
this.m_presence=this.m_content.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_presence,"presence");
this.m_title=this.m_content.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_title,"title");
this.m_description=this.m_content.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_description,"description");
this.m_icon=this.m_content.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_icon,"icon");
ui.connectEvent(this.m_content,"click",this,"hide");
gPubSub.subscribe(this.m_buddy,"meebo.IMObject::changeOnline",this,"updateBuddyState");
this.updateBuddyState()
};
this.updateBuddyState=function(){if(this.m_buddy.isOnline()){this.setBuddyOnline()
}else{this.setBuddyOffline()
}};
this.setBuddyOffline=function(){addClassName(this.m_content,"offline");
removeClassName(this.m_content,"online");
var b=gLogon.getMeeboMeLogon();
if(b&&b.getName()==this.m_buddy.getName()){this.m_title.innerHTML=gLang.whatFriendsWillSee;
this.m_description.innerHTML=gLang.goAheadAndSend
}else{this.m_title.innerHTML=sprintf(gLang.isCurrentlyOffline,'<span class="alias">'+this.m_buddy.getAlias()+"</span>");
this.m_description.innerHTML=sprintf(gLang.weHaveToldThemBuddylist,'<span class="highlight">',"</span>")
}};
this.setBuddyOnline=function(){removeClassName(this.m_content,"offline");
addClassName(this.m_content,"online");
var b=gLogon.getMeeboMeLogon();
if(b&&b.getName()==this.m_buddy.getName()){this.m_title.innerHTML=gLang.whatFriendsWillSee;
this.m_description.innerHTML=gLang.goAheadAndSend
}else{this.m_title.innerHTML=sprintf(gLang.hasComeOnline,'<span class="alias">'+this.m_buddy.getAlias()+"</span>");
this.m_description.innerHTML=gLang.goAheadStartChatting
}};
this.hide=function(){gPubSub.unsubscribe(this.m_buddy,"meebo.IMObject::changeOnline",this);
this.setDisplay(false);
removeElement(this.m_element)
}
});
Class("meeboApp.buddyListDlg",ui.dlg,function(a){this.initialize=function(){a(this,"initialize");
this.m_onClose=new Array();
this.m_onMouseDown=new Array();
this.m_onFocus=new Array();
this.m_onKeyPress=new Array();
this.m_onKeyDown=new Array();
this.control="buddylistdlg";
this.m_toolbar;
this.m_addBuddyBtn;
this.m_removeBuddyBtn;
this.m_imBuddyBtn;
this.m_tree;
this.m_trees={};
this.m_offlineGroup;
this.m_slider;
this.m_overlay;
this.m_defaultSortMethod=meeboApp.util.tree.getBuddySortIndex;
this.m_buddyContextMenu;
this.m_minX=160;
this.m_minY=160;
this.m_persistenceTime=30000;
this.m_inviteChat=null;
this.m_pendingInvites=null;
this.m_buddyStatusQueue=[];
this.m_timerStatusFeedback=-1;
this.m_timerPersistence=-1;
this.m_restoreTimerId=null;
this.m_isOffline=false;
this.m_inNetworkInterrupt=false;
this.m_autoReconnectTimeout=-1;
this.m_autoReconnectDelta=0;
this.m_autoReconnectDeltas=[5+10*Math.random(),50+20*Math.random(),120+60*Math.random(),240+120*Math.random()];
this.m_autoReconnectDeltaTimeout=-1;
this.m_autoReconnectTime=-1;
this.m_countDownTimer=-1;
this.m_reconnectButton=null;
this.m_subscriptions=[]
};
this.subscribe=function(b,c){this.m_subscriptions.push(b);
gPubSub.subscribe(b,this,c)
};
this.unsubscribeAll=function(){gClient.unsubscribe("EventsProcessed",this,"onEventsProcessed");
while(this.m_subscriptions.length){gPubSub.unsubscribe(this.m_subscriptions.pop(),this)
}};
this.doSubscribe=function(){gClient.subscribe("EventsProcessed",this,"onEventsProcessed");
this.subscribe("meebo.BuddyList::createGroup","onCreateGroup");
this.subscribe("meebo.BuddyList::removeGroup","onRemoveGroup");
this.subscribe("meebo.BuddyList::addBuddyToGroup","onAddBuddyToGroup");
this.subscribe("meebo.BuddyList::removeBuddyFromGroup","onRemoveBuddyFromGroup");
this.subscribe("meebo.BuddyList::beforeClearBuddyList","onBeforeClearBuddyList");
this.subscribe("meebo.IMObject::changeOnline","onBuddyChangeOnline");
this.subscribe("meebo.IMObject::changeIcon","onBuddyChangeIcon");
this.subscribe("meebo.BuddyGroup::changeName","onGroupChangeName");
this.subscribe("meebo.EventMgr::networkInterrupt","onNetworkInterrupt");
this.subscribe("meebo.EventMgr::networkResume","onNetworkResume");
this.subscribe("meebo.EventMgr::changeState","onEventMgrChangeState")
};
this.removeSelections=function(){var m=this.getNumSelections();
var k=this.getSelectionTypesHash();
var l=this.getSelections();
if(!m){gWindowMgr.createNotifyDlg({id:getUniqueId(),caption:gLang.removeBuddiesContext},gLang.removeBuddiesInstr);
return
}var h=0;
for(var b in k){h++
}if(h!=1){return
}if(k.buddy){this.handleSelectedBuddyActionRequest("removebuddy","removes",null,l,k.buddy)
}else{if(k.chat){var g=k.chat==1;
for(var d in l){var p=l[d].getExtra()
}var n=g?gLang.removeChatHeader:gLang.removeChatsHeader;
var c=g?sprintf(gLang.confirmRemove,escapeHTML(p.getAlias())):sprintf(gLang.confirmRemoveChats,k.chat);
gWindowMgr.createOkDlg({id:"removeGroupChat",caption:n},c,hitch(gNetworkMgr,"requestRemoveBuddies",l),null,gLang.removeBtn,null,"removeBuddy.gif")
}else{if(k.buddygroup){if(m==1){var o=this.getFirstSelection();
if(this.m_offlineGroup&&o.m_id==this.m_offlineGroup.getId()){gWindowMgr.createNotifyDlg({id:getUniqueId(),caption:gLang.removeBuddiesContext},gLang.removeBuddiesOffline);
return
}var f=o.getExtra().getName();
var e=gLang.removeBuddyGroupHeader;
var c=gLang.confirmRemoveBuddyGroup
}else{var f=m;
var e=gLang.removeBuddyGroupsHeader;
var c=gLang.confirmRemoveBuddyGroups
}if(this.m_removeBuddyGroupDlg){this.m_removeBuddyGroupDlg._("closeWindow");
this.m_removeBuddyGroupDlg=null
}this.m_removeBuddyGroupDlg=gWindowMgr.createOkDlg({id:"removebuddygroup",caption:e},sprintf(c,f),hitch(this,"removeSelectedBuddyGroups",l),null,gLang.removeBtn,null,"removeBuddy.gif")
}}}};
this.handleSelectedBuddyActionRequest=function(l,e,f,g,k){var h=null;
if(e=="blocks"&&!f){this.performActionOnSelectedBuddies("blocks",g,false);
return
}if(!k){k=this.getSelectionTypesHash()["buddy"]
}if(k==1){if(e=="blocks"){var d=gLang.blockBuddy;
var b=gLang.confirmBlock;
var m="blockBuddy.gif";
h=gLang.block
}else{if(e=="removes"){var d=gLang.removeBuddyHeader;
var b=gLang.confirmRemove;
var m="removeBuddy.gif";
h=gLang.removeBtn
}}var c=this.getFirstSelection().getExtra().getAlias()
}else{if(e=="blocks"){var d=gLang.blockBuddies;
var b=gLang.confirmBlocks;
var m="blockBuddy.gif";
h=gLang.block
}else{if(e=="removes"){var d=gLang.removeBuddiesHeader;
var b=gLang.confirmRemoveBuddies;
var m="removeBuddy.gif";
h=gLang.removeBtn
}}var c=k
}gWindowMgr.createOkDlg({id:l,caption:d},sprintf(b,c),hitch(this,"performActionOnSelectedBuddies",e,g,f),null,h,null,m)
};
this.performActionOnSelectedBuddies=function(b,c,d){switch(b){case"removes":runInMainContext(gNetworkMgr,gNetworkMgr.requestRemoveBuddies,c);
break;
case"blocks":runInMainContext(gNetworkMgr,gNetworkMgr.requestBlockBuddies,c,d);
break
}};
this.removeSelectedBuddyGroups=function(b){var c=this.m_offlineGroup&&this.m_offlineGroup.getId();
if(b[c]){this.getTree().getSelectionModel().removeNode(b[c])
}runInMainContext(gNetworkMgr,gNetworkMgr.requestRemoveBuddyGroups,b);
this.getTree().getSelectionModel().resetSelections()
};
this.initContent=function(c){var b=this.getBody();
addClassName(b,"BuddyListDlg");
this.m_contentWidth=b.offsetWidth;
this.m_contentHeight=b.offsetHeight;
b.ptr=this;
this.doSubscribe();
this.createToolbar();
this.createTree();
this.createBuddyFilter();
this.createBuddyContextMenu();
this.connectContentEvents();
this.resize(this.getBody().offsetWidth,this.getBody().offsetHeight);
if(gLogon.getMeeboUser()&&gPrefs.getPref("buddySort")){this.sortGroups(gPrefs.getPref("buddySort"),true)
}this.m_timerStatusFeedback=gTimerMgr.addTimer(hitch(this,"handleBuddyChangeStatusFeedback"),1000);
this.m_timerPersistence=gTimerMgr.addTimer(hitch(this,"updatePersistence"),gBuddyListDlg.m_persistenceTime);
if(!c){gBuddyList.getBuddies().foreach(function(f,e){var g=e.getGroups();
for(var d=0,h;
(h=g[d]);
d++){if(!this.m_trees[h.getId()]){this.onCreateGroup(gBuddyList,"meebo.BuddyList::onCreateGroup",h)
}this.onAddBuddyToGroup(gBuddyList,"meebo.BuddyList::addBuddyToGroup",e,h)
}},this)
}return true
};
this.onTreeContextMenu=function(k,e){if(!e){e=window.event
}if(this.getNumSelections()<=1||!k.isSelected()){this.m_tree.getSelectionModel().selectOnly(k)
}gInfoDlg.hideInfo();
var f=this.m_buddyContextMenu;
f.removeAllItems();
f.closeMenu();
var h=k.getExtra();
var o=this.getSelectionTypesHash();
var n=0;
for(var b in o){n++
}if(n!=1){return
}if(o.buddy){if(o.buddy==1){var d=h.getAlias();
f.addMenuItem(sprintf(gLang.imBuddyContext,d),null,"message");
var s=h.getProtocol();
var q=(!h.getNetwork().isCIMPartner()&&s=="aim"||s=="icq"||s=="yahoo"||gProtocols[s].isJabberBased()||gLogon.getMeeboUser());
var m=q?"rename":"rename-upsell";
if(!h.isWidgetUser()){f.addMenuItem(sprintf(gLang.renameBuddy,h.getAlias()),null,m)
}if(h.getNetwork().supports("block")){if(h.isBlocked()){f.addMenuItem(sprintf(gLang.unblockBuddyContext,d),null,"unblock")
}else{f.addMenuItem(sprintf(gLang.blockBuddyContext,d),null,"block")
}}if(h.getNetwork().supports("remove")){f.addMenuItem(sprintf(gLang.removeBuddyContext,h.getAlias()),null,"remove")
}f.addMenuItem(gLang.viewProfile,null,"viewprofile");
if(h.getNetwork().supports("chatlogs")&&!h.isWidgetUser()){f.addMenuItem(gLang.viewChatLog,null,"viewlog")
}}else{if(this.existsBlockedSelectedBuddy(true)){f.addMenuItem(gLang.unblockBuddiesContext,null,"unblocks")
}if(this.existsBlockedSelectedBuddy(false)){f.addMenuItem(gLang.blockBuddiesContext,null,"blocks")
}f.addMenuItem(gLang.removeBuddiesContext,null,"removes")
}}else{if(o.chat){var g=o.chat==1;
if(g){f.addMenuItem(gLang.visitRoom,null,"join");
var t=gBuddyList.getGroupByName(gLang.recentRooms);
if(h.hasGroup(t)){f.addMenuItem(gLang.addToBuddyList,null,"add")
}}f.addMenuItem(g?gLang.removeChatContext:gLang.removeChatsContext,null,"remove")
}else{if(o.buddygroup){var l=this.m_offlineGroup&&this.getSelections()[this.m_offlineGroup.getId()];
if(!l){if(o.buddygroup==1){f.addMenuItem(sprintf(gLang.addBuddyToGroup,h.getName()),null,"addbuddytogroup");
f.addMenuItem(sprintf(gLang.renameBuddy,h.getName()),null,"renamegroup")
}}f.addMenuItem(gLang.addBuddyGroupContext,null,"addgroup");
if(!l){f.addMenuItem(this.getNumSelections()==1?gLang.removeBuddyGroupContext:gLang.removeBuddyGroupsContext,null,"removegroup");
var p=f.addMenuItem(gLang.sortGroupByName,null,"sortgroupalias");
var c=p.getElement().style;
c.borderTop="1px solid #677788";
c.height=(p.m_height-1)+"px";
f.addMenuItem(gLang.sortGroupByNetwork,null,"sortgroupprotocol");
f.addMenuItem(gLang.sortGroupByStatus,null,"sortgroupstatus")
}}else{ui.setEventHandled(e);
return
}}}f.showMenu(e,k);
ui.setEventHandled(e)
};
this.onContextSelect=function(f,g){gInfoDlg.hideInfo();
var c=this.getSelectionTypesHash();
var n=this.m_buddyContextMenu.getContextObject();
if(!n){return
}gNetworkMgr.doUILog(this.control,"contextmenu",g);
if(c.buddygroup){var k=n.getExtra();
switch(g){case"addgroup":gWindowMgr.createAddBuddyGroupDlg();
break;
case"removegroup":this.removeSelections();
break;
case"addbuddytogroup":gWindowMgr.createAddBuddyDlg(null,{group:k.getName()});
break;
case"renamegroup":n.showEditInput(hitch(this,"handleGroupRename"),k.getName());
break;
case"sortgroupalias":this.sortGroups("alias");
break;
case"sortgroupprotocol":this.sortGroups("protocol");
break;
case"sortgroupstatus":this.sortGroups("status");
break
}}else{if(c.buddy==1){var e=n.getExtra();
var l=gWindowMgr.getConvWindow(e);
switch(g){case"message":n.publish("Activate");
break;
case"block":var h=hitch(this,function(){runInMainContext(gNetworkMgr,gNetworkMgr.requestBlockBuddies,this.getSelections(),true);
if(l){l.toggleBlock()
}});
gWindowMgr.createOkDlg({id:"blockbuddy",caption:gLang.blockBuddy},sprintf(gLang.confirmBlock,e.getAlias()),h,null,gLang.block,null,"blockBuddy.gif");
break;
case"unblock":runInMainContext(gNetworkMgr,gNetworkMgr.requestBlockBuddies,this.getSelections(),false);
if(l){l.toggleBlock()
}break;
case"remove":this.removeSelections();
break;
case"viewlog":if(gLogon.getMeeboUser()){gWindowMgr.createChatLogWindow(null,e)
}else{gWindowMgr.createCreateMeeboAccountDlg({},"bl-viewlog","upsell_chatlogs.png")
}break;
case"viewprofile":var d=posWithRespectTo(n.getElement(),$("buddies"));
var b=posWithRespectTo(this.getBody(),this.m_win.document.body);
gWindowMgr.createProfileDlg({id:getProfileId(e),caption:e.getAlias(),x:d.x-300+b.x,y:d.y-15},e);
break;
case"rename":n.showEditInput(hitch(this,"handleRename"),e.getAlias());
break;
case"rename-upsell":gWindowMgr.createCreateMeeboAccountDlg({},"bl-rename","upsell_rename.png");
default:break
}}else{if(c.buddy>1){switch(g){case"groupchat":this.storePendingInvites();
gWindowMgr.createGroupChatDlg(true);
break;
case"blocks":this.handleSelectedBuddyActionRequest("blockbuddies","blocks",true,this.getSelections(),c.buddy);
break;
case"unblocks":this.handleSelectedBuddyActionRequest("blockbuddies","blocks",false,this.getSelections(),c.buddy);
break;
case"removes":this.removeSelections();
break;
default:break
}}else{if(c.chat){switch(g){case"join":n.publish("Activate");
break;
case"remove":this.removeSelections();
break;
case"add":var m=n.getExtra();
gNetworkMgr.requestMoveBuddy(hitch(gNetworkMgr,"receiveAddChat",m),[m],gLang.meeboChats);
break
}}}}}};
this.handleKeyPress=function(f,d){if(f){var e=f.keyCode||f.charCode;
switch(e){case ui.KEY_DELETE:case 63272:this.removeSelections();
gNetworkMgr.doUILog(this.control,"toolbar","remove-key");
break;
case 47:case 191:this.m_buddyFilter.focus();
break;
case 9:if(!f.ctrlKey){if(f.shiftKey){gWindowMgr.focusPrev()
}else{gWindowMgr.focusNext()
}break
}return true;
case ui.KEY_RIGHT:case ui.KEY_LEFT:ui.setEventHandled(f);
return false;
case ui.KEY_ESC:this.clearBuddyFilter();
this.m_buddyFilter.blur();
default:switch(e){case ui.KEY_UP:case 63232:case ui.KEY_DOWN:case 63233:var b=this.m_tree.getSelectionModel().handleKeyEvent(f);
var c=b&&b.getExtra();
if(gInfoDlg.isVisible()&&c&&c.getInfo){gInfoDlg.showInfo(b)
}return false;
default:return this.m_tree.getSelectionModel().handleKeyEvent(f)
}}ui.setEventHandled(f);
return false
}};
this.storePendingInvites=function(){this.m_pendingInvites=[];
var c=this.getSelections();
for(var d in c){var b=c[d].getExtra();
if(b.getType()!="buddy"){continue
}this.m_pendingInvites.push([b.getName(),b.getAlias()])
}};
this.sortGroups=function(f){if(!f){return
}gPrefs.saveBuddySortPref(f);
var c=this.getSortFunctionFromMethod(f);
if(c==this.m_defaultSortMethod){return
}this.m_defaultSortMethod=c;
var b=this.getTree();
if(!b){return
}var e=b.getChildren();
for(var d=0,g;
(g=e[d]);
d++){g.setSortFunc(this.m_defaultSortMethod)
}};
this.getSortFunctionFromMethod=function(c){var b=meeboApp.util.tree;
var d={protocol:b.getBuddyProtocolSortIndex,status:b.getBuddyStatusSortIndex,alias:b.getBuddySortIndex};
return d[c in d?c:"alias"]
};
this.handleGroupRenameError=function(c,b,d){if(b){return
}else{gWindowMgr.createNotifyDlg({id:"renameGroupError"+getUniqueId(),caption:gLang.renameGroupNetError},gLang.renameGroupNetError+gLang.pleaseCheck)
}};
this.handleGroupRename=function(b,h){if(h==null){return
}var g=b.getExtra();
var d=g.getName();
var f=stripWhitespace(h);
var c=gBuddyList.getGroupByName(f);
if(!f||f==d){return
}var e=hitch(gWindowMgr,"createNotifyDlg",{id:"renameGroupError"+getUniqueId(),caption:gLang.renameGroupNetError});
if(c&&c!=g){e(gLang.renameGroupExistsError,f)
}else{gBuddyList.setGroupName(g,f);
runInMainContext(gNetworkMgr,gNetworkMgr.requestRenameGroup,hitch(gBuddyListDlg,"handleGroupRenameError"),d,f)
}};
this.handleRenameError=function(c,b,d){if(b){return
}else{gWindowMgr.createNotifyDlg({id:"renameError"+getUniqueId(),caption:gLang.renameBuddyNetError},gLang.renameBuddyNetError+gLang.pleaseCheck)
}};
this.handleRename=function(b,e){if(e==null){return
}var c=b.getExtra(),d=stripWhitespace(e);
if(d==c.getAlias()){return
}c.setAlias(d);
runInMainContext(gNetworkMgr,gNetworkMgr.requestSetAlias,c,d,hitch(gBuddyListDlg,"handleRenameError"));
this.m_tree.redrawChildren()
};
this.createBuddyContextMenu=function(){this.m_buddyContextMenu=new ui.contextmenu();
this.m_buddyContextMenu.init("buddymenu",150,this.m_win.document);
this.m_buddyContextMenu.addSelectFunc(hitch(this,"onContextSelect"));
return this.m_buddyContextMenu
};
this.createToolbar=function(){this.m_toolbar=new ui.toolbar("large").create(this.m_win);
this.getBody().appendChild(this.m_toolbar.getElement());
this.m_addBuddyBtn=this.m_toolbar.addButton("blAddBuddy","addbuddy",gLang.addBuddyTT);
this.m_removeBuddyBtn=this.m_toolbar.addButton("blRemoveBuddy","removebuddy",gLang.removeBuddyTT);
this.m_imBuddyBtn=this.m_toolbar.addButton("blIMBuddy","chat",gLang.anyoneTT);
this.addGroupChatButton();
if(!this.m_protocolGroupChatBtn){gPubSub.subscribe("meebo.LogonMgr::addLogon",this,"addGroupChatButton");
gPubSub.subscribe("meebo.LogonMgr::removeLogon",this,"removeGroupChatButton")
}this.m_flexToolSpace=new ui.toolbarFlexibleSpace().create(this.m_win);
this.m_toolbar.addButton(this.m_flexToolSpace);
this.m_popBtn=(this.isPoppedOut()?this.m_toolbar.addButton("blPopButton","popin",gLang.popInTT):this.m_toolbar.addButton("blPopButton","popout",gLang.popOutTT));
return this.m_toolbar
};
this.addGroupChatButton=function(){if(gLogon.getLogons({supports:"chatrooms"}).length||gLogon.hasMeeboAccount()){gPubSub.unsubscribe("meebo.LogonMgr::addLogon",this,"addGroupChatButton");
this.m_protocolGroupChatBtn=this.m_toolbar.addButton("blProtocolGroupChat","groupchat",gLang.groupChatTT,null,null,this.m_flexToolSpace);
this.m_toolbar.resize();
this.m_protocolGroupChatBtn.addOnMouseUp(hitch(gWindowMgr,"createGroupChatDlg",null))
}};
this.removeGroupChatButton=function(){gPubSub.unsubscribe("meebo.LogonMgr::addLogon",this,"removeGroupChatButton");
this.m_toolbar.removeButton(this.m_protocolGroupChatBtn);
this.m_toolbar.resize()
};
this.createBuddyFilter=function(){this.m_buddyFilter=this.m_win.document.createElement("input");
this.m_buddyFilter.type="text";
this.m_buddyFilter.name="buddyFilter";
this.m_buddyFilter.className="BuddyFilter";
this.m_buddyFilter.autocomplete=false;
this.m_toolbar.getElement().appendChild(this.m_buddyFilter);
this.m_buddyFilterClearButton=this.createBuddyFilterClearButton();
this.m_filterTimeoutId=null;
this.clearBuddyFilter();
var c=/^\W*$/;
function d(h){if(this.m_ignoreClearFilter){ui.setEventHandled(h);
this.m_buddyFilter.focus();
this.m_ignoreClearFilter=false
}else{this.clearBuddyFilter()
}}function g(){if(this.m_buddyFilter.value==gLang.searchBuddyList){this.m_buddyFilter.value="";
this.m_buddyFilter.style.color="#000";
this.m_buddyFilterClearButton.style.visibility="visible"
}}var e=200;
function f(h){if(!h){return
}switch(h.keyCode){case 9:if(ui.isWebKit){return this.handleKeyPress(h,this.m_buddyFilter)
}break;
case ui.KEY_ESC:case ui.KEY_UP:case ui.KEY_DOWN:case ui.KEY_RETURN:return this.handleKeyPress(h,this.m_buddyFilter);
default:if(this.m_filterTimeoutId){this.m_win.clearTimeout(this.m_filterTimeoutId)
}this.m_filterTimeoutId=this.m_win.setTimeout(hitch(this,function(){this.m_filterTimeoutId=null;
this.filterBuddies(this.m_buddyFilter.value)
}),e)
}}function b(h){if(!h){return
}switch(h.keyCode){case 9:return this.handleKeyPress(h,this.m_buddyFilter);
case ui.KEY_ESC:case ui.KEY_UP:case ui.KEY_DOWN:if(ui.isFirefox){ui.setEventHandled(h);
return false
}else{return this.handleKeyPress(h,this.m_buddyFilter)
}}}ui.connectEvent(this.m_buddyFilter,"blur",this,d,true,false);
ui.connectEvent(this.m_buddyFilter,"focus",this,g,false,false);
if(ui.isIE){ui.connectEvent(this.m_buddyFilter,"mousedown",this,function(){this.m_win.setTimeout(hitch(this,function(){this.m_buddyFilter.focus()
}),0)
},false,false)
}ui.connectEvent(this.m_buddyFilter,"keypress",this,b,true);
ui.connectEvent(this.m_buddyFilter,"keydown",this,f,true);
ui.connectEvent($("buddylistwin"),"mousedown",this,function(){this.m_ignoreClearFilter=true
});
ui.connectEvent($("buddylistwin"),"mouseup",this,function(){this.m_ignoreClearFilter=false
})
};
this.createBuddyFilterClearButton=function(){var b=this.m_win.document.createElement("div");
b.className="BuddyFilterClearButton";
b.style.visibility="hidden";
this.m_buddyFilter.parentNode.appendChild(b);
ui.connectEvent(b,"mouseover",this,function(){b.style.backgroundPosition="-23px 0"
},false,false);
ui.connectEvent(b,"mouseout",this,function(){b.style.backgroundPosition="-4px 0"
},false,false);
ui.connectEvent(b,"mousedown",this,function(){b.style.backgroundPosition="-42px 0"
},false,false);
ui.connectEvent(b,"mouseup",this,function(){b.style.backgroundPosition="-23px 0";
this.clearBuddyFilter()
},false,false);
return b
};
this.filterBuddies=function(h){h=normalizeString(h);
var k=this.m_tree.getChildren();
var c;
var s=h.match(/^\/(.*)\/$/);
try{c=new RegExp(s?s[1]:escapeRegexp(h),"i")
}catch(m){c=new RegExp(escapeRegexp(h),"i")
}for(var p=0;
p<k.length;
p++){var d=k[p].getChildren();
var f=false;
for(var l=0;
l<d.length;
l++){var q=d[l];
var n=q.getExtra();
var b=n.getName().split("@")[0];
var g=n.getAlias();
if(c.test(normalizeString(b))||c.test(normalizeString(g))){q.show();
f=true
}else{q.hide()
}}if(f||stripWhitespace(h)==""){var o=k[p];
o.show();
if(h&&o.m_children.length&&!o.m_bToggleOpen){o.toggle()
}}else{k[p].hide()
}}};
this.clearBuddyFilter=function(){if(this.m_filterTimeoutId){this.m_win.clearTimeout(this.m_filterTimeoutId)
}this.m_buddyFilter.style.color="#aaa";
this.m_buddyFilter.value=gLang.searchBuddyList;
this.m_buddyFilterClearButton.style.visibility="hidden";
this.filterBuddies("")
};
this.createTree=function(){if(this.m_tree){removeElement(this.m_tree.m_element);
this.m_offlineGroup=null
}var b=this.getBody();
this.m_tree=new ui.Tree({eventModel:meeboApp.TreeEventModel,buildDragTree:function(){var e=this.m_win.document.body.appendChild(this.m_win.document.createElement("div"));
e.style.position="absolute";
e.className="BuddyListDlg";
e.style.overflow="visible";
e.style.zIndex=2000000000;
e.style.cursor="not-allowed";
var d=e.appendChild(this.m_win.document.createElement("div"));
d.className="uiTree maBlBuddies";
d.style.width="100%";
d.style.overflow="visible";
d.style.backgroundColor="transparent";
d.style.borderWidth="0px";
return e
}});
this.m_tree.create(this);
this.m_tree.addClassName("maBlBuddies");
this.m_tree.setDropTargets(new ui.drag.dragObject());
b.appendChild(this.m_tree.m_element);
var c=new ui.TreeNode("buddies");
c.setSortFunc(meeboApp.util.tree.getGroupSortIndex);
this.m_tree.setRoot(c);
if(this.m_overlay){b.appendChild(this.m_overlay)
}this.showOfflineGroup(true);
this.resize(b.offsetWidth,b.offsetHeight);
return this.m_tree
};
this.showOfflineGroup=function(c){if(Boolean(c)==Boolean(this.m_offlineGroup)){return
}if(c){this.m_offlineGroup=new meebo.BuddyGroup(gLang.offlineGroup);
this.m_offlineGroup.m_id+="-meebo-offline-group";
var b=this.m_tree.insertItem(this.createTreeGroup(this.m_offlineGroup));
b.getText=function(){return gLang.offlineGroup
};
b.markRedraw()
}else{var b=this.m_trees[this.m_offlineGroup.getId()];
b.getParent().deleteItem(b);
delete this.m_trees[this.m_offlineGroup.getId()];
this.m_offlineGroup=null
}gBuddyList.getBuddies({online:false}).foreach(function(h,g){var k=g.getGroups();
for(var f=0,l;
(l=k[f]);
f++){var e=this.m_trees[g.getGroupId(l)];
var d=this.m_trees[this.m_offlineGroup?this.m_offlineGroup.getId():l.getId()];
if(!e||!d){continue
}if(!this.m_offlineGroup){d.insertItem(e)
}else{if(f==0){b.insertItem(e)
}else{d.deleteItem(e,true)
}}}},this)
};
this.setOffline=function(b){if(this.m_isOffline==b){return
}this.m_isOffline=b;
this.m_addBuddyBtn.setDisabled(b);
this.m_removeBuddyBtn.setDisabled(b);
this.m_imBuddyBtn.setDisabled(b);
if(this.m_protocolGroupChatBtn){this.m_protocolGroupChatBtn.setDisabled(b)
}this.m_popBtn.setDisabled(b);
this.m_buddyFilter.disabled=b;
gInfoDlg.hideInfo();
if(this.m_buddyContextMenu){this.m_buddyContextMenu.removeAllItems();
this.m_buddyContextMenu.closeMenu()
}};
this.showDisconnectionOverlay=function(h){var g=h?gLang.networkInterruption:gLang.disconnected;
var f=h?gLang.networkTrouble+"!<br><br>"+sprintf(gLang.reconnectingIn,"<span></span>")+"\u2026":gLang.thanks+gLang.logout+"<br><br>"+gLang.comeBack;
var d="<div><b>"+escapeHTML(g)+"</b><br><br>"+f+"</div>";
var c=this.createOverlay(d);
c.style.background="#f7f7f3";
var e=c.firstChild;
e.style.overflow="hidden";
e.style.fontSize="11px";
e.style.padding="20px 8px";
e.style.margin="0 8px";
e.style.border="1px solid #ddd";
e.style.background="white";
if(h){this.m_countDownSpan=e.getElementsByTagName("span")[0];
this.updateCountDown()
}var b=this.m_reconnectButton=new ui.button(this.getId()+"-reconnectbutton",gLang.reconnectionBtn).create(this.m_win);
e.appendChild(b.getElement());
this.updateReconnectButton();
b.addOnMouseUp(hitch(this,"reconnect"));
b.m_element.style[ui.isIE?"styleFloat":"cssFloat"]="right";
b.m_element.style.marginTop="12px";
e.style.marginTop=((c.offsetHeight-e.offsetHeight)/2)+"px";
this.m_reconnectMessageDiv=e
};
this.updateCountDown=function(){var b=Math.round((this.m_autoReconnectTime-new Date().getTime())/1000);
if(b<0){b=0
}setText(this.m_countDownSpan,getTimeString(b,true))
};
this.updateReconnectButton=function(b){b=b||gEventMgr.getState()=="reconnecting";
this.m_reconnectButton.setDisabled(b);
this.m_reconnectButton.setText(b?capitalize(gLang.reconnecting)+"\u2026":(this.m_inNetworkInterrupt?gLang.tryNow+"\u2026":gLang.reconnectionBtn))
};
this.reconnect=function(){this.updateReconnectButton(true);
gLogon.reconnectAll()
};
this.inNetworkInterrupt=function(){return this.m_inNetworkInterrupt
};
this.showNotification=function(b){var c=this.m_win.document.createElement("div");
c.className="networkNotification";
setText(c,b);
this.m_notificationDiv=this.getBody().appendChild(c);
this.resize()
};
this.hideNotification=function(){if(this.m_notificationDiv){removeElement(this.m_notificationDiv);
this.m_notificationDiv=null;
this.resize()
}};
this.onNetworkInterrupt=function(d,b,c){if(c==2){this.showNotification(gLang.networkTrouble+"\u2026")
}};
this.onNetworkResume=function(c,b){this.hideNotification()
};
this.onEventsProcessed=function(){this.m_tree.redrawChildren()
};
this.onEventMgrChangeState=function(e,b,f,c){this.setOffline(f!="im");
switch(f){case"done":this.m_inNetworkInterrupt=e.inNetworkInterrupt()||this.m_inNetworkInterrupt;
if(this.m_reconnectButton){this.updateReconnectButton()
}else{this.showDisconnectionOverlay(this.m_inNetworkInterrupt)
}if(this.m_inNetworkInterrupt){if(this.m_autoReconnectDeltaTimeout!=-1){clearTimeout(this.m_autoReconnectDeltaTimeout);
this.m_autoReconnectDeltaTimeout=-1
}var g=this.m_autoReconnectDeltas[this.m_autoReconnectDelta]*1000;
log("autoreconnect in "+(g/1000)+" seconds");
this.autoReconnectIn(g);
if(++this.m_autoReconnectDelta>=this.m_autoReconnectDeltas.length){this.m_autoReconnectDelta--
}}break;
case"reconnecting":if(this.m_autoReconnectTimeout!=-1){clearTimeout(this.m_autoReconnectTimeout);
this.m_autoReconnectTimeout=-1;
gTimerMgr.removeTimer(this.m_countDownTimer);
this.m_countDownTimer=-1
}break;
default:var g=this.m_autoReconnectDeltas[this.m_autoReconnectDelta]*1000;
this.m_autoReconnectDeltaTimeout=setTimeout(hitch(this,function(){this.m_autoReconnectDelta=0;
this.m_autoReconnectDeltaTimeout=-1
}),g);
this.m_inNetworkInterrupt=false;
if(this.m_reconnectButton){removeElement(this.m_overlay);
this.m_overlay=this.m_reconnectMessageDiv=this.m_reconnectButton=null
}this.hideNotification();
break
}};
this.autoReconnectIn=function(b){this.m_autoReconnectTimeout=setTimeout(hitch(this,"reconnect"),b);
this.m_autoReconnectTime=new Date().getTime()+b;
if(this.m_countDownTimer==-1){this.m_countDownTimer=gTimerMgr.addTimer(hitch(this,"updateCountDown"),1000)
}};
this.resize=function(b,d){if(!b){b=this.getBody().offsetWidth
}if(!d){d=this.getBody().offsetHeight
}if(b>0&&this.m_tree){this.m_tree.m_element.style.width=b-2+"px"
}var e=55;
if(this.m_toolbar&&!this.m_toolbar.getDisplay()){e=3
}var c=6;
if(this.m_overlay&&this.m_state!="min"){this.m_overlay.style.top=e+"px";
this.m_overlay.style.width=b+"px";
this.m_overlay.style.height=(d-e-c)+"px";
if(this.m_reconnectMessageDiv){this.m_reconnectMessageDiv.style.marginTop=((this.m_overlay.offsetHeight-this.m_reconnectMessageDiv.offsetHeight)/2)+"px"
}}if(this.m_notificationDiv){e+=this.m_notificationDiv.offsetHeight;
this.m_notificationDiv.style.width=b-8+"px"
}if(this.m_tree){var f=d-e-c;
f=f>=0?f:0;
this.m_tree.m_element.style.top=e+"px";
this.m_tree.m_element.style.height=f+"px"
}if(this.m_toolbar){this.m_toolbar.resize(b)
}if(this.m_buddyFilter){this.m_buddyFilter.style.width=b-21+"px"
}};
this.connectContentEvents=function(){this.m_addBuddyBtn.addOnMouseUp(hitch(gWindowMgr,"createAddBuddyDlg",null));
this.m_addBuddyBtn.addOnMouseUp(hitch(gNetworkMgr,"doUILog",this.control,"toolbar","add",false));
this.m_removeBuddyBtn.addOnMouseUp(hitch(this,"removeSelections"));
this.m_removeBuddyBtn.addOnMouseUp(hitch(gNetworkMgr,"doUILog",this.control,"toolbar","remove",false));
this.m_imBuddyBtn.addOnMouseUp(hitch(gWindowMgr,"createIMBuddyDlg",null));
this.m_imBuddyBtn.addOnMouseUp(hitch(gNetworkMgr,"doUILog",this.control,"toolbar","imbuddy",false));
if(this.m_popBtn){this.m_popBtn.addOnMouseUp(hitch(this,"reversePop",null,null));
this.m_popBtn.addOnMouseUp(hitch(this,"logPopButton"))
}this.addOnClose(this,"onClose");
this.addOnBlur(this,"clearBuddyFilter");
if(ui.isIE){this.addOnKeyDown(this,"handleKeyPress")
}else{this.addOnKeyPress(this,"handleKeyPress")
}if(ui.isWebKit&&!ui.isFluid){this.addOnKeyDown(this,"handleKeyPress")
}};
this.logPopButton=function(){gNetworkMgr.doUILog(this.control,"toolbar",this.isPoppedOut()?"unpop":"pop",false)
};
this.onClose=function(){if(gBuddyListDlg==this){gBuddyListDlg=null
}if(this.m_restoreTimerId){clearTimeout(this.m_restoreTimerId);
this.m_restoreTimerId=null
}if(this.m_timerStatusFeedback!=-1){gTimerMgr.removeTimer(this.m_timerStatusFeedback)
}if(this.m_timerPersistence!=-1){gTimerMgr.removeTimer(this.m_timerPersistence)
}if(!this.m_bPoppingOut&&this.isPoppedOut()){var g=this.getWindowPos();
var b=this.saveState();
function l(m){m.restoreState(b)
}var c=this.m_createFnc.f;
var h=this.m_createFnc.c;
var d=this.m_createFnc.a;
runInMainContext(null,function(){c.apply(h,d.concat(l,false,g))
})
}if(!this.m_bPoppingOut&&this.m_tree){var e=this.m_tree.getChildren();
for(var f=0,k;
(k=e[f]);
f++){gDragManager.removeDropTarget(k)
}}if(this.m_autoReconnectTimeout!=-1){clearTimeout(this.m_autoReconnectTimeout);
this.m_autoReconnectTimeout=-1
}if(this.m_countDownTimer!=-1){gTimerMgr.removeTimer(this.m_countDownTimer);
this.m_countDownTimer=-1
}this.unsubscribeAll()
};
this.onMoveToTop=function(c,b){gWindowMgr.activateWindow(this);
if(gInfoDlg.isVisible()){gInfoDlg.moveToTop()
}return true
};
this.setUpsell=function(k,n){this.setWindowCaption(gLang.signon);
if(k&&k.toLowerCase()=="meebo"){k="meebome"
}var o=k&&gNetworks[k.toLowerCase()];
if(!o||o=="facebook"){o=gNetworks.aim
}var g='<div id="upsell"><center>			<div class="maBlUpsell">			<div class="maBlUpsellHeader">'+gLang.upsellHeader+'</div>			<img path="upsell_protocols.png" class="maBlUpsellProtocols" png="true">			<div class="maBlUpsellBody">			<table cellspacing="4" cellpadding="0">			<tr><td align="right" class="maBlUpsellLabel">'+gLang.network+'</td>					<td id="upsell-protocol"></td>			<tr><td align="right" class="maBlUpsellLabel"><label for="upsell-login-input" id="upsell-login-label">'+(o.loginIsEmail()?gLang.email:gLang.loginId)+'</label></td>					<td id="upsell-login"><input type="text"					id="upsell-login-input" class="textBox" value="'+n+'"></td>			<tr><td align="right" class="maBlUpsellLabel"><label for="upsell-password-input">'+gLang.password+'</label></td>					<td id="upsell-password"><input type="password"					id="upsell-password-input" class="textBox"></td>			<tr><td></td><td id="upsell-invisible" align="left">				<input type="checkbox" id="upsell-invischeck">				<label for="upsell-invischeck">'+gLang.autoInvisible+'</label>				</td>			<tr><td colspan="2" id="upsell-signon-td"></td>			</table>			</div><div class="maBlUpsellFooter">			<div class="title">'+gLang.upsellFooterTitle+"</div>"+gLang.upsellFooter+'&nbsp;<a href="javascript:void(null)" id="upsell-join">'+gLang.joinNow+"</a></div></div>			</center></div>";
if(this.m_toolbar){this.m_toolbar.setDisplay(false)
}var d=this.createOverlay(g);
d.style.backgroundColor="#FFFFFF";
d.style.backgroundImage="url("+gImages.getPath()+"upsell_bg2.gif)";
d.style.backgroundRepeat="repeat-x";
cacheImgs(d);
var e=new ui.menuheader(getUniqueId(),null,135,135,"left",16,false,null,false,false,135).create(this.m_win);
e.setDelayMenu(true);
$("upsell-protocol").appendChild(e.getElement());
var b=e.getElement().style;
b.position="relative";
b.textAlign="left";
e.setTitle(o.getName(),o.getId(),true);
e.setImage("network/"+o.getId()+"_14_online.gif");
for(var f in gNetworks){if(!gNetworks[f].isLive()||f=="facebook"){continue
}e.addMenuItem(gNetworks[f].getName(),"network/"+f+"_14_online.gif",f)
}e.addSelectFunc(function(){setText($("upsell-login-label"),gNetworks[e.getItemValue()].loginIsEmail()?gLang.email:gLang.loginId)
});
var c=new ui.button("upsell-signon",gLang.signon,null,null,"big").create(this.m_win);
$("upsell-signon-td").appendChild(c.getElement());
var l=$("upsell-join");
var m=hitch(gWindowMgr,"createMyMeeboWindow",{parent:document.body},false,"connectionstab","connectionpanecontent");
ui.connectEvent(l,"click",gWindowMgr,"createCreateMeeboAccountDlg",false,false,{},"bl-accounts","upsell_accounts.png",m);
this.m_upsellLogin=$("upsell-login-input");
this.m_upsellPassword=$("upsell-password-input");
this.m_upsellInvisible=$("upsell-invischeck");
this.m_upsellMenu=e;
this.m_upsellPassword.focus();
function h(p){if(p.keyCode==13){this.loginUpsell()
}}c.addOnMouseUp(hitch(this,"loginUpsell"));
ui.connectEvent(this.m_upsellLogin,"keyup",this,h,true,false);
ui.connectEvent(this.m_upsellPassword,"keyup",this,h,true,false);
ui.connectEvent(this.m_upsellInvisible,"keyup",this,h,true,false);
gPubSub.subscribe("meebo.Logon::changeState",this,"onLogonChangeState");
c.getElement().parentNode.style.paddingLeft=((c.getElement().parentNode.offsetWidth-c.getElement().offsetWidth)/2)+"px"
};
this.onLogonChangeState=function(c,b,d){if(d=="error"){if(gWait){gWait.hideWait()
}}else{if(d=="online"){if(c.getNetwork()=="meebome"&&c.isAnonymous()){return
}this.setWindowCaption(gLang.buddylist);
gPubSub.unsubscribe("meebo.Logon::changeState",this);
if(gWait){gWait.hideWait()
}this.hideOverlay();
this.m_upsellLogin=null;
this.m_upsellPassword=null;
this.m_upsellMenu=null;
if(this.m_toolbar){this.m_toolbar.setDisplay(true)
}this.resize(this.getBody().offsetWidth,this.getBody().offsetHeight);
gNetworkMgr.doUILog(this.control,"signin",c.getNetwork(),true)
}}};
this.createOverlay=function(b){this.m_overlay=this.m_win.document.createElement("div");
this.m_overlay.className="maBlBuddies";
this.m_overlay.id="buddyListOverlay";
this.m_overlay.innerHTML=b;
this.m_overlay=this.getBody().appendChild(this.m_overlay);
this.resize(this.getBody().offsetWidth,this.getBody().offsetHeight);
return this.m_overlay
};
this.hideOverlay=function(){if(!this.m_overlay){return
}this.m_overlay.parentNode.removeChild(this.m_overlay);
this.m_overlay=null
};
this.loginUpsell=function(){var d=this.m_upsellLogin.value;
var c=this.m_upsellPassword.value;
var e=this.m_upsellMenu.getItemValue();
var f=this.m_upsellInvisible.checked;
var b=meebo.util.createAccount(d,e,c);
if(typeof b=="string"){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.incompleteLogon,parent:this},b);
return false
}if(b instanceof meebo.Logon&&f){b.setStatus("invisible")
}if(!gWait){gWait=new meeboApp.logonWaitDlg()
}gWait.showWait(gLang.signOnWait,gImages.getPath()+"wait_ax.gif",$("upsell"));
gWait.m_element.style.zIndex=this.getZIndex()+1;
gNetworkMgr.requestLogin("login",[b]);
return true
};
this.onBeforeClearBuddyList=function(){var e=this.m_tree.getChildren();
for(var d=0,f;
(f=e[d]);
d++){gDragManager.removeDropTarget(f)
}for(var c in this.m_trees){var b=this.m_trees[c];
if(b&&b.destroy){b.destroy()
}}this.m_trees={};
this.m_offlineGroup=null;
this.createTree()
};
this.onBuddyChangeOnline=function(e,m,f){var d=e.getGroups();
for(var b=0,k;
(k=d[b]);
b++){var c=this.m_trees[e.getGroupId(k)];
var h=this.m_trees[k.getId()];
if(this.m_offlineGroup){if(f){c.setNewParent(h)
}else{if(b==0){c.setNewParent(this.m_trees[this.m_offlineGroup.getId()])
}else{h.deleteItem(c,true)
}}}c.markRedraw();
h.markRedraw();
this.showBuddyTreeChangeStatusFeedback(c)
}if(meeboApp.util.hasMeeboExtension()&&gEventMgr.getState()=="im"&&!gEventMgr.inNetworkInterrupt()&&e.getType()=="buddy"&&e.isOnlist()&&new Date().getTime()-e.getWentOnlistTime()>2000){var g=function(){var n=gWindowMgr.createIMWindow(e,true);
if(!n||!n.isPoppedOut||!n.isPoppedOut()){MeeboExtension.showMeeboTab()
}};
var l=sprintf(e.isOnline()?gLang.cameOnline:gLang.wentOffline,e.getAlias());
MeeboExtension.showNotification(e.getAlias(),l,e.getIconURL(),e.isOnline()?"online":"offline",g)
}};
this.onBuddyChangeIcon=function(f,c,h){if(f.getType()!="buddy"){return
}var k=f.getPresences();
for(chatId in k){var e=k[chatId];
var d=e.getChat();
var g=gWindowMgr.getConvWindow(d);
if(g){var b=g.m_trees[f.getId()]
}if(b){b.updateImage()
}}};
this.updateBuddyRows=function(c){var e=c.getGroups();
for(var d=0,f;
(f=e[d]);
d++){var b=this.m_trees[c.getGroupId(f)];
if(b){b.markRedraw()
}}};
this.onRemoveGroup=function(d,c,e){var b=this.m_trees[e.getId()];
delete this.m_trees[e.getId()];
this.m_tree.getRoot().deleteItem(b);
gDragManager.removeDropTarget(b)
};
this.onCreateGroup=function(d,b,e){var c=this.createTreeGroup(e);
this.m_tree.getRoot().insertItem(c);
gDragManager.addDropTarget(c)
};
this.onGroupChangeName=function(g,c,d,e,f,h){var b=this.m_trees[h];
delete this.m_trees[h];
this.m_trees[f]=b;
b.getParent().renameChildItemId(h,f);
gPrefs.savePref("gn:"+d,b.isToggled());
b.redraw()
};
this.createTreeItem=function(c,e){var d=c.getType();
var b=(d=="buddy"?new meeboApp.BuddyRow(c,e):new meeboApp.ChatRow(c,e));
this.m_trees[e]=b;
if(ui.isIPhone){b.subscribe("Click",this,"onBuddyTreeActivate")
}else{b.subscribe("MouseOver",this,"onBuddyTreeMouseOver");
b.subscribe("MouseOut",gInfoDlg,"clearTreeWithHover");
b.subscribe("Activate",this,"onBuddyTreeActivate")
}b.subscribe("ContextMenu",this,"onTreeContextMenu");
return b
};
this.createTreeGroup=function(d){var c=d.getId();
var b=new meeboApp.imGroupRow(d,c);
this.m_trees[c]=b;
b.setSortFunc(this.m_defaultSortMethod);
b.subscribe("ContextMenu",this,"onTreeContextMenu");
b.subscribe("Toggle",this,"onGroupTreeToggle");
b.subscribe("Activate",b,"toggle");
b.subscribe("MouseOver",gInfoDlg,"handleGroupOn");
return b
};
this.onBuddyTreeMouseOver=function(b,d){var c=gBuddyListDlg.m_buddyContextMenu;
if(!gBuddyListDlg.isPoppedOut()&&!gBuddyListDlg.m_tree.m_bDragging&&(!c||!c.isOpen())){gInfoDlg.setTreeWithHover(b)
}};
this.onBuddyTreeActivate=function(b){gInfoDlg.hideInfo()
};
this.onGroupTreeToggle=function(b,c){gPrefs.savePref("gn:"+b.getExtra().getName(),c)
};
this.onAddBuddyToGroup=function(f,c,e,g){var b=this.m_trees[g.getId()];
var h=e.getGroupId(g);
var d=this.createTreeItem(e,h);
if(!this.m_offlineGroup||e.isOnline()){b.insertItem(d)
}else{if(e.getGroups().length<=1){this.m_trees[this.m_offlineGroup.getId()].insertItem(d)
}}b.markRedraw();
this.showBuddyTreeChangeStatusFeedback(d)
};
this.updatePersistence=function(){var b=gLogon.getMeeboMeLogon();
if(!b){return
}var c=gBuddyList.getBuddies({protocol:b.getProtocol(),user:b.getName()});
if(!c.length){clearInterval(this.m_persistenceId);
this.m_persistenceId=-1
}c.foreach(function(e,d){this.updateBuddyPersistence(d)
},this)
};
this.updateBuddyPersistence=function(b){if(!b){return
}b.calcOnlineTime();
var c=gWindowMgr.getConvWindow(b);
if(c&&c.isVisible()){c.updateIMStatus()
}};
this.showBuddyMessageFeedback=function(d,c){if(d.getType()!="buddy"){return
}var f=d.getGroups();
for(var e=0,g;
(g=f[e]);
e++){var b=this.m_trees[d.getGroupId(g)];
if(b){b.showFeedback(c)
}}this.m_tree.redrawChildren();
meeboApp.updateStatusPanelIcon()
};
this.getTotalUnreadMessageCount=function(){var b=0;
gBuddyList.getBuddies({type:"buddy"}).foreach(function(e,d){var c=d.getConversation();
if(c){b+=c.getUnreadCount()
}});
return b
};
this.handleBuddyChangeStatusFeedback=function(){var c=new Date().getTime();
while(this.m_buddyStatusQueue.length){if(this.m_buddyStatusQueue[0].time>=c){return
}var b=this.m_buddyStatusQueue.shift().tree;
b.removeHeaderClassName("statusFeedback")
}};
this.showBuddyTreeChangeStatusFeedback=function(b){b.addHeaderClassName("statusFeedback");
this.m_buddyStatusQueue.push({tree:b,time:new Date().getTime()+7000})
};
this.clearBuddyTypingNotification=function(b){b.setTyping(0);
this.m_tree.redrawChildren()
};
this.onRemoveBuddyFromGroup=function(b,l,d,k){if(!d||!k){return
}var e=d.getGroupId(k);
var c=this.m_trees[e];
delete this.m_trees[e];
var g=this.m_trees[k.getId()];
if(this.m_offlineGroup){var h=this.m_trees[this.m_offlineGroup.getId()];
var f=d.getGroups()[0];
if(c.getParent()==h&&f){this.m_trees[d.getGroupId(f)].setNewParent(h)
}}c.getParent().deleteItem(c);
c.destroy();
g.markRedraw()
};
this.getTree=function(){return this.m_tree
};
this.getSelections=function(){return this.getTree().getSelectionModel().getSelections()
};
this.getNumSelections=function(){return this.getTree().getSelectionModel().getNumSelections()
};
this.getFirstSelection=function(){return this.getTree().getSelectionModel().getFirstSelection()
};
this.unselectAll=function(){this.getTree().getSelectionModel().unselectAll()
};
this.getSelectionTypesHash=function(){var c={};
var b=this.getSelections();
for(var d in b){var e=b[d].getType();
if(!c[e]){c[e]=0
}c[e]++
}return c
};
this.existsBlockedSelectedBuddy=function(c){var d=this.getSelections();
for(var e in d){var b=d[e].getExtra();
if(b.getType()=="buddy"&&b.isBlocked()==c&&b.getNetwork().supports("block")){return true
}}return false
};
this.saveState=function(){this.m_tree.uncreate();
var b={tree:this.m_tree,trees:this.m_trees,offlineGroup:this.m_offlineGroup,statusQueue:this.m_buddyStatusQueue,isOffline:this.m_isOffline,inNetworkInterrupt:this.m_inNetworkInterrupt,autoReconnectDelta:this.m_autoReconnectDelta,autoReconnectTime:this.m_autoReconnectTime};
return b
};
this.restoreState=function(c){this.m_trees=c.trees;
var b=this.m_tree.getElement();
b.parentNode.insertBefore(c.tree.create(this).getElement(),b);
removeElement(b);
this.m_tree=c.tree;
this.m_tree.m_element.className="maBlBuddies";
this.m_offlineGroup=c.offlineGroup;
this.m_buddyStatusQueue=c.statusQueue;
this.setOffline(c.isOffline);
this.m_inNetworkInterrupt=c.inNetworkInterrupt;
this.m_autoReconnectDelta=c.autoReconnectDelta;
if(c.isOffline){this.showDisconnectionOverlay(this.m_inNetworkInterrupt);
if(this.m_inNetworkInterrupt){this.autoReconnectIn(c.autoReconnectTime-new Date().getTime())
}}this.resize(this.getBody().offsetWidth,this.getBody().offsetHeight)
}
});
Class("meeboApp.notifyDlg",ui.element,function(a){this.initialize=function(){a(this,"initialize");
this.control="notifydlg";
this.m_onOK=new Array();
this.m_okBtn=null;
this.m_icon={src:"notifyBuddy.gif",w:32,h:26}
};
this.setDelegateParams=function(c,b){this.m_msg=c;
if(b){this.m_icon=b
}};
this.getTemplate=function(){return'<table border=0 cellspacing=4 cellpadding=0><tr			><td valign="top" id="notifyimg" width="32"></td><td class="uiDescr">'+this.m_msg+"</td></tr></table>"
};
this.addOnClose=function(b){if(b){this.m_dlg.m_onClose.push(b)
}};
this.addOnOK=function(b){if(b){this.m_onOK.push(b)
}};
this.onOK=function(){if(this.m_onOK){doFunctions(this.m_onOK)
}this.m_dlg.closeWindow()
};
this.initContent=function(){var c=this.m_element;
var d=getPartFromElement(this.m_element,"notifyimg");
d.appendChild(createImg("",d,this.m_icon.w,this.m_icon.h,this.m_icon.src,"",true,"middle",/\.png$/i.test(this.m_icon.src)));
this.m_okBtn=new ui.button("okbutton",gLang.okBtn).create(this.m_win);
this.m_okBtn.addClassName("buttonBottomAlign");
this.getElement().appendChild(this.m_okBtn.getElement());
this.connectContentEvents();
return true
};
this.handleKeyPress=function(c,b){if(!c){return true
}if(c.keyCode==13){this.onOK();
ui.setEventHandled(c);
return false
}if(c.keyCode==27){this.m_dlg.closeWindow();
ui.setEventHandled(c);
return false
}return true
};
this.connectContentEvents=function(){this.m_dlg.addOnKeyPress(this,"handleKeyPress");
this.m_okBtn.addOnMouseUp(hitch(this,"onOK"))
}
});
var landingPage={m_loginBoxHeight:132,getAnimation:function(){if(this.m_animation){return this.m_animation
}this.m_animation=new ui.Animation({duration:500,transition:ui.Animation.easeInOut});
this.m_animation.addSubject(hitch(this,"animate"));
this.m_animation.onfinished=hitch(this,"onAnimationFinished");
return this.m_animation
},show:function(d,c){if(this.m_selectedNetwork==d||!$(d+"loginbox")||this.m_isAnimating){return
}util.cookie.save("morenetworks",d);
if(d=="facebook"){gFBConnect.show(this)
}var b=this.m_selectedNetwork;
if(b&&$(b+"loginbox")){c=true
}removeClassName($("toggle-"+b),"selected");
addClassName($("toggle-"+d),"selected");
this.m_selectedNetwork=d;
var a=$(d+"loginbox");
if(c){if($(b+"loginbox")){$(b+"loginbox").style.display="none"
}a.style.height=this.m_loginBoxHeight+"px";
a.style.display="inline";
return
}a.style.height="1px";
a.style.display="inline";
this.m_isAnimating=true;
this.getAnimation().seekFromTo(0,1)
},animate:function(b){var a=$(this.m_selectedNetwork+"loginbox");
a.style.height=Math.ceil(this.m_loginBoxHeight*b)+"px";
$("loginboxescontent").className=$("loginboxescontent").className
},onAnimationFinished:function(){if(this.getAnimation().getState()==1){var a=$(this.m_selectedNetwork+"loginbox");
a.style.height=this.m_loginBoxHeight+"px"
}else{var a=$(this.m_selectedNetwork+"loginbox");
a.style.display="none";
this.m_selectedNetwork=null
}this.m_isAnimating=false
},hide:function(){var a=$(this.m_selectedNetwork+"loginbox");
if(this.m_isAnimating||!a){return
}util.cookie.erase("morenetworks");
removeClassName($("toggle-"+this.m_selectedNetwork),"selected");
if(this.m_selectedNetwork=="facebook"){gFBConnect.hide(this);
if(gFrontPage.m_facebookConnectLink){gFrontPage.m_facebookConnectLink.destroy();
gFrontPage.m_facebookConnectLink=null
}}this.m_isAnimating=true;
this.getAnimation().seekFromTo(1,0)
},toggle:function(a){if(this.m_selectedNetwork==a){this.hide()
}else{this.show(a)
}},focusIdInputOnClick:function(c,b){if(!gFrontPage.isRegistrationMode()){landingPage.highlightBox(b);
var a=b.getElementsByTagName("input")[0];
if(!landingPage.canFocus(c)&&a){a.select()
}}},canFocus:function(b){var c=b.target||b.srcElement;
c=c.nodeType==3?c.parentNode:c;
var a=/^(a|button|textarea|input|select|option)$/i;
return a.test(c.nodeName)
},highlightBox:function(a){if(typeof(a)=="string"){a=$(a)
}removeClassName(landingPage.selectedBox,"selectedBox");
landingPage.selectedBox=a;
addClassName(landingPage.selectedBox,"selectedBox")
}};
Class("meeboApp.skins",function(){this.initialize=function(){this.m_skins={skin1:{n:"Flat",p:"default"},skin2:{n:"Aqua",p:"aqua"},skin3:{n:"Brown",p:"brown"},skin4:{n:"Carbon",p:"carbon"},skin5:{n:gLang.greenSkin,p:"green"},skin6:{n:gLang.pinkSkin,p:"pink"},skin7:{n:gLang.purpleSkin,p:"purple"},skin8:{n:"Red",p:"red"},skin10:{n:gLang.currSkin,p:"beta"},skin9:{n:gLang.onyxSkin,p:"onyx"}};
this.m_defaultSkin="skin1";
for(var a in this.m_skins){if(this.m_skins[a].p==gImages.m_currentSkin){this.m_defaultSkin=a;
break
}}this.m_hasLoadedSkins=false
};
this.getSkin=function(a){return this.m_skins[a]||this.m_skins[this.m_defaultSkin]
};
this.getSkins=function(){return this.m_skins
};
this.setSkin=function(a){if(gImages.m_currentSkin==this.pathFromSkin(a)){return
}var b=!this.m_skins[a];
if(gPrefs.savePref("meeboSkin",a)){gNetworkMgr.doUILog("prefs","skin",a,false)
}var c=this.pathFromSkin(a);
gImages.setSkin(c);
gPubSub.publish(this,"meeboApp.skins::setSkin",a);
if(b){gPrefs.doPreferenceSync()
}};
this.nameFromSkin=function(a){return this.getSkin(a).n
};
this.pathFromSkin=function(a){return this.getSkin(a).p
}
});
Class("meeboApp.fontbar",ui.toolbar,function(a){this.initialize=function(k,d,b,g,f,e,h,c){a(this,"initialize",["small"]);
this.m_id=k;
this.m_cBtn=null;
this.m_eBtn=null;
this.m_mBtn=null;
this.m_animation=null;
this.m_sTooltip=null;
this.m_sTooltipShowing=false;
this.m_fontSizes=[8,10,11,12,14,16,20,24,36];
this.m_palette=null;
this.m_emoticonPalette=null;
this.m_isDisabled=false;
this.m_fontType=g||"Tahoma";
this.m_fontSize=f||"11";
this.m_bBold=e||false;
this.m_bItalics=h||false;
this.m_bUnderline=c||false;
this.m_className=b;
this.m_delegate=d;
gPubSub.subscribe("meeboApp.MediaBar::launchAd",this,"onLaunchAd")
};
this.setImDlg=function(b){this.m_dlg=b
};
this.getImDlg=function(){return this.m_dlg
};
this.createContent=function(){a(this,"createContent");
this.addClassName(this.m_className);
this.addClassName("FontBar");
this.getElement().id=this.m_id;
this.m_cBtn=this.addButton("color","color",gLang.fontStyle);
this.m_cBtn.addArrow(true);
disableSelection(this.m_cBtn.getElement(),true);
this.m_eBtn=this.addButton("emoticons","emoticon",gLang.emoticonTT);
this.m_eBtn.addArrow(true);
disableSelection(this.m_eBtn.getElement(),true);
this.m_cBtn.addOnMouseUp(hitch(this,"onFontPalette"));
this.m_eBtn.addOnMouseUp(hitch(this,"onEmoticonPalette"))
};
this.addMediaButton=function(){if(this.m_mBtn){return
}this.addButton(new ui.toolbarFlexibleSpace().create(this.m_win));
this.m_mBtn=this.addButton("add media","addmedia",gLang.addMediaTT);
this.m_mBtn.addOnMouseUp(hitch(this,"publish","Media"))
};
this.onFontPalette=function(b){if(this.m_dlg){this.m_dlg.callActivate()
}this.showFontPalette();
ui.setEventHandled(b)
};
this.onEmoticonPalette=function(b){if(this.m_dlg){this.m_dlg.callActivate()
}this.showEmoticonPalette();
ui.setEventHandled(b)
};
this.setPalettePos=function(b,d){var c=getElementPosition(b.m_element);
d.m_element.style.left=c.left+"px";
d.m_element.style.top=c.top-d.m_element.offsetHeight+"px"
};
this.closeAll=function(){if(this.m_palette){this.m_palette.hide()
}if(this.m_emoticonPalette){this.m_emoticonPalette.hide()
}};
this.showFontPalette=function(){if(this.m_cBtn.isDepressed()){this.closeAll();
return
}this.closeAll();
gNetworkMgr.doUILog("fontbar","click","font");
if(!this.m_palette){this.m_palette=new meeboApp.FontPalette(this.m_fontSizes,this.m_fontType,this.m_fontSize,this.m_bBold,this.m_bItalics,this.m_bUnderline);
this.m_palette.create(this.getId()+"-fontPalette",this.m_win.document.body,this.m_delegate,this.m_cBtn.m_element);
this.m_palette.addOnClose(hitch(this.m_cBtn,"setDepressed",false))
}this.setPalettePos(this.m_cBtn,this.m_palette);
this.m_palette.show();
this.m_cBtn.setDepressed(true)
};
this.showEmoticonPalette=function(){if(this.m_eBtn.isDepressed()){this.closeAll();
return
}this.closeAll();
gNetworkMgr.doUILog("fontbar","click","emoticon");
if(!this.m_emoticonPalette){this.m_emoticonPalette=new meeboApp.EmoticonPalette();
this.m_emoticonPalette.create(this.getId()+"-emoticonPalette",this.m_win.document.body,this.m_eBtn.m_element);
disableSelection(this.m_emoticonPalette.getElement(),true);
this.m_emoticonPalette.addOnEmoticon(hitch(this,"publish","Emoticon"));
this.m_emoticonPalette.addOnClose(hitch(this.m_eBtn,"setDepressed",false))
}this.m_emoticonPalette.setStyle("visibility","hidden");
this.m_emoticonPalette.show();
this.setPalettePos(this.m_eBtn,this.m_emoticonPalette);
this.m_emoticonPalette.setStyle("visibility","visible");
this.m_eBtn.setDepressed(true)
};
this.createShareLink=function(c){this.m_enableShareLink=true;
c=c||(gMediaBar&&gMediaBar.getLastLaunchedAd());
if(!c){return
}if(c.getProp("type")=="VideoEgg"){return
}if(this.m_shareLink){this.m_element.removeChild(this.m_shareLink);
this.m_shareLink=null
}this.m_shareLinkAd=c;
var b=this.m_win.document.createElement("div");
b.innerHTML=sprintf('<img path="share-icon.gif" align="left"><span>%1</span>',sprintf(gLang.shareLink,this.m_shareLinkAd.getProp("title")));
cacheImgs(b);
addClassName(b,"ShareLink");
this.m_element.appendChild(b);
ui.connectEvent(b,"mouseover",this,function(){b.style.textDecoration="underline";
this.showShareTooltip()
});
ui.connectEvent(b,"mouseout",this,function(){b.style.textDecoration="";
this.hideShareTooltip()
});
ui.connectEvent(b,"click",this,function(){this.publish("Share",meebo.util.generateMeeboShareLink(this.m_shareLinkAd.getProp("share")))
});
this.m_shareLinkWidth=b.offsetWidth;
this.m_shareLink=b;
this.resize(this.getElement().offsetWidth)
};
this.onLaunchAd=function(c,b,d){if(this.m_enableShareLink){this.createShareLink(d)
}};
this.setDisabled=function(b){this.m_isDisabled=b;
this.m_cBtn.setDisabled(b);
this.m_eBtn.setDisabled(b)
};
this.resize=function(b){if(!this.m_shareLink){return
}var c=this.m_eBtn.getElement().offsetLeft+this.m_eBtn.getElement().offsetWidth;
if(this.getElement().offsetWidth-c<this.m_shareLinkWidth){this.m_shareLink.style.left=c;
setText(this.m_shareLink.getElementsByTagName("span")[0],getTruncatedText(sprintf(gLang.shareLink,this.m_shareLinkAd.getProp("title")),this.getElement().offsetWidth-c-20,0,truncateEnd))
}else{this.m_shareLink.style.left="";
this.m_shareLink.style.right="0px";
setText(this.m_shareLink.getElementsByTagName("span")[0],sprintf(gLang.shareLink,this.m_shareLinkAd.getProp("title")))
}};
this.showShareTooltip=function(){clearTimeout(this.m_hideTooltipInterval);
if(this.m_tooltip&&this.m_tooltip.isVisible()){return
}if(!this.m_tooltip){this.m_tooltip=new meeboApp.ShareTooltip().create(this.m_win);
this.m_tooltip.setSticky(false)
}this.m_tooltip.setAd(this.m_shareLinkAd);
this.m_tooltip.showAt(this.m_shareLink,this.m_tooltip.BELOW)
};
this.hideShareTooltip=function(){if(!this.m_tooltip||!this.m_tooltip.isVisible()){return
}this.m_hideTooltipInterval=setTimeout(hitch(this,function(){this.m_tooltip.hide()
}),0)
}
});
Class("meeboApp.FontPalette",ui.element,function(a){this.initialize=function(f,e,d,c,g,b){this.m_element=null;
this.m_fontType=e;
this.m_fontSize=d;
this.m_bBold=c;
this.m_bItalics=g;
this.m_bUnderline=b;
this.m_specialFonts={LucidaHandwriting:"Cursive"};
this.m_fontSizes=f.slice();
this.m_fontColors=["#FFA6C9","#FF9900","#AAF200","#99EE99","#2EE5E5","#CC99CC","#990000","#FF8080","#FF6600","#00E500","#0099FF","#0000CC","#CC33CC","#666666","#FF00CC","#FF0000","#009900","#006600","#000080","#8000A0","#000000"];
this.createHandler("Close")
};
this.getFontName=function(b){var c=b.replace(/ /g,"");
if(this.m_specialFonts[c]){b=this.m_specialFonts[c]
}return b
};
this.create=function(e,d,c,b){this.m_id=e;
this.m_win=gWin(d);
this.m_delegate=c;
this.m_btnElement=b;
this.m_element=this.m_win.document.createElement("div");
this.addClassName("FontPalette");
this.m_element.id=this.m_id;
this.m_element.unselectable=true;
this.m_win.document.body.appendChild(this.m_element);
this.addColorSwatches();
this.addFontToolbar()
};
this.addColorSwatches=function(){var d=this.m_win.document.createElement("div");
addClassName(d,"ColorSwatch");
this.m_element.appendChild(d);
this.m_element.unselectable=true;
for(var e=0,c;
(c=this.m_fontColors[e]);
e++){var b=this.m_win.document.createElement("div");
addClassName(b,"Swatch");
b.style.background=c;
b.unselectable=true;
d.appendChild(b);
ui.connectEvent(b,"click",this.m_delegate,"setFontColor",false,false,c)
}};
this.addFontToolbar=function(){var b=new ui.toolbar("small").create(this.m_win).addClassName("FontToolbar");
b.getElement().id=this.m_id+"-fontToolbar";
this.m_element.appendChild(b.getElement());
this.m_boBtn=b.addButton("bold","bold",gLang.boldTT);
this.m_iBtn=b.addButton("italicize","italic",gLang.italicTT);
this.m_uBtn=b.addButton("underline","underline",gLang.underlineTT);
this.initSizeMenu(this.m_fontSize);
this.initTypeMenu(this.m_fontType);
if(this.m_bBold){this.m_boBtn.setDepressed(true)
}if(this.m_bItalics){this.m_iBtn.setDepressed(true)
}if(this.m_bUnderline){this.m_uBtn.setDepressed(true)
}this.m_boBtn.addOnMouseUp(hitch(this,"toggleBold"));
this.m_iBtn.addOnMouseUp(hitch(this,"toggleItalics"));
this.m_uBtn.addOnMouseUp(hitch(this,"toggleUnderline"));
this.m_sizeMenu.addSelectFunc(hitch(this,"handleFontSize"));
this.m_typeMenu.addSelectFunc(hitch(this,"handleFontType"));
this.m_sizeMenu.addCloseFunc(hitch(this,"connectPaletteEvents"));
this.m_typeMenu.addCloseFunc(hitch(this,"connectPaletteEvents"))
};
this.initSizeMenu=function(c){this.m_sizeMenu=new ui.menuheader(this.m_id+"sizemenu",String(c),40,40,"left",16,false);
this.m_sizeMenu.setDelayMenu(true);
this.m_sizeMenu.create(this.m_win).addClassName("SizeMenu");
$(this.getId()+"-fontToolbar").appendChild(this.m_sizeMenu.getElement());
for(var b=0;
b<this.m_fontSizes.length;
b++){this.m_sizeMenu.addMenuItem(String(this.m_fontSizes[b]),"")
}};
this.initTypeMenu=function(c){var b=this.getFontName(c);
this.m_typeMenu=new ui.menuheader(this.m_id+"typemenu",b,72,72,"left",16,false,c);
this.m_typeMenu.setDelayMenu(true);
this.m_typeMenu.create(this.m_win).addClassName("TypeMenu");
$(this.m_id+"-fontToolbar").appendChild(this.m_typeMenu.getElement());
this.m_typeMenu.addMenuItem("Arial","","Arial");
this.m_typeMenu.addMenuItem("Arial Black","","Arial Black");
this.m_typeMenu.addMenuItem("Century Gothic","","Century Gothic");
this.m_typeMenu.addMenuItem("Comic Sans MS","","Comic Sans MS");
this.m_typeMenu.addMenuItem("Courier","","Courier");
this.m_typeMenu.addMenuItem("Cursive","","Lucida Handwriting");
this.m_typeMenu.addMenuItem("Georgia","","Georgia");
this.m_typeMenu.addMenuItem("Papyrus","","Papyrus");
this.m_typeMenu.addMenuItem("Tahoma","","Tahoma");
this.m_typeMenu.addMenuItem("Times","","Times");
this.m_typeMenu.addMenuItem("Verdana","","Verdana");
this.m_typeMenu.setMenuMax(this.m_typeMenu.m_numItems)
};
this.show=function(){this.m_element.style.zIndex=gWindowMgr.getNextZIndex();
this.m_element.style.visibility="visible";
this.connectPaletteEvents()
};
this.hide=function(){this.m_element.style.visibility="hidden";
this.onClose();
ui.disconnectGlobalEvent(gDoc(this.m_win),"mousedown");
ui.disconnectGlobalEvent(gDoc(this.m_win),"mouseup")
};
this.connectPaletteEvents=function(){ui.connectGlobalEvent(gDoc(this.m_win),"mousedown",hitch(this,"onGlobalClick"));
ui.connectGlobalEvent(gDoc(this.m_win),"mouseup",hitch(this,"onGlobalClick"))
};
this.onGlobalClick=function(b){if(!isCursorInElement(this.m_element,b)&&!isCursorInElement(this.m_btnElement,b)){this.hide();
ui.setEventHandled(b)
}if(b.type=="mousedown"){ui.setEventHandled(b);
return false
}};
this.handleFontType=function(b,c){this.m_delegate.setFontType(b,c)
};
this.handleFontSize=function(b){this.m_delegate.setFontSize(b)
};
this.toggleBold=function(){this.setBold(!this.m_bBold);
this.m_delegate.setBold(this.m_bBold)
};
this.toggleItalics=function(){this.setItalics(!this.m_bItalics);
this.m_delegate.setItalics(this.m_bItalics)
};
this.toggleUnderline=function(){this.setUnderline(!this.m_bUnderline);
this.m_delegate.setUnderline(this.m_bUnderline)
};
this.setFontType=function(c){var b=this.getFontName(c);
this.m_typeMenu.setTitle(b,c,true)
};
this.setFontSize=function(b){this.m_sizeMenu.setTitle(b,b,true)
};
this.setBold=function(b){this.m_bBold=b;
this.m_boBtn.setDepressed(b)
};
this.setItalics=function(b){this.m_bItalics=b;
this.m_iBtn.setDepressed(b)
};
this.setUnderline=function(b){this.m_bUnderline=b;
this.m_uBtn.setDepressed(b)
}
});
Class("meeboApp.SharePalette",ui.element,function(a){this.initialize=function(){a(this,"initialize");
this.createHandler("Share");
this.createHandler("Close")
};
this.create=function(e,c,b){this.m_id=e;
this.m_win=gWin(c);
this.m_btnElement=b;
var d=this.m_win.document.createElement("div");
d.id=this.getId()+"-ruler";
addClassName(d,"SharePalette");
this.m_win.document.body.appendChild(d);
this.m_element=this.m_win.document.createElement("div");
this.addClassName("SharePalette");
this.m_element.id=this.m_id;
this.m_win.document.body.appendChild(this.m_element)
};
this.addShareItem=function(c,b,n,g,h){var d=this.m_win.document.createElement("div");
addClassName(d,"Item");
var f=Math.floor(new Date().getTime()/1000),k=g||f,m=Math.max(f-k,0),e=h==1?gLang.viewedAgo:gLang.sharedAgo;
if(n&&!m){time=gLang.sponsored
}else{if(!n&&!m){time=gLang.viewingNow
}else{time=sprintf(e,getTimeString(m,true))
}}var c=c||b.replace(/^https?:\/\//i,"");
var l=getTruncatedText(c,190,null,truncateMiddle,$(this.getId()+"-ruler"));
d.innerHTML='<div class="Title" title="'+escapeHTML(b)+'">'+l+'</div><div class="Time">'+time+"</div>";
this.m_element.appendChild(d);
ui.connectEvent(d,"click",this,"onClickShare",false,false,c,b,n);
ui.connectEvent(d,"mouseover",window,"addClassName",false,false,d,"ItemHover");
ui.connectEvent(d,"mouseout",window,"removeClassName",false,false,d,"ItemHover");
return d
};
this.populateShares=function(){removeChildren(this.m_element);
var f=this.m_win.document.createElement("div");
f.id=this.getId()+"-info";
addClassName(f,"Info");
setText(f,gLang.recentLinksInfo);
this.m_element.appendChild(f);
var e=gMediaBar&&gMediaBar.getAd();
if(e&&e.getProp("isSharable")){var b=e&&meebo.util.generateMeeboShareLink(e.getProp("share"))
}var g=meeboApp.share.getRecentlyViewed();
for(var c=Math.min(5,g.length-1);
c>=0;
c--){if(b==g[c].url){continue
}this.addShareItem(g[c].name,g[c].url,g[c].sponsored,g[c].eventtime,g[c].accesstype)
}if(e&&e.getProp("isSharable")){var d=this.addShareItem(e.getProp("title"),b,true,0);
addClassName(d,"ItemSponsored")
}};
this.show=function(){this.m_element.style.zIndex=gWindowMgr.getNextZIndex();
this.m_element.style.visibility="visible";
ui.connectGlobalEvent(gDoc(this.m_win),"mousedown",hitch(this,"onGlobalClick"));
ui.connectGlobalEvent(gDoc(this.m_win),"mouseup",hitch(this,"onGlobalClick"))
};
this.hide=function(){this.m_element.style.visibility="hidden";
this.onClose();
ui.disconnectGlobalEvent(gDoc(this.m_win),"mousedown");
ui.disconnectGlobalEvent(gDoc(this.m_win),"mouseup")
};
this.onGlobalClick=function(b){if(!isCursorInElement(this.m_element,b)&&!isCursorInElement(this.m_btnElement,b)){this.hide();
return true
}if(b.type=="mousedown"){ui.setEventHandled(b);
return false
}};
this.onClickShare=function(d,c,b){this.onShare(d,c,b);
this.hide()
};
this.onClickCloseInfo=function(){var c=$(this.getId()+"-info");
if(!c){return
}var b=parseInt(getCSSProp(c,"margin-top"),10);
this.getElement().style.top=this.getElement().offsetTop+c.offsetHeight+(b*2)+"px";
removeElement(c)
}
});
Class("meeboApp.EmoticonPalette",ui.imagemap,function(a){this.initialize=function(){a(this,"initialize");
this.m_emoticons=[[":)",":D","B)",":>","(pirate)"],[";)","(lol)",":P",";P",":S"],[":-*",":O",":|",":T",":x"],["(sad)",":'D",":<",":\\","(hmm)"],["(emo)","(rapper)",":)>-","(ninja)","(skull)"],["(pacman)","(ghost)","(m)","(panda)",":@)"]];
this.m_xTop=2;
this.m_yTop=3;
this.m_xSpace=29;
this.m_ySpace=22;
this.m_emoticonW=26;
this.m_emoticonH=18;
this.createHandler("Emoticon")
};
this.create=function(d,c,b){this.m_id=d;
this.m_win=gWin(c);
a(this,"create",[d,c,b,"epalette.png",152,141]);
this.setStyle("position","absolute");
this.addSwatches()
};
this.addSwatches=function(){for(var e=0,f;
(f=this.m_emoticons[e]);
e++){var b=this.m_xTop;
var g=this.m_yTop+this.m_ySpace*e;
for(var c=0,d;
(d=f[c]);
c++){this.addRegion(b,g,b+this.m_emoticonW,g+this.m_emoticonH,hitch(this,"onEmoticon",d));
b+=this.m_xSpace
}}}
});
Class("meeboApp.mediaList",ui.element,function(a){this.initialize=function(){this.m_mediaTable=null;
this.m_mediaList=[];
this.m_mediaItems={};
this.m_defaultSize=50;
this.m_selectedItem=null;
this.m_playIcon=null;
this.createHandler("MediaChange")
};
this.create=function(e,c){var d=gWin(c);
var b=d.document.createElement("div");
b.id=e;
this.init(c.appendChild(b))
};
this.init=function(b){this.m_element=b;
this.m_win=gWin(b);
this.m_id=b.id;
this.m_mediaTable=this.m_element.appendChild(this.m_win.document.createElement("table"));
this.m_mediaTable.insertRow(-1);
this.addClassName("meeboMediaList")
};
this.addMedia=function(b){var g=this.normalizeUrl(b.itemUrl);
if(this.m_mediaItems[g]){return this.m_mediaItems[g]
}b.idx=this.m_mediaList.length;
this.m_mediaList.push(b);
this.m_mediaItems[g]=b;
if(!this.m_element){return b
}var f=this.m_element.scrollLeft+this.m_element.offsetWidth>=this.m_element.scrollWidth;
var k=this.m_mediaTable.rows[0].insertCell(-1);
var h=this.m_win.document.createElement("div");
h.style.position="relative";
k.appendChild(h);
var d=b.description.length?b.description:b.itemUrl;
if(b.thumbnailUrl){h.appendChild(createImg(getUniqueId(),this.getElement(),this.m_defaultSize,this.m_defaultSize,b.thumbnailUrl,d,false,null,false))
}else{h.style.width=h.style.height="50px"
}var c=b.type+"-frame.gif";
if(!b.thumbnailUrl&&b.type=="video"){c="video-frame-missing.gif"
}var e=h.appendChild(createImg(getUniqueId(),this.getElement(),this.m_defaultSize+2,this.m_defaultSize+2,c,d,true));
e.style.position="absolute";
e.style.top=e.style.left="-1px";
if(f){this.m_element.scrollLeft=this.m_element.scrollWidth-this.m_element.offsetWidth
}ui.connectEvent(k,"click",this,"onMediaChange",false,false,b);
return b
};
this.getMediaItemByUrl=function(b){return this.m_mediaItems[this.normalizeUrl(b)]
};
this.getMediaItemByIdx=function(b){return this.m_mediaList[b]
};
this.deleteMediaItemByUrl=function(b){var c=this.getMediaItemByUrl(b);
if(c){this.deleteMediaItemByIdx(c.idx)
}};
this.deleteMediaItemByIdx=function(c){if(this.m_mediaList[c]){if(this.m_mediaTable){this.m_mediaTable.rows[0].deleteCell(c)
}delete this.m_mediaItems[this.normalizeUrl(this.m_mediaList[c].itemUrl)];
this.m_mediaList.splice(c,1);
for(var b=0;
b<this.m_mediaList.length;
b++){this.m_mediaList[b].idx=b
}if(ui.isFirefox){this.m_mediaTable.parentNode.appendChild(this.m_mediaTable)
}}};
this.getNumMediaItems=function(){return this.m_mediaList.length
};
this.getMediaList=function(){return this.m_mediaList
};
this.restoreMediaList=function(b){for(var c=0;
c<b.length;
c++){this.addMedia(b[c])
}};
this.setPos=function(b,f,c,d){if(!this.m_element){return
}var e=this.m_element.scrollLeft+this.m_element.offsetWidth>=this.m_element.scrollWidth;
a(this,"setPos",arguments);
if(e){this.m_element.scrollLeft=this.m_element.scrollWidth-this.m_element.offsetWidth
}};
this.selectItem=function(b){if(!this.m_mediaTable){return
}if(this.m_selectedItem){this.m_selectedItem.isSelected=false;
removeClassName(this.m_mediaTable.rows[0].cells[this.m_selectedItem.idx],"selected");
this.m_selectedItem=null
}var c;
if(!b||!(c=this.getMediaItemByUrl(b))){return
}this.m_selectedItem=c;
c.isSelected=true;
var e=this.m_mediaTable.rows[0].cells[c.idx];
addClassName(e,"selected");
var d=e.offsetLeft;
if(d<this.m_element.scrollLeft){this.m_element.scrollLeft=d
}else{if(d>this.m_element.scrollLeft+this.m_element.offsetWidth){this.m_element.scrollLeft=((d+e.offsetWidth)-this.m_element.offsetWidth)
}}};
this.selectRoomItem=function(b){if(this.m_playIcon){removeElement(this.m_playIcon)
}if(!this.m_playIcon){this.m_playIcon=createImg(getUniqueId(),this.m_selectedItem,23,16,"group-sync.gif","",true);
this.m_playIcon.style.position="absolute";
this.m_playIcon.style.top="36px";
this.m_playIcon.style.left="28px"
}var c=this.getMediaItemByUrl(b);
if(!c){return
}var d=this.m_mediaTable.rows[0].cells[c.idx];
d.firstChild.appendChild(this.m_playIcon)
};
this.saveScrollPos=function(){if(this.m_element){this.m_scrollPos=(this.m_element.scrollLeft/this.m_element.scrollWidth)
}};
this.restoreScrollPos=function(b){if(this.m_element){this.m_element.scrollLeft=Math.round(this.m_element.scrollWidth*this.m_scrollPos)
}};
this.normalizeUrl=function(b){if(!(/^http|^\//i).test(b)){b="http://"+b
}b=b.replace(/\/*$/i,"");
return b
}
});
Class("meeboApp.MediaListItem",function(){this.initialize=function(a){if(!a){return
}this.thumbnailUrl=a.thumbnailUrl;
this.mediaUrl=a.mediaUrl;
this.itemUrl=a.itemUrl;
this.clickUrl=a.clickUrl;
this.type=a.type;
this.length=a.length;
this.description=a.description||"";
this.watermark=a.watermark;
this.trackingUrl=a.trackingUrl;
this.isDefaultMedia=a.isDefaultMedia;
this.isSelected=false;
if(this.type=="page"){this.thumbnailUrl=this.mediaUrl=(window.location.protocol=="https:"?"https://origin-":"http://")+"images.meebo.com/image/unsupported.png";
this.clickUrl=this.itemUrl;
this.watermark=""
}}
});
meeboApp.MediaListItem.fromEvent=function(a){return new meeboApp.MediaListItem({thumbnailUrl:a.d.t,mediaUrl:a.d.m,itemUrl:a.message,clickUrl:a.d.click_url||a.message,type:a.d.type,length:a.d.l,description:a.d.d,watermark:a.d.w,trackingUrl:a.d.tracking_url,isDefaultMedia:false})
};
meeboApp.MediaListItem.fromChatLog=function(a){return new meeboApp.MediaListItem({thumbnailUrl:a.t,mediaUrl:a.m,itemUrl:a.s,clickUrl:a.click_url||a.s,type:a.type,length:a.l,description:a.d,watermark:a.w,trackingUrl:a.tracking_url,isDefaultMedia:false})
};
Class("meeboApp.MediaBar",ui.element,function(a){this.initialize=function(){a(this,"initialize");
this.m_id=getUniqueId()+"-MediaBar";
this.m_minTabW=100;
this.m_animation=new ui.Animation({transition:ui.Animation.easeInOut,duration:400});
this.m_animation.addSubject(hitch(this,"animate"));
this.m_lAnimation=new ui.Animation({transition:ui.Animation.easeInOut,duration:1000});
this.m_lAnimation.addSubject(hitch(this,"animateLeaderboard"));
this.m_minHeight=25;
this.m_midHeight=116;
this.m_maxHeight=this.m_defaultMaxHeight=510;
this.m_maxHeightVideoEgg=460;
this.m_leaderboardHeight=90;
this.m_startHeight=this.m_minHeight;
this.m_animationStart=0;
this.m_animationEnd=0;
this.m_lastState=this.m_state=this.m_nextState=this.m_startHeight;
this.m_ad=null;
this.m_lastLaunchedAd=null;
this.m_mediaBarAd=null;
this.m_bodyDiv=null;
this.m_leaderboardDiv=null;
gPubSub.subscribe("meebo.EventMgr::changeState",this,"onEventMgrChangeState")
};
this.setAdJustLaunched=function(b){this.m_adJustLaunched=b
};
this.getAdJustLaunched=function(){return this.m_adJustLaunched
};
this.getLastLaunchedAd=function(){return this.m_lastLaunchedAd
};
this.clearLastLaunchedAd=function(){this.m_lastLaunchedAd=null
};
this.getGalleryTop=function(){return this.getElement().offsetHeight
};
this.getZIndex=function(){return parseInt(this.m_element.style.zIndex)
};
this.getAd=function(){return this.m_ad
};
this.setAd=function(c,b){if(this.m_am){this.m_am.destroy();
this.m_am=null
}this.m_ad=c;
if(c.getProp("height")){this.m_maxHeight=c.getProp("height")+110
}else{this.m_maxHeight=this.m_defaultMaxHeight
}if(!this.m_bodyDiv){return
}gNetworkMgr.doRequest("getrotate",{shareid:this.m_ad.share});
this.renderLeaderboard(b)
};
this.isMaximized=function(){return this.m_state==this.m_maxHeight||this.m_state==this.m_maxHeightVideoEgg
};
this.isMinimized=function(){return this.m_state==this.m_minHeight
};
this.isMidimized=function(){return this.m_state==this.m_midHeight
};
this.create=function(b){this.m_win=gWin(b||this.m_win);
if(!this.m_element){this.m_element=this.m_win.document.createElement("div");
this.m_element.id=this.getId();
if(b){b.appendChild(this.m_element)
}}this.m_element.style.zIndex=2
};
this.initContent=function(){this.addClassName("MediaBar");
this.addClassName("MediaBarEmpty");
this.m_element.style.height=this.m_state+"px";
this.m_frameDiv=this.m_element.appendChild(this.m_win.document.createElement("div"));
this.m_frameDiv.innerHTML='<table cellpadding="0" cellspacing="0"><tr>			<td class="tl"><br/></td>			<td class="tm">&nbsp;<br/></td>			<td class="tr"><br/></td></tr><tr>			<td class="bl"><br/></td>			<td class="bm">&nbsp;<br/></td>			<td class="br"><br/></td></tr>			</table>';
addClassName(this.m_frameDiv,"Frame");
util.css.setOpacity(this.m_frameDiv,0.8);
this.m_topBar=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_topBar,"TopBar");
this.m_rollOverUpsell=this.m_topBar.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_rollOverUpsell,"Upsell");
this.m_rollOverUpsell.innerHTML='<div class="roll-l"></div>			<div class="roll-m">rollover to expand</div>			<div class="roll-r"></div>';
this.m_adUpsell=this.m_topBar.appendChild(this.m_win.document.createElement("span"));
addClassName(this.m_adUpsell,"AdUpsell");
this.m_bodyDiv=this.m_element.appendChild(this.m_win.document.createElement("div"));
this.m_bodyDiv.className="Body";
this.createLeaderboardContainer();
var b=this.m_leaderboardDiv.appendChild(this.m_win.document.createElement("div"));
addClassName(b,"LeaderboardBorder");
b.innerHTML="&nbsp;";
util.css.setOpacity(b,0.8);
this.m_arrowBtn=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_arrowBtn,"Arrow");
ui.connectEvent(this.getElement(),"mousedown",this,"moveToTop",false,false);
ui.connectEvent(this.m_adUpsell,"click",this,"doToggle",false,false);
ui.connectEvent(this.m_adUpsell,"mouseover",window,"addClassName",false,false,this.m_adUpsell,"AdUpsellHover");
ui.connectEvent(this.m_adUpsell,"mouseout",window,"removeClassName",false,false,this.m_adUpsell,"AdUpsellHover");
ui.connectEvent(this.m_arrowBtn,"mouseover",window,"addClassName",false,false,this.m_arrowBtn,"ArrowHover");
ui.connectEvent(this.m_arrowBtn,"mouseout",window,"removeClassNames",false,false,this.m_arrowBtn,"ArrowHover","ArrowPress");
ui.connectEvent(this.m_arrowBtn,"mousedown",window,"addClassName",false,false,this.m_arrowBtn,"ArrowPress");
ui.connectEvent(this.m_arrowBtn,"mouseup",this,"onClickArrow",false,false,true);
ui.connectEvent(this.m_rollOverUpsell,"mouseover",this,"onRollOverLeaderboard");
ui.connectEvent(this.m_rollOverUpsell,"mouseout",this,"onRollOutLeaderboard");
ui.connectEvent(this.m_rollOverUpsell,"click",this,"onClickRollOverUpsell",false,false);
this.m_lastState=this.m_state=this.m_startHeight;
if(this.m_ad){this.setAd(this.m_ad)
}this.onResize();
return true
};
this.createLeaderboardContainer=function(){this.m_leaderboardDiv=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_leaderboardDiv,"LeaderboardContainer");
var e=this.m_win.document.createElement("div");
e.id=this.getId()+"-ad";
addClassName(e,"Ad");
this.m_leaderboardDiv.appendChild(e);
var d=this.m_win.document.createElement("div");
d.id=this.getId()+"-leaderboard";
e.appendChild(d);
this.m_rolloverIdx=Math.floor(Math.random()*gRollovers.length);
var b=this.m_win.document.createElement("div");
b.id=this.getId()+"-rollover";
addClassName(b,"Rollover");
b.innerHTML='<iframe src="'+gRollovers[this.m_rolloverIdx]+'" width="728" height="90"			style="position: absolute; left: 0px; top: 0px;" frameborder="0"			allowtransparency="true" id="'+this.getId()+'-rollIframe"></iframe>';
e.appendChild(b);
var c=this.m_win.document.createElement("div");
c.id=this.getId()+"-leaderboardOverlay";
addClassName(c,"LeaderboardOverlay");
c.innerHTML='<img path="blank.gif" width="100%" height="100%">';
e.appendChild(c);
cacheImgs(c);
ui.connectEvent(c,"mouseover",this,"onRollOverLeaderboard");
ui.connectEvent(c,"mouseout",this,"onRollOutLeaderboard");
ui.connectEvent(c,"click",this,"onClickLeaderboard")
};
this.createLeaderboard=function(b){var c=this.m_ad.getProp("leaderboard") instanceof Array?this.m_ad.getProp("leaderboard"):[this.m_ad.getProp("leaderboard")],e=c[b||0];
var f=document.createElement("div");
var d="";
if(e.search(/\.swf$/i)!=-1){d='<embed src="'+e+'" width="728"				height="90" wmode="transparent">'
}else{if(this.m_ad.getProp("type")=="bulk"){d='<iframe src="'+e+'" width="728"					height="90" frameborder="0"></iframe>'
}else{if(this.m_ad.getProp("type")=="VideoEgg"){}else{if(e.search(/\.html$/i)!=-1){d='<iframe src="'+e+'" width="728"					height="90" frameborder="0"></iframe>'
}else{d='<img border="0" src="'+e+'">';
if(!this.m_ad.getProp("engaged")){d='<a href="'+this.m_ad.getProp("click")+'" target="_blank">'+d+"</a>"
}}}}}f.innerHTML=d;
addClassName(f,"Leaderboard");
return f
};
this.onClickRollOverUpsell=function(){if(!this.m_ad){return
}if(VideoEgg.takeoverAction){VideoEgg.takeoverAction.show()
}else{this.launchAd(this.m_ad,"adupsell")
}};
this.moveToTop=function(){gWindowMgr.deactivateWindows();
if(this.isMaximized()){var b=gWindowMgr.getNextZIndex();
this.m_element.style.zIndex=b;
gWindowMgr.m_currentZindex=b+i
}};
this.onLoadMediaBar=function(b){this.setAd(b);
b.trackImpression();
if(ui.Wallpaper.getCurrentUrl()&&ui.Wallpaper.getCurrentUrl()==gTakeover.livepaper){if(this.m_ad.getProp("share")==gTakeover.share){ui.Wallpaper.getCurrentEl().animate()
}else{ui.Wallpaper.getCurrentEl().setStickyHotspot(-1)
}}};
this.renderLeaderboard=function(c){this.m_adUpsell.style.display=this.m_ad.getProp("type")=="VideoEgg"?"none":"";
removeChildren($(this.getId()+"-leaderboard"));
if(this.m_ad.getProp("leaderboardColor")){this.m_leaderboardDiv.style.backgroundColor="#"+this.m_ad.getProp("leaderboardColor")
}if(this.m_ad.getProp("type")=="VideoEgg"){if(typeof videoegg=="undefined"){return
}var h=$(this.getId()+"-leaderboard");
var b=this.m_win.document.createElement("div");
b.id=this.getId()+"-videoEgg";
addClassName(b,"VideoEgg");
h.appendChild(b);
var g=gTargeting.getTargeting();
var e=hitch(gAdServer,"load",{type:"MediaBarHouse",callback:hitch(this,"onLoadMediaBar")});
var f="meebodisplay";
if(gConfig.getReleaseType()=="stage"){f="testpublisher"
}var d={publisher:f,site:"meebodisplay",area:"meebodisplay",width:728,height:90,loops:1,parentElement:b.id,takeover:VideoEgg.CustomTakeover,takeoverAction:VideoEgg.CustomTakeoverAction,ve_a:g.age,ve_g:g.gender,alternate:e};
if(this.m_ad.getProp("area")){d.area=this.m_ad.getProp("area")
}this.m_am=new videoegg.AdManager(d)
}else{$(this.getId()+"-leaderboard").appendChild(this.createLeaderboard(c));
VideoEgg.takeover=null;
VideoEgg.takeoverAction=null
}this.m_rollOverUpsell.style.display=this.m_ad.getProp("type")!="bulk"?"block":"none";
gPubSub.unsubscribe("ui.drag::startResize",this);
gPubSub.unsubscribe("ui.drag::startMove",this);
gPubSub.unsubscribe("ui.drag::stopResize",this);
gPubSub.unsubscribe("ui.drag::stopMove",this);
if(this.m_ad.getProp("type")=="VideoEgg"){gPubSub.subscribe("ui.drag::startResize",this,hitch(this,"showOverlay",true));
gPubSub.subscribe("ui.drag::startMove",this,hitch(this,"showOverlay",true));
gPubSub.subscribe("ui.drag::stopResize",this,hitch(this,"showOverlay",false));
gPubSub.subscribe("ui.drag::stopMove",this,hitch(this,"showOverlay",false))
}this.showRollOver(this.m_ad.getProp("type")!="VideoEgg"&&this.m_ad.getProp("type")!="bulk"&&this.m_ad.getProp("engaged"));
this.showOverlay(this.m_ad.getProp("type")!="VideoEgg"&&this.m_ad.getProp("type")!="bulk"&&this.m_ad.getProp("engaged"));
if(this.m_ad.getProp("type")==meebo.APP_TYPE_LeaderBoard){this.m_ad.setProp("share",this.m_ad.getProp("app").share)
}this.m_leaderboardDiv.style.width=this.getElement().offsetWidth-4+"px";
if(this.m_state==this.m_minHeight){setText(this.m_adUpsell,this.m_ad.getProp("description"))
}if(this.hasClassName("MediaBarEmpty")){this.doToggle();
this.removeClassName("MediaBarEmpty")
}};
this.fadeLeaderboard=function(){var d=$(this.getId()+"-leaderboard");
if(this.m_lAnimation.isAnimating()){while(d.childNodes.length>2){d.removeChild(d.firstChild)
}}var c=d.childNodes[0],b=d.childNodes[1];
this.m_lAnimation.onfinished=hitch(this,function(){c.parentNode.removeChild(c)
});
this.m_lAnimation.pause();
this.m_lAnimation.removeSubject();
this.m_lAnimation.addSubject(hitch(this,"animateLeaderboard",c,b));
this.m_lAnimation.seekFromTo(0,1)
};
this.animateLeaderboard=function(c,b,d){util.css.setOpacity(c,1-d);
util.css.setOpacity(b,d)
};
this.getRollOverIFrame=function(){var b=$(this.getId()+"-rollover"),c=$(this.getId()+"-rollIframe");
if(!b||b.style.display=="none"||!c){return
}return(!ui.isWebKit?c.contentWindow:c.contentDocument.parentWindow)
};
this.onRollOverLeaderboard=function(){if(!window.m_focus){return
}var b=this.getRollOverIFrame();
if(b&&b.onRollOver){b.onRollOver()
}};
this.onRollOutLeaderboard=function(){var b=this.getRollOverIFrame();
if(b&&b.onRollOut){b.onRollOut()
}};
this.showRollOver=function(b){var c=$(this.getId()+"-rollover");
if(c){c.style.display=b?"block":"none"
}};
this.showOverlay=function(b){var c=$(this.getId()+"-leaderboardOverlay");
if(c){c.style.display=b?"block":"none"
}};
this.onClickLeaderboard=function(){gNetworkMgr.doUILog("mediabar","leaderboard","click-"+gSounds.isMuted(),true);
this.launchAd()
};
this.launchAd=function(d,c){gNetworkMgr.doUILog("mediabar","leaderboard","launch-"+gSounds.isMuted(),true);
d=d||this.m_ad;
if(gEventMgr.getState()!="im"){return gWindowMgr.createReconnectDlg()
}var f=this.m_lastLaunchedAd?this.m_lastLaunchedAd.title:d.getProp("title");
this.m_lastLaunchedAd=d;
this.setAdJustLaunched(true);
gPubSub.publish(this,"meeboApp.MediaBar::launchAd",d);
if(this.isMaximized()){var e=gWindowMgr.createOkDlg({id:getUniqueId(),caption:sprintf(gLang.replaceAd,f),bReconnectDlg:false},sprintf(gLang.viewingWillReplace,d.getProp("title")),hitch(this,"createMediaBarAd",d,c),null,"Ok",null,"notifyBuddy.gif")
}else{var b=this.createMediaBarAd(d,c);
return d.getProp("type")=="VideoEgg"?b:null
}};
this.createMediaBarAd=function(d,c){d=d||this.m_ad;
if(c){gNetworkMgr.doUILog("mediabar","click",c+"-"+d.getProp("share"),true)
}if(d.getProp("isSharable")){var b=meebo.util.generateMeeboShareLink(d.getProp("share"));
meeboApp.share.saveLink(b,d.getProp("title"),true)
}var e=null;
this.m_mediaBarAd=new meeboApp.MediaBarAd(d);
this.m_mediaBarAd.create(this.m_bodyDiv);
this.seek(d.getProp("type")=="VideoEgg"?this.m_maxHeightVideoEgg:this.m_maxHeight);
this.m_bodyDiv.style.width=this.getElement().offsetWidth-4+"px";
return this.m_mediaBarAd
};
this.doToggle=function(b){var c=gEventMgr.getState();
if(this.isMinimized()){if(c!="im"){return gWindowMgr.createReconnectDlg()
}this.seek(this.m_midHeight);
gNetworkMgr.doUILog("mediabar","expandToMedium",this.m_ad.getProp("share"),true)
}else{if(this.isMidimized()){this.seek(this.m_minHeight);
if(b){this.m_ad.track({type:"minimize"})
}}else{if(c=="im"){this.seek(this.m_lastState)
}else{this.seek(this.m_minHeight)
}gNetworkMgr.doUILog("mediabar","reduceToMedium",this.m_ad.getProp("share"),true);
this.m_ad.track({type:"close"});
this.m_ad.setProp("customUserParams",null);
this.m_ad.setProp("customTitle",null)
}}};
this.seek=function(c,b){if(this.m_state!=this.m_nextState){return
}this.m_nextState=c;
if(this.m_state!=c){this.m_lastState=this.m_state
}this.m_onWipe=b||null;
if(this.m_state==this.m_minHeight){this.onWipe(c);
this.seekHeight(c)
}else{this.seekHeight(this.m_minHeight)
}};
this.seekHeight=function(c,d){this.m_animation.onfinished=d?null:hitch(this,"onAnimationFinished",c);
var b=Math.min(c,ui.getClientRect(this.m_win).h);
if(c==this.m_maxHeight){this.m_bodyDiv.style.height=b-this.m_topBar.offsetHeight+1+"px"
}this.m_animationStart=this.getElement().offsetHeight;
this.m_animationEnd=b;
this.m_animation.seekFromTo(1,0)
};
this.onWipe=function(b){switch(b){case this.m_minHeight:if(this.m_ad){setText(this.m_adUpsell,this.m_ad.getProp("description"))
}this.m_element.style.zIndex=2;
this.addClassName("MediaBarMin");
this.removeClassName("MediaBarMax");
removeChildren(this.m_bodyDiv);
gAdTimer.pauseRotation();
break;
case this.m_midHeight:this.m_element.style.zIndex=2;
this.removeClassName("MediaBarMin");
this.removeClassName("MediaBarMax");
removeChildren(this.m_bodyDiv);
gAdTimer.resumeRotation();
break;
case this.m_maxHeight:case this.m_maxHeightVideoEgg:setText(this.m_adUpsell,gLang.clickToClose);
this.m_element.style.zIndex=gWindowMgr.getNextZIndex();
this.removeClassName("MediaBarMin");
this.addClassName("MediaBarMax");
this.moveToTop();
gAdTimer.pauseRotation();
break
}if(ui.Wallpaper.getCurrentUrl()&&ui.Wallpaper.getCurrentUrl()==gTakeover.livepaper){var c=!(b==this.m_minHeight||b==this.m_midHeight);
ui.Wallpaper.getCurrentEl().setVisible(!c)
}this.m_rollOverUpsell.style.visibility=b==this.m_midHeight?"visible":"hidden";
if(this.m_onWipe){this.m_onWipe()
}};
this.animate=function(d){var c=this.m_animationStart,b=this.m_animationEnd;
if(this.m_animationEnd==this.m_midHeight){this.m_rollOverUpsell.style.bottom=Math.floor(-20*d)+"px"
}else{if(this.m_animationStart==this.m_midHeight){this.m_rollOverUpsell.style.bottom=Math.floor(-20*(1-d))+"px"
}}this.getElement().style.height=b-Math.round((b-c)*d)+"px"
};
this.onAnimationFinished=function(b){this.m_state=b;
if(this.m_state==this.m_minHeight){this.onWipe(this.m_nextState)
}if(this.m_nextState!=this.m_state){this.seekHeight(this.m_nextState)
}gWindowMgr.tileMinWindows()
};
this.onClickHotspot=function(c){if(this.m_ad.getProp("share")!=gTakeover.share){var b=hitch(this,function(f){this.setAd(f,c);
if(this.m_state==this.m_minHeight){this.seek(this.m_midHeight)
}});
var d=gAdServer.getAd("MediaBar",gTakeover.share);
if(!d){gAdServer.load({type:"MediaBar",shareId:gTakeover.share,callback:b})
}else{b(d)
}}else{if(this.m_state==this.m_minHeight){removeChildren($(this.getId()+"-leaderboard"));
$(this.getId()+"-leaderboard").appendChild(this.createLeaderboard(c));
this.seek(this.m_midHeight)
}else{var e=this.createLeaderboard(c);
util.css.setOpacity(e,0);
$(this.getId()+"-leaderboard").appendChild(e);
this.fadeLeaderboard()
}}};
this.onResize=function(){if(!this.m_bodyDiv){return
}var c=this.getElement();
var b=c.offsetWidth;
this.m_bodyDiv.style.width=b-4+"px";
this.m_leaderboardDiv.style.width=b-4+"px";
if(ui.isIE==6){c.style.bottom=-(c.parentNode.offsetHeight%2)+"px"
}};
this.onClickArrow=function(b){removeClassName(this.m_arrowBtn,"ArrowPress");
if(this.isMaximized()&&this.m_mediaBarAd.getAd().getProp("type")=="VideoEgg"){VideoEgg.takeover.hide()
}else{this.doToggle(b)
}};
this.onEventMgrChangeState=function(e,b,f,d){if(f=="im"){if(d=="connecting"||d=="logon"){if(gConsoleMgr.getMainPage().getRegistrationMode()){this.seek(this.m_minHeight);
gPubSub.subscribe("meeboApp.ConsolePageMain::changeRegistrationMode",this,function(){gPubSub.unsubscribe("meeboApp.ConsolePageMain::changeRegistrationMode",this);
if(this.isMinimized()){this.seek(this.m_midHeight)
}})
}this.initContent();
gAdTimer.resumeRotation(true);
var c=util.query.getHashVariable(util.query.AUTO_LAUNCH_ID);
if(c){gAdServer.load({type:"MediaBarPartnerOkay",shareId:c,callback:hitch(this,"launchAd")})
}}else{if(this.isMinimized()){if(VideoEgg.takeoverAction&&this.m_lastState==this.m_maxHeightVideoEgg){VideoEgg.takeoverAction.show()
}else{this.seek(this.m_lastState)
}}gAdTimer.resumeRotation()
}this.setDisplay(true)
}else{if(f=="done"&&d=="im"){gAdTimer.pauseRotation();
if(!this.isMaximized()){this.m_lastState=this.m_state;
if(this.isMidimized()){this.seek(this.m_minHeight)
}}}}}
});
Class("meeboApp.MediaBarAd",ui.element,function(a){this.initialize=function(b){a(this,"initialize");
this.m_id=getUniqueId();
this.m_ad=b;
this.m_titles={buddy:"Buddy Icons",wallpaper:"Wallpapers",share:"Share"};
this.m_creatives={buddy:{w:48,h:48,numPerRow:8,list:this.m_ad.getProp("buddyIcons")},wallpaper:{w:130,h:98,numPerRow:4,list:this.m_ad.getProp("wallpaperThumbnails")}};
this.m_adOverlayDiv=null;
gPubSub.subscribe("ui.drag::startResize",this,hitch(this,"showAdOverlay",true));
gPubSub.subscribe("ui.drag::startMove",this,hitch(this,"showAdOverlay",true));
gPubSub.subscribe("ui.drag::stopResize",this,hitch(this,"showAdOverlay",false));
gPubSub.subscribe("ui.drag::stopMove",this,hitch(this,"showAdOverlay",false));
this.m_startTime;
this.m_sentTimeToStat={}
};
this.getAd=function(){return this.m_ad
};
this.getMediaContainer=function(){return $(this.getId()+"-mediaContainer")
};
this.create=function(d){var g=this.m_win.document.createElement("div");
g.className="MediaBarAd";
g.innerHTML='<b class="corner adcorner"><b class="corner1 adcorner1"><b></b></b>			<b class="corner2 adcorner2"><b></b></b><b class="corner3 adcorner3"></b>			<b class="corner4 adcorner4"></b><b class="corner5 adcorner5"></b></b>			<div id="'+this.getId()+'-content" class="Content">&nbsp;</div>			<b class="corner adcorner"><b class="corner5 adcorner5"></b>			<b class="corner4 adcorner4"></b><b class="corner3 adcorner3"></b>			<b class="corner2 adcorner2"><b></b></b><b class="corner1 adcorner1"><b></b></b></b>';
g.style.width=((this.m_ad.getProp("width")||900)+18)+"px";
d.appendChild(g);
var g=$(this.getId()+"-content");
this.m_element=g;
this.createTopBar();
var c=this.m_win.document.createElement("div");
c.id=this.getId()+"-mediaContainer";
addClassName(c,"MediaContainer");
g.appendChild(c);
if(this.m_ad.getProp("type")!="VideoEgg"){var f=shallowCopy(this.m_ad.getProp("userParams")||{});
f.sound=gSounds.isMuted()?"off":"on";
f.meeboUserId=gLogon.getUserHash();
if(gApplicationPlatform.getChannel()){f.meeboChannel=gApplicationPlatform.getChannel()
}f.type="meebo";
if(this.m_ad.getProp("share")){f.shareId=this.m_ad.getProp("share")
}var b=util.query.addParams(this.m_ad.getProp("engaged"),f);
var e=this.getMediaContainer();
e.innerHTML='<iframe src="'+b+'" frameborder="0" width="'+(this.m_ad.getProp("width")||900)+'" height="'+(this.m_ad.getProp("height")||400)+'">'
}this.m_ad.track({type:"click"});
if(this.m_ad.getProp("click")){trackClickInIframe("MediaBarAdClickIframe",this.m_ad.getProp("click"))
}if(this.m_ad.getProp("partnerImpression_engaged")){new ui.TrackingPixel(null,this.m_ad.getProp("partnerImpression_engaged"),true).create()
}this.m_startTime=new Date().getTime()
};
this.createLink=function(c,e,d){var b=this.m_win.document.createElement("span");
addClassName(b,"Link");
setText(b,e);
c.appendChild(b);
ui.connectEvent(b,"mouseover",window,"addClassName",false,false,b,"LinkHover");
ui.connectEvent(b,"mouseout",window,"removeClassName",false,false,b,"LinkHover");
ui.connectEvent(b,"click",window,d,false,false)
};
this.createTopBar=function(){if(this.m_ad.getProp("type")=="VideoEgg"){return
}var f=this.m_win.document.createElement("div");
addClassName(f,"TopBar");
f.style.width=(this.m_ad.getProp("width")||900)+"px";
this.getElement().appendChild(f);
var d=this.m_win.document.createElement("table");
d.cellSpacing=0;
d.cellPadding=0;
var e=d.insertRow(-1);
if(this.m_ad.getProp("numBuddyIcons")>0){var g=e.insertCell(-1);
g.vAlign="middle";
addClassName(g,"BuddyIconContainer");
this.m_iconChooser=new ui.ImageChooser(getUniqueId()+"iconChooser","",48,48,Math.ceil(this.m_ad.getProp("buddyIcons").length/2),this.m_ad.getProp("buddyIcons")).create(this.m_win);
g.appendChild(this.m_iconChooser.getElement());
this.m_iconChooser.addSelectFunc(hitch(this,"onClickBuddyIcon"));
g=e.insertCell(-1);
g.vAlign="middle";
addClassName(g,"LinkContainer");
this.createLink(g,gLang.setAsBuddyIcon,hitch(this,"setBuddyIcon"))
}if(this.m_ad.getProp("numWallpapers")>0){var g=e.insertCell(-1);
g.vAlign="middle";
addClassName(g,"WallpaperContainer");
this.m_wallpaperChooser=new ui.ImageChooser(getUniqueId()+"iconChooser","",64,48,Math.ceil(this.m_ad.getProp("wallpaperThumbnails").length/2),this.m_ad.getProp("wallpaperThumbnails"),"uiWallpaperChooser").create(this.m_win);
g.appendChild(this.m_wallpaperChooser.getElement());
this.m_wallpaperChooser.addSelectFunc(hitch(this,"onClickWallpaper"));
g=e.insertCell(-1);
g.vAlign="middle";
addClassName(g,"LinkContainer");
this.createLink(g,gLang.setAsWallpaper,hitch(this,"setWallpaper"))
}g=e.insertCell(-1);
g.align="right";
var b=this.m_win.document.createElement("div");
addClassName(b,"ShareContainer");
g.appendChild(b);
var c=this.m_win.document.createElement("div");
addClassName(c,"ShareContent");
c.innerHTML=sprintf('<input type="text" value="%1"			onclick="this.select()" readonly %2>',meebo.util.generateMeeboShareLink(this.m_ad.getProp("share"),this.m_ad.getProp("userParams")),this.m_ad.getProp("type")=="VideoEgg"?"disabled":"");
b.appendChild(c);
this.createShareMenu(c);
roundElementCorners(c);
f.appendChild(d)
};
this.createShareMenu=function(f){var e=new ui.menuheader(getUniqueId(),"",null,120,"left",20,false,0,true,false,120).create(this.m_win);
e.addClassName("ShareMenu");
e.addSelectFunc(hitch(this,"onShare"));
e.setSkin("big");
e.setImage("share-icon.gif",14,16);
e.setTitle(gLang.share,null,true);
f.appendChild(e.getElement());
if(this.m_ad.getProp("type")=="VideoEgg"){e.setDisabled(true)
}var h=e.m_menuBody;
var g=gBuddyList.getBuddies({type:"buddy",online:true,onlist:true}).toArray();
g.sort(function(l,k){if(k.getActivityTime()<l.getActivityTime()){return -1
}else{if(l.getActivityTime()<k.getActivityTime()){return 1
}}return 0
});
if(!g.length){var b=h.addMenuItem(getUniqueId(),null,gLang.noBuddiesToShare,22,"nobuddies");
b.addClassName("uiHeaderItem");
b.m_highlightColor="#ececec";
b.m_height=22
}else{var b=h.addMenuItem(getUniqueId(),null,gLang.imBuddies,22,"imbuddies");
b.addClassName("uiHeaderItem");
b.m_element.style.borderBottom="1px solid #b6b6b6";
b.m_highlightColor="#ececec";
b.m_height=23;
for(var d=0,c;
((c=g[d])&&d<5);
d++){var b=h.addMenuItem(getUniqueId(),meeboApp.util.protocol.getBuddyProtocolIcon(c,true),c.getAlias(),18,c.getId());
b.m_element.style.backgroundColor="white"
}var b=h.addMenuItem(getUniqueId(),null,"More...",22,"more");
b.addClassName("uiHeaderItem");
b.m_element.style.borderTop="1px solid #b6b6b6";
b.m_height=23;
var b=h.addMenuItem(getUniqueId(),null,gLang.imToGroup,22,"group");
b.addClassName("uiHeaderItem");
b.m_element.style.borderTop="1px solid #b6b6b6";
b.m_height=23
}h.layoutMenuItems()
};
this.logEventTime=function(b){if(!(b in this.m_sentTimeToStat)){var c=Math.floor((new Date().getTime()-this.m_startTime)/1000);
this.m_sentTimeToStat[b]=true
}};
this.onShare=function(g,h){var l=this.m_ad.getProp("shareMsg")||sprintf(gLang.comeCheckOutInMeebo,this.m_ad.getProp("customTitle")||this.m_ad.getProp("title"));
var f=meebo.util.generateMeeboShareLink(this.m_ad.getProp("share"),this.m_ad.getProp("customUserParams")||this.m_ad.getProp("userParams"));
var d=hitch(this,function(q,p){this.logEventTime("share");
for(var o=0,n;
(n=q[o]);
o++){meeboApp.dispatchIM(gEventMgr,"meebo.EventMgr::sentIM",n,linkify(p))
}gNetworkMgr.requestMultiSend(q,p)
});
var c=hitch(this,function(n,p){var o=gWindowMgr.createIMWindow(n,true,false);
if(o.addCb){o.addCb(function(s,q){s.m_message.setText(p)
})
}else{o.m_message.setText(p)
}});
switch(h){case"nobuddies":case"imbuddies":break;
case"more":case"group":var m="Share",k=sprintf(gLang.selectBuddiesToShare,this.m_ad.getProp("title")),b=hitch(this,function(q,p){for(var n=0,o;
(o=q[n]);
n++){this.m_ad.track({type:"share"},o.getLogin(),o)
}d(q,p+"  "+f);
return true
});
gWindowMgr.createInviteDlg({caption:m},k,l,h=="group",gLang.sendIM,b);
break;
default:var e=gBuddyList.getBuddyById(h);
c(e,l+"  "+f);
break
}};
this.onClickBuddyIcon=function(c,b){this.m_iconChooser.setImage(b,48,48);
this.setBuddyIcon()
};
this.onClickWallpaper=function(c,b){this.m_wallpaperChooser.setImage(b,64,48);
this.setWallpaper()
};
this.setBuddyIcon=function(){this.logEventTime("buddy_icon");
var b=this.m_iconChooser.getImage();
meeboApp.setBuddyIconUrl(b)
};
this.setWallpaper=function(){this.logEventTime("wallpaper");
var b=null,d=this.m_wallpaperChooser.getImage();
for(var c=0;
c<this.m_ad.getProp("wallpapers").length;
c++){if(this.m_ad.getProp("wallpaperThumbnails")[c]==d){b=this.m_ad.getProp("wallpapers")[c];
break
}}if(!b){return
}this.m_ad.track({group:"setwallpaper",item:c});
meeboApp.setWallpaper(b,d,this.m_ad.getProp("title"))
};
this.onBeforeClose=function(b){if(this.customTakeover){this.customTakeover.hide()
}else{b()
}};
this.showAdOverlay=function(b){var c=this.m_adOverlayDiv;
if(!c){this.m_adOverlayDiv=c=this.m_win.document.createElement("div");
addClassName(c,"Overlay");
this.getElement().appendChild(c)
}c.style.display=b?"block":"none"
};
this.onResize=function(b,c){}
});
Class("meeboApp.FrontPage",function(){this.init=function(){this.m_accounts=[];
startlogtime("loginspeed",new Date().getTime());
var e=util.query;
var f=e.getHashVariable(e.ADD_BUDDY_USERNAME);
var b=$("langselect");
ui.connectEvent(b,"change",this,"onLanguageSelected",false,true);
this.initMeeboLogin();
var a=this.m_meeboLoginBox=new meeboApp.FrontPageMeeboLogin(f).create(window);
$("meebologincontent").appendChild(a.getElement());
a.initNavigation();
a.subscribe("EnterRegistration",this,"hideErrorMessages");
a.subscribe("EnterRegistration",this,"showOverlay",true);
a.getRegistrationForm().subscribe("LoginError",this,"showErrorMessage",gLang.noPass);
a.getRegistrationForm().subscribe("Ineligible",this,"onIneligibleRegistration");
if(!gIsGuestGroupChat){a.getRegistrationForm().subscribe("AccountCreated",gSecurePlatform,"notifyMeeboAccountCreated")
}if(f){this.initBuddyLinkBackground(f);
$("meebologincontent").insertBefore(this.createBuddyGreeting(f),$("meebologincontent").firstChild);
if(util.cookie.load("mid")){this.prefillMeeboLogin()
}else{var d=a.getScrollingContent();
d.scrollTo(d.BOTTOM,true)
}setTimeout(hitch(gWindowMgr,"loadObjects",["meeboApp.registrationFlow.inc"],null),1000)
}else{this.initNetworksContainer();
this.prefillMeeboLogin()
}this.fixLayout();
$("frontpage").style.visibility="visible";
var c=$("preload");
c.innerHTML='<img path="'+gImages.getPath()+'wait_ax.gif">';
cacheImgs(c);
this.connectLinkEvents();
gPubSub.subscribe("meebo.Logon::changeState",this,"onLogonChangeState");
gPubSub.subscribe("meebo.CIMAccount::changeState",this,"onLogonChangeState");
gPubSub.subscribe("meebo.EventMgr::changeState",this,"onEventMgrChangeState");
gFBConnect.subscribe("auth",this,"onFacebookConnectAuth")
};
this.onIneligibleRegistration=function(a){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-createDlg",caption:gLang.sorry},gLang.atLeast13);
if(a){gNetworkMgr.doUILog("registration","bounced-out","tooyoung",true);
gNetworkMgr.doUILog("regflow2","closed","verifydatefail",true)
}else{gNetworkMgr.doUILog("regflow2","notOpened","ineligible",true)
}};
this.onLanguageSelected=function(a){util.cookie.save("lang","index-"+a.value+".html");
location.href="index-"+a.value+".html"
};
this.initMeeboLogin=function(){var a=new ui.button("meebosignon",gLang.signon,gLang.signon,1,"big").create(window);
$("signonCellFrontpage").appendChild(a.getElement());
a.addOnMouseUp(hitch(this,"loginUser"));
this.fixButton(a.getElement());
util.storage.erase("meebopassword");
$("remembermecheck").onchange=function(){if(!this.checked){util.cookie.erase("mid")
}};
var c=$("loginboxescontainer").getElementsByTagName("input");
for(var d=0,b;
(b=c[d]);
d++){this.attachBlurClassName(b)
}};
this.createBuddyGreeting=function(f){var e=document.createElement("div");
e.id="buddyGreeting";
var c=e.appendChild(document.createElement("div"));
addClassName(c,"buddyIcon");
var d=e.appendChild(document.createElement("h3"));
addClassName(d,"buddyname loginboxheader");
setTruncatedText(window,d,f,185);
var a=e.appendChild(document.createElement("div"));
addClassName(a,"description");
setText(a,gLang.justOneStepFromChatting);
var b=e.appendChild(document.createElement("div"));
addClassName(b,"seperator");
return e
};
this.initNetworksContainer=function(){this.m_logonBoxProtocols={};
$("terms").innerHTML=sprintf(gLang.signOnTerms,gLang.termsLink,gLang.privacyLink);
var d=new ui.button("imsignon",gLang.signon,gLang.signon,1,"big").create(window);
$("loginBoxesControls").appendChild(d.getElement());
d.addOnMouseUp(hitch(this,"loginUser"));
this.fixButton(d.getElement());
if(util.cookie.load("morenetworks")){landingPage.show(util.cookie.load("morenetworks"),true)
}var a=$("facebookconnectlink");
if(a){this.m_facebookConnectLink=new meeboApp.FacebookConnectLink(a)
}var c=$("meebosubmit").getElementsByTagName("input");
for(var e=0,b;
(b=c[e]);
e++){this.attachBlurClassName(b)
}$("loginboxes").style.visibility="visible"
};
this.initBuddyLinkBackground=function(e){$("loginboxes").style.visibility="hidden";
$("meebolinks").style.visibility="hidden";
$("audiobtn").style.visibility="hidden";
$("languagelinks").style.visibility="hidden";
$("biz-links").style.visibility="hidden";
$("copyright").style.visibility="hidden";
var c=$("loginboxes");
removeChildren(c);
var b=c.appendChild(document.createElement("div"));
b.id="fakeImDlg";
var d=c.appendChild(document.createElement("div"));
d.id="fakeBuddylistDlg";
var a=b.appendChild(document.createElement("span"));
addClassName(a,"uiDlgCaption");
setText(a,e);
this.showOverlay(true,true);
this.createIMDlgAndBuddyList(e)
};
this.createIMDlgAndBuddyList=function(a){};
this.attachBlurClassName=function(a){if(a.type=="text"||a.type=="password"){ui.connectEvent(a,"focus",this,hitch(window,"addClassName",a,"focused"));
ui.connectEvent(a,"blur",this,hitch(window,"removeClassName",a,"focused"))
}};
this.fixLayout=function(){function c(d,k){try{var l=document.styleSheets[document.styleSheets.length-1];
if(l.cssRules){var f=l.cssRules.length;
var h=d+" { "+k+" }";
l.insertRule(h,f)
}else{var f=l.rules.length;
l.addRule(d,k,f)
}}catch(g){}}var a=$("loginboxes").getElementsByTagName("table")[0];
if(a){var b=(a.offsetWidth+10)-218;
if(b>0){c(".loginbox","width: "+(218+b)+"px");
c("#loginboxes","width: "+($("loginboxes").offsetWidth+2*b)+"px");
c("#frontpage","width: "+($("frontpage").offsetWidth+2*b)+"px")
}}var a=$("meebologinbox").getElementsByTagName("table")[0];
var b=(a.offsetWidth+20)-280;
if(b>0){c("#meebologin","width: "+($("meebologin").offsetWidth+b)+"px");
c("#frontpage","width: "+($("frontpage").offsetWidth+b)+"px")
}if(ui.isMac&&ui.isFirefox<3){c(".meeboConsole .overlay","opacity: 1; -moz-opacity: 1;")
}};
this.fixButton=function(b){if(!ui.isWebKit){var a=b.cloneNode(true);
$("frontpage").appendChild(a);
if(ui.isIE){b.style.width=a.offsetWidth+"px"
}else{b.childNodes[1].style.width=a.childNodes[1].offsetWidth+"px"
}removeElement(a)
}};
this.prefillMeeboLogin=function(){var a=util.query.getHashVariable(util.query.PREFILL_NAME);
if(!a){a=util.cookie.load("mid")
}if(a){$("meeboid").value=a;
$("remembermecheck").checked=true;
setTimeout(function(){$("meebopassword").focus()
},0)
}else{setTimeout(function(){$("meeboid").focus()
},0)
}landingPage.highlightBox("meebologinbox")
};
this.connectLinkEvents=function(){var c=$("meebolinks");
var a=c.getElementsByTagName("A");
for(var b=0;
b<a.length;
b++){ui.connectEvent(a[b],"click",a[b],function(){var e=this.href;
var d=this.href.indexOf(document.location.href);
if(d!=-1){e=e.substr(document.location.href.length)
}gNetworkMgr.doUILog("console-links",e,gEventMgr.getState())
})
}};
this.initAudioButton=function(){var b=$("audiobtn");
if(!b){return
}if(gSounds.isDisabled()){b.style.visibility="hidden";
return
}b.style.visibility="visible";
gAudioBtn=new ui.button("audiobtn",null,"audio",null,null,"buttons/audio","png").create(window,b);
var a=util.cookie.load("sound");
if((a==null)||(a=="")||(a=="true")){gAudioBtn.m_element.sound=true;
gSounds.unmute()
}else{gAudioBtn.m_element.sound=false;
gSounds.mute()
}gAudioBtn.m_imageBase=(gAudioBtn.m_element.sound)?"buttons/audio":"buttons/noaudio";
gAudioBtn.refreshImage();
gAudioBtn.addOnMouseUp(function(){gAudioBtn.m_element.sound=!gAudioBtn.m_element.sound;
util.cookie.save("sound",gAudioBtn.m_element.sound);
gAudioBtn.m_imageBase=(gAudioBtn.m_element.sound)?"buttons/audio":"buttons/noaudio";
if(gAudioBtn.m_element.sound){gSounds.unmute()
}else{gSounds.mute()
}gAudioBtn.refreshImage()
});
return gAudioBtn
};
this.getNeighborBox=function(c){for(var a=0,b;
(b=gNetworkOrder[a]);
a++){if(c==b){var d=(a%2==0)?a+1:a-1;
neighborBox=$(gNetworkOrder[d]+"loginbox");
if(neighborBox&&neighborBox.style.display!="none"){return neighborBox
}break
}}};
this.showErrorMessage=function(c,b){b=(b=="meebome")?"meebo":b;
function a(){var g=$(b+"loginbox");
addClassName(g,"loginerror");
addClassName(g,"extraHeight");
var f=this.getNeighborBox(b);
if(f){addClassName(f,"extraHeight")
}var e=$(b+"loginError");
setText(e,c);
$(b+"password").focus();
$(b+"password").select();
var d=$(b+"img");
if(d){d.style.display="none";
$(b+"errorimg").style.display=""
}$("loginboxescontent").className=$("loginboxescontent").className
}this.m_meeboLoginBox.monitorHeight(hitch(this,a))
};
this.hideErrorMessages=function(){function c(h){var g=$(h+"loginbox");
if(g&&hasClassName(g,"loginerror")){removeClassName(g,"loginerror");
removeClassName(g,"extraHeight");
var f=this.getNeighborBox(h);
if(f){removeClassName(f,"extraHeight")
}var e=$(h+"img");
if(e){e.style.display="";
$(h+"errorimg").style.display="none"
}}$("loginboxescontent").className=$("loginboxescontent").className
}var d=gNetworkOrder.concat("meebo");
for(var a=0,b;
(b=d[a]);
a++){this.m_meeboLoginBox.monitorHeight(hitch(this,c,b))
}};
this.isRegistrationMode=function(){var a=this.m_meeboLoginBox.getScrollingContent();
return(a.getState()==a.BOTTOM)
};
this.updateInnerMeebo=function(){var b=document.body,g=document.documentElement;
g.style.overflow=b.style.overflow="hidden";
g.style.height=b.style.height="100%";
b.scrollTop=b.scrollLeft=0;
var c=$("languagelinks");
if(c){c.style.visibility="hidden"
}removeElement($("copyright"));
removeElement($("meeboRoomsLink"));
removeElement($("meebolinks"));
var f=$("meebologo");
var a;
if(f){a=f.cloneNode(true);
removeClassName(a,"outerMeeboLogo");
addClassName(a,"innerMeeboLogo");
if(meeboApp.util.hasMeeboExtension()){addClassName(a,"firefoxMeeboLogo")
}}if(gWait){gWait.hideWait()
}removeElement($("frontpagecontainer"));
var e=$("ConsoleGradient");
var d=b.insertBefore(document.createElement("div"),e?e.nextSibling:document.body.firstChild);
d.id="meebotopcontainer";
addClassName(d,"meeboTopContainer");
if(a){d.appendChild(a)
}};
this.showOverlay=function(a,c){if(!this.m_overlayDiv){var b=0.75;
this.m_overlayDiv=document.createElement("div");
this.m_overlayDiv.id="registrationOverlay";
util.css.setOpacity(this.m_overlayDiv,0);
document.body.appendChild(this.m_overlayDiv);
this.m_overlayAnimation=new ui.Animation({duration:500});
this.m_overlayAnimation.addSubject(hitch(this,function(d){util.css.setOpacity(this.m_overlayDiv,d*b)
}));
this.m_overlayAnimation.onfinished=hitch(this,function(){if(this.m_overlayAnimation.getState()==0){this.m_overlayDiv.style.display="none";
if($("meebologin")){$("meebologin").style.position="static"
}}});
this.onResize()
}if(c){this.m_stickyOverlay=true
}else{if(this.m_stickyOverlay){return
}}if(this.m_overlayAnimation.getState()==0){this.m_overlayDiv.style.display="block"
}this.m_overlayAnimation.pause();
if(c){this.m_overlayDiv.style.display=a?"block":"none";
util.css.setOpacity(this.m_overlayDiv,a?b:0)
}else{this.m_overlayAnimation.seekTo(a?1:0)
}if($("meebologin")){$("meebologin").style.position="absolute"
}};
this.onResize=function(){if(this.m_overlayDiv){this.m_overlayDiv.style.height=document.documentElement.scrollHeight+"px"
}};
this.loginUser=function(){if(gWait&&gWait.isShowing()){return
}var g=new Date().getTime();
startTime=g;
logSpeed("start button clicked");
$("focuser").focus();
var l=(getValue("meeboid")&&getValue("meebopassword")?$("meebologin"):$("loginboxescontainer"));
if(!gWait){gWait=new meeboApp.logonWaitDlg()
}gWait.showWait(gLang.signOnWait,gImages.getPath()+"wait_ax.gif",l);
this.hideErrorMessages();
var h=$("invisiblecheck");
var q=h&&h.checked;
var o=["meebo"].concat(gNetworkOrder);
var k=[];
var e=false;
for(var f=0;
f<o.length;
f++){var c=o[f];
var p=$(c+"loginbox");
if(!p||p.style.display=="none"){continue
}var a=getValue(c+"id");
var n=getValue(c+"password");
if(a||n){e=true
}var b=meebo.util.createAccount(a,c,n);
if(typeof b=="string"){if(!a&&!n){continue
}this.showErrorMessage(b,c)
}else{if(b instanceof meebo.Logon){if(q){b.setStatus("invisible")
}this.m_logonBoxProtocols[b.getId()]=c
}gWait.incrementWait();
k.push(b)
}}if(k.length){if(q){gLogon.setStatus("invisible",null)
}if(gDebug){setTimeout(hitch(gLogon,"receiveVerifyUser"),1000)
}else{gNetworkMgr.requestLogin("joinexisting",k);
if(islogtiming("loginspeed")){var m=stoplogtime("loginspeed");
var d=new Date().getTime()-m-gStartPage;
gNetworkMgr.doUILog("usability","loginspeed","TimeToLogin",false,m);
gNetworkMgr.doUILog("usability","loadspeed","TimeToLoad",false,d)
}}this.m_accounts=k
}else{if(!e){this.showErrorMessage(gLang.incomplete,"meebo")
}gWait.hideWait()
}};
this.onLogonChangeState=function(b,a,c){if(!gWait){return
}if(c=="online"){gWait.hideWait();
if(meeboApp.util.hasMeeboExtension()){MeeboExtension.markSuccessfulLogin()
}}else{if(c=="error"){setTimeout(hitch(gWait,"updateWait",gLang.waitReceive),0);
gWait.decrementWait();
this.showErrorMessage(gLang.loginError,this.m_logonBoxProtocols[b.getId()]||b.getNetwork())
}}};
this.onEventMgrChangeState=function(a,k,b){if(b!="im"){return
}gPubSub.unsubscribe("meebo.EventMgr::changeState",this);
gPubSub.unsubscribe("meebo.Logon::changeState",this);
gPubSub.unsubscribe("meebo.CIMAccount::changeState",this);
gFBConnect.unsubscribe("auth",this);
if(this.m_facebookConnectLink){this.m_facebookConnectLink.destroy()
}if(gLogon.hasMeeboAccount()&&$("remembermecheck")&&$("remembermecheck").checked){util.cookie.save("mid",getValue("meeboid"))
}var g=function(){var m=ui.getClient()+ui.getVersion();
var l=(window.location!=window.top.location);
gNetworkMgr.doUILog("meebo","load",(gUILogging?"stats":"nostats"),true,"client:"+m+",iframed:"+l+",uid:"+gUid.onUid())
};
gUid.executeWhenReady(g);
var h=util.cookie.load("signup");
if(h&&gEventMgr.getState()=="connecting"){setTimeout(function(){var l=gBuddyList.getBuddies().length;
gNetworkMgr.doUILog("protocolsignup",h,l,true);
util.cookie.save("signup","")
},1000*15)
}this.updateInnerMeebo();
if(gWait){gWait.hideWait()
}setTimeout(hitch(meeboApp,"preloadImages"),60000);
var f=[];
for(var e=0,c;
(c=this.m_accounts[e]);
e++){var d=(c.getNetwork?c.getNetwork().getId():"meebo");
f.push(d)
}new ui.TrackingPixel({frontpagenetworks:f.join(","),bcookie:gClient.getBCookie()}).create();
this.showOverlay(false,true)
};
this.onFacebookConnectAuth=function(b){var d=$("facebookconnecting"),c=$("facebookconnected");
if(!d){return
}if(!b.xmpp_login){this.showErrorMessage(gLang.mustAllowFacebookChat,"facebook");
return
}d.style.display="none";
c.innerHTML='<table>		<col><col class="logincol">		<tr>			<td class="label"><label for="facebookid">'+gLang.loginId+'</label>			<td id="facebookname">		</tr>		<tr><td colspan="2" class="signon label"><label>'+gLang.clickSignOn+"</label>		</tr></table>";
var a=new meeboApp.FacebookNameInput(b.name);
$("facebookname").appendChild(a.getElement());
a.addOnClear(hitch(this,"clearFacebookBox"));
a.addOnSubmit(hitch(this,"loginUser"));
c.style.display="block";
a.getElement().focus();
$("facebookconnectinglink").style.display="none";
$("facebookconnectedlink").style.display="inline";
ui.connectEvent($("facebookconnectedlink"),"click",this,function(){gFBConnect.logout();
this.clearFacebookBox()
});
$("facebookid").value=b.uid;
$("facebookpassword").value=b.sessionKey;
$("facebookalias").value=b.name
};
this.clearFacebookBox=function(){var b=$("facebookconnecting"),a=$("facebookconnected");
if(!b){return
}a.style.display="none";
b.style.display="block";
$("facebookconnectedlink").style.display="none";
$("facebookconnectinglink").style.display="inline";
$("facebookid").value=$("facebookpassword").value=$("facebookalias").value=""
}
});
Class("meeboApp.FrontPageMeeboLogin",ui.Element,function(a){this.initialize=function(b){a(this,"initialize");
this.m_buddyUsername=b;
if(b){gNetworkMgr.addUILogFilter("viral","regflow2",function(c){c.action+="-buddylinkviral";
return c
})
}};
this.createContent=function(){this.addClassName("FrontPageMeeboLogin");
this.m_scrollingContent=new meeboApp.ScrollingContent().create(this.m_win);
this.m_element.appendChild(this.m_scrollingContent.getElement());
this.createSignonBox();
this.createHeader();
this.createRegistrationForm();
this.createControls();
this.connectContentEvents()
};
this.createSignonBox=function(){var b=$("meebologincontent");
while(b.firstChild){this.m_scrollingContent.getContent().appendChild(b.firstChild)
}};
this.createHeader=function(){this.m_header=this.m_scrollingContent.getContent().appendChild(this.m_win.document.createElement("h3"));
this.m_header.id="registerMeeboAccount";
setText(this.m_header,"... "+gLang.orRegisterNow);
var b=this.m_scrollingContent.getContent().appendChild(this.m_win.document.createElement("div"));
addClassName(b,"subtitle");
b.innerHTML=sprintf(gLang.registrationSubtitle,"<br>")
};
this.createRegistrationForm=function(){var b=this.m_scrollingContent;
this.m_registrationForm=new meeboApp.RegistrationForm().create(this.m_win);
this.m_heightMonitor=new meeboApp.HeightMonitor(this.m_registrationForm,b.getContent(),b.getElement());
this.m_heightMonitor.monitorMethod("validateInput");
this.m_heightMonitor.monitorMethod("removeValidationError");
this.m_heightMonitor.subscribe("HeightChange",this,function(){$("meebologin").className=$("meebologin").className
});
b.getContent().appendChild(this.m_registrationForm.getElement())
};
this.monitorHeight=function(b){return this.m_heightMonitor.monitorHeight(b)
};
this.createControls=function(){var c=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(c,"controls");
var d=this.m_buddyUsername?gLang.finish:gLang.register;
this.m_registerButton=new ui.button("registerButton",d,d,2,"big").create(this);
c.appendChild(this.m_registerButton.getElement());
var b=this.m_buddyUsername?gLang.alreadyHaveAnAccount:gLang.backTT;
var e=this.m_buddyUsername?"meebo":"back";
this.m_backLink=new meeboApp.ImgLinkButton(b,e).create(this);
this.m_backLink.setDisplay(false);
this.m_backLink.subscribe(this,"onBackLinkClick");
c.appendChild(this.m_backLink.getElement())
};
this.connectContentEvents=function(){this.m_scrollingContent.subscribe("ScrollFinished",this,"onScrollFinished");
this.m_registrationForm.subscribe("AccountCreated",this,"onAccountCreated");
this.m_registrationForm.subscribe("AgeVerificationNeeded",gWindowMgr,"createDateDlg",{parent:document.body,id:"ageVerification"},gLang.pleaseEnterYourBirthday,hitch(this.m_registrationForm,"verifyDate"),"questionmark.png");
this.m_registrationForm.subscribe("NetError",gWindowMgr,"createNotifyDlg",{id:getUniqueId()+"-notify",caption:gLang.netErrorHeader},gLang.netError);
this.m_registerButton.addOnMouseDown(hitch(this,"onRegisterButtonClick"));
this.m_backLink.subscribe("click",this,"onBackLinkClick")
};
this.onAccountCreated=function(b){gFrontPage.showOverlay(false);
gWindowMgr.loadObjects(["meeboApp.registrationFlow.inc"],hitch(gConsoleMgr.getMainPage(),"setRegistrationMode",true,b))
};
this.getRegistrationForm=function(){return this.m_registrationForm
};
this.getScrollingContent=function(){return this.m_scrollingContent
};
this.isRegistrationMode=function(){return(this.m_scrollingContent.getState()==this.m_scrollingContent.BOTTOM)
};
this.onRegisterButtonClick=function(d){gFrontPage.hideErrorMessages();
var e=this.m_scrollingContent,c=this.m_registrationForm;
switch(e.getState()){case e.TOP:var f=c.m_emailIsOk==null?c.validateEmail():c.m_emailIsOk;
var b=c.validateName();
if(!b||!f){return
}gFrontPage.showOverlay(true);
e.scrollTo(e.BOTTOM);
gWindowMgr.loadObjects(["meeboApp.registrationFlow.inc"]);
break;
case e.BOTTOM:c.submit()
}if(d){ui.setEventHandled(d)
}};
this.onBackLinkClick=function(){this.m_registrationForm.removeAllValidationErrors();
gFrontPage.showOverlay(false);
this.m_scrollingContent.scrollTo(this.m_scrollingContent.TOP);
gNetworkMgr.doUILog("regflow2","closed","cancellink",true)
};
this.onScrollFinished=function(){var b=this.m_scrollingContent;
switch(b.getState()){case b.TOP:this.m_registerButton.setText(gLang.register);
this.m_backLink.setDisplay(false);
break;
case b.BOTTOM:this.m_registrationForm.focus();
this.m_registerButton.setText(gLang.finish);
this.m_backLink.setDisplay(true);
break
}};
this.initNavigation=function(){this.defineNavigation("registerEmail","registerName","registerButton",hitch(this,"onRegisterButtonClick"),hitch(this,"isRegistrationMode"));
this.defineNavigation("registerName","registerId","registerEmail",hitch(this,"onRegisterButtonClick"),hitch(this,"isRegistrationMode"));
this.defineNavigation("registerId","registerPassword","registerName",hitch(this,"onRegisterButtonClick"));
this.defineNavigation("registerPassword","registerMale","registerId",hitch(this,"onRegisterButtonClick"));
this.defineNavigation("registerMale","registerAge","registerPassword",hitch(this,"onRegisterButtonClick"));
this.defineNavigation("registerFemale","registerAge","registerMale",hitch(this,"onRegisterButtonClick"));
this.defineNavigation("registerAge","registerButton","registerMale",hitch(this,"onRegisterButtonClick"));
this.defineNavigation("registerButton","registerEmail","registerAge",hitch(this,"onRegisterButtonClick"),hitch(this,"isRegistrationMode"),true,"meeboid","registerName");
this.defineNavigation("meeboid","meebopassword","registerButton",hitch(gFrontPage,"loginUser"));
ui.connectEvent($("registerId"),"focus",this,hitch(this,function(b){if(!this.isRegistrationMode()){ui.setEventHandled(b);
$("registerButton").focus()
}}),true)
};
this.defineNavigation=function(g,f,d,h,c,e,k,b){ui.connectEvent($(g),"keypress",this,function(n){switch(n.keyCode){case ui.KEY_SPACEBAR:if(!e){return
}case ui.KEY_RETURN:if(h){h()
}break;
case ui.KEY_TAB:var l=f;
var m=d;
if(c){if(k){if(!c()){l=k;
m=b
}}else{if(!c()){return
}}}$(n.shiftKey?m:l).focus();
break;
default:return
}ui.setEventHandled(n)
},true)
}
});
Class("meeboApp.BlogDlg",ui.element,function(a){this.initialize=function(){a(this,"initialize");
this.control="blogdlg";
this.m_logged=false;
this.m_blogAuthor="";
this.m_content;
this.m_minX=160;
this.m_minY=160
};
this.initContent=function(){this.m_content=this.m_win.document.createElement("div");
this.m_content.className="uiBlogContent";
this.m_content.innerHTML=sprintf(gLang.offlineBlog,gLang.commentsLink,gLang.blogLink,gLang.forumLink);
this.m_element.appendChild(this.m_content);
ui.connectEvent(this.m_content,"scroll",this,function(){if(this.m_logged){return
}this.m_logged=true;
var b="scrolled"+(this.m_blogAuthor?"-"+this.m_blogAuthor:"");
gNetworkMgr.doUILog(this.control,b,"true")
});
this.m_dlg.addOnKeyPress(this,"handleKeyPress");
this.m_element.ptr=this;
this.resize(this.m_element.offsetWidth,this.m_element.offsetHeight);
this.requestDailyBlog();
return true
};
this.setDailyBlog=function(b){if(!b){this.m_dlg.setWindowCaption(gLang.welcomeHeader,null);
var d=this.m_dlg.getWindowPos();
this.m_dlg.setWindowPos(d.x,d.y,240,160);
this.m_content.innerHTML=sprintf(gLang.offlineBlog,gLang.commentsLink,gLang.blogLink,gLang.forumLink);
return
}var e=/\<b\>([^\<]*)\<\/b\>\sposted\sthis\son/i;
var c=b.match(e);
if(c.length){this.m_blogAuthor=c[1]
}this.m_content.innerHTML=meebo.util.emoticons.insertMeeboEmoticons(b);
cacheImgs(this.m_content)
};
this.requestDailyBlog=function(){if(gDebug){this.setDailyBlog(null,false);
return
}var c=(meeboApp.util.hasMeeboExtension()&&MeeboExtension.shouldShowIntroBlog());
var d=(c?"blog-ff.txt":"blog.txt");
if(typeof(gSpecifyBlog)=="function"){d=gSpecifyBlog(d)
}var b="/"+d+"?"+Math.floor(new Date().getTime()/900000);
gNetworkMgr.requestURL(b,hitch(this,"setDailyBlog"))
};
this.handleKeyPress=function(b){switch(b.keyCode){case ui.KEY_ESC:this.m_dlg.closeWindow();
ui.setEventHandled(b);
return false
}return true
};
this.resize=function(c,d){var b=this.m_content.style;
if(c>=20){b.width=c-6+"px"
}if(d>=20){b.height=d-13+"px"
}}
});
Class("meeboApp.OkDlg",ui.element,function(a){this.initialize=function(){a(this,"initialize");
this.control="okdlg";
this.m_onOK=[];
this.m_onCancel=[]
};
this.setDelegateParams=function(f,g,b,e,d,c){this.m_msg=f;
this.m_okText=e||gLang.okBtn;
this.m_cancelText=d||gLang.cancelTT;
this.m_img=c||"notifyBuddy.gif";
if(g){this.addOnOK(g)
}if(b){this.addOnCancel(b)
}};
this.getTemplate=function(){return'<table border=0 cellspacing=4 cellpadding=0><tr><td id="headimg" valign="top"			></td><td class="uiDescr">'+this.m_msg+"</td></tr></table			>"
};
this.addOnOK=function(b){this.m_onOK.push(b)
};
this.addOnCancel=function(b){this.m_onCancel.push(b)
};
this.onCancel=function(){if(this.m_onCancel){doFunctions(this.m_onCancel)
}this.m_dlg.closeWindow()
};
this.onOK=function(){if(this.m_onOK){doFunctions(this.m_onOK)
}this.m_dlg.closeWindow()
};
this.initContent=function(){var c=getPartFromElement(this.getElement(),"headimg");
c.appendChild(createImg("",c,32,26,this.m_img,"",true,""));
this.m_okBtn=new ui.button("okbutton",this.m_okText).create(this.m_win).addClassName("buttonSpacer");
this.m_cancelBtn=new ui.button("cancelbutton",this.m_cancelText).create(this.m_win);
var b=this.m_win.document.createElement("div");
addClassName(b,"buttonBottomAlign");
b.appendChild(this.m_cancelBtn.getElement());
b.appendChild(this.m_okBtn.getElement());
this.getElement().appendChild(b);
this.connectContentEvents();
return true
};
this.onKeyPress=function(c,b){switch(c.keyCode){case ui.KEY_ESC:this.onCancel();
ui.setEventHandled(c);
break;
case ui.KEY_RETURN:this.onOK();
ui.setEventHandled(c);
break
}};
this.connectContentEvents=function(){this.m_dlg.addOnKeyPress(this,"onKeyPress");
this.m_okBtn.addOnMouseUp(hitch(this,"onOK"));
this.m_cancelBtn.addOnMouseUp(hitch(this,"onCancel"))
}
});
Class("meeboApp.GuestDownload",ui.element,function(a){this.initialize=function(){a(this,"initialize");
this.m_control="meeboApp.GuestDownload";
this.m_className="guestDownload";
this.m_acceptButton;
this.m_args={};
this.m_fileId="";
this.m_username=""
};
this.init=function(b){this.m_element=b;
var f=b.id;
var d=b.parentNode;
var c=b.getAttribute("fileId");
var e=b.getAttribute("username");
this.create(f,d,c,e)
};
this.create=function(f,c,b,e){if(!(f&&c&&b&&e)){return
}var d=gDoc(c);
this.m_id=f;
this.m_fileId=b;
this.m_username=e;
if(!this.m_element){this.m_element=d.createElement("div");
c.appendChild(this.m_element)
}this.m_element.id=this.m_id;
this.m_element.setAttribute("control",this.m_control);
this.addClassName(this.m_className);
this.initContent()
};
this.initContent=function(){this.setInnerHTML(this.getTemplate());
cacheImgs(this.getElement());
var b=this.getId();
this.m_acceptButton=new ui.button(b+"-acceptFile",gLang.accept).create(this.m_win).addClassName("acceptFile").addClassName("acceptButton");
this.m_acceptButton.setDisabled(true);
$(b+"-content").appendChild(this.m_acceptButton.getElement());
this.connectContentEvents();
this.requestFileInfo()
};
this.getTemplate=function(){var f=this.getId();
var c='<div id="'+f+'-NW" class="NWcorner"></div>			<div id="'+f+'-NE" class="NEcorner"></div>			<div id="'+f+'-SW" class="SWcorner"></div>			<div id="'+f+'-SE" class="SEcorner"></div>';
var e=this.getHeaderText();
var b='<div id="'+f+'-header" class="header">			<span id="'+f+'-headerText" class="headerText">'+e+"</span>			</div>";
var d='<div id="'+f+'-content" class="content loading">			<img id="'+f+'-downloadImg" class="downloadImg" path="file_download.gif"/>			<div id="'+f+'-loading" class="fileLoad">'+gLang.retrievingFileInfo+'</div>			<div id="'+f+'-error" class="fileError"></div>			<div id="'+f+'-fileInfo" class="fileInfo">			<span id="'+f+'-fileNameContainer" class="fileName">'+gLang.fileName+': <strong id="'+f+'-fileName"></strong></span>			<span id="'+f+'-fileSizeContainer" class="fileSize">'+gLang.fileSize+': <strong id="'+f+'-fileSize"></strong></span>			</div>			</div>';
return[c,b,d].join("")
};
this.getHeaderText=function(){return sprintf(gLang.buddySentFile,"<strong>"+this.m_username+"</strong>")
};
this.connectContentEvents=function(){this.m_acceptButton.addOnMouseUp(hitch(this,"acceptFile"))
};
this.acceptFile=function(){gNetworkMgr.doUILog("filetransfer","accept-guest","true",true);
meeboApp.fileTransfer.downloadFile(this.m_args)
};
this.requestFileInfo=function(){meeboApp.fileTransfer.getDownloadFileInfo(this.m_fileId,this.m_username,{onGetDownloadFileInfo:hitch(this,"receiveFileInfo")})
};
this.receiveFileInfo=function(d){if(!d){return
}this.m_args=d;
var h=this.getId();
var e=$(h+"-content");
removeClassName(e,"loading");
if(d.error_code){var c=$(h+"-error");
c.innerHTML=meeboApp.fileTransfer.getStringFromError(d.error_code);
addClassName(e,"error")
}else{var g=$(h+"-fileName");
var b=$(h+"-fileSize");
var f=decodeURIComponent(d.filename);
setText(g,f);
setText(b,computeFileSize(d.filesize));
this.m_acceptButton.setDisabled(false);
addClassName(e,"loaded")
}}
});
meeboApp.GuestDownload=new meeboApp.GuestDownload();
Class("meeboApp.FileTransfer",function(){this.initialize=function(){this.m_transferErrorCodes={"12":gLang.transferConnFailed,"13":gLang.transferConnFailed,"14":gLang.transferConnFailed,"15":gLang.transferTimedOut,"16":gLang.transferFailed,"17":gLang.fileTypeDisallowed,"21":gLang.uploadFileTooLarge,"22":gLang.uploadLimitReached,"30":gLang.transferFailed,"31":gLang.downloadLimitReached,"32":gLang.downloadFileNotFound,"33":gLang.downloadFileExpired}
};
this.sendFile=function(b,a,d){var c={muser:gLogon.getMeeboUser()};
gNetworkMgr.doRequest("init_upload.py",c,hitch(this,"initUploadCallback",b,a));
gNetworkMgr.doUILog("filetransfer","sent","true",true,"protocol="+d.getNetwork()+" sender="+d.getUser()+" receiver="+d.getName())
};
this.initUploadCallback=function(c,b,e,a){if(b.onBeforeSendFile){b.onBeforeSendFile()
}if(!a||e.error){b.onSendFile(e,false,null);
return
}var d={username:gLogon.getMeeboUser(),signature:e.signature,time:e.time,file:c,cb:window.location.protocol+"//"+window.location.host+"/getfile.html",domain:document.domain,upload_limit:e.upload_limit,thumbnail:e.thumbnail};
gNetworkMgr.doRequest(e.upload_url,d,hitch(this,"sendFileCallback",b))
};
this.sendFileCallback=function(b,c,a){if(!a||c.error_code){b.onSendFile(c,false,a?c.error_code:null)
}else{if(c.fileid){b.onSendFile(c,true)
}}};
this.getDownloadFileInfo=function(d,c,a){var b={username:c,fileid:d};
gNetworkMgr.doRequest("init_download.py",b,hitch(this,"callbackGetDownloadFileInfo",a))
};
this.callbackGetDownloadFileInfo=function(a,b){if(!a.onGetDownloadFileInfo){return
}a.onGetDownloadFileInfo(b)
};
this.downloadFile=function(e){if((new Date()).getTime()>e.expire_time*1000){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.fileTransfer},gLang.downloadFileExpired);
return
}var c={signature:e.signature,time:e.time,username:e.username,fileid:e.fileid,error_cb:window.location.protocol+"//"+window.location.host+"/getfile.html",error_domain:document.domain};
var b=[];
for(var d in c){b.push(d+"="+encodeURIComponent(c[d]))
}removeElement($("downloadframe"));
var a=document.createElement("iframe");
a.id="downloadframe";
a.src=e.download_url+"?"+b.join("&");
document.body.appendChild(a)
};
this.getStringFromError=function(a){return this.m_transferErrorCodes[a]||gLang.transferFailed
}
});
meeboApp.fileTransfer=new meeboApp.FileTransfer();
Class("meeboApp.Platform",function(){this.initialize=function(){this.m_platformEl=null;
this.m_isReady=false;
this.m_apps={};
this.m_platformInstanceId=Math.floor(Math.random()*100000);
this.m_readyCallbacks=[]
};
this.getPlatformInstanceId=function(){return this.m_platformInstanceId
};
this.create=function(){var b=util.flash.getVersion().major>=8;
if(!b){return
}var c=document.createElement("div");
var a='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"				width="1" height="1" align="middle" id="meebo_platform">';
a+='<param name="allowScriptAccess" value="always" />';
var d=window.location.protocol+"//"+window.location.hostname+"/flash/meebo_platform.swf";
a+='<param name="movie" value=\''+d+"' />";
a+='<param name="quality" value="high" />';
a+='<param name="wmode" value="transparent" />';
a+='<param name="FlashVars" value="readyCallback=meeboApp.platform.onComponentReady				&platformInstanceId='+this.m_platformInstanceId+'" />';
a+='<embed src="'+d+'" quality="high"				width="1" height="1" swLiveConnect=true id="meebo_platform"				name="meebo_platform" align="middle"				FlashVars="readyCallback=meeboApp.platform.onComponentReady&platformInstanceId='+this.m_platformInstanceId+'" allowScriptAccess="always" type="application/x-shockwave-flash" />';
a+="</object>";
document.body.appendChild(c);
c.innerHTML=a;
this.m_platformEl=ui.isIE?window.meebo_platform:document.meebo_platform
};
this.onComponentReady=function(){this.m_isReady=true;
if(!this.m_platformEl){this.m_platformEl=ui.isIE?window.meebo_platform:document.meebo_platform
}if(!this.m_platformEl||!this.m_platformEl.registerCallback){this.m_isReady=false;
return
}this.m_platformEl.registerCallback("registerapp","meeboApp.platform.registerApp");
this.m_platformEl.registerCallback("sendmsg","meeboApp.platform.sendMsg");
this.m_platformEl.registerCallback("onstart","meeboApp.platform.onStart");
this.m_platformEl.registerCallback("openinvite","meeboApp.platform.openInvite");
this.m_platformEl.registerCallback("onquit","meeboApp.platform.onQuit");
this.m_platformEl.registerCallback("debug","meeboApp.platform.debug");
if(this.m_readyCallbacks){for(var b=0,a=this.m_readyCallbacks.length;
b<a;
b++){this.m_readyCallbacks[b]()
}delete this.m_readyCallbacks
}};
this.ensurePlatformReady=function(a){if(this.m_isReady){a()
}else{this.m_readyCallbacks.push(a)
}};
this.isRegistered=function(a){return(a in this.m_apps)?this.m_apps[a].isRegistered:false
};
this.isStarted=function(a){return(a in this.m_apps)?this.m_apps[a].isStarted:false
};
this.createAppInstance=function(b,d,a,c){if(!this.m_isReady){return false
}var a=d?d.getApplication().domain:a;
this.m_platformEl.createApp(b,a);
this.m_apps[b]={isRegistered:false,isStarted:false,messages:[],type:c||meebo.APP_TYPE_IM};
if(d){this.m_apps[b].room=d;
gPubSub.subscribe(d,"meebo.ApplicationRoom::receiveAppMsg",this,"receiveMsg")
}};
this.removeApp=function(a){if(!this.m_isReady){return false
}this.m_platformEl.removeApp(a);
delete this.m_apps[a]
};
this.escapeParams=function(a){var c={};
for(var b in a){c[b]=a[b];
if(typeof(c[b])=="string"){c[b]=c[b].replace(/\\/g,"\\\\")
}}return c
};
this.join=function(b,a){if(!this.m_isReady){return false
}this.m_platformEl.join(b,this.escapeParams(a.getAppArgs()))
};
this.leave=function(b,a){if(!this.m_isReady){return false
}if(!this.m_platformEl.leave){return
}this.m_platformEl.leave(b,this.escapeParams(a.getAppArgs()))
};
this.changeAlias=function(b,a){if(!this.m_isReady){return false
}this.m_platformEl.changeAlias(b,this.escapeParams(a.getAppArgs()))
};
this.invite=function(b,a){if(!this.m_isReady){return false
}this.m_platformEl.invite(b,a)
};
this.mute=function(b,a){if(!this.m_isReady){return false
}this.m_platformEl.mute(b,a)
};
this.muteAllApps=function(a){for(var b in this.m_apps){this.mute(b,a)
}};
this.receiveMsg=function(c,a,d){if(!this.m_isReady){return false
}var b=c.getChatName();
if(!this.m_apps[b].isRegistered){this.m_apps[b].messages.push(d)
}else{this.m_platformEl.receiveMsg(b,d)
}};
this.registerApp=function(l,f,k){if(!this.m_apps[l]){return
}f=f||1;
k=k||0;
var a=this.m_apps[l].room;
if(!a){return
}var g=gWindowMgr.getConvWindow(this.m_apps[l].room);
if(g){g.hideAppLoadingOverlay()
}a.logLoadTime("toregisterapp");
var h=a.getPresences();
for(var b in h){var c=h[b];
this.join(l,c)
}var d=this.m_apps[l].messages;
for(var e=0;
e<d.length;
e++){this.m_platformEl.receiveMsg(l,d[e])
}this.m_apps[l].isRegistered=true
};
this.sendMsg=function(c,e,a,f){var d=this.m_apps[c];
var b=this.m_apps[c].room;
if(!b){return
}b.sendMsg(e,a,f)
},this.onStart=function(c){this.m_apps[c].isStarted=true;
var b=this.m_apps[c].room;
if(!b||!b.hasPresences()){return
}var a=b.getInvites();
if(!a){return
}var d=gWindowMgr.getConvWindow(b);
if(!d){return
}b.clearInvites();
d.inviteBuddies(a.invitees,false,"onstart",a.msg)
},this.openInvite=function(b){if(!this.m_apps[b]){return
}var a=this.m_apps[b].room;
if(!a){return
}var c=gWindowMgr.getConvWindow(this.m_apps[b].room);
if(c){c.openInviteDlg()
}},this.onQuit=function(a){},this.debug=function(b,d){return;
if(!this.m_apps[b]){return
}var a=this.m_apps[b].room;
if(!a){return
}var c=gWindowMgr.getConvWindow(a);
if(!c){return
}c.addHistoryIM("Application",d,true)
}
});
meeboApp.platform=new meeboApp.Platform();
Class("meeboApp.LinkButton",ui.Element,function(a){this.initialize=function(b){a(this,"initialize");
this.m_text=b
};
this.createContent=function(){this.m_span=this.m_element.appendChild(this.m_win.document.createElement("span"));
this.addClassName("LinkButton");
this.setText(this.m_text);
ui.connectEvent(this.m_element,"mouseover",this,"addClassName",false,false,"underline");
ui.connectEvent(this.m_element,"mouseout",this,"removeClassName",false,false,"underline");
ui.connectEvent(this.m_element,"click",this,"publish",false,false,"click")
};
this.setText=function(b){this.m_text=b;
setText(this.m_span,b)
}
});
Class("meeboApp.ImgLinkButton",meeboApp.LinkButton,function(a){this.initialize=function(c,b){a(this,"initialize",arguments);
this.m_imgClassName=b
};
this.createContent=function(){this.m_img=this.m_element.appendChild(this.m_win.document.createElement("img"));
a(this,"createContent");
this.addClassName("ImgLinkButton");
addClassName(this.m_img,this.m_imgClassName);
this.m_img.src=gImages.getPath()+"blank.gif"
}
});
Class("meeboApp.ApplicationPlatform",meebo.Platform,function(a){this.initialize=function(){a(this,"initialize");
this.m_appInstances={};
this.m_appInfos={}
};
this.initCommandHandlers=function(){var b=meebo.util.platform;
this.setCommandHandler(b.CMD_REQS_BUDDY_ICON,hitch(meeboApp,"setBuddyIconUrl"));
this.setCommandHandler(b.CMD_REQS_WALLPAPER,hitch(this,"handleSetWallpaper"));
this.setCommandHandler(b.CMD_REQS_STATUS_MESSAGE,hitch(meeboApp,"setStatusMessage"));
this.setCommandHandler(b.CMD_ADD_BUDDY,hitch(this,"handleAddBuddy"));
this.setCommandHandler(b.CMD_REQS_SHARE_ITEM,hitch(this,"handleSetShareItem"));
this.setResponseHandler(b.CMD_REQG_BUDDY_ICON,hitch(meeboApp,"getBuddyIcon"));
this.setResponseHandler(b.CMD_REQG_ALIAS,hitch(meeboApp,"getDisplayName"));
this.setResponseHandler(b.CMD_REQG_SHARE_LIST,hitch(this,"handleGetShareList"));
this.setResponseHandler(b.CMD_REQG_PROTOCOL_LIST,hitch(this,"handleGetProtocolList"));
this.setCommandHandler(b.CMD_APP_MSG,hitch(this,"handleAppMessageFromApp"));
this.setCommandHandler(b.CMD_TRACK_AD,hitch(this,"handleTrackRequest"));
this.setCommandHandler(b.CMD_SEND_MSG,hitch(this,"handleSendMessage"))
};
this.handleTrackRequest=function(b){if("item" in b){meebo.util.createTrackingPixel({component:"MediaBar",shareId:b.shareId,group:b.group,item:b.item},gLogon.getLogons())
}else{meebo.util.createTrackingPixel({component:"MediaBar",type:b.group,shareId:b.shareId},gLogon.getLogons())
}};
this.handleSendMessage=function(d){var b=gBuddyList.getBuddy(d.name,d.protocol,d.user);
if(!b){return
}var c=gWindowMgr.createIMWindow(b,true,false);
if(c.addCb){c.addCb(function(f,e){f.m_message.setText(d.msg)
})
}else{c.m_message.setText(d.msg)
}};
this.handleSetWallpaper=function(b){meeboApp.setWallpaper(b.url,b.url,b.shareId)
};
this.handleAddBuddy=function(c){var b=c.name,f=c.protocol;
var e={buddy:b,group:meebo.util.getDefaultGroup(f)};
var d=gLogon.getLogons({online:true,protocol:f});
if(d.length){e.logon=d[0]
}gWindowMgr.createAddBuddyDlg(null,e)
};
this.handleSetShareItem=function(b){var c=b.params;
if(c.userParams){gMediaBar.getAd().setProp("customUserParams",c.userParams)
}if(c.title){gMediaBar.getAd().setProp("customTitle",c.title)
}};
this.handleGetShareList=function(d,g){var f=[];
var e=gBuddyList.getBuddies({type:"buddy",online:true}).toArray();
e.sort(function(k,h){if(h.getActivityTime()<k.getActivityTime()){return -1
}else{if(k.getActivityTime()<h.getActivityTime()){return 1
}}return 0
});
for(var c=0,b;
(b=e[c]);
c++){f.push({name:b.getName(),alias:b.getAlias(),user:b.getUser(),protocol:b.getProtocol().toString()})
}return f
};
this.handleGetProtocolList=function(e,g){var b=[];
var f=gLogon.getLogons({online:true});
for(var d=0,c;
(c=f[d]);
d++){var h=c.getProtocol().toString();
if(!(h in b)){b[h]=true;
b.push(h)
}}return b
};
this.launchApplication=function(c,b){if(this.m_appInfos[c]){var d=this.createAppFromInfo(this.m_appInfos[c]);
d.launch();
b(d)
}else{gNetworkMgr.doRequest("mainfo",{app_id:c},hitch(this,"onAppInfo",function(e,g){this.m_appInfos[c]=e;
var f=this.createAppFromInfo(this.m_appInfos[c]);
f.launch();
b(f)
}))
}};
this.createAppFromInfo=function(b){if(b.type==meebo.util.platform.APP_TYPE_SINGLE){var c=new meebo.ApplicationSingle(b)
}else{var c=new meebo.Application(b);
gPubSub.subscribe(room,"meebo.ApplicationRoom::receiveAppMsg",this,"handleAppMessageFromServer",c)
}return c
};
this.handleAppMessageFromApp=function(c,b){b.getRoom().sendMsg(c.msg,meebo.util.platform.APP_MSG,c.to)
};
this.handleAppMessageFromServer=function(f,e,b,d){var c=meebo.util.platform.getAppChannelId(f.getInstanceId());
this.m_bridge.sendMessage(c,{m_event:meebo.util.platform.EVT_APP_MSG,message:d})
}
});
Class("meeboApp.ConsoleContainer",ui.element,function(a){this.m_overlayDiv=null;
this.m_contentDiv=null;
this.m_displayDuringRegistration=false;
this.initialize=function(){a(this,"initialize");
this.m_extensionModificationQueue=[];
this.createHandler("Update");
gPubSub.subscribe("meeboApp.ConsolePageMain::changeRegistrationMode",this,"onChangeRegistrationMode")
};
this.onChangeRegistrationMode=function(c,b,d){if(d){a(this,"setDisplay",(this.m_displayDuringRegistration?"block":"none"))
}else{if(this.m_savedDisplay){this.setDisplay(this.m_savedDisplay);
this.update()
}}};
this.setDisplay=function(b,c){this.m_savedDisplay=b;
if(gConsoleMgr.getMainPage().getRegistrationMode()){a(this,"setDisplay",[this.m_displayDuringRegistration?b:"none"])
}else{a(this,"setDisplay",[b])
}};
this.create=function(b,c){this.m_win=gWin(b);
this.m_element=this.m_win.document.createElement("div");
this.m_id=this.m_element.id=c;
this.addClassName("meeboConsoleContainer");
b.appendChild(this.m_element);
this.initOverlay();
this.initContent();
this.positionOverlay()
};
this.initOverlay=function(){this.m_overlayDiv=this.m_element.appendChild(this.m_win.document.createElement("div"));
this.m_overlayDiv.className="overlay";
this.m_overlayDiv.innerHTML='<b class="corner blackcorner"><b class="corner1 blackcorner1"><b></b></b>			<b class="corner2 blackcorner2"><b></b></b><b class="corner3 blackcorner3"></b>			<b class="corner4 blackcorner4"></b><b class="corner5 blackcorner5"></b></b>			<div>&nbsp;</div>			<b class="corner blackcorner"><b class="corner5 blackcorner5"></b>			<b class="corner4 blackcorner4"></b><b class="corner3 blackcorner3"></b>			<b class="corner2 blackcorner2"><b></b></b><b class="corner1 blackcorner1"><b></b></b></b>'
};
this.initContent=function(){this.m_contentDiv=this.m_element.appendChild(this.m_win.document.createElement("div"));
this.m_contentDiv.className="content ConsoleContainerContent"
};
this.getContent=function(){return this.m_contentDiv
};
this.update=function(){this.positionOverlay();
this.onUpdate()
};
this.getWidth=function(){return this.m_contentDiv.offsetWidth
};
this.getHeight=function(){return this.m_contentDiv.offsetHeight
};
this.showOverlay=function(b){this.m_overlayDiv.style.display=b?"block":"none";
if(b){this.positionOverlay()
}};
this.positionOverlay=function(b){b=b||0;
this.m_overlayDiv.style.width=this.getWidth()+"px";
this.m_overlayDiv.getElementsByTagName("div")[0].style.height=this.getHeight()+b+"px"
};
this.addExtension=function(b){this.scheduleExtensionModification(hitch(this,"doAddExtension",b))
};
this.removeExtension=function(b){this.scheduleExtensionModification(hitch(this,"doRemoveExtension",b))
};
this.scheduleExtensionModification=function(b){if(this.m_isModifyingExtensions){this.m_extensionModificationQueue.unshift(b)
}else{this.m_isModifyingExtensions=true;
b()
}};
this.doNextExtensionModification=function(){var b=this.m_extensionModificationQueue.pop();
if(b){b.call(this)
}else{this.m_isModifyingExtensions=false
}};
this.doAddExtension=function(b){if(b.container&&b.container.style.visibility=="visible"){this.doNextExtensionModification();
return
}if(!this.m_extensionDiv){this.m_extensionDiv=this.m_win.document.createElement("div");
addClassName(this.m_extensionDiv,"ConsoleExtensionContainer");
this.m_contentDiv.appendChild(this.m_extensionDiv)
}b.container=this.m_extensionDiv.appendChild(this.m_win.document.createElement("div"));
b.container.style.visibility="hidden";
b.animation=new ui.Animation({transition:ui.Animation.easeInOut,duration:650});
b.animation.addSubject(hitch(this,function(c){b.container.style.height=b.getHeight()*c+"px";
this.update()
}));
b.animation.onfinished=hitch(this,function(){b.container.style.visibility="visible";
b.container.appendChild(b.create(this.m_win).getElement());
this.update();
this.doNextExtensionModification()
});
b.subscribe("done",this,hitch(this,"removeExtension",b));
b.animation.seekTo(1)
};
this.doRemoveExtension=function(b){if(b.container&&b.container.style.visibility=="hidden"){this.doNextExtensionModification();
return
}b.animation.pause();
b.container.style.visibility="hidden";
b.animation.onfinished=hitch(this,function(){b.uncreate();
removeElement(b.container);
this.update();
this.doNextExtensionModification()
});
b.animation.seekTo(0)
};
this.getExtensionHeight=function(){return this.m_extensionDiv?this.m_extensionDiv.offsetHeight:0
}
});
Class("meeboApp.ConsoleNav",meeboApp.ConsoleContainer,function(a){this.initialize=function(){a(this,"initialize");
this.m_navAccounts=null;
this.m_navPrefs=null;
this.m_navWidgets=null;
this.m_navRooms=null;
this.m_navHelp=null;
this.m_displayDuringRegistration=true;
this.m_control="console"
};
this.initContent=function(){a(this,"initContent");
this.addClassName("ConsoleNav");
this.addClassName("unselectable");
this.update();
gPubSub.subscribe("meebo.LogonMgr::addLogon",this,"listenForAccountChanges");
this.listenForAccountChanges()
};
this.update=function(){removeChildren(this.m_contentDiv);
this.createRoomsLink();
this.createAccountsLink();
this.createPreferencesMenu();
this.createHelpLink();
if(gAudioBtn){this.m_contentDiv.appendChild(gAudioBtn.getElement());
gAudioBtn.getElement().style.visibility="visible"
}};
this.createRoomsLink=function(){this.m_navRooms=this.createNavigationLink(this.m_contentDiv,"meebo rooms",hitch(this,"onRooms"));
addClassName(this.m_navRooms,"rooms-link");
var b=this.m_win.document.createElement("span");
addClassName(b,"link");
setText(b,"|");
this.m_contentDiv.appendChild(b)
};
this.createAccountsLink=function(){this.m_navAccounts=this.createNavigationLink(this.m_contentDiv,gLang.accountsTabHeader.toLowerCase(),hitch(this,"onAccounts"));
addClassName(this.m_navAccounts,"accounts-link")
};
this.createHelpLink=function(){this.m_navHelp=this.createNavigationLink(this.m_contentDiv,gLang.help);
this.m_navHelp.target="_blank";
this.m_navHelp.href="http://www.meebo.com/support/";
addClassName(this.m_navHelp,"help-link")
};
this.createPreferencesMenu=function(){if(!this.m_preferencesMenu){var b=[{text:gLang.appearancePanel.toLowerCase(),handler:hitch(this,"onAppearance")},{text:gLang.IMSettings.toLowerCase(),handler:hitch(this,"onPreferences")},{text:gLang.meebomeWidgetsCap.toLowerCase(),handler:hitch(this,"onMeeboMe")}];
var c=this.m_preferencesMenu=new meeboApp.ConsoleMenu({text:gLang.preferencesTabHeader.toLowerCase(),items:b});
c.appendTo(this.m_contentDiv);
addClassName(c.getElement(),"link preferences-menu");
this.createConsoleIcon(c.getElement())
}};
this.listenForAccountChanges=function(){if(gLogon.getLogons({cimPartner:true}).length){this.createNotificationsMenu()
}if(gLogon.hasMeeboAccount()){this.createSettingsMenuItem()
}};
this.createNotificationsMenu=function(){if(this.m_notificationsMenu){return
}var b=this.m_notificationsMenu=new meeboApp.NotificationsMenu({text:gLang.notifications.toLowerCase(),items:[]});
b.appendTo(this.m_contentDiv,this.m_preferencesMenu.getElement());
addClassName(b.m_element,"link notifications-menu");
this.createConsoleIcon(b.m_element);
gConsoleMgr.getMainPage().onResize()
};
this.createSettingsMenuItem=function(){if(this.m_settingsNav){return
}this.m_settingsNav=this.m_preferencesMenu.insertItem({text:gLang.settings.toLowerCase(),handler:hitch(this,"onSettings")},2)
};
this.createNavigationLink=function(c,g,f){var e=this.m_win.document;
var b=e.createElement("a");
b.className="link";
c.appendChild(b);
var d=e.createElement("span");
setText(d,g);
d.className="label";
b.appendChild(d);
this.createConsoleIcon(b);
if(f){ui.connectEvent(b,"click",this,f)
}ui.connectEvent(b,"mouseover",this,function(){d.style.textDecoration="underline"
});
ui.connectEvent(b,"mouseout",this,function(){d.style.textDecoration=""
});
return b
};
this.createConsoleIcon=function(c){var b=this.m_win.document.createElement("img");
b.src=gConfig.getImageServer()+"blank.gif";
b.className="icon";
c.insertBefore(b,c.firstChild)
};
this.onAccounts=function(){var c=gLogon.getMeeboUser();
gNetworkMgr.doUILog(this.m_control,"general","accounts"+(c?"-mu":""));
if(c){gWindowMgr.createMyMeeboWindow({parent:document.body},false,"connectionstab","connectionpanecontent")
}else{var b=new meeboApp.AccountUpsellTooltip(gLang.MultipleAccounts,gLang.multipleAccountsDescription,"accounts");
b.showAt(this.m_navAccounts,b.BELOW)
}};
this.onSettings=function(){var b=gLogon.getMeeboUser();
gNetworkMgr.doUILog(this.m_control,"general","settings"+(b?"-mu":""));
gWindowMgr.createSettingsPanel({parent:document.body},b?false:true,"settingsPanel","settingsPanel")
};
this.onPreferences=function(){var b=gLogon.getMeeboUser();
gNetworkMgr.doUILog(this.m_control,"general","preferences"+(b?"-mu":""));
gWindowMgr.createPreferencesPanel({parent:document.body},b?false:true,"preferencesPanel","preferencesPanel")
};
this.onAppearance=function(){var b=gLogon.getMeeboUser();
gNetworkMgr.doUILog(this.m_control,"general","appearance"+(b?"-mu":""));
gWindowMgr.createAppearancePanel({parent:document.body},b?false:true,"apperancePanel","apperancePanel")
};
this.onMeeboMe=function(){var b=gLogon.getMeeboUser();
gNetworkMgr.doUILog(this.m_control,"general","widgets"+(b?"-mu":""));
var c=hitch(gWindowMgr,"createMyMeeboWindow",{parent:document.body},false,"meebometab","meebomepane");
if(b){c()
}else{gWindowMgr.createCreateMeeboAccountDlg({caption:gLang.meeboMeUpsell},"console-meebome","upsell_meebome.png",c)
}};
this.onRooms=function(){if(gLogon.getMeeboUser()){gWindowMgr.createRoomCreateDlg({id:getCreateGroupChatDlgId(),caption:gLang.createMeeboChat},null,false)
}else{var b=new meeboApp.AccountUpsellTooltip(gLang.rooms,gLang.createMeeboChat,"createroom");
b.showAt(this.m_navRooms,b.BELOW)
}};
this.getWidth=function(){return this.m_contentDiv.offsetWidth+(this.m_notificationsMenu?this.m_notificationsMenu.getElement().offsetWidth:0)
}
});
Class("meeboApp.ConsoleAccounts",meeboApp.ConsoleContainer,function(a){this.m_buddyIconTooltipDelay=1500;
this.m_presences={available:capitalize(gLang.availableShort),away:capitalize(gLang.awayShort),invisible:capitalize(gLang.inv),offline:capitalize(gLang.offlineGroup)};
this.m_presenceImages={available:"avail.gif",away:"away.gif",savedAwayMessage:"away.gif",invisible:"invis.gif",offline:"presence-offline-icon.gif"};
this.initialize=function(){a(this,"initialize");
this.m_header=null;
this.m_iconChooser=null;
this.m_signOnDiv=null;
this.m_mobileNotifications=null;
this.m_consoleMenus={};
this.m_menuOrder=[];
this.m_menuHeight=24;
this.m_menuItemVals=["alias","prof","sign"];
this.doSubscriptions()
};
this.doSubscriptions=function(){gPubSub.subscribe("meebo.Prefs::changeIcon",this,"onSetIcon");
gPubSub.subscribe("meebo.LogonMgr::addLogon",this,"onAddLogon");
gPubSub.subscribe("meebo.LogonMgr::removeLogon",this,"onRemoveLogon");
gPubSub.subscribe("meebo.MeeboAccount::changeState",this,"onMeeboAccountChangeState");
gPubSub.subscribe("meebo.EventMgr::networkResume",this,"update");
gPubSub.subscribe("meebo.EventMgr::networkInterrupt",this,"update");
gPubSub.subscribe("meebo.EventMgr::changeState",this,"onEventMgrChangeState");
gIMGateway.subscribe("AddLocation",this,"onClientsChange").subscribe("RemoveLocation",this,"onClientsChange").subscribe("ClientsClear",this,"onClientsChange").subscribe("PushClient",this,"onClientsChange")
};
this.initContent=function(){a(this,"initContent");
this.addClassName("ConsoleAccounts");
this.setDisplay(true);
this.createHeader();
this.createPresenceMenu();
this.createNetworkStateLink();
this.createStatusInput();
this.createMenuContainer();
this.createSignOnLink();
this.positionOverlay();
if(gLogon.getMeeboMeLogon()){addClassName(this.m_element,"meeboUser")
}var d=gLogon.getLogons();
for(var c=0,b;
(b=d[c]);
c++){this.onAddLogon(null,"",b)
}this.updateSignedOnLocations();
this.updateMobileNotifications();
this.updateNetworkStateLink()
};
this.numberOfRemoteLocations=function(){var b=Math.max(0,gIMGateway.getLocations().length-1);
var c=gIMGateway.getPushClient();
if(c&&!gIMGateway.getClients({type:c}).length){b+=1
}return b
};
this.updateSignedOnLocations=function(){var e=this.m_win.document,c=this.numberOfRemoteLocations();
if(c==0){removeElement(this.m_signedOnLocations);
this.m_signedOnLocations=null;
this.positionOverlay();
this.onUpdate()
}else{if(!this.m_signedOnLocations){var f=this.m_signedOnLocations=e.createElement("div");
f.className="locations";
f.innerHTML='<a href="#"><span></span></a>';
ui.connectEvent(f.firstChild,"click",this,function(g){ui.preventDefault(g);
gWindowMgr.createLocationsDlg()
},true);
var b=createImg("",f,16,16,"console-icon-01-location.png","",true,"",true);
f.firstChild.insertBefore(b,f.firstChild.firstChild);
var d=this.m_mobileNotifications;
this.m_header.insertBefore(f,d?d.getElement():this.m_presenceDiv);
this.positionOverlay();
this.onUpdate()
}setText(this.m_signedOnLocations.firstChild.lastChild,sprintf(gLang.youAreSignedInFromNLocations,c+1))
}};
this.updateMobileNotifications=function(){var b=(gIMGateway.getClients({type:"iphone"}).length||gIMGateway.getPushClient()=="iphone");
if(b&&!this.m_mobileNotifications){gWindowMgr.loadObjects(["meeboApp.mobileNotifications.inc"],hitch(this,"initMobileNotifications"))
}else{if(!b&&this.m_mobileNotifications){this.m_mobileNotifications.uncreate();
this.m_mobileNotifications=null
}}};
this.initMobileNotifications=function(){if(this.m_mobileNotifications){return
}this.m_mobileNotifications=new meeboApp.MobileNotifications();
this.m_header.insertBefore(this.m_mobileNotifications.create(this.m_win).getElement(),this.m_presenceDiv);
this.positionOverlay();
this.onUpdate()
};
this.onClientsChange=function(b){this.updateSignedOnLocations();
this.updateMobileNotifications();
this.updateNetworkStateLink();
this.positionOverlay();
this.onUpdate()
};
this.update=function(){this.positionOverlay();
this.refreshMenus();
this.onUpdate()
};
this.getWidth=function(){return 320
};
this.getHeight=function(){return this.m_header.offsetHeight+this.m_menuContainer.offsetHeight+this.m_signOnDiv.offsetHeight+this.getExtensionHeight()
};
this.createPresenceMenu=function(){var c=this.m_presenceMenu=new ui.menuheader("presenceMenu","",130,130,"left",20,false,"",false);
c.setMenuBodyClassName("PresenceMenuBody");
c.setVerticalOffset(-1);
c.setPreventReselect(false);
c.setHasDisabledImage(false);
c.create(this.m_win);
this.m_presenceDiv.appendChild(c.getElement());
gPubSub.subscribe("meebo.Prefs::changeAwayMessages",this,hitch(this,"updatePresenceMenu",true));
gPubSub.subscribe("meebo.LogonMgr::changeStatus",this,"onChangeStatus");
this.updatePresenceMenu();
var b=gLogon.getStatus();
this.m_lastStatus=this.m_status=b;
this.setPresenceMenuState(b);
c.addSelectFunc(hitch(this,"onSetPresence"))
};
this.createNetworkStateLink=function(){var c=this.m_win.document;
var b=this.m_networkStateLink=c.createElement("a");
b.href="#";
b.className="networkStateLink";
setText(b,gLang.signOff);
ui.connectEvent(b,"click",this,"onNetworkStateLinkClick",true);
this.m_presenceDiv.appendChild(b)
};
this.updateNetworkStateLink=function(){var b=(gEventMgr.getState()!="im"?gLang.reconnectionBtn:this.numberOfRemoteLocations()==0?gLang.signOff:gLang.signOffHere);
setText(this.m_networkStateLink,b)
};
this.onChangeStatus=function(c,b,e,d){this.setPresenceMenuState(e)
};
this.onSetPresence=function(b){var c=this.m_presenceMenu.getItemValue();
if(c=="savedAwayMessage"){this.m_presenceMenu.setTitle(this.m_presences.away,"away",true);
this.m_presenceMenu.setImage(this.m_presenceImages.savedAwayMessage);
this.m_statusInput.setStatus("away",b);
this.updatePresence(b)
}else{this.m_statusInput.setStatus(c);
this.m_statusInput.setValue(this.m_lastNonSavedStatusMessage,true);
this.updatePresence()
}};
this.setPresenceMenuState=function(b){this.m_presenceMenu.setSelected(this.m_presenceImages[b],this.m_presences[b],b,false,true)
};
this.updatePresenceMenu=function(b){if(this.m_updatePresenceMenuTimer){this.m_win.clearTimeout(this.m_updatePresenceMenuTimer)
}this.m_updatePresenceMenuTimer=this.m_win.setTimeout(hitch(this,"doUpdatePresenceMenu",b),350)
};
this.shouldUpdatePresenceMenu=function(){if(!this.m_presenceMenu.getMenuItem("away")){return true
}var c=gLogon.getLogons({online:true,supports:"invisible"}).length>0;
var b=!!this.m_presenceMenu.getMenuItem("invisible");
if(c!=b){return true
}if(!this.m_presenceMenu.getMenuItem("editSavedAwayMessages")&&gLogon.hasMeeboAccount()){return true
}return false
};
this.addPresenceItem=function(c,d,e){var b=this.m_presenceMenu.addMenuItem(d||this.m_presences[c],this.m_presenceImages[c],c,false,null,e||c);
b.m_preImg.w=23;
b.m_height=20;
return b
};
this.doUpdatePresenceMenu=function(d){if(!d&&!this.shouldUpdatePresenceMenu()){return
}this.m_presenceMenu.closeMenu();
this.m_presenceMenu.removeAllItems();
this.addPresenceItem("available");
this.addPresenceItem("away");
var e=gPrefs.getCustomAwayMessages();
for(var c=0;
c<e.length;
c++){var h=this.addPresenceItem("savedAwayMessage",e[c],"savedAwayMessage-"+c)
}if(gLogon.hasMeeboAccount()){var g=lastItem=this.m_presenceMenu.addMenuItem(capitalize(gLang.edit)+"\u2026",null,"editSavedAwayMessages",false,null,"editSavedAwayMessages");
g.addClassName("editSavedAwayMessages");
g.onMouseUp=hitch(this,"onEditSavedAwayMessages")
}if(gLogon.getLogons({online:true,supports:"invisible"}).length>0){this.addPresenceItem("invisible")
}var f=["available","away","invisible"];
var b=0;
for(var c=0;
c<f.length;
c++){var h=this.m_presenceMenu.getMenuItem(f[c]);
if(h){h.addTopBorder();
b+=1
}}this.m_presenceMenu.m_topBorderHeight=b
};
this.onEditSavedAwayMessages=function(){this.m_presenceMenu.closeMenu();
gWindowMgr.createStatusMenuDlg()
};
this.createStatusInput=function(){var b={available:capitalize(gLang.availableShort),away:capitalize(gLang.awayShort),invisible:""};
meeboApp.statusInput=this.m_statusInput=new meeboApp.StatusInput(gLang.WhatAreYouDoing,b,gLogon.getStatus(),gLogon.getStatusMessage());
this.m_statusInput.create(this.m_presenceDiv);
this.m_statusInput.addOnValueChange(hitch(this,"onStatusMessageChange"))
};
this.onStatusMessageChange=function(e,d){var f=false;
var c=gPrefs.getCustomAwayMessages();
for(var b=0;
b<c.length;
b++){if(e==c[b]){f=true;
break
}}if(!f){this.m_lastNonSavedStatusMessage=e
}this.updatePresence(e)
};
this.onNetworkStateLinkClick=function(c){ui.preventDefault(c);
var b=gEventMgr.getState();
if(b=="im"){gNetworkMgr.doUILog("console","logbuttons","signoff");
gEventMgr.logout("detach")
}else{if(b=="done"){gNetworkMgr.doUILog("console","logbuttons","reconnect");
gLogon.reconnectAll()
}}};
this.updatePresence=function(g){g=g||(this.m_statusInput.hasCustomValue()?this.m_statusInput.getValue():"");
var d=this.m_presenceMenu.getItemValue();
var e=gEventMgr.getState();
var f=gLogon.getLogons();
for(var c=0,b;
(b=f[c]);
c++){if(e!="im"||!b.isOnline()){b.setStatus(d);
b.setStatusMessage(g)
}}gLogon.setStatus(d,g);
gNetworkMgr.doRequest("setstatus",{state:d,message:g});
meeboApp.updateStatusPanelIcon();
this.m_lastStatus=this.m_status;
this.m_status=d
};
this.createHeader=function(){if(this.m_header){return
}var d=this.m_win.document;
var c=this.m_header=d.createElement("div");
c.className="header";
this.m_contentDiv.appendChild(c);
var b=this.m_greetingDiv=d.createElement("div");
b.className="meeboGreeting";
setText(b,gLang.welcomeHeader);
c.appendChild(b);
var b=this.m_presenceDiv=d.createElement("div");
b.className="presence";
this.createIconChooser(b);
c.appendChild(b)
};
this.writeSignOnHeader=function(){this.m_header.innerHTML=gLang.blankConsole+'<span class="mocklinks" onclick="gWindowMgr.createSignOnWindow();"			>'+gLang.signon+"!</span><br><br>"
};
this.createSignOnLink=function(){var f=this.m_win.document;
var g=this.m_signOnDiv=f.createElement("div");
g.className="signOnLink";
var c=f.createElement("a");
c.innerHTML="<span>"+gLang.consoleSignOnLink+"&hellip;</span>";
var e=c.firstChild;
var d=createImg("",c,null,null,"console-add.gif","",true,"bottom");
addClassName(d,"plus");
c.insertBefore(d,c.firstChild);
var b=createImg("",c,null,null,"networks-upsell.png","",true,"bottom",true);
addClassName(b,"networks");
c.appendChild(b);
ui.connectEvent(c,"mouseup",this,"onSignOnClick");
ui.connectEvent(c,"mouseover",this,function(){e.style.textDecoration="underline"
});
ui.connectEvent(c,"mouseout",this,function(){e.style.textDecoration="none"
});
g.appendChild(c);
this.m_contentDiv.appendChild(g)
};
this.onSignOnClick=function(){gWindowMgr.createSignOnWindow();
gNetworkMgr.doUILog("console","general","signonlink")
};
this.createIconChooser=function(c){if(!this.m_iconChooser||ui.isIE){this.m_iconChooser=new ui.IconChooser(getUniqueId()+"iconChooser",gPrefs.getIcon()).create(this.m_win);
c.appendChild(this.m_iconChooser.getElement());
this.m_iconChooser.m_menuBodyClassName="BuddyIconBody";
var b=this.m_iconChooser.getElement().style;
b.display="inline";
b.marginLeft="10px";
b.marginRight="15px";
this.m_iconChooser.setVerticalOffset(-4);
this.m_iconChooser.setHorizontalOffset(3);
this.m_iconChooser.addSelectFunc(hitch(this,"onSelectIcon"))
}else{c.appendChild(this.m_iconChooser.m_element)
}};
this.onSelectIcon=function(d,c){var b=gLogon.getMeeboUser();
gNetworkMgr.doUILog("console","general","buddyicon"+(b?"-mu":""));
switch(d){case"Recent Icons":if(c){gNetworkMgr.requestSetIcon(null,null,c)
}break;
case"Clear Icon":gNetworkMgr.requestSetIcon("");
break;
case"Custom Icon...":if(c){gNetworkMgr.requestSetIcon("",c)
}break;
default:if(c){gNetworkMgr.requestSetIcon(c)
}break
}};
this.createMenuContainer=function(){if(!this.m_menuContainer){this.m_menuContainer=this.m_win.document.createElement("div");
addClassName(this.m_menuContainer,"menuContainer");
this.m_contentDiv.appendChild(this.m_menuContainer)
}};
this.refreshMenus=function(){var d=gLogon.getLogons();
for(var c=0,b;
(b=d[c]);
c++){if(!this.m_consoleMenus[b.getId()]){continue
}this.refreshConsoleMenu(b)
}};
this.createConsoleMenu=function(c){var h=c.getId();
if(this.m_consoleMenus[h]){return
}var d=c.getNetwork();
var e=c.isOnline();
var b=(d=="meebome");
if(b&&!c.isMeeboLogon()){return
}var f=new ui.menuheader(c.getId(),this.getLogonTitle(c),null,null,"left",16,false,null,true,true,280).create(this.m_win);
var g=this.m_win.document.createElement("div");
addClassName(g,"accountWrapper");
if(c.isMeeboLogon()&&this.m_menuContainer.firstChild){this.m_menuContainer.insertBefore(g,this.m_menuContainer.firstChild)
}else{this.m_menuContainer.appendChild(g)
}f.setDelayMenu(true);
f.setHasDisabledImage(false);
f.setSkin("ondemand");
f.setDisabled(b);
f.addClassName("meeboConsoleMenu");
f.setImage(this.getLogonImage(c),20);
f.addSelectFunc(hitch(this,"onMenuSelect"));
g.appendChild(f.getElement());
if(b){this.m_menuOrder.unshift(f)
}else{this.m_menuOrder.push(f)
}this.m_consoleMenus[h]={menu:f,element:g};
this.addConsoleMenuItems(c,this.m_consoleMenus[h]);
this.positionOverlay();
this.onUpdate()
};
this.refreshConsoleMenu=function(c){var f=c.getId();
var e=this.m_consoleMenus[f]&&this.m_consoleMenus[f].menu;
if(!e){return
}e.shrinkToSize();
var d=this.getLogonTitle(c);
if(d!=e.getTitle()){e.setTitle(d,null,true)
}e.setDisabled(gEventMgr.getState()!="im"||(c.getNetwork()=="meebome"&&c.isOnline()));
var b=this.getLogonImage(c);
if(b!=e.getImage()){e.setImage(b,20)
}this.addConsoleMenuItems(c,this.m_consoleMenus[f])
};
this.addConsoleMenuItems=function(c,d){var f=c.getNetwork();
var g=c.isOnline();
var h=d.menu;
if(!d.menuItems){d.menuItems={}
}var b={};
b[this.m_menuItemVals[0]]={title:gLang.setDisplayName,isVisible:f.supports("customalias")&&g};
b[this.m_menuItemVals[1]]={title:gLang.setProfile,isVisible:f=="aim"&&!meebo.util.isICQ(c.getName())&&g};
b[this.m_menuItemVals[2]]={title:g?gLang.logoff:gLang.signon,isVisible:((f=="meebome"&&!g)||f!="meebome")&&gEventMgr.getState()=="im"};
for(var k in b){var e=d.menuItems[k];
if(e){e=h.replaceMenuItem(e,b[k].title,null,k,!b[k].isVisible)
}else{e=h.addMenuItem(b[k].title,null,k,false,null,null,!b[k].isVisible)
}d.menuItems[k]=e
}};
this.getLogonImage=function(b){var d="network/"+b.getNetwork()+"_20";
var c=b.getStatus();
if(!b.isOnline()||c=="invisible"){d+="_offline"
}else{if(c=="away"||c=="unavailable"){d+="_away"
}else{d+="_online"
}}return d+".png"
};
this.getLogonTitle=function(c){var f=c.getAlias();
var b=(gEventMgr.inNetworkInterrupt()||gBuddyListDlg&&gBuddyListDlg.inNetworkInterrupt());
var e=c.getStatus();
var d=(b&&(c.isOnline()||c.getState()=="disconnected")&&gLang.consoleDisruption)||(c.getState()=="pending"&&gLang.loading+"...")||((c.isOnline()&&e=="unavailable")&&gLang.doNotDisturb)||((c.isOnline()&&e=="invisible")&&gLang.inv)||"";
if(d){f+=" ("+d+")"
}return f
};
this.closeAllMenus=function(){for(var b in this.m_consoleMenus){if(this.m_consoleMenus[b]){this.m_consoleMenus[b].menu.closeMenu()
}}if(this.m_iconChooser){this.m_iconChooser.closeMenu()
}};
this.facebookConnect=function(b){var c=["xmpp_login"];
if(b.isMeeboChild()){c.push("offline_access")
}gFBConnect.subscribe("auth",this,"onFacebookConnectAuth").setRequiredPermissions(c).connect()
};
this.onFacebookConnectAuth=function(d){gFBConnect.unsubscribe("auth",this);
var c=gLogon.getLogons({network:"facebook",name:d.uid})[0];
if(!c||c.getState()!="error"){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.tryAgainHeader},gLang.connectedAsDifferentUser);
return
}else{if(!d.xmpp_login){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.tryAgainHeader},gLang.mustAllowFacebookChat);
return
}else{if(c.getPassword()!=d.sessionKey){c.setPassword(d.sessionKey);
if(c.isMeeboChild()){c.setHasPassword(true);
var b={muser:gLogon.getMeeboUser(),numLogins:1,"1user":c.getName(),"1protocol":c.getProtocol(),"1password":gNetworkMgr.encryptPassword(d.sessionKey)};
gNetworkMgr.doRequest("setacc",b,hitch(gNetworkMgr,"receiveSetAcc"))
}}}}gLogon.reconnect(c)
};
this.onMenuSelect=function(h,c,g){var d=gLogon.getLogons()[g.getId()];
if(!d){return
}switch(c){case"alias":var b=d.getId()+"aliasInputDlg";
gWindowMgr.createSetDisplayNameDlg({id:b,caption:gLang.setDisplayName+" ("+d.getDisplayName()+")"},d);
break;
case"prof":var b=d.getId()+"profileTextareaDlg";
gWindowMgr.createSetProfileDlg({id:b,caption:gLang.setProfile+" ("+d.getName()+")"},d);
break;
case"sign":if(d.getNetwork()=="facebook"&&!d.isOnline()){var f=(d.getState()=="error"&&d.getLastError());
if(!d.hasPassword()||(f.type==2&&f.description=="Need chat permission")||(f.type==16&&f.description=="Session key invalid or no longer valid")){this.facebookConnect(d);
break
}}gLogon.toggleOnline(d);
c+=d.isOnline()?"off":"on";
break;
default:return
}gNetworkMgr.doUILog(this.control,"contextmenu",c)
};
this.onProfileDataArrival=function(b){if(!b.isset&&!gLogon.hasMeeboAccount()){this.m_infoExtension=new meeboApp.ConsoleExtensionInfoCollect();
this.m_infoExtension.subscribe("done",this,function(){this.m_infoExtension=null
});
this.setExtension(this.m_infoExtension)
}};
this.onSetIcon=function(c,b,d){if(this.m_iconChooser){this.m_iconChooser.setImage(d,48,48)
}};
this.onMeeboAccountChangeState=function(d,b,e){var c=d.getFirstName()||d.getName();
setText(this.m_greetingDiv,sprintf(gLang.welcomeComma,c));
if(this.m_infoExtension){this.removeExtension(this.m_infoExtension)
}};
this.onLogonChange=function(c,b){this.updatePresenceMenu();
this.refreshConsoleMenu(c)
};
this.onAddLogon=function(d,b,c){gPubSub.subscribe(c,"meebo.Logon::changeState",this,"onLogonChange");
gPubSub.subscribe(c,"meebo.Logon::changeAlias",this,"onLogonChange");
gPubSub.subscribe(c,"meebo.Logon::changeStatusMessage",this,"onLogonChange");
gPubSub.subscribe(c,"meebo.Logon::changeStatus",this,"onLogonChange");
this.createConsoleMenu(c);
this.updatePresenceMenu()
};
this.onRemoveLogon=function(e,b,c){var g=c.getId();
var f=this.m_consoleMenus[g];
if(!f){return
}removeElement(f.element);
for(var d=0;
d<this.m_menuOrder.length;
d++){if(this.m_menuOrder[d]==this.m_consoleMenus[g].menu){this.m_menuOrder.splice(d,1);
break
}}delete this.m_consoleMenus[g];
this.updatePresenceMenu();
this.positionOverlay();
this.onUpdate()
};
this.onEventMgrChangeState=function(d,b,e,c){if(e!="im"){this.m_lastOnlineStatus=this.m_status;
this.setPresenceMenuState("offline")
}else{if(this.m_lastOnlineStatus){this.setPresenceMenuState(this.m_lastOnlineStatus);
this.m_lastOnlineStatus=null
}}this.m_presenceMenu.setDisabled(e!="im");
this.m_iconChooser.setDisabled(e!="im");
this.m_statusInput.setDisabled(e!="im");
this.updateNetworkStateLink();
if(this.m_infoExtension&&e!="im"||gIsGuestGroupChat){this.removeExtension(this.m_infoExtension)
}}
});
Class("meeboApp.ConsoleInfoBlock",meeboApp.ConsoleContainer,function(a){this.initialize=function(){a(this,"initialize");
gPubSub.subscribe("meeboApp::loadGuestIcon",this,"onLoadGuestIcon")
};
this.initContent=function(){a(this,"initContent");
this.addClassName("ConsoleInfoBlock");
var c=this.m_id+"-icon";
var d=[];
d.push('<table><tr><td id="'+c+'" class="icon"></td>');
d.push('<td style="">');
var g=util.query;
var f=g.getHashVariable(g.MEEBO_USER);
var b=g.getHashVariable(g.USER);
if(f,b){d.push(sprintf(gLang.welcomeToUserPage,b,f))
}else{d.push(gLang.welcomeToMeebo)
}this.m_contentDiv.innerHTML=d.join("");
var e=$(c);
e.innerHTML='<img path="defaultbuddyicon.gif">';
cacheImgs(e)
};
this.onLoadGuestIcon=function(e,b,d){if(!d){return
}var c=$(this.m_id+"-icon").firstChild;
c.style.display="none";
c.onload=hitch(this,function(){c.width=c.height=48;
c.style.display="inline";
this.onUpdate()
});
c.src=d
}
});
Class("meeboApp.ConsoleSparkAd",meeboApp.ConsoleContainer,function(a){this.initialize=function(){a(this,"initialize");
this.m_sparkHeight=40;
gClient.subscribe("info::ad",this,"onLoadPartnerAd")
};
this.getWidth=function(){return 320
};
this.initContent=function(){a(this,"initContent");
this.addClassName("ConsoleSparkAd");
this.setDisplay(false);
var b=this.m_contentDiv;
addClassName(b,"Container");
this.positionOverlay();
this.onUpdate()
};
this.getAdHtml=function(e){var c=e.getProp("link"),d=e.getProp("icon"),f=e.getProp("title"),b=e.getProp("text")+(!e.getProp("companion")?'<img class="Icon" path="spark-pop-out.png"				border="0" width="11" height="11" png="true">':"");
return'<div class="AdContent '+(!d?"TextOnly":"")+'"				><a href="'+c+'" id="consoleAdLink" target="_blank"				><img class="AdTitle" path="spark-ad-label.png" border="0"				png="true">'+(d?'<img id="consoleAdIcon" border=0 class="Thumbnail"				png="true" width="32" height="32" path="'+d+'">':"")+'<div class="Text"><div id="console-adTitle" class="Title">'+f+'</div				><div id="console-adDesc" class="Description">'+b+"</div				></div></a></div>"
};
this.onLoad=function(b){this.clickUrl=null;
if(b.getProp("source")){this.m_clickUrl=b.getProp("link");
gNetworkMgr.doRequest("fetchad",{type:b.getProp("source"),count:1})
}else{this.renderAd(b)
}};
this.onLoadPartnerAd=function(e){var c=e.ads,d={};
for(var b in c[0]){d[b]=c[0][b]
}d.getProp("click")=this.m_clickUrl;
this.renderAd(d)
};
this.renderAd=function(e){if(this.calculateAvailableHeight()<this.m_sparkHeight){gNetworkMgr.doUILog("Spark","occluded",1,true)
}var b={};
for(var d in e.getProp("track")){b[d]=e.getProp("track")[d]
}e.trackImpression(b);
this.m_contentDiv.innerHTML=this.getAdHtml(e);
cacheImgs(this.m_contentDiv);
this.setDisplay(true);
var c=$("consoleAdLink");
if(e.getProp("companion")){ui.connectEvent(c,"click",this,"launchCompanion",true,false,e)
}else{if(e.getProp("clickUrl")||e.getProp("click")){ui.connectEvent(c,"click",this,function(){trackClickInIframe("SparkAdClickIframe",e.getProp("clickUrl")||e.getProp("click"));
var f={type:"click"};
for(var g in e.getProp("track")){f[g]=e.getProp("track")[g]
}e.track(f)
})
}}this.positionOverlay();
this.onUpdate()
};
this.launchCompanion=function(c,b){if(gMediaBar.getAd()&&gMediaBar.getAd().getProp("share")==b.getProp("companion")){gMediaBar.launchAd()
}else{gAdServer.load({type:"MediaBar",shareId:b.getProp("companion"),callback:hitch(this,"launchAd")})
}ui.setEventHandled(c);
return false
};
this.calculateAvailableHeight=function(){this.m_element.style.visibility="hidden";
this.setDisplay(true);
this.onUpdate();
var b=gMediaBar.getElement().offsetTop-this.m_element.offsetTop;
this.setDisplay(false);
this.m_element.style.visibility="visible";
return b
}
});
Class("meeboApp.ConsolePoll",meeboApp.ConsoleContainer,function(a){this.initialize=function(){a(this,"initialize");
gClient.subscribe("info::poll",this,"onLoadPolls");
this.m_pollAnimation=new ui.Animation({transition:ui.Animation.easeInOut,duration:1000});
this.m_pollAnimation.addSubject(hitch(this,"onAnimatePoll"));
this.m_closeAnimation=new ui.Animation({transition:ui.Animation.easeInOut,duration:1000});
this.m_closeAnimation.addSubject(hitch(this,"onAnimateClose"));
this.m_resultsAnimation=new ui.Animation({transition:ui.Animation.easeInOut,duration:1000});
this.m_singlePollHeight=185;
this.m_doublePollHeight=315;
this.m_isPollHorizontal=false;
this.m_ad=null
};
this.getWidth=function(){return 320
};
this.initContent=function(){a(this,"initContent");
this.addClassName("ConsoleSparkAd");
this.setDisplay(false);
var b=this.m_contentDiv;
addClassName(b,"Container");
this.positionOverlay();
this.onUpdate()
};
this.onLoad=function(c){this.m_ad=c;
if(this.m_currPoll){gNetworkMgr.doUILog("poll","completed",this.m_currPoll,true);
this.m_currPoll=0
}this.m_polls=[];
this.m_currPoll=0;
var b={count:this.m_ad.getProp("numQuestions")||gNumPollQuestions};
if(this.m_ad.getProp("category")){b.category=this.m_ad.getProp("category")
}gNetworkMgr.doRequest("fetchpoll",b)
};
this.calculateAvailableHeight=function(){this.m_element.style.visibility="hidden";
this.setDisplay(true);
this.onUpdate();
var b=gMediaBar.getElement().offsetTop-this.m_element.offsetTop;
this.setDisplay(false);
this.m_element.style.visibility="visible";
return b
};
this.stripPolls=function(c){for(var b=c.length-1;
b>=0;
b--){if(c[b].poll.category.indexOf("sponsored:")==-1){continue
}c.splice(b,1)
}};
this.stripSponsoredPolls=function(c){for(var b=c.length-1;
b>=0;
b--){if(c[b].poll.category==this.m_ad.getProp("category")){continue
}c.splice(b,1)
}};
this.onLoadPolls=function(c){var b=c.polls;
if(this.m_ad.getProp("type")=="poll"){this.stripPolls(b)
}else{this.stripSponsoredPolls(b)
}this.m_polls=b;
if(b&&b.length>0){var d=this.calculateAvailableHeight();
if(d<=this.m_singlePollHeight){return
}if(this.m_ad.getProp("partnerImpression")){new ui.TrackingPixel(null,this.m_ad.getProp("partnerImpression"),true).create()
}new ui.TrackingPixel(null,this.m_ad.getProp("impression")).create();
this.m_isPollHorizontal=d<=this.m_doublePollHeight;
this.m_hasLoggedResult=false;
gNetworkMgr.doUILog("poll","impression",true,true);
this.renderNextPoll()
}};
this.renderNextPoll=function(){var b=this.m_currPoll==0,c=this.m_currPoll>=this.m_polls.length;
gAdTimer.resetTimer();
if(b){this.initializePolls()
}var e=this.insertEmptyPoll();
if(!c){this.renderPoll(e,this.m_polls[this.m_currPoll].poll,this.m_polls[this.m_currPoll].results)
}else{this.renderPollEnd(e)
}this.setDisplay(true);
if(b){var d=$("console-poll");
d.style.height=e.offsetHeight+"px";
d.scrollLeft=0;
d.scrollTop=0
}else{if(!this.m_closeAnimation.isAnimating()&&$("console-poll-links").offsetHeight<20){this.m_closeAnimation.seekFromTo(0,1)
}}this.m_currPoll++;
this.positionOverlay();
this.onUpdate()
};
this.initializePolls=function(){var c="questionmark-32.png",d=gLang.meeboPolls;
if(this.m_ad.getProp("type")=="sponsoredpoll"){c=this.m_ad.getProp("icon");
d=sprintf(gLang.sponsoredPolls,this.m_ad.getProp("brand"))
}this.m_contentDiv.innerHTML='<div class="poll">'+(this.m_ad.getProp("type")=="sponsoredpoll"?'<img path="poll-sponsored-label.png" class="sponsoredLabel" png="true">':"")+'<div class="icon"><img path="'+c+'" width="32" height="32"></div>			<div class="greeting">'+d+'</div>			<div id="console-poll" class="scrollContainer">			<table id="console-poll-table" class="questions"></table>			</div>			<div class="hide" id="console-poll-links">			<span id="console-poll-hide">'+capitalize(gLang.hideQuestions)+'</span>			<span id="console-poll-next">'+capitalize(gLang.nextQuestion)+"</span>			<div>		</div>";
cacheImgs(this.m_contentDiv);
ui.connectEvent(this.m_contentDiv.firstChild,"mousedown",ui,"setEventHandled",true,false,true);
var e=$("console-poll-links"),b=$("console-poll-hide"),f=$("console-poll-next");
util.css.setOpacity(e,0.85);
ui.connectEvent(b,"click",this,"onHidePoll",false,false);
ui.connectEvent(b,"mouseover",window,"addClassName",false,false,b,"hover");
ui.connectEvent(b,"mouseout",window,"removeClassName",false,false,b,"hover");
if(this.m_isPollHorizontal){ui.connectEvent(f,"click",this,"scrollNextPoll",false,false);
ui.connectEvent(f,"mouseover",window,"addClassName",false,false,f,"hover");
ui.connectEvent(f,"mouseout",window,"removeClassName",false,false,f,"hover")
}else{$("console-poll-next").style.display="none"
}};
this.insertEmptyPoll=function(){var b=$("console-poll-table");
if(this.m_isPollHorizontal){if(b.rows.length==0){b.insertRow(-1)
}var e=b.rows[0].insertCell(-1);
e.vAlign="top";
var d=this.m_win.document.createElement("div");
e.appendChild(d);
b.style.width=(b.rows[0].cells.length*320)+"px"
}else{var c=b.insertRow(-1);
var e=c.insertCell(-1);
e.vAlign="top";
var d=this.m_win.document.createElement("div");
e.appendChild(d)
}return d
};
this.renderPoll=function(e,g,d){setText(e,g.question);
var k=this.m_win.document.createElement("ol");
k.type="A";
e.appendChild(k);
var b={};
for(var c=0,m;
(m=g.answers[c]);
c++){var n=this.m_win.document.createElement("li");
n.title=m.human;
n.id=getUniqueId();
k.appendChild(n);
var f=this.m_win.document.createElement("div");
addClassName(f,"content");
var l=this.m_win.document.createElement("div");
addClassName(l,"answer");
setText(l,m.human);
f.appendChild(l);
n.appendChild(f);
var o=m.shortname;
b[o]=n.id;
ui.connectEvent(n,"click",this,"onAnswer",false,false,g,d,o,b);
ui.connectEvent(n,"mouseover",window,"addClassName",false,false,n,"hover");
ui.connectEvent(n,"mouseout",window,"removeClassName",false,false,n,"hover")
}if(!this.m_isPollHorizontal){var h=this.m_win.document.createElement("div");
h.innerHTML="<div/>";
addClassName(h,"seperator");
e.appendChild(h)
}};
this.renderPollEnd=function(b){gNetworkMgr.doUILog("poll","atend",true,true);
if(this.m_ad.getProp("title")){b.innerHTML=sprintf('<b>%1</b><br><a href="%2" target="_blank">%3 &#187;</a>',this.m_ad.getProp("title"),this.m_ad.getProp("link"),this.m_ad.getProp("text"));
addClassName(b,"stopNoticeSponsored")
}else{b.innerHTML=gLang.answeredAllQuestions;
addClassName(b,"stopNotice")
}};
this.scrollNextPoll=function(){$("console-poll-next").style.display="none";
if(this.m_currPoll>this.m_polls.length){setText($("console-poll-hide"),capitalize(gLang.hide))
}this.m_startHeight=$("console-poll").offsetHeight;
if(this.m_isPollHorizontal){this.m_startScroll=$("console-poll").scrollLeft
}else{this.m_startScroll=$("console-poll").scrollTop
}this.m_pollAnimation.seekFromTo(0,1)
};
this.onAnswer=function(m,g,f,e){if(this.m_currPoll==1&&this.m_ad&&(this.m_ad.getProp("clickUrl")||this.m_ad.getProp("click"))){trackClickInIframe("PollClickIframe",this.m_ad.getProp("clickUrl")||this.m_ad.getProp("click"))
}g[f]=(g[f]||0)+1;
var n=0;
for(var t in g){n+=g[t]
}var d=[];
for(var t in e){var q=$(e[t]);
if(!q){continue
}addClassName(q,"result");
if(f==t){addClassName(q,"selected")
}var p=g[t]||0,c=Math.round(p/n*100),o=Math.floor(p/n*200);
var l=q.firstChild,b=f==t?"poll-fg-selected.png":"poll-fg.png";
var s=this.m_win.document.createElement("div");
s.style.visibility="hidden";
l.appendChild(s);
var k=this.m_win.document.createElement("div");
addClassName(k,"graphs");
k.innerHTML='<img path="poll-bg.png" class="bg">				<img path="'+b+'" class="fg">';
cacheImgs(k);
var h=this.m_win.document.createElement("div");
addClassName(h,"percent");
setText(h,"0%");
l.insertBefore(k,l.firstChild);
l.appendChild(h);
d.push({img:q.getElementsByTagName("img")[1],percentDiv:h,width:o,totalPercent:c});
ui.disconnectEvent(q,"click")
}this.m_resultsAnimation.removeAllSubjects();
this.m_resultsAnimation.addSubject(hitch(this,"onAnimateResults",d));
this.m_resultsAnimation.seekFromTo(0,1);
if(this.m_isPollHorizontal){$("console-poll-next").style.display="inline"
}if(!this.m_hasLoggedResult){gNetworkMgr.doUILog("poll","click",true,true);
this.m_hasLoggedResult=true
}gNetworkMgr.doRequest("setfact",{type:"poll_answers",key:m.id,value:f});
this.renderNextPoll();
if(!this.m_isPollHorizontal){this.scrollNextPoll()
}};
this.onAnimateResults=function(c,e){for(var b=0,d;
(d=c[b]);
b++){c[b].img.style.width=Math.floor(c[b].width*e)+"px";
setText(c[b].percentDiv,Math.floor(c[b].totalPercent*e)+"%")
}};
this.onAnimatePoll=function(c){var e=$("console-poll"),b=$("console-poll-table");
if(this.m_isPollHorizontal){var l=b.rows[0].cells,h=l[l.length-1].firstChild;
e.style.height=this.m_startHeight+Math.floor((h.offsetHeight-this.m_startHeight)*c);
this.positionOverlay();
this.onUpdate();
e.scrollLeft=this.m_startScroll+(320*c)
}else{var d=b.rows[b.rows.length-2].cells[0].firstChild,h=b.rows[b.rows.length-1].cells[0].firstChild;
var f=h.offsetHeight+d.offsetHeight;
e.style.height=this.m_startHeight+Math.floor((f-this.m_startHeight)*c);
this.positionOverlay();
this.onUpdate();
if(b.rows.length>2){var g=d.parentNode,k=h.parentNode;
e.scrollTop=this.m_startScroll+Math.floor((g.offsetTop-this.m_startScroll)*c)
}}};
this.onAnimateClose=function(b){$("console-poll-links").style.height=Math.floor(20*b)+"px";
this.positionOverlay();
this.onUpdate()
};
this.onHidePoll=function(b){if(this.m_currPoll!=0){gNetworkMgr.doUILog("poll","hide",this.m_currPoll<this.m_polls.length?this.m_polls[this.m_currPoll-1].poll.id:"end",true)
}this.setDisplay(false);
gAdTimer.loadAds("Spark")
}
});
Class("meeboApp.ConsoleRevertTakeover",meeboApp.ConsoleContainer,function(a){this.initialize=function(){a(this,"initialize");
gPubSub.subscribe("meeboApp.ConsolePageMain::setWallpaper",this,"onSetWallpaper");
gPubSub.subscribe("meeboApp.skins::setSkin",this,"onSetSkin");
this.m_skinId="skin1"
};
this.getWidth=function(){return 320
};
this.initContent=function(){a(this,"initContent");
this.addClassName("ConsoleRevertTakeover");
this.setDisplay(false);
var b=this.m_contentDiv;
this.m_contentDiv.innerHTML='<div class="Revert"><img path="revert-gem-blue.png"			height="32" align="left" id="RevertGem" png="true">'+sprintf(gLang.changeBackTo,'<span id="RevertName">',"</span>")+"</div>";
cacheImgs(this.m_contentDiv);
ui.connectEvent(this.getElement(),"click",this,"doRevert");
if(gConsoleMgr.getMainPage().m_wallpaperUrl==gTakeover.bgimage_inside){this.enableRevert()
}else{this.positionOverlay();
this.onUpdate()
}};
this.doRevert=function(){gSkins.setSkin(this.m_skinId);
gPrefs.savePref("enableWallpaper",false);
gConsoleMgr.getMainPage().setWallpaper(null);
meebo.util.createTrackingPixel({component:"Takeover",type:"revert"},gLogon.getLogons())
};
this.onSetSkin=function(e,b,c){this.m_skinId=c;
var f=$("RevertGem"),d=$("RevertName");
if(!f||!d){return
}f.style.border="1px solid white";
gImages.requestImage("revert-gem-"+gSkins.pathFromSkin(c)+".png",f);
setText(d,gSkins.nameFromSkin(c).toLowerCase())
};
this.enableRevert=function(){this.setDisplay(true);
if(!isEmpty(gMediaBar.getAd())){new ui.TrackingPixel({},gTakeover.impression_inside).create()
}gPubSub.subscribe("meeboApp.AdTimer::loadAds",this,function(c,b,d){if(d!="MediaBar"){return
}new ui.TrackingPixel({},gTakeover.impression_inside).create()
});
this.positionOverlay();
this.onUpdate()
};
this.onSetWallpaper=function(d,b,c){if((("bgimage_inside" in gTakeover&&c==gTakeover.bgimage_inside)||("livepaper" in gTakeover&&c==gTakeover.livepaper))&&!gTakeover.disable_revert&&this.getDisplay()=="none"){this.enableRevert();
return
}gPubSub.unsubscribe("meeboApp.ConsolePageMain::setWallpaper",this);
gPubSub.unsubscribe("meeboApp.skins::setSkin",this);
removeClassName(document.body,"HasWallpaper");
this.setDisplay(false);
this.positionOverlay();
this.onUpdate()
}
});
Class("meeboApp.ConsoleUpsell",meeboApp.ConsoleContainer,function(a){this.initialize=function(){a(this,"initialize")
};
this.initContent=function(){this.addClassName("ConsoleUpsell");
a(this,"initContent");
this.m_contentDiv.innerHTML='<div class="title">'+gLang.upsellLine1+"</div>			<ul><li>"+gLang.upsellLine2+"</li>			<li>"+gLang.upsellLine3+"</li>			<li>"+gLang.upsellLine4+'</li></ul>			<div class="callToAction">				<img path="console-freshman.png" png="true" align="left">				<span id="'+this.m_id+'-join">'+gLang.upsellLine5+"</span>			</div>";
cacheImgs(this.m_contentDiv);
ui.connectEvent($(this.m_id+"-join"),"click",gWindowMgr,"createCreateMeeboAccountDlg",false,false,{},"guest-upsell","upsell_accounts.png",null);
disableSelection(this.getElement(),true)
};
this.getWidth=function(){return 320
}
});
Class("meeboApp.ConsoleExtension",ui.Element,function(a){this.initialize=function(){a(this,"initialize");
this.m_height=100
};
this.createContent=function(){this.addClassName("ConsoleExtension");
this.createSeperator();
this.m_links=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_links,"links")
};
this.createSeperator=function(){var b=this.m_win.document.createElement("div");
b.appendChild(this.m_win.document.createElement("div"));
addClassName(b,"seperator");
this.m_element.appendChild(b);
this.m_element.style.height=this.m_height+"px"
};
this.addLink=function(e,b,c){var d=new meeboApp.ImgLinkButton(e,b);
d.subscribe("click",this,c);
d.create(this.m_win);
this.m_links.appendChild(d.getElement());
return d
};
this.addHeight=function(b){this.m_height+=b;
if(this.m_element){this.m_element.style.height=this.m_height+"px"
}};
this.getHeight=function(){return this.m_height
}
});
Class("meeboApp.ConsoleExtensionInfoCollect",meeboApp.ConsoleExtension,function(a){this.initialize=function(){a(this,"initialize");
this.m_height=85
};
this.createContent=function(){a(this,"createContent");
var b=this.m_win.document.createElement("div");
var c=this.m_win.document.createElement("div");
this.addClassName("info");
addClassName(c,"greeting");
addClassName(b,"icon");
b.appendChild(createImg(getUniqueId(),b,null,null,gImages.getPath()+"questionmark.png","questionmark",true,"bottom",true));
setText(c,gLang.meeboGetToKnowYou);
this.m_element.appendChild(b);
this.m_element.appendChild(c);
this.m_form=new ui.Form(this.m_element,{handler:hitch(this,"onAgeGenderSubmit"),items:[{type:"text",name:"Age",label:gLang.age+":",verify:function(d){return(d&&d.match(/[1-9][0-9]*/)&&d<121)
}},{type:"radio",name:"Gender",options:["Male","Female"],checked:"Male",verify:function(d){return d&&d.match(/Male|Female/i)
}},{type:"submitlink",text:gLang.submit}]});
this.m_form.initContent()
};
this.onAgeGenderSubmit=function(b){if(b.Age<13){gWindowMgr.createDateDlg({parent:this.m_win.document.body,id:"ageVerification"},gLang.pleaseEnterYourBirthday,hitch(this,"verifyDate",b),"questionmark.png")
}else{this.submitData(b)
}this.setDisplay(false)
};
this.verifyDate=function(e,d){var c=new Date(d.year+13,d.month-1,d.day);
var b=new Date();
if(c.getTime()>b.getTime()){gNetworkMgr.doRequest("deleteuserinfo");
this.publish("done")
}else{e.birthyear=d.year;
this.submitData(e)
}};
this.submitData=function(b){gNetworkMgr.doRequest("setuserprofile",{birthyear:b.birthyear||new Date().getFullYear()-b.Age,gender:b.Gender});
this.publish("done")
}
});
Class("meeboApp.ConsoleExtensionNotifier",meeboApp.ConsoleExtension,function(a){this.initialize=function(){a(this,"initialize");
this.m_height=125
};
this.createContent=function(){a(this,"createContent");
this.addClassName("NotifierExtension");
this.createImage();
this.createLinks();
this.createText();
this.createButton()
};
this.createImage=function(){var b=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(b,"imageHolder")
};
this.createLinks=function(){this.addLink(gLang.hideThis,"finish",hitch(this,"onClick",false))
};
this.createText=function(){var c=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(c,"text");
var b='<a href="http://www.meebo.com/notifier/" target="_blank">'+capitalize(gLang.learnMore)+"</a>";
c.innerHTML=gLang.notifierExplanation+" "+b
};
this.createButton=function(){var b=new ui.button("allowButton",gLang.download).create(this.m_win).addClassName("uiButton-big");
b.addOnMouseUp(hitch(this,"onClick",true));
this.m_element.appendChild(b.getElement())
};
this.onClick=function(b){if(b){gWindowMgr.createNotifierUpsellDlg();
meeboApp.downloadNotifier("consolelarge")
}else{if(gLogon.hasMeeboAccount()){gPrefs.savePref("noNotifierThanks",true)
}else{util.storage.save("noNotifierThanks",true)
}}this.publish("done",b)
}
});
Class("meeboApp.ConsolePageContainers",ui.element,function(a){this.initialize=function(){a(this,"initialize");
this.m_containers=[];
this.m_containerIndex={};
this.m_verticalSpacing=24;
this.m_topLeftPos={x:20,y:73}
};
this.addContainer=function(d,b,c,e,f){c=c||this.m_containers.length;
this.m_containers.splice(c,0,{constructor:b,id:getUniqueId(),mainContainer:f,name:d});
if(e){this.updateContent();
return this.m_containers[c].obj
}};
this.updateContent=function(){if(!this.m_element){this.m_element=this.m_win.document.createElement("div");
this.m_element.id=this.m_id;
document.body.appendChild(this.m_element);
this.addClassName("meeboConsole")
}for(var b=0;
b<this.m_containers.length;
b++){if(!this.m_containers[b].obj){this.m_containers[b].obj=new this.m_containers[b].constructor();
if(this.m_containerIndex[this.m_containers[b]["name"]]){throw new Error("Console container name must be unique.")
}this.m_containerIndex[this.m_containers[b]["name"]]=this.m_containers[b].obj;
this.m_containers[b].obj.create(this.getElement(),this.m_containers[b].id);
this.m_containers[b].obj.addOnUpdate(hitch(this,"positionContainers"));
this.positionContainers()
}else{this.m_containers[b].obj.update(this.getElement())
}if(this.m_containers[b].mainContainer){this.setMainContainer(this.m_containers[b].obj)
}}};
this.getContainer=function(b){return this.m_containerIndex[b]
};
this.setMainContainer=function(b){this.m_mainConsoleContainer=b
};
this.getMainContainer=function(){return this.m_mainConsoleContainer
};
this.positionContainers=function(){var c=this.m_topLeftPos.y;
for(var b=0;
b<this.m_containers.length;
b++){if(!this.m_containers[b].obj||this.m_containers[b].obj.getDisplay()=="none"){continue
}this.m_containers[b].obj.setPos(this.m_topLeftPos.x,c);
c+=this.m_containers[b].obj.getHeight()+this.m_verticalSpacing
}}
});
Class("meeboApp.ConsolePageMain",meeboApp.ConsolePageContainers,function(a){this.initialize=function(){a(this,"initialize");
this.m_id="ConsolePageMain";
this.m_registrationMode=false;
this.addContainer("accounts",meeboApp.ConsoleAccounts,null,null,true);
if(hasClassName(document.body,"HasWallpaper")){this.addContainer("revertTakeover",meeboApp.ConsoleRevertTakeover)
}this.addContainer("favorites",meeboApp.Application.ConsoleFavorites);
this.addContainer("spark",meeboApp.ConsoleSparkAd);
this.addContainer("poll",meeboApp.ConsolePoll);
gPubSub.subscribe("meebo.EventMgr::changeState",this,"onEventMgrChangeState");
gPubSub.subscribe("meebo.Logon::changeState",this,"onLogonChangeState");
gPubSub.subscribe("meeboApp.skins::setSkin",this,"onSaveSkinPref");
gPubSub.subscribe("meebo.Prefs::loadWallpaper",this,"onLoadWallpaper");
gPubSub.subscribe("ui.imagecache::skinLoaded",this,"updateContent")
};
this.updateContent=function(){a(this,"updateContent");
if(!this.m_consoleNav){this.m_consoleNav=new meeboApp.ConsoleNav();
this.m_consoleNav.create(this.getElement(),getUniqueId()+"-consoleNav");
this.m_consoleNav.showOverlay(false);
this.onResize()
}};
this.onLogonChangeState=function(c,b,d){if(gEventMgr.getState()!="im"||c.isAnonymous()||!c.isOnline()){return
}this.updateContent();
this.setVisibility(true);
gPubSub.unsubscribe("meebo.Logon::changeState",this)
};
this.onEventMgrChangeState=function(d,b,f,c){var e=f in arrayToObject(["im","reconnecting","done"])&&!gIsGuestGroupChat;
if(e){this.updateContent()
}this.setVisibility(e)
};
this.onLoadWallpaper=function(d,b,c){this.setWallpaper(c)
};
this.setTakeoverWallpaper=function(){var b=((!ui.isLinux&&util.flash.getVersion().major>=7&&gMediaBar)&&gTakeover.livepaper)||gTakeover.bgimage_inside;
if(!b){return
}this.setWallpaper(b,true,gTakeover.bgimage_disable_gradient);
meebo.util.createTrackingPixel({component:"Takeover",type:"set"},gLogon.getLogons())
};
this.setWallpaper=function(c,b,d){ui.Wallpaper.setWallpaper((gPrefs.getPref("enableWallpaper",false)||b)?c:null,d);
gPubSub.publish(this,"meeboApp.ConsolePageMain::setWallpaper",c);
this.m_wallpaperUrl=c
};
this.getCurrentWallpaperUrl=function(){return this.m_wallpaperUrl
};
this.onSaveSkinPref=function(d,b,c){var e=gSkins.getSkin(c);
if(e.invertedLogo){addClassName($("meebologo"),"invertedMeeboLogo")
}else{removeClassName($("meebologo"),"invertedMeeboLogo")
}};
this.onResize=function(){if(this.m_consoleNav){var e=gBuddyListDlg?gBuddyListDlg.getWindowPos().w:235;
var d=e+this.m_consoleNav.getWidth()+65;
var c=245;
var b=Math.max(calcWinPos(this.m_win).w-d,c);
this.m_consoleNav.setPos(b,15)
}};
this.setRegistrationMode=function(d,b){if(this.m_registrationMode==d){return
}this.m_registrationMode=d;
gPubSub.publish(this,"meeboApp.ConsolePageMain::changeRegistrationMode",d);
if(d){var c=new meeboApp.RegistrationManager(b);
c.subscribe("finished",this,hitch(this,"setRegistrationMode",false));
c.start()
}};
this.getRegistrationMode=function(){return this.m_registrationMode
}
});
Class("meeboApp.ConsolePageGuest",meeboApp.ConsolePageContainers,function(a){this.initialize=function(){a(this,"initialize");
this.m_id="ConsolePageGuest";
this.m_containers=[{constructor:meeboApp.ConsoleInfoBlock,id:getUniqueId()+"-infoBlock"},{constructor:meeboApp.Application.ConsoleFavorites,id:getUniqueId()+"-consoleFavorites"},{constructor:meeboApp.ConsoleUpsell,id:getUniqueId()+"-consoleUpsell"}];
gPubSub.subscribe("meebo.EventMgr::changeState",this,"onEventMgrChangeState");
gPubSub.subscribe("meebo.Logon::changeState",this,"onLogonChangeState")
};
this.updateContent=function(){a(this,"updateContent");
var b=meebo.util.getMeeboApplicationLink(document.location)!=null;
if(b){return
}for(var c=0;
c<this.m_containers.length;
c++){if(!this.m_containers[c].obj){continue
}this.m_containers[c].obj.setDisplay(false)
}};
this.onLogonChangeState=function(c,b,d){if(c.isAnonymous()||!c.isOnline()){return
}meeboApp.GuestDownload.setVisibility(false);
this.setVisibility(false);
gPubSub.unsubscribe("meebo.Logon::changeState",this)
};
this.onEventMgrChangeState=function(d,b,f,c){var e=gEventMgr.getState()=="im"&&gIsGuestGroupChat;
if(e){this.updateContent()
}this.setVisibility(e)
}
});
Class("meeboApp.AdTimer",function(){this.initialize=function(){this.m_isPaused=true;
this.m_delaySeconds=gAdTargetingInfoDelay||1;
this.m_firstAdsLoaded=false;
this.m_firstAdTimeout=null;
this.m_loadAdsTimeout=null;
this.m_rotationInterval=120;
this.m_lastTime=0;
gClient.subscribe("info::rotation",this,"setInterval");
gTargeting.subscribe("ready",this,"onTargetingReady")
};
this.onTargetingReady=function(){gTargeting.unsubscribe("ready",this,"onTargetingReady");
this.loadAds();
this.resumeRotation()
};
this.resetTimer=function(){this.m_lastTime=Math.floor(new Date().getTime()/1000)
};
this.isPaused=function(){return this.m_isPaused
};
this.pauseRotation=function(){this.m_isPaused=true
};
this.resumeRotation=function(){if(!this.m_isPaused){return
}this.m_isPaused=false;
this.resetTimer()
};
this.setInterval=function(a){this.m_rotationInterval=a.interval
};
this.checkInterval=function(){if(this.m_isPaused){return
}var a=Math.floor(new Date().getTime()/1000);
if(a-this.m_lastTime>=this.m_rotationInterval){this.loadAds();
this.m_lastTime=a
}};
this.loadAds=function(a){clearTimeout(this.m_loadAdsTimeout);
var b=hitch(this,function(){this.m_loadAdsTimeout=null;
var d=new Date().getTime();
var c=[{type:"MediaBarPartnerOkay",shareId:meeboApp.mediaBarAdId,callback:hitch(gMediaBar,"onLoadMediaBar")}];
if(!gIsGuestGroupChat){c.push({type:"Spark",shareId:meeboApp.sparkAdId,callback:hitch(this,function(e){var f,g;
if(e.getProp("type")=="poll"||e.getProp("type")=="sponsoredpoll"){f="poll";
g="spark"
}else{if(!e.getProp("type")){f="spark";
g="poll"
}}if(f&&g){gConsoleMgr.getMainPage().getContainer(f).onLoad(e);
gConsoleMgr.getMainPage().getContainer(g).setDisplay(false)
}})})
}gAdServer.load(c);
gPubSub.publish(this,"meeboApp.AdTimer::loadAds","MediaBar")
});
if(a){b()
}else{this.m_loadAdsTimeout=setTimeout(b,3000)
}};
this.delayLoadAds=function(){if(this.m_loadAdsTimeout===null){return
}this.loadAds()
}
});
Class("meeboApp.Share",function(){this.initialize=function(){this.m_recentlyViewed=[];
this.m_shouldGleam=false;
this.m_gleamTime=20;
this.m_newShares=0;
this.m_newSharesTime=5000;
this.m_linkCallbacks={};
gClient.subscribe("info::recently_viewed",this,"onRecentlyViewed");
if(util.query.getHashVariable(util.query.ADD_BUDDY_USERNAME)){gPubSub.subscribe("meebo.MeeboAccount::changeState",this,function(b,a,c){if(c=="online"){gClient.subscribe("EventsProcessed",this,"onMeeboUserLoggedOn")
}})
}};
this.onMeeboUserLoggedOn=function(){gPubSub.unsubscribe("meebo.MeeboAccount::changeState",this);
gClient.unsubscribe("EventsProcessed",this,"onMeeboUserLoggedOn");
this.handleUrlClick(meeboApp.href)
};
this.getRecentlyViewed=function(){return this.m_recentlyViewed
};
this.getRecentAdLaunch=function(){for(var a=0,b;
(b=this.m_recentlyViewed[a]);
a++){if(b.sponsored){break
}}return b
};
this.handleUrlClick=function(a,l){var b=false;
var e=util.query.url(a);
var d=e.host&&/(^|\.)meebo\.com$/i.test(e.host);
var k=getURIParamsAsObject(e.hash);
if(d){var n=meebo.util.getMeeboShareLink(a);
if(n){var f=function(p){gAdServer.normalize(p);
m(new ads.Ad("MediaBar",p))
};
var m=function(p){p.setProp("userParams",getURIParamsAsObject(n.query));
gMediaBar.launchAd(p)
};
var h=hitch(gAdServer,"load",{type:"MediaBar",shareId:n.share,callback:m});
gAdServer.shareClick(n,"meebo.com",f,h);
b=true
}else{if(k[util.query.ADD_BUDDY_USERNAME]){var g=k[util.query.ADD_BUDDY_USERNAME];
this.handleAddBuddyLinkClick(g);
b=true
}else{if(e.pathname.match(/^\/add/)){var g=e.pathname.split("/")[2];
this.handleAddBuddyLinkClick(g);
b=true
}}}}else{if(gComishify){var o=document.createElement("script");
var c=getUniqueId();
this.m_linkCallbacks[c]={callback:hitch(this,"onLoadLink",c),timer:setTimeout(hitch(this,"onLoadLink",c,a),2000),win:util.openPopup({id:c},true),script:o};
o.src="http://api.viglink.com/api/click?"+getObjectAsURIParams({key:"d129188a7eb17afcc5071eef03c74394",out:a,loc:"http://www.meebo.com",format:"jsonp",jsonp:"meeboApp.share.m_linkCallbacks["+c+"].callback"});
document.getElementsByTagName("head")[0].appendChild(o);
b=true
}}return b
};
this.onLoadLink=function(c,a){if(!(c in this.m_linkCallbacks)){return
}clearTimeout(this.m_linkCallbacks[c].timer);
this.m_linkCallbacks[c].win.location.href=a;
var b=this.m_linkCallbacks[c].script;
setTimeout(hitch(this,function(){removeElement(b)
}),0);
delete this.m_linkCallbacks[c]
};
this.saveLink=function(a,c,b){gNetworkMgr.doRequest("arv",{name:c||"",url:a,eventtime:(new Date()).getTime()/1000,sponsored:b})
};
this.handleAddBuddyLinkClick=function(b){if(!b){return
}var a=gLogon.getMeeboMeLogon();
if(!a){gWindowMgr.createCreateMeeboAccountDlg({caption:sprintf(gLang.signupToAddBuddy,b)},"buddylink-protocol","upsell_accounts.png",hitch(this,"handleAddBuddyLinkClick",b))
}else{if(!a.isOnline()){gPubSub.subscribe(a,"meebo.Logon::changeState",this,function(d,c,e){if(e=="online"){gPubSub.unsubscribe(a,"meebo.Logon::changeState",this);
this.doAddBuddy(b,a.getUser())
}})
}else{this.doAddBuddy(b,a.getUser())
}}};
this.doAddBuddy=function(g,f){var c=gLogon.getMeeboMeLogon();
var b=gBuddyList.addBuddy(g+"@meebo.org",c);
if(meebo.util.stripJabber(c.getName())==meebo.util.stripJabber(b.getName())){return
}var e="Meebo";
runInMainContext(gNetworkMgr,gNetworkMgr.requestAddBuddy,hitch(gNetworkMgr,"receiveAddBuddy"),b.getName(),c.getNetwork().getProtocol(),e,f);
var a=gWindowMgr.createIMWindow(b);
var d=new meeboApp.IMDlgBuddyLinkOverlay(b);
if(a._){a._("setHistoryOverlay",d)
}else{a.setHistoryOverlay(d)
}};
this.onRecentlyViewed=function(f){var a=0;
for(var c=0;
c<f.length;
c++){var d=f[c],e=false;
for(var b=this.m_recentlyViewed.length-1;
b>=0;
b--){if(this.m_recentlyViewed[b].url==d.url){if(this.m_recentlyViewed[b].name){d.name=this.m_recentlyViewed[b].name
}this.m_recentlyViewed.splice(b,1);
e=true
}}d.isNew=new Date().getTime()/1000-d.eventtime<this.m_gleamTime;
if(d.isNew&&!e){a++
}this.m_recentlyViewed.splice(0,0,d)
}this.addNewShares(a)
};
this.addNewShares=function(a){this.setNewShares(this.m_newShares+a)
};
this.clearNewShares=function(){this.setNewShares(0)
};
this.getNewShares=function(){return this.m_newShares
};
this.setNewShares=function(a){clearTimeout(this.m_newSharesTimeout);
if(a){this.m_newSharesTimeout=setTimeout(hitch(this,"clearNewShares"),this.m_newSharesTime)
}this.m_newShares=a;
gPubSub.publish(this,"meeboApp.Share::newShares",a)
};
this.getBuddyLink=function(a){var b=gLogon.getMeeboUser(true);
if(!b){return null
}return(a?"":"http://")+"meebo.com/add/"+b
}
});
VideoEgg={};
VideoEgg.mediaBarAd=null;
VideoEgg.loadJS=function(){if(window.location.protocol=="https:"){return
}function a(c){var b=document.createElement("script");
b.src=c;
b.type="text/javascript";
document.documentElement.firstChild.appendChild(b)
}a("http://core.videoegg.com/eap/html/js/init.js?"+Math.floor(Math.random()*99999999));
document.write=function(c){var b=/<script src="([^"]*)"><\/script>/.exec(c);
if(b){a(b[1])
}}
};
VideoEgg.CustomTakeoverAction=function(){this.supr.call(this)
};
VideoEgg.CustomTakeoverAction.prototype.create=function(){VideoEgg.takeoverAction=this;
this.supr()
};
VideoEgg.CustomTakeoverAction.prototype.show=function(){this.supr();
if(this._enabled){try{VideoEgg.mediaBarAd=gMediaBar.launchAd();
VideoEgg.mediaBarAd.customTakeoverAction=this;
this.onShowComplete()
}catch(a){}}};
VideoEgg.CustomTakeoverAction.prototype.hide=function(){this.supr();
try{this._element.style.display="none";
this.onHideComplete();
gMediaBar.doToggle(true)
}catch(a){}};
VideoEgg.CustomTakeoverAction.prototype.destroy=function(){this.supr()
};
VideoEgg.CustomTakeoverAction.prototype.getDimensions=function(){return{width:900,height:400}
};
VideoEgg.CustomTakeover=function(){this.supr.call(this)
};
VideoEgg.CustomTakeover.prototype.create=function(){VideoEgg.takeover=this;
this.supr()
};
VideoEgg.CustomTakeover.prototype.show=function(){this.supr();
VideoEgg.mediaBarAd.customTakeover=this;
VideoEgg.mediaBarAd.getMediaContainer().appendChild(this._element)
};
VideoEgg.CustomTakeover.prototype.hide=function(){this.supr()
};
VideoEgg.CustomTakeover.prototype.destroy=function(){this.supr()
};
VideoEgg.CustomTakeover.prototype.getDimensions=function(){return{width:900,height:400}
};
Class("meeboApp.InviteBuddies",ui.element,function(a){this.initialize=function(d,e,b,c){a(this,"initialize");
this.control=d;
this.m_title=e;
this.m_messageTitle=b;
this.m_message=c
};
this.create=function(c,b){this.m_id=c;
this.m_win=gWin(b);
this.m_element=this.m_win.document.createElement("div");
this.m_element.id=c;
this.m_element.innerHTML=this.getTemplateHtml();
b.appendChild(this.m_element);
this.addClassName("InviteBuddies");
this.initBuddies();
this.connectContentEvents()
};
this.getTemplateHtml=function(){var e=this.getId();
var d='<div class="Header">'+this.m_title+"</div>";
var c='<div class="Invite"><div class="Title">'+this.m_messageTitle+'</div>			<textarea class="Message" id="'+e+'-message">'+this.m_message+"</textarea></div>";
var b='<div class="List" id="'+e+'-buddies"></div>			<div class="Links"><span id="'+e+'-checkAll"			class="Link"><span class="Text">'+gLang.checkAll+'</span></span>&nbsp&nbsp|&nbsp&nbsp<span id="'+e+'-clearAll"			class="Link"><span class="Text">'+gLang.uncheckAll+"</span></span></div>";
return[d,c,b].join("")
};
this.initBuddies=function(){var c=this.getId();
var h=$(c+"-buddies");
var k=[];
var b={};
gBuddyList.withGroups(hitch(this,function(p){var o=p.getBuddies();
for(var n=0,m;
(m=o[n]);
n++){if(m.getType()!="buddy"||m.isOnline()==false||(m.getNetwork()=="meebome"&&m.isGuestUser())){continue
}k.push(m);
b[m.getId()]=meeboApp.util.protocol.getBuddyProtocolIcon(m)
}}));
k.sort(sortBuddies);
var g="";
for(var e=0;
e<k.length;
e++){invitee=k[e];
var f=getTruncatedText(invitee.getAlias(),180,null,null,h);
var d=c+"-buddy"+e;
var l=invitee.getIconURL()||(window.location.protocol=="https:"?"https://origin-":"http://")+"icons.meebo.com/stock/meebo_bubble.png";
g+='<div class="Buddy"><img align="left"					path="'+l+'" width="30"					height="30"><input type="checkbox" id="'+d+'" 					buddyid="'+escapeHTML(invitee.getId())+'"><label for="'+d+'">'+f+"</label></div>"
}h.innerHTML=g;
cacheImgs(h);
disableSelection(h,true)
};
this.connectContentEvents=function(){var b=$(this.getId()+"-checkAll");
var e=$(this.getId()+"-clearAll");
ui.connectEvent(b,"mouseover",this,"showHover",false,false,b);
ui.connectEvent(b,"mouseout",this,"removeHover",false,false,b);
ui.connectEvent(b,"click",this,"checkAllBuddies",false,false,true);
ui.connectEvent(e,"mouseover",this,"showHover",false,false,e);
ui.connectEvent(e,"mouseout",this,"removeHover",false,false,e);
ui.connectEvent(e,"click",this,"checkAllBuddies",false,false,false);
var d=$(this.getId()+"-buddies");
var f=d.getElementsByTagName("div");
var g=d.getElementsByTagName("input");
for(var c=0;
c<g.length;
c++){ui.connectEvent(f[c],"mousedown",this,"startToggler",true,false,g[c]);
ui.connectEvent(f[c],"click",ui,"setEventHandled",true,false);
ui.connectEvent(f[c],"mouseover",this,"handleToggleHover",false,false,g[c]);
ui.connectEvent(f[c],"mouseout",this,"handleToggleHover",false,false,g[c])
}};
this.showHover=function(b){b.style.textDecoration="underline"
};
this.removeHover=function(b){b.style.textDecoration="none"
};
this.startToggler=function(c,b){this.m_isChecked=!b.checked;
this.m_isToggling=true;
ui.connectGlobalEvent(this.m_win.document,"mouseup",hitch(this,"stopToggler"));
ui.setEventHandled(c);
this.handleToggleHover(b)
};
this.stopToggler=function(){this.m_isToggling=false;
ui.disconnectGlobalEvent(this.m_win.document,"mouseup")
};
this.handleToggleHover=function(b){if(!this.m_isToggling){return
}b.checked=this.m_isChecked
};
this.checkAllBuddies=function(d){var c=$(this.getId()+"-buddies").getElementsByTagName("input");
for(var b=0;
b<c.length;
b++){c[b].checked=d
}};
this.getSelectedBuddies=function(){var d=$(this.getId()+"-buddies").getElementsByTagName("input");
var e=[];
for(var c=0;
c<d.length;
c++){if(!d[c].checked){continue
}var f=d[c].getAttribute("buddyid");
var b=gBuddyList.getBuddyById(f);
if(b){e.push(b)
}}return{buddies:e,message:$(this.getId()+"-message").value}
}
});
Class("meeboApp.SkinSelector",ui.element,function(a){this.initialize=function(){a(this,"initialize");
this.m_currentSkin=gPrefs.getPref("meeboSkin")
};
this.getCurrentSkin=function(){return this.m_currentSkin
};
this.create=function(g,d){this.m_win=gWin(d);
this.m_id=g;
this.m_element=this.m_win.document.createElement("div");
this.addClassName("SkinSelector");
this.m_element.id=this.m_id;
var f=gSkins.getSkins();
for(var e in f){var c=this.m_win.document.createElement("div");
if(e=="skin10"){c.style.marginLeft="6px"
}addClassName(c,"SkinColorCell");
c.id=this.m_id+"-skin"+e;
var b=this.m_win.document.createElement("img");
gImages.requestImage(gSkins.pathFromSkin(e)+"_gem.png",b);
c.appendChild(b);
this.m_element.appendChild(c);
ui.connectEvent(c,"mousedown",this,"onSelectSkin",true,false,e);
if(this.m_currentSkin==e){addClassName(c,"SkinColorCellSelected")
}}d.appendChild(this.m_element)
};
this.onSelectSkin=function(d,b){var f=gSkins.getSkins();
for(var c in f){removeClassName($(this.m_id+"-skin"+c),"SkinColorCellSelected")
}addClassName($(this.m_id+"-skin"+b),"SkinColorCellSelected");
this.m_currentSkin=b
}
});
meeboApp.Application={};
meeboApp.Application.m_pendingApps={};
meeboApp.Application.launchApp=function(f,a,e,b,d){var c=getUniqueId();
meeboApp.Application.m_pendingApps[c]={dlg:e,invites:b,inviteMsg:d||null,app_id:f.app_id,time:new Date().getTime()};
f.launch(c,a,meeboApp.platform.getPlatformInstanceId(),null)
};
meeboApp.Application.launchAppInviteDlg=function(e,a,c){var b=sprintf(gLang.launchAppDescr,e.alias);
var d=sprintf(gLang.comeJoinMeInApp,e.alias);
gWindowMgr.createInviteDlg({caption:gLang.invite},b,d,false,gLang.launch,function(g,f){if(!g.length){gWindowMgr.createNotifyDlg({id:getUniqueId()+"-notify",caption:gLang.tryAgainHeader},sprintf(gLang.selectBuddiesToInviteDescr,e.alias));
return false
}meeboApp.Application.launchApp(e,g[0].getUser(),null,g,f);
return true
},c)
};
meeboApp.Application.joinApp=function(b,a,f,c,e){var d=gBuddyList.addApplicationRoom(c,e);
d.setLaunchTime(new Date().getTime());
runInMainContext(gNetworkMgr,gNetworkMgr.requestJoinRoom,null,c,b,"",a,f,meeboApp.platform.getPlatformInstanceId());
return d
};
meeboApp.Application.onAppCreated=function(c,a,d,b){if(!meeboApp.Application.m_pendingApps[b]){return
}var e=meeboApp.Application.m_pendingApps[b];
if(e.invites){d.setInvites(meeboApp.Application.m_pendingApps[b].invites,meeboApp.Application.m_pendingApps[b].inviteMsg)
}if(e.dlg){e.dlg.setApplicationRoom(d)
}d.setLaunchTime(e.time);
delete meeboApp.Application.m_pendingApps[b]
};
meeboApp.Application.onAppLoaded=function(a){if(!a.getLaunchId()||meeboApp.m_pendingApps[a.getLaunchId()]){return
}var c=meeboApp.m_pendingApps[a.getLaunchId()].dlg,b=c&&c.m_appList;
if(b){if(b.getDisplay()!="none"){c.toggleAppList()
}b.onAppLoaded()
}};
meeboApp.Application.checkAppLaunch=function(b,g,a,h,d){if(meebo.util.accessByIP()){gWindowMgr.createNotifyDlg({id:getUniqueId(),caption:gLang.cannotLaunchApplication},gLang.cannotLaunchApplicationIP);
return
}var e=gWindowMgr.getApplicationWindows(d);
if(e.length&&!d.multi_instance){var k=b?gLang.acceptInvitationTitle:gLang.launchAppTitle;
var c=b?gLang.youAreAlreadyUsingAppInvite:gLang.youAreAlreadyUsingAppLaunch;
gWindowMgr.createOkDlg({id:getUniqueId(),caption:k},sprintf(c,d.alias),hitch(meeboApp.Application,"closeAllApps",a,d),h,gLang.acceptBtn,null,"warning.gif")
}else{if(g&&g.getApplicationRoom()){var k=b?gLang.acceptInvitationTitle:gLang.launchAppTitle;
var f=g.getApplicationRoom().getApplication();
var c=gLang.youWillLeaveApp;
gWindowMgr.createOkDlg({id:getUniqueId(),caption:k},sprintf(c,f.alias),a,h,gLang.acceptBtn,null,"warning.gif")
}else{a(d)
}}};
meeboApp.Application.closeAllApps=function(c,d){var b=gWindowMgr.getApplicationWindows(d);
for(var a=0;
a<b.length;
a++){b[a].toggleAppArea()
}c(d)
};
Class("meeboApp.Application.List",ui.element,function(a){this.initialize=function(){a(this,"initialize");
this.m_apps=[];
this.m_isDisabled=false;
this.m_isLoading=false;
this.m_loadingRow=null;
this.m_shouldDisable=true;
this.m_imdlg=null;
this.m_selectedRow=null;
this.m_selectedApp=null;
this.m_favoritesCategory={category:"favorites",category_id:-2,category_icon:""};
this.m_featuredCategory={category:"featured",category_id:-1,category_icon:""};
this.createHandler("SelectApp")
};
this.disableOnSelect=function(b){this.m_shouldDisable=b
};
this.create=function(f,d,e,b){var c=gWin(d).document.createElement("div");
c.id=f;
c=d.appendChild(c);
addClassName(c,"ApplicationList");
if(e){this.m_selectedApp=e
}this.m_id=f;
this.m_element=c;
this.m_win=gWin(d);
this.m_imdlg=b
};
this.populateList=function(){var b=meebo.applicationMgr.getCategories();
if(!b.length){meebo.applicationMgr.loadList(hitch(this,"render"))
}else{var c=meebo.applicationMgr.getApplications();
this.render(c,b)
}};
this.getCategories=function(b){return[this.m_favoritesCategory,this.m_featuredCategory].concat(b)
};
this.getCategorizedApps=function(c,g){var k={};
for(var f=0;
f<g.length;
f++){k[g[f].category_id]={apps:[],category:g[f]}
}var l=meebo.applicationMgr.getFeatured();
var b=meebo.applicationMgr.getFavorites();
var h=this.m_imdlg.m_imobject.getLogin();
var m=(h.getNetwork()=="myspace"&&h.getAge()<18);
for(var f=0;
f<c.length;
f++){var e=c[f].category_id;
if(m&&e==meebo.APP_COMMUNICATION_CATEGORY){continue
}var d=c[f].app_id;
if(b[d]){k[this.m_favoritesCategory.category_id].apps.push(c[f])
}if(l[d]){k[this.m_featuredCategory.category_id].apps.push(c[f])
}if(!k[e]){continue
}k[e].apps.push(c[f])
}return k
};
this.render=function(b,k){var d=this.getElement();
while(d.childNodes.length){d.removeChild(d.childNodes[0])
}var g=d.appendChild(this.m_win.document.createElement("div"));
g.className="header";
var m=g.appendChild(this.m_win.document.createElement("span"));
setText(m,gLang.games);
var l=d.appendChild(this.m_win.document.createElement("div"));
l.className="list";
this.m_listDiv=l;
k=this.getCategories(k);
var n=this.getCategorizedApps(b,k);
if(!b.length){}else{for(var e in n){var c=n[e].category;
var b=n[e].apps;
if(!b.length){continue
}for(var h=0;
h<b.length;
h++){var f=b[h];
if(f.enabled==2){continue
}var p=this.m_win.document.createElement("div");
p.id=this.m_id+"-"+f.app_id;
addClassName(p,"row");
if(h==b.length-1){p.style.borderBottom="none"
}if(!f.enabled){addClassName(p,"disabledRow")
}var o=escapeHTML(f.icon_location);
if(window.location.protocol=="https:"){o=o.replace(/^http:\/\/icons/i,"https://origin-icons")
}p.innerHTML='<img src="'+o+'" 							width="24" height="24" class="icon"						><div class="title">'+escapeHTML(f.alias)+'</div						><div class="description">'+(f.enabled?escapeHTML(f.owner_name):gLang.temporarilyDisabled)+"</div>";
l.appendChild(p);
if(f==this.m_selectedApp){this.m_selectedRow=p;
addClassName(p,"selectedRow")
}if(f.enabled){ui.connectEvent(p,"mouseover",this,"onMouseOverRow",false,false,p,f);
ui.connectEvent(p,"mouseout",this,"onMouseOutRow",false,false,p);
ui.connectEvent(p,"click",this,"onClickRow",false,false,f,p)
}}}}disableSelection(d,true);
this.m_apps=b
};
this.onMouseOverRow=function(d,c){if(!this.m_isLoading&&!this.m_isDisabled){addClassName(d,"highlightedRow")
}gInfoDlg.clearHideTimeout();
var b=hitch(this,function(){gInfoDlg.setInfoHtml(this.getPreviewHtml(c));
gInfoDlg.makeVisible();
var e=getElementPosition(d);
gInfoDlg.positionRelativeTo(e.x,e.y,d.offsetWidth,d.offsetHeight)
});
if(!gInfoDlg.isVisible()){gInfoDlg.setTimeout(b,250)
}else{b()
}};
this.getPreviewHtml=function(b){return'<div class="ApplicationPreview">				<div class="title">'+b.alias+'</div>				<div class="description">'+b.info+"</div>"+(b.screenshot_location?'<div class="preview"><img src="'+b.screenshot_location+'"></div>':"")+"</div>"
};
this.onMouseOutRow=function(b){if(!this.m_isLoading&&!this.m_isDisabled){removeClassName(b,"highlightedRow")
}gInfoDlg.setHideTimeout()
};
this.onClickRow=function(b,e){if(this.m_isLoading||this.m_isDisabled){return
}if(e==this.m_selectedRow){return
}removeClassName(this.m_selectedRow,"selectedRow");
if(this.m_shouldDisable){this.m_isLoading=true;
this.m_loadingRow=e;
if(this.m_listDiv){addClassName(this.m_listDiv,"disabled")
}addClassName(e,"loadingRow");
var d=this.m_win.document.createElement("div");
d.className="icon loadingIcon";
var c=e.getElementsByTagName("img")[0];
c.style.display="none";
e.insertBefore(d,c);
gInfoDlg.setHideTimeout()
}else{addClassName(e,"selectedRow");
this.m_selectedRow=e;
this.m_selectedApp=b
}this.onSelectApp(b)
};
this.clearLoading=function(){if(!this.m_isLoading){return
}if(!this.m_isDisabled){removeClassName(this.m_listDiv,"disabled")
}removeClassName(this.m_loadingRow,"loadingRow");
removeClassName(this.m_loadingRow,"highlightedRow");
var b=this.m_loadingRow.getElementsByTagName("img")[0];
b.style.display="";
b.parentNode.removeChild(b.previousSibling);
this.m_isLoading=false;
this.m_loadingRow=null
};
this.onAppLoaded=function(c){this.clearLoading();
if(c&&!this.m_selectedApp){var b=$(this.m_id+"-"+c.app_id);
this.m_selectedRow=b;
this.m_selectedApp=c;
addClassName(b,"selectedRow")
}};
this.onAppUnloaded=function(){this.setDisplay("block");
if(!this.m_selectedApp){return
}removeClassName(this.m_selectedRow,"selectedRow");
this.m_selectedApp=this.m_selectedRow=null
};
this.setDisplay=function(b){a(this,"setDisplay",arguments);
if(this.getDisplay()=="none"){if(this.m_listDiv){for(var c=0,d;
(d=this.m_listDiv.childNodes[c]);
c++){removeClassName(d,"highlightedRow")
}}}else{if(!this.m_apps.length){this.populateList()
}}};
this.toggleDisplay=function(){this.setDisplay(this.getDisplay()=="none")
};
this.setDisabled=function(b){this.m_isDisabled=b;
if(this.m_listDiv){if(b){addClassName(this.m_listDiv,"disabled")
}else{if(!this.m_isLoading){removeClassName(this.m_listDiv,"disabled")
}}}};
this.getSelectedApp=function(){return this.m_selectedApp
}
});
Class("meeboApp.Application.ConsoleFavorites",meeboApp.ConsoleContainer,function(a){this.initialize=function(){a(this,"initialize");
gPubSub.subscribe("meebo.ApplicationMgr::updateFavorites",this,"updateFavorites")
};
this.initContent=function(){a(this,"initContent");
this.addClassName("consoleFavorites");
this.updateFavorites()
};
this.getFeaturedAppId=function(){var c=meebo.applicationMgr.getFavorites();
var e=meebo.applicationMgr.getFeatured();
var b=[];
for(var d in e){if(c[d]){continue
}b.push(d)
}return b.length?b[0]:null
};
this.updateFavorites=function(){var h=this.m_contentDiv;
removeChildren(h);
if(!hasClassName(h,"empty")){addClassName(h,"empty")
}var b=meebo.applicationMgr.getFavorites();
var f=this.m_win.document.createElement("div");
addClassName(f,"row titleRow");
var k=util.query;
var l=gIsGuestGroupChat?sprintf(gLang.usersFavoriteApps,k.getHashVariable(k.MEEBO_USER)):gLang.myFavoriteApps;
f.innerHTML='<div class="title" id="'+this.m_id+'-title"></div>			<div class="editLink" id="'+this.m_id+'-edit"'+(gIsGuestGroupChat?' style="display: none;"> ':"> ")+(this.hasClassName("editConsoleFavorites")?gLang.done:gLang.edit)+"</div>";
h.appendChild(f);
var d=$(this.m_id+"-edit");
ui.connectEvent(d,"click",this,"onClickEdit");
ui.connectEvent(d,"mouseover",window,"addClassName",false,false,d,"editLinkHover");
ui.connectEvent(d,"mouseout",window,"removeClassName",false,false,d,"editLinkHover");
for(var m in b){var c=meebo.applicationMgr.getApplication(m);
if(!c){continue
}removeClassName(h,"empty");
this.addRow(c)
}var g=!hasClassName(h,"empty");
var e=this.getFeaturedAppId();
if(e){this.addRow(meebo.applicationMgr.getApplication(e),g?true:false)
}this.setDisplay(e||g?true:false);
if(!g){this.removeClassName("editConsoleFavorites")
}setText($(this.m_id+"-title"),g?l:gLang.featuredApps);
cacheImgs(this.m_contentDiv);
disableSelection(this.getElement(),true);
this.positionOverlay();
this.onUpdate()
};
this.addRow=function(h,b){if(!h){return
}var g=h.app_id;
var e=this.m_win.document.createElement("div");
addClassName(e,"row");
var d=h.icon_location;
if(d&&window.location.protocol=="https:"){d=d.replace(/^http:\/\/icons/i,"https://origin-icons")
}e.innerHTML='<div class="container">			<div id="'+g+'-info">'+(b?'<img path="console-featured.png"				class="featuredTag" png="true">':"")+'<img path="'+d+'" class="icon">			<div class="name">'+h.alias+'</div>			<div class="owner">'+h.owner_name+'</div>			</div>			<div class="remove" id="'+g+'-remove">				<img path="console-delete.png" png="true"></div>			</div>';
if(b){addClassName(e,"featuredRow")
}this.m_contentDiv.appendChild(e);
var f=$(g+"-info");
var c=$(g+"-remove");
ui.connectEvent(f,"mouseover",window,"addClassName",false,false,f,"highlightedRow");
ui.connectEvent(f,"mouseout",window,"removeClassName",false,false,f,"highlightedRow");
ui.connectEvent(f,"click",this,"onClickApp",false,false,h);
ui.connectEvent(c,"click",this,"onClickRemove",false,false,h);
ui.connectEvent(c,"mouseover",window,"addClassName",false,false,c,"removeHover");
ui.connectEvent(c,"mouseout",window,"removeClassName",false,false,c,"removeHover");
return e
};
this.onClickEdit=function(){var b;
if(this.hasClassName("editConsoleFavorites")){this.removeClassName("editConsoleFavorites");
b=gLang.edit
}else{this.addClassName("editConsoleFavorites");
b=gLang.done
}setText($(this.m_id+"-edit"),b)
};
this.onClickApp=function(k){var h=gLogon.getLogons({online:true});
var g=[],b=[];
for(var e=0,c;
(c=h[e]);
e++){var d=gBuddyList.getBuddies({type:"buddy",onlist:true,logon:c,online:true}).toArray();
if(c.getNetwork()=="myspace"&&c.getAge()<18){b=b.concat(d)
}else{g=g.concat(d)
}}if(!g.length&&!b.length){gWindowMgr.createNotifyDlg({id:"deny-favorite-apps",caption:gLang.couldNotInviteBuddies},gLang.inviteNoBuddies);
return
}else{if(!g.length&&b.length&&k.category_id==meebo.APP_COMMUNICATION_CATEGORY){gWindowMgr.createNotifyDlg({id:"deny-favorite-apps",caption:gLang.couldNotInviteBuddies,h:175},sprintf(gLang.underageMySpaceNoBuddies,k.alias));
return
}}var f=hitch(meeboApp.Application,"launchAppInviteDlg",k,null,k.category_id==meebo.APP_COMMUNICATION_CATEGORY);
gNetworkMgr.doUILog("consoleFavorites","clickApp",k.name);
if(!gIsGuestGroupChat){f()
}else{gWindowMgr.createCreateMeeboAccountDlg({},"guest-favorites","upsell_accounts.png",f)
}if(g.length&&b.length&&k.category_id==meebo.APP_COMMUNICATION_CATEGORY){gWindowMgr.createNotifyDlg({id:"deny-favorite-apps",caption:gLang.couldNotInviteBuddies},sprintf(gLang.underageMySpaceSomeBuddies,k.alias))
}};
this.onClickRemove=function(b){gWindowMgr.createOkDlg({id:"removeFavoriteApp",caption:gLang.removeFavoriteAppHeader},sprintf(gLang.confirmRemoveFavoriteApp,b.alias),hitch(meebo.applicationMgr,"removeFavorite",b.app_id),null,gLang.removeBtn,null,"removeBuddy.gif")
}
});
Class("meeboApp.InviteBuddiesPage",ui.WizardPage,function(a){this.initialize=function(b){a(this,"initialize",arguments);
this.control="InviteBuddiesPage";
this.m_buddies=null;
this.m_inviteMsgInput=null;
this.m_description=null;
this.m_inviteMsg=null;
this.m_hideMySpaceUnderage=false;
this.m_groupsClosed=false
};
this.setDescription=function(b){var c=$(this.getId()+"-header");
if(c){setText(c,b)
}else{this.m_description=b
}};
this.setInviteMsg=function(c){var b=$(this.getId()+"-message");
if(b){b.value=c
}else{this.m_inviteMsg=c
}};
this.setHideMySpaceUnderage=function(b){if(this.m_hideMySpaceUnderage==b){return
}this.m_hideMySpaceUnderage=b
};
this.toggleGroups=function(){this.m_groupsClosed=!this.m_groupsClosed;
for(var b=0,c;
(c=$(this.getId()+"-group"+b));
b++){this.toggleGroup(c)
}};
this.showPage=function(b){a(this,"showPage",arguments);
if(b){var c=this.m_buddies.offsetTop;
this.m_buddies.style.display="none";
this.m_buddies.style.height=(this.getBody().offsetHeight-c-30)+"px";
this.m_buddies.style.display="block"
}};
this.getTemplate=function(){var f=this.getId();
var e='<table border="0" cellspacing="4" cellpadding="0"><tr>			<td class="maDlgHeader" id="headimg" valign="top" style="width: 32px; height: 32px;"></td>			<td class="maDlgHeader unselectable" id="'+f+'-header" unselectable="on">'+this.m_description+'</td></tr></table><div class="createBuddies">';
var c='<div class="createBuddyListTitle">'+gLang.buddies+':</div>			<div class="createBuddyList" id="'+f+'-buddies"></div>';
var d='<div class="createBuddyListTitle">'+gLang.sendInviteMessage+'</div><div class="createInviteMsg">			<span><textarea class="createInviteMsg" id="'+f+'-message">'+this.m_inviteMsg+"</textarea></span></div>";
var b='</div><div id="'+f+'-buttonContainer" 			style="position: absolute; bottom: 0px; right: 8px;"></div>';
return[e,d,c,b].join("")
};
this.initBuddies=function(){var e=this.getId();
var d=0,b=0;
var c="<ul>";
gBuddyList.withGroups(hitch(this,function(q){var k="",n=0;
var h=q.getBuddies();
for(var m=0,o;
(o=h[m]);
m++){var p=(o.getNetwork()=="myspace"&&o.getLogin().getAge()<18);
if(o.getType()!="buddy"||o.isOnline()==false||(o.getNetwork()=="meebome"&&o.isGuestUser())||(this.m_hideMySpaceUnderage&&p)){continue
}var l=meeboApp.util.protocol.getBuddyProtocolIcon(o,true);
k+='<li class="Buddy" id="'+e+"-buddy"+d+'">					<input type="checkbox" buddyid="'+o.getId()+'">					<img class="BuddyImg" style="background-image: url('+gImages.getPath()+l+')" path="blank.gif">'+o.getAlias()+"</li>";
d++;
n++
}if(n){var g=sprintf("%1 (%2)",q.getName(),n);
var f="Group "+(this.m_groupsClosed?"Closed":"");
c+='<li class="'+f+'" id="'+e+"-group"+b+'"><img class="DropImg" path="blank.gif">					<input type="checkbox">'+g+"<ul>"+k+"</ul>";
b++
}}));
c+="</ul>";
this.m_buddies.innerHTML=c;
cacheImgs(this.m_buddies)
};
this.onClickCheckbox=function(b){var f=b.checked;
var d=b;
while(d){if(d.tagName=="UL"){var e=d.getElementsByTagName("input");
for(var c=0;
c<e.length;
c++){e[c].checked=f
}}d=d.nextSibling
}};
this.initContent=function(){var b=this.getBody();
var e=this.getId();
var d=getPartFromElement(b,"headimg");
var c=createImg("",d,null,null,"inviteChat.png","",true,null,true);
d.appendChild(c);
this.m_buddies=$(e+"-buddies");
this.m_inviteMsgInput=$(e+"-message");
this.initBuddies();
disableSelection(this.m_buddies,true);
this.connectContentEvents()
};
this.connectContentEvents=function(){var g=this.getId();
var f=this.m_buddies.getElementsByTagName("input");
for(var d=0,c;
(c=f[d]);
d++){ui.connectEvent(c,"click",this,"onClickCheckbox",false,false,c)
}for(var d=0,e;
(e=$(g+"-group"+d));
d++){var b=e.getElementsByTagName("img");
ui.connectEvent(b[0],"click",this,"toggleGroup",false,false,e)
}};
this.toggleGroup=function(b){if(hasClassName(b,"Closed")){removeClassName(b,"Closed")
}else{addClassName(b,"Closed")
}};
this.getValues=function(){var d=this.m_buddies.getElementsByTagName("input");
var g=[];
for(var c=0;
c<d.length;
c++){if(!d[c].checked){continue
}var f=d[c].getAttribute("buddyid");
var b=gBuddyList.getBuddyById(f);
if(b){g.push(b)
}}var e=this.m_inviteMsgInput.value;
return{invitees:g,inviteMsg:e}
};
this.validateInputs=function(b){return true
}
});
Class("meeboApp.ConsoleMenu",function(){this.initialize=function(a){this.m_items=[];
this.m_lagTime=500;
this.m_dirty=false;
this.m_seperateItems=false;
this.m_text=a.text;
this.m_maxHeight=400;
this.m_win=gWin();
this.m_element=this.m_win.document.createElement("div");
this.m_body=this.m_win.document.createElement("div");
this.m_label=this.m_win.document.createElement("span");
addClassName(this.m_element,"ConsoleMenuHead");
addClassName(this.m_body,"ConsoleMenuBody");
addClassName(this.m_label,"label");
setText(this.m_label,this.m_text);
this.hide();
this.m_element.appendChild(this.m_label);
this.m_win.document.body.appendChild(this.m_body);
ui.connectEvent(this.m_element,"mouseup",this,"showAt",false,true);
ui.connectEvent(this.m_element,"mouseover",this,"onHeadMouseOver");
ui.connectEvent(this.m_element,"mouseout",this,"onHeadMouseOut");
ui.connectEvent(this.m_body,"mouseout",this,"startCloseTimer");
ui.connectEvent(this.m_body,"mouseover",this,"stopCloseTimer");
if(a.items){this.addItems(a.items)
}this.createArrow();
gPubSub.subscribe("ui.ConsoleMenu::show",this,function(b){if(b!=this){this.hide()
}})
};
this.getElement=function(){return this.m_element
};
this.appendTo=function(a,b){if(b!=null){a.insertBefore(this.m_element,b)
}else{a.appendChild(this.m_element)
}};
this.createArrow=function(){this.m_arrow=this.m_win.document.createElement("img");
this.m_arrow.src=gConfig.getImageServer()+"links-dropdown-icon.gif";
this.m_arrow.className="arrow";
this.m_element.insertBefore(this.m_arrow,this.m_element.firstChild)
};
this.showArrow=function(){this.m_arrow.style.visibility="visible"
};
this.hideArrow=function(){this.m_arrow.style.visibility="hidden"
};
this.onHeadMouseOver=function(){this.showArrow();
this.stopCloseTimer();
addClassName(this.m_element,"hot")
};
this.onHeadMouseOut=function(){this.hideArrow();
this.startCloseTimer();
removeClassName(this.m_element,"hot")
};
this.startCloseTimer=function(){this.m_closeTimeout=this.m_win.setTimeout(hitch(this,"hide"),this.m_lagTime)
};
this.stopCloseTimer=function(){if(this.m_closeTimeout){this.m_win.clearTimeout(this.m_closeTimeout)
}};
this.addItem=function(a){this.m_dirty=true;
this.m_items.push(a)
};
this.addItems=function(a){for(var b=0;
b<a.length;
b++){this.addItem(a[b])
}};
this.insertItem=function(b,a){this.m_dirty=true;
this.m_items.splice(a,0,b);
return true
};
this.removeLastItem=function(){this.m_dirty=true;
this.m_items.pop()
};
this.showAt=function(b){if(hasClassName(this.m_element,"open")){this.hide();
return
}addClassName(this.m_element,"open");
var d=getElementPosition(b);
var c=ui.getClientRect(this.m_win).h;
var a=Math.min(c-(d.y+40),this.m_maxHeight);
this.renderItems();
this.m_body.style.visibility="hidden";
this.m_body.style.display="block";
this.setPos(d);
this.clampHeight(a);
this.m_body.style.zIndex=gWindowMgr.getTopZIndex();
this.m_body.style.visibility="visible";
gPubSub.publish(this,"ui.ConsoleMenu::show")
};
this.clampHeight=function(a){this.m_body.style.height="auto";
if(this.m_body.offsetHeight>a){this.m_body.style.height=a+"px";
this.m_body.style.overflowY="scroll"
}else{this.m_body.style.overflowY="hidden"
}};
this.renderItems=function(){if(this.m_dirty){removeChildren(this.m_body);
for(var b=0;
b<this.m_items.length;
b++){if(this.m_seperateItems&&b>0){this.m_body.appendChild(this.createSeperator())
}var a=this.createElement(this.m_items[b]);
this.m_body.appendChild(a);
sanitizeLinks(a)
}addClassName(this.m_body.firstChild,"firstItem");
addClassName(this.m_body.lastChild,"lastItem")
}this.m_dirty=false
};
this.createElement=function(b){if(b=="-"){return this.createSeperator()
}if(typeof b=="string"){return this.createCategory(b)
}var c=this.m_win.document.createElement("div");
addClassName(c,"item");
ui.connectEvent(c,"mousedown",b,b.handler);
var a=this.m_win.document.createElement("div");
addClassName(a,"text");
this.setElementContent(a,b);
c.appendChild(a);
return c
};
this.setElementContent=function(a,b){setText(a,b.text)
};
this.createSeperator=function(){var a=this.m_win.document.createElement("div");
addClassName(a,"seperator");
return a
};
this.hide=function(){removeClassName(this.m_element,"open");
this.m_body.style.display="none"
};
this.setPos=function(b,a){a=a||this.m_body;
this.m_body.style.left=b.x+"px";
this.m_body.style.top=b.y+b.h+"px"
}
});
Class("meeboApp.NotificationsMenu",meeboApp.ConsoleMenu,function(a){this.initialize=function(b){a(this,"initialize",arguments);
this.m_notificationsCount=0;
this.m_seperateItems=true;
addClassName(this.m_body,"NotificationsMenuBody");
gClient.subscribe("info::notifications",this,"onNotification")
};
this.onNotification=function(c,d){if(c.url){return
}this.m_notificationsCount+=1;
this.updateNotifications();
var e='<span class="friend">'+c.subjectalias+"</span> "+c.predicate;
if(c.subjectusernam&&c.protocol&&c.username){var b=gBuddyList.getBuddy(c.subjectusername,c.protocol,c.username)
}this.addItem({html:e,timestamp:new Date(),rightIconSrc:b?b.getIconURL():gPrefs.getDefaultIcon(),leftIconSrc:b?b.getCaptionImage():""})
};
this.updateNotifications=function(){var b=this.m_text;
if(this.m_notificationsCount>0){b+=" ("+this.m_notificationsCount+")"
}setText(this.m_label,b)
};
this.createElement=function(c){var f=a(this,"createElement",arguments);
if(typeof c=="string"){return f
}addClassName(f,"notification");
var e=this.m_win.document.createElement("div");
e.setAttribute("timestamp",c.timestamp.getTime());
this.writeTimestamp(e);
addClassName(e,"timestamp");
f.firstChild.appendChild(e);
if(c.leftIconSrc){var b=createImg("",f,15,15,c.leftIconSrc,"provider",true,"left");
addClassName(b,"iconLeft");
f.insertBefore(b,f.firstChild)
}if(c.rightIconSrc){var d=createImg("",f,32,32,c.rightIconSrc,"provider",true,"left");
f.insertBefore(d,f.firstChild);
addClassName(d,"iconRight")
}return f
};
this.setElementContent=function(b,c){b.innerHTML=c.html
};
this.writeTimestamp=function(b){var c=new Date(parseInt(b.getAttribute("timestamp")));
util.time.setTimestampString(b,c)
};
this.addItem=function(b){this.insertItem(b,0)
};
this.renderItems=function(){if(this.m_items.length){a(this,"renderItems");
var d=this.m_body.getElementsByTagName("span");
for(var c=0,b=d.length;
c<b;
c++){if(hasClassName(d[c],"timestamp")){this.writeTimestamp(d[c])
}}}else{this.m_body.innerHTML='<div class="noNotifications">'+gLang.noNotifications+"</div>"
}this.m_notificationsCount=0;
this.updateNotifications()
}
});
Class("meeboApp.PartnerInterstitial",ui.Lightbox,function(){this.createContent=function(){this.addClassName("partnerInterstitial");
this.createText();
this.createHeader();
this.createButton();
this.createFooter();
this.m_element.appendChild(this.m_content)
};
this.createText=function(){};
this.createHeader=function(){this.m_header=this.m_win.document.createElement("div");
addClassName(this.m_header,"header");
this.m_windowButtons=new uiDlgButtons();
this.m_windowButtons.create(this.getId()+"-close",this.m_header,"none","none","enable");
this.m_windowButtons.addOnCloseUp(hitch(this,"hide"));
this.m_content.appendChild(this.m_header)
};
this.createButton=function(){this.m_button=new ui.button(this.getId()+"-button","continue").create(this.m_win).addClassName("uiButton-huge");
this.m_content.appendChild(this.m_button.getElement());
this.m_button.addOnMouseUp(hitch(this,"hide"))
};
this.createFooter=function(){this.m_footer=this.m_win.document.createElement("div");
addClassName(this.m_footer,"footer");
this.m_footer.appendChild(this.createLink("terms of use","http://www.meebo.com/terms/"));
this.m_footer.appendChild(this.createSeperator());
this.m_footer.appendChild(this.createLink("privacy policy","http://www.meebo.com/privacy/"));
this.m_content.appendChild(this.m_footer)
};
this.createLink=function(c,a){var b=this.m_win.document.createElement("a");
setText(b,c);
b.href=a;
b.target="_blank";
return b
};
this.createSeperator=function(){var a=this.m_win.document.createElement("span");
setText(a," | ");
return a
}
});
Class("meeboApp.CIMInterstitial",meeboApp.PartnerInterstitial,function(a){this.initialize=function(b){a(this,"initialize");
this.m_networkId=b
};
this.createText=function(){this.m_content.offsetWidth;
var b=this.m_content.appendChild(document.createElement("div"));
b.className="textContent";
b.innerHTML='<div class="subtitle">All your <img class="cimIcon" src="'+gImages.getPath()+"network/"+this.m_networkId+'_24_online.png" class="fixPng" onload="fixPng(this);">'+gNetworks[this.m_networkId].getName()+' friends are here!</div><div class="description">At Meebo you can chat with friends from all the major IM networks.</div><div class="networksArrow"></div>'
}
});
Class("meeboApp.FacebookConnectLink",ui.element,function(a){this.initialize=function(){a(this,"initialize",arguments);
this.addClassName("FacebookConnectLink");
this.m_spinnerImg=createImg("",this.m_element,13,13,"miniwait.gif","",true,"bottom");
this.m_spinnerImg.className="spinner";
this.m_loading=false;
this.m_connecting=false;
this.m_onClick=[];
ui.connectEvent(this.m_element,"click",this,"onClick");
gFBConnect.subscribe("loading",this,"showSpinner").subscribe("loaded",this,"hideSpinner")
};
this.destroy=function(){gFBConnect.unsubscribe("loading",this).unsubscribe("loaded",this)
};
this.onClick=function(){if(this.m_loading){return
}this.m_connecting=true;
if(doFunctions(this.m_onClick)){gFBConnect.connect()
}};
this.addOnClick=function(b){this.m_onClick.push(b)
};
this.showSpinner=function(){if(!this.m_connecting||this.m_loading){return
}var b=this.m_element.getElementsByTagName("img")[0];
b.parentNode.insertBefore(this.m_spinnerImg,b);
b.style.display="none";
this.m_loading=true
};
this.hideSpinner=function(){if(!this.m_loading){return
}var c=this.m_element.getElementsByTagName("img")[0];
var b=c.nextSibling;
removeElement(c);
b.style.display="";
this.m_loading=false
}
});
Class("meeboApp.FacebookNameInput",ui.element,function(a){this.initialize=function(b){a(this,"initialize");
this.m_win=window;
this.m_element=this.m_win.document.createElement("div");
this.m_element.className="facebookNameInput";
this.m_element.tabIndex=1;
this.m_element.innerHTML="<div><span><span><span><span>"+escapeHTML(b)+'</span></span></span></span			></div><span class="closeButton">&nbsp;</span>';
ui.connectEvent(this.m_element,"focus",this,"addClassName",false,false,"facebookNameInput-focus");
ui.connectEvent(this.m_element,"blur",this,"removeClassName",false,false,"facebookNameInput-focus");
ui.connectEvent(this.m_element,"keypress",this,"onKeyPress",true);
this.m_closeButton=this.m_element.getElementsByTagName("span")[4];
ui.connectEvent(this.m_closeButton,"mouseover",this,"setCloseButtonBackgroundPosition",false,false,-19,0);
ui.connectEvent(this.m_closeButton,"mouseout",this,"setCloseButtonBackgroundPosition",false,false,null,null);
ui.connectEvent(this.m_closeButton,"mousedown",this,"setCloseButtonBackgroundPosition",false,false,-38,0);
ui.connectEvent(this.m_closeButton,"mouseup",this,"setCloseButtonBackgroundPosition",false,false,null,null);
ui.connectEvent(this.m_closeButton,"click",this,"onClear");
this.createHandler("Clear");
this.createHandler("Submit")
};
this.setCloseButtonBackgroundPosition=function(b,c){this.m_closeButton.style.backgroundPosition=(b==null&&c==null?"":b+"px "+c+"px")
};
this.setShowsCloseButton=function(b){this.m_closeButton.style.display=b?"block":"none";
return this
};
this.onKeyPress=function(b){switch(b.keyCode){case ui.KEY_BACKSPACE:case ui.KEY_DELETE:ui.setEventHandled(b);
this.onClear();
break;
case ui.KEY_RETURN:this.onSubmit();
break
}}
});
Class("meeboApp.StatusInput",function(a){this.m_whitespaceRegexp=/^\W*$/;
this.initialize=function(c,d,b,e){this.m_defaultText=c;
this.m_defaultMessages=d;
this.m_status=b;
this.m_value=e;
this.m_lastValue="";
this.m_onValueChange=[];
this.m_inputId="statusInput-"+getUniqueId()
};
this.create=function(b){if(this.m_element){return
}this.m_win=gWin(b);
this.m_element=this.m_win.document.createElement("div");
addClassName(this.m_element,"StatusInput");
this.initContent();
b.appendChild(this.m_element);
this.setValue(this.m_value)
};
this.initContent=function(){var d=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(d,"top");
var b=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(b,"middle");
var c=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(c,"bottom");
this.m_input=this.m_element.appendChild(this.m_win.document.createElement("textarea"));
this.m_input.id=this.m_inputId;
ui.connectEvent(d,"click",this,"focus",true);
ui.connectEvent(c,"click",this,"focus",true);
ui.connectEvent(this.m_input,"click",this,"focus",true);
ui.connectEvent(this.m_input,"keypress",this,"onKeyPress",true);
ui.connectEvent(this.m_input,"blur",this,"onInputBlur");
gPubSub.subscribe("meebo.LogonMgr::changeStatus",this,"onChangeStatus")
};
this.onChangeStatus=function(c,b,e,d){this.setValue(d,true)
};
this.addOnValueChange=function(b){this.m_onValueChange.push(b)
};
this.setStatus=function(b,c){this.m_status=b;
if(c){this.setValue(c)
}};
this.setDisplay=function(b){if(b==this.m_defaultText||b==""){addClassName(this.m_input,"defaultText");
this.m_input.value=this.m_defaultText
}else{removeClassName(this.m_input,"defaultText");
this.m_input.value=getTruncatedText(unescapeHTML(b),this.m_input.offsetWidth-5,15)
}};
this.onInputFocus=function(c){if(!this.m_isFocused){this.m_inputValueOnFocus=this.getValue();
this.m_isFocused=true;
addClassName(this.m_element,"StatusInputHot");
if(!this.hasCustomValue()){var b=this.m_defaultMessages[this.m_status];
if(b){this.setDisplay(b)
}}else{this.m_input.value=unescapeHTML(this.getValue())
}this.select()
}else{if(c){ui.setEventHandled(c)
}}};
this.select=function(){this.m_input.select()
};
this.focus=function(b){if(this.m_input.disabled){return
}if(!this.m_isFocused){this.m_input.focus();
setTimeout(hitch(this,"onInputFocus"),0)
}if(b){ui.setEventHandled(b)
}};
this.onInputBlur=function(){this.m_isFocused=false;
removeClassName(this.m_element,"StatusInputHot");
this.setValue(escapeHTML(this.m_input.value))
};
this.onKeyPress=function(b){if(!b){return
}switch(b.keyCode){case ui.KEY_ESC:this.m_input.value=this.m_inputValueOnFocus;
case ui.KEY_RETURN:this.m_input.blur();
ui.setEventHandled(b);
break
}};
this.setValue=function(c,b){c=stripWhitespace(c);
this.setDisplay(c);
if(c!=this.m_value){this.m_lastValue=this.m_value;
this.m_value=c;
if(!b){doFunctions(this.m_onValueChange,this.getValue(),this.m_lastValue)
}}};
this.getValue=function(){var b=this.m_value;
if(b==this.m_defaultText){return""
}return b
};
this.hasCustomValue=function(){var c=this.getValue();
for(var b in this.m_defaultMessages){if(c==this.m_defaultMessages[b]){return false
}}return c?true:false
};
this.setDisabled=function(b){toggleClassName(this.m_element,b,"StatusInput-disabled");
this.m_input.disabled=!!b
}
});
Class("meeboApp.NotifierUpsellDlg",ui.element,function(a){this.getTemplate=function(){return'<img path="notifierUpsell.jpg"><div			><h1>your own mini meebo</h1			><p>The Meebo Notifier provides message previews in your taskbar without an open browser. If your download hasn\'t already started, click below.<p			><a href="/notifier/" target="_blank">Learn more about the Notifier</a			><p>After your download is complete, don\'t forget to double-click to install it!</div>'
};
this.initContent=function(){this.addClassName("NotifierUpsellDlg");
cacheImgs(this.m_element)
}
});
GoogleAnalytics={m_tracked:false,track:function(){if(this.m_tracked||!gConfig.getReleaseType().length){return
}this.m_tracked=true;
var c=document;
var b=(("https:"==c.location.protocol)?"https://ssl.":"http://www.");
var a=c.createElement("script");
a.src=b+"google-analytics.com/ga.js";
function d(){var e=_gat._getTracker("UA-3931792-1");
e._initData();
e._trackPageview()
}a.onload=function(){a.onloadDone=true;
d()
};
a.onreadystatechange=function(){if(("loaded"==a.readyState||"complete"==a.readyState)&&!a.onloadDone){a.onloadDone=true;
d()
}};
c.documentElement.firstChild.appendChild(a)
}};
Class("meeboApp.BuddyIconUpsellTooltip",ui.Tooltip,function(a){this.initialize=function(){a(this,"initialize");
gPubSub.subscribe("meebo.MeeboAccount::changeState",this,"hide")
};
this.createContent=function(){a(this,"createContent");
this.addClassName("BuddyIconUpsellTooltip");
this.m_scrollingContent=new meeboApp.ScrollingContent().create(this);
this.m_content.appendChild(this.m_scrollingContent.getElement());
this.m_container=this.m_scrollingContent.getContent().appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_container,"container");
this.createText();
this.createUplaoder();
this.createGallery();
this.createFooter();
this.createRegistrationTitle();
this.createRegistrationForm();
this.setSticky(true);
gNetworkMgr.doUILog("upsells","buddyicon","shown",true)
};
this.createText=function(){var c=this.m_container.appendChild(this.m_win.document.createElement("div"));
addClassName(c,"title");
var b=this.m_container.appendChild(this.m_win.document.createElement("div"));
addClassName(b,"upsell");
setText(c,gLang.setYourPicture);
setText(b,gLang.weNoticedNoPicture)
};
this.createUplaoder=function(){var b=this.m_container.appendChild(this.m_win.document.createElement("div"));
addClassName(b,"uploader");
var c=b.appendChild(this.m_win.document.createElement("div"));
addClassName(c,"subTitle");
setText(c,"Upload a new picture");
this.m_chooseButton=new ui.FileUploadButton(null,gLang.ChooseFile).create(this.m_win);
this.m_chooseButton.addClassName("uiButton-big");
this.m_chooseButton.addOnMouseUp(hitch(this,"setIcon"));
b.appendChild(this.m_chooseButton.m_element);
this.m_uploadLabel=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_uploadLabel,"label");
setText(this.m_uploadLabel,"no file selected");
b.appendChild(this.m_uploadLabel)
};
this.createGallery=function(){this.m_gallery=this.m_container.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_gallery,"gallery");
var f=this.m_gallery.appendChild(this.m_win.document.createElement("div"));
addClassName(f,"subTitle");
setText(f,"Or choose one from our gallery:");
var d=this.m_gallery.appendChild(this.m_win.document.createElement("div"));
addClassName(d,"iconList");
for(var c=0,e;
(e=gDefaultBuddyIcons[c]);
c++){var b=this.m_win.document.createElement("img");
b.src=(window.location.protocol=="https:"?"https://origin-":"http://")+"icons.meebo.com/stock/"+e;
addClassName(b,"icon");
d.appendChild(b);
ui.connectEvent(b,"mouseover",this.m_win,"addClassName",false,false,b,"icon-hot");
ui.connectEvent(b,"mouseout",this.m_win,"removeClassName",false,false,b,"icon-hot");
ui.connectEvent(b,"click",this,hitch(this,"setIcon",b.src,b))
}};
this.createFooter=function(){var b=this.m_container.appendChild(this.m_win.document.createElement("div"));
addClassName(b,"footer");
this.m_nextButton=new ui.button("nextButton",gLang.nextTT,gLang.nextTT,2,"big");
b.appendChild(this.m_nextButton.create(this).getElement());
this.m_nextButton.setDisabled(true);
var c=b.appendChild(this.m_win.document.createElement("div"));
addClassName(c,"text");
setText(c,gLang.youWillCreateAccount);
this.m_nextButton.addOnMouseDown(hitch(this,"onNextButtonClick"));
this.m_nextButton.addOnMouseDown(function(){gNetworkMgr.doUILog("upsells","buddyicon","regstart",true)
})
};
this.setIcon=function(c,e){var d=this.m_gallery.getElementsByTagName("img");
for(var b=0,f;
(f=d[b]);
b++){removeClassName(f,"icon-selected")
}if(e){addClassName(e,"icon-selected")
}var g=e?gLang.noFileSelected:(ui.isWin?c.value.split("\\").pop():c.value);
setTruncatedText(this.m_win,this.m_uploadLabel,g,130);
this.m_icon=c;
this.m_nextButton.setDisabled(false);
gNetworkMgr.doUILog("upsell","buddyicon","choseicon",true)
};
this.createRegistrationTitle=function(){var b=this.m_scrollingContent.getContent().appendChild(this.m_win.document.createElement("div"));
addClassName(b,"title registrationTitle");
setText(b,gLang.signUpToSaveYourPicture)
};
this.createRegistrationForm=function(){if(this.m_registrationForm){this.m_registrationForm.removeAllValidationErrors()
}else{this.m_registrationForm=new meeboApp.RegistrationForm().create(this);
gNetworkMgr.addUILogFilter("regfloworigin","stepcompleted",function(g){g.name+="-buddyicontooltip";
return g
});
var e=this.m_registrationForm.getElement().getElementsByTagName("input");
for(var d=0,e;
(input=e[d]);
d++){input.tabIndex=1
}var f=this.m_scrollingContent;
var c=new meeboApp.HeightMonitor(this.m_registrationForm,f.getContent(),f.getElement());
c.monitorMethod("validateInput");
c.monitorMethod("removeValidationError");
f.getContent().appendChild(this.m_registrationForm.getElement());
var b=new ui.button("registerButton",gLang.finish,null,2,"big").create(this);
this.m_registrationForm.getElement().appendChild(b.getElement());
b.addOnMouseDown(hitch(this.m_registrationForm,"submit"));
this.m_registrationForm.subscribe("AccountCreated",this,"onAccountCreated")
}};
this.show=function(){this.m_container.style.visibility="visible";
this.createRegistrationForm();
var b=this.m_scrollingContent;
this.m_scrollingContent.scrollTo(b.TOP,true);
a(this,"show")
};
this.hide=function(){a(this,"hide");
this.setSticky(false)
};
this.onNextButtonClick=function(){this.m_container.style.visibility="hidden";
var b=this.m_scrollingContent;
this.setSticky(true);
b.scrollTo(b.BOTTOM)
};
this.onAccountCreated=function(){this.hide();
gPubSub.subscribe("meebo.MeeboAccount::changeState",this,"onMeeboUserLogon")
};
this.onMeeboUserLogon=function(c,b,d){if(d!="online"){return
}gPubSub.unsubscribe("meebo.MeeboAccount::changeState",this);
meeboApp.setBuddyIconUrl(this.m_icon)
}
});
Class("meeboApp.AccountUpsellTooltip",ui.Tooltip,function(a){this.m_resizeDuration=350;
this.initialize=function(d,c,b){a(this,"initialize");
this.m_featureName=d;
this.m_featureDescription=c;
this.m_logName=b;
gNetworkMgr.doUILog("upsells",this.m_logName,"shown",true);
gPubSub.subscribe("meebo.MeeboAccount::changeState",this,"hide")
};
this.createContent=function(){a(this,"createContent");
this.addClassName("AccountUpsellTooltip");
var d=this.m_content.appendChild(this.m_win.document.createElement("div"));
setText(d,this.m_featureName);
addClassName(d,"title");
this.m_upsell=this.m_content.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_upsell,"upsell");
var c=this.m_upsell.appendChild(this.m_win.document.createElement("div"));
addClassName(c,"description");
setText(c,this.m_featureDescription);
var b=new ui.button("signupButton",gLang.signUp2);
b.addOnMouseUp(hitch(this,"onSignupClick"));
this.m_upsell.appendChild(b.create(this).getElement());
var e=this.m_upsell.appendChild(this.m_win.document.createElement("span"));
addClassName(e,"label");
setText(e,gLang.toTurnOnThisFeature)
};
this.onSignupClick=function(){this.m_currentWidth=this.m_content.offsetWidth;
this.m_currentHeight=this.m_content.offsetHeight;
this.m_upsell.style.visibility="hidden";
this.m_targetWidth=260;
this.m_targetHeight=220;
this.getResizeAnimation().seekFromTo(0,1)
};
this.createRegistrationForm=function(){if(this.m_registrationForm){this.m_registrationForm.removeAllValidationErrors()
}else{this.m_registrationForm=new meeboApp.RegistrationForm().create(this.m_win);
gNetworkMgr.addUILogFilter("regfloworigin","stepcompleted",function(f){f.name+=("-"+this.m_logName)
});
var e=this.m_registrationForm.getElement().getElementsByTagName("input");
for(var d=0,e;
(input=e[d]);
d++){input.tabIndex=1
}var c=new meeboApp.HeightMonitor(this.m_registrationForm,this.m_registrationForm.getElement(),this.m_content);
c.monitorMethod("validateInput");
c.monitorMethod("removeValidationError");
var b=new ui.button("registerButton",gLang.finish,null,2,"big").create(this);
this.m_content.appendChild(this.m_registrationForm.create(this).getElement());
this.m_content.appendChild(b.getElement());
b.addOnMouseDown(hitch(this.m_registrationForm,"submit"));
this.m_registrationForm.subscribe("AccountCreated",this,"hide");
this.m_registrationForm.focus()
}};
this.show=function(){a(this,"show",arguments);
this.setSticky(false)
};
this.getResizeAnimation=function(){if(this.m_resizeAnimation){return this.m_resizeAnimation
}this.m_resizeAnimation=new ui.Animation({duration:this.m_resizeDuration,transition:ui.Animation.easeInOut});
this.m_resizeAnimation.addSubject(hitch(this,"animateResize"));
this.m_resizeAnimation.onfinished=hitch(this,"onResizeFinished");
return this.m_resizeAnimation
};
this.animateResize=function(d){var b=this.m_targetWidth-this.m_currentWidth;
var c=this.m_targetHeight-this.m_currentHeight;
this.m_content.style.width=this.m_currentWidth+(b*d)+"px";
this.m_content.style.height=this.m_currentHeight+(c*d)+"px";
this.checkWindowOverflow()
};
this.onResizeFinished=function(){this.m_upsell.style.display="none";
this.setSticky(true);
this.m_element.style.zIndex=gWindowMgr.getTopZIndex();
this.createRegistrationForm()
}
});
Class("meeboApp.HeightMonitor",lib.Publisher,function(a){this.initialize=function(c,b,d){a(this,"initialize");
this.m_component=c;
this.m_monitoredElement=b;
this.m_resizingElement=d
};
this.monitorHeight=function(f){var c=Array.prototype.slice.call(arguments,1);
if(this.m_isMonitoring){return f.apply(this,c)
}this.m_isMonitoring=true;
var d=this.m_monitoredElement.offsetHeight;
var e=f.apply(this,c);
var b=this.m_monitoredElement.offsetHeight;
var g=b-d;
if(g){this.m_resizingElement.style.height=this.m_resizingElement.offsetHeight+g+"px";
this.publish("HeightChange")
}this.m_isMonitoring=false;
return e
};
this.monitorMethod=function(b){var c=this.m_component[b];
this.m_component[b]=hitch(this,"monitorHeight",hitch(this.m_component,c))
}
});
Class("meeboApp.ScrollingContent",ui.Element,function(a){this.createContent=function(){this.addClassName("ScrollingContent");
this.m_content=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(this.m_content,"content")
};
this.getContent=function(){return this.m_content
};
this.TOP=0;
this.BOTTOM=1;
this.scrollTo=function(c,b){if(b){this.getAnimation().jumpTo(c)
}else{this.getAnimation().seekTo(c)
}};
this.getState=function(){return this.getAnimation().getState()
};
this.getAnimation=function(){if(this.m_animation){return this.m_animation
}this.m_animation=new ui.Animation({transition:ui.Animation.easeInOut,duration:400});
this.m_animation.onfinished=hitch(this,"publish","ScrollFinished");
this.m_animation.addSubject(hitch(this,"animate"));
this.m_animation.m_target=1;
return this.m_animation
};
this.animate=function(e){var b=this.getElement().offsetHeight;
var d=this.getContent().offsetHeight;
var c=d-b;
this.m_element.scrollTop=Math.floor(c*e)
}
});
Class("meeboApp.RegistrationForm",ui.Element,function(a){this.m_inputValidations={registerName:function(b){return b.length
},registerEmail:function(b){return isEmail(b)
},registerPassword:function(b){return b.length>=5
},registerAge:function(c){var b=parseInt(c);
return(c.match(/[0-9]+/)&&b>=1&&b<99)
}};
this.m_errorStrings={registerId:gLang.usernameError,registerEmail:gLang.emailError,registerPassword:gLang.passwordError,registerAge:gLang.ageError};
this.m_emptyValueStrings={registerName:gLang.nameMissing,registerEmail:gLang.emailMissing,registerId:gLang.usernameMissing,registerPassword:gLang.passwordMissing,registerAge:gLang.ageMissing,registerMale:gLang.genderMissing};
this.m_usernameRegexp=/^[\w_.]{4,255}$/;
this.initialize=function(){a(this,"initialize",arguments);
this.m_emailIsOk=null;
this.m_meeboUsernameIsOk=false
};
this.createContent=function(){this.addClassName("RegistrationForm");
this.createForm();
this.createTerms();
this.connectContentEvents();
this.setRegistrationInputsDisabled(false)
};
this.createForm=function(){var b=this.m_element.appendChild(this.m_win.document.createElement("table"));
this.m_table=b.appendChild(this.m_win.document.createElement("tbody"));
this.m_emailInput=this.createInputRow("registerEmail",gLang.email,2);
this.m_nameInput=this.createInputRow("registerName",gLang.fullName,2);
this.m_idInput=this.createInputRow("registerId",gLang.meeboid,3);
this.m_passwordInput=this.createInputRow("registerPassword",gLang.password,3,"password");
this.createGenderRow();
this.m_ageInput=this.createInputRow("registerAge",gLang.age,3)
};
this.createTerms=function(){var b=this.m_element.appendChild(this.m_win.document.createElement("div"));
addClassName(b,"terms");
b.innerHTML=sprintf(gLang.registerTerms,"<a href='/terms/' target='_blank'>","</a>","<a href='/privacy/full/' target='_blank'>","</a>")
};
this.createInputRow=function(b,f,h,l){l=l||"text";
var p=this.m_table.appendChild(this.m_win.document.createElement("tr"));
var c=this.m_table.appendChild(this.m_win.document.createElement("tr"));
var g=p.appendChild(this.m_win.document.createElement("td"));
var d=p.appendChild(this.m_win.document.createElement("td"));
var o=p.appendChild(this.m_win.document.createElement("td"));
var n=this.m_win.document.createElement("label");
n.htmlFor=b;
setText(n,f);
var m;
if(l=="radio"){m=createRadio(b,this.m_win)
}else{m=this.m_win.document.createElement("input");
m.type=l
}m.id=b;
m.tabIndex=h;
var e=this.m_win.document.createElement("img");
e.src=gImages.getPath()+"blank.gif";
addClassName(p,"inputRow "+b+"-row");
addClassName(c,"errorRow hidden");
addClassName(g,"labelCell");
addClassName(d,"inputCell");
addClassName(o,"validationCell");
addClassName(n,"label");
addClassName(e,"validation");
addClassName(m,l=="text"||l=="password"?"text-input":"");
g.appendChild(n);
d.appendChild(m);
o.appendChild(e);
c.insertCell(-1);
var k=c.insertCell(-1);
addClassName(k,"errorMessage");
c.insertCell(-1);
return m
};
this.createGenderRow=function(){this.m_maleRadio=this.createInputRow("registerGender",gLang.Iam+" ...",3,"radio");
this.m_femaleRadio=createRadio("registerGender",this.m_win);
this.m_maleRadio.id="registerMale";
this.m_femaleRadio.id="registerFemale";
this.m_femaleRadio.type="radio";
this.m_femaleRadio.tabIndex=3;
var c=this.m_maleRadio.parentNode;
var b=this.m_win.document.createElement("label");
var d=this.m_win.document.createElement("label");
b.setAttribute("for","registerMale");
d.setAttribute("for","registerFemale");
addClassName(b,"genderRadioLabel");
addClassName(d,"genderRadioLabel");
setText(b,gLang.male);
setText(d,gLang.female);
c.appendChild(b);
c.appendChild(this.m_femaleRadio);
c.appendChild(d);
this.m_femaleRadio.checked=false;
this.m_maleRadio.checked=false
};
this.connectContentEvents=function(){ui.connectEvent(this.m_nameInput,"blur",this,"validateInput",false,true);
ui.connectEvent(this.m_passwordInput,"blur",this,"validateInput",false,true);
ui.connectEvent(this.m_ageInput,"blur",this,"validateInput",false,true);
ui.connectEvent(this.m_emailInput,"blur",this,"checkEmailExists");
ui.connectEvent(this.m_idInput,"blur",this,"checkMeeboUsername");
var e=hitch(this,"getRegistrationGender");
ui.connectEvent(this.m_maleRadio,"blur",this,"validateInput",false,true,false,e);
ui.connectEvent(this.m_maleRadio,"click",this,"validateInput",false,true,false,e);
ui.connectEvent(this.m_femaleRadio,"blur",this,"validateInput",false,true,false,e);
ui.connectEvent(this.m_femaleRadio,"click",this,"validateInput",false,true,false,e);
var d=this.m_element.getElementsByTagName("input");
for(var c=0,b;
(b=d[c]);
c++){ui.connectEvent(b,"keypress",this,"onKeyPress",true)
}};
this.onKeyPress=function(b){switch(b.keyCode){case ui.KEY_RETURN:this.submit();
break
}};
this.setRegistrationInputsDisabled=function(b){this.m_nameInput.disabled=b;
this.m_emailInput.disabled=b;
this.m_idInput.disabled=b;
this.m_passwordInput.disabled=b;
this.m_maleRadio.disabled=b;
this.m_femaleRadio.disabled=b;
this.m_ageInput.disabled=b
};
this.getRegistrationGender=function(){return this.m_maleRadio.checked?"m":(this.m_femaleRadio.checked?"f":null)
};
this.getValue=function(b){return(b.type=="radio"?this.getRegistrationGender():stripWhitespace(b.value))
};
this.focus=function(){var d=this.m_element.getElementsByTagName("input");
for(var c=0,b;
(b=d[c]);
c++){if(!b.value&&b.type!="radio"){b.focus();
return
}}};
this.validateName=function(){return this.validateInput(this.m_nameInput,true)
};
this.validateEmail=function(){return this.validateInput(this.m_emailInput,true)
};
this.validateAllRegistrationInputs=function(e){var f=true;
for(var c in this.m_inputValidations){if(!this.validateInput($(c),true,this.m_inputValidations[c])){f=false
}}if(f){var b=parseInt(this.getValue(this.m_ageInput));
if(b<13){this.publish("AgeVerificationNeeded");
if(e){e(false)
}return
}}var d=this.validateInput(this.m_maleRadio,true,hitch(this,"getRegistrationGender"));
this.checkMeeboUsername(null,true);
this.checkEmailExists(hitch(this,function(g){if(e){e(f&&d&&this.m_meeboUsernameIsOk&&g)
}}),true)
};
this.validateInput=function(h,f,m){f=f||this.m_isSubmitting;
var g=m||this.m_inputValidations[h.id];
var l=(h.type=="radio"?this.getRegistrationGender():this.getValue(h));
var k=!l||g(l);
var e="";
var n=h.parentNode;
var d=this.getErrorNode(h);
var c=hasClassName(n.parentNode,"hasError");
if(!k){e=this.m_errorStrings[h.id];
if(h.id=="registerId"){var b=h.value;
if(stripWhitespace(b).length<4){e=gLang.shortIdError
}else{if(stripWhitespace(b).length>255){e=gLang.longIdError
}else{if(!b.match(/^[\w_.]{4,255}$/)){e=gLang.specialCharError
}else{e=sprintf(e,l)
}}}}if((h.id=="registerEmail")&&m){e=gLang.emailExistsError
}}else{if((c&&!l)||(f&&!l)){e=this.m_emptyValueStrings[h.id]
}}toggleClassName(n.parentNode,e,"hasError");
toggleClassName(n.parentNode,this.getValue(h)&&k,"validInput");
toggleClassName(d.parentNode,!e,"hidden");
setText(d,e);
return !e
};
this.verifyDate=function(d){var c=new Date(d.year+13,d.month-1,d.day);
var b=new Date();
if(c.getTime()>b.getTime()){var e=3*24*60*60*1000;
util.cookie.save("ineligible","true",e);
this.publish("Ineligible",true);
return
}else{$("registerAge").value=b.getFullYear()-d.year;
this.submit()
}};
this.removeAllValidationErrors=function(b){var d=this.m_inputValidations;
for(var c in this.m_inputValidations){this.removeValidationError(c,b)
}this.removeValidationError("registerId",b);
this.removeValidationError("registerMale",b)
};
this.removeValidationError=function(d,b){var c=$(d);
var e=c.parentNode;
var f=this.getErrorNode(c);
removeClassName(e.parentNode,"hasError");
removeClassName(e.parentNode,"validInput");
addClassName(f.parentNode,"hidden");
setText(f,"");
if(b){c.value=""
}};
this.getErrorNode=function(b){return b.parentNode.parentNode.nextSibling.childNodes[1]
};
this.checkMeeboUsername=function(e,c){var b=hitch(this,function(f){var g=hitch(this,function(){return f
});
this.validateInput(this.m_idInput,c,g);
if(e){e(f)
}});
var d=this.getValue(this.m_idInput);
if(!d&&!c){b(true)
}else{if(!d||!(d.match(this.m_usernameRegexp)&&d.length>=4)||((d==this.m_meeboUsername)&&!this.m_meeboUsernameIsOk)){b(false)
}else{this.m_meeboUsernameIsOk=false;
this.m_meeboUsername=d;
addClassName(this.m_idInput,"loading");
gNetworkMgr.doRequest("exists",{muser:d},hitch(this,"receiveUsernameCheck",b))
}}};
this.checkEmailExists=function(e,d){var b=hitch(this,function(f){var g=hitch(this,function(){return f
});
this.validateInput(this.m_emailInput,d,g);
if(e){e(f)
}});
var c=this.getValue(this.m_emailInput);
if(!c&&!d){b(true)
}else{if(!isEmail(c)){this.validateInput(this.m_emailInput,d)
}else{if(!c||((c==this.m_email)&&!this.m_emailIsOk)){b(false)
}else{this.m_emailIsOk=null;
this.m_email=c;
addClassName(this.m_emailInput,"loading");
gNetworkMgr.doRequest("emailverified",{email:c},hitch(this,"receiveEmailCheck",b))
}}}};
this.receiveEmailCheck=function(d,c,b){removeClassName(this.m_emailInput,"loading");
if(!b){this.publish("NetError");
return
}this.m_emailIsOk=!c.data.verified;
if(d){d(this.m_emailIsOk)
}};
this.receiveUsernameCheck=function(d,c,b){removeClassName(this.m_idInput,"loading");
if(!b){this.publish("NetError");
return
}this.m_meeboUsernameIsOk=!c;
if(d){d(!c)
}};
this.submit=function(){if(util.cookie.load("ineligible")){this.publish("Ineligible");
return
}this.m_isSubmitting=true;
this.validateAllRegistrationInputs(hitch(this,function(c){if(c){this.setRegistrationInputsDisabled(true);
var b=hitch(this,"createMeeboAccount");
if(gIMGateway.isConnected()){b()
}else{gIMGateway.start(function(e,d){if(d){b()
}})
}}else{this.m_isSubmitting=false;
gNetworkMgr.doUILog("regflow2","validation","failed",true)
}}))
};
this.createMeeboAccount=function(){var b={muser:this.getValue(this.m_idInput),name:this.getValue(this.m_nameInput),password:gNetworkMgr.encryptPassword(this.getValue(this.m_passwordInput)),email:this.getValue(this.m_emailInput),gender:this.getRegistrationGender(),birthyear:new Date().getFullYear()-parseInt(this.getValue(this.m_ageInput)),conf:"meebo"};
gNetworkMgr.doRequest("create",b,hitch(this,"receiveNewUser"))
};
this.receiveNewUser=function(e,g,d){if(!g||e!="success"){this.setRegistrationInputsDisabled(false)
}if(!g){this.publish("NetError");
return
}if(e!="success"){this.m_meeboUsernameIsOk=false;
this.validateAllRegistrationInputs();
return
}var f=this.getValue(this.m_idInput);
var b=this.getValue(this.m_passwordInput);
var c=gLogon.addMeeboAccount(f,b);
c.setEmail(this.getValue(this.m_emailInput));
c.setFirstName(this.getValue(this.m_nameInput).split(" ")[0]);
util.cookie.save("mid",f);
this.publish("AccountCreated",f);
gNetworkMgr.doUILog("regflow2","stepcompleted","2-fullform",true);
gPubSub.subscribe("meebo.MeeboAccount::changeState",this,"onMeeboAccountChangeState");
gNetworkMgr.requestLogin("login",[c])
};
this.receiveNewUserLogon=function(d,b,c){if(!b){this.publish("LoginError");
return
}};
this.onMeeboAccountChangeState=function(f,b,g){if(g!="online"){return
}var d=gLogon.getLogons({online:true});
for(var e=d.length-1,c;
(c=d[e]);
e--){if(c.getNetwork()=="meebome"){d.splice(e,1)
}else{c.setAutoStart(true);
c.setMeeboChild(true)
}}gNetworkMgr.requestAddAccounts(d,hitch(gLogon,"receiveVerifyUser"))
}
});
Class("meeboApp.ShareTooltip",ui.Tooltip,function(a){this.createContent=function(){a(this,"createContent");
this.addClassName("TooltipYellow");
this.addClassName("ShareTooltip");
this.m_content.style.padding="5px 0px";
this.m_lineHeight="14px"
};
this.setAd=function(b){if(this.m_ad==b||!this.m_content){return
}this.m_ad=b;
this.m_content.innerHTML=sprintf(gLang.clickAboveToSend,this.m_ad.getProp("title"))
}
});
var gClient,gIMGateway,gEventGateway,gPubSub,gEventMgr,gNetworkMgr,gLogon,gBuddyList,gPrefs,gTargeting,gWidgets,gUIState,gFeedMgr;
function init(){if(arguments.callee.called){return
}arguments.callee.called=true;
if(typeof gPubSub=="undefined"){gPubSub=new lib.PubSub()
}gClient=new events.Client();
gIMGateway=new events.IMGateway(gClient);
if(events.EventGateway){gEventGateway=new events.EventGateway(gClient)
}gEventMgr=new meebo.EventMgr();
gNetworkMgr=new meebo.NetworkMgr();
gLogon=new meebo.LogonMgr();
gBuddyList=new meebo.BuddyList();
gPrefs=new meebo.Prefs();
gTargeting=new ads.Targeting();
gWidgets=null;
if(meebo.UIState){gUIState=new meebo.UIState()
}if(meebo.FeedMgr){gFeedMgr=new meebo.FeedMgr()
}}window.onload=function(a){contentLoaded();
if(typeof gNetworkMgr!="undefined"){gNetworkMgr.init()
}};
function contentLoaded(){init();
if(typeof gPubSub=="undefined"||typeof onContentLoaded=="undefined"){return
}if(arguments.callee.called){return
}arguments.callee.called=true;
onContentLoaded()
}var gBuddyListDlg;
var gSounds;
var gNotice;
var gUid;
var gColorMgr;
var gMediaBar;
var gAdTimer;
var gTimerMgr;
var gWindowMgr;
var gAudioBtn;
var gWait;
var gWindows;
var gConsoleMgr;
var gInfoDlg;
var gBrowser;
var gSerializer;
var gSkins;
var gFrontPage;
var gRemote;
var gDragManager;
var gIsGuestGroupChat=false;
var gIsGuestFileTransfer=false;
var gRoomBuddyListCache=[];
var gCurrentPartner;
var gStatusMessages;
function onContentLoaded(){document.createElement("m_span");
var c=util.query;
c.grabHashVariables();
meeboApp.initGlobals();
gClient.setBCookie(gBCookie);
gPubSub.subscribe("meebo.EventMgr::changeState",meeboApp,"onEventMgrChangeState");
gPubSub.subscribe("meebo.EventMgr::IM",meeboApp,"dispatchIM");
gPubSub.subscribe("meebo.EventMgr::sentIM",meeboApp,"dispatchIM");
gPubSub.subscribe("meebo.EventMgr::buddyAddRequest",meeboApp,"onBuddyAddRequest");
gPubSub.subscribe("meebo.EventMgr::roomInvite",meeboApp,"onChatInvite");
gPubSub.subscribe("meebo.EventMgr::appInvite",meeboApp,"onChatInvite");
gPubSub.subscribe("meebo.EventMgr::shareInvite",meeboApp,"onChatInvite");
gPubSub.subscribe("meebo.EventMgr::appCreated",meeboApp.Application,"onAppCreated");
gPubSub.subscribe("meebo.EventMgr::appRegister",meeboApp,"onAppRegister");
gPubSub.subscribe("meebo.EventMgr::loadApps",meebo.applicationMgr,"loadList");
gPubSub.subscribe("meebo.MeeboAccount::changeState",meeboApp,"onMeeboAccountChangeState");
gPubSub.subscribe("meebo.Chat::changeChatId",meeboApp,"onChatChangeChatId");
gPubSub.subscribe("meebo.Buddy::conversation",meeboApp,"onConversation");
gPubSub.subscribe("meebo.Conversation::changeUnreadCount",meeboApp,"onUnreadMessageCountChange");
meeboApp.addNavigateAwayWarnings();
var b=getQueryVariable("ip")||"";
if(b){gClient.setIPAddress(b)
}if(!gIsGuestGroupChat&&!gIsGuestFileTransfer){meeboApp.initBasicMeebo()
}else{meeboApp.initGuestMeebo()
}ui.hookEvents.subscribe("mousedown",meeboApp,"onInput");
meeboApp.platform.create();
setTimeout(function(){if(window.Quantcast){Quantcast.track()
}if(window.GoogleAnalytics){GoogleAnalytics.track()
}if(window.ComScore){ComScore.track(ComScore.CORE_ID)
}},2000);
var a=c.getHashVariable(c.TRACK_VIRAL);
if(a){gNetworkMgr.addUILogFilter("viral","regflow2|registration|joined-",function(d){d.action+="-viral";
return d
});
gNetworkMgr.doUILog("frontpage","tracking",a,true)
}if(typeof treatmentCallback=="function"){treatmentCallback()
}if(window.gTakeover){meeboApp.initializeTakeover()
}VideoEgg.loadJS()
}function setReturnHandler(a){gRemote.callback=a
};
