
var NewSiteApplication=function(){return function(){this.initialize.apply(this,arguments)};}();NewSiteApplication.prototype={initialize:function(){this.comps=[];this.obs={};this.addedElements={};this.componentJSON=null;this.configJSON=null;this.queryString=null;this.onLoadCallbacks=[];this._readyEventFired=false;this._componentLoadComplete=false;this._videoPlayerComponentReady=false;this._playerContainerName=null;this._responseJSON=null;this._partnerGuid=null;this._defaultClipId=null;this._prefix="NS_";this._flashEmbedPrefix="NS_FLASH_";this._PIDLength=32;this._scriptTagId="NS_GUID_JS";this._guidURLParam="guid";this._jsonServiceTimeoutID=null;this._jsonServiceTimeoutLength=10000;this._guidJSurl="http://config.hulu.com/js/";this._urlJSON="http://player.hulu.com/player/vs?callback=NewSite.loadComponents";this.DEBUG=false;this.LOGGER=null;this.VERSION="$Id: hulu_global.js 2.31 $";if(!window.opera&&document.all){this.unloadSet=false;if(!this.unloadSet){window.attachEvent("onbeforeunload",this._prepUnload);this.unloadSet=true;}}},_prepUnload:function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};var nullSWFFuncs=function(){var objArr=document.getElementsByTagName("OBJECT");for(var i=objArr.length-1;i>=0;i--){objArr[i].style.display='none';for(var j in objArr[i]){if(typeof objArr[i][j]=='function'){objArr[i][j]=function(){};}}}}
window.attachEvent("onunload",nullSWFFuncs);},getComponentServiceUrl:function(){var url=this._urlJSON;var sep=this.getUrlSeparator(url);try{if(url.toLowerCase().indexOf(this._guidURLParam)==-1){url+=sep+this._guidURLParam+"="+this.getPartnerGuid();}}
catch(e){this.reportError(e);}
return url;},run:function(){var thisObj=this;if(!window.opera&&document.all)
window.attachEvent('onunload',this.cleanupSwfs);this._jsonServiceTimeoutID=window.setTimeout(function(){thisObj.fireJSONError(thisObj);},thisObj._jsonServiceTimeoutLength)
this.loadExternalJS(this.getComponentServiceUrl());},cleanupSwfs:function(){var objects=document.getElementsByTagName("OBJECT");for(var i=objects.length-1;i>=0;i--){objects[i].style.display='none';for(var x in objects[i]){if(typeof objects[i][x]=='function'){objects[i][x]=function(){};}}
objects[i].parentNode.removeChild(objects[i]);}},ping:function(){return true;},fireJSONError:function(t){var errorObj={code:"NS_JS_001",type:"JSON",displayMessage:"Page components failed to load.",description:"Page component JSON service timed out."}
t.updateObservers("newsiteError",errorObj);},loadExternalJS:function(url){try{if(!url){throw('url parameter is required');}
var randomId=Math.random()+'';randomId.replace(/\./g,'');var urlSeperator=this.getUrlSeparator(url);var scriptObj=document.createElement("script");scriptObj.setAttribute("type","text/javascript");scriptObj.setAttribute("src",url);scriptObj.setAttribute("id",randomId);var head=document.getElementsByTagName("head");if(!head){throw("No head tag found.");}
var headTag=head.item(0);headTag.appendChild(scriptObj);return randomId;}
catch(e){this.reportError(e,"NewSite.loadExternalJS");}},registerReady:function(componentName){this.traceMsg("registerReady: "+componentName);if(this.addedElements[componentName]){this.addedElements[componentName].isReady=true;}
if(componentName=='videoPlayerComponent'){this.traceMsg("incoming: "+componentName);this._videoPlayerComponentReady=true;for(var i in this.addedElements){var comp=this.addedElements[i];if(comp&&comp.isReady&&!comp.isTracked){this.videoPlayerComponent.trackComponent([comp.trackingInfo]);comp.isTracked=true;}}}
this.fireReady(componentName);},getComponents:function(){return this.componentJSON;},isComponentReady:function(componentName){var comp=this.addedElements[componentName];if(!comp||comp.isReady===true){this.traceMsg("isComponentReady: "+componentName+" true");return true;}
this.traceMsg("isComponentReady: "+componentName+" false");return false;},loadComponents:function(responseJSON){clearTimeout(this._jsonServiceTimeoutID);var thisObj=this;try{if(responseJSON.error){window.setTimeout(function(){thisObj.fireJSONError(thisObj);thisObj.reportError("Service error: "+responseJSON.error.errorMessage);},500)}
if(responseJSON.components.videoPlayerComponent.url.indexOf("widget_player.swf")!=-1){responseJSON.components.videoPlayerComponent.url+="noCache"+Math.round(Math.random()*10000);}
if(responseJSON.components.videoPlayerComponent.url.indexOf("fancast16x9_player.swf")!=-1||responseJSON.components.videoPlayerComponent.url.indexOf("fancast4x3_player.swf")!=-1){responseJSON.components.videoPlayerComponent.url+="&inSwf=true&";}
try{var jsParams=this._parseQueryString(this.EL(this._scriptTagId).src.split('?')[1]);if(jsParams.partner!=undefined){responseJSON.components.videoPlayerComponent.optionalAttributes.distributionPartner=jsParams.partner;responseJSON.components.videoPlayerComponent.url+="&partner="+jsParams.partner;}
if(jsParams.showMetaDataBar!=undefined){responseJSON.components.videoPlayerComponent.optionalAttributes.distributionPartner=jsParams.partner;responseJSON.components.videoPlayerComponent.url+="&showMetaDataBar=true";}
if(jsParams.width!=undefined){responseJSON.components.videoPlayerComponent.width=jsParams.width;}
if(jsParams.height!=undefined){responseJSON.components.videoPlayerComponent.height=jsParams.height;}}
catch(e){this.reportError(e,"JS query params");}
responseJSON.components.videoPlayerComponent.url+="&referrer="+escape(document.location);this._responseJSON=responseJSON;var components=this.componentJSON=this._responseJSON.components;var config=this.configJSON=this._responseJSON.config;for(var componentName in components){var componentDetails=components[componentName];var component=this.initializeComponent(componentName,componentDetails);if(this.EL(componentName)){component=this.addComponentToDom(component);}
this.extendComponent(component);this.comps.push(componentName);}
this.traceMsg("ComponentLoadComplete");this._componentLoadComplete=true;this.fireReady();}
catch(e){this.reportError(e,"loadComponents");}},initializeComponent:function(componentName,options){return this[componentName]={instance:null,compName:componentName,parent:this,options:options};},addComponentToDom:function(component){var componentName=component.compName;this.traceMsg("addComponentToDom: "+componentName);var options=component.options;if(this.EL(componentName)){var instanceId=this._flashEmbedPrefix+componentName;if(!this.EL(instanceId)){this.addedElements[componentName]={};this.addedElements[componentName].isReady=false;this.addedElements[componentName].isTracked=false;this.EL(componentName).innerHTML=this.getFlashTag(instanceId,options);this.addedElements[componentName].trackingInfo=this.getTrackingInfo(componentName,options);component.instance=this.registerFlashObject(instanceId);}}
return component;},extendComponent:function(component){var componentName=component.compName;this.extend(component,this["commonComponentMethods"]);if(this[componentName+"Methods"]){this.extend(component,this[componentName+"Methods"]);}},registerFlashObject:function(id){var component=null;if(navigator.appName.indexOf("Microsoft")!=-1){component=window[id];}
else{component=document[id];}
return component?component:false;},addListener:function(eventType,callbackObj,callbackFunc){this.traceMsg("addListener: "+eventType+"\n<br>callbackObj "+callbackObj+"\n<br>callbackFunc "+callbackFunc);callbackObj=this._stringToObject(callbackObj);if(!callbackFunc){callbackFunc=eventType;}
if(!this.obs[eventType]){this.obs[eventType]=[];}
var obsType=this.obs[eventType]
var len=obsType.length;for(var i=0;i<len;i++){try{if(obsType[i].obj&&obsType[i].obj==callbackObj&&obsType[i].func==callbackFunc)
throw"Addition of duplicate listener ignored.";}
catch(e){this.reportError(e);};}
var cb;if(callbackObj&&callbackObj.id){cb=callbackObj.id;}
else{cb=callbackObj;}
this.traceMsg("addListener: "+eventType+"\n<br>callbackObj "+cb+"\n<br>callbackFunc "+callbackFunc);this.obs[eventType].push({obj:callbackObj,func:callbackFunc});return eventType;},addFlashListener:function(eventType,callbackObj,callbackFunc){callbackObj=this.registerFlashObject(callbackObj);this.addListener(eventType,callbackObj,callbackFunc);},removeListener:function(eventType,callbackObj,callbackFunc){callbackObj=this._stringToObject(callbackObj);if(!callbackFunc){callbackFunc=eventType;}
this.traceMsg("removeListener:\ncallbackObj "+callbackObj+"\ncallbackFunc "+callbackFunc);if(!this.obs[eventType]){return false;}
var obsType=this.obs[eventType]
var len=obsType.length;for(var i=0;i<len;i++){try{if(obsType[i].obj&&obsType[i].obj==callbackObj&&obsType[i].func==callbackFunc){return obsType.splice(i,1);}}
catch(e){this.reportError(e);};}
return false;},updateObservers:function(eventType,data){this.traceMsg('updateObservers : eventType '+eventType+" "+data);var obsType=this.obs[eventType]
if(!obsType){return;}
var len=obsType.length;for(var i=0;i<len;i++){try{var obj=this._stringToObject(obsType[i].obj);var func=obsType[i].func;if(obj&&func){if(typeof obj!='object'){throw"Object missing: "+obj;}
if(func==undefined||func==null){func=eventType;}
if(typeof obj[func]=="function"){obj[func](data);}
else{obj.toComponent(func,data);}}}
catch(e){this.reportError(e,"updateObservers("+eventType+")");};}},_stringToObject:function(str){var obj;if(typeof str=="string"){var arr=str.split('.');var count=0;while(arr.length>0){var c=arr.shift();if(!count++){obj=window[c];}
else{obj=obj[c];}}
if(obj){return obj;}}
return str;},setPlayerContainer:function(id){this.traceMsg('setPlayerContainer : '+id);if(this.EL(id)){this._playerContainerName=id;return id;}
return null;},getPlayerContainerName:function(){return this._playerContainerName;},setDefaultClipId:function(id){this._defaultClipId=id;},getDefaultClipId:function(){return this._defaultClipId;},_parseVideoId:function(id){try{id=id+'';id=id.replace(/.*pid=([^&]+).*/i,"$1");if(id.length!=this._PIDLength){throw"Invalid Video PID: "+id;}}
catch(e){this.reportError(e,"")};return id;},getNPMLObject:function(){return this._responseJSON;},EL:function(el){if(typeof el=='string'){el=document.getElementById(el);}
return el;},extend:function(destinationObj,sourceObj){for(var property in sourceObj){destinationObj[property]=sourceObj[property];}
return destinationObj;},readyEventFired:function(){return this._readyEventFired;},fireReady:function(componentName){this.traceMsg("fireReady: "+componentName);if(!this.readyEventFired()){if(this._componentLoadComplete&&this.allComponentsReady()){this.traceMsg("componentLoadComplete: "+componentName);this.updateObservers("newsiteReady",{});this._readyEventFired=true;this.onComponentsLoaded();}}},allComponentsReady:function(){this.traceMsg("allComponentsReady?");for(var i in this.addedElements){if(this.isComponentReady(i)!=true){this.traceMsg(i+" is Not ready");return false;}}
this.traceMsg("allComponentsReady!! "+this._videoPlayerComponentReady);return this._videoPlayerComponentReady;},onComponentsLoaded:function(){while(this.onLoadCallbacks.length>0){var callback=this.onLoadCallbacks.pop();try{if(callback)callback();}
catch(e){this.reportError(e);}}},onLoad:function(func){this.onLoadCallbacks.push(func);},getQueryString:function(){if(!this.queryString){this.queryString=this._parseQueryString();}
return this.queryString;},_parseQueryString:function(querystring){var qsObj={};var qs=querystring?querystring:window.location.search;if(qs.charAt(0)=='?'){qs=qs.slice(1,qs.length);}
if(qs.length<1){return qsObj;}
qs=qs.replace(/\&amp\;/gi,'&');qs=qs.split('&');for(var i=0;i<qs.length;i++){var pairs=qs[i].split("=");qsObj[pairs[0]]=pairs[1];}
return qsObj;},getPartnerGuid:function(){if(!this._partnerGuid){try{var guidscript=this.EL(this._scriptTagId).src;var guidqsObj=this._parseQueryString(guidscript.split('?')[1]);this._partnerGuid=guidqsObj.guid;}
catch(e){this.reportError(e);}}
return this._partnerGuid;},getUrlSeparator:function(url){return url.indexOf('?')==-1?'?':'&';},getEnvironment:function(){var qs=this.getQueryString();var ref=document.referrer;var url=document.URL;var ua=navigator.userAgent;var env={location:ref,queryString:qs,referrer:ref,url:url,userAgent:ua}
var sc=["availHeight","availWidth","colorDepth","height","width"];for(var i=0;i<sc.length;i++){var e=sc[i];env[e]=screen[e];}
return env;},getTrackingInfo:function(componentName,options){try{var obj={};obj.componentName=componentName;obj.url=document.URL;obj.pixelArea=options.width*options.height;obj.version=1;}
catch(e){this.reportError(e);}
return obj;},loadGuidJS:function(){this.loadExternalJS(this._guidJSurl+this._parseQueryString(this.EL(this._scriptTagId).src.split('?')[1]).guid+".js");},getFlashTag:function(id,options){var fb=this.getFlashBuilder();fb.setId(id);fb.setAttributes(options);var isIE=(navigator.appName.indexOf("Microsoft")!=-1);var tag=isIE?fb.getObjectTag():fb.getEmbedTag();fb.cleanup();delete fb;return tag;},getFlashBuilder:function(){var fb={errorHandler:null,id:'',attributes:[],allowedAttributes:{width:{req:true,def:null},height:{req:true,def:null},url:{req:true,def:null},wmode:{req:false,def:'transparent'},bgcolor:{req:false,def:'#FFFFFF'},allowScriptAccess:{req:false,def:'always'},allowFullScreen:{req:false,def:'true'},menu:{req:false,def:'true'}},setId:function(id){this.id=id},getId:function(){return this.id},setErrorHandler:function(func){this.errorHandler=func;},setAttributes:function(a){for(var k in a){this.setAttribute(k,a[k]);}},setAttribute:function(name,value){this.attributes[name]=value;},getAttribute:function(name){return this.attributes[name]||this.getDefaultValue(name)||false;},getAllowedAttributes:function(){return this.allowedAttributes},isRequired:function(name){var att=this.allowedAttributes[name];return att&&att.req?true:false;},getDefaultValue:function(name){var att=this.allowedAttributes[name];return att&&att.def||null;},getEmbedTag:function(){try{var id=this.getId();var tag='<embed quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" ';tag+='name="'+id+'" id="'+id+'" ';var aa=this.getAllowedAttributes();for(var att in aa){var attVal=this.getAttribute(att);if(this.isRequired(att)&&!this.getAttribute(att)){throw"Missing required attribute for "+id+": "+att;}
if(att.toLowerCase()=='url'){att='src';}
tag+=att+'="'+attVal+'" ';}
tag+='></embed>';}
catch(e){this.handleError(e);return'';}
return tag;},getObjectTag:function(){try{var aa=this.getAllowedAttributes();var tag='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';tag+='name="'+this.getId()+'" id="'+this.getId()+'" ';tag+='width="'+this.getAttribute('width')+'" height="'+this.getAttribute('height')+'"><param name="quality" value="high" />';for(var att in aa){var attVal=this.getAttribute(att);if(this.isRequired(att)&&!this.getAttribute(att)){throw"Missing required attribute: "+att;}
if(att.toLowerCase()!='width'&&att.toLowerCase()!='height'){if(att.toLowerCase()=='url')att='movie';tag+='<param name="'+att+'" value="'+attVal+'" />';}}
tag+='</object>';}
catch(e){this.handleError(e);return'';}
return tag;},handleError:function(e){if(this.errorHandler!=null){this.errorHandler(e);}},cleanup:function(){this.errorHandler=null;for(var x in this){this[x]=null;}}};fb.setErrorHandler(this.reportError);return fb;},hideAllComponents:function(){try{var len=this.comps.length;for(var i=0;i<len;i++){this[this.comps[i]].hide();}}
catch(e){}},showAllComponents:function(){try{var len=this.comps.length;for(var i=0;i<len;i++){this[this.comps[i]].show();}}
catch(e){}},pingImgUrl:function(url){try{var randomId=Math.random()+'';randomId.replace(/\./g,'');var img=document.createElement('IMG');img.width=1;img.height=1;img.src=url;img.id=randomId;img.onload=img.onerror=function(){var o=this.parentNode.removeChild(this);delete o;}
document.body.appendChild(img);}
catch(e){};},reportError:function(e,loc){try{var thisRef=NewSite,msg;if(!thisRef.DEBUG||!thisRef.LOGGER){return false;}
if(navigator.appName.indexOf("Microsoft")!=-1){msg=e.message+"\n"+e.name+"\n"+e.number+"\n"+e.description+"\n";}
else{msg=e;}
if(loc){msg=loc+"\n\n"+msg;}
var d=new Date().getMilliseconds();var p=document.createElement('P');p.style.backgroundColor="red";p.style.color="white";p.innerHTML=d+": Error caught: \n\n"+msg;thisRef.LOGGER.insertBefore(p,thisRef.LOGGER.firstChild);}
catch(e){}},traceMsg:function(msg,loc){try{if(!this.DEBUG||!this.LOGGER){return false;}
if(loc){msg=loc+"\n\n"+msg;}
var d=new Date().getMilliseconds();var p=document.createElement('P');p.innerHTML=d+": Trace: \n\n"+msg;this.LOGGER.insertBefore(p,this.LOGGER.firstChild)}
catch(e){}},getTimer:function(){}}
NewSiteApplication.prototype.commonComponentMethods={show:function(){var instance=this.getInstance();try{instance.width=this.options.width;instance.height=this.options.height;}
catch(e){}
this.toComponent("show");},hide:function(){var instance=this.getInstance();try{instance.width=1;instance.height=1;}
catch(e){}
this.toComponent("hide");},getFlashMethod:function(method){if(!this.parent){return method;}
return this.parent._prefix+this.compName+"_"+method;},info:{},getInfo:function(){return this.info;},setInfo:function(info){this.info=info;},getInstance:function(){return this.instance;},toComponent:function(func,param){try{var parent=this.parent
var instance=this.getInstance();var flashFunc=this.getFlashMethod(func);if(typeof instance[flashFunc]=="function"){instance[flashFunc](param);parent.traceMsg("toComponent("+flashFunc+")");}
else if(typeof instance[func]=="function"){instance[func](param);parent.traceMsg("toComponent("+func+")");}
else if(typeof instance.toFlash=="function"){instance.toFlash(func,param);parent.traceMsg("toComponent.toFlash("+func+")");}
else{throw"Function not found";}}
catch(e){parent.reportError(e,"NewSiteApplication.toComponent<br>"+func+"<br>"+flashFunc+"<br>"+instance);}}}
NewSiteApplication.prototype.videoPlayerComponentMethods={properties:{},openMenu:function(){this.toComponent('openMenu');},closeMenu:function(){this.toComponent('closeMenu');},setConfiguration:function(options){this.getInstance().setConfiguration(options);},setSmoothing:function(ifSmoothInNormal,ifSmoothInFS){this.getInstance().setSmoothing(ifSmoothInNormal,ifSmoothInFS);},setSize:function(w,h){this.getInstance().width=w;this.getInstance().height=h;try{this.getInstance().setStageSize(w,h);}catch(e){}
this.getInstance().setSize(w,h);},getEmbedCode:function(){return this.getInstance().getEmbedCode();},getCurrentTime:function(){return this.getInstance().getCurrentTime();},enableFullscreen:function(flag){this.toComponent('enableFullscreen',flag);},cueVideoById:function(id){this.getInstance().cueVideoById(id);},playVideo:function(id,pos){this.toComponent('playVideo',id);},pauseVideo:function(){this.toComponent('pauseVideo');},stopVideo:function(){this.toComponent('stopVideo');},resumeVideo:function(){this.toComponent('resumeVideo');},next:function(){this.toComponent('nextVideo');},previous:function(){this.toComponent('previousVideo');},seek:function(position){this.toComponent('seekVideo',position);},getProperty:function(propertyName){return this.properties[propertyName];},getProperties:function(){return this.properties;},setProperties:function(propObj){for(var i in propObj){this.properties[i]=propObj[i];}},mute:function(){this.toComponent('muteVideo');},setVolume:function(volumeNumber){this.toComponent('setPlayerVolume',volumeNumber);},trackComponent:function(domComponents){this.toComponent('trackComponent',domComponents);},trackBeacon:function(beaconParam){this.toComponent('trackBeacon',beaconParam);},submitToUrl:function(url){this.toComponent('submitToUrl',url);},closeConnection:function(){this.toComponent('closeConnection');},getInstance:function(){if(!this.instance){this.instance=this.parent.registerFlashObject(this.parent.getPlayerContainerName());}
return this.instance;}}
NewSiteApplication.prototype.linkComponentMethods={newLink:function(linkData){this.setInfo(linkData);this.toComponent('newLink',linkData);}}
NewSiteApplication.prototype.logoComponentMethods={}
NewSiteApplication.prototype.adComponentMethods={overlayAdBegin:function(adData){this.setInfo(adData);this.toComponent('overlayAdBegin',adData);},videoAdBegin:function(adData){this.setInfo(adData);this.toComponent('videoAdBegin',adData);},videoAdEnd:function(){this.toComponent('videoAdEnd');},getBannerState:function(){return this.getInstance().getBannerState();}}
NewSiteApplication.prototype.metadataComponentMethods={videoMetadata:function(metadata){this.setInfo(metadata);this.toComponent('videoMetadata',metadata);}}
NewSiteApplication.prototype.relatedVideosComponentMethods={relatedVideos:function(relatedVideoData){this.setInfo(relatedVideoData);this.toComponent('relatedVideos',relatedVideoData);}}
if(!NewSite){var NewSite=new NewSiteApplication;NewSite.run();}