var GalleryWidget={};GalleryWidget.Global=function(){};GalleryWidget.Global.parseUTCDate=function(a){var d=parseInt(a.substring(0,4),10),c=parseInt(a.substring(5,7),10)-1,e=parseInt(a.substring(8,10),10),b=parseInt(a.substring(11,13),10),f=parseInt(a.substring(14,16),10),g=parseInt(a.substring(17,19),10);return new Date(Date.UTC(d,c,e,b,f,g))};GalleryWidget.Global.formatDateString=function(c,b){var a=GalleryWidget.Global.parseUTCDate(c);return GalleryWidget.Global.format(b,a.getMonth()+1,a.getDate(),a.getFullYear())};GalleryWidget.Global.checkNumber=function(a){return GalleryWidget.Global.checkDefined(a)&&!isNaN(a)};GalleryWidget.Global.checkDefined=function(a){return a!=undefined};GalleryWidget.Global.getElementStyle=function(a){if(a.currentStyle)return a.currentStyle;else if(document.defaultView&&document.defaultView.getComputedStyle)return document.defaultView.getComputedStyle(a,"");else return a.style};GalleryWidget.Global.getElementPadding=function(i){var a=GalleryWidget.Global.getElementStyle(i),b=a.padding?parseInt(a.padding):0,d=a.paddingLeft?parseInt(a.paddingLeft):b,e=a.paddingRight?parseInt(a.paddingRight):b,f=a.paddingTop?parseInt(a.paddingTop):b,c=a.paddingBottom?parseInt(a.paddingBottom):b,g=d+e,h=f+c;return {lPadding:d,rPadding:e,tPadding:f,bPadding:c,hPadding:g,vPadding:h}};GalleryWidget.Global.getElementWidth=function(a){var b=GalleryWidget.Global.getElementStyle(a);return parseInt(b.width)+GalleryWidget.Global.getElementPadding(a).hPadding};GalleryWidget.Global.getElementHeight=function(a){var b=GalleryWidget.Global.getElementStyle(a);return parseInt(b.height)+GalleryWidget.Global.getElementPadding(a).vPadding};GalleryWidget.Global.getElementInnerWidth=function(a){return Math.max(0,a.offsetWidth-GalleryWidget.Global.getElementPadding(a).hPadding)};GalleryWidget.Global.getElementInnerHeight=function(a){return Math.max(0,a.offsetHeight+GalleryWidget.Global.getElementPadding(a).vPadding)};GalleryWidget.Global.format=function(b){for(var a=1;a<arguments.length;a++)b=b.split("{"+(a-1)+"}").join(arguments[a]);return b};GalleryWidget.Global.extractNumber=function(d){var a,c="";for(var b=0;b<d.length;b++){a=d.charAt(b);if(!isNaN(a))c+=a}return parseInt(c)};GalleryWidget.Global.fixAbsoluteWidth=function(a){try{var c=a,b=0;do{c=c.parentNode;b=c.clientWidth}while(b==0);b=b-parseInt(a.currentStyle.paddingLeft)-parseInt(a.currentStyle.paddingRight);if(a.currentStyle.marginLeft!="auto")b-=parseInt(a.currentStyle.marginLeft);if(a.currentStyle.marginRight!="auto")b-=parseInt(a.currentStyle.marginRight);if(a.currentStyle.borderLeftStyle!="none")b-=parseInt(a.currentStyle.borderLeftWidth);if(a.currentStyle.borderRightStyle!="none")b-=parseInt(a.currentStyle.borderRightWidth);a.style.width=b-parseInt(a.currentStyle.left)-parseInt(a.currentStyle.right)+"px"}catch(d){}};GalleryWidget.Global.fixAbsoluteHeight=function(a){try{var c=a,b=0;do{c=c.parentNode;b=c.clientHeight}while(b==0);b=b-parseInt(a.currentStyle.paddingTop)-parseInt(a.currentStyle.paddingBottom);if(a.currentStyle.marginTop!="auto")b-=parseInt(a.currentStyle.marginTop);if(a.currentStyle.marginBottom!="auto")b-=parseInt(a.currentStyle.marginBottom);if(a.currentStyle.borderTopStyle!="none")b-=parseInt(a.currentStyle.borderTopWidth);if(a.currentStyle.borderBottomStyle!="none")b-=parseInt(a.currentStyle.borderBottomWidth);a.style.height=b-parseInt(a.currentStyle.top)-parseInt(a.currentStyle.bottom)+"px"}catch(d){}};GalleryWidget.Global.doAbsoluteFix=function(a,c){if(a.currentStyle&&a.currentStyle.position=="absolute"){if(a.currentStyle.left!="auto"&&a.currentStyle.right!="auto"&&a.currentStyle.width=="auto")GalleryWidget.Global.fixAbsoluteWidth(a);if(a.currentStyle.top!="auto"&&a.currentStyle.bottom!="auto"&&a.currentStyle.height=="auto")GalleryWidget.Global.fixAbsoluteHeight(a)}if(c)for(var b=0;b<a.childNodes.length;b++)GalleryWidget.Global.doAbsoluteFix(a.childNodes[b],c)};GalleryWidget.Global.isIE6OrLess=function(){var a=navigator.userAgent.toLowerCase();if(a.indexOf("msie 6.0")!=-1)return true;return false};GalleryWidget.Global.isIE=function(){var a=navigator.userAgent.toLowerCase();if(a.indexOf("msie")!=-1)return true;return false};GalleryWidget.Global.hashCodeFletcher=function(e){var c=e.length,a=65535,b=65535,f=0;while(c){var d=c>360?360:c;c-=d;do{a+=e.charCodeAt(f++);b+=a}while(--d);a=(a&65535)+(a>>16);b=(b&65535)+(b>>16)}a=(a&65535)+(a>>16);b=(b&65535)+(b>>16);return b<<16|a};GalleryWidget.Global.uriConcat=function(a,b){if(a.charAt(a.length-1)!="/")a+="/";return a+b};GalleryWidget.widgetInstances=new Array;GalleryWidget.AddInstance=function(b,a){GalleryWidget.widgetInstances.push({id:b,obj:a})};GalleryWidget.GetInstance=function(b){for(var a=0;a<GalleryWidget.widgetInstances.length;a++)if(GalleryWidget.widgetInstances[a].id==b)return GalleryWidget.widgetInstances[a].obj;return null};GalleryWidget.Instances=function(){var b=new Array;for(var a=0;a<GalleryWidget.widgetInstances.length;a++)b.push(GalleryWidget.widgetInstances[a].obj);return b};Function.prototype.bind=function(c){var a=this,b=function(){return a.apply(c,arguments)};return b};String.prototype.trim=function(){return this.replace(/^\s*/,"").replace(/\s*$/,"")};GalleryWidget.EventBroadcaster=function(){};GalleryWidget.EventBroadcaster.prototype.listeners=function(){if(!this._listeners)this._listeners=new Array;return this._listeners};GalleryWidget.EventBroadcaster.prototype.addListener=function(a){if(null!=a){for(var b=0;b<this.listeners().length;b++)if(this.listeners()[b]==a)return;this.listeners().push(a)}};GalleryWidget.EventBroadcaster.prototype.removeListener=function(b){for(var a=0;a<this.listeners().length;a++)if(this.listeners()[a]==b){this.listeners().splice(a,1);return}};GalleryWidget.EventBroadcaster.prototype.removeAllListeners=function(){this.listeners()=new Array};GalleryWidget.EventBroadcaster.prototype.broadcastEvent=function(b){var c=new Array;for(var a=1;a<arguments.length;a++)c.push(arguments[a]);for(a=0;a<this.listeners().length;a++)if(this.listeners()[a][b])this.listeners()[a][b].apply(this.listeners()[a],c)};GalleryWidget.Omniture=function(){};GalleryWidget.Omniture.bridge=null;GalleryWidget.Omniture.isReady=false;GalleryWidget.Omniture.queue=new Array;GalleryWidget.Omniture.ready=function(){GalleryWidget.Omniture.isReady=true;for(var a=0;a<GalleryWidget.Omniture.queue.length;a++)GalleryWidget.Omniture.send(GalleryWidget.Omniture.queue[a]);GalleryWidget.Omniture.queue=new Array};GalleryWidget.Omniture.create=function(b,e){if(null==GalleryWidget.Omniture.bridge){var a=b.id+"_OmnitureBridge",c=document.createElement("DIV");c.setAttribute("id",a);b.appendChild(c);var d=GalleryWidget.Global.uriConcat(e.getVal("FlashResourceLocation"),"omniturebridge.swf");GalleryWidget.PreviewManager.Flash.Build(d,"8",1,1,a,{wmode:"transparent",allowScriptAccess:"always",allowFullScreen:"true",base:d});GalleryWidget.Omniture.bridge=document.getElementById(a+"obj")}};GalleryWidget.Omniture.send=function(a){if(GalleryWidget.Omniture.isReady){GalleryWidget.Omniture.bridge.setProps(a);GalleryWidget.Omniture.bridge.send()}else GalleryWidget.Omniture.queue.push(a)};GalleryWidget.Omniture.pageLoad=function(){};GalleryWidget.Omniture.videoClick=function(c,b){var a=new Object;a.account="msnportalvideov4";a.prop1="MSNvideo^v4";a.prop2=c.getVal("Mkt");a.prop3="MSNvideo^gallerywidget";a.prop4=encodeURIComponent(b.source);a.prop5="onclick:gallerywidget";a.prop6=c.getVal("From")+"^"+c.getVal("Fg");a.prop7="";a.prop11=b.csid;a.prop17=encodeURIComponent(b.title);a.prop32=b.uuid;a.prop41="flash";a.pageName=b.provider+"^"+b.title;a.channel="MSNvideo^gallerywidget";a.ns="msnportal";a.server=window.location.hostname;GalleryWidget.Omniture.send(a)};GalleryWidget.PreviewManager=function(){};GalleryWidget.PreviewManager.PLAY_TIMEOUT=200;GalleryWidget.PreviewManager.STOP_TIMEOUT=2000;GalleryWidget.PreviewManager.prototype.onPreviewClick=function(b){var a=document.getElementById(b);if(a&&a.control&&a.control.onPlayVideo)a.control.onPlayVideo()};GalleryWidget.PreviewManager.prototype.playPreview=function(b,g,f,d,c,e){var a;if(b.childNodes.length>0&&b.childNodes[0].nodeName=="OBJECT")a=b.childNodes[0];else{a=this.createPreview(b,g,f,d,c);a.style.cursor="pointer"}clearTimeout(a.playTimeout);clearTimeout(a.stopTimeout);a.url=e;a.playTimeout=setTimeout(this.playInternal.bind(a),GalleryWidget.PreviewManager.PLAY_TIMEOUT);return a};GalleryWidget.PreviewManager.prototype.stopPreview=function(a){if(!a)return;clearTimeout(a.playTimeout);if(a.stopVideo)a.stopVideo();a.stopTimeout=setTimeout(this.stopInternal.bind(a),GalleryWidget.PreviewManager.STOP_TIMEOUT)};GalleryWidget.PreviewManager.prototype.cleanObject=function(a){try{a.style.display="none";for(var b in a)if(typeof a[b]=="function")a[b]=null}catch(c){}};GalleryWidget.PreviewManager.prototype.playInternal=function(){if(this.playVideo){this.playVideo(this.url);this.marginLeft="0px"}};GalleryWidget.PreviewManager.prototype.stopInternal=function(){try{this.parentNode.innerHTML="";GalleryWidget.PreviewManager.Instance.cleanObject(this)}catch(a){}};GalleryWidget.PreviewManager.prototype.createPreview=function(a,e,d,b,c){GalleryWidget.PreviewManager.Flash.Build(b,"8",e,d,a.id,{wmode:"transparent",allowScriptAccess:"always",allowFullScreen:"true",base:b,flashvars:c});return a.childNodes[0]};GalleryWidget.PreviewManager.Flash=new function(){var me=this,flv=null,d=document,w=window;function E(a){return d.getElementById(a)}function flVer(){if(flv===null){flv=0;var i,f=null,p=w.navigator.plugins;if(p&&p.length){f=p["Shockwave Flash"]||p["Shockwave Flash 2.0"];if(f&&(i=f.description))flv=parseInt(i.substring(i.indexOf(".")-2))}else if(w.ActiveXObject)for(i=15;i>2&&!f;--i){eval("try{f=new ActiveXObject('ShockwaveFlash.ShockwaveFlash.'+i);}catch(e){}");if(f)flv=i}}return flv}this.Version=function(){return flVer()};this.Build=function(k,f,m,l,c,b){var j=5;if(f){var a=f.lastIndexOf(" ");if(a>0)a=parseInt(f.substring(a));else a=parseInt(f);j=isNaN(a)?j:a}if(j<=flVer()){var g={movie:k,quality:"high"},i='<object id="'+c+'obj" type="application/x-shockwave-flash" width="'+m+'" height="'+l+'" data="'+k+'">';if(b){for(var e in g)if(!b[e])b[e]=g[e]}else b=g;for(a in b)if(b[a])i+='<param name="'+a+'" value="'+b[a]+'"/>';i+="</object>";var h=c?d.getElementById(c):null;window[c+"obj"]=new Object;if(h)h.innerHTML=i;h=null;window[c+"obj"]=document.getElementById(c+"obj")}};return this};GalleryWidget.PreviewManager.Instance=new GalleryWidget.PreviewManager;GalleryWidget.TweenManager=function(){this.tweens=new Array;this.intervalId=-1;this.frameRate=100};GalleryWidget.TweenManager.prototype.stopAll=function(){for(var a=0;a<this.tweens.length;a++)this.tweens[a].stop();this.tweens=new Array};GalleryWidget.TweenManager.prototype.addTween=function(a){this.tweens.push(a);this.start()};GalleryWidget.TweenManager.prototype.removeTween=function(b){for(var a=0;a<this.tweens.length;a++)if(this.tweens[a]==b){this.tweens.splice(a,1);this.stop();return true}return false};GalleryWidget.TweenManager.prototype.start=function(){if(this.tweens.length>0&&this.intervalId==-1)this.intervalId=setInterval(this.onFrame.bind(this),1000/this.frameRate)};GalleryWidget.TweenManager.prototype.stop=function(){if(this.tweens.length==0&&this.intervalId!=-1){clearInterval(this.intervalId);this.intervalId=-1}};GalleryWidget.TweenManager.prototype.onFrame=function(){var b=new Array;for(var a=0;a<this.tweens.length;a++)if(!this.tweens[a].onFrame())b.push(this.tweens[a]);for(a=0;a<b.length;a++)this.removeTween(b[a])};GalleryWidget.TweenManager.Instance=new GalleryWidget.TweenManager;GalleryWidget.Tween=function(f,a,b,c,e,d){this.frameRate=100;this.obj=f;this.param=a instanceof Array?a:[a];this.from=b instanceof Array?b:[b];this.to=c instanceof Array?c:[c];this.current=this.from;this.time=e;this.easing=d?d:GalleryWidget.Tween.easeInOut;this.startTime=new Date;this.intervalId};GalleryWidget.Tween.EVENT_TWEEN_COMPLETE="tweenComplete";GalleryWidget.Tween.prototype=new GalleryWidget.EventBroadcaster;GalleryWidget.Tween.create=function(g,d,e,h,f,c,b){var a=new GalleryWidget.Tween(g,d,e,h,f,c);a.addListener(b);a.start();GalleryWidget.TweenManager.Instance.addTween(a);return a};GalleryWidget.Tween.prototype.start=function(){this.setParam(this.from)};GalleryWidget.Tween.prototype.stop=function(){this.setParam(this.to);this.broadcastEvent(GalleryWidget.Tween.EVENT_TWEEN_COMPLETE,this)};GalleryWidget.Tween.easeNone=function(d,a,b,c){return b*d/c+a};GalleryWidget.Tween.easeIn=function(a,b,c,d){return c*(a/=d)*a+b};GalleryWidget.Tween.easeOut=function(a,b,c,d){return -c*(a/=d)*(a-2)+b};GalleryWidget.Tween.easeInOut=function(a,b,c,d){if((a/=d/2)<1)return c/2*a*a+b;return -c/2*(--a*(a-2)-1)+b};GalleryWidget.Tween.prototype.onFrame=function(){if(this.timeEllapsed()/1000<this.time){var b=new Array;for(var a=0;a<this.param.length;a++){var c=this.to[a]-this.from[a];b.push(this.easing(this.timeEllapsed(),this.from[a],c,this.time*1000))}this.setParam(b)}else{this.stop();return false}return true};GalleryWidget.Tween.prototype.setParam=function(b){var a=this;if(this.obj instanceof Array)for(var c=0;c<this.obj.length;c++)d(this.obj[c]);else d(this.obj);function d(f){if(a.param instanceof Array)for(var c=0;c<a.param.length;c++){var d=a.param[c],e=b[c];if(d instanceof Array){d=a.param[c][0];e=GalleryWidget.Global.format(a.param[c][1],b[c])}f[d]=e}else{d=a.param;e=b;if(d instanceof Array){d=a.param[0];e=GalleryWidget.Global.format(a.param[1],b)}f[d]=e}}};GalleryWidget.Tween.prototype.timeEllapsed=function(){return new Date-this.startTime};GalleryWidget.Settings=function(){this.DISPLAY_VISIBLE="true";this.DISPLAY_NONE="false";this.reqId=0;this.listeners=new Array;this.pendingRequests=new Array;this.genericSettings=Object();this.viewSettings=Object()};GalleryWidget.Settings.RESOURCE_PREFIX="IDS_GW_";GalleryWidget.Settings.DISPLAY_VISIBLE="true";GalleryWidget.Settings.DISPLAY_NONE="false";GalleryWidget.Settings.XML_REQ_TYPE="xml";GalleryWidget.Settings.JSON_REQ_TYPE="json";GalleryWidget.Settings.OBJ_REQ_TYPE="obj";GalleryWidget.Settings.EVENT_LOAD_COMPLETE="onSettingsLoadComplete";GalleryWidget.Settings.EVENT_SETTINGS_INITIALIZED="onAllSettingsInitialized";GalleryWidget.Settings.PARAM_TYPE_ARRAY="array";GalleryWidget.Settings.PARAM_TYPE_FLOAT="float";GalleryWidget.Settings.PARAM_TYPE_INT="int";GalleryWidget.Settings.PARAM_TYPE_BOOLEAN="boolean";GalleryWidget.Settings.PARAM_TYPE_STRING="string";GalleryWidget.Settings.LOC_TOP_LEFT="top_left";GalleryWidget.Settings.LOC_TOP_CENTER="top_center";GalleryWidget.Settings.LOC_TOP_RIGHT="top_right";GalleryWidget.Settings.LOC_BOTTOM_LEFT="bottom_left";GalleryWidget.Settings.LOC_BOTTOM_CENTER="bottom_center";GalleryWidget.Settings.LOC_BOTTOM_RIGHT="bottom_right";GalleryWidget.Settings.LOC_TOP="top";GalleryWidget.Settings.LOC_RIGHT="right";GalleryWidget.Settings.LOC_BOTTOM="bottom";GalleryWidget.Settings.LOC_LEFT="left";GalleryWidget.Settings.LOC_HIDDEN="hidden";GalleryWidget.Settings.AUTO_PLAY_NONE="false";GalleryWidget.Settings.AUTO_PLAY_START="true";GalleryWidget.Settings.AUTO_PLAY_CONTINUOUS="continuous";GalleryWidget.Settings.prototype.loadFromXml=function(c){var a=null,d=this;if(window.XMLHttpRequest)a=new XMLHttpRequest;else if(window.ActiveXObject)a=new ActiveXObject("Microsoft.XMLHTTP");var b=this.reqId++;if(a){this.addRequest(b,c,GalleryWidget.Settings.XML_REQ_TYPE);a.id=b;a.settings=this;a.open("GET",c,true);a.onreadystatechange=function(){d.onXmlLoad(a)};a.send(null)}else this.broadcastEvent(GalleryWidget.Settings.EVENT_LOAD_COMPLETE,b,false);return b};GalleryWidget.Settings.prototype.loadFromObject=function(b){for(var a in b)if(a=="views")for(var c in b[a])for(var d in b[a][c])this.setVal(d,b[a][c][d],"",c);else if(a=="resources")for(var e in b[a])this.setVal(e,b[a][e],"");else this.setVal(a,b[a],"")};GalleryWidget.Settings.prototype.toString=function(){var b="[";for(var a in this.genericSettings)b+=a+": "+this.genericSettings[a]+", ";for(var c in this.viewSettings){b+=c+"[";for(a in this.viewSettings[c])b+=a+": "+this.viewSettings[c][a]+", ";b+="], "}b+="]";return b};GalleryWidget.Settings.prototype.addListener=function(a){this.listeners.push(a)};GalleryWidget.Settings.prototype.removeListener=function(b){for(var a=0;a<this.listeners.length;a++)if(this.listeners[a]==b)this.listeners.splice(a,1)};GalleryWidget.Settings.prototype.isInitialized=function(){return this.pendingRequests.length==0};GalleryWidget.Settings.prototype.getParsedVal=function(a,b,c){return this.getVal(a,c,b)};GalleryWidget.Settings.prototype.getResource=function(b){var a=this.getVal(b);return a==undefined?"":a};GalleryWidget.Settings.prototype.getVal=function(a,b,c){if(this.viewSettings[b]&&this.viewSettings[b][a])return this.parseVal(this.viewSettings[b][a],c);else return this.parseVal(this.genericSettings[a],c)};GalleryWidget.Settings.prototype.setVal=function(c,e,d,a){var b=this.genericSettings;if(a){if(!this.viewSettings[a])this.viewSettings[a]=new Object;b=this.viewSettings[a]}b[c]=this.parseVal(e,d)};GalleryWidget.Settings.loadFromXml=function(b){var a=new GalleryWidget.Settings;a.loadFromXml(b);return a};GalleryWidget.Settings.loadFromObject=function(b){var a=new GalleryWidget.Settings;a.loadFromObject(b);return a};GalleryWidget.Settings.prototype.broadcastEvent=function(b){for(var a=0;a<this.listeners.length;a++)if(this.listeners[a][b])if(arguments.length==1)this.listeners[a][b]();else if(arguments.length==2)this.listeners[a][b](arguments[1]);else this.listeners[a][b](arguments[1],arguments[2])};GalleryWidget.Settings.prototype.addRequest=function(c,b,a){this.pendingRequests.push({id:c,response:null,url:b,type:a})};GalleryWidget.Settings.prototype.removeRequest=function(b,c){for(var a=0;a<this.pendingRequests.length;a++)if(this.pendingRequests[a].id==b){this.broadcastEvent(GalleryWidget.Settings.EVENT_LOAD_COMPLETE,b,c);this.pendingRequests.splice(a,1);this.processRequest(this.getNextRequest());return}};GalleryWidget.Settings.prototype.getRequest=function(b){for(var a=0;a<this.pendingRequests.length;a++)if(this.pendingRequests[a].id==b)return this.pendingRequests[a]};GalleryWidget.Settings.prototype.getNextRequest=function(){if(this.pendingRequests.length>0)return this.pendingRequests[0];else return null};GalleryWidget.Settings.prototype.parseVal=function(a,b){if(b==GalleryWidget.Settings.PARAM_TYPE_ARRAY)return a.split(";");else if(b==GalleryWidget.Settings.PARAM_TYPE_FLOAT)return parseFloat(a);else if(b==GalleryWidget.Settings.PARAM_TYPE_INT)return parseInt(a);else if(b==GalleryWidget.Settings.PARAM_TYPE_BOOLEAN)return a.toLowerCase()=="true";else return a};GalleryWidget.Settings.prototype.onXmlLoad=function(a){if(a.readyState==4){var b=a.settings;if(a.status==200){var c=b.getRequest(a.id);c.response=a.responseXML;if(b.getNextRequest().id==c.id)b.processRequest(c)}else b.onXmlError(a)}};GalleryWidget.Settings.prototype.onXmlError=function(a){var b=a.settings;b.removeRequest(a.id,false)};GalleryWidget.Settings.prototype.processRequest=function(a){if(a==null){this.broadcastEvent(GalleryWidget.Settings.EVENT_SETTINGS_INITIALIZED);return}var b=false;if(a.type==GalleryWidget.Settings.XML_REQ_TYPE){this.processXmlRequest(a.response);b=true}else if(a.type==GalleryWidget.Settings.JSON_REQ_TYPE);else if(a.type==GalleryWidget.Settings.OBJ_REQ_TYPE);this.removeRequest(a.id,b)};GalleryWidget.Settings.prototype.processXmlRequest=function(k){var a=k.getElementsByTagName("root")[0];if(a)for(var b=0;b<a.childNodes.length;b++)if(a.childNodes[b].tagName=="data"){var f=a.childNodes[b].getAttribute("key");if(f!="viewSettings"){var h=a.childNodes[b].getAttribute("value"),j=a.childNodes[b].getAttribute("type");this.setVal(f,h,j)}else{var d=a.childNodes[b].childNodes;for(var c=0;c<d.length;c++)if(d[c].tagName=="data"){var i=d[c].getAttribute("key");for(var g=0;g<d[c].childNodes.length;g++){var e=d[c].childNodes[g];if(e.tagName=="data"){f=e.getAttribute("key");h=e.getAttribute("value");j=e.getAttribute("type");this.setVal(f,h,i)}}}}}};GalleryWidget.ImageManager=function(c,b,a){this.catalogRoot=c;this.chunkSize=a!=undefined?a:10;this.queue=new Array;this.numProcessing=0;this.processing=false;this.defaultImageUrl=GalleryWidget.Global.uriConcat(b,GalleryWidget.ImageManager.DEFAULT_IMAGE_FILE)};GalleryWidget.ImageManager.DEFAULT_IMAGE_FILE="default_thumb.gif";GalleryWidget.ImageManager.IMAGE_SERVICE_SERVERS=["http://img1.catalog.video.msn.com","http://img2.catalog.video.msn.com","http://img3.catalog.video.msn.com","http://img4.catalog.video.msn.com","http://img5.catalog.video.msn.com"];GalleryWidget.ImageManager.prototype.add=function(b,a,c,e,d){if(e>0&&d>0){if(c==undefined)c=true;if(c)a=this.getImageServiceDomain(a)+GalleryWidget.Global.format("/image.aspx?uuid={0}&w={1}&h={2}",a,e,d);if(b.src==a)return;b.style.visibility="hidden";this.removeImage(b);this.queue.push({img:b,src:a});this.processQueue()}};GalleryWidget.ImageManager.prototype.getImageServiceDomain=function(c){if(this.catalogRoot&&this.catalogRoot!=""&&this.catalogRoot!="http://{0}.catalog.video.msn.com")return this.catalogRoot;var a=0,b=GalleryWidget.ImageManager.IMAGE_SERVICE_SERVERS.length;if(b==1)return GalleryWidget.ImageManager.IMAGE_SERVICE_SERVERS[0];a=Math.abs(GalleryWidget.Global.hashCodeFletcher(c))%b;return GalleryWidget.ImageManager.IMAGE_SERVICE_SERVERS[a]};GalleryWidget.ImageManager.prototype.processQueue=function(){setTimeout(this.processQueueAsync.bind(this),0)};GalleryWidget.ImageManager.prototype.processQueueAsync=function(){if(!this.processing){this.processing=true;while(this.numProcessing<this.chunkSize&&this.queue.length>0){this.processItem(this.queue[0]);this.queue.splice(0,1)}this.processing=false}};GalleryWidget.ImageManager.prototype.processItem=function(b){var a=b.img,c=b.src;if(!a||!c)return false;this.numProcessing++;if(a.addEventListener){a.addEventListener("load",this.onLoad.bind(this),false);a.addEventListener("error",this.onError.bind(this),false)}else{a.attachEvent("onload",this.onLoad.bind(this));a.attachEvent("onerror",this.onError.bind(this))}a.src=c};GalleryWidget.ImageManager.prototype.onLoad=function(a){var b=a.srcElement?a.srcElement:a.currentTarget;b.style.visibility="";this.numProcessing=Math.max(0,this.numProcessing-1);this.processQueue()};GalleryWidget.ImageManager.prototype.onError=function(b){var a=b.srcElement?b.srcElement:b.currentTarget;if(a.src!=this.defaultImageUrl){a.src=this.defaultImageUrl;a.style.visibility=""}this.numProcessing=Math.max(0,this.numProcessing-1);this.processQueue()};GalleryWidget.ImageManager.prototype.removeImage=function(b){for(var a=0;a<this.queue.length;a++)if(this.queue[a].img==b){this.queue.splice(a,1);return true}return false};GalleryWidget.RequestHandler=function(){var g=this,a=new Array,e=0,c=null,b=null,d=["edge1","edge2","edge3","edge4","edge5"];function f(c,e,d,b,a){this.intId=c;this.id=e;this.url=d;this.callbackFunc=b;this.callbackData=a;this.cancelled=false}this.getDomain=function(c){var a=0,b=d.length;if(b==1)return d[0];a=Math.abs(GalleryWidget.Global.hashCodeFletcher(c))%b;return d[a]};this.checkFunction=function(a){return typeof a=="function"};this.makeRequestUrl=function(a){var b=a;if(a.toLowerCase().indexOf("http://")==0)b=a.substring(a.indexOf("/",8)+1);var c=GalleryWidget.Global.format(a,this.getDomain(b));return c};this.makeRequest=function(k,j,m){var d=null;if(this.checkFunction(j)){if(c==null)c=document.getElementById("vcScripts");if(b==null)b=document.getElementById("vcGarbage");var l=this.makeRequestUrl(k),h=e++;d=GalleryWidget.Global.hashCodeFletcher(k);for(var i=0;i<a.length;i++)if(a[i].id==d){d+="_"+h;break}var n=new f(h,d,l,function(b,a){j(b,a)},m),o=l+"&responseEncoding=json&callbackName=GalleryWidget.RequestHandlerSingleton.doCallback&cd="+encodeURIComponent(d);a.push(n);var g=document.createElement("script");g.id="VCRequest"+h;c.appendChild(g);g.src=o}return d};this.cancelRequest=function(c){for(var b=0;b<a.length;b++)if(a[b].id==c){a[b].cancelled=true;break}};this.doCallback=function(f,e){for(var c=0;c<a.length;c++)if(a[c].id==e){var d=a[c];a.splice(c,1);if(!d.cancelled)d.callbackFunc(f,d.callbackData);e=d.intId;setTimeout(function(){var a=document.getElementById("VCRequest"+e);if(a&&a.parentNode){b.appendChild(a);b.innerHTML="";a=null}},100);f=null;break}}};GalleryWidget.RequestHandlerSingleton=new GalleryWidget.RequestHandler;GalleryWidget.RequestManager=function(){this.cacheSize=3;this.concurrentRequests=1;this._cache=new Array;this._cacheData=new Object;this._queue=new Array;this._inProgress=new Array;this._reqId=0;this._processingQueue=false};GalleryWidget.RequestManager.EVENT_REQUEST_COMPLETE="requestComplete";GalleryWidget.RequestManager.prototype=new GalleryWidget.EventBroadcaster;GalleryWidget.RequestManager.prototype.queueRequest=function(d,e,b){var a=this._reqId++,c=this.checkCache(d);if(null!=c)this.broadcastRequest(c,a,b);else{this.addToQueue({url:d,data:b,priority:e,id:a});this.processQueue()}return a};GalleryWidget.RequestManager.prototype.clearCache=function(){this._cache=new Array;this._cacheData=new Object};GalleryWidget.RequestManager.prototype.clearQueue=function(){this._queue=new Array};GalleryWidget.RequestManager.prototype.cancelRequest=function(a){this.removeFromQueue(a);this.removeFromInProgress(a);this.processQueue()};GalleryWidget.RequestManager.prototype.cancelAllRequests=function(){this.clearQueue();this._inProgress=new Array};GalleryWidget.RequestManager.prototype.requestHandler=function(b,a){if(this.removeFromInProgress(a.id)){this.addToCache(a.url,b);this.broadcastRequest(b,a.id,a.data)}};GalleryWidget.RequestManager.prototype.broadcastRequest=function(b,c,a){this.broadcastEvent(GalleryWidget.RequestManager.EVENT_REQUEST_COMPLETE,b,c,a)};GalleryWidget.RequestManager.prototype.addToCache=function(a,c){if(this._cache.length==this.cacheSize&&this.cacheSize>0){var b=this._cache[0];this._cache.splice(0,1);delete this._cacheData[b]}this._cache.push(a);this._cacheData[a]=c};GalleryWidget.RequestManager.prototype.checkCache=function(b){for(var a=0;a<this._cache.length;a++)if(this._cache[a]==b)return this._cacheData[b];return null};GalleryWidget.RequestManager.prototype.processQueue=function(){setTimeout(this.processQueueInt.bind(this),0)};GalleryWidget.RequestManager.prototype.processQueueInt=function(){if(!this._processingQueue){this._processingQueue=true;while(this._inProgress.length<this.concurrentRequests){var a=this.removeNextItemFromQueue();if(null!=a)this.processItem(a);else{break;}}this._processingQueue=false}};GalleryWidget.RequestManager.prototype.processItem=function(b){var a=new GalleryWidget.RequestItem(this,b);a.process()};GalleryWidget.RequestManager.prototype.removeFromInProgress=function(b){for(var a=0;a<this._inProgress.length;a++)if(this._inProgress[a].id==b){this._inProgress.splice(a,1);this.processQueue();return true}return false};GalleryWidget.RequestManager.prototype.removeNextItemFromQueue=function(){if(this._queue.length==0)return null;var a=this._queue[0];this._queue.splice(0,1);return a};GalleryWidget.RequestManager.prototype.removeFromQueue=function(b){for(var a=0;a<this._queue.length;a++)if(this._queue[a].id==b){this._queue.splice(a,1);return true}return false};GalleryWidget.RequestManager.prototype.addToQueue=function(a){if(a.priority==undefined)a.priority=0;var c=false;for(var b=0;b<this._queue.length;b++)if(this._queue[b].priority>a.priority){c=true;this._queue.splice(b,0,a);return}if(!c)this._queue.push(a)};GalleryWidget.RequestItem=function(a,b){this._reqManager=a;this._item=b};GalleryWidget.RequestItem.prototype.process=function(){setTimeout(this.processInt.bind(this),0)};GalleryWidget.RequestItem.prototype.processInt=function(){this._reqManager._inProgress.push(this._item);GalleryWidget.RequestHandlerSingleton.makeRequest(this._item.url,this._reqManager.requestHandler.bind(this._reqManager),this._item)};GalleryWidget.VCRequest=function(a,b){this.requestManager=a?a:new GalleryWidget.RequestManager;this.requestManager.addListener(this);this.settings=b;this.domain=this.settings.getVal("CatalogRoot");this.serviceName="";this.params=new Object;this.params.ff="8a";this.params.mk=this.settings.getVal("VcMarket")};GalleryWidget.VCRequest.EVENT_REQUEST_COMPLETE="requestComplete";GalleryWidget.VCRequest.PAGE_INDEX_PARAM="ind";GalleryWidget.VCRequest.PAGE_SIZE_PARAM="ps";GalleryWidget.VCRequest.prototype=new GalleryWidget.EventBroadcaster;GalleryWidget.VCRequest.prototype.clone=function(){var a=new GalleryWidget.VCRequest(this.requestManager,this.settings);a.domain=this.domain;a.serviceName=this.serviceName;for(var b in this.params)a.params[b]=this.params[b];return a};GalleryWidget.VCRequest.prototype.makeRequest=function(a,c,b){if(a==undefined)a=1;if(a<1)return;this.setPageNum(a);return this.requestManager.queueRequest(this.getUrl(),c,{orig:b,pageNum:a,pageSize:this.params.ps})};GalleryWidget.VCRequest.prototype.getUrl=function(){var b=this.domain+"/"+this.serviceName+"?",c=true;for(var a in this.params){if(!c)b+="&";else c=false;b+=a+"="+this.params[a]}return b};GalleryWidget.VCRequest.createFromUrl=function(b,l,m,h,i,j,k){var a=new GalleryWidget.VCRequest(l,m);try{if(h)a.addListener(h);var c=b.lastIndexOf("/");if(c!=-1&&c!=0){a.domain=b.slice(0,c+1);b=b.slice(c+1)}var e=b.split("?");a.serviceName=e[0];if(k)a.params.ns=k;if(e.length>1){var g=e[1].split("&");for(var f=0;f<g.length;f++){var d=g[f].split("=");if(d.length==2){var n=d[0],o=d[1];a.params[n]=o}}}if(i!=undefined)a.setPageSize(i);if(j)a.params.mk=j}catch(p){}return a};GalleryWidget.VCRequest.prototype.cleanup=function(){this.requestManager.removeListener(this)};GalleryWidget.VCRequest.prototype.pageNumToIndex=function(b,a){return (b-1)*a+1};GalleryWidget.VCRequest.prototype.pageIndexToNum=function(a,b){return Math.floor((a-1)/b)+1};GalleryWidget.VCRequest.prototype.setStartIndex=function(a){this.params[GalleryWidget.VCRequest.PAGE_INDEX_PARAM]=a};GalleryWidget.VCRequest.prototype.setPageNum=function(a){this.params[GalleryWidget.VCRequest.PAGE_INDEX_PARAM]=this.pageNumToIndex(a,this.getPageSize())};GalleryWidget.VCRequest.prototype.setPageSize=function(a){this.params[GalleryWidget.VCRequest.PAGE_SIZE_PARAM]=a};GalleryWidget.VCRequest.prototype.getStartIndex=function(){return this.params[GalleryWidget.VCRequest.PAGE_INDEX_PARAM]};GalleryWidget.VCRequest.prototype.getPageSize=function(){return this.params[GalleryWidget.VCRequest.PAGE_SIZE_PARAM]};GalleryWidget.VCRequest.prototype.getPageNum=function(){return this.pageIndexToNum(this.params[GalleryWidget.VCRequest.PAGE_INDEX_PARAM],this.getPageSize())};GalleryWidget.VCRequest.prototype.requestComplete=function(a,j,e){var d=new Array,c=0,g=e.pageSize,f=Math.max(1,(e.pageNum-1)*g+1);if(a&&a.video)if(a.$total){c=parseInt(a.$total);for(var b=0;b<a.video.length;b++){var h=GalleryWidget.VideoData.createFromJson(a.video[b],this.settings);d.push(h)}}else{c=a.video.length;for(b=f-1;b<Math.min(a.video.length,f+g-1);b++){h=GalleryWidget.VideoData.createFromJson(a.video[b],this.settings);d.push(h)}}else if(a){h=GalleryWidget.VideoData.createFromJson(a,this.settings);d.push(h);c=1}var i=new GalleryWidget.VideoList(d,g,f,c);this.maxIndex=c;this.broadcastEvent(GalleryWidget.VCRequest.EVENT_REQUEST_COMPLETE,i,j,e.orig)};GalleryWidget.VideoData=function(a){this.settings=a;this.title="";this.description="";this.previewUrl="";this.source="";this.date="";this.uuid="";this.csid="";this.provider="";this.usage=new Object};GalleryWidget.VideoData.prototype.toString=function(){return "VideoData[ title: "+this.title+"]"};GalleryWidget.VideoData.createFromJson=function(a,d){var b=new GalleryWidget.VideoData(d);b.title=a.title.$;b.description=a.description.$;b.uuid=a.uuid.$;b.date=GalleryWidget.Global.formatDateString(a.startDate.$,d.getResource("DatePosted"));b.source=a.source.$friendlyName;b.csid=a.csId.$;b.provider=a.providerId.$;for(var c=0;c<a.files.file.length;c++)if(a.files.file[c].$formatCode==GalleryWidget.VideoData.IMAGE_FORMAT_CODE)b.imageUrl=a.files.file[c].uri.$;var e=GalleryWidget.VideoData.getFileUrlAndType(a.videoFiles.videoFile,b.settings.getParsedVal("PreviewCode",GalleryWidget.Settings.PARAM_TYPE_ARRAY));b.previewUrl=e?e.url:"";for(c=0;c<a.usage.usageItem.length;c++)if(a.usage.usageItem[c].$counterType=="1"){b.usage["hourlyCount"]=a.usage.usageItem[c].$hourlyCount;b.usage["hourlyChange"]=a.usage.usageItem[c].$hourlyChange;b.usage["dailyCount"]=a.usage.usageItem[c].$dailyCount;b.usage["weeklyCount"]=a.usage.usageItem[c].$weeklyCount;b.usage["monthlyCount"]=a.usage.usageItem[c].$monthlyCount;b.usage["totalCount"]=a.usage.usageItem[c].$totalCount;b.usage["totalAverage"]=a.usage.usageItem[c].$totalAverage}return b};GalleryWidget.VideoData.getFileUrlAndType=function(d,b){for(var a=0;a<b.length;a++){var c=GalleryWidget.VideoData.getFileUrl(d,b[a]);if(c)return {url:c,code:b[a]}}return null};GalleryWidget.VideoData.getFileUrl=function(d,e){var c=null;for(var b=0;b<d.length;b++){var a=d[b];if(a.$formatCode==e&&a.uri.$){c=a.uri.$;break}}return c};GalleryWidget.VideoList=function(d,b,a,c){this.videos=d!=undefined?d:new Array;this.pageSize=b!=undefined?b:this.videos.length;this.startIndex=a!=undefined?a:1;this.videoTotal=c!=undefined?c:this.pageSize};GalleryWidget.VideoList.prototype.toString=function(){var b="VideoList[ pageSize: "+this.pageSize+", startIndex: "+this.startIndex+", videoTotal: "+this.videoTotal+", videos: \n";for(var a=0;a<this.videos.length;a++)b+="\t"+this.videos[a]+"\n";b+="]";return b};GalleryWidget.VideoList.prototype.pageNum=function(){return Math.floor((this.startIndex-1)/this.pageSize)+1};if(!window.GalleryWidget)window.GalleryWidget={};GalleryWidget.BaseControl=function(){};GalleryWidget.BaseControl.prototype=new GalleryWidget.EventBroadcaster;GalleryWidget.BaseControl.prototype.setSize=function(b,a){this.width=b?b:0;this.height=a?a:0;this.elem.style.width=this.width-this.getPadding().hPadding+"px";this.elem.style.height=this.height-this.getPadding().vPadding+"px"};GalleryWidget.BaseControl.prototype.setPosition=function(a,b){this.x=a?a:0;this.y=b?b:0;this.elem.style.left=this.x+"px";this.elem.style.top=this.y+"px"};GalleryWidget.BaseControl.prototype.getInnerWidth=function(){var a=parseInt(this.getStyle().width);return GalleryWidget.Global.checkNumber(a)?a:0};GalleryWidget.BaseControl.prototype.getInnerHeight=function(){var a=parseInt(this.getStyle().height);return GalleryWidget.Global.checkNumber(a)?a:0};GalleryWidget.BaseControl.prototype.getWidth=function(){return GalleryWidget.Global.checkNumber(this.width)?this.width:0};GalleryWidget.BaseControl.prototype.getHeight=function(){return GalleryWidget.Global.checkNumber(this.height)?this.height:0};GalleryWidget.BaseControl.prototype.getPadding=function(){return GalleryWidget.Global.getElementPadding(this.elem)};GalleryWidget.BaseControl.prototype.getStyle=function(){return GalleryWidget.Global.getElementStyle(this.elem)};GalleryWidget.BaseControl.prototype.addListenerFor=function(a,c,b,e){var f=this,d=function(a){b.bind(f)(a,e)};if(a&&b)if(a.addEventListener)a.addEventListener(c,d.bind(this),false);else a.attachEvent("on"+c,d.bind(this))};GalleryWidget.BaseControl.prototype.getElementByMarker=function(b,d,c){var a=this.getElementsByMarker(b,d,c);if(a.length>0)return a[0];else return null};GalleryWidget.BaseControl.prototype.getElementsByMarker=function(a,c,b){return this.getElementsByAttribute("marker",a,c,b)};GalleryWidget.BaseControl.prototype.getElementsByAttribute=function(f,g,d,a){if(d==undefined)d="*";if(a==undefined)a=this.elem;var e=new Array;if(a!=undefined){var c=a.getElementsByTagName(d);for(var b=0;b<c.length;b++)if(c[b].getAttribute(f)==g)e.push(c[b])}return e};GalleryWidget.BaseControl.prototype.findElement=function(c,b){if(b==undefined)b=this.elementMap!=undefined?this.elementMap:new Object;if(b[c]!=undefined&&b[c].length>0){var a=this.elem,f=b[c];for(var d=0;d<f.length;d++){var e=f[d];if(e<a.childNodes.length)a=a.childNodes[e];else return null}if(a)return a}return null};GalleryWidget.BaseControl.prototype.findElements=function(d,c){if(c==undefined)c=this.elementMap!=undefined?this.elementMap:new Object;if(c[d]!=undefined&&c[d].length>0){var a=[this.elem],h=c[d];for(var f=0;f<h.length;f++){var e=h[f];if(e=="*")if(a.length==1){var g=new Array;for(var b=0;b<a[0].childNodes.length;b++)g.push(a[0].childNodes[b]);a=g}else return null;else if(a)for(b=0;b<a.length;b++)if(e<a[b].childNodes.length)a[b]=a[b].childNodes[e];else return null;else break}if(a)return a}return null};GalleryWidget.BaseControl.prototype.createElementMap=function(c){var g=new Object,d=c!=undefined?c.split(";"):new Array;for(var b=0;b<d.length;b++){var a=d[b].split("=");if(a.length==2){var e=a[0],f=a[1].split("/");if(e!=""&&f.length>0)g[e]=f}}return g};GalleryWidget.PagingControl=function(a,b){this.videoList;this.settings=b;this.type=a?a:GalleryWidget.PagingControl.TYPE_BOTH;this.infoElem;this.pagingElem;this.elem=this.create()};GalleryWidget.PagingControl.TYPE_INFO="info";GalleryWidget.PagingControl.TYPE_CONTROL="control";GalleryWidget.PagingControl.TYPE_BOTH="both";GalleryWidget.PagingControl.PAGE_CHANGE_REQUEST="pageChangeRequest";GalleryWidget.PagingControl.prototype=new GalleryWidget.BaseControl;GalleryWidget.PagingControl.prototype.update=function(a){this.videoList=a;if(this.infoElem)this.infoElem.innerHTML=this.getPageInfoString();if(this.pagingElem)this.createPagingElemContents(this.pagingElem)};GalleryWidget.PagingControl.prototype.create=function(){var a=document.createElement("DIV");a.className="pagingControl";if(this.type==GalleryWidget.PagingControl.TYPE_INFO||this.type==GalleryWidget.PagingControl.TYPE_BOTH)this.infoElem=this.createPageInfo(a);if(this.type==GalleryWidget.PagingControl.TYPE_BOTH)this.separator=this.createSeparator(a);if(this.type==GalleryWidget.PagingControl.TYPE_CONTROL||this.type==GalleryWidget.PagingControl.TYPE_BOTH)this.pagingElem=this.createPagingElem(a);return a};GalleryWidget.PagingControl.prototype.createSeparator=function(b){var a=this.createSpan("&nbsp;&nbsp;|&nbsp;&nbsp;");b.appendChild(a);return a};GalleryWidget.PagingControl.prototype.createPagingElem=function(b){var a=this.createSpan("");b.appendChild(a);return a};GalleryWidget.PagingControl.prototype.createPagingElemContents=function(m){var b=m,j=this;b.innerHTML="";if(this.videoList){var f=this.videoList.pageNum(),d=Math.max(1,Math.floor((this.videoList.videoTotal-1)/this.videoList.pageSize)+1),g=f-2;if(g<1)g=1;var h=g+3;if(h>d){h=d;g=d-3>=1?d-3:1}if(g==h==1){if(this.separator)this.separator.style.display="none";return}else if(this.separator)this.separator.style.display="inline";if(f!=1){var a=this.createLink("&laquo;","pagingControlLink");a.setAttribute("title",this.settings.getResource("FirstPageTooltip"));b.appendChild(a);b.appendChild(this.createSpan("&nbsp;"));e(a,1);a=null;a=this.createLink("&lt;","pagingControlLink");a.setAttribute("title",this.settings.getResource("PreviousPageTooltip"));b.appendChild(a);b.appendChild(this.createSpan("&nbsp;"));e(a,f-1);a=null}for(var c=g;c<=h;c++){if(c==f){a=this.createSpan(c,"pagingControlSelected");b.appendChild(a);b.appendChild(this.createSpan("&nbsp;"));e(a,c)}else{a=this.createLink(c,"pagingControlLink");b.appendChild(a);b.appendChild(this.createSpan("&nbsp;"));e(a,c)}var i=(c-1)*this.videoList.pageSize+1,l=i+this.videoList.pageSize-1,k=this.videoList.videoTotal;a.setAttribute("title",GalleryWidget.Global.format(this.settings.getResource("SpecificPageTooltip"),i,l,k));a=null}if(f!=d&&d!=0){a=this.createLink("&gt;","pagingControlLink");a.setAttribute("title",this.settings.getResource("NextPageTooltip"));b.appendChild(a);b.appendChild(this.createSpan("&nbsp;"));e(a,f+1);a=this.createLink("&raquo;","pagingControlLink");a.setAttribute("title",this.settings.getResource("LastPageTooltip"));b.appendChild(a);e(a,d);a=null}}function e(a,b){if(a.addEventListener)a.addEventListener("click",function(){j.changePage(b)},false);else a.attachEvent("onclick",function(){j.changePage(b)});a=null}};GalleryWidget.PagingControl.prototype.createSpan=function(c,b){var a=document.createElement("SPAN");if(b)a.className=b;a.innerHTML=c;return a};GalleryWidget.PagingControl.prototype.createLink=function(c,b){var a=document.createElement("A");if(b)a.className=b;a.innerHTML=c;return a};GalleryWidget.PagingControl.prototype.createPageInfo=function(b){var a=this.createSpan("","pageInfoText");b.appendChild(a);return a};GalleryWidget.PagingControl.prototype.getPageInfoString=function(){var a=this.videoList,b=a.startIndex,c=b+a.pageSize-1;if(c>a.videoTotal)c=a.videoTotal;if(b>a.videoTotal)b=0;return GalleryWidget.Global.format(this.settings.getResource("PageInfo"),b,c,a.videoTotal)};GalleryWidget.PagingControl.prototype.changePage=function(a){this.broadcastEvent(GalleryWidget.PagingControl.PAGE_CHANGE_REQUEST,a)};GalleryWidget.CategoryMenu=function(a){this.options=new Array;this.selectedOption={label:"",value:""};this.menuList=null;this.defaultLabel=null;this.direction=a==undefined?GalleryWidget.CategoryMenu.DIRECTION_BELOW:a};GalleryWidget.CategoryMenu.EVENT_MENU_SELECTION_CHANGED="menuSelectionChanged";GalleryWidget.CategoryMenu.DIRECTION_ABOVE="above";GalleryWidget.CategoryMenu.DIRECTION_BELOW="below";GalleryWidget.CategoryMenu.prototype=new GalleryWidget.BaseControl;GalleryWidget.CategoryMenu.prototype.addOption=function(a,b){this.options.push({label:a,value:b});if(this.options.length==1)this.selectedOption=this.options[0]};GalleryWidget.CategoryMenu.prototype.render=function(f){var g=this,c=document.createElement("DIV");c.className="categoryMenu";if(null!=f)f.appendChild(c);var a=document.createElement("DIV");a.className="categoryMenuDefault";var b=this.defaultLabel=document.createElement("SPAN");b.innerHTML=this.selectedOption.label;b.style.styleFloat="left";b.style.cssFloat="left";a.appendChild(b);b=document.createElement("DIV");b.className="categoryMenuButton";a.appendChild(b);c.appendChild(a);this.addListenerFor(a,"click",this.toggleMenuVisibility);this.menuList=a=document.createElement("DIV");a.className=this.direction==GalleryWidget.CategoryMenu.DIRECTION_BELOW?"categoryMenuList":"categoryMenuListAbove";a.style.display="none";for(var e=0;e<this.options.length;e++){var d=document.createElement("DIV");d.className="categoryMenuLink";var h=document.createElement("A");h.innerHTML=this.options[e].label;d.appendChild(h);i(d,e);a.appendChild(d)}c.appendChild(a);return c;function i(a,b){g.addListenerFor(a,"click",function(){g.selectMenuOption(b)})}};GalleryWidget.CategoryMenu.prototype.selectNextOption=function(){var b=0;for(var a=0;a<this.options.length;a++)if(this.options[a]==this.selectedOption)b=a;var c=b+1>=this.options.length?0:b+1;this.selectMenuOption(c)};GalleryWidget.CategoryMenu.prototype.selectMenuOption=function(a){this.selectedOption=this.options[a]?this.options[a]:a;if(null!=this.defaultLabel)this.defaultLabel.innerHTML=this.selectedOption.label;this.broadcastEvent(GalleryWidget.CategoryMenu.EVENT_MENU_SELECTION_CHANGED,this,this.selectedOption);this.toggleMenuVisibility(false)};GalleryWidget.CategoryMenu.prototype.toggleMenuVisibility=function(a){if(a!=true&&a!=false)a=this.menuList.style.display=="none";if(a&&this.direction==GalleryWidget.CategoryMenu.DIRECTION_ABOVE&&this.menuList.parentNode.style.position!="absolute")this.menuList.style.left=this.menuList.parentNode.offsetLeft+"px";if(null!=this.menuList)a?this.menuList.style.display="block":this.menuList.style.display="none"};GalleryWidget.SearchBox=function(a){this.inputField=null;this.buttonText=a};GalleryWidget.SearchBox.EVENT_SEARCH_REQUESTED="searchRequested";GalleryWidget.SearchBox.prototype=new GalleryWidget.BaseControl;GalleryWidget.SearchBox.prototype.getText=function(){return this.inputField?this.inputField.value:""};GalleryWidget.SearchBox.prototype.render=function(c){var b=document.createElement("DIV");b.className="searchBox";if(null!=c)c.appendChild(b);var a=this.inputField=document.createElement("INPUT");a.className="searchBoxInput";b.appendChild(a);this.addListenerFor(a,"keypress",this.onKeyPress);a=document.createElement("DIV");a.className="searchBoxFade";b.appendChild(a);a=document.createElement("DIV");a.className="searchBoxButton";a.innerHTML=this.buttonText;a.setAttribute("title",this.buttonText);b.appendChild(a);this.addListenerFor(a,"click",this.onButtonClick);return b};GalleryWidget.SearchBox.prototype.onButtonClick=function(){this.broadcastEvent(GalleryWidget.SearchBox.EVENT_SEARCH_REQUESTED,this,this.getText())};GalleryWidget.SearchBox.prototype.onKeyPress=function(a){if(a.which=="13"||a.keyCode=="13"){if(a&&a.preventDefault){a.preventDefault();a.stopPropagation()}else if(window.event){window.event.cancelBubble=true;window.event.returnValue=false}this.onButtonClick();return false}return true};GalleryWidget.VideoControl=function(a,f,e,d,c,b){this.elem=a;this.view=f;this.settings=e;this.imageManager=d;this.hoverControl=c;this.previewAttempt={url:"",attempt:GalleryWidget.VideoControl.MAX_PREVIEW_PLAY_ATTEMPTS};this.elementMap=b?b:new Object;this.imageElem=this.findElement("thumbnail");this.titleElem=this.findElement("title");this.sourceElem=this.findElement("source");this.dateElem=this.findElement("date");this.playButton=this.findElement("playButton");this.descriptionElem=this.findElement("description");this.usageElem=this.findElement("usage");this.previewElem=this.findElement("videoPreview");this.imageContainer=this.findElement("imageContainer");this.video=this.buildVideoData();this.video.uuid=a.getAttribute("uuid");this.video.previewUrl=a.getAttribute("videoUrl");this.video.provider=a.getAttribute("provider");this.video.csid=a.getAttribute("csid");this.hookupEvents()};GalleryWidget.VideoControl.PLAY_INLINE="inline";GalleryWidget.VideoControl.PLAY_INTERNAL="internal";GalleryWidget.VideoControl.PLAY_DAUGHTER_WIN="daughter_win";GalleryWidget.VideoControl.PLAY_DIRECT_LINK="direct_link";GalleryWidget.VideoControl.PLAY_SHOW_PLAYER="show_player";GalleryWidget.VideoControl.PREVIEW_ID=0;GalleryWidget.VideoControl.MAX_PREVIEW_PLAY_ATTEMPTS=30;GalleryWidget.VideoControl.PREVIEW_PLAY_ATTEMPT_DELAY=100;GalleryWidget.VideoControl.EVENT_TITLE_MOUSE_OVER="onVideoTitleMouseOver";GalleryWidget.VideoControl.EVENT_TITLE_MOUSE_OUT="onVideoTitleMouseOut";GalleryWidget.VideoControl.prototype=new GalleryWidget.BaseControl;GalleryWidget.VideoControl.prototype.setVisible=function(b){var a=this.elem;if(a)if(b)a.style.visibility="visible";else a.style.visibility="hidden"};GalleryWidget.VideoControl.prototype.loadVideo=function(a){if(a==null){this.setVisible(false);return}this.video=a;var b=this.createLinkbackUrl(a.uuid);this.setImage(a.uuid,b);this.setTitle(a.title,b);this.setSource(a.source);this.setDate(a.date);this.setDescription(a.description);this.setUsage(a.usage[this.settings.getVal("UsageType",this.view)]);this.setVisible(true)};GalleryWidget.VideoControl.prototype.setPlaying=function(a){this.elem.className=a?"videoControlPlaying":"videoControl"};GalleryWidget.VideoControl.prototype.setImage=function(b,c){if(this.imageElem&&this.imageElem.nodeName=="IMG"){if(this.imageManager)this.imageManager.add(this.imageElem,b,true,this.settings.getVal("ImageWidth",this.view),this.settings.getVal("ImageHeight",this.view));else this.imageElem.src=b;var a=this.imageElem.parentNode;if(a&&a.nodeName=="A")a.href=c}};GalleryWidget.VideoControl.prototype.setTitle=function(b,a){if(this.titleElem){this.titleElem.innerHTML=b;this.titleElem.href=a}};GalleryWidget.VideoControl.prototype.setSource=function(a){if(this.sourceElem)this.sourceElem.innerHTML=a};GalleryWidget.VideoControl.prototype.setDate=function(a){if(this.dateElem)this.dateElem.innerHTML=a};GalleryWidget.VideoControl.prototype.setDescription=function(a){if(this.descriptionElem)this.descriptionElem.innerHTML=a};GalleryWidget.VideoControl.prototype.setUsage=function(c){if(this.usageElem){var b=this.settings.getVal("UsageType",this.view),a=this.settings.getResource(this.resourceForUsageType(b));this.usageElem.innerHTML=GalleryWidget.Global.format(a,c)}};GalleryWidget.VideoControl.prototype.resourceForUsageType=function(a){switch(a){case "hourlyCount":return "HourlyViews";case "dailyCount":return "DailyViews";case "weeklyCount":return "WeeklyViews";case "monthlyCount":return "MonthlyViews";case "totalCount":return "AllTimeViews";case "hourlyChange":return "HourlyChange";default:return "AllTimeViews"}};GalleryWidget.VideoControl.prototype.hookupEvents=function(){this.addListenerFor(this.playButton,"click",this.onPlayVideo);this.addListenerFor(this.titleElem,"click",this.onPlayVideo);this.addListenerFor(this.imageContainer,"click",this.onPlayVideo);this.addListenerFor(this.imageContainer,"mouseover",this.onImageMouseOver);this.addListenerFor(this.imageContainer,"mouseout",this.onImageMouseOut);this.addListenerFor(this.titleElem,"mouseover",this.onTitleMouseOver);this.addListenerFor(this.titleElem,"mouseout",this.onTitleMouseOut)};GalleryWidget.VideoControl.prototype.onTitleMouseOver=function(){this.broadcastEvent(GalleryWidget.VideoControl.EVENT_TITLE_MOUSE_OVER,this.video);if(this.view=="List");};GalleryWidget.VideoControl.prototype.onTitleMouseOut=function(){this.broadcastEvent(GalleryWidget.VideoControl.EVENT_TITLE_MOUSE_OUT,this.video);if(this.view=="List");};GalleryWidget.VideoControl.prototype.onImageMouseOver=function(a){if(!a)var a=window.event,c,b;if(window.event){c=a.srcElement;b=a.fromElement}else{c=a.target;b=a.relatedTarget}if(!c||!b)return;if(this.isChildOf(this.imageContainer,b))return;if(this.settings.getVal("PreviewThumbType",this.view)=="hover")this.playPreview();else if(this.hoverControl&&this.settings.getParsedVal("EnableVideoHover",GalleryWidget.Settings.PARAM_TYPE_BOOLEAN,this.view)&&this.elem.parentNode.style.display!="none"){if(this.hoverControl.normalControl&&this.hoverControl.normalControl!=this)this.hoverControl.normalControl.setVisible(true);this.hoverControl.normalControl=this;this.elem.parentNode.appendChild(this.hoverControl.elem);var d=this.buildVideoData();this.hoverControl.loadVideo(d);this.setVisible(false);this.hoverControl.setVisible(true)}};GalleryWidget.VideoControl.prototype.onImageMouseOut=function(a){var b=a&&a.target?a.relatedTarget:event.toElement;if(this.normalControl&&!this.isChildOf(this.imageContainer,b)){this.setVisible(false);this.normalControl.setVisible(true)}if(this.previewVideo&&this.settings.getVal("PreviewThumbType",this.view)=="hover"&&!this.isChildOf(this.imageContainer,b))this.stopPreview()};GalleryWidget.VideoControl.prototype.doPreviewAutoPlay=function(){if(this.settings.getVal("PreviewThumbType")=="auto")setTimeout(this.playPreview.bind(this),100)};GalleryWidget.VideoControl.prototype.playPreview=function(){var b="preview"+GalleryWidget.VideoControl.PREVIEW_ID++;this.previewElem.setAttribute("id",b);this.previewElem.control=this;var a="";a+="playTime="+this.settings.getVal("PreviewThumbPlayTime",this.view);a+="&startTime="+this.settings.getVal("PreviewThumbStartTime",this.view);a+="&volume="+this.settings.getVal("PreviewVolume",this.view);a+="&parentId="+b;var c=GalleryWidget.Global.uriConcat(this.settings.getVal("FlashResourceLocation"),"miniplayer.swf"),e=parseInt(this.previewElem.style.width),d=parseInt(this.previewElem.style.height);this.previewVideo=GalleryWidget.PreviewManager.Instance.playPreview(this.previewElem,e,d,c,a,this.video.previewUrl)};GalleryWidget.VideoControl.prototype.stopPreview=function(){GalleryWidget.PreviewManager.Instance.stopPreview(this.previewVideo)};GalleryWidget.VideoControl.prototype.isChildOf=function(b,a){if(b&&a)while(a.parentNode){if(a.parentNode==b)return true;a=a.parentNode}return false};GalleryWidget.VideoControl.prototype.buildVideoData=function(){if(this.video)return this.video;this.video=new GalleryWidget.VideoData(this.settings);this.video.title=this.titleElem.innerHTML;this.video.description=this.descriptionElem?this.descriptionElem.innerHTML:"";this.video.source=this.sourceElem.innerHTML;this.video.date=this.dateElem?this.dateElem.innerHTML:"";this.video.usage[this.settings.getVal("UsageType",this.view)]=this.usageElem?GalleryWidget.Global.extractNumber(this.usageElem.innerHTML):0;return this.video};GalleryWidget.VideoControl.prototype.playInline=function(b){var a=document.getElementById(this.settings.getVal("PlayerId"));if(a&&a.vidPlayId){a.vidPlayId(b);return true}return false};GalleryWidget.VideoControl.prototype.onPlayVideo=function(e){if(e&&e.preventDefault)e.preventDefault();else if(window.event){window.event.cancelBubble=true;window.event.returnValue=false}this.stopPreview();GalleryWidget.Omniture.videoClick(this.settings,this.video,this.currentRequest);var j=this.settings.getVal("Mkt"),g=this.settings.getVal("Brand"),h=this.settings.getVal("From"),k=this.settings.getVal("Fg"),b=this.settings.getVal("PlayType"),f=this.settings.getVal("ShowPlayerChannelName"),i=this.settings.getVal("ShowPlayerShowName"),d=this.settings.getVal("ShowPlayerEpisode"),a=this.settings.getVal("ShowPlayerPlaylist");if(b==GalleryWidget.VideoControl.PLAY_INLINE){if(this.playInline(this.video.uuid))return false}else if(b==GalleryWidget.VideoControl.PLAY_DAUGHTER_WIN){try{msn4dw(j,g,this.video.uuid,h);return false}catch(l){}}else if(b==GalleryWidget.VideoControl.PLAY_SHOW_PLAYER){var c=GalleryWidget.Global.format("http://{0}.msn.com/player?sh={1}&g={2}",f,i,this.video.uuid);if(d&&""!=d)c+="&ep="+d;if(a&&""!=a)c+="&p="+a;window.open(c,"_gwShowPlayer","width=902,height=650");return false}window.open(this.createLinkbackUrl(this.video.uuid),"_gwDirectLink");return false};GalleryWidget.VideoControl.prototype.createLinkbackUrl=function(a){return GalleryWidget.VideoControl.createLinkbackUrl(this.settings,a)};GalleryWidget.VideoControl.createLinkbackUrl=function(b,j){var h=b.getVal("Mkt"),d=b.getVal("Brand"),e=b.getVal("From"),g=b.getVal("Fg"),a=b.getVal("Playlist"),f=b.getVal("Tab"),i=b.getVal("ShowPlaylist").toLowerCase()=="true";if(a&&a.indexOf("&")!=-1)a=a.substring(0,a.indexOf("&"));var c="?vid="+j;if(h&&h!="")c+="&mkt="+h;if(d&&d!="")c+="&brand="+d;if(e&&e!="")c+="&from="+e;if(g&&g!="")c+="&fg="+g;if(a&&a!=""){c+="&playlist="+a;if(i)c+="&showPlaylist=true"}if(f&&f!="")c+="&tab="+f;return b.getVal("MsnVideoRoot")+c};GalleryWidget.VideoControl.prototype.setShowPlayerPlaylist=function(a){this.showPlayerPlaylist=a};GalleryWidget.VideoListControl=function(a,d,c,b){if(b==undefined)b=false;this.elem=a;this.viewName=a.getAttribute("viewName");this.elementMap=this.createElementMap(a.getAttribute("elementMaps"));this.settings=d;this.imageManager=c;this.currentList=null;this.rows=parseInt(this.settings.getVal("NumRows",this.viewName));this.cols=parseInt(this.settings.getVal("NumCols",this.viewName));this.listContainer=this.findElement("listContainer");this.thumbnail=this.findElement("listThumb");this.thumbnailPreview=this.findElement("listThumbPreview");this.previewVideo=null;this.currentControls=new Array;this.buffers=new Array;this.hoverControl;this.transitionBuffer=null;this.numBuffers=2;this.nextBuffer=0;this.controlsLoaded=false;this.errorSet=false;if(!b)this.loadControls();this.currentList=new GalleryWidget.VideoList(null,this.currentControls.length,1,parseInt(a.getAttribute("videoTotal")));this.errorText=this.createErrorBox()};GalleryWidget.VideoListControl.BUFFER_LIST="buffer";GalleryWidget.VideoListControl.PRIMARY_LIST="primary";GalleryWidget.VideoListControl.TRANSITION_NONE="none";GalleryWidget.VideoListControl.CROSS_FADE="cross_fade";GalleryWidget.VideoListControl.MOVE_HORIZONTAL="move_horizontal";GalleryWidget.VideoListControl.MOVE_VERTICAL="move_vertical";GalleryWidget.VideoListControl.MOVE_VERTICAL_REVERSE="move_vertical_reverse";GalleryWidget.VideoListControl.FADE_IN_OUT="fade_in_out";GalleryWidget.VideoListControl.prototype=new GalleryWidget.BaseControl;GalleryWidget.VideoListControl.prototype.setError=function(a){this.errorSet=true;this.listContainer.style.display="none";this.errorText.parentNode.parentNode.style.visibility="visible";this.errorText.innerHTML=a};GalleryWidget.VideoListControl.prototype.clearError=function(){this.errorSet=false;this.listContainer.style.display="block";this.errorText.parentNode.parentNode.style.visibility="hidden";this.errorText.innerHTML=""};GalleryWidget.VideoListControl.prototype.setVisible=function(a){this.elem.style.display=a?"block":"none";this.elem.style.visibility=a&&this.elem.parentNode.style.visibility!="hidden"?"visible":"hidden"};GalleryWidget.VideoListControl.prototype.loadVideoList=function(a,h,d){if(this.errorSet&&this.errorText.innerHTML!=this.settings.getResource("NoVideosFound"))return;if(this.currentList==null)d=GalleryWidget.VideoListControl.TRANSITION_NONE;if(d==undefined)d=this.settings.getVal("PagingAnim",this.viewName);var g=this.currentList==null?true:a.pageNum()>=this.currentList.pageNum();if(!this.controlsLoaded)this.loadControls();if(h==GalleryWidget.VideoListControl.PRIMARY_LIST){this.currentList=a;if(a.videos.length>0)this.playPreview(a.videos[0],true);if(a.videoTotal==0)this.setError(this.settings.getResource("NoVideosFound"));else this.clearError();if(this.listMatch(a,this.currentControls)){for(var b=0;b<a.videos.length;b++){this.currentControls[b].video.provider=a.videos[b].provider;this.currentControls[b].video.csid=a.videos[b].csid;this.currentControls[b].currentRequest=this.currentRequest;this.currentControls[b].doPreviewAutoPlay()}return}else{var c=this.currentControls,f=this.checkBuffer(a);if(null!=f)c=f;else c=this.loadBuffer(a);if(c!=this.currentControls)this.doTransition(c,d,g)}if(this.viewName=="List"&&this.currentControls.length>0){var e=this.findElement("listThumb");if(e){this.currentControls[0].imageElem=e;this.currentControls[0].setImage(this.currentControls[0].video.uuid,this.currentControls[0].createLinkbackUrl(this.currentControls[0].video.uuid));e.onclick=this.currentControls[0].onPlayVideo.bind(this.currentControls[0])}}}else if(a.videos.length>0&&this.checkBuffer(a)==null)this.loadBuffer(a)};GalleryWidget.VideoListControl.prototype.setOmnitureRequestUrl=function(b){for(var a=0;a<this.currentControls.length;a++)this.currentControls[a].currentRequest=b};GalleryWidget.VideoListControl.prototype.setPlaying=function(b){for(var a=0;a<this.currentControls.length;a++)this.currentControls[a].setPlaying(this.currentControls[a].video.uuid==b)};GalleryWidget.VideoListControl.prototype.checkBuffer=function(b){for(var a=0;a<this.buffers.length;a++)if(this.listMatch(b,this.buffers[a]))return this.buffers[a];return null};GalleryWidget.VideoListControl.prototype.loadBuffer=function(c){var d=this.getNextAvailableBuffer(),e=c==null?0:Math.min(c.videos.length,this.cols*this.rows);for(var b=0;b<this.cols*this.rows;b++){var a=d[b];if(b<e){a.currentRequest=this.currentRequest;a.loadVideo(c.videos[b]);a.setVisible(true)}else{a.uuid="";a.setVisible(false)}}return d};GalleryWidget.VideoListControl.prototype.getNextAvailableBuffer=function(){if(this.buffers.length>0){var a=this.buffers[this.nextBuffer];this.nextBuffer++;if(this.nextBuffer>=this.numBuffers)this.nextBuffer=0;if(a!=this.transitionBuffer)return a}return this.currentControls};GalleryWidget.VideoListControl.prototype.doTransition=function(b,d,h){var i=true;if(GalleryWidget.Global.isIE())try{if(this.elem.filters==undefined)i=false}catch(o){i=false}if(undefined==d||!i&&(d==GalleryWidget.VideoListControl.CROSS_FADE||d==GalleryWidget.VideoListControl.FADE_IN_OUT))d=GalleryWidget.VideoListControl.TRANSITION_NONE;if(undefined==h)h=true;GalleryWidget.TweenManager.Instance.stopAll();if(d==GalleryWidget.VideoListControl.CROSS_FADE){this.positionControls(b);this.setListVisibility(b,true);var l=this.getBufferStyles(b),k=this.getBufferStyles(this.currentControls);GalleryWidget.Tween.create(l,["opacity",["filter","alpha(opacity={0})"]],[0,0],[1,100],0.5);GalleryWidget.Tween.create(k,["opacity",["filter","alpha(opacity={0})"]],[1,100],[0,0],0.5)}else if(d==GalleryWidget.VideoListControl.FADE_IN_OUT){this.positionControls(b);var f=this.getBufferStyles(b),e=this.getBufferStyles(this.currentControls),m=this;GalleryWidget.Tween.create(e,["opacity",["filter","alpha(opacity={0})"]],[1,100],[0,0],0.3);setTimeout(function(){m.setListVisibility(b,true);GalleryWidget.Tween.create(f,["opacity",["filter","alpha(opacity={0})"]],[0,0],[1,100],0.3)},300)}else if(d==GalleryWidget.VideoListControl.MOVE_HORIZONTAL){f=this.getBufferStyles(b,true);e=this.getBufferStyles(this.currentControls,true);if(h){this.positionControls(b,100);this.positionControls(this.currentControls);this.setListVisibility(b,true);for(var a=0;a<f.length;a++){var c=b[a].left,g=c-100;GalleryWidget.Tween.create(f[a],[["left","{0}%"]],c,g,1.25)}for(a=0;a<e.length;a++){c=this.currentControls[a].left;g=c-100;GalleryWidget.Tween.create(e[a],[["left","{0}%"]],c,g,1.25)}}else{this.positionControls(b,-100);this.positionControls(this.currentControls);this.setListVisibility(b,true);for(a=0;a<f.length;a++){c=b[a].left;g=c+100;GalleryWidget.Tween.create(f[a],[["left","{0}%"]],c,g,1.25)}for(a=0;a<e.length;a++){c=this.currentControls[a].left;g=c+100;GalleryWidget.Tween.create(e[a],[["left","{0}%"]],c,g,1.25)}}}else if(d==GalleryWidget.VideoListControl.MOVE_VERTICAL||d==GalleryWidget.VideoListControl.MOVE_VERTICAL_REVERSE){f=this.getBufferStyles(b,true);e=this.getBufferStyles(this.currentControls,true);if(d==GalleryWidget.VideoListControl.MOVE_VERTICAL_REVERSE)h=!h;if(!h){this.positionControls(b,0,-100);this.positionControls(this.currentControls);this.setListVisibility(b,true);for(a=0;a<f.length;a++){c=b[a].top;g=c+100;GalleryWidget.Tween.create(f[a],[["top","{0}%"]],c,g,1.25)}for(a=0;a<e.length;a++){c=this.currentControls[a].top;g=c+100;GalleryWidget.Tween.create(e[a],[["top","{0}%"]],c,g,1.25)}}else{this.positionControls(b,0,100);this.positionControls(this.currentControls);this.setListVisibility(b,true);for(a=0;a<f.length;a++){c=b[a].top;g=c-100;GalleryWidget.Tween.create(f[a],[["top","{0}%"]],c,g,1.25)}for(a=0;a<e.length;a++){c=this.currentControls[a].top;g=c-100;GalleryWidget.Tween.create(e[a],[["top","{0}%"]],c,g,1.25)}}}else{this.setListVisibility(this.currentControls,false);this.positionControls(b);this.setListVisibility(b,true)}var n=this.getNextAvailableBuffer(),j;for(a=0;a<this.buffers.length;a++)if(this.buffers[a]==n){j=this.buffers[a];this.buffers[a]=this.currentControls}this.currentControls=b;for(a=0;a<this.buffers.length;a++)if(this.buffers[a]==b)this.buffers[a]=j};GalleryWidget.VideoListControl.prototype.getBufferStyles=function(b,c){if(c==undefined)c=false;var d=new Array;for(var a=0;a<b.length;a++)if(!c)d.push(b[a].elem.style);else d.push(b[a].elem.parentNode.style);return d};GalleryWidget.VideoListControl.prototype.positionControls=function(b,c,d){if(c==undefined)c=0;if(d==undefined)d=0;for(var a=0;a<b.length;a++){var j=Math.floor(a/this.cols),i=a%this.cols,h=100/this.cols,g=100/this.rows,e=Math.floor(i*h)+c,f=Math.floor(j*g)+d;b[a].elem.parentNode.style.left=e+"%";b[a].elem.parentNode.style.top=f+"%";b[a].left=e;b[a].top=f}};GalleryWidget.VideoListControl.prototype.setListVisibility=function(b,c){var d=c?"block":"none";for(var a=0;a<b.length;a++){b[a].elem.parentNode.style.display=d;if(c){b[a].elem.parentNode.style.visibility="visible";b[a].doPreviewAutoPlay()}else b[a].stopPreview()}};GalleryWidget.VideoListControl.prototype.listMatch=function(b,c){if(b.videos.length>c.length)return false;else for(var a=0;a<b.videos.length;a++)if(c[a].video.uuid!=b.videos[a].uuid)return false;return true};GalleryWidget.VideoListControl.prototype.loadControls=function(){this.currentControls=new Array;var f=this.findElement("videoControlHover");if(f)this.hoverControl=new GalleryWidget.VideoControl(f,this.viewName,this.settings,this.imageManager);var b=this.findElements("videoControl"),e=b[0],d=e&&e.parentNode?e.parentNode.cloneNode(true):null;for(var a=0;a<b.length;a++){var c=new GalleryWidget.VideoControl(b[a],this.viewName,this.settings,this.imageManager,this.hoverControl,this.elementMap);c.addListener(this);this.currentControls.push(c)}if(d){var i=this.rows*this.cols;for(a=0;a<i-b.length;a++){var h=d.cloneNode(true);this.listContainer.appendChild(h);c=new GalleryWidget.VideoControl(h.childNodes[0],this.viewName,this.settings,this.imageManager,this.hoverControl,this.elementMap);c.addListener(this);this.currentControls.push(c)}this.createBufferLists(d)}if(this.viewName=="List"){var j=this.findElement("listThumb");if(b.length>0&&j){var g=new Array;g.push(this.currentControls[0]);for(a=0;a<this.buffers.length;a++)g.push(this.buffers[a][0])}}this.controlsLoaded=true};GalleryWidget.VideoListControl.prototype.createBufferLists=function(f){var g=this.rows*this.cols;f.style.display="none";for(var b=0;b<this.numBuffers;b++){var e=new Array;this.buffers.push(e);for(var c=0;c<g;c++){var a=f.cloneNode(true);a.setAttribute("id","buffer"+b+"_control"+c);this.listContainer.appendChild(a);var d=new GalleryWidget.VideoControl(a.childNodes[0],this.viewName,this.settings,this.imageManager,this.hoverControl,this.elementMap);d.addListener(this);e.push(d)}}};GalleryWidget.VideoListControl.prototype.createErrorBox=function(){var a=document.createElement("DIV");a.className="errorBox";a.style.visibility="hidden";var b=document.createElement("DIV");b.className="errorTextContainer";var c=document.createElement("SPAN");c.className="errorText";b.appendChild(c);a.appendChild(b);this.elem.appendChild(a);return c};GalleryWidget.VideoListControl.prototype.setShowPlayerPlaylist=function(b){for(var a=0;a<this.currentControls.length;a++)this.currentControls[a].setShowPlayerPlaylist(b)};GalleryWidget.VideoListControl.prototype.onVideoTitleMouseOver=function(a){this.playPreview(a)};GalleryWidget.VideoListControl.prototype.onVideoTitleMouseOut=function(){this.stopPreview()};GalleryWidget.VideoListControl.prototype.playPreview=function(c,b){if(b==undefined)b=false;if(this.thumbnail){this.setThumbnail(c.uuid,GalleryWidget.VideoControl.createLinkbackUrl(this.settings,c.uuid));if(!b&&this.settings.getVal("PreviewThumbType",this.viewName)=="hover"){var d="preview"+GalleryWidget.VideoControl.PREVIEW_ID++;this.thumbnailPreview.setAttribute("id",d);this.thumbnailPreview.control=this;var a="";a+="playTime="+this.settings.getVal("PreviewThumbPlayTime",this.viewName);a+="&startTime="+this.settings.getVal("PreviewThumbStartTime",this.viewName);a+="&volume="+this.settings.getVal("PreviewVolume",this.viewName);a+="&parentId="+d;var e=GalleryWidget.Global.uriConcat(this.settings.getVal("FlashResourcesLocation"),"miniplayer.swf"),g=parseInt(this.thumbnailPreview.style.width),f=parseInt(this.thumbnailPreview.style.height);this.previewVideo=GalleryWidget.PreviewManager.Instance.playPreview(this.thumbnailPreview,g,f,e,a,c.previewUrl)}}};GalleryWidget.VideoListControl.prototype.stopPreview=function(){if(this.thumbnail&&this.settings.getVal("PreviewThumbType",this.viewName)=="hover")GalleryWidget.PreviewManager.Instance.stopPreview(this.previewVideo)};GalleryWidget.VideoListControl.prototype.setThumbnail=function(b,c){if(this.thumbnail&&this.thumbnail.nodeName=="IMG"){this.imageManager.add(this.thumbnail,b,true,this.settings.getVal("ImageWidth",this.viewName),this.settings.getVal("ImageHeight",this.viewName));var a=this.thumbnail.parentNode;if(a&&a.nodeName=="A")a.href=c}};GalleryWidget.VideoRequestControl=function(b,c){this.elem=b;this.settings=c;this.currentView=null;this.currentPage=1;this.currentRequest;this.mk;this.vcMkt;this.ns;this.brand;this.from;this.fg;this.cs;this.msnVideoRootPath;this.pageControlsLocation;this.pageInfoLocation;this.searchBoxLocation;this.linkbackLocation;this.categoryMenuLocation;this.idp;this.linkbackText;this.defaultView;this.allowedViews;this.useAutoPage;this.autoPageCategories;this.autoPageMax;this.autoPageTime;this.autoLoadVideo;this.playType;this.requests;this.loadSettings();this.appendVCRequestDiv();this.imageManager=new GalleryWidget.ImageManager(this.settings.getVal("CatalogRoot"),this.settings.getVal("ImageResourcesLocation"));this.requestManager=new GalleryWidget.RequestManager;this.elementMap=this.createElementMap(b.getAttribute("elementMaps"));this.listControls=this.loadListControls();this.tabRow=this.createTabRow(this.findElement("tabbar"));this.header=this.findElement("header");this.footer=this.findElement("footer");this.pageInfo=this.createPageInfo();this.pageControls=this.createPageControls();this.linkback=this.createLinkback();this.categoryMenu=this.createCategoryMenu();this.searchBox=this.createSearchBox();this.errorText=this.createErrorBox();this.currentView=this.defaultView;this.imageManager.chunkSize=this.getPageSize();this.errorSet=false;this.checkImageSizes(this.currentView);if(this.requests.length>0)this.loadRequest(this.requests[0].url,1,GalleryWidget.VideoRequestControl.REQUEST_NONE);var a=this.listControls[this.currentView]?parseInt(this.listControls[this.currentView].elem.getAttribute("videoTotal")):0;if(isNaN(a))a=parseInt(this.listControls[this.currentView].elem.getAttribute("videoCount"));if(a==0&&this.listControls[this.currentView])this.listControls[this.currentView].setError(this.settings.getResource("NoVideosFound"));if(this.pageInfo)this.pageInfo.update(new GalleryWidget.VideoList(null,this.getPageSize(),1,isNaN(a)?0:a));if(this.pageControls)this.pageControls.update(new GalleryWidget.VideoList(null,this.getPageSize(),1,isNaN(a)?0:a));this.setShowPlayerPlaylist()};GalleryWidget.VideoRequestControl.EVENT_VIEW_CHANGED="viewChanged";GalleryWidget.VideoRequestControl.EVENT_REQUEST_CHANGED="requestChanged";GalleryWidget.VideoRequestControl.REQUEST_BUFFER_DELAYED="buffer_delayed";GalleryWidget.VideoRequestControl.REQUEST_BUFFER_HOVER="buffer_hover";GalleryWidget.VideoRequestControl.REQUEST_NONE="none";GalleryWidget.VideoRequestControl.REQUEST_NORMAL="normal";GalleryWidget.VideoRequestControl.REQUEST_BUFFER_DELAY=5000;GalleryWidget.VideoRequestControl.prototype=new GalleryWidget.BaseControl;GalleryWidget.VideoRequestControl.prototype.setError=function(b){this.errorSet=true;for(var a=0;a<this.elem.childNodes.length;a++)this.elem.childNodes[a].style.visibility="hidden";this.errorText.parentNode.parentNode.style.visibility="visible";this.errorText.innerHTML=b};GalleryWidget.VideoRequestControl.prototype.clearError=function(){this.errorSet=false;for(var a=0;a<this.elem.childNodes.length;a++)this.elem.childNodes[a].style.visibility="visible";this.errorText.parentNode.parentNode.style.visibility="hidden";this.errorText.innerHTML=""};GalleryWidget.VideoRequestControl.prototype.loadPageNum=function(b,a){if(a==undefined)a=GalleryWidget.VideoRequestControl.REQUEST_NORMAL;this.currentPage=b;this.requestManager.cancelAllRequests();if(a==GalleryWidget.VideoRequestControl.REQUEST_NORMAL)this.request.makeRequest(b,0,GalleryWidget.VideoListControl.PRIMARY_LIST);else{if(this.useAutoPage){clearTimeout(this.autoPageId);this.autoPageId=setTimeout(this.doAutoPage.bind(this),this.autoPageTime*1000)}if(this.listControls[this.currentView]!=undefined)this.listControls[this.currentView].setOmnitureRequestUrl(this.currentRequest)}if(a==GalleryWidget.VideoRequestControl.REQUEST_BUFFER_DELAYED||a==GalleryWidget.VideoRequestControl.REQUEST_NORMAL){var d=a==GalleryWidget.VideoRequestControl.REQUEST_BUFFER_DELAYED?GalleryWidget.VideoRequestControl.REQUEST_BUFFER_DELAY:0,c=this;setTimeout(function(){c.request.makeRequest(b+1,1,GalleryWidget.VideoListControl.BUFFER_LIST);c.request.makeRequest(b-1,2,GalleryWidget.VideoListControl.BUFFER_LIST)},d)}};GalleryWidget.VideoRequestControl.prototype.loadNextPage=function(){var a=this.request.getPageNum();this.loadPageNum(a+1)};GalleryWidget.VideoRequestControl.prototype.loadPreviousPage=function(){var a=this.request.getPageNum();this.loadPageNum(a-1)};GalleryWidget.VideoRequestControl.prototype.loadRequest=function(a,b,d){if(b==undefined)b=1;this.currentRequest=a;if(this.request)this.request.cleanup();this.request=GalleryWidget.VCRequest.createFromUrl(a,this.requestManager,this.settings,this,this.getPageSize(),this.vcMkt,this.ns);this.loadPageNum(b,d);var c=this.request.clone();this.broadcastEvent(GalleryWidget.VideoRequestControl.EVENT_REQUEST_CHANGED,c);c.cleanup();this.tabRow.selectTab(a);return this.request};GalleryWidget.VideoRequestControl.prototype.getPageSize=function(){var b=this.settings.getParsedVal("NumRows",GalleryWidget.Settings.PARAM_TYPE_INT,this.currentView),a=this.settings.getParsedVal("NumCols",GalleryWidget.Settings.PARAM_TYPE_INT,this.currentView);return b*a};GalleryWidget.VideoRequestControl.prototype.setView=function(a){if(this.listControls[a]&&a!=this.currentView){var c=(this.currentPage-1)*this.getPageSize();this.currentView=a;for(var b in this.listControls)this.listControls[b].setVisible(false);this.listControls[a].currentList=null;if(this.currentRequest){var d=Math.floor(c/this.getPageSize())+1;this.loadRequest(this.currentRequest,d)}this.checkImageSizes(a);this.broadcastEvent(GalleryWidget.VideoRequestControl.EVENT_VIEW_CHANGED,a)}};GalleryWidget.VideoRequestControl.prototype.loadSettings=function(){this.mk=this.settings.getVal("Mkt");this.vcMkt=this.settings.getVal("VcMarket");this.ns=this.settings.getVal("Ns");this.brand=this.settings.getVal("Brand");this.from=this.settings.getVal("From");this.fg=this.settings.getVal("Fg");this.playlist=this.settings.getVal("Playlist");this.showPlaylist=this.settings.getVal("ShowPlaylist").toLowerCase()=="true";this.tab=this.settings.getVal("Tab");this.cs=this.settings.getVal("Cs");this.msnVideoRootPath=this.settings.getVal("MsnVideoRoot");this.pageControlsLocation=this.settings.getVal("PageControlsLocation");this.pageInfoLocation=this.settings.getVal("PageInfoLocation");this.searchBoxLocation=this.settings.getVal("SearchBoxLocation");this.linkbackLocation=this.settings.getVal("LinkbackLocation");this.categoryMenuLocation=this.settings.getVal("CategoryMenuLocation");this.idp=this.settings.getVal("Linkback");this.linkbackText=this.settings.getVal("LinkbackText");this.defaultView=this.settings.getVal("DefaultView");this.allowedViews=this.settings.getParsedVal("AllowedViews",GalleryWidget.Settings.PARAM_TYPE_ARRAY);this.useAutoPage=this.settings.getVal("UseAutoPage").toLowerCase()=="true";this.autoLoadVideo=this.settings.getVal("AutoLoadVideo");this.playType=this.settings.getVal("PlayType");this.autoPageCategories=this.settings.getVal("AutoPageCategories").toLowerCase()=="true";this.autoPageMax=parseInt(this.settings.getVal("AutoPageMax"));this.autoPageTime=Math.max(1,parseFloat(this.settings.getVal("AutoPageTimer")));this.requests=this.loadRequests(this.settings.getParsedVal("CategoryRequests",GalleryWidget.Settings.PARAM_TYPE_ARRAY),this.settings.getParsedVal("CategoryNames",GalleryWidget.Settings.PARAM_TYPE_ARRAY))};GalleryWidget.VideoRequestControl.prototype.checkImageSizes=function(a){var c=this.settings.getParsedVal("ImageWidth",GalleryWidget.Settings.PARAM_TYPE_INT,a),b=this.settings.getParsedVal("ImageHeight",GalleryWidget.Settings.PARAM_TYPE_INT,a);if(b/c!=0.75&&a!="List")if(this.listControls[a]){this.listControls[a].setError(this.settings.getResource("ErrorInvalidImageAspectRatio"));this.listControls[a].listContainer.removeChild(this.listControls[a].listContainer.childNodes[0])}};GalleryWidget.VideoRequestControl.prototype.appendVCRequestDiv=function(){var a=document.createElement("div");a.setAttribute("id","vcScripts");this.elem.appendChild(a);a=document.createElement("div");a.setAttribute("id","vcGarbage");this.elem.appendChild(a)};GalleryWidget.VideoRequestControl.prototype.pageChangeRequest=function(a){this.useAutoPage=false;this.loadPageNum(a)};GalleryWidget.VideoRequestControl.prototype.loadRequests=function(b,d){var c=new Array;for(var a=0;a<b.length;a++){var e=a<d.length?d[a]:"";if(b[a].trim().length>0)c.push({url:b[a].trim(),name:e})}return c};GalleryWidget.VideoRequestControl.prototype.loadListControls=function(){var e=new Object,c=this.findElements("videoList");for(var a=0;a<c.length;a++){var d=c[a].getAttribute("viewname");for(var b=0;b<this.allowedViews.length;b++)if(d==this.allowedViews[b]){var f=d!=this.defaultView,g=new GalleryWidget.VideoListControl(c[a],this.settings,this.imageManager,f);e[this.allowedViews[b]]=g;break}}return e};GalleryWidget.VideoRequestControl.prototype.createSearchBox=function(){var a=new GalleryWidget.SearchBox(this.settings.getResource("SearchButton"));a.addListener(this);this.addToControlBar(a.render(),this.searchBoxLocation);return a};GalleryWidget.VideoRequestControl.prototype.createCategoryMenu=function(){var c=this.locationIsTop(this.categoryMenuLocation)?GalleryWidget.CategoryMenu.DIRECTION_BELOW:GalleryWidget.CategoryMenu.DIRECTION_ABOVE,a=new GalleryWidget.CategoryMenu(c);a.addListener(this);for(var b=0;b<this.requests.length;b++)a.addOption(this.requests[b].name,this.requests[b].url);if(this.settings.getVal("TabCustom")!="true")this.addToControlBar(a.render(),this.categoryMenuLocation);return a};GalleryWidget.VideoRequestControl.prototype.menuSelectionChanged=function(b,a){if(this.ignoreNextCategoryChange==false)this.useAutoPage=false;this.ignoreNextCategoryChange=false;this.loadRequest(a.value)};GalleryWidget.VideoRequestControl.prototype.searchRequested=function(c,b){this.useAutoPage=false;var a="search.aspx?q="+encodeURIComponent(b);if(undefined!=this.cs&&""!=this.cs)a+="&cs="+this.cs;this.loadRequest(a)};GalleryWidget.VideoRequestControl.prototype.tabSelected=function(a,b){if(b==undefined)b=false;if(b)this.useAutoPage=false;if(a&&a!=""&&a!=this.currentRequest)this.loadRequest(a)};GalleryWidget.VideoRequestControl.prototype.createLinkback=function(){var b=undefined==this.linkbackText||""==this.linkbackText?this.settings.getResource("LinkbackName"):this.linkbackText,a=GalleryWidget.Global.format("<a href='{0}' class='linkback' target='_blank'>{1}</a>",this.getLinkbackUrl(),b);return this.addToControlBar(a,this.linkbackLocation)};GalleryWidget.VideoRequestControl.prototype.createPageInfo=function(){if(this.pageInfoLocation==this.pageControlsLocation)if(this.pageControls)return this.pageControls;else{var a=new GalleryWidget.PagingControl(GalleryWidget.PagingControl.TYPE_BOTH,this.settings);a.addListener(this);this.addToControlBar(a.elem,this.pageInfoLocation);return a}else{a=new GalleryWidget.PagingControl(GalleryWidget.PagingControl.TYPE_INFO,this.settings);a.addListener(this);this.addToControlBar(a.elem,this.pageInfoLocation);return a}};GalleryWidget.VideoRequestControl.prototype.createPageControls=function(){if(this.pageInfoLocation==this.pageControlsLocation)if(this.pageInfo)return this.pageInfo;else{var a=new GalleryWidget.PagingControl(GalleryWidget.PagingControl.TYPE_BOTH,this.settings);a.addListener(this);this.addToControlBar(a.elem,this.pageControlsLocation);return a}else{a=new GalleryWidget.PagingControl(GalleryWidget.PagingControl.TYPE_CONTROL,this.settings);a.addListener(this);this.addToControlBar(a.elem,this.pageControlsLocation);return a}};GalleryWidget.VideoRequestControl.prototype.createTabRow=function(a){if(a){var b=new GalleryWidget.TabBar(a,this.requests);b.addListener(this);return b}};GalleryWidget.VideoRequestControl.prototype.requestComplete=function(a,c,b){if(this.listControls[this.currentView]==undefined)return;this.listControls[this.currentView].currentRequest=this.currentRequest;this.listControls[this.currentView].loadVideoList(a,b);this.listControls[this.currentView].setVisible(true);if(b==GalleryWidget.VideoListControl.PRIMARY_LIST){if(this.pageInfo)this.pageInfo.update(a);if(this.pageControls)this.pageControls.update(a);if(this.useAutoPage){clearTimeout(this.autoPageId);this.autoPageId=setTimeout(this.doAutoPage.bind(this),this.autoPageTime*1000)}this.setShowPlayerPlaylist();Msn.Video.OnMediaChanged();Msn.Video.OnMediaCompleted()}};GalleryWidget.VideoRequestControl.prototype.setShowPlayerPlaylist=function(){var a=GalleryWidget.VCRequest.createFromUrl(this.currentRequest,null,this.settings).params["tag"];if(this.listControls[this.currentView])this.listControls[this.currentView].setShowPlayerPlaylist(a)};GalleryWidget.VideoRequestControl.prototype.doAutoPage=function(){if(!this.useAutoPage)return;var a=this.listControls[this.currentView].currentList,b=Math.min(this.autoPageMax,Math.ceil(a.videoTotal/a.pageSize));if(this.currentPage+1<=b)this.loadPageNum(this.currentPage+1);else if(this.autoPageCategories){this.ignoreNextCategoryChange=true;this.categoryMenu.selectNextOption()}else this.loadPageNum(1)};GalleryWidget.VideoRequestControl.prototype.addToControlBar=function(a,b){if(typeof a=="string"){var c=a;a=document.createElement("DIV");a.innerHTML=c}if(this.locationIsHidden(b))a.style.display="none";if(this.locationIsLeft(b)){a.style.textAlign="left";a.style.position="absolute";a.style.left="0px";a.style.top="0px"}else if(this.locationIsCenter(b)){a.style.textAlign="center";a.style.marginRight="auto";a.style.marginLeft="auto"}else{a.style.textAlign="right";a.style.position="absolute";a.style.right="0px";a.style.top="0px"}if(this.locationIsTop(b))this.header.appendChild(a);else this.footer.appendChild(a);return a};GalleryWidget.VideoRequestControl.prototype.getLinkbackUrl=function(){if(this.idp&&this.idp!="")return this.idp;else{if(this.playlist&&this.playlist.indexOf("&")!=-1)this.playlist=this.playlist.substring(0,this.playlist.indexOf("&"));var a="";if(this.mk&&this.mk!="")a+="?mkt="+this.mk;if(this.brand&&this.brand!="")a+="&brand="+this.brand;if(this.from&&this.from!="")a+="&from="+this.from;if(this.fg&&this.fg!="")a+="&fg="+this.fg;if(this.playlist&&this.playlist!="")a+="&playlist="+this.playlist;if(this.playlist&&this.playlist!=""&&this.showPlaylist)a+="&showPlaylist=true";if(this.tab&&this.tab!="")a+="&tab="+this.tab;var b=this.msnVideoRootPath+a;return b}};GalleryWidget.VideoRequestControl.prototype.createErrorBox=function(){var a=document.createElement("DIV");a.className="errorBox";a.style.visibility="hidden";var b=document.createElement("DIV");b.className="errorTextContainer";var c=document.createElement("SPAN");c.className="errorText";b.appendChild(c);a.appendChild(b);this.elem.appendChild(a);return c};GalleryWidget.VideoRequestControl.prototype.locationIsBottom=function(a){return a==GalleryWidget.Settings.LOC_BOTTOM_LEFT||a==GalleryWidget.Settings.LOC_BOTTOM_CENTER||a==GalleryWidget.Settings.LOC_BOTTOM_RIGHT};GalleryWidget.VideoRequestControl.prototype.locationIsTop=function(a){return a==GalleryWidget.Settings.LOC_TOP_LEFT||a==GalleryWidget.Settings.LOC_TOP_CENTER||a==GalleryWidget.Settings.LOC_TOP_RIGHT};GalleryWidget.VideoRequestControl.prototype.locationIsLeft=function(a){return a==GalleryWidget.Settings.LOC_TOP_LEFT||a==GalleryWidget.Settings.LOC_BOTTOM_LEFT};GalleryWidget.VideoRequestControl.prototype.locationIsCenter=function(a){return a==GalleryWidget.Settings.LOC_TOP_CENTER||a==GalleryWidget.Settings.LOC_BOTTOM_CENTER};GalleryWidget.VideoRequestControl.prototype.locationIsRight=function(a){return a==GalleryWidget.Settings.LOC_TOP_RIGHT||a==GalleryWidget.Settings.LOC_BOTTOM_RIGHT};GalleryWidget.VideoRequestControl.prototype.locationIsHidden=function(a){return a==GalleryWidget.Settings.LOC_HIDDEN};var lastPlayedUuid,lastLoadedUuid,lastPagePlayed;if(!window.Msn)window.Msn={};if(!Msn.Video)Msn.Video={};Msn.Video.OnMediaCompleted=function(){for(var f=0;f<GalleryWidget.Instances().length;f++){var a=GalleryWidget.Instances()[f].reqControl,b=a.listControls[a.currentView];if(a.autoLoadVideo==GalleryWidget.Settings.AUTO_PLAY_CONTINUOUS&&a.playType==GalleryWidget.VideoControl.PLAY_INLINE){var e=lastLoadedUuid;for(var c=0;c<b.currentControls.length;c++){var h=b.currentControls[c];if(h.video.uuid==e||e=="first"){if(c+1<b.currentControls.length){var g=e=="first"?h:b.currentControls[c+1];g.playInline(g.video.uuid)}else{var d=a.currentPage+1,i=Math.floor((b.currentList.videoTotal-1)/b.currentList.pageSize)+1;if(d>i)d=1;lastLoadedUuid="first";if(d!=a.currentPage)a.loadPageNum(d);else Msn.Video.OnMediaCompleted()}break}}break}}};Msn.Video.OnVideoLoaded=function(a){lastLoadedUuid=a;if(undefined==lastPlayedUuid)Msn.Video.OnMediaChanged(a)};Msn.Video.OnMediaChanged=function(a){if(a==undefined)a=lastPlayedUuid;lastPlayedUuid=a;for(var b=0;b<GalleryWidget.Instances().length;b++){var c=GalleryWidget.Instances()[b].reqControl;c.listControls[c.currentView].setPlaying(a)}};GalleryWidget.TabBar=function(b,a){this.requests=a;this.tabs=new Array;this.create(b);if(this.requests.length>0)this.selectTab(this.requests[0].url)};GalleryWidget.TabBar.prototype=new GalleryWidget.BaseControl;GalleryWidget.TabBar.prototype.create=function(c){for(var a=0;a<this.requests.length;a++)if(this.requests[a].url!=""&&this.requests[a].name!=""){var b=this.createTab(this.requests[a].name,this.requests[a].url,true);c.appendChild(b);b=this.createTab(this.requests[a].name,this.requests[a].url,false);c.appendChild(b)}};GalleryWidget.TabBar.prototype.createTab=function(c,d,b){var a=document.createElement("DIV");a.className=b?"tabSelected":"tab";a.innerHTML=c;if(!b)this.addListenerFor(a,"click",this.onTabClick);this.tabs.push({elem:a,label:c,value:d,selected:b});return a};GalleryWidget.TabBar.prototype.selectTab=function(b,c){for(var a=0;a<this.tabs.length;a++)if(this.tabs[a].value==b&&this.tabs[a].selected||this.tabs[a].value!=b&&!this.tabs[a].selected)this.tabs[a].elem.style.display="block";else this.tabs[a].elem.style.display="none";this.broadcastEvent(GalleryWidget.TabBar.EVENT_TAB_SELECTED,b,c)};GalleryWidget.TabBar.prototype.onTabClick=function(b){b=b||window.event;var c=b.srcElement||b.target;for(var a=0;a<this.tabs.length;a++)if(this.tabs[a].elem==c||this.tabs[a].elem==c.parentNode){this.selectTab(this.tabs[a].value,true);return}};GalleryWidget.TabBar.EVENT_TAB_SELECTED="tabSelected";GalleryWidget.GalleryWidget=function(b,a){this.elem=b;this.elementMap=this.createElementMap(b.getAttribute("elementMaps"));this.container=this.findElement("widgetContainer");this.rssButton;this.viewButtons;if(GalleryWidget.Global.isIE6OrLess())this.tryAbsoluteFix();this.reqControl=new GalleryWidget.VideoRequestControl(this.findElement("requestControl"),a);this.reqControl.addListener(this);var c=this.checkForErrors(a);if(!c){this.initContainer();this.viewChanged(a.getVal("DefaultView"))}GalleryWidget.Omniture.create(b,a);GalleryWidget.Omniture.pageLoad(a);GalleryWidget.AddInstance(this.elem.id,this)};GalleryWidget.GalleryWidget.prototype=new GalleryWidget.BaseControl;GalleryWidget.GalleryWidget.prototype.tryAbsoluteFix=function(){var b=this.container.parentNode,a=this;if(b.clientWidth!=0)GalleryWidget.Global.doAbsoluteFix(a.container,true);else setTimeout(function(){a.tryAbsoluteFix()},100)};GalleryWidget.GalleryWidget.prototype.checkForErrors=function(a){var c=a.getParsedVal("AllowedViews",GalleryWidget.Settings.PARAM_TYPE_ARRAY),e=a.getVal("DefaultView"),d=false;for(var b=0;b<c.length;b++)if(c[b].toLowerCase()==e.toLowerCase())d=true;if(!d){this.reqControl.setError(a.getResource("ErrorInvalidDefaultView"));return true}return false};GalleryWidget.GalleryWidget.prototype.initContainer=function(){this.viewButtons=new Array;var b=this.findElements("titleButtons"),d=new Array,e=new Array;if(b){for(var a=0;a<b.length;a++)if(b[a].getAttribute("marker")=="rssButton")this.rssButton=b[a];else if(b[a].getAttribute("marker")=="viewButton")d.push(b[a]);else if(b[a].getAttribute("marker")=="viewButtonSelected")e.push(b[a]);for(a=0;a<d.length;a++){var c=new Object;c.view=d[a].getAttribute("view");c.normalButton=d[a];this.addListenerFor(d[a],"click",this.viewButtonClicked,c.view);for(var f=0;f<e.length;f++)if(e[f].getAttribute("view")==c.view){c.selectedButton=e[f];this.viewButtons.push(c);break}}}};GalleryWidget.GalleryWidget.prototype.viewButtonClicked=function(b,a){this.reqControl.setView(a)};GalleryWidget.GalleryWidget.prototype.viewChanged=function(b){for(var a=0;a<this.viewButtons.length;a++)if(this.viewButtons[a].view==b){this.viewButtons[a].selectedButton.style.display="block";this.viewButtons[a].normalButton.style.display="none"}else{this.viewButtons[a].selectedButton.style.display="none";this.viewButtons[a].normalButton.style.display="block"}};GalleryWidget.GalleryWidget.prototype.requestChanged=function(a){if(this.rssButton){a.params.responseEncoding="rss";a.setPageNum(1);a.setPageSize(100);a.domain="http://catalog.video.msn.com";this.rssButton.href=a.getUrl()}}