<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs  title="Remote Desktop"
              description="Connect to your remote computer from anywhere in the world using the Remote Desktop gadget. The Remote Desktop gadget provides a quick and easy way to connect to your remote PC."
              author="Matt Baylis"
              author_email="smogreport+modulefeedback@gmail.com"
              directory_title="Remote Desktop"
              width="413" height="210"
              screenshot="http://hosting.gmodules.com/ig/gadgets/file/103534220535816043845/remotedesktopss.png"
              thumbnail="http://hosting.gmodules.com/ig/gadgets/file/103534220535816043845/remotedesktopthumb.png"
>
<Require feature="setprefs" />
<Require feature="analytics" />
<Require feature="dynamic-height"/>
</ModulePrefs>
<UserPref name="target" display_name="Connection History" default_value=""/>
<UserPref name="port" display_name="Port" default_value="3389"/>
<UserPref name="performance" display_name="Your connection speed" default_value="2" datatype="enum" >
    <EnumValue value="0" display_value="Modem (28.8 Kbps)" />
    <EnumValue value="1" display_value="Modem (56 Kbps)" />
    <EnumValue value="2" display_value="Broadband (128 Kbps - 1.5 Mbps)" />
    <EnumValue value="3" display_value="LAN(10 Mbps or higher)" />
</UserPref>
<UserPref name="screenmode" display_name="Screen Type" default_value="2" datatype="enum" >
    <EnumValue value="2" display_value="Fullscreen" />
    <EnumValue value="1" display_value="Windowed" /> 
</UserPref>
<UserPref name="audiomode" display_name="Remote Computer Sound" default_value="0" datatype="enum" >
    <EnumValue value="0" display_value="Bring to this computer" />
    <EnumValue value="1" display_value="Leave at remote computer" />
    <EnumValue value="2" display_value="Do not play" />
</UserPref>
<UserPref name="colormode" display_name="Colors" default_value="32" datatype="enum" >
    <EnumValue value="8" display_value="256 Colors" />
    <EnumValue value="16" display_value="High Color (16-bit)" />
    <EnumValue value="24" display_value="True Color (24-bit)" />
    <EnumValue value="32" display_value="Highest Quality (32-bit)" />
</UserPref>
<UserPref name="keyboardhook" display_name="Apply Windows key combinations (i.e. ALT+TAB)" default_value="2" datatype="enum" >
    <EnumValue value="0" display_value="On the local computer" />
    <EnumValue value="1" display_value="On the remote computer" />
    <EnumValue value="2" display_value="In fullscreen mode only" />
</UserPref>
<UserPref name="smartsizing" display_name="Scale desktop when resizing window?" datatype="bool" default_value="false"/>
<UserPref name="redirectprinters" display_name="Redirect Printers?" datatype="bool" default_value="true"/>
<UserPref name="redirectdrives" display_name="Redirect Drives?" datatype="bool" default_value="false"/>
<UserPref name="redirectcomports" display_name="Redirect COM ports?" datatype="bool" default_value="false"/>
<UserPref name="redirectsmartcards" display_name="Redirect Smartcards?" datatype="bool" default_value="false"/>
<UserPref name="adtype" display_name="Ad size" default_value="Small" datatype="enum" >
    <EnumValue value="Normal" />
    <EnumValue value="Small" />
    <EnumValue value="Disabled" display_value="Disabled (Are you sure?)" />
</UserPref>
<Content type="html"><![CDATA[
  <script language="JavaScript" src="http://hosting.gmodules.com/ig/gadgets/file/103534220535816043845/aw.js"></script>
  <link rel="stylesheet" type="text/css" href="http://hosting.gmodules.com/ig/gadgets/file/103534220535816043845/aw.css" rel="stylesheet"/>
  <script>
     // Track this gadget using Google Analytics.
     _IG_Analytics("UA-346747-17", "/gadget_remotedesktop");

    var prefs__MODULE_ID__;
    var history__MODULE_ID__ = new Array();
    var comboObj__MODULE_ID__ = new AW.UI.Combo;

    _IG_RegisterOnloadHandler(function () {
      prefs__MODULE_ID__ = new _IG_Prefs(__MODULE_ID__);
      var adtype = prefs__MODULE_ID__.getString("adtype");
      var target = prefs__MODULE_ID__.getString("target");
      history__MODULE_ID__ = target.split(",");
      buildComboBoxList__MODULE_ID__();
      
      if(adtype != "Disabled")
      {
        var adRandom = Math.floor(Math.random()*2+1);

        if(adtype == "Normal")
        {
          if(adRandom == 1)
          {
            document.getElementById('adNormal__MODULE_ID__').style.display = 'block';
            document.getElementById('adSmall__MODULE_ID__').style.display = 'none';
          }
          else
          {    
            document.getElementById('adNormal__MODULE_ID__').style.display = 'none';
            document.getElementById('adSmall__MODULE_ID__').style.display = 'block';
          }
        }
        else
        {        
          document.getElementById('adNormal__MODULE_ID__').style.display = 'none';
          document.getElementById('adSmall__MODULE_ID__').style.display = 'block';
        }
      }
      _IG_AdjustIFrameHeight();
      if(self.innerWidth < document.getElementById('main_content_div__MODULE_ID__').style.width.substring(0, document.getElementById('main_content_div__MODULE_ID__').style.width.length-2))
      {
        document.getElementById('main_content_div__MODULE_ID__').style.width = (self.innerWidth-2)+'px';
      }
      setEditable__MODULE_ID__(true);
      
    });
    
    function setEditable__MODULE_ID__(editable)
    {
      if (screen.width<=1280)
      {
        if(editable)
        {
          var popUpTemplate = comboObj__MODULE_ID__.getPopupTemplate();
          popUpTemplate.setStyle("width","150px");
          popUpTemplate.setStyle("height",calculatePopupHeight__MODULE_ID__(history__MODULE_ID__));
          comboObj__MODULE_ID__.setPopupTemplate(popUpTemplate);
          comboObj__MODULE_ID__.setStyle("width","150px");
          comboObj__MODULE_ID__.setStyle("background-color","#FFFFFF");        
          comboObj__MODULE_ID__.getContent("box/text").setAttribute("readonly", false);
          comboObj__MODULE_ID__.refresh();
        }
        else
        {          
          var popUpTemplate = comboObj__MODULE_ID__.getPopupTemplate();
          popUpTemplate.setStyle("width","150px");
          popUpTemplate.setStyle("height","0px");
          comboObj__MODULE_ID__.setPopupTemplate(popUpTemplate);
          comboObj__MODULE_ID__.setStyle("width","150px");
          comboObj__MODULE_ID__.setStyle("background-color","#CCCCCC");
          comboObj__MODULE_ID__.getContent("box/text").setAttribute("readonly", true);
          comboObj__MODULE_ID__.refresh();
        }
      }
      else
      {
        if(editable)
        {
          var popUpTemplate = comboObj__MODULE_ID__.getPopupTemplate();
          popUpTemplate.setStyle("width","195px");
          popUpTemplate.setStyle("height",calculatePopupHeight__MODULE_ID__(history__MODULE_ID__));
          comboObj__MODULE_ID__.setPopupTemplate(popUpTemplate);
          comboObj__MODULE_ID__.setStyle("width","195px");
          comboObj__MODULE_ID__.setStyle("background-color","#FFFFFF");
          comboObj__MODULE_ID__.getContent("box/text").setAttribute("readonly", false);
          comboObj__MODULE_ID__.refresh();
        }
        else
        {          
          var popUpTemplate = comboObj__MODULE_ID__.getPopupTemplate();
          popUpTemplate.setStyle("width","195px");
          popUpTemplate.setStyle("height","0px");
          comboObj__MODULE_ID__.setPopupTemplate(popUpTemplate);
          comboObj__MODULE_ID__.setStyle("width","195px");
          comboObj__MODULE_ID__.setStyle("background-color","#CCCCCC");
          comboObj__MODULE_ID__.getContent("box/text").setAttribute("readonly", true);
          comboObj__MODULE_ID__.refresh();
        }
      }
    }
    
    function submitForm__MODULE_ID__(formObj)
    {
      formObj.server.value = comboObj__MODULE_ID__.getControlValue();
      if(formObj.server.value.length > 0)
      {
        setEditable__MODULE_ID__(false);
        document.getElementById('controls__MODULE_ID__').style.display = 'none';
        document.getElementById('loading__MODULE_ID__').style.display = 'block';
        newPostProcessObj = new PostProcessObj__MODULE_ID__();
        newPostProcessObj.formObj = formObj;
        newPostProcessObj.prefs = prefs__MODULE_ID__;
        window.setTimeout( "newPostProcessObj.postSubmit()", 1000*3 );
        formObj.submit();
      }
      else
      {
        alert("Remote Desktop Error:\n\nPlease enter your computer's name or IP address to connect.");
      }
    }
    
    function arrayContains__MODULE_ID__(array, item)
    {
      var found = false;
      for(var i=0; i<array.length; i++)
      {
        if(array[i] == item)
        {
          found = true;
          break;
        }
      }
      return found;
    }
    
    function PostProcessObj__MODULE_ID__()
    {
      this.formObj = null;
      this.prefs = null;
      this.postSubmit = function()
      {
        // if the item is new, add it to the list
        if(arrayContains__MODULE_ID__(history__MODULE_ID__, this.formObj.server.value) == false)
        {
          //hack
          if((history__MODULE_ID__.length == 1) && (history__MODULE_ID__[0] == ""))
          {
            history__MODULE_ID__[0] = this.formObj.server.value;
          }
          else
          {
            history__MODULE_ID__ = insertToFrontOfArray__MODULE_ID__(this.formObj.server.value,history__MODULE_ID__);
          }
          buildComboBoxList__MODULE_ID__();
          this.formObj.server.value = "";
        }
        this.prefs.set("target", history__MODULE_ID__.join(","));
        setEditable__MODULE_ID__(true);
        document.getElementById('controls__MODULE_ID__').style.display = 'block';
        document.getElementById('loading__MODULE_ID__').style.display = 'none';
      }
    }
       
    function buildComboBoxList__MODULE_ID__()
    {
      comboObj__MODULE_ID__.setId("myCombo");
      //  comboObj__MODULE_ID__.setControlSize(150, 22);  // width, height
      //  comboObj__MODULE_ID__.setControlPosition(10, 100);  // left, top - adds "position:absolute"
      comboObj__MODULE_ID__.setControlText("");
      comboObj__MODULE_ID__.setControlImage("");
      comboObj__MODULE_ID__.setItemText(history__MODULE_ID__);
      comboObj__MODULE_ID__.setItemLink(history__MODULE_ID__);
      comboObj__MODULE_ID__.setItemCount(history__MODULE_ID__.length);
      document.getElementById('combo__MODULE_ID__').innerHTML = comboObj__MODULE_ID__;
      var popUpTemplate = comboObj__MODULE_ID__.getPopupTemplate();
      popUpTemplate.setStyle("width","195px");
      popUpTemplate.setStyle("height",calculatePopupHeight__MODULE_ID__(history__MODULE_ID__));
      comboObj__MODULE_ID__.setPopupTemplate(popUpTemplate);
      comboObj__MODULE_ID__.setStyle("width","195px");
      comboObj__MODULE_ID__.getContent("box/text").setAttribute("autocomplete","off");
      comboObj__MODULE_ID__.getContent("box/text").setAttribute("maxlength",20);
      comboObj__MODULE_ID__.getContent("box/text").setAttribute("title", "Enter your computer's name or IP address here and click Connect.");
      comboObj__MODULE_ID__.refresh();
    }
    
    function calculatePopupHeight__MODULE_ID__(arrayOfItems)
    {
      var heightMultiplier = 18;
      var listLength = arrayOfItems.length;
      if(listLength > 3)
      {        
        listLength = 3;
      }
      return((heightMultiplier*listLength) + "px");
    }
    
    function insertToFrontOfArray__MODULE_ID__(item,oldArray)
    {
      var newArray = new Array();
      newArray[0] = item;
      for(var i=0; i<oldArray.length; i++)
      {
        newArray[newArray.length] = oldArray[i];
      }
      return newArray;
    }
  </script>
  <style>
    .main_content__MODULE_ID__ {
      background:#ebe9ed;
      border-top:1px solid #FFF;
      border-left:1px solid #FFF;
      border-right:1px solid #808080;
      border-bottom:1px solid #808080;
    }
    .text__MODULE_ID__ {
      FONT-FAMILY: Verdana, Helvetica, Arial, San-Serif;
      font-weight:normal;
      font-size:11px;
      color:#000000;
    }
    .loadingtext__MODULE_ID__ {
      FONT-FAMILY: Verdana, Helvetica, Arial, San-Serif;
      font-weight:normal;
      font-size:12px;
      color:#7a7a7a;
      vertical-align:middle;
    }
  </style>
  <center>
<center><br/><div><a href="https://itunes.apple.com/us/app/smog-report/id607748201?ls=1&mt=8" target="_blank"><img width="300" height="50" alt="Smog Report - Free Download" src="http://www.smogreport.com/ads/bannerad-50x300.png"/></a></div></center>
  <div id="main_content_div__MODULE_ID__" class="main_content__MODULE_ID__" style="width:405px;">
  <form name="remotedesktopform__MODULE_ID__" method="post" action="http://www.mattandjoy.com/remotedesktop/" onSubmit="javascript:submitForm__MODULE_ID__(this);return false;" autocomplete="off">
    <center>
    <table width="100%">
      <tr>
        <td align="center" valign="middle" style="height:70px;background:url(http://hosting.gmodules.com/ig/gadgets/file/103534220535816043845/rdp-header-loading.gif);background-repeat: no-repeat;">
          &nbsp;
        </td>
      </tr>
    </table>
    </center>
    <center>
    <table>
      <tr><td></td></tr>
      <tr>
        <td align="right" valign="middle" width=1>
          <span class="text__MODULE_ID__">&nbsp;&nbsp;Computer:</span>
        </td>
        <td align="left" valign="middle">
          <span id="combo__MODULE_ID__"></span>
          <input type="hidden" name="server" value=""/>
          <input type="hidden" name="port" value="__UP_port__"/>
          <input type="hidden" name="screenmode" value="__UP_screenmode__"/>
          <input type="hidden" name="audiomode" value="__UP_audiomode__"/>
          <input type="hidden" name="redirectprinters" value="__UP_redirectprinters__"/>
          <input type="hidden" name="redirectdrives" value="__UP_redirectdrives__"/>
          <input type="hidden" name="redirectcomports" value="__UP_redirectcomports__"/>
          <input type="hidden" name="redirectsmartcards" value="__UP_redirectsmartcards__"/>
          <input type="hidden" name="smartsizing" value="__UP_smartsizing__"/>
          <input type="hidden" name="colormode" value="__UP_colormode__"/>
          <input type="hidden" name="keyboardhook" value="__UP_keyboardhook__"/>
          <input type="hidden" name="performance" value="__UP_performance__"/>
          <input type="hidden" name="adtype" value="__UP_adtype__"/>
        </td>
      </tr>
      <tr><td></td></tr>
      <tr><td></td></tr>
      <tr>
        <td align="right" valign="top">
          &nbsp;&nbsp;
        </td>
        <td align="left" valign="top">
          <div id="controls__MODULE_ID__" style="display:block;">
            <input type="submit" id="submit" name="submit" value="Connect" title="Click here to connect after entering your computer's name or IP address above."/>&nbsp;&nbsp;<input type="button" value="Help" onClick="window.open('http://www.microsoft.com/windowsxp/using/mobility/getstarted/remoteintro.mspx','RDPintro')" title="Click here to get help on setting up Remote Desktop for your PC."/>
          </div>
          <div id="loading__MODULE_ID__" style="display:none;">
            <table><tr><td valign="middle">
              <img src="http://hosting.gmodules.com/ig/gadgets/file/103534220535816043845/spinner.gif" border=0 title="Loading..."/>
            </td><td valign="middle">
              <span class="loadingtext__MODULE_ID__">&nbsp;&nbsp;Loading...</span>
            </td></tr></table>
          </div>
        </td>
      </tr>
    </table>
    </center>
  </form>
  </div>
<center><br/><div><a href="https://itunes.apple.com/us/app/smog-report/id607748201?ls=1&mt=8" target="_blank"><img width="300" height="50" alt="Smog Report - Free Download" src="http://www.smogreport.com/ads/bannerad-50x300.png"/></a></div></center>
  <div id="adNormal__MODULE_ID__" style="display:none;">
    
  </div>
  <div id="adSmall__MODULE_ID__" style="text-align:center;font-size:12px;display:none;">
  </div>
  </center>
]]></Content>
</Module>
