<?xml version="1.0" encoding="UTF-8"?>

<Module>
<ModulePrefs
      title_url="http://www.builderhelper.com/"
      title="Google Image Search - Interior Design"
      description="Display Results From Google Image Search - Customize Search !!!"
      author="Matt Olsen" 
author_affiliation="Cell Phone Style" author_photo="http://www.nuzs.com/matt.png" author_aboutme="Accountant, SEO, Marketing" 
author_link="http://www.cellphonestyle.net" author_location="Orem, UT" 
author_quote="The key to happiness is having dreams..the key to success is making dreams come true." 
author_email="mattolsen10@gmail.com"  
height="450" width="300"
      screenshot="http://www.mappingnews.com/intdesign.jpg"
      thumbnail="http://www.mappingnews.com/intdesign.jpg"
>
<Require feature="minimessage" />
</ModulePrefs>

<UserPref name="UPsearchTerm" display_name=" Search Term" default_value='"Interior design" OR "home design"'/>
<UserPref name="UPthumb" display_name="Thumbnail"  datatype="bool" default_value="false" />
<UserPref name="UPrefreshInt" display_name="Refresh Min." default_value='10'/>

<Content type="html">
<![CDATA[

<DIV id="container__MODULE_ID__">
<TABLE width="100%"><TR><TD align=center>
<DIV align='right' style='font-size:10pt;text-decoration:underline;color:0000cc;cursor:pointer;' onclick='javascript:getIMG__MODULE_ID__()'>REFRESH</DIV>
<DIV id="imgSRC__MODULE_ID__"></DIV>
</TD></TR></TABLE>

</DIV>


<script>

var msg = new _IG_MiniMessage(__MODULE_ID__);

var to;

getIMG__MODULE_ID__();

function getIMG__MODULE_ID__(){
  var prefs__MODULE_ID__ = new _IG_Prefs(__MODULE_ID__); // Get user preferences
  var UPsearchTerm__MODULE_ID__ = prefs__MODULE_ID__.getString('UPsearchTerm');
  var UPthumb__MODULE_ID__ = prefs__MODULE_ID__.getBool('UPthumb');
  var UPrefreshInt__MODULE_ID__ = prefs__MODULE_ID__.getInt('UPrefreshInt');

  var start = Math.floor(Math.random()*10) * 10;
  UPsearchTerm__MODULE_ID__ = escape(UPsearchTerm__MODULE_ID__);
  var url__MODULE_ID__ = 'http://images.google.com/images?q=' + UPsearchTerm__MODULE_ID__ + '&start=' + start + '&ei=gvAORtaYPKGqiwHJvb28Aw&gbv=1&ei=xvAORuviBYGMiQHrlIT6AQ';

  _IG_FetchContent(url__MODULE_ID__, function (responseText) {
    // get content
    var dynIMG = responseText.match(/images\?q=tbn:[^\s]*/g);
    var fullInfo = responseText.match(/imgurl=[^<]*(?!<img)/g);

    // get random image number
    var resLen = dynIMG.length - 1;
    imgNum =  Math.floor(Math.random()*resLen) + 1;

    // create image links
    var full = fullInfo[imgNum].toString().match(/imgurl=(.*)(?=&imgrefurl)/);
    var fullSRC = full[1];
    var thumbnail = "http://images.google.com/" + dynIMG[imgNum];
    var thumbIMG = "<A href='" + fullSRC + "' target='_blank'><IMG src='" + thumbnail + "' border=0></A>"


    // height and width
    var hw = fullInfo[imgNum].toString().match(/h=([^&]*)&w=([^&]*)&sz/);
    var h = hw[1];
    var w = hw[2];
    // max width/height size of module window
    var wStrict = 280;
    var hStrict = 225;

    if (UPthumb__MODULE_ID__ == true){
      _gel("imgSRC__MODULE_ID__").innerHTML = thumbIMG;
    }else{
      while(w > wStrict || h > hStrict){
        if (w > wStrict){
          h = wStrict * h / w;
          w = wStrict;
        }else if(h > hStrict){
          w = hStrict * w / h;
          h = hStrict;
        }
      }

      _gel("imgSRC__MODULE_ID__").innerHTML = "<A href='" + fullSRC + "' target='_blank'><IMG id='fIMG__MODULE_ID__' src='' height='" + h + "' + width='" + w + "' border=0></A>";
      _gel('fIMG__MODULE_ID__').onerror = function (){
          _gel("imgSRC__MODULE_ID__").innerHTML = thumbIMG;
      }
      _gel('fIMG__MODULE_ID__').src = fullSRC;
    }
  });  // fetch

  clearTimeout(to);
  to = setTimeout(getIMG__MODULE_ID__, UPrefreshInt__MODULE_ID__ * 60 * 1000);
}

</script>
</p>
<p align="center"
<A HREF="http://www.builderhelper.com/" target="_blank"> 
<IMG SRC="http://www.nuzs.com/bhlogo.png" height="30" width="30" border="0"> 
</A> 
<A HREF="http://www.builderhelper.com" target="_blank" > 
Why Put Your Plans Online?</a href>
<br>
<br>
<p>
<script type="text/javascript"><!--
google_ad_client = "pub-6305086703890847";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text_image";
//2007-04-05: image
google_ad_channel = "9160585964";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_text = "000000";
google_color_url = "008000";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>


]]>
</Content>
</Module>


