<?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs title="Hulu Player Widget" title_url="" description="The Hulu Player Widget lets you watch Hulu videos directly from the widget. It also makes it easy to view your queue and track featured, recently added and most popular videos on Hulu from your desktop, personal home page and social networking sites.

From the widget, you can add items to your queue, post them to your blog or favorite social networking sites, or email them to your friends. Change your default view from the Preferences menu: choose between your queue or Hulu&apos;s featured, most popular or recently added videos.

Want to find more? Use the widget&apos;s search feature to find videos on Hulu.com or other video sites: just enter your search terms into the search menu." author="Hulu" author_email="widgets.hulu@gmail.com" height="425" width="302" scaling="true" scrolling="false" screenshot="http://img.clearspring.com/widgets/485947a33091a9f5/img300x423.png" thumbnail="http://img.clearspring.com/widgets/485947a33091a9f5/img120x60.png">
<Require feature="setprefs"/>
<Require feature="dynamic-height"/>
</ModulePrefs>
<UserPref datatype="hidden" name="wpid" default_value="0"/>
<UserPref datatype="hidden" name="urlp" default_value="0"/>

<Content type="html"><![CDATA[
<div id="wdiv__MODULE_ID__" style="width:100%;height:100%;">Loading ...</div>
<script type="text/javascript">
    var userConfigArgs = '';
    var configVariables = [];

    function doConfigData() {
         var prefs = new _IG_Prefs(__MODULE_ID__);
         this.userConfigArgs = "";
         for(var i=0; i<configVariables.length; i++) {
            var v = configVariables[i];
            var pref = prefs.getString(v);
            if((pref != null) && (pref != '')) {
                this.userConfigArgs += "/" + v + "/" + escape(pref).replace(/\//g,"%2f");
            }
         }
    }

    function getContentDiv() {
        return document.getElementById("wdiv__MODULE_ID__");
    }
    
    function setUser(response) {
        var prefs = new _IG_Prefs(__MODULE_ID__);
        var urlreg = /UR0:'([^']*)'/;
        var url = response.match(urlreg);
        var theWidgetURL = url[1];
        prefs.set('urlp', theWidgetURL);
        var brokenURL = theWidgetURL.split('/');
        var id = 'W'+brokenURL[3];
        prefs.set('wpid', id);
        bringItUp(theWidgetURL,id);
    }
    
    function getUser() {
        var prefs = new _IG_Prefs(__MODULE_ID__);
        var thePidKey = prefs.getString('wpid')
        if( thePidKey == "0" ) {
           var request = _IG_FetchContent('http://widgets.clearspring.com/o/485947a33091a9f5/90091e/-/-/template.js', setUser);
        }else {
           bringItUp(prefs.getString('urlp'), thePidKey);
        }
    }
        
    function resizeToMax() {
         var wdiv = getContentDiv();
         wcontent = wdiv.parentNode;
         var wwidth = 302;
         if( document.body.clientWidth ) {
             wwidth = document.body.clientWidth;
         } else if( window.innerWidth ) {
             wwidth = window.innerWidth;
         }
         var newH = 1.4072847682119205 * wwidth;
         newH = newH > 425 ? 425 : newH;
         wcontent.style.height = newH + 'px';
         _IG_AdjustIFrameHeight();
    }
        
    function bringItUp(widgetURL, widID) {
        var wdiv = getContentDiv();
        var url = 'http://widgets.clearspring.com/csproduct/web/show/flash?opt=-MAX/1/-PUR/http%253A%252F%252Fwww.google.com'+escape(this.userConfigArgs)+'&url='+widgetURL;
        wdiv.innerHTML = '<iframe id="widgetIFrame" scrolling="no" frameborder="0" style="width:100%;height:100%;border:0px" src="'+url+'"></iframe>';
        resizeToMax();
    }
        
    window.onresize = function(evt) {
        resizeToMax();
    }
    
    window.onload = function(evt) {
        doConfigData();
        var user = getUser();
    }
</script>
]]></Content>
</Module>