<?xml version="1.0" encoding="UTF-8" ?> 
 <Module>
  <ModulePrefs 
   title="scifAI mu" title_url="http://scifai.com/" 
   description="The latest SciFaiku (science fiction haiku) posted at scifai.com, as a smaller gadget"
   author="Alex Ibrado"
   author_email="gadget@scifai.com"
   author_affiliation="ibrado.org"
   author_location="Mandaluyong, PH"
   height="90"
   width="200"
   thumbnail="http://stargate.scifai.com/scifai-logo2.png"
   screenshot="http://stargate.scifai.com/igoogle-mu.png">
    <Require feature="setprefs" />   
  </ModulePrefs>
  
  <UserPref 
    name="lastseen" 
    default_value="0" 
    datatype="hidden"/>
  
  <Content type="html">
 <![CDATA[ 
 
<style type="text/css">
  #scifai-wrap {
    background: #000;
    color: #bfad8a;
    height: 90px;
    display: block;
  }
  .scifai-loader {
    background: #000;
    text-align: center;
    position: relative;
    top: 25px;
    display: block;
  }
  .scifai-content {
    color: #bfad8a;
    text-align: left;
    font-family: Georgia;
    font-size: 14px;
    padding-left: 5px;
    padding-top: 5px;
  }
  .scifai-tanka {
    color: #bfad8a;
    text-align: left;
    font-family: Georgia;
    font-size: 12px;
    line-height: 12px;
    padding-left: 5px;
    padding-top: 5px;
  }
  .scifai-links {
    border-width: 0px;
    font-size: 10px;
    position: absolute;
    top: 72px;
    right: 10px;
    color: #333;
    height: 12px;
    text-align: right;
    list-style-type: none;
    margin: 0pt;
    padding: 0pt;  
  }
  .scifai-links a {
    color: #333;
    font-size: 10px;
    border-bottom: 1px dotted #333;
    text-decoration: none;
  }
  .scifai-links a:hover {
    color: #bfad8a; 
    font-size: 10px;
    border-bottom: 1px solid #bfad8a;
    text-decoration: none;
  }
  .scifai-disqus {
     position: absolute;
     top: 72px;
     left: 10px;
     float: left;
     display: block;
     color: #333;
     height: 15px;
     font-size: 10px;
   }
  .scifai-disqus a {
    color: #333;
    border-bottom: 1px dotted #333;
    text-decoration: none;
  }
  .scifai-disqus a:hover {
    color: #bfad8a; 
    border-bottom: 1px solid #bfad8a;
    text-decoration: none;
  }
  .scifai-more {
    position: absolute;
    top: 0px;
    right: 0px;
    float: right;
    display: block;
    color: #333;
    padding: 3px;
    font-size: 9px;
  }
  .scifai-more a {
    color: #888;
    font-size: 9px;
    text-decoration: none;
  }
  .scifai-more a:hover {
    background: #999;
    color: #000; 
    font-size: 9px;
    border-bottom: 1px solid #bfad8a;
    text-decoration: none;
  }
</style>
  
<div id="scifai-more-wrap"></div>
<div id="scifai-wrap">
  <div class="scifai-loader"><img alt="*" src="http://stargate.scifai.com/ajax-loader3.gif" height="42" width="42" /></div>
</div>
<div id="scifai-disqus-wrap"></div>

<script type="text/javascript">
  var prefs = new _IG_Prefs(__MODULE_ID__);
  var post_url = '#';
  
  function swagURLs(content) {
    content = content.replace(/^\s+/g, '').replace(/\s+$/g, '');
    content = content.replace(/<br\/?>\\s*$/gi, '');
  
    var re = new RegExp("([^<]+)\\s+<br/?>([^<]+)\\s+<br/?>([^<]+)\\s+<br/?>([^<]+)\\s+<br/?>([^<]+)", "i");
    var m = re.exec(content);
    var urls = new Array('#', '#');
    var pref = 'http://www.zazzle.com/api/create?at=238030773790926334&ax=Linkover&fwd=ProductPage';

    if(m != null) {
      var line1 = encodeURI(m[1]);
      var line2 = encodeURI(m[2]);
      var line3 = encodeURI(m[3]);
      var line4 = encodeURI(m[4]);
      var line5 = encodeURI(m[5]);
      urls[0] = pref + '&pd=235811679170238687'
          + '&line1='+line1
          + '&line2='+line2
          + '&line3='+line3
          + '&line4='+line4
          + '&line5='+line5;
          
      urls[1] = pref + '&pd=168818891060041226'
          + '&line1='+line1
          + '&line2='+line2
          + '&line3='+line3
          + '&line4='+line4
          + '&line5='+line5;
          
      urls[2] = '1';    
          
    } else { 
      re = new RegExp("([^<]+)\\s+<br/?>([^<]+)\\s+<br/?>([^<]+)", "i");
      m = re.exec(content);
    
      if(m != null) {
        var line1 = encodeURI(m[1]);
        var line2 = encodeURI(m[2]);
        var line3 = encodeURI(m[3]);
        urls[0] = pref + '&pd=235492492309225217'
            + '&line1='+line1
            + '&line2='+line2
            + '&line3='+line3;
        urls[1] = pref + '&pd=168256815828863591'
            + '&line1='+line1
            + '&line2='+line2
            + '&line3='+line3;
        urls[2] = '0';
      }
    } 
    return urls;  
  }
  
  function scifaiCBdisqus(obj) {
    var post_nc = obj['num_posts'];
    var s = (post_nc == 1) ? '' : 's';
    document.getElementById('scifai-disqus-wrap').innerHTML =
      '<div class="scifai-disqus"><a href="' + post_url + '#ratethis" target="_blank">rate</a> | '
      + '<a href="' + post_url + '#disqus_thread" target="_blank">' + post_nc + ' comment' + s + '</a></div>';
  }

  function scifaiCBtumblr(obj) {
    var post_body = obj['posts'][0]['regular-body'];
    var post_id = obj['posts'][0]['id'];
    post_url = obj['posts'][0]['url'];
    var post_turl = encodeURI(post_url);
    var post_count = obj['posts-total'];  
    var post_date = new Date(obj['posts'][0]['date']);
    var post_m = post_date.getMonth() + 1;
    var post_d = post_date.getDate();
    var post_y = parseInt(post_date.getYear() % 100);
    if (post_d < 10) post_d = '0' + post_d;
    if (post_y < 10) post_y = '0' + post_y;

    var swag = swagURLs(post_body);
    var newhtml = '<div class="scifai-'
      + (((typeof(swag[2]) != 'undefined') && (swag[2] == '1')) ? 'tanka' : 'content')
      +  '">' + post_body + '</div><div class="scifai-links">';
      
    if (swag[0] != '#') 
      newhtml += '<a href="' + swag[0] + '" target="_blank">T</a> | <a href="'
        + swag[1] + '" target="_blank">M</a>&nbsp;&nbsp';

    newhtml += '<a href="' + post_url + '" target="_blank">#' + post_count + '</a>&nbsp;'
      + post_m + '.' + post_d + '.' + post_y + '</div>';
    
    document.getElementById('scifai-wrap').innerHTML = newhtml;
    var last_seen = prefs.getInt("lastseen");
    
    var mhtml = '<div class="scifai-more"><a href="http://scifai.com/" target="_blank">more</a></div>';
    var delta = post_count - last_seen - 1;
    if(delta > 0) {
      mhtml =
        '<div class="scifai-more"><a href="http://scifai.com/" target="_blank">' + delta + ' more</a></div>';
    }
    document.getElementById('scifai-more-wrap').innerHTML = mhtml;
          
    prefs.set("lastseen", post_count);

    document.write('<script type="text/javascript" src="http://disqus.com/api/v1/get_num_posts?forum_url=scifai&amp;thread_url='
      + post_turl + '&amp;response_type=json&amp;callback=scifaiCBdisqus"></' + 'script>');
  }

</script>
<script src="http://scifai.com/api/read/json?num=1&amp;type=regular&amp;callback=scifaiCBtumblr" type="text/javascript"></script>
<script type="text/javascript">
sc_project=3551173; 
sc_invisible=1; 
sc_partition=39; 
sc_security="dee4faaa"; 
</script>
<script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script>
  ]]> 
  </Content>
  </Module>