<?xml version="1.0" encoding="UTF-8"?>
  <Module>
    <ModulePrefs title="Netflix: New Watch Instantly"
      title_url="http://www.Netflix.com"
      author="www.MonkandMonk.com"
      author_email="info@MonkandMonk.com"      
      description="Simply lists the newest listings under the Watch Instantly category on Netflix. In iGoogle, you can customize the gadget settings to expand the number of columns and the number of movies to show.  This version also has a direct link to the Play Now option on Netflix."
      scrolling="true"      
      thumbnail="http://lh4.googleusercontent.com/_1ULSO0XKfTI/TUxKxZSyLNI/AAAAAAAAHnw/KbnJsyProYQ/GG-Netflix-WI-PlayNow_thumb.png"
      screenshot="http://lh5.googleusercontent.com/_1ULSO0XKfTI/TUxKxDQgTGI/AAAAAAAAHns/wf8QHpbX_3c/GG-Netflix-WI-PlayNow.png"
      height="640"
      width="25"> 
    </ModulePrefs>
    
    <UserPref name="pref_BoxSize" 
    display_name="Picture size:"
    datatype="enum"
    default_value="2">
      <EnumValue value="1" display_value="Small"/>
      <EnumValue value="2" display_value="Medium"/>
      <EnumValue value="3" display_value="Large"/>
    </UserPref>
    <UserPref name="num_entries" display_name="Num movies:" default_value="25"/>  
    <UserPref name="num_columns" display_name="Num columns:" default_value="3"/>
    <UserPref name="pref_PlayNowLink" display_name="Show play?" datatype="bool" default_value="false"/>
    <UserPref name="pref_ShowTitle" display_name="Show title?" datatype="bool" default_value="false"/>
                
    <Content type="html">
    <![CDATA[
    <style> #content_div { font-size: 80%;  margin: 5px; background-color: #FFFFFF; vertical-align:top}         </style>
    <style> #overlay { visibility: hidden; position: absolute; left: 0px; top: 0px; width:100%; height:100%; text-align:center; z-index: 1000; } </style>
<style type="text/css">
a:link {text-decoration: none; color: gray;}
a:visited {text-decoration: none}
a:active {text-decoration: none}
a:hover {background:#ffffff; text-decoration: color: blue;}
</style>

<style>
a.tooltiplarge{ 
    position:relative;
    z-index:24; background-color:#ccc;
    color:#FFF;
    text-decoration:none}

a.tooltiplarge:hover{z-index:25; background-color:#ff0}

a.tooltiplarge span{display: none}

a.tooltiplarge:hover span{ /*the span will display just on :hover state*/
    display:block;
    position:absolute;
    top:-15em; left:-2em; width:20em; 
    padding: 0px 0px 0px 0px;
    border:1px solid #000;
    background-color:white; color:#000;    
    text-align: left;
    font-size:small}
</style>
     
<style>
a.tooltipsmall{ 
  position:relative;
  z-index:24; background-color:#ccc;
  color:#000;
  text-decoration:none}

a.tooltipsmall:hover{z-index:25; background-color:#ff0}

a.tooltipsmall span{display: none}

a.tooltipsmall:hover span{ /*the span will display just on :hover state*/
  display:block;
  position:absolute;
  top:-.75em; left:-.9em; width:240px; height:290px;      
  padding: 15px 10px 15px 15px;
  background-image:url('http://tiny.cc/iaw7a');
  text-align: left;
  font-size:small}

div#movieBox a.hover{
  display:block;
  position:absolute;
  top:.75em; left:-.9em; width:240px; height:290px;      
  padding: 15px 10px 15px 15px;
  background-image:url('http://tiny.cc/iaw7a');
  text-align: left;
  font-size:small}

div#header_div {
  position:fixed;
  top:0;
  height:100px;
  width:100%; }

div#content_div {
  position:left;}

div#about {
  position:right;}

</style>
    
<div id="header_div">


</div>
<div id="about">
<script type="text/javascript">
html_about;
html_about = "This is the right column that will hold the movie informaiton";
</script>
</div>

<div id="content_div">
    <script type="text/javascript">


    // Get userprefs
    var prefs = new gadgets.Prefs();
    var boxSize = prefs.getString("pref_BoxSize");
    var entries = prefs.getInt("num_entries");
    var columns = prefs.getInt("num_columns");
    var playNowLink = prefs.getBool("pref_PlayNowLink");
    var showTitle = prefs.getBool("pref_ShowTitle");
    srch = "Not Set";
    html;

    // kicks off the whole feed load process (getfeed->response)
    gadgets.util.registerOnLoadHandler(getFeed);

    function getFeed() {  
      var params = {};  
      params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.FEED;  
      params[gadgets.io.RequestParameters.NUM_ENTRIES] = new Number(entries);
      params[gadgets.io.RequestParameters.GET_SUMMARIES] = true;
      var url = "http://www.netflix.com/NewWatchInstantlyRSS";  
      gadgets.io.makeRequest(url, response, params);
   }

   // function mySearch(form) {
   //     srch = trim(form.inputbox.value);
  //return srch;
        //gadgets.util.registerOnLoadHandler(getFeed);        
//        }
         
    function response(obj) {
      // obj.data contains the feed data
      var feed = obj.data;
      html = "";
      //Give the user a message when in test/Developemnt mode
      //html += "Just a little testing for new features...will be done shortly.<br>"

  
  // Search
  //html += "<BR>Searching For:" + srch;
  //document.write(srch);

  // Read the Feed
  if (feed.Entry) {

    //set up where to show in a grid
    var c = 1;
    html += "<table WIDTH='110px'><tr>";      

    for (var i = 0; i < feed.Entry.length; i++) {

    //Control where the pic shows in the grid.
    if (c > columns)
      {
        c = 1;
        html += "<td>&nbsp</td><td>&nbsp</td><td>&nbsp</td></tr><tr>";
      }

    html += "<td valign='top'>";

      //Get the Netflix move ID 
            var vid = feed.Entry[i].Link;        
            vid = vid.substring(vid.search(/\/\d/)+1, vid.length);
      
     //Get Just the Summary
            var theSummary = feed.Entry[i].Summary.substring(feed.Entry[i].Summary.indexOf("</a><br>")+8, feed.Entry[i].Summary.length);
            var theTitle = feed.Entry[i].Title
            var theSumRegEx = new RegExp("<[^<]+?>|\'","g");
            theSummary = theSummary.replace(theSumRegEx, "");
            theTitle = theTitle.replace(theSumRegEx, "");

  //Super Long titles are annoying...move long titles to alt/title text and limit to 50 on-screen       
                var eTitle = feed.Entry[i].Title;

                 if (eTitle.length > 50)
                 {
                   eTitle = eTitle.substring(0,37);
                   eTitle += "...";
                 }
  
  //Build the rest of the info to show in Grid
            html += "<div style='text-align: center; vertical-align:top'>" 
                 
                 if ((playNowLink == "1")||(showTitle == "1"))
                 {
                   html += "<hr>" 
                 }

    //Play Now link             
                 if (playNowLink == "1")
                 {                 
                 html += "<a target='_blank' href='http://movies.netflix.com/WiPlayer?movieid=" + vid 
                 + "' alt='Play movie online now (Netflix account required)'" 
                 + "title='Play movie online now (Netflix account required)'>"
                 + "<FONT SIZE='1'>[Play Now]</FONT></a><br>"
                 }

    //Picture
                 html += "<div id='movieBox" + i + "'> "
      //Determine what style small/large for tooltip/popup 
                
        switch (boxSize)
    {
    case '1':
    html += "<a class='tooltipsmall' href='" + feed.Entry[i].Link  + "' target='_blank'>"
                   html += "<img src='http://cdn-0.nflximg.com/us/boxshots/small/"                    
                   + vid
                   + ".jpg' "; 
    break;
    case '2':
    html += "<a class='tooltiplarge' href='" + feed.Entry[i].Link  + "' target='_blank'>"
                   html += "<img src='http://cdn-0.nflximg.com/us/boxshots/large/" 
                   + vid
                   + ".jpg' ";
    break; 
    case '3':
    html += "<a class='tooltiplarge' href='" + feed.Entry[i].Link  + "' target='_blank'>"
                   html += "<img src='http://cdn-0.nflximg.com/us/boxshots/gsd/" 
                   + vid
                   + ".jpg' ";
    break;
    default:
    html += "<a class='tooltiplarge' href='" + feed.Entry[i].Link  + "' target='_blank'>"
                   html += "<img src='http://cdn-0.nflximg.com/us/boxshots/large/" 
                   + vid
                   + ".jpg' "; 
    }
                     
                 html += "border='0' />"    
    
      //Tooltip like popup
                 html += "<span><br><FONT COLOR='#000000'>"
                      +  "<b>"+theTitle+"</b></FONT><br><br>"
                 html += "<img src='http://cdn-0.nflximg.com/us/boxshots/gsd/" 
                   + vid
                   + ".jpg' border='0' style='float:left;margin:5px 5px 0px 10px;'/>" 
                    
                   
          if (theSummary.length >= 300) 
          {
          html += theSummary.substring(0,300)+"...<br>  [Click to read more]" 
          }
          else
          {
          html += theSummary 
          }
    html += "</span>"
     
          html += "</a></div>"
                                  
      //Title
                 if (showTitle == "1")
                 {
                 html += "<a target='_blank' href='" + feed.Entry[i].Link + "' "
                 + "alt='Links to the movie page for " + theTitle + "' "
                 + "title='Links to the movie page for " + theTitle + "' "
                 + ">" 
                 + "<FONT SIZE='1'>"
                 + eTitle + "</FONT></a><br>"
                 }
                 
                 html += "</div></td>";      
                 c += 1;
    }
      }    
      html += "</table><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>";    
      document.getElementById('content_div').innerHTML = html;
      document.getElementById('about').innerHTML = html_about;


    };
    
</script>
</div>
    ]]>
    </Content>
  </Module>