/* Copyright (C) 2009 Microsoft Corporation */window.$cxp_ic=window.$cxp_ic||{};$cxp_ic.ic={};$cxp_ic.eventutil={};$cxp_ic.dom={};$cxp_ic.data={};$cxp_ic.presence={};$cxp_ic.menu={};$cxp_ic.constants={};$cxp_ic.ItemType={Tile:"Tile",Name:"Name",Message:"Message",MenuCustom:"MenuCustom"};$cxp_ic.scoped_eval=function(p_args){eval(p_args)};var $cxp_ic_f=function(){var f=$cxp_ic.constants={ControlDataIndex:{cid:"0",showmenu:"1",menudefault:"2",name:"3",contactid:"4",deccid:"5",address:"6",membername:"7",attachmenutobody:"8",placedintable:"9",menucustom:"10",tileitemid:"11",nameitemid:"12",psmitemid:"13",actiontypeurloverride:"14"},MenuIndex:{text:"0",url:"1",itemid:"2",callback:"3",target:"4"}},c=new function(){var a=window.navigator.appVersion,b=document.body;this.isIE=function(){return window.ActiveXObject?1:0};this.direction="rtl"===(b.currentStyle?b.currentStyle.direction:document.defaultView.getComputedStyle(b,"").getPropertyValue("direction"))?"right":"left";this.getVersion=function(){return this.isIE()?parseFloat(a.substr(a.indexOf("MSIE")+5,3)):parseFloat(a)};this.isIE6=function(){return this.isIE()&&this.getVersion()==6};this.isIE7=function(){return this.isIE()&&this.getVersion()==7};this.isIE6_RTL=function(){return this.isIE6()&&this.direction=="right"}},b=$cxp_ic.eventutil=new function(){var a=[];this.addEvent=function e(e,b,d,f){c.isIE()?e.attachEvent("on"+b,d):e.addEventListener(b,d,false);if(!f)a.push({target:e,eventType:b,listener:d})};this.removeEvent=function d(d,a,b){c.isIE()?d.detachEvent("on"+a,b):d.removeEventListener(a,b,false)};this.removeAllEvents=function b(){var b,c=a.length;while(c--){b=a[c];this.removeEvent(b.target,b.eventType,b.listener)}};this.stopEvent=function(a){c.isIE()?(event.cancelBubble=true):a.stopPropagation()};this.stopEventAction=function(a){c.isIE()?(event.returnValue=false):a.preventDefault()};this.eventTarget=function(a){return c.isIE()?event.srcElement:a.target};this.clientX=function(a){return c.isIE()?event.clientX:a.clientX};this.clientY=function(a){return c.isIE()?event.clientY:a.clientY};this.clientHeight=function(){return c.isIE()?document.documentElement.clientHeight:window.innerHeight};this.clientWidth=function(){return c.isIE()?document.documentElement.clientWidth:window.innerWidth}},a=$cxp_ic.dom=new function(){var a={};this.clear=function(){a={}};this.dispose=function(){a=null};this.getIcIdFromTarget=function(c){var a=b.eventTarget(c).id;return a&&a.indexOf("_")>0?a.split("_")[0]:""};this.$=function(d,c){var b=[d,"_",c].join("");if(!a[b])a[b]=document.getElementById(b);return a[b]}},g=$cxp_ic.presence=new function(){var b=this,g,i,h="NI",j={},f={};this.start=function(){if(!b.isShowPresence())return;if(c.isIE()&&h=="NI")try{g=new ActiveXObject("MSNMessenger.Hotmail2Control");if(g){var a=g.GetLocalUserStatus();g.SetLocalUserStatus(a);h="E";k();i=window.setInterval(function(){k()},5e3)}}catch(d){h="NE";g=null;f={}}if(!b.isEnabled())f={}};this.startWeb=function(){var a,c;if(!b.isShowPresence())return;try{h="E";for(a in f){c=a.indexOf("cid:")==0?a.substring(4):null;j[a]=gPresenceManager.subscribe(b,b.update,!c?a:null,c,null)}}catch(d){h="NE"}};this.dispose=function(){try{if(b.isWebMsgr()){var a;for(a in j)gPresenceManager.unsubscribe(j[a])}else if(i){window.clearInterval(i);i=null}g=j=f=h=b=null}catch(c){}};this.isEnabled=function(){return h=="E"};this.isShowPresence=function(){var a=window.navigator.cpuClass,c=a=="x64"||a=="ia64";return (!c||b.isWebMsgr())&&d.CommonData.getItem("showpresence")=="1"};this.isWebMsgr=function(){return d.CommonData.getItem("webpresence")=="1"};this.register=function(a,c){if(!b.isShowPresence()||!a||!c)return;if(!f[a])f[a]=[];f[a].push(c)};var k=function(){var d,a,c;try{a=g.GetLocalUserStatus()}catch(e){}if(!a)a=0;for(d in f)try{if(a==1||a==0)c=0;else c=g.GetUserStatus(d);b.update({emailAddress:d,status:c})}catch(e){}if(a==0)if(i){window.clearInterval(i);h="NE";i=null}};this.update=function(i){var v,t,w;try{if(i){v=i.status;t=i.emailAddress||(i.cid?["cid:",i.cid].join(""):null);w=i.psm}if(v==null||t==null)return;var h,g,n=d.CommonData;switch(v){case 2:h="green";g=n.getItem("p_av");break;case 10:case 50:h="red";g=n.getItem("p_b");break;case 14:case 18:case 34:case 66:h="orange";g=n.getItem("p_aw");break;case 1:case 6:h="blue";g=n.getItem("p_off");break;case 0:default:h="blue";g=""}if(h){var c,p,j,o,x,r,q,k,u,m,l,z=f[t],A=["cxp_ic_",h,"frame",g?" cxp_ic_pr_av":""].join("");for(p=0;p<z.length;++p){c=z[p];o=a.$(c,"frame");r=a.$(c,"pr_t");j=a.$(c,"menu_si");q=a.$(c,"menu_si_pr_t");x=j&&j.style.display=="none";u=a.$(c,"menu");if(o){var y="";if(o.className.indexOf("cxp_ic_frame_clip")>=0)y=" cxp_ic_frame_clip";o.className=A+y}if(q)q.innerHTML=g;if(j)if(g&&x)j.style.display="block";else if(g=="")j.style.display="none";if(u&&u.style.display=="block")e.adjustShadow(c);if(r)r.innerHTML=" "+g;k=a.$(c,"psm");if(k&&b.isWebMsgr()){m=a.$(c,"text");var s=a.$(c,"usertilecontainer")&&a.$(c,"usertilecontainer").className.split(" ");if(s&&s[1])l=s[1].replace("cxp_ic_img_","");else l="";if(w){k.style.display="block";k.innerHTML=w;if(m.className.indexOf("text_h")>0&&l!="xl")m.className="cxp_ic_text_h"}else{k.style.display="none";k.innerHTML="";if(m.className.indexOf("text_h")>0&&l!="xl")m.className="cxp_ic_text_h cxp_ic_text_h_"+l}}}}}catch(B){}};this.isAvailableForIC=function(c){var b=a.$(c,"frame");if(b)return b.className.indexOf("cxp_ic_pr_av")>=0;return false};this.startIM=function(a){var c;if(!a)return;try{if(b.isWebMsgr()){c=a.indexOf("cid:")==0?a.substring(4):null;gPresenceManager.chat(!c?a:null,c)}else g.InstantMessage2(a,"",0)}catch(d){}}},d=$cxp_ic.data=new function(){var a=this;this.dispose=function(){a.Itemid_Element_Map.dispose();a.Cid_Icid_Map.dispose();a=null};this.Itemid_Element_Map=new function(){var a={};this.add=function(b,c,d){if(!b||!c||!d)return;if(!a[b])a[b]={};if(!a[b][c])a[b][c]=[];a[b][c].push(d)};this.getItem=function(b,c){if(a[b]&&a[b][c])return a[b][c];else return []};this.dispose=function(){a=null}};this.Cid_Icid_Map=new function(){var a={};this.add=function(b,c){if(!a[b])a[b]=[];a[b].push(c)};this.getItem=function(b){if(a[b])return a[b];else return []};this.dispose=function(){a=null}};this.CommonData=new function(){this.getItem=function(a){if(typeof cxp_ic_common_data!="undefined"&&cxp_ic_common_data[a])return cxp_ic_common_data[a];return ""}};this.ControlData=new function(){this.exists=function(){return typeof cxp_ic_control_data!="undefined"};this.getObject=function(){if(this.exists())return cxp_ic_control_data;else return []};this.getItem=function(c,b){var a=this.exists()?cxp_ic_control_data[c]:null;return a&&a[b]?a[b]:""}}},e=$cxp_ic.menu=new function(){var m=this,h=['<div id="',"{ic_cntrlid}",'_highlight_tp"  class="cxp_ic_highlight cxp_ic_highlight_tp"></div>','<div id="',"{ic_cntrlid}",'_highlight" class="cxp_ic_highlight" ><span class="cxp_ic_chevron"><img  src="',"{ic_imgbaseurl}","{ic_iconmap}",'" ','alt="i" ',"{ic_ie6_alpha_style_tag}"," /></span></div>",'<div id="',"{ic_cntrlid}",'_menu" class="cxp_ic_menu cxp_ic_menu_btm cxp_ic_menu_right" style="display:none;"></div>'],k=0,e=f.MenuIndex,q=d.ControlData,o=f.ControlDataIndex,i=null;this.dispose=function(){h=e=i=null;m=null};var n=function(e){var k=a.$(e,"usertilecontainer"),n=k.className.indexOf("cxp_ic_img_xl")>=0?"xl":"",o=c.isIE6()&&typeof uxp_p=="undefined"?"8":"24",l=["iciconmap",n,o,".png"].join("");h[1]=h[4]=h[13]=e;h[6]=d.CommonData.getItem("imgbaseurl");if(c.isIE6()&&typeof uxp_p!="undefined"){h[7]="cb.gif";h[10]=["style=\"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='",d.CommonData.getItem("imgbaseurl"),l,"')\" "].join("")}else{h[7]=l;h[10]=""}var f=document.createElement("div");f.innerHTML=h.join("");while(f.firstChild)if(j(e)&&f.firstChild.id==[e,"_menu"].join(""))u().appendChild(f.firstChild);else k.appendChild(f.firstChild);if(c.isIE6_RTL())k.innerHTML+='<div style="filter:alpha(opacity = 25);position: absolute;"></div>';var i=a.$(e,"highlight_tp"),m=a.$(e,"frame_clip");m.style.outline="none";i.setAttribute("title",m.title);var g=$cxp_ic.ic;b.addEvent(i,"mouseover",g.focus);b.addEvent(i,"mouseout",g.blur);b.addEvent(i,"click",g.click);b.removeEvent(a.$(e,"frame"),"mouseover",g.focus);if(typeof uxp_p!="undefined")b.removeEvent(a.$(e,"usertile"),"mouseover",g.focus)};this.showHighlight=function(c){var b=a.$(c,"highlight");if(!b)n(c);else b.style.display="block"};this.hideHighlight=function(c){var b=a.$(c,"highlight");if(b)b.style.display="none"};this.show=function(b,g,f){var d=a.$(b,"menu");if(!d){n(b);d=a.$(b,"menu")}if(!a.$(b,"menu_ul"))y(b);d.style.display="block";a.$(b,"highlight").style.display="block";if(!j(b)){var e=a.$(b,"usertilecontainer");e.parentNode.style.zIndex=50;if(!c.isIE6_RTL())e.style.zIndex=50}m.dock(b,d,g,f);v(b);m.adjustShadow(b)};this.hide=function(b){a.$(b,"menu").style.display="none";a.$(b,"highlight").style.display="none";if(!j(b)){var d=a.$(b,"usertilecontainer");d.parentNode.style.zIndex=0;if(!c.isIE6_RTL())d.style.zIndex=0}};var j=function(a){return q.getItem(a,o.attachmenutobody)=="1"},z=function(a){a=a||event;i=a.shiftKey},w=function(h){var g=b.eventTarget(h),c,d;if(!i){var f=g.parentNode.nextSibling;if(!f||f&&f.style.display=="none"&&!f.nextSibling){c=$cxp_ic.ic.getActiveIcId();d=a.$(c,"name")||a.$(c,"frame_clip")}}else{var e=g.parentNode.previousSibling;if(!e||e&&e.style.display=="none"&&!e.previousSibling){c=$cxp_ic.ic.getActiveIcId();d=a.$(c,"frame_clip")}i=null}if(d){$cxp_ic.ic.hideActiveIc();d.focus()}};this.dock=function(g,e,w,A){if(!e){e=a.$(g,"menu");if(!e)return}var r=c.direction,n,h;if(w){var l=b.clientX(w),v=b.clientY(w),y=b.clientHeight(),u=b.clientWidth();if(!A){n=v+200>y?y-(v+150)<v-150:false;if(r=="left")h=l+200>u?u-(l+150)<l-150:false;else h=l-200<0?l-150<u-(l+150):false}else{n=false;h=false}}if(!j(g)){var f=e.className;f=n?f.replace("btm","top"):f.replace("top","btm");f=h?f.replace("right","left"):f.replace("left","right");e.className=f}else{var m=a.$(g,"highlight"),z=a.$(g,"usertilecontainer"),d=document.getElementById(g),p=d.offsetLeft,i=d.offsetTop;while(d=d.offsetParent){p+=d.offsetLeft;i+=d.offsetTop}if(c.isIE7()){if(k==0)x();p=Math.round(p/k);i=Math.round(i/k)}if(c.isIE()&&q.getItem(g,o.placedintable)=="1"){d=a.$(g,"pos_ref");i=d.offsetTop+1+(c.isIE6()?1:0);while(d=d.offsetParent)i+=d.offsetTop}var s=p+z.offsetLeft+m.offsetLeft,t=i+m.offsetTop+m.offsetHeight;if(r=="left"&&h||r=="right"&&!h)s=s-(e.offsetWidth-m.offsetWidth);if(n)t=t-m.offsetHeight-e.offsetHeight;e.style.left=s+"px";e.style.top=t+"px"}};var u=function(){var a=document.getElementById("cxp_ic_menus");if(!a){a=document.createElement("div");a.id="cxp_ic_menus";document.body.insertBefore(a,document.body.firstChild)}return a},y=function(c){var b,d;b=document.createElement("ul");b.className="c_m";b.setAttribute("id",[c,"_menu_ul"].join(""));d=s(c,b);t(c,b,d);a.$(c,"menu").appendChild(b)},s=function(b,K){var y,H,A,s,n,t,B,x,u,D,F,z,w,c,L,m,J,E,C,I,N,o,i=d.ControlData,j=f.ControlDataIndex,k=d.CommonData,M=parseInt(k.getItem("max_name"))||-1;if(typeof cxp_ic_menu_data!="undefined"){y=i.getItem(b,j.menudefault)||[];H=i.getItem(b,j.cid);D=i.getItem(b,j.address);N=i.getItem(b,j.deccid);z=i.getItem(b,j.contactid);L=i.getItem(b,j.membername);w=i.getItem(b,j.name);E=document.createElement("span");E.innerHTML=w;C=E.innerHTML;J=M>0&&C.length>M;for(var G=0;G<y.length;++G){m=y[G];s=cxp_ic_menu_data[m];if(!s)continue;c=s[e.text];if(m=="tp"){if(w.length<=0||J)c=k.getItem(m+"_no_name");c=c.replace("{name}",w)}I=k.getItem("ru");F=s[e.itemid];n=t=A="";u=B=false;o="_top";var h=i.getItem(b,j.actiontypeurloverride);h=!h||!h[m]?s[e.url]:h[m];try{switch(m){case "tp":case "pr":case "gr":case "ev":case "ph":n=h.replace("{cid}",H);break;case "ct":n=h.replace("{contactid}",z);o=null;break;case "se":n=h.replace("{address}",D).replace("{ru}",encodeURIComponent(I));o=null;break;case "sm":n=h.replace("{address}",N).replace("{ru}",encodeURIComponent(I));break;case "si":A=[b,"_menu_si"].join("");c+=['&nbsp;<span id="',b,'_menu_si_pr_t">{0}</span>'].join("");if(!g.isAvailableForIC(b)){B=true;c=c.replace("{0}","")}else{var v=a.$(b,"frame").className,q="";if(v.indexOf("green")>=0)q=k.getItem("p_av");else if(v.indexOf("orange")>=0)q=k.getItem("p_aw");else if(v.indexOf("red")>=0)q=k.getItem("p_b");else if(v.indexOf("blue")>=0)q=k.getItem("p_off");c=c.replace("{0}",q)}t=l("sendim",{membername:L});o=null;break;case "c4":case "c3":case "c2":case "c1":u=true;t=l("invite",{inviteUrl:h,cid:H,email:D,cnid:z,name:C,icid:b});o=null}}catch(O){n="";F=""}if(u)x=p(K,null,[b,"_menu_inviteSeparator"].join(""));r(K,u?null:x,A,c,n,t,F,B,o)}}return x},l=function(c,a){var b=d.CommonData;switch(c){case "invite":return function(){var d=["0x",a.cid].join(""),f="0",e="cid";if(a.cid=="0000000000000000")if(a.cnid&&a.cnid!=""){d=a.cnid;f="2";e="cnid"}else{d=a.email;f="1";e="email"}if(typeof $sn_invite_popover!="undefined")$sn_invite_popover.show(d,f,a.name,a.icid);else try{var c=a.inviteUrl;c=[c,"&",e,"=",encodeURIComponent(d)].join("");c=c.replace("{name}",encodeURIComponent(a.name)).replace("{vcid}",b.getItem("vcid")).replace("{scxt}",b.getItem("socialcontext")).replace("{ru}",encodeURIComponent(b.getItem("ru")));window.location=c}catch(g){}return false};case "sendim":return function(){g.startIM(a.membername);return false};case "customonclick":return function(){try{$cxp_ic.scoped_eval(a)}catch(b){return false}}}},t=function(j,h,g){var c,a,b,i;c=d.ControlData.getItem(j,f.ControlDataIndex.menucustom);while(c.length>0){a=c.shift();b=null;if(a[e.text]&&a[e.text]=="cxp_ic_menu_separator")p(h,g);else{if(a[e.callback]){b=a[e.callback];if(typeof b=="string")b=l("customonclick",b)}if(cxp_ic_menu_data["mc"])i=cxp_ic_menu_data["mc"][e.itemid];r(h,g,null,a[e.text],a[e.url],b,i,null,a[e.target])}}},r=function(h,g,l,k,d,e,j,m,i){var c,a,f;if(e&&!d){d="#";f="return false;"}if(k&&(d||e)){c=document.createElement("li");a=document.createElement("a");if(l)c.setAttribute("id",l);if(d){a.setAttribute("href",d);if(f)a.setAttribute("onclick",f);if(i)a.setAttribute("target",i)}if(j)b.addEvent(a,"click",function(){var a=new Image;a.src=j});if(e)b.addEvent(a,"click",e);a.innerHTML=k;if(m)c.style.display="none";c.appendChild(a);if(g)h.insertBefore(c,g);else h.appendChild(c);b.addEvent(a,"keydown",z);b.addEvent(a,"blur",w)}return c},p=function(c,b,d){var a=document.createElement("li");if(d)a.setAttribute("id",d);a.innerHTML='<div class="c_ms">&nbsp;</div>';a.className="cxp_ic_menu_separator";if(b)c.insertBefore(a,b);else c.appendChild(a);return a},v=function(c){if(!a.$(c,"menu_shadow")){var b=document.createElement("div");b.className="cxp_ic_menu_shadow";b.id=[c,"_menu_shadow"].join("");a.$(c,"menu").appendChild(b)}};this.adjustShadow=function(d,f,e){var c=f||a.$(d,"menu_ul"),b=e||a.$(d,"menu_shadow");if(c&&b){b.style.width=c.offsetWidth-2+"px";b.style.height=c.offsetHeight-4+"px"}};var x=function(){var a=document.createElement("div");a.id="ic_zd";a.style.visibility="hidden";a.style.position="absolute";a.style.width="0px";a.style.height="0px";a.style.left="20px";a.style.top="20px";document.body.appendChild(a);var b=a.offsetTop;k=b/20}};$cxp_ic.ic=new function(){var h=this,c=null,l=[],j=null,i=null;this.init=function(){if(d.ControlData.exists()){if(h.load)return;h.load="started";h.bind();h.load="finished"}};this.reinit=function(){if(d.ControlData.exists()){a.clear();h.bind()}};this.dispose=function(){try{d.dispose();g.dispose();e.dispose();a.dispose();b.removeAllEvents();c=j=i=h=l=null}catch(f){}};this.getActiveIcId=function(){return c};this.bind=function(){var c,q,j,o,p,t,n=$cxp_ic.ItemType,e=d.ControlData,i=f.ControlDataIndex,l=d.Itemid_Element_Map,r=d.Cid_Icid_Map;t=document.getElementById("cxp_ic_usertiles");for(c in d.ControlData.getObject()){if(!document.getElementById(c))continue;if(e.getItem(c,i.showmenu)=="1"){q=a.$(c,"frame");if(!q)continue;j=a.$(c,"frame_clip");b.addEvent(q,"mouseover",h.focus,true);if(typeof uxp_p!="undefined"){var s=a.$(c,"usertile");b.addEvent(s,"mouseover",h.focus,true)}b.addEvent(j,"focus",h.focus);b.addEvent(j,"keydown",h.keyDown);b.addEvent(j,"blur",h.blur);b.addEvent(j,"click",h.click);j.setAttribute("href","#");j.onclick=null;p=e.getItem(c,i.menucustom);for(o=0;o<p.length;++o)l.add(p[o][f.MenuIndex.itemid],n.MenuCustom,[c,"_",o].join(""))}else{l.add(e.getItem(c,i.tileitemid),n.Tile,a.$(c,"frame_clip"));if(typeof uxp_p!="undefined")l.add(e.getItem(c,i.tileitemid),n.Tile,a.$(c,"usertile"))}r.add(e.getItem(c,i.cid),c);g.register(e.getItem(c,i.membername),c);l.add(e.getItem(c,i.nameitemid),n.Name,a.$(c,"name"));l.add(e.getItem(c,i.psmitemid),n.Message,a.$(c,"psm"))}b.addEvent(document,"click",k);b.addEvent(window,"resize",m);if(!g.isWebMsgr())g.start();b.addEvent(window,"unload",h.dispose,false)};this.hideActiveIc=function(){k()};this.click=function(a){n(a)};this.focus=function(a){o(a)};this.blur=function(a){p(a)};this.keyDown=function(a){a=a||event;j=a.shiftKey;i=true};var m=function(){if(c)e.dock(c)},n=function(f){var d=a.getIcIdFromTarget(f),g=c==d;if(d=="")return;k();if(!g){e.show(d,f,i);c=d}b.stopEvent(f);b.stopEventAction(f);i=false},o=function(f){var b=a.getIcIdFromTarget(f);if(b=="")return;var d;while(d=l.pop()){if(c&&c==d)continue;e.hideHighlight(d)}e.showHighlight(b);l.push(b)},p=function(f){var b=a.getIcIdFromTarget(f);if(b=="")return;if(c&&c==b){if(f.type=="blur"){if(j){k();j=null}else{var d=a.$(b,"menu_ul").getElementsByTagName("a");if(d&&d.length>0)d[0].focus()}return}}else e.hideHighlight(b)},k=function(){if(c){e.hide(c);c=null}}}};$cxp_ic_f();$cxp_ic.ic.init()