<search function="gusip">
  <name>Gula Sidorna Privatpersoner</name>
  <category>People and Places</category>
  <contributor>Kim Gr&#228;sman</contributor>
  <link>http://privatpersoner.eniro.se</link>
  <email>kim@mvps.org</email>
  <description>
  S&#246;ker efter privatpersoner hos Eniro.
    <div class="helpboxDescLabels">Anv&#228;ndning:</div>
    <table class="helpboxDescTable">
	<tr><td>gusip <i>f&#246;rnamn</i> <i>efternamn</i></td><td> - </td><td>S&#246;ker efter person i hela Sverige</td></tr>
	<tr><td>gusip <i>f&#246;rnamn</i> <i>efternamn</i>, <i>postort</i></td><td> - </td><td>S&#246;ker efter person p&#229; angiven postort</td></tr>
	<tr><td>gusip <i>telefonnummer</i></td><td> - </td><td>S&#246;ker efter person med angivet telefonnummer</td></tr>
    </table>  
  </description>
  <form name="gusipf"
        method="get"
        action="http://privatpersoner.eniro.se/query">
    <input type="hidden" name="stq" value="0" />
    <input type="hidden" name="firstname" value="" />
    <input type="hidden" name="lastname" value="" />
    <input type="hidden" name="area" value="" />
    <input type="hidden" name="phone_number" value="" />
    <input type="hidden" name="what" value="wp" />
    <input type="hidden" name="firstnameType" value="trunc" />
    <input type="hidden" name="lastnameType" value="trunc" />
    <input type="hidden" name="addressType" value="trunc" />
  </form>
  <script><![CDATA[
  	// Helper functions
  	function gusipStripChars(str)
  	{
  	  // Strips off all characters in toStrip, and returns a clean string
  		var toStrip = "-/ ";
  		var retStr = "";
  		for(var n = 0; n < str.length; n++)
  		{
  			if (toStrip.indexOf(str.charAt(n)) == -1)
  			{
  				retStr = retStr + str.charAt(n)
  			}
  		}

  		return retStr;
  	}
  	
    function gusipIsPhoneNumber(q) 
    {
      var valid = "0123456789-/ ";
      for(var n = 0; n < q.length; n++)
      {
        if (valid.indexOf(q.charAt(n)) == -1)
        {
          return false;
        }
      }
    
      return true;
    }
    
  	// Searches by phone number
    function gusipSearchByPhone(q)
    {
			document.gusipf.phone_number.value = gusipStripChars(q);
  		submitForm(gusipf);    
    }
    
    // Searches by name
    function gusipSearchByName(q)
    {
		  var params = q.split(",");
		  if( params.length == 1 )
		  {
			  // "firstName lastName"
			  var names = params[0].split(" ");
			  if( names.length < 2 )
  			{
  				return false;
  			}
			
  			document.gusipf.firstname.value = trimWhitespace(names[0]);
  			document.gusipf.lastname.value = trimWhitespace(names[1]);
  			document.gusipf.area.value = "";	
  		}
  		else if( params.length == 2 )
  		{
  			// "firstName lastName, region"
  			var names = params[0].split(" ");
  			if( names.length < 2 )
  			{
  				return false;
  			}
  			
  			document.gusipf.firstname.value = trimWhitespace(names[0]);
  			document.gusipf.lastname.value = trimWhitespace(names[1]);
  			document.gusipf.area.value = trimWhitespace(params[1]);
  		}
  		else
  		{
  			return false;
  		}
	
  		submitForm(gusipf);
	  }
  
    function gusip(q)
    {
    	if( nullArgs("gusip", q) )
      	return false;

  		if ( gusipIsPhoneNumber(q) )
  		{
  			return gusipSearchByPhone(q);
  		}
  		else
  		{
  			return gusipSearchByName(q);
  		}
    }
  ]]></script>
  <copyright>
    The following applies if this file is included and distributed with Dave's Quick Search Deskbar:
    Copyright (c) 2002 David Bau; Distributed under the terms of the GNU Public License, Version 2 (http://www.gnu.org/copyleft/gpl.txt)
  </copyright>
  <created_by>
    This search file was initially created on 05/29/03 at 13:28:14
    by Dave's Quick Search Deskbar Search Wizard version 1.2,
    Copyright (c) 2002 Glenn Carr; Distributed under the terms of the GNU General Public License, Version 2
  </created_by>
</search>