	var pel = null;
	var pbg = null;
	var mthset = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];

	// Writes a line to the end of a debug console window it.
	// if the window isn't open then open it
    var dbgnbr = 0;

	function dbg(msg)
	{
		if (window.logger == null)
		{
			log = window.open("#", "DbgLog", "width=290 height=250 scrollbars resizable", false);
			window.logger = log;
		}
		try
		{
			++dbgnbr;
			doc = window.logger.document;
			line = doc.createTextNode("" + dbgnbr + ": " + msg);
			doc.body.appendChild(line);
			doc.body.appendChild(doc.createElement("BR"));
			window.logger.scroll(0, 9999999);
		}
		catch (e)
		{
			// swallow the error that happens the first time
		}
	}
	// 

	// datetime parsing and formatting routimes. modify them if you wish other datetime format
	function str2dt (strin) 
	{
		var dts;

		try
		{
			dts = strin;
			dts = dts.replace(" ", "");
			dts = dts.replace("\t", "");
			var s1 = dts.indexOf("/");
			var s2 = dts.indexOf("/", s1 + 1);

			var mo = Number(dts.slice(0, s1)) - 1;
			var dy = Number(dts.slice(s1 + 1, s2));
			var yr = Number(dts.substring(s2 + 1));

			return (new Date (yr, mo, dy));
		}
		catch (e)
		{
			return (new Date ());
			return alert("Invalid Date: "+ strin + " - Should be in MM/DD/YYYY form");
		}
	}

	function dt2str (dtin) 
	{
		return (new String ("" + (dtin.getMonth()+1) + "/" + dtin.getDate() + "/" + dtin.getFullYear()));
	}


	function elx(el)
	{
		var x = el.offsetLeft;

		while (el.offsetParent != null)
		{
			el = el.offsetParent;
			x += el.offsetLeft;
		}
		return x;
	}

	function ely(el)
	{
		var y = el.offsetTop;

		while (el.offsetParent != null)
		{
			el = el.offsetParent;
			y += el.offsetTop;
		}
		return y;
	}


	function pickDate(calMode, xp, yp, dfld, rfld)
	{
		top.calShell = caltbl;
		top.depFld = dfld;
		top.retFld = rfld;
		caltbl.style.zIndex = 10000;
		caltbl.style.left = xp;
		caltbl.style.top = yp;
		caltbl.style.visibility = 'visible';

		if (calMode == "D")
			calName = "Depart&nbsp;On";
		else
			calName = "Return&nbsp;On";

		var calurl = "pickdate.html?m=" + calMode + "&t=" + calName + "&d=" + dfld.value + "&r=" + rfld.value;
		calframe.document.location.replace(calurl);
		top.box = calbox;
	}

	function showCal(mode)
	{
		var xp = 350;
		var yp = 350;

		try 
		{
			el = window.event.srcElement;
			xp = elx(el);
			yp = ely(el) + el.offsetHeight;
		}
		catch (e)
		{
			alert("netscape???");
		}
		pickDate(mode, xp, yp, document.RequestAirForm.depDate, document.RequestAirForm.retDate);
	}


	function monthStr(dt)
	{
		return mthset[dt.getMonth()]; 
	}

	function setDepMD()
	{
		try
		{
			var dep = new Date(document.RequestAirForm.depDate.value);
			document.RequestAirForm.depMonth.value = monthStr(dep).toUpperCase();
			document.RequestAirForm.depDay.value = dep.getDate();		
		}
		catch (e)
		{
		}
	}

	function setRetMD()
	{
		try
		{
			var ret = new Date(document.RequestAirForm.retDate.value);
			document.RequestAirForm.retMonth.value = monthStr(ret).toUpperCase();
			document.RequestAirForm.retDay.value = ret.getDate();
		}
		catch (e)
		{
		}
	}


