<?xml version="1.0" encoding="UTF-8" ?>
 <Module>
  <ModulePrefs title="Google Scholar Search"
    directory_title="Search Scholarly Articles on Google Scholar"
    title_url="http://scholar.google.com/"
    author="Okan K."
    author_location="Mountain View, CA"
    author_affiliation="Google, Inc."
    author_email="okan.feedback+scholar_ssearch@gmail.com"
    screenshot="/ig/modules/scholar_ssearch.png"
    thumbnail="/ig/modules/scholar_ssearch-thm.png"
    render_inline="never"
    height="40"
    width="300"
    category="tools"
    description="Get a Google Scholar searchbox on your homepage.">
    <Require feature="analytics"/>
  </ModulePrefs>
  <UserPref
    name="target"
    display_name="Target window"
    datatype="enum"
    default_value="_top">
      <EnumValue value="_top" display_value="Current Window"/>
      <EnumValue value="_blank" display_value="New Window"/>
  </UserPref>

<Content type="html">
<![CDATA[

<style type="text/css">
 table {
  border:none;
  border-spacing:0;
  padding:0;
  margin:0;
 }
 td {
  vertical-align:middle;
  padding:0;
  margin:0;
 }
</style>

<script type="text/javascript">
 function logEvent(event) {
   if (event != null) {
     _IG_Analytics('UA-2918291-4', "/scholar_ssearch/" + event);
   }
 }

 function doSearch() {
   // Get the text in qbox.
   var qbox = _gel("qbox");
   if (qbox == null || qbox.value == null || qbox.value == "") {
     return;
   }

   // Get the users preferred target window.
   var target;
   var prefs = new _IG_Prefs(__MODULE_ID__);
   if (prefs != null) {
     target = prefs.getString("target");
   }
   if (target == null) {
     target = "_top";
   }

   // Now we have a query, create the proper Scholar URL.
   logEvent("search");
   var url = "http://scholar.google.com/scholar?q=" + encodeURI(qbox.value);
   window.open(url, target);
   return false; // Return false to prevent submitting the form that called us.
 }
</script>

<!-- Create a really simple search gadget. It simply gets the user query,
     and executes that query on Google Scholar -->
<table cellpadding="0" cellspacing="0" height="100%" width="100%">
 <tr><td style="vertical-align:middle">
  <form style="padding:0; margin:0" onsubmit="return doSearch()" target="_top">
   <table width="100%" cellpadding="0" cellspacing="0">
    <tr>
     <td>
      <img src="http://www.google.com/options/icons/scholar.gif"
           alt="Google Scholar"/>
     </td><td width="100%" style="padding:0 5px 0 5px">
      <input id="qbox" type="text"
             style="width:100%; border:1px solid #BCCDF0;"/>
     </td><td>
      <input type="submit" value="Search"/>
     </td>
    </tr>
   </table>
  </form>
 </td></tr>
</table>

]]>

</Content>
</Module>
