<search function="virtel">
  <name>Virtual Telescope</name>
  <category>Reference<category>General</category></category>
  <contributor>Gregory Krohne</contributor>
  <link>http://www.fourmilab.ch/yoursky/#Telescope</link>
  <email>zeakz1d02@sneakemail.com</email>
  <description>
  A star map for a given time, date, and aiming point (celestial coordinates). You can also aim at a named planet, star, constellation, or other object in the sky.
    <div class="helpboxDescLabels">Switches:</div>
    <table class="helpboxDescTable">
      <tr><td>/right_ascension|ascension|longitude</td><td> - </td><td>hours, minutes, seconds or decimal degrees</td></tr>
      <tr><td>/declination|latitude</td><td> - </td><td>degrees, minutes, seconds or decimal degrees</td></tr>
      <tr><td>/field|view|fov:degrees</td><td> - </td><td>field of view</td></tr>
      <tr><td>/date|universal:[date,time]</td><td> - </td><td>date/time in universal format</td></tr>
      <tr><td>/julian:number</td><td> - </td><td>date/time in Julian format</td></tr>
      <tr><td>/image|size</td><td> - </td><td>Image width/height in pixels</td></tr>
      <tr><td colspan="3">/colour|color:[colour|color|black|white|night|red]</td></tr>
      <tr><td>/aim_at:name</td><td> - </td><td>Aim at first matching object name</td></tr>
      <tr><td colspan="3">/planet:name</td></tr>
      <tr><td colspan="3">/constellation:name</td></tr>
      <tr><td>/deep_sky:name</td><td> - </td><td>Deep sky objects, like galaxies and nebulae</td></tr>
      <tr><td>/nonstellar|messier:name</td><td> - </td><td>The M# non-stellar objects</td></tr>
      <tr><td colspan="3">/meteor|shower:name</td></tr>
      <tr><td colspan="3">/star:name</td></tr>
      <tr><td colspan="3">/comet:name</td></tr>
    </table>
    <div class="helpboxDescLabels">Examples:</div>
    <table class="helpboxDescTable">
      <tr><td>virtel 0 90 45</td></tr>
      <tr><td> - pointed at Polaris, which is due North</td></tr>
      <tr><td>virtel /right:6h45m9.6s /dec:-16d42m34s /fov:20d</td></tr>
      <tr><td> - Sirius, the dog star</td></tr>
      <tr><td>virtel /right:14h24m /dec:-10d30m /date:[2000-01-01,00:00:00]</td></tr>
      <tr><td> - the Moon at the turn of the century</td></tr>
      <tr><td>virtel /const:cass /color:night /size:1024</td></tr>
      <tr><td> - large, red (night vision) map of constellation Cassiopeia</td></tr>
      <tr><td>virtel /aim:halley /color:color</td></tr>
      <tr><td> - color map of Halley's Comet</td></tr>
    </table>
  </description>
  <form name="virtelf"
        method="post"
        action="http://www.fourmilab.ch/cgi-bin/uncgi/Yourtel">
		<input type="hidden" name="date" value="0"/>
    <input type="hidden" name="utc" value="2000-01-01 12:00:00" />
    <input type="hidden" name="jd" value="2451545.00000" />
    <input type="hidden" name="lon" value="0h" />
    <input type="hidden" name="lat" value="0°" />
    <input type="hidden" name="ns" value="North" />
    <input type="hidden" name="fov" value="45°" />
    <input type="hidden" name="coords" value="on" />
    <input type="hidden" name="moonp" value="on" />
    <input type="hidden" name="deep" value="on" />
    <input type="hidden" name="deepm" value="6.5" />
    <input type="hidden" name="consto" value="on" />
    <input type="hidden" name="constn" value="on" />
    <input type="hidden" name="constb" value="on" />
    <input type="hidden" name="limag" value="6.5" />
    <input type="hidden" name="starn" value="on" />
    <input type="hidden" name="starnm" value="3.5" />
    <input type="hidden" name="starb" value="on" />
    <input type="hidden" name="starbm" value="4.0" />
    <input type="hidden" name="showm" value="" />
    <input type="hidden" name="showmb" value="-1.5" />
    <input type="hidden" name="showmd" value="6.0" />
    <input type="hidden" name="flip" value="on" />
    <input type="hidden" name="imgsize" value="512" />
    <input type="hidden" name="scheme" value="0" />
    <input type="hidden" name="edump" value="-xe" />
    <input type="hidden" name="elements" value="" />
  </form>
  <script><![CDATA[
    function virtel(q)
    {
      if( nullArgs("virtel", q) )
        return;
			
			var cont = true;

      // Parse switches with parseArgs:
      var args = parseArgs(q, "right_ascension, ascension, declination, latitude, longitude, field, view, fov, date, image, size, colour, color, julian, universal, planet, constellation, deep_sky, meteor, shower, star, comet, nonstellar, non-stellar, messier, aim_at");
      for (var iSwitch = 0; iSwitch < args.switches.length; iSwitch++)
      {
        switch( args.switches[iSwitch].name )
        {
          case "right_ascension":
          case "ascension":
          case "longitude":
						document.virtelf.lon.value = args.switches[iSwitch].value;
						break;
          case "declination":
          case "latitude":
						document.virtelf.lat.value = args.switches[iSwitch].value;
            break;
          case "field":
          case "view":
					case "fov":
						document.virtelf.fov.value = args.switches[iSwitch].value;
            break;
          case "date":
					case "universal":
						// Parse out the date/time portion, however it was enclosed
						var pattern = /\d+[\/-]\d+[\/-]\d+[\D\d+:\d+[:\d+]?]?/;
						var result = args.switches[iSwitch].value.match(pattern);
						if (result != null) {
							document.virtelf.utc.value = result[0];
							document.virtelf.date.value = "1";
						}
						break;
          case "image":
          case "size":
						document.virtelf.imgsize.value = args.switches[iSwitch].value;
            break;
          case "colour":
          case "color":
						switch( args.switches[iSwitch].value.toLowerCase() )
						{
							case "black":
							case "b":
								document.virtelf.scheme.value = "1";
								break;
							case "white":
							case "w":
								document.virtelf.scheme.value = "2";
								break;
							case "night":
							case "n":
							case "red":
							case "r":
								document.virtelf.scheme.value = "3";
								break;
							default:
								document.virtelf.scheme.value = "0";
								break;
						}
            break;
          case "julian":
						document.virtelf.date.value = "2";
						document.virtelf.jd.value = args.switches[iSwitch].value;
						break;
						
          case "planet":
						if ( isEarth ( args.switches[iSwitch].value ) )
						// isEarth opens its own SearchWindow if it finds a match
							cont = false;
						else 
							cont = getPlanet( args.switches[iSwitch].value );
            break;
						
          case "constellation":
						cont = getConstellation( args.switches[iSwitch].value );
            break;
						
          case "deep_sky":
						cont = getDeepSky( args.switches[iSwitch].value );
            break;
						
          case "meteor":
          case "shower":
						cont = getMeteorShower( args.switches[iSwitch].value );
            break;
						
          case "star":
						cont = getStar( args.switches[iSwitch].value );
            break;
						
          case "comet":
						getComet( args.switches[iSwitch].value );
						// getComet opens its own SearchWindow if it finds a match
						cont = false;
            break;
					
					case "non-stellar":
					case "nonstellar":
					case "messier":
						cont = getNonStellar (args.switches[iSwitch].value );
						break;
						
					case "aim_at":
						cont = getAnything( args.switches[iSwitch].value );
						break;
						
          default:
            break;
						
        }
      }
			
			if ( args.q ) {
				var parsed = args.q.split(/ /);
				document.virtelf.lon.value = parsed[0];
				if (parsed[1])
					document.virtelf.lat.value = parsed[1];
				if (parsed[2])
				document.virtelf.fov.value = parsed[2];
			}


      if ( cont ) submitForm( virtelf );
    }
		
		function isEarth( strTarget ) {
			if (strTarget.match(/earth/i) ) {
				openSearchWindow( "http://www.fourmilab.ch/cgi-bin/uncgi/Earth/action?opt=-s" );
				return true;
			}
			
			return false;
		}
		
		function getPlanet(strTarget, quiet) {
			
			var strURL = "http://www.fourmilab.ch/yoursky/catalogues/planets.html";

			// get the target from the list
			var objXmlHttp = new ActiveXObject("Microsoft.XmlHttp");
			objXmlHttp.open("GET", strURL, false);
			objXmlHttp.send();
			
			var strBody = objXmlHttp.responseText;
			
			// parse out the target we want
			var objRegExp = new RegExp(
					'<a href="http:/cgi-bin/uncgi/Yourtel(.*)">.*'
					+ strTarget
					+ '.*</a>', "i");
			var aResult = objRegExp.exec( strBody );
			
			if (aResult != null)
			{
				document.virtelf.action = "http://www.fourmilab.ch/cgi-bin/uncgi/Yourtel" + aResult[1];
				return true;
			} else if ( ! quiet ) {
				setSearchWindowText( "Planet [" + strTarget + "] not found" );
				openSearchWindow(strURL);
			}
			
			return false;
				
		}
		
		function getConstellation( strTarget, quiet) {
			var strURL = "http://www.fourmilab.ch/yoursky/catalogues/constellations.html";
			var strRegExp =
				'<a href="/cgi-bin/uncgi/Yourtel\\?lat=(.*)&lon=(.*)&z=1">.*'
				+ strTarget
				+ '.*</a>';

			return getObject( strTarget, strURL, strRegExp, "Constellation", quiet );

		}
		
		function getDeepSky( strTarget, quiet ) {
			var strURL = "http://www.fourmilab.ch/yoursky/catalogues/deepsky.html";
			var strRegExp =
				'<a href="/cgi-bin/uncgi/Yourtel\\?lat=(.*)&lon=(.*)&z=1&deepm=(.*)">.*'
				+ strTarget
				+ '.*</a>';

			return getObject( strTarget, strURL, strRegExp, "Deep Sky object", quiet );

		}
		
		function getStar( strTarget, quiet ) {
			var strURL = "http://www.fourmilab.ch/yoursky/catalogues/starname.html";
			var strRegExp = 
					'<a href="/cgi-bin/uncgi/Yourtel\\?lat=(.*)&lon=(.*)&z=1">.*'
					+ strTarget
					+ '.*</a>';

			return getObject( strTarget, strURL, strRegExp, "Star", quiet );

		}
		
		function getMeteorShower( strTarget, quiet ) {
			var strURL = "http://www.fourmilab.ch/yoursky/catalogues/meteor.html";
			var strRegExp = 
					'<a href="/cgi-bin/uncgi/Yourtel\\?lat=(.*)&lon=(.*)&z=1">.*'
					+ strTarget
					+ '.*</a>';

			return getObject( strTarget, strURL, strRegExp, "Meteor Shower", quiet );

		}
		
		function getObject( strTarget, strURL, strRegExp, strObjectType, quiet ) {
			if ( getLocation( strURL, strRegExp ) )
				return true;
			else if ( ! quiet ) {
				setSearchWindowText( strObjectType + " [" + strTarget + "] not found" );
				openSearchWindow(strURL);
			}
			
			return false;
		}
				

		function getNonStellar( strTarget, quiet ) {
			
			var strURL = "http://www.fourmilab.ch/yoursky/catalogues/messier.html";
			var strRegExp = 
					'<a href="/cgi-bin/uncgi/Yourtel\\?lat=(.*)&lon=(.*)&z=1&deepm=(.*)">.*'
					+ strTarget
					+ '.*</a>';
				
			return getObject( strTarget, strURL, strRegExp, "Non-stellar object", quiet );
				
		}
		
		function getComet( strTarget, quiet ) {
			
			var strURL = "http://www.fourmilab.ch/yoursky/catalogues/periodic_comets.html";
			var strRegExp = 
					'Yourtel(.*)">.*'
					+ strTarget
					+ '.*</a>';
				
			// get the target from the list
			var objXmlHttp = new ActiveXObject("Microsoft.XmlHttp");
			objXmlHttp.open("GET", strURL, false);
			objXmlHttp.send();
			
			var strBody = objXmlHttp.responseText;
			
			// parse out the target we want
			var objRegExp = new RegExp(strRegExp, "i");
			var aResult = objRegExp.exec(strBody);
			
			if (aResult != null)
			{
				openSearchWindow("http://www.fourmilab.ch/cgi-bin/uncgi/Yourtel" + aResult[1]);
				return true;
			} else if ( ! quiet ) {
				setSearchWindowText( "Comet [" + strTarget + "] not found" );
				openSearchWindow(strURL);
			}
			
			return false;	
				
		}
		
		function getAnything(strTarget) {
			
			if ( isEarth( strTarget ) )
				return false;
			if ( getPlanet( strTarget, true ) )			
				return true;
			else if ( getStar( strTarget, true ) )
				return true;
			else if ( getConstellation( strTarget, true ) )
				return true;
			else if ( getDeepSky( strTarget, true ) )
				return true;
			else if ( getNonStellar( strTarget, true ) )
				return true;
			else if ( getComet( strTarget, true ) )
				return false;
			else if ( getMeteorShower( strTarget, true ) )
				return true;
			else {
				setSearchWindowText( "Object [" + strTarget + "] not found" );
				openSearchWindow( "http://www.fourmilab.ch/yoursky/catalogues/catalogues.html" );
			}

			return false;
				
		}
		
		
		function getLocation(strURL, strRegExp) {
			
			// get the target from the list
			var objXmlHttp = new ActiveXObject("Microsoft.XmlHttp");
			objXmlHttp.open("GET", strURL, false);
			objXmlHttp.send();
			
			var strBody = objXmlHttp.responseText;
			
			// parse out the target we want
			var objRegExp = new RegExp(strRegExp, "i");
			var aResult = objRegExp.exec(strBody);
			
			if (aResult != null)
			{
				if (aResult[1])
					document.virtelf.lat.value = aResult[1];
				if (aResult[2])
					document.virtelf.lon.value = aResult[2];
				if (aResult[3])
					document.virtelf.deepm.value = aResult[3];
				return true;
			}
			
			return false;
				
		}
		
		]]></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 08/19/04 at 11:13:04
    by Dave's Quick Search Deskbar Search Wizard version 1.3,
    Copyright (c) 2002 Glenn Carr; Distributed under the terms of the GNU General Public License, Version 2
  </created_by>
</search>
