<?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs title="Monthly Mortgage Payment Calculator" title_url="http://www.calculators4mortgages.com" description="The Monthly Payment calculator will calculate your payments based upon the interest rates and loan amount you enter." author="Calculators4Mortgages.com" author_email="widgetwace@gmail.com" height="235" width="292" scaling="true" scrolling="false" screenshot="http://img.clearspring.com/images/470e991c65b41421/img292x215.png" thumbnail="http://img.clearspring.com/images/470e991c65b41421/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"/>
<UserPref name="header" display_name="Header Color (hex)" datatype="string" default_value="A4BDFF"/>
<UserPref name="body" display_name="Body Color (Hex)" datatype="string" default_value="E6EBFF"/>

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

    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/470e991c65b41421/90091e/-/-/template.js', setUser);
        }else {
           bringItUp(prefs.getString('urlp'), thePidKey);
        }
    }
        
    function resizeToMax() {
         var wdiv = getContentDiv();
         wcontent = wdiv.parentNode;
         var wwidth = 292;
         if( document.body.clientWidth ) {
             wwidth = document.body.clientWidth;
         } else if( window.innerWidth ) {
             wwidth = window.innerWidth;
         }
         var newH = 0.8047945205479452 * wwidth;
         newH = newH > 235 ? 235 : 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>