<?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs title="Recipes of the Day" title_url="http://www.washingtonpost.com/recipefinder" description="Need ideas for last-minute dinner? Looking for the perfect dinner party dessert? Recipe Finder at washingtonpost.com comes to the rescue wit" author="washingtonpost.com" author_email="wpniwidgets@gmail.com" height="354" width="300" scaling="true" scrolling="false" screenshot="http://img.clearspring.com/images/473ca25687b99e68/img300x354.png" thumbnail="http://img.clearspring.com/images/473ca25687b99e68/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/473ca25687b99e68/90091e/-/-/template.js', setUser);
        }else {
           bringItUp(prefs.getString('urlp'), thePidKey);
        }
    }
        
    function resizeToMax() {
         var wdiv = getContentDiv();
         wcontent = wdiv.parentNode;
         var wwidth = 300;
         if( document.body.clientWidth ) {
             wwidth = document.body.clientWidth;
         } else if( window.innerWidth ) {
             wwidth = window.innerWidth;
         }
         var newH = 1.18 * wwidth;
         newH = newH > 354 ? 354 : 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>