﻿// Copyright (c) Microsoft Corporation.  All rights reserved. 
// Use of this code is governed by the Terms of Use located at: http://dev.live.com/contactscontrol/gadgettou.aspx
// and http://dev.live.com/spacescontrol/gadgettou.aspx
registerNamespace=function(f){if(typeof Type!="undefined"&&typeof Type.registerNamespace=="function")return Type.registerNamespace(f);var d=window,c=f.split(".");for(var b=0;b<c.length;b++){var e=c[b],a=d[e];if(!a){a=d[e]={};if(b===0){if(!window.__rootNamespaces)window.__rootNamespaces=[];window.__rootNamespaces[window.__rootNamespaces.length]=a}}if(!a.__namespace){a.__namespace=true;a.__typeName=c.slice(0,b+1).join(".");a.getName=function g(){return this.__typeName}}d=a}};registerNamespace("Microsoft.Live.Platform");Microsoft.Live.Platform.baseURL=window.location.protocol+"//controls.services.live.com/scripts/base/v0.3/";Microsoft.Live.Platform.scriptURL=Microsoft.Live.Platform.baseURL;Microsoft.Live.Platform.addEvent=function(a,b,c){if(a.addEventListener)a.addEventListener(b,c,false);else if(a.attachEvent)a.attachEvent("on"+b,c)};Microsoft.Live.Platform.removeEvent=function(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c,false);else if(a.detachEvent)a.detachEvent("on"+b,c)};Microsoft.Live.Platform.uniqueID=function(a){var b=a+Math.floor(Math.random()*1024*1024);if(document.getElementById(b))return Microsoft.Live.Platform.uniqueID(a);return b};Microsoft.Live.Platform.escapeRegExp=function(a){var b=new RegExp("(\\+|\\/|\\*|\\?|\\||\\{|\\[|\\(|\\)|\\^|\\$|\\#|\\.|\\}|\\])","g");return a?a.replace(/(\\)/g,"\\\\").replace(b,"\\$1"):""};Microsoft.Live.Platform.expandURL=function(e,f){var a;if(!e||e.length==0){var g=window.location.protocol+"//"+window.location.host+window.location.pathname;a=g.split("/");a.pop()}else a=e.replace(/\\/g,"/").split("/");if(a.length>0&&a[a.length-1].length==0)a.pop();if(f&&f.length>0){var b=f.replace(/\\/g,"/").split("/"),c;if(b.length>0){c=b[0];var d;if(a.length>=2&&a[0].substr(a[0].length-1)==":"&&a[1].length==0)d=3;else d=1;if(c.length==0){a.length=d;b.shift()}else if(c.substr(c.length-1)==":")return b.join("/");b.reverse();for(;b.length>0;){c=b.pop();switch(c){case ".":break;case "..":if(a.length>d)a.pop();break;default:a.push(c)}}}}return a.join("/")};Microsoft.Live.Platform.findHash=function(a){var b=a.indexOf("#");if(b>=0&&typeof a=="string")return a.substring(b);return ""};Microsoft.Live.Platform.expandURLs=function(d,a){if(!a)return null;var c=new Array(a.length);for(var b=0;b<a.length;b++)c[b]=Microsoft.Live.Platform.expandURL(d,a[b]);return c};Microsoft.Live.Platform._load={list:[],onLoads:[],onErrors:[],loading:0};Microsoft.Live.Platform.load=function(d,i,h){function j(c,b){for(var a=b.length-1;a>=0;a--)c.push(Microsoft.Live.Platform.expandURL("",b[a]))}var b=Microsoft.Live.Platform._load;if("string"===typeof d)b.list.push(d);else j(b.list,d);if(i)b.onLoads.push(i);if(h)b.onErrors.push(h);if(!b.loading)a();function a(){var d=Microsoft.Live.Platform._load;if(d.list.length>0){d.loading=1;var e=d.list.pop();if(e.indexOf("://")==0)e=Microsoft.Live.Platform.expandURL("",e);var h=document.getElementsByTagName("script"),b;for(var i=0;i<h.length;i++){b=h[i];if(b.src==e)if(b.readyState=="loaded"||b.readyState=="complete"){d=e=h=b=null;a();return}else{Microsoft.Live.Platform.addEvent(b,"load",g);Microsoft.Live.Platform.addEvent(b,"error",f);Microsoft.Live.Platform.addEvent(b,"readystatechange",c);d=e=h=b=null;return}}h=null;b=document.createElement("script");b.type="text/javascript";Microsoft.Live.Platform.addEvent(b,"load",g);Microsoft.Live.Platform.addEvent(b,"error",f);Microsoft.Live.Platform.addEvent(b,"readystatechange",c);b.src=e;document.getElementsByTagName("head")[0].appendChild(b)}else{var j,k=d.list.length;for(;d.onLoads.length>0;){j=d.onLoads.pop();try{j();if(d.list.length>k){a();return}}catch(l){}}d.loading=0}}function c(c){if(!c)c=system.event;var b=c.srcElement;if(b.readyState=="loaded"||b.readyState=="complete"){e(b);a()}}function g(){this.readyState="complete";e(this);a()}function f(){this.readyState="complete";e(this);var b;for(;Microsoft.Live.Platform._load.onErrors.length>0;){b=Microsoft.Live.Platform._load.onErrors.pop();try{b(this)}catch(c){}}a()}function e(a){Microsoft.Live.Platform.removeEvent(a,"load",g);Microsoft.Live.Platform.removeEvent(a,"error",f);Microsoft.Live.Platform.removeEvent(a,"readystatechange",c)}};Microsoft.Live.Platform.loadFrom=function(c,a,e,d){var b;if("string"===typeof a)b=Microsoft.Live.Platform.expandURL(c,a);else b=Microsoft.Live.Platform.expandURLs(c,a);Microsoft.Live.Platform.load(b,e,d)};Microsoft.Live.Platform.using=function(a,d,c){if("string"===typeof a)a=[a];for(var b=0;b<a.length;b++)a[b]=Microsoft.Live.Platform.scriptURL+a[b]+".js";Microsoft.Live.Platform.load(a,d,c)};Microsoft.Live.Platform.getCookie=function(b){var a=document.cookie.match(b+"=(.*?)(;|$)");if(a)return unescape(a[1]);else return null};Microsoft.Live.Platform.deleteCookie=function(b,c,a){var d=new Date(0);document.cookie=b+"=;expires="+d.toGMTString()+";path="+c+";domain="+a+";"};Microsoft.Live.Platform.format=function(){var b=arguments[0],d="",c=0;for(var a=0;a<b.length;a++)if(b.charAt(a)=="%"&&arguments[b.charAt(a+1)]){d+=b.substr(c,a-c)+arguments[b.charAt(a+1)];a++;c=a+1}if(c<b.length)d+=b.substr(c);return d};Microsoft.Live.Platform.sanitizeColor=function(a){var b=new RegExp("^(#[0-9a-fA-F]{1,6}|rgb\\([0-9]{1,3}%?,[0-9]{1,3}%?,[0-9]{1,3}%?\\)|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow)$");if(b.test(a))return a;else return null};Microsoft.Live.Platform.Hesc=function(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&#39;")};Microsoft.Live.ArgumentException=function(a){this.name="ArgumentException";this.message=a;Microsoft.Live.ArgumentException.prototype.toString=function(){return this.name+": "+this.message}};Microsoft.Live.InvalidOperationException=function(a){this.name="InvalidOperationException";this.message=a;Microsoft.Live.InvalidOperationException.prototype.toString=function(){return this.name+": "+this.message}};if("undefined"===typeof window.XMLHttpRequest)window.XMLHttpRequest=function(){var b=["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];for(var a=0;a<b.length;a++)try{var c=new ActiveXObject(b[a]);return c}catch(d){}return null};if("undefined"===typeof window.location.replace)window.location.replace=window.location.assign;registerNamespace("Microsoft.Live.Channels");Microsoft.Live.Channels.baseURL=Microsoft.Live.Platform.expandURL(Microsoft.Live.Platform.baseURL,"../../channel/v0.3/");Microsoft.Live.Channels.scriptURL=Microsoft.Live.Platform.expandURL(Microsoft.Live.Platform.scriptURL,"../../channel/v0.3/");Microsoft.Live.Channels.secureScriptURL=Microsoft.Live.Channels.scriptURL.replace("http://","https://");registerNamespace("Microsoft.Live.Channels.Internal");Microsoft.Live.IfmFrame=function(k,c,d,e,h,i){var a=document.getElementById(k),j=Microsoft.Live.Channels.Internal,l=Microsoft.Live.Platform;if(!c||c.length==0);if(!e){var f=c.split("/");if(f&&f.length>3)e=f[0]+"//"+f[2]+"/channel.htm"}if(!d)d=document.location.protocol+"//"+document.location.host+"/channel.htm";d=Microsoft.Live.Platform.expandURL("",d);var b=document.createElement("iframe"),m=a.style;b["scrolling"]=a["scrolling"]||"no";b["width"]="100%";b["height"]="100%";b["align"]=a["align"]||"left";b["frameBorder"]=a["frameborder"]=="yes"||a["frameborder"]=="1"?1:0;b.id=b.name=l.uniqueID("ifm");if(c.indexOf("#")==-1)c+="#";c+="&WLIFMp="+encodeURIComponent(d)+"&WLIFMi="+encodeURIComponent(b.id);if(j.testFlashVersion(7,0)){var g=Microsoft.Live.Channels.Internal.getDomainFromURL(e);a.channel=new Microsoft.Live.Channels.FlashChannel(g,b.id,g);a.channel.onReceiveMessage=h;a.channel.onError=i;a.transport="fast";c+="&WLIFMt=f"}else{a.channel=new Microsoft.Live.Channels.Channel("",d,g);a.channel.onReceiveMessage=h;a.channel.onError=i;a.channel.connect(b.id,e);Microsoft.Live.Channels.Mux.register_recver(b.id,e,a.channel.onReceiveMessage,true);a.transport="slow";c+="&WLIFMt=i"}b.src=c;a.appendChild(b);a.channel.setReceiver=function(c){if(typeof c=="function")if(j.testFlashVersion(7,0))a.channel.onReceiveMessage=c;else{a.channel.onReceiveMessage=c;Microsoft.Live.Channels.Mux.register_recver(b.id,e,a.channel.onReceiveMessage,true)}};return a};Microsoft.Live.IfmChannel=function(n,c,d,h,k){if(self.location==top.location){top.location="about:blank";throw new Error("This website must be inside of an Iframe to be used.");return}var l=Microsoft.Live.Channels.Internal,b=null,f=null,j=null;function m(){var d=document.URL?document.URL:document.location.href,c=Microsoft.Live.Platform.findHash(d).substr(1).split("&"),e={};if(c&&c.length>0){var a;for(i=0;i<c.length;i++){a=c[i].split("=");if(a&&a.length==2)switch(a[0]){case "WLIFMp":b=decodeURIComponent(a[1]);break;case "WLIFMi":f=decodeURIComponent(a[1]);break;case "WLIFMt":j=a[1]}}}}var a=document.getElementById(n);m();if(!c||c.length==0)return;if(!b||b.length==0)return;var e=Microsoft.Live.Platform.escapeRegExp(c);e=e.replace(/\\\*/g,".*");e="^(("+e.replace(/,/g,")|(")+"))$";var g=Microsoft.Live.Channels.Internal.getDomainFromURL(b);if(!g.match(new RegExp(e)))return;if(!d)d=document.location.protocol+"//"+document.location.host+"/channel.htm";d=Microsoft.Live.Platform.expandURL("",d);if(l.testFlashVersion(7,0)&&j=="f"){a.channel=new Microsoft.Live.Channels.FlashChannel(c,f,g);a.channel.onReceiveMessage=h;a.channel.onError=k;a.transport="fast"}else{a.channel=new Microsoft.Live.Channels.Channel(f,d,g);a.channel.onReceiveMessage=h;a.channel.onError=k;a.channel.allowDomains=c;a.channel.connect("",b);Microsoft.Live.Channels.Mux.register_recver("",b,a.channel.onReceiveMessage,true);a.transport="slow"}a.channel.setReceiver=function(c){if(typeof c=="function")if(l.testFlashVersion(7,0))a.channel.onReceiveMessage=c;else{a.channel.onReceiveMessage=c;Microsoft.Live.Channels.Mux.register_recver("",b,a.channel.onReceiveMessage,true)}};return a};registerNamespace("Microsoft.Live.Channels.Mux");function OneShotSemaphore(){this.signal=function(){var c;if(!b){b=true;for(var d=0;d<a.length;d++){c=a[d];if(c)try{c()}catch(e){}}a=[]}};this.reset=function(){b=false};this.waitFor=function(a){if(b)a();else c(a)};this.isSignalled=function(){return b};var a=[],b=false,c=function(b){a.push(b)},d=function(c){var b=a.indexOf(c);if(b>=0)a[b]=null}}Microsoft.Live.Channels.Mux._channels={};Microsoft.Live.Channels.Mux._chanids={};Microsoft.Live.Channels.Mux._srcurls={};Microsoft.Live.Channels.Mux._receivers={};Microsoft.Live.Channels.Mux._ackcounters={};if("undefined"==typeof Microsoft.Live.Channels.Mux._uniqueids)Microsoft.Live.Channels.Mux._uniqueids=[];Microsoft.Live.Channels.Internal._addIDs=function(){var a;for(a=0;a<arguments.length;a++)Microsoft.Live.Channels.Mux._uniqueids.push(arguments[a]);var b=Microsoft.Live.Channels.Mux._uniqueIdMutex;Microsoft.Live.Channels.Mux._uniqueIdMutex=null;b.signal()};Microsoft.Live.Channels.Mux._getUniqueId=function(b){if(Microsoft.Live.Channels.Mux._uniqueids.length==0){var a=Microsoft.Live.Channels.Mux._uniqueIdMutex?true:false;if(!a)Microsoft.Live.Channels.Mux._uniqueIdMutex=new OneShotSemaphore;Microsoft.Live.Channels.Mux._uniqueIdMutex.waitFor(function(){Microsoft.Live.Channels.Mux._getUniqueId(b)});if(!a){var c=document.createElement("script");c.src=Microsoft.Live.Channels.scriptURL+"uniqid2.aspx?numids=10&u="+Math.random();document.getElementsByTagName("head")[0].appendChild(c)}}else b(Microsoft.Live.Channels.Mux._uniqueids.pop())};Microsoft.Live.Channels.Mux._encode=function(a){if("string"!=typeof a)a="";a=encodeURIComponent(a);return a.replace(/%/g,"\\")};Microsoft.Live.Channels.Mux._decode=function(a){if("string"!=typeof a)a="";a=a.replace(/\\/g,"%");return decodeURIComponent(a)};Microsoft.Live.Channels.Mux._clean_iframes=function(c){var b;switch(c){case "S":default:b="Microsoft.Live.Channels.Mux.Sframe";break;case "R":b="Microsoft.Live.Channels.Mux.Rframe"}var a=document.getElementById(b);if(a){a.parentNode.removeChild(a);a=null}};Microsoft.Live.Channels.Mux._send_chunk=function(c,d){try{var a;switch(c){case "S":default:a="Microsoft.Live.Channels.Mux.Sframe";break;case "R":a="Microsoft.Live.Channels.Mux.Rframe"}var b=document.getElementById(a);if(!b){Microsoft.Live.Channels.Mux.init_iframes();b=document.getElementById(a)}b.src=d}catch(e){}};Microsoft.Live.Channels.Mux._CountACKs=function(a,b){var c=false;if(!Microsoft.Live.Channels.Mux._ackcounters[a])Microsoft.Live.Channels.Mux._ackcounters[a]={ackid:0,count:0};if(Microsoft.Live.Channels.Mux._ackcounters[a].ackid==b){if(Microsoft.Live.Channels.Mux._ackcounters[a].count>=5){c=true;Microsoft.Live.Channels.Mux._ackcounters[a].count=0}}else Microsoft.Live.Channels.Mux._ackcounters[a].count=0;Microsoft.Live.Channels.Mux._ackcounters[a].ackid=b;Microsoft.Live.Channels.Mux._ackcounters[a].count++;return c};Microsoft.Live.Channels.Mux._recv_chunk=function(f){if("string"!=typeof f)f=f.hash.substr(1);var e=f.split("/"),a=e[1],i=e[2].substr(0,1),c=parseInt(e[2].substr(1),16),h=e[3],l=e.length>4?e[4]:null;switch(i){case "S":var d=a;if("undefined"==typeof Microsoft.Live.Channels.Mux._chanids[d])Microsoft.Live.Channels.Mux._getUniqueId(function(a){Microsoft.Live.Channels.Mux._chanids[d]=a;Microsoft.Live.Channels.Mux._recv_chunk(f)});else{a=Microsoft.Live.Channels.Mux._chanids[d];var b=Microsoft.Live.Channels.Mux._decode(h),k=Microsoft.Live.Channels.Mux._CountACKs(a,c);if(k)Microsoft.Live.Channels.Mux._clean_iframes("R");else{var j=b+d+"/R"+c.toString(16)+"/"+a+"/"+document.location.hostname;Microsoft.Live.Channels.Mux._send_chunk("R",j)}if("undefined"==typeof Microsoft.Live.Channels.Mux._srcurls[a]&&b!=null){Microsoft.Live.Channels.Mux._srcurls[a]=b;if("undefined"==typeof Microsoft.Live.Channels.Mux._receivers[b])Microsoft.Live.Channels.Mux._receivers[b]=new Microsoft.Live.Channels.Mux._Receiver(b);Microsoft.Live.Channels.Mux._receivers[b]._set_chunkid(c)}}break;case "R":var d=a;a=Microsoft.Live.Channels.Mux._decode(h);if("undefined"!=typeof Microsoft.Live.Channels.Mux._channels[d]){var g=Microsoft.Live.Channels.Mux._channels[d];if(g._validate_sender(l)){if("undefined"==typeof Microsoft.Live.Channels.Mux._channels[a]){Microsoft.Live.Channels.Mux._channels[a]=g;g._set_chanid(a);g._recv_chunk(a,c)}}else return}break;case "C":case "L":if("undefined"!=typeof Microsoft.Live.Channels.Mux._srcurls[a]){var b=Microsoft.Live.Channels.Mux._srcurls[a],k=Microsoft.Live.Channels.Mux._CountACKs(a,c),j=b+a+"/A"+c.toString(16);if(k)Microsoft.Live.Channels.Mux._clean_iframes("R");else Microsoft.Live.Channels.Mux._send_chunk("R",j);Microsoft.Live.Channels.Mux._receivers[b]._recv_chunk(i,c,h)}break;case "X":if("undefined"!=typeof Microsoft.Live.Channels.Mux._srcurls[a])Microsoft.Live.Channels.Mux._receivers[b]._recv_abort(c);break;case "A":if("undefined"!=typeof Microsoft.Live.Channels.Mux._channels[a])Microsoft.Live.Channels.Mux._channels[a]._recv_chunk(a,c)}};Microsoft.Live.Channels.Mux._Receiver=function(g){var b=this,d,e,c,a=[];b.recver=null;var f=g.split("#");d=f[1].split("/")[0];e=f[0];a.push(null);b._set_chunkid=function(a){c=a;c++};b._recv_chunk=function(e,f,g){if(c!=f)return;c++;var d=a[a.length-1];if(null==d)d="";d+=g;a[a.length-1]=d;if("L"==e)a.push(null);b._recv()};b._recv_abort=function(b){if(c!=b)return;a=[]};b._recv=function(){if(null==b.recver)return;var c;for(var f=0;a.length-1>f;f++){c=Microsoft.Live.Channels.Mux._decode(a[f]);b.recver(d,e,c)}c=a[a.length-1];a=[c]}};Microsoft.Live.Channels.Mux.register_recver=function(e,a,b,d){Microsoft.Live.Channels.Mux._useOldChannel=d?null:true;var c=null;if(b)c=function(c,d,e){var a=Microsoft.Live.Channels.Internal.decodeArgs(e);if(Microsoft.Live.Channels.Mux._useOldChannel){a.unshift(d);a.unshift(c);b.apply(this,a)}else b.apply(this,a)};a=a+"#"+e+"/";if("undefined"==typeof Microsoft.Live.Channels.Mux._receivers[a])Microsoft.Live.Channels.Mux._receivers[a]=new Microsoft.Live.Channels.Mux._Receiver(a);Microsoft.Live.Channels.Mux._receivers[a].recver=c;Microsoft.Live.Channels.Mux._receivers[a]._recv()};Microsoft.Live.Channels.Mux.init_iframes=function(){var a=document.getElementById("Microsoft.Live.Channels.Mux.Sframe");if(!a){a=document.createElement("iframe");a.id="Microsoft.Live.Channels.Mux.Sframe";a.style.width="0px";a.style.height="0px";a.style.visibility="hidden";document.body.appendChild(a)}var b=document.getElementById("Microsoft.Live.Channels.Mux.Rframe");if(!b){var b=document.createElement("iframe");b.id="Microsoft.Live.Channels.Mux.Rframe";b.style.width="0px";b.style.height="0px";b.style.visibility="hidden";document.body.appendChild(b)}};Microsoft.Live.Channels.Mux.register_iframe=function(){Microsoft.Live.Channels.Mux._useOldChannel=true;Microsoft.Live.Channels.Mux.init_iframes()};Microsoft.Live.Channels.Internal.getDomainFromURL=function(b){var a=null;if(b){a=b.split("/")[2];a=a.substr(a.indexOf("@")+1);if(a.indexOf(":")>0)a=a.substr(0,a.indexOf(":"))}return a};Microsoft.Live.Channels.Internal.encodeArgs=function(c){var b=[],a;for(a=0;a<c.length;a++){b[a]=encodeURIComponent(c[a]);b[a]=b[a].replace(new RegExp("'","g"),"%27")}return b.join("&")};Microsoft.Live.Channels.Internal.decodeArgs=function(c){var a=c.split("&");for(var b=0;b<a.length;b++){a[b]=a[b].replace(new RegExp("%27","g"),"'");a[b]=decodeURIComponent(a[b])}return a};Microsoft.Live.Channels.Channel=function(u,v,s){var b=this,m=4095;if(0<=navigator.userAgent.indexOf("Gecko/"))m=42263;var t="0123456789ABCDEF0123456789ABCDEF/C01234567/".length,h=1000,e=-1,w=v+"#"+u+"/",f,n=s,l,g=[],d,c,a=null,i=new OneShotSemaphore;Microsoft.Live.Channels.Mux._getUniqueId(function(a){e=a;Microsoft.Live.Channels.Mux._channels[a]=b;i.signal()});var j=function(){Microsoft.Live.Channels.Mux._send_chunk("S",c);a=window.setTimeout(o,h)},o=function(){Microsoft.Live.Channels.Mux._send_chunk("S",c);a=window.setTimeout(p,h*2)},p=function(){Microsoft.Live.Channels.Mux._send_chunk("S",c);a=window.setTimeout(q,h*3)},q=function(){Microsoft.Live.Channels.Mux._send_chunk("S",c);a=window.setTimeout(r,h*4)},r=function(){Microsoft.Live.Channels.Mux._clean_iframes("S");a=window.setTimeout(j,parseInt(h)/2)},k=function(){if(0==g.length)return;d++;var a=g[0],h=Math.min(l,a.length),b=a.substr(0,h);a=a.substr(h);if(0<a.length){g[0]=a;c=f+e+"/C"+d.toString(16)+"/"+b}else{g.shift();c=f+e+"/L"+d.toString(16)+"/"+b}j()};b.connect=function(a,b){i.waitFor(function(){f=b+"#"+a+"/";l=m-(f.length+t);d=0;var g=Microsoft.Live.Channels.Mux._encode(w);c=f+e+"/S"+d.toString(16)+"/"+g;j()})};b.send=function(){var b=Microsoft.Live.Channels.Internal.encodeArgs(arguments);i.waitFor(function(){b=Microsoft.Live.Channels.Mux._encode(b);g.push(b);if(null==a)k()})};b.abort=function(){clearTimeout(a);a=null;g=[];c=f+e+"/X"+d.toString(16);j()};b._set_chanid=function(a){e=a;i.signal()};b._recv_chunk=function(c,b){if(e!=c||d!=b)return;clearTimeout(a);a=null;k()};b._validate_sender=function(c){var a=b.getCallerDomain();return c&&a&&c==a};b.getCallerDomain=function(){if(n)return n;else return Microsoft.Live.Channels.Internal.getDomainFromURL(f)}};Microsoft.Live.Channels.Internal.testFlashVersion=function(h,m){if(typeof Microsoft.Live.Channels.useFlashTransport!="undefined"&&!Microsoft.Live.Channels.useFlashTransport)return false;var b=0,d=0,k=navigator.appVersion.indexOf("MSIE")!=-1?true:false,i=navigator.appVersion.toLowerCase().indexOf("win")!=-1?true:false,g=navigator.userAgent.indexOf("Opera")!=-1?true:false;if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]){var e;if(navigator.plugins["Shockwave Flash 2.0"])e=navigator.plugins["Shockwave Flash 2.0"].description;else e=navigator.plugins["Shockwave Flash"].description;var l=e.split(" "),j=l[2].split(".");b=j[0];d=j[1]}}else if(k&&i&&!g){var a,f,p,c;try{f=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");a=f.GetVariable("$version")}catch(q){}if(!a)try{f=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");a="WIN 6,0,21,0"}catch(q){}if(!a)return false;if(k&&i&&!g){var o=a.split(" "),n=o[1];c=n.split(",")}else c=a.split(".");b=c[0];d=c[1]}if(b==0)return false;if(b>parseFloat(h))return true;else if(b==parseFloat(h))if(d>=parseFloat(m))return true;return false};Microsoft.Live.Channels.Internal.getFlashControl=function(a){return document.getElementById(a)||document[a]};Microsoft.Live.Channels.Internal.trace=function(c){var a=document.getElementById("trace");if(a){var b=document.createElement("p");b.innerText=c;a.appendChild(b)}};Microsoft.Live.Channels.Internal.error=function(b){var a=Microsoft.Live.Channels.Internal.getFlashControl(p_id);if(a&&a.channel)a.channel.doError(b)};Microsoft.Live.Channels.FlashChannel=function(u,n,F){var d=this,a="",s=navigator.appVersion.indexOf("MSIE")!=-1?true:false,A=navigator.appVersion.toLowerCase().indexOf("win")!=-1?true:false,y=navigator.userAgent.indexOf("Opera")!=-1?true:false,G=function(c,b){var a=document.createElement("param");a.setAttribute("name",c);a.setAttribute("value",b);return a},x=function(){a=Microsoft.Live.Platform.uniqueID("IFM");var e="domain="+document.location.hostname,c=Microsoft.Live.Channels.secureScriptURL+"flashchannel.swf",b;b=document.createElement("div");b.id=a+"div";b.name=b.id;b.channel=d;flashHTML="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width = '1' height = '1' id = '"+a+"' type = 'application/x-shockwave-flash' data = '"+c+"'>"+"<param name= 'movie' value = '"+c+"'></param>"+"<param name='allowScriptAccess' value='always'></param> "+"<param name = 'FlashVars' value = '"+e+"'></param>"+"<embed play='true' menu='false' swLiveConnect='true' allowScriptAccess='always' type = 'application/x-shockwave-flash' FlashVars = '"+e+"' src='"+c+"' width = '1' height='1' name='"+a+"'></embed>"+"</object>";if(s)flashHTML+="<SCRIPT event='FSCommand(command,args)' for ='"+a+"' >"+a+"_DoFSCommand(command,args)</SCRIPT>";b.innerHTML=flashHTML;document.body.appendChild(b);window[a+"_DoFSCommand"]=function(d,c){var b=Microsoft.Live.Channels.Internal.getFlashControl(a+"div");switch(d){case "ready":if(b)D(b);break;case "listening":if(b)B(c=="true");break;case "dispatch":if(b)C(c);break;case "debug":Microsoft.Live.Channels.Internal.trace(c);break;case "error":if(b)w(c);break;case "setdomain":if(b)E(c)}};return b};if(!s||!A||y)x();var r=null,t=false,b=null,c=null,e=u,m=false,l=false,j=0,h=[],i="",p=38*1024,v=F,k=new OneShotSemaphore,z=new OneShotSemaphore;Microsoft.Live.Channels.Mux._getUniqueId(function(a){b=a;if(r)k.signal()});k.waitFor(function(){e=u;g("_Microsoft.Live.Channels.IFMConnect."+n,e);z.waitFor(function(){if(t){b="_Microsoft.Live.Channels.IFMConnect."+n;m=true;l=true}else{g(b,e);g(b+"ack",e);f("_Microsoft.Live.Channels.IFMConnect."+n,"#"+b);c="-"+b}})});d.send=function(){var a=Microsoft.Live.Channels.Internal.encodeArgs(arguments);h.push(a);if(!l&&c)k.waitFor(function(){if(!l)o()})};d.getCallerDomain=function(){return v};var f=function(c,d){var b=document.embeds[a]||document.getElementById(a);if(b)b.SetVariable("ifm.SendParams","session="+encodeURIComponent(c)+"&arg="+encodeURIComponent(d))},g=function(d,c){var b=document.embeds[a]||document.getElementById(a);if(b)b.SetVariable("ifm.ListenParams","session="+encodeURIComponent(d)+"&arg="+encodeURIComponent(c))},q=function(c){var b=document.embeds[a]||document.getElementById(a);if(b)b.SetVariable("ifm.CloseParams","session="+encodeURIComponent(c))},o=function(){if(0==h.length){l=false;return}var a=h[0];j++;if(a.length>p){var b=a.substr(0,p);h[0]=a.substr(p);f(c,"C"+j+":"+b)}else{h.shift();f(c,"L"+j+":"+a)}},D=function(a){if(!r){r=a;if(b)k.signal()}},B=function(a){t=a;z.signal()},C=function(a){switch(a.charAt(0)){case "#":if(m){m=false;q(b);c=a.substr(1);b="-"+c;g(b,e);g(b+"ack",e);f(c,"AA");o()}break;case "C":if(d.onReceiveMessage){var h=a.indexOf(":");if(h>0){var k=a.substr(1,h-1);i+=a.substr(h+1);f(c+"ack","A"+k)}}break;case "L":if(d.onReceiveMessage){var h=a.indexOf(":");if(h>0){var k=a.substr(1,h-1);i+=a.substr(h+1);var l=Microsoft.Live.Channels.Internal.decodeArgs(i);i="";f(c+"ack","A"+k);d.onReceiveMessage.apply(d,l)}}break;case "A":if(parseInt(a.substr(1))==j||a.length==2&&a.charAt(1)=="A")o()}},E=function(a){if(v!=a){d.send=function(){};q(b);q(c);w("The domain used for this connection is incorrect.")}},w=function(a){if(d.onError)d.onError(a)};if(s&&A&&!y)x()};registerNamespace("Microsoft.Live.Contacts.Write");Microsoft.Live.Contacts.Write.baseURL=window.location.protocol+"//controls.services.msn.com/scripts/contacts/v0.3/";Microsoft.Live.Contacts.Write.scriptURL=Microsoft.Live.Contacts.Write.baseURL;Microsoft.Live.Contacts.Write=function(o,n,l){var m=this,b=[],c=0,e={"firstname":"firstName","middlename":"middleName","lastname":"lastName","nickname":"AB.NickName","emailpersonal":"ContactEmailPersonal","emailbusiness":"ContactEmailBusiness","emailother":"ContactEmailOther","phonepersonal":"ContactPhonePersonal","phonebusiness":"ContactPhoneBusiness","phonemobile":"ContactPhoneMobile","phonepager":"ContactPhonePager","phonefax":"ContactPhoneFax","phoneother":"ContactPhoneOther","personalstreet":"ContactLocationPersonal.street","personalcity":"ContactLocationPersonal.city","personalstate":"ContactLocationPersonal.state","personalcountry":"ContactLocationPersonal.country","personalpostalcode":"ContactLocationPersonal.postalCode","businessname":"ContactLocationBusiness.name","businessstreet":"ContactLocationBusiness.street","businesscity":"ContactLocationBusiness.city","businessstate":"ContactLocationBusiness.state","businesscountry":"ContactLocationBusiness.country","businesspostalcode":"ContactLocationBusiness.postalCode","websitepersonal":"ContactWebSitePersonal","websitebusiness":"ContactWebSiteBusiness"},h={};for(var f in e)h[f]=f;var a=null,d=false;function j(c,g,a){var f="",d="";if(a instanceof Array)throw new Microsoft.Live.ArgumentException(L_74_T.replace("%1","fieldMap"));if(!a)a=h;for(var b in a)if(e[b]){if(c[a[b]]&&"function"!=typeof c[a[b]]){f+=d+encodeURIComponent(e[b])+"="+encodeURIComponent(c[a[b]]);d=g}}else throw new Microsoft.Live.ArgumentException(L_73_T.replace("%1",b));return f}function g(a){if(a>30)throw new Microsoft.Live.InvalidOperationException(L_75_T);if(a+c>1000)throw new Microsoft.Live.InvalidOperationException(L_76_T)}function k(f,a,h){if("undefined"===typeof a||a===null)throw new Microsoft.Live.ArgumentException(L_72_T.replace("%1","contacts"));if(!(a instanceof Array))throw new Microsoft.Live.ArgumentException(L_74_T.replace("%1","contacts"));g(a.length);var e=[encodeURIComponent(f)];for(var d=0;d<a.length;d++)e.push(j(a[d],"&",h));b.push(e.join(","));c+=a.length}this.callBack=null;this.createContacts=function(a,b){k("ADDCONTACTS",a,b)};this.deleteContacts=function(a){if("undefined"===typeof a||a===null)throw new Microsoft.Live.ArgumentException(L_72_T.replace("%1","contacts"));if(!(a instanceof Array))throw new Microsoft.Live.ArgumentException(L_74_T.replace("%1","contacts"));g(a.length);var d=encodeURIComponent("DELETECONTACTS");for(var e in a)d+=","+encodeURIComponent(a[e]);b.push(d);c+=a.length};this.commitContacts=function(c){if(d)throw new Microsoft.Live.InvalidOperationException(L_77_T);if("undefined"===typeof c||c===null)throw new Microsoft.Live.ArgumentException(L_72_T.replace("%1","resultsCallback"));if(!("function"===typeof c))throw new Microsoft.Live.ArgumentException(L_74_T.replace("%1","resultsCallback"));if("undefined"===typeof a||a===null){a=document.getElementById(l);if(a&&a.channel)a=a.channel}var e=encodeURIComponent("COMMIT")+"&&&"+b.join("&&");m.callBack=function(a){d=false;c(a)};a.send(e);i();d=true};var i=function(){b=null;b=[];c=0};this.abortContacts=function(){i()}};registerNamespace("Microsoft.Live.Intl");Microsoft.Live.Intl.baseURL=Microsoft.Live.Platform.expandURL(Microsoft.Live.Platform.baseURL,"../../intl/v0.3/");Microsoft.Live.Intl.scriptURL=Microsoft.Live.Platform.expandURL(Microsoft.Live.Platform.scriptURL,"../../intl/v0.3/");Microsoft.Live.Intl.computeMarket=function(c){var a=c.appPref||c.userPref||"en-us",d=Microsoft.Live.Intl.getCountry(a);if(!d||d.length==0){var b=Microsoft.Live.Intl.getLanguage(a);switch(b){case "en":a="en-us";break;case "ja":a="ja-jp";break;case "jp":a="ja-jp";break;case "ko":a="ko-kr";break;case "zh":a="zh-cn";break;default:a=b+"-"+b}}return a};Microsoft.Live.Intl.getLanguage=function(a){return a==null?null:a.substr(0,2)};Microsoft.Live.Intl.getCountry=function(a){return a==null?null:a.substr(3,2)};Microsoft.Live.Intl.getMarket=function(a,b){return a.substr(0,2)+"-"+b.substr(0,2)};Microsoft.Live.Intl.getLCID=function(b){var a={"en":1033,"en-us":1033,"fr":1036,"fr-fr":1036,"fr-ca":3084,"ja":1041,"jp":1041,"ja-jp":1041,"de":1031,"de-de":1031,"es":1034,"es-es":1034,"it":1040,"it-it":1040,"ko":1042,"ko-kr":1042,"nl":1043,"nl-nl":1043,"pt-br":1046,"sv":1053,"sv-se":1053,"zh-cn":2052};if(a[b])return a[b];else if(a[Microsoft.Live.Intl.getLanguage(b)])return a[Microsoft.Live.Intl.getLanguage(b)];else return a["en-us"]};Microsoft.Live.Intl.sanitizeMarket=function(a){if(!a||a.length==0)return "en-us";if(a.length<=2)return a;if(a.length>5||a.charAt(2)!="-")return "en-us";return a};Microsoft.Live.Intl.loadStrings=function(d){var c=d.market||"en-us",g=d.baseURL||"",f=d.filename||"strings.js",e=d.onCompletion||null,h=d.onError||null;c=Microsoft.Live.Intl.sanitizeMarket(c);var b=new XMLHttpRequest;try{b.open("GET",Microsoft.Live.Platform.expandURL(g,c+"/"+f),false);b.send("");if(b.status==200){var a=document.createElement("script");if(typeof a.canHaveChildren=="undefined"||a.canHaveChildren)a.appendChild(document.createTextNode(b.responseText));else a.text=b.responseText;var i=document.getElementsByTagName("head")[0];if(i)i.appendChild(a);else document.body.appendChild(a);if(e)e()}else if(h)h("ERROR")}catch(j){Microsoft.Live.Platform.load([Microsoft.Live.Platform.expandURL(g,Microsoft.Live.Intl.getLanguage(c)+"/"+f),Microsoft.Live.Platform.expandURL(g,c+"/"+f)],e)}};