var aDay = 86400000;
var past_date = new Date();
past_date = new Date(past_date.valueOf() - aDay);
//<!--
var local_server_position = "us";
function ss(w){window.status=w;return true;}
function cs(){window.status='';}
function ga(l){if (l) location.href=l;}
function enabled_searchDateOption(clicked, type)
{
	var f = document.getElementById(type);
	var workRange;
	if (type == "SoldSearch")
	{
		workRange = new Array("FromMonth", "FromDate", "FromYear", "ToMonth", "ToDate", "ToYear");
	}
	else if (type == "BookingSearch")
	{
		workRange = new Array("Month", "Date", "Year");
	}
	if (workRange)
	{
		f['searchByBar'].disabled = !clicked;
		for (i=0; i<workRange.length; i++)
		{
			f[workRange[i]].disabled = clicked;
		}
	}
}	

function Device_OnLoad()
{
	if (navigator.userAgent.indexOf("Windows CE") != -1) 
	{
		window.location="http://www.gotobus.com/palm.html";
	}
}

function Vendor_onLoad(sold, booking)
{
	var s  = document.getElementById('SoldSearch');
	var b = document.getElementById('BookingSearch');
	if (s)
	{
		enabled_searchDateOption(sold, 'SoldSearch');
	}
	if (b)
	{
		enabled_searchDateOption(booking, 'BookingSearch');
	}
}

function opener_url(url)
{
        var target = window;
        if (window.opener != null && window.opener.closed == false)
        {
                target = window.opener;
        }
        target.location.href=url;
        target.focus();
        return false;
}


function open_url_param(url, date)
{
	var lnk = url;
	if (date != "")
	{
		if (lnk.match(/\?/))
		{
			lnk += "&d="+date;
		}
		else
		{
			lnk += "?"+date;
		}
	}
	opener_url(lnk);
}

function set_gid_cookie(value, expires)
{
	var name = "gid";
    var today = new Date();
    today.setTime(today.getTime());
    if (!expires)
    {
    	expires = 7;
    }
    expires = expires * 1000 * 60 * 60 * 24;
    var expires_date = new Date(today.getTime() + expires);
    document.cookie = name + "=" +escape(value) + (expires ? ";expires=" + expires_date.toGMTString() : "") + ";path=/;domain=gotobus.com";
}

function pre_set_data()
{
	var date = null;
	if (window.location.search.length>0)
	{
		data = window.location.search.substring(1);
		if (data.match(/-/))
		{
			var s  = document.getElementById('Date');
			set_tour_date (s, data);
		}
		else
		{
			set_gid_cookie(data);
		}
	}
}


function pre_set_date()
{
	var date = null;
	if (window.location.search.length>0)
	{
		date = window.location.search.substring(1);
		var s  = document.getElementById('Date');
		set_tour_date (s, date);
	}
}

function set_tour_date(obj, selected_date)
{
	if (obj == null || selected_date == null || selected_date == "")
	{
		return;
	}

	var sdate = selected_date.substr(0, 10);
	for (var i=0; i< obj.options.length; i++)
	{
		var val = obj.options[i].value;
		if (val != "")
		{
			val = val.substr(0,10);
			if (sdate.match(val))
			{
				obj.options.selectedIndex = i;
				return;
			}
		}
	}
}

function OnCalendarClick()
{
        window.open("http://www.gotobus.com/calendar/calendar.html", "calendar", 'width=240,height=200');
}

var browser = window.navigator.appName;
var isIE = false;
var Win = navigator.userAgent.indexOf("Win") > -1;
var MSIE = navigator.appName == "Microsoft Internet Explorer";

if (Win && MSIE)
{
    var n = navigator.userAgent;
    var MSIEVer = n.substr(n.indexOf("MSIE ")+("MSIE ").length, 4);
    MSIEVer = parseFloat(MSIEVer); 
    if (MSIEVer > 5.0)
	isIE = true;
}

function addToFavorites(url, title)
{
    if (window.external)
    {
        window.external.AddFavorite(url, title)
    }
    else
    { 
        alert("Sorry! Your browser doesn't support this function.");
    }
}

var d_about_up = "http://www.gotobus.com/images/explore_up.gif";
var d_about_down = "http://www.gotobus.com/images/explore_down.gif";
function changeImage_aboutus()
{
    if (document.images) {
        if (document.myImage_aboutus.src == d_about_up)
            document.myImage_aboutus.src = d_about_down;
        else
            document.myImage_aboutus.src = d_about_up;
    }
}

function SwitchMenu(obj)
{
    if(document.getElementById) {
        var el = document.getElementById(obj);
        if(el.style.display != "block")
            el.style.display = "block";
        else
            el.style.display = "none";
        changeImage_aboutus();
    }
}

function set_selected(obj, v)
{
    for (var i=0; i<obj.options.length; i++)
    {
        if (obj.options[i].value == v)
        {
            obj.options.selectedIndex = i;
            return i;
        }
    }
    return -1;
}

function clear_show_all_text(obj)
{
        if (obj && obj.value == "Show All")
        {
                obj.value = "";
        }
}

function set_cookie(name, value, expires) 
{
    var today = new Date();
    today.setTime(today.getTime());
    if (expires)
    {
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date(today.getTime() + expires);
    document.cookie = name + "=" +escape(value) + (expires ? ";expires=" + expires_date.toGMTString() : "") + ";path=/;domain=gotobus.com";
}

function get_cookie(name)
{
    var start = document.cookie.indexOf( name + "=" );
    var len = start + name.length + 1;
    if ((!start) && (name != document.cookie.substring(0, name.length)))
    {
        return null;
    }
    if (start == -1) return null;
    var end = document.cookie.indexOf(";", len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len, end));
}

function Trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function viewSavedTrips()
{
	make_unvisible();
    var savedBlock=document.getElementById("savedBlock");
    if(!savedBlock){
        savedBlock = document.createElement("div");
        savedBlock.id = "savedBlock";
    }
    savedBlock.innerHTML="";  
    var light_top = document.body.scrollTop + (document.body.clientHeight - 230)/2;
	var light_left = document.body.scrollLeft + (document.body.clientWidth - 420)/2;
	light_top = light_top + "px";
	light_left = light_left + "px";
	savedBlock.style.left = light_left;
	savedBlock.style.top = light_top;
	savedBlock.className = "top_div";		
    var param = "type=find_saved_trip";
    var compare_xml;
    if(window.XMLHttpRequest) {
        compare_xml = new XMLHttpRequest();
    } else {
        compare_xml = new ActiveXObject("MSXML2.XMLHTTP");
    }
    url = '/cgi-bin/ajax.cgi?' + param;
    compare_xml.open("GET", url, true);
    compare_xml.onreadystatechange = function show_div()
    {
        if (compare_xml.readyState == 4)
        {
            var showResponseText=compare_xml.responseText;
            savedBlock.innerHTML=showResponseText;   
        }
    };
    compare_xml.setRequestHeader("If-Modified-Since","0");
    compare_xml.send("");
    document.body.appendChild(savedBlock);
    var fadeBlock=document.getElementById("fadeBlock");
    if(!fadeBlock){
        var fadeBlock = document.createElement("div");
        fadeBlock.id="fadeBlock";
    }
    fadeBlock.style.height = document.body.scrollHeight;
	fadeBlock.style.width = document.body.scrollWidth;
    fadeBlock.className="bg_div";   
    document.body.appendChild(fadeBlock);
    savedBlock.style.display='block';
    fadeBlock.style.display='block';
}
function hideDiv(tag, fade)
{
	make_visible();
	var light=document.getElementById(tag);
	var fade=document.getElementById(fade);
	light.style.display='none';
	fade.style.display='none';
	if($('compare_page') && $('compare_page').value !=get_count())
	{

		pageRefresh();
	}
}

function  make_unvisible(){
	var as = document.getElementsByTagName("select");
	if(as !=null && as.length>0){
		for(var i=0; i < as.length; i++) {
			as[i].style.visibility="hidden";
		}
	}
}
function  make_visible(){
	var as = document.getElementsByTagName("select");
	if(as !=null && as.length>0){
		for(var i=0; i < as.length; i++) {
			as[i].style.visibility="visible";
		}
	}
}

function show_link(value) {
	if(value) {
		var currentValue = get_cookie('SAVED_TRIPS');
		if(!currentValue)
		{
			currentValue="";
		}
		var exists = currentValue.indexOf(value);
		var link_div = $(value+'_a');
		if(link_div)
		{
			if(exists == -1){
				link_div.innerHTML="<img src='/images/ico_add2compare.gif'/><a href='javascript:void(0)' class='link1' title='Save Tour to Compare' onclick='saveToCookie(" + value+ ");'>Save Tour</a>";
			} else {
				link_div.innerHTML="<img src='/images/ico_add2compare1.gif'/><a href='javascript:void(0)' class='link1' title='Tour Saved'>Saved</a><br>" + 
				"<img src='/images/ico_viewcompare.gif'/><a href='http://www.gotobus.com/cgi-bin/v.cgi?a=product_compare' class='link1' title='Compare Tours' class='link1'>Compare</a>";
			}
		}
		showDetailSaveLink(value);
	}
}

function $() {
	return document.getElementById(arguments[0]);
}

function saveToCookie(value) {
	if(value) {
		var currentValue = get_cookie('SAVED_TRIPS');
		if(!currentValue)
		{
			currentValue = "";
		}
		var exists = currentValue.indexOf(value);
		if(exists == -1) {
			if(currentValue.length == 0) {
				var newValue = value;
			} else {
				var newValue = currentValue + "," + value;
			}				
			set_cookie('SAVED_TRIPS',newValue,7);
		}
	}
	updateSavedTrip(value);
}

function updateSavedTrip(value) {
	show_count();
	show_link(value);
}	

function removeChildNodes() {
	var a = (typeof arguments[0] == "string") ? $(arguments[0]) : arguments[0];
	while ( a.hasChildNodes() ) {
		a.removeChild(a.childNodes[0]);
	}
}

function removeFromCookie(obj,value) {
	if(value) {
		document.body.style.cursor = "wait";
		var currentValue = get_cookie('SAVED_TRIPS');
		var exists = currentValue.indexOf(value);			
		if(exists != -1){
			if(currentValue.indexOf("," + value) != -1) {
				var newValue = currentValue.replace("," + value,"");
			} else if(currentValue.indexOf(value + ",") != -1) {
				var newValue = currentValue.replace(value + ",","");
			} else {
				var newValue = currentValue.replace(value,"");
			}
			set_cookie('SAVED_TRIPS',newValue,7);
		} 
		this.updateRemovedTrip(obj,value);
		document.body.style.cursor = "auto";
	}
}

function updateRemovedTrip(obj,value) {
	var tdParent = obj.parentNode;
	var trParent = tdParent.parentNode;
	var tblParent = trParent.parentNode;		 	
	tblParent.removeChild(trParent);
	show_count();
	show_link(value);
}

function show_count() {
	var count = get_count();
	var stLink = $('saved_trip_count');
	if(stLink){
		removeChildNodes(stLink);
		stLink.appendChild(document.createTextNode(count));
	}
	var div_count = $('div_saved_trip_count');
	if(div_count){
		removeChildNodes(div_count);
		div_count.appendChild(document.createTextNode(count));
	}
}

function get_count() {
	var currentValue = get_cookie('SAVED_TRIPS');
	var count = 0;
	if(currentValue && currentValue.length != 0)
	{
		count = currentValue.split(',').length;
	}
	return count;
}
function pageRefresh()
{
	window.location.reload();
}

function showDetailSaveLink(value) {
	if(value) {
		var currentValue = get_cookie('SAVED_TRIPS');
		if(!currentValue)
		{
			currentValue="";
		}
		var exists = currentValue.indexOf(value);
		var link_div = $("detail_save_link");
		if(link_div)
		{
			if(exists == -1){
				link_div.innerHTML="<img src='/images/ico_add2compare.gif'/><a href='javascript:void(0)' class='link1' title='Save Tour to Compare' onclick='saveToCookie(" + value+ ");'>Save Tour</a>";
			} else {
				link_div.innerHTML="<img src='/images/ico_add2compare1.gif'/><a href='javascript:void(0)' class='link1' title='Tour Saved'>Tour Saved</a>";
			}
		}
	}
}
function setTabInit(name,cursel,n){
	for(i=1;i<=n;i++){
	var menu=document.getElementById(name+i);
	  var con=document.getElementById("con_"+name+"_"+i);
	  menu.className=i==cursel?"hover":"";
	  con.style.display=i==cursel?"block":"none";
	}
	if (cursel == 1)
	{
		document.getElementById("con_one_2").style.display="block";
	}
}
function product_onload()
{
	var current_no=document.getElementById("month_current_div");
	if(current_no != null && current_no != "")
	{
		document.getElementById("month_current_div").value=1;
	}
	urlvalue=document.location.href;
	if(urlvalue.match(/(.+)#write$/)!= null){
		setTabInit('one',5,5);
	}
}
function show_hide_image_div(obj,nth_day)
{
	var image_div=$("add_images_div_"+nth_day);
	if(image_div.style.display == "block")
	{
		obj.src="/images/add_image.gif";
		image_div.innerHTML = "";
		image_div.style.display="none";
	}
	else
	{
		obj.src="/images/reduce_image.gif";
		image_div.innerHTML=$("serach_image_hidden_div").innerHTML;
		var inputs = image_div.getElementsByTagName("input"); 
		var selects = image_div.getElementsByTagName("select"); 
		var destination = selects[0];
		var divs = image_div.getElementsByTagName("div"); 
		var div = divs[0];
		var keywords;
		var search_button;
		for(var i=0;i<inputs.length;i++)
		{
			if(inputs[i].name=="keywords")
			{
				keywords = inputs[i];
			}					
			if(inputs[i].type=="button")
			{
				search_button = inputs[i];
			}
		}
		var product = $("product_id");
		search_button.onclick =  function(){
			var param = "type=search_images&keywords="+keywords.value+"&destination="+destination.value+"&product_id="+product.value+"&nth_day="+nth_day;
			var search_xml;
		    if(window.XMLHttpRequest) {
		        search_xml = new XMLHttpRequest();
		    } else {
		        search_xml = new ActiveXObject("MSXML2.XMLHTTP");
		    }
		    var url = '/cgi-bin/ajax.cgi?' + param;
		    search_xml.open("GET", url, true);
		    search_xml.onreadystatechange = function show_div()
		    {
		        if (search_xml.readyState == 4)
		        {
		            var rt_text=search_xml.responseText;
		            div.innerHTML = "";
		            div.innerHTML = rt_text;
		        }
		    };
		    search_xml.setRequestHeader("If-Modified-Since","0");
		    search_xml.send("");					
		};
		image_div.style.display="block";
	}
}
function removeThisNode(spanname,nth_day) {
	var position = spanname.lastIndexOf("_");
	var image_id = spanname.substring(position+1,spanname.length);
	var image_ids_obj = $("image_ids_"+nth_day);
	var image_ids = image_ids_obj.value;
	image_ids=image_ids.replace(","+image_id+",",",");
	image_ids_obj.value=image_ids;
	var obj = $(spanname);
	var objParent = obj.parentNode;	 	
	objParent.removeChild(obj);
	if(image_ids == ",")
	{
		var message = document.createElement("span");
		message.innerHTML="<img src='/images/logo/nophoto.gif' title='No image' width='70px' height='55px'/>";
		objParent.appendChild(message);
	}
}
function appendToImage(obj,spanname,nth_day) {
	var position = spanname.lastIndexOf("_");
	var image_id = spanname.substring(position+1,spanname.length);
	var image_ids_obj = $("image_ids_"+nth_day);
	var image_ids = image_ids_obj.value;
	var exists = image_ids.indexOf(","+image_id+",");
	if(exists >= 0){
		alert("The image already exists!");
		obj.src='/images/already_add.gif';
		obj.onclick=function(){};
	    obj.onmouseover=function(){};
	    obj.onmouseout=function(){};
	    return;
	}
	var div = $("image_show_div_"+nth_day);
	if(image_ids == ",")
	{
		var message = div.getElementsByTagName("span")[0];
		div.removeChild(message);
	}
	image_ids_obj.value = image_ids + image_id + ",";
	var objParent = obj.parentNode;	
	var simg = objParent.childNodes[0];
	var img = simg.cloneNode(false);
	img.onclick=function(){};
	var imageObj = document.createElement("span");
	imageObj.setAttribute('name', spanname);
	imageObj.setAttribute('id', spanname);
    imageObj.appendChild(img);
   	var delImag = document.createElement("img");
   	delImag.src="/images/ico_tr_del.gif";
   	delImag.className="delete_image";
	delImag.setAttribute('title', "Delete");
   	delImag.onmouseover= function(){this.src='/images/ico_tr_delover.gif';};
   	delImag.onmouseout= function(){this.src='/images/ico_tr_del.gif';};
    delImag.onclick= function(){removeThisNode(spanname,nth_day)};
    imageObj.appendChild(delImag);
    div.appendChild(imageObj);
    obj.src='/images/already_add.gif';
    obj.onclick=function(){};
    obj.onmouseover=function(){};
    obj.onmouseout=function(){};
}
function getPhotoDiv(obj)
{
	var parNode = obj.parentNode;
	var divNode = parNode.getElementsByTagName("div");
	return divNode[0];	
}
function appendToImageByImage(obj,spanname,nth_day)
{
	var parNode = obj.parentNode;
	var imgNode = parNode.getElementsByTagName("img");
	var add_button = imgNode[1];
	appendToImage(add_button,spanname,nth_day);
}


//-->

// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

/* SOURCE FILE: AnchorPosition.js */
function getAnchorPosition(anchorname){var useWindow=false;var coordinates=new Object();var x=0,y=0;var use_gebi=false, use_css=false, use_layers=false;if(document.getElementById){use_gebi=true;}else if(document.all){use_css=true;}else if(document.layers){use_layers=true;}if(use_gebi && document.all){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_gebi){var o=document.getElementById(anchorname);x=AnchorPosition_getPageOffsetLeft(o);y=AnchorPosition_getPageOffsetTop(o);}else if(use_css){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_layers){var found=0;for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==anchorname){found=1;break;}}if(found==0){coordinates.x=0;coordinates.y=0;return coordinates;}x=document.anchors[i].x;y=document.anchors[i].y;}else{coordinates.x=0;coordinates.y=0;return coordinates;}coordinates.x=x;coordinates.y=y;return coordinates;}
function getAnchorWindowPosition(anchorname){var coordinates=getAnchorPosition(anchorname);var x=0;var y=0;if(document.getElementById){if(isNaN(window.screenX)){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else{x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}}else if(document.all){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else if(document.layers){x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}coordinates.x=x;coordinates.y=y;return coordinates;}
function AnchorPosition_getPageOffsetLeft(el){var ol=el.offsetLeft;while((el=el.offsetParent) != null){ol += el.offsetLeft;}return ol;}
function AnchorPosition_getWindowOffsetLeft(el){return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;}
function AnchorPosition_getPageOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent) != null){ot += el.offsetTop;}return ot;}
function AnchorPosition_getWindowOffsetTop(el){return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;}

/* SOURCE FILE: date.js */
var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x){return(x<0||x>9?"":"0")+x}
function isDate(val,format){var date=getDateFromFormat(val,format);if(date==0){return false;}return true;}
function compareDates(date1,dateformat1,date2,dateformat2){var d1=getDateFromFormat(date1,dateformat1);var d2=getDateFromFormat(date2,dateformat2);if(d1==0 || d2==0){return -1;}else if(d1 > d2){return 1;}return 0;}
function formatDate(date,format){format=format+"";var result="";var i_format=0;var c="";var token="";var y=date.getYear()+"";var M=date.getMonth()+1;var d=date.getDate();var E=date.getDay();var H=date.getHours();var m=date.getMinutes();var s=date.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;var value=new Object();if(y.length < 4){y=""+(y-0+1900);}value["y"]=""+y;value["yyyy"]=y;value["yy"]=y.substring(2,4);value["M"]=M;value["MM"]=LZ(M);value["MMM"]=MONTH_NAMES[M-1];value["NNN"]=MONTH_NAMES[M+11];value["d"]=d;value["dd"]=LZ(d);value["E"]=DAY_NAMES[E+7];value["EE"]=DAY_NAMES[E];value["H"]=H;value["HH"]=LZ(H);if(H==0){value["h"]=12;}else if(H>12){value["h"]=H-12;}else{value["h"]=H;}value["hh"]=LZ(value["h"]);if(H>11){value["K"]=H-12;}else{value["K"]=H;}value["k"]=H+1;value["KK"]=LZ(value["K"]);value["kk"]=LZ(value["k"]);if(H > 11){value["a"]="PM";}else{value["a"]="AM";}value["m"]=m;value["mm"]=LZ(m);value["s"]=s;value["ss"]=LZ(s);while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(value[token] != null){result=result + value[token];}else{result=result + token;}}return result;}
function _isInteger(val){var digits="1234567890";for(var i=0;i < val.length;i++){if(digits.indexOf(val.charAt(i))==-1){return false;}}return true;}
function _getInt(str,i,minlength,maxlength){for(var x=maxlength;x>=minlength;x--){var token=str.substring(i,i+x);if(token.length < minlength){return null;}if(_isInteger(token)){return token;}}return null;}
function getDateFromFormat(val,format){val=val+"";format=format+"";var i_val=0;var i_format=0;var c="";var token="";var token2="";var x,y;var now=new Date();var year=now.getYear();var month=now.getMonth()+1;var date=1;var hh=now.getHours();var mm=now.getMinutes();var ss=now.getSeconds();var ampm="";while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(token=="yyyy" || token=="yy" || token=="y"){if(token=="yyyy"){x=4;y=4;}if(token=="yy"){x=2;y=2;}if(token=="y"){x=2;y=4;}year=_getInt(val,i_val,x,y);if(year==null){return 0;}i_val += year.length;if(year.length==2){if(year > 70){year=1900+(year-0);}else{year=2000+(year-0);}}}else if(token=="MMM"||token=="NNN"){month=0;for(var i=0;i<MONTH_NAMES.length;i++){var month_name=MONTH_NAMES[i];if(val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()){if(token=="MMM"||(token=="NNN"&&i>11)){month=i+1;if(month>12){month -= 12;}i_val += month_name.length;break;}}}if((month < 1)||(month>12)){return 0;}}else if(token=="EE"||token=="E"){for(var i=0;i<DAY_NAMES.length;i++){var day_name=DAY_NAMES[i];if(val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()){i_val += day_name.length;break;}}}else if(token=="MM"||token=="M"){month=_getInt(val,i_val,token.length,2);if(month==null||(month<1)||(month>12)){return 0;}i_val+=month.length;}else if(token=="dd"||token=="d"){date=_getInt(val,i_val,token.length,2);if(date==null||(date<1)||(date>31)){return 0;}i_val+=date.length;}else if(token=="hh"||token=="h"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>12)){return 0;}i_val+=hh.length;}else if(token=="HH"||token=="H"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>23)){return 0;}i_val+=hh.length;}else if(token=="KK"||token=="K"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>11)){return 0;}i_val+=hh.length;}else if(token=="kk"||token=="k"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>24)){return 0;}i_val+=hh.length;hh--;}else if(token=="mm"||token=="m"){mm=_getInt(val,i_val,token.length,2);if(mm==null||(mm<0)||(mm>59)){return 0;}i_val+=mm.length;}else if(token=="ss"||token=="s"){ss=_getInt(val,i_val,token.length,2);if(ss==null||(ss<0)||(ss>59)){return 0;}i_val+=ss.length;}else if(token=="a"){if(val.substring(i_val,i_val+2).toLowerCase()=="am"){ampm="AM";}else if(val.substring(i_val,i_val+2).toLowerCase()=="pm"){ampm="PM";}else{return 0;}i_val+=2;}else{if(val.substring(i_val,i_val+token.length)!=token){return 0;}else{i_val+=token.length;}}}if(i_val != val.length){return 0;}if(month==2){if( ((year%4==0)&&(year%100 != 0) ) ||(year%400==0) ){if(date > 29){return 0;}}else{if(date > 28){return 0;}}}if((month==4)||(month==6)||(month==9)||(month==11)){if(date > 30){return 0;}}if(hh<12 && ampm=="PM"){hh=hh-0+12;}else if(hh>11 && ampm=="AM"){hh-=12;}var newdate=new Date(year,month-1,date,hh,mm,ss);return newdate.getTime();}
function parseDate(val){var preferEuro=(arguments.length==2)?arguments[1]:false;generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');var d=null;for(var i=0;i<checkList.length;i++){var l=window[checkList[i]];for(var j=0;j<l.length;j++){d=getDateFromFormat(val,l[j]);if(d!=0){return new Date(d);}}}return null;}

/* SOURCE FILE: PopupWindow.js */
function PopupWindow_getXYPosition(anchorname){var coordinates;if(this.type == "WINDOW"){coordinates = getAnchorWindowPosition(anchorname);}else{coordinates = getAnchorPosition(anchorname);}this.x = coordinates.x;this.y = coordinates.y;}
function PopupWindow_setSize(width,height){this.width = width;this.height = height;}
function PopupWindow_populate(contents){this.contents = contents;this.populated = false;}
function PopupWindow_setUrl(url){this.url = url;}
function PopupWindow_setWindowProperties(props){this.windowProperties = props;}
function PopupWindow_refresh(){if(this.divName != null){if(this.use_gebi){document.getElementById(this.divName).innerHTML = this.contents;}else if(this.use_css){document.all[this.divName].innerHTML = this.contents;}else if(this.use_layers){var d = document.layers[this.divName];d.document.open();d.document.writeln(this.contents);d.document.close();}}else{if(this.popupWindow != null && !this.popupWindow.closed){if(this.url!=""){this.popupWindow.location.href=this.url;}else{this.popupWindow.document.open();this.popupWindow.document.writeln(this.contents);this.popupWindow.document.close();}this.popupWindow.focus();}}}
function PopupWindow_showPopup(anchorname){this.getXYPosition(anchorname);this.x += this.offsetX;this.y += this.offsetY;if(!this.populated &&(this.contents != "")){this.populated = true;this.refresh();}if(this.divName != null){if(this.use_gebi){document.getElementById(this.divName).style.left = this.x + "px";document.getElementById(this.divName).style.top = this.y + "px";document.getElementById(this.divName).style.visibility = "visible";}else if(this.use_css){document.all[this.divName].style.left = this.x;document.all[this.divName].style.top = this.y;document.all[this.divName].style.visibility = "visible";}else if(this.use_layers){document.layers[this.divName].left = this.x;document.layers[this.divName].top = this.y;document.layers[this.divName].visibility = "visible";}}else{if(this.popupWindow == null || this.popupWindow.closed){if(this.x<0){this.x=0;}if(this.y<0){this.y=0;}if(screen && screen.availHeight){if((this.y + this.height) > screen.availHeight){this.y = screen.availHeight - this.height;}}if(screen && screen.availWidth){if((this.x + this.width) > screen.availWidth){this.x = screen.availWidth - this.width;}}var avoidAboutBlank = window.opera ||( document.layers && !navigator.mimeTypes['*']) || navigator.vendor == 'KDE' ||( document.childNodes && !document.all && !navigator.taintEnabled);this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");}this.refresh();}}
function PopupWindow_hidePopup(){if(this.divName != null){if(this.use_gebi){document.getElementById(this.divName).style.visibility = "hidden";}else if(this.use_css){document.all[this.divName].style.visibility = "hidden";}else if(this.use_layers){document.layers[this.divName].visibility = "hidden";}}else{if(this.popupWindow && !this.popupWindow.closed){this.popupWindow.close();this.popupWindow = null;}}}
function PopupWindow_isClicked(e){if(this.divName != null){if(this.use_layers){var clickX = e.pageX;var clickY = e.pageY;var t = document.layers[this.divName];if((clickX > t.left) &&(clickX < t.left+t.clip.width) &&(clickY > t.top) &&(clickY < t.top+t.clip.height)){return true;}else{return false;}}else if(document.all){var t = window.event.srcElement;while(t.parentElement != null){if(t.id==this.divName){return true;}t = t.parentElement;}return false;}else if(this.use_gebi && e){var t = e.originalTarget;while(t.parentNode != null){if(t.id==this.divName){return true;}t = t.parentNode;}return false;}return false;}return false;}
function PopupWindow_hideIfNotClicked(e){if(this.autoHideEnabled && !this.isClicked(e)){this.hidePopup();}}
function PopupWindow_autoHide(){this.autoHideEnabled = true;}
function PopupWindow_hidePopupWindows(e){for(var i=0;i<popupWindowObjects.length;i++){if(popupWindowObjects[i] != null){var p = popupWindowObjects[i];p.hideIfNotClicked(e);}}}
function PopupWindow_attachListener(){if(document.layers){document.captureEvents(Event.MOUSEUP);}window.popupWindowOldEventListener = document.onmouseup;if(window.popupWindowOldEventListener != null){document.onmouseup = new Function("window.popupWindowOldEventListener();PopupWindow_hidePopupWindows();");}else{document.onmouseup = PopupWindow_hidePopupWindows;}}
function PopupWindow(){if(!window.popupWindowIndex){window.popupWindowIndex = 0;}if(!window.popupWindowObjects){window.popupWindowObjects = new Array();}if(!window.listenerAttached){window.listenerAttached = true;PopupWindow_attachListener();}this.index = popupWindowIndex++;popupWindowObjects[this.index] = this;this.divName = null;this.popupWindow = null;this.width=0;this.height=0;this.populated = false;this.visible = false;this.autoHideEnabled = false;this.contents = "";this.url="";this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";if(arguments.length>0){this.type="DIV";this.divName = arguments[0];}else{this.type="WINDOW";}this.use_gebi = false;this.use_css = false;this.use_layers = false;if(document.getElementById){this.use_gebi = true;}else if(document.all){this.use_css = true;}else if(document.layers){this.use_layers = true;}else{this.type = "WINDOW";}this.offsetX = 0;this.offsetY = 0;this.getXYPosition = PopupWindow_getXYPosition;this.populate = PopupWindow_populate;this.setUrl = PopupWindow_setUrl;this.setWindowProperties = PopupWindow_setWindowProperties;this.refresh = PopupWindow_refresh;this.showPopup = PopupWindow_showPopup;this.hidePopup = PopupWindow_hidePopup;this.setSize = PopupWindow_setSize;this.isClicked = PopupWindow_isClicked;this.autoHide = PopupWindow_autoHide;this.hideIfNotClicked = PopupWindow_hideIfNotClicked;}


/* SOURCE FILE: CalendarPopup.js */

function CalendarPopup(){var c;if(arguments.length>0){c = new PopupWindow(arguments[0]);}else{c = new PopupWindow();c.setSize(150,175);}c.offsetX = -152;c.offsetY = 25;c.autoHide();c.monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");c.monthAbbreviations = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");c.dayHeaders = new Array("S","M","T","W","T","F","S");c.returnFunction = "CP_tmpReturnFunction";c.returnMonthFunction = "CP_tmpReturnMonthFunction";c.returnQuarterFunction = "CP_tmpReturnQuarterFunction";c.returnYearFunction = "CP_tmpReturnYearFunction";c.weekStartDay = 0;c.isShowYearNavigation = false;c.displayType = "date";c.disabledWeekDays = new Object();c.disabledDatesExpression = "";c.yearSelectStartOffset = 2;c.currentDate = null;c.todayText="Today";c.cssPrefix="";c.isShowNavigationDropdowns=false;c.isShowYearNavigationInput=false;window.CP_calendarObject = null;window.CP_targetInput = null;window.CP_dateFormat = "MM/dd/yyyy";c.copyMonthNamesToWindow = CP_copyMonthNamesToWindow;c.setReturnFunction = CP_setReturnFunction;c.setReturnMonthFunction = CP_setReturnMonthFunction;c.setReturnQuarterFunction = CP_setReturnQuarterFunction;c.setReturnYearFunction = CP_setReturnYearFunction;c.setMonthNames = CP_setMonthNames;c.setMonthAbbreviations = CP_setMonthAbbreviations;c.setDayHeaders = CP_setDayHeaders;c.setWeekStartDay = CP_setWeekStartDay;c.setDisplayType = CP_setDisplayType;c.setDisabledWeekDays = CP_setDisabledWeekDays;c.addDisabledDates = CP_addDisabledDates;c.setYearSelectStartOffset = CP_setYearSelectStartOffset;c.setTodayText = CP_setTodayText;c.showYearNavigation = CP_showYearNavigation;c.showCalendar = CP_showCalendar;c.hideCalendar = CP_hideCalendar;c.getStyles = getCalendarStyles;c.refreshCalendar = CP_refreshCalendar;c.getCalendar = CP_getCalendar;c.select = CP_select;c.setCssPrefix = CP_setCssPrefix;c.showNavigationDropdowns = CP_showNavigationDropdowns;c.showYearNavigationInput = CP_showYearNavigationInput;c.copyMonthNamesToWindow();return c;}
function CP_copyMonthNamesToWindow(){if(typeof(window.MONTH_NAMES)!="undefined" && window.MONTH_NAMES!=null){window.MONTH_NAMES = new Array();for(var i=0;i<this.monthNames.length;i++){window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthNames[i];}for(var i=0;i<this.monthAbbreviations.length;i++){window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthAbbreviations[i];}}}
function CP_tmpReturnFunction(y,m,d){if(window.CP_targetInput!=null){var dt = new Date(y,m-1,d,0,0,0);if(window.CP_calendarObject!=null){window.CP_calendarObject.copyMonthNamesToWindow();}window.CP_targetInput.value = formatDate(dt,window.CP_dateFormat);}else{alert('Use setReturnFunction() to define which function will get the clicked results!');}}
function CP_tmpReturnMonthFunction(y,m){alert('Use setReturnMonthFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , month='+m);}
function CP_tmpReturnQuarterFunction(y,q){alert('Use setReturnQuarterFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , quarter='+q);}
function CP_tmpReturnYearFunction(y){alert('Use setReturnYearFunction() to define which function will get the clicked results!\nYou clicked: year='+y);}
function CP_setReturnFunction(name){this.returnFunction = name;}
function CP_setReturnMonthFunction(name){this.returnMonthFunction = name;}
function CP_setReturnQuarterFunction(name){this.returnQuarterFunction = name;}
function CP_setReturnYearFunction(name){this.returnYearFunction = name;}
function CP_setMonthNames(){for(var i=0;i<arguments.length;i++){this.monthNames[i] = arguments[i];}this.copyMonthNamesToWindow();}
function CP_setMonthAbbreviations(){for(var i=0;i<arguments.length;i++){this.monthAbbreviations[i] = arguments[i];}this.copyMonthNamesToWindow();}
function CP_setDayHeaders(){for(var i=0;i<arguments.length;i++){this.dayHeaders[i] = arguments[i];}}
function CP_setWeekStartDay(day){this.weekStartDay = day;}
function CP_showYearNavigation(){this.isShowYearNavigation =(arguments.length>0)?arguments[0]:true;}
function CP_setDisplayType(type){if(type!="date"&&type!="week-end"&&type!="month"&&type!="quarter"&&type!="year"){alert("Invalid display type! Must be one of: date,week-end,month,quarter,year");return false;}this.displayType=type;}
function CP_setYearSelectStartOffset(num){this.yearSelectStartOffset=num;}
function CP_setDisabledWeekDays(){this.disabledWeekDays = new Object();for(var i=0;i<arguments.length;i++){this.disabledWeekDays[arguments[i]] = true;}}
function CP_addDisabledDates(start, end){if(arguments.length==1){end=start;}if(start==null && end==null){return;}if(this.disabledDatesExpression!=""){this.disabledDatesExpression+= "||";}if(start!=null){start = parseDate(start);start=""+start.getFullYear()+LZ(start.getMonth()+1)+LZ(start.getDate());}if(end!=null){end=parseDate(end);end=""+end.getFullYear()+LZ(end.getMonth()+1)+LZ(end.getDate());}if(start==null){this.disabledDatesExpression+="(ds<="+end+")";}else if(end  ==null){this.disabledDatesExpression+="(ds>="+start+")";}else{this.disabledDatesExpression+="(ds>="+start+"&&ds<="+end+")";}}
function CP_setTodayText(text){this.todayText = text;}
function CP_setCssPrefix(val){this.cssPrefix = val;}
function CP_showNavigationDropdowns(){this.isShowNavigationDropdowns =(arguments.length>0)?arguments[0]:true;}
function CP_showYearNavigationInput(){this.isShowYearNavigationInput =(arguments.length>0)?arguments[0]:true;}
function CP_hideCalendar(){if(arguments.length > 0){window.popupWindowObjects[arguments[0]].hidePopup();}else{this.hidePopup();}}
function CP_refreshCalendar(index){var calObject = window.popupWindowObjects[index];if(arguments.length>1){calObject.populate(calObject.getCalendar(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]));}else{calObject.populate(calObject.getCalendar());}calObject.refresh();}
function CP_showCalendar(anchorname){if(arguments.length>1){if(arguments[1]==null||arguments[1]==""){this.currentDate=new Date();}else{this.currentDate=new Date(parseDate(arguments[1]));}}this.populate(this.getCalendar());this.showPopup(anchorname);}
function CP_select(inputobj, linkname, format){var selectedDate=(arguments.length>3)?arguments[3]:null;if(!window.getDateFromFormat){alert("calendar.select: To use this method you must also include 'date.js' for date formatting");return;}if(this.displayType!="date"&&this.displayType!="week-end"){alert("calendar.select: This function can only be used with displayType 'date' or 'week-end'");return;}if(inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea"){alert("calendar.select: Input object passed is not a valid form input object");window.CP_targetInput=null;return;}if(inputobj.disabled){return;}window.CP_targetInput = inputobj;window.CP_calendarObject = this;this.currentDate=null;var time=0;if(selectedDate!=null){time = getDateFromFormat(selectedDate,format)}else if(inputobj.value!=""){time = getDateFromFormat(inputobj.value,format);}if(selectedDate!=null || inputobj.value!=""){if(time==0){this.currentDate=null;}else{this.currentDate=new Date(time);}}window.CP_dateFormat = format;this.showCalendar(linkname);}
function getCalendarStyles(){var result = "";var p = "";if(this!=null && typeof(this.cssPrefix)!="undefined" && this.cssPrefix!=null && this.cssPrefix!=""){p=this.cssPrefix;}result += "<STYLE>\n";result += "."+p+"cpYearNavigation,."+p+"cpMonthNavigation{background-color:#C0C0C0;text-align:center;vertical-align:center;text-decoration:none;color:#000000;font-weight:bold;}\n";result += "."+p+"cpDayColumnHeader, ."+p+"cpYearNavigation,."+p+"cpMonthNavigation,."+p+"cpCurrentMonthDate,."+p+"cpCurrentMonthDateDisabled,."+p+"cpOtherMonthDate,."+p+"cpOtherMonthDateDisabled,."+p+"cpCurrentDate,."+p+"cpCurrentDateDisabled,."+p+"cpTodayText,."+p+"cpTodayTextDisabled,."+p+"cpText{font-family:arial;font-size:8pt;}\n";result += "TD."+p+"cpDayColumnHeader{text-align:right;border:solid thin #C0C0C0;border-width:0px 0px 1px 0px;}\n";result += "."+p+"cpCurrentMonthDate, ."+p+"cpOtherMonthDate, ."+p+"cpCurrentDate{text-align:right;text-decoration:none;}\n";result += "."+p+"cpCurrentMonthDateDisabled, ."+p+"cpOtherMonthDateDisabled, ."+p+"cpCurrentDateDisabled{color:#D0D0D0;text-align:right;text-decoration:line-through;}\n";result += "."+p+"cpCurrentMonthDate, .cpCurrentDate{color:#000000;}\n";result += "."+p+"cpOtherMonthDate{color:#808080;}\n";result += "TD."+p+"cpCurrentDate{color:white;background-color: #C0C0C0;border-width:1px;border:solid thin #800000;}\n";result += "TD."+p+"cpCurrentDateDisabled{border-width:1px;border:solid thin #FFAAAA;}\n";result += "TD."+p+"cpTodayText, TD."+p+"cpTodayTextDisabled{border:solid thin #C0C0C0;border-width:1px 0px 0px 0px;}\n";result += "A."+p+"cpTodayText, SPAN."+p+"cpTodayTextDisabled{height:20px;}\n";result += "A."+p+"cpTodayText{color:black;}\n";result += "."+p+"cpTodayTextDisabled{color:#D0D0D0;}\n";result += "."+p+"cpBorder{border:solid thin #808080;}\n";result += "</STYLE>\n";return result;}
function CP_getCalendar(){var now = new Date();if(this.type == "WINDOW"){var windowref = "window.opener.";}else{var windowref = "";}var result = "";if(this.type == "WINDOW"){result += "<HTML><HEAD><TITLE>Calendar</TITLE>"+this.getStyles()+"</HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 RIGHTMARGIN=0 LEFTMARGIN=0>\n";result += '<CENTER><TABLE WIDTH=100% BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>\n';}else{result += '<TABLE CLASS="'+this.cssPrefix+'cpBorder" WIDTH=144 BORDER=1 BORDERWIDTH=1 CELLSPACING=0 CELLPADDING=1>\n';result += '<TR><TD ALIGN=CENTER>\n';result += '<CENTER>\n';}if(this.displayType=="date" || this.displayType=="week-end"){if(this.currentDate==null){this.currentDate = now;}if(arguments.length > 0){var month = arguments[0];}else{var month = this.currentDate.getMonth()+1;}if(arguments.length > 1 && arguments[1]>0 && arguments[1]-0==arguments[1]){var year = arguments[1];}else{var year = this.currentDate.getFullYear();}var daysinmonth= new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);if( ((year%4 == 0)&&(year%100 != 0) ) ||(year%400 == 0) ){daysinmonth[2] = 29;}var current_month = new Date(year,month-1,1);var display_year = year;var display_month = month;var display_date = 1;var weekday= current_month.getDay();var offset = 0;offset =(weekday >= this.weekStartDay) ? weekday-this.weekStartDay : 7-this.weekStartDay+weekday ;if(offset > 0){display_month--;if(display_month < 1){display_month = 12;display_year--;}display_date = daysinmonth[display_month]-offset+1;}var next_month = month+1;var next_month_year = year;if(next_month > 12){next_month=1;next_month_year++;}var last_month = month-1;var last_month_year = year;if(last_month < 1){last_month=12;last_month_year--;}var date_class;if(this.type!="WINDOW"){result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";}result += '<TR>\n';var refresh = windowref+'CP_refreshCalendar';var refreshLink = 'javascript:' + refresh;if(this.isShowNavigationDropdowns){result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="78" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpMonthNavigation" name="cpMonth" onChange="'+refresh+'('+this.index+',this.options[this.selectedIndex].value-0,'+(year-0)+');">';for( var monthCounter=1;monthCounter<=12;monthCounter++){var selected =(monthCounter==month) ? 'SELECTED' : '';result += '<option value="'+monthCounter+'" '+selected+'>'+this.monthNames[monthCounter-1]+'</option>';}result += '</select></TD>';result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10">&nbsp;</TD>';result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="56" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpYearNavigation" name="cpYear" onChange="'+refresh+'('+this.index+','+month+',this.options[this.selectedIndex].value-0);">';for( var yearCounter=year-this.yearSelectStartOffset;yearCounter<=year+this.yearSelectStartOffset;yearCounter++){var selected =(yearCounter==year) ? 'SELECTED' : '';result += '<option value="'+yearCounter+'" '+selected+'>'+yearCounter+'</option>';}result += '</select></TD>';}else{if(this.isShowYearNavigation){result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;</A></TD>';result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="58"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+'</SPAN></TD>';result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;</A></TD>';result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10">&nbsp;</TD>';result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year-1)+');">&lt;</A></TD>';if(this.isShowYearNavigationInput){result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><INPUT NAME="cpYear" CLASS="'+this.cssPrefix+'cpYearNavigation" SIZE="4" MAXLENGTH="4" VALUE="'+year+'" onBlur="'+refresh+'('+this.index+','+month+',this.value-0);"></TD>';}else{result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><SPAN CLASS="'+this.cssPrefix+'cpYearNavigation">'+year+'</SPAN></TD>';}result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year+1)+');">&gt;</A></TD>';}else{result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;&lt;</A></TD>\n';result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="100"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+' '+year+'</SPAN></TD>\n';result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;&gt;</A></TD>\n';}}result += '</TR></TABLE>\n';result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=0 CELLPADDING=1 ALIGN=CENTER>\n';result += '<TR>\n';for(var j=0;j<7;j++){result += '<TD CLASS="'+this.cssPrefix+'cpDayColumnHeader" WIDTH="14%"><SPAN CLASS="'+this.cssPrefix+'cpDayColumnHeader">'+this.dayHeaders[(this.weekStartDay+j)%7]+'</TD>\n';}result += '</TR>\n';for(var row=1;row<=6;row++){result += '<TR>\n';for(var col=1;col<=7;col++){var disabled=false;if(this.disabledDatesExpression!=""){var ds=""+display_year+LZ(display_month)+LZ(display_date);eval("disabled=("+this.disabledDatesExpression+")");}var dateClass = "";if((display_month == this.currentDate.getMonth()+1) &&(display_date==this.currentDate.getDate()) &&(display_year==this.currentDate.getFullYear())){dateClass = "cpCurrentDate";}else if(display_month == month){dateClass = "cpCurrentMonthDate";}else{dateClass = "cpOtherMonthDate";}if(disabled || this.disabledWeekDays[col-1]){result += '	<TD CLASS="'+this.cssPrefix+dateClass+'"><SPAN CLASS="'+this.cssPrefix+dateClass+'Disabled">'+display_date+'</SPAN></TD>\n';}else{var selected_date = display_date;var selected_month = display_month;var selected_year = display_year;if(this.displayType=="week-end"){var d = new Date(selected_year,selected_month-1,selected_date,0,0,0,0);d.setDate(d.getDate() +(7-col));selected_year = d.getYear();if(selected_year < 1000){selected_year += 1900;}selected_month = d.getMonth()+1;selected_date = d.getDate();}result += '	<TD CLASS="'+this.cssPrefix+dateClass+'"><A HREF="javascript:'+windowref+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+this.cssPrefix+dateClass+'">'+display_date+'</A></TD>\n';}display_date++;if(display_date > daysinmonth[display_month]){display_date=1;display_month++;}if(display_month > 12){display_month=1;display_year++;}}result += '</TR>';}var current_weekday = now.getDay() - this.weekStartDay;if(current_weekday < 0){current_weekday += 7;}result += '<TR>\n';result += '	<TD COLSPAN=7 ALIGN=CENTER CLASS="'+this.cssPrefix+'cpTodayText">\n';if(this.disabledDatesExpression!=""){var ds=""+now.getFullYear()+LZ(now.getMonth()+1)+LZ(now.getDate());eval("disabled=("+this.disabledDatesExpression+")");}if(disabled || this.disabledWeekDays[current_weekday+1]){result += '		<SPAN CLASS="'+this.cssPrefix+'cpTodayTextDisabled">'+this.todayText+'</SPAN>\n';}else{result += '		<A CLASS="'+this.cssPrefix+'cpTodayText" HREF="javascript:'+windowref+this.returnFunction+'(\''+now.getFullYear()+'\',\''+(now.getMonth()+1)+'\',\''+now.getDate()+'\');'+windowref+'CP_hideCalendar(\''+this.index+'\');">'+this.todayText+'</A>\n';}result += '		<BR>\n';result += '	</TD></TR></TABLE></CENTER></TD></TR></TABLE>\n';}if(this.displayType=="month" || this.displayType=="quarter" || this.displayType=="year"){if(arguments.length > 0){var year = arguments[0];}else{if(this.displayType=="year"){var year = now.getFullYear()-this.yearSelectStartOffset;}else{var year = now.getFullYear();}}if(this.displayType!="year" && this.isShowYearNavigation){result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";result += '<TR>\n';result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-1)+');">&lt;&lt;</A></TD>\n';result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="100">'+year+'</TD>\n';result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+1)+');">&gt;&gt;</A></TD>\n';result += '</TR></TABLE>\n';}}if(this.displayType=="month"){result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';for(var i=0;i<4;i++){result += '<TR>';for(var j=0;j<3;j++){var monthindex =((i*3)+j);result += '<TD WIDTH=33% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnMonthFunction+'('+year+','+(monthindex+1)+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+this.monthAbbreviations[monthindex]+'</A></TD>';}result += '</TR>';}result += '</TABLE></CENTER></TD></TR></TABLE>\n';}if(this.displayType=="quarter"){result += '<BR><TABLE WIDTH=120 BORDER=1 CELLSPACING=0 CELLPADDING=0 ALIGN=CENTER>\n';for(var i=0;i<2;i++){result += '<TR>';for(var j=0;j<2;j++){var quarter =((i*2)+j+1);result += '<TD WIDTH=50% ALIGN=CENTER><BR><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnQuarterFunction+'('+year+','+quarter+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">Q'+quarter+'</A><BR><BR></TD>';}result += '</TR>';}result += '</TABLE></CENTER></TD></TR></TABLE>\n';}if(this.displayType=="year"){var yearColumnSize = 4;result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";result += '<TR>\n';result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-(yearColumnSize*2))+');">&lt;&lt;</A></TD>\n';result += '	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+(yearColumnSize*2))+');">&gt;&gt;</A></TD>\n';result += '</TR></TABLE>\n';result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';for(var i=0;i<yearColumnSize;i++){for(var j=0;j<2;j++){var currentyear = year+(j*yearColumnSize)+i;result += '<TD WIDTH=50% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnYearFunction+'('+currentyear+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+currentyear+'</A></TD>';}result += '</TR>';}result += '</TABLE></CENTER></TD></TR></TABLE>\n';}if(this.type == "WINDOW"){result += "</BODY></HTML>\n";}return result;}

<!--
var listing_style = "";
var b_cities = new Array('Baltimore, MD', 'New York, NY', 'Philadelphia, PA', 'Richmond, VA', 'Rockville, MD', 'Washington, DC');
var g_bus = new Object;
var total_cities = b_cities.length;
for (i=0; i<total_cities; i++)
  g_bus[b_cities[i]] = new Array;

g_bus['Baltimore, MD'][0] = 'New York, NY';
g_bus['New York, NY'][0] = 'Baltimore, MD';
g_bus['New York, NY'][1] = 'Philadelphia, PA';
g_bus['New York, NY'][2] = 'Richmond, VA';
g_bus['New York, NY'][3] = 'Rockville, MD';
g_bus['New York, NY'][4] = 'Washington, DC';
g_bus['Philadelphia, PA'][0] = 'New York, NY';
g_bus['Philadelphia, PA'][1] = 'Washington, DC';
g_bus['Richmond, VA'][0] = 'New York, NY';
g_bus['Rockville, MD'][0] = 'New York, NY';
g_bus['Washington, DC'][0] = 'New York, NY';
g_bus['Washington, DC'][1] = 'Philadelphia, PA';
///////////// function
function update_bus_from()
{
	var bf_obj = get_bus_from_obj();
	while(bf_obj.hasChildNodes())
	{
		bf_obj.removeChild(bf_obj.lastChild);

	}
	bf_obj.options[0] = new Option("Departure City","");
	if(listing_style == 'states')
	{
		bus_listing_states(bf_obj);
	}
	else
	{
		//document.getElementById("listing_style").checked = false;
		bus_listing_cityes(bf_obj);
	}
}

function bus_listing_cityes(bf_obj)
{
	for (var i=0; i<b_cities.length; i++)
	{
		var j = i+1;
		bf_obj.options[j] = new Option(b_cities[i], b_cities[i]);
	}
}

function bus_listing_states(bf_obj)
{
	var opg_arr = new Array();
	for (var opg in states )
	{
		opg_arr[opg] = document.createElement("optgroup");
		opg_arr[opg].label = states[opg];
	}
	for (var i=0; i<b_cities.length; i++)
	{
		var j = i+1;
		var o = document.createElement("option");
		var arr = b_cities[i].split(/,\s+/);
		o.value = b_cities[i];
		o.innerHTML = arr[0];
		var short_state = arr[1];
		if(opg_arr[short_state])
			opg_arr[short_state].appendChild(o);

	}
	for(var opg in opg_arr) {
		opg_arr[opg].label = states[opg];
		if(opg_arr[opg].hasChildNodes())
			bf_obj.appendChild(opg_arr[opg]);
	}
}

function change_r_date(d)
{
    if (document.bus_search)
    {
		if (document.bus_search.b_roundtrip.checked == false)
		{
			document.bus_search.return_date.value = '';
		}
		else
		{
			if (d == "")
			{
				d = "N/A";
			}
			var f_count = document.forms.length;
			for (var i=0; i<f_count; ++i)
			{
				if (document.forms[i].r_date)
				{
					document.forms[i].r_date.value = d;
				}
			}
		}
    }
}

function change_passengers(n)
{
    if (document.bus_search)
    {
        var f_count = document.forms.length;
        for (var i=0; i<f_count; ++i)
        {
            if (document.forms[i].vol)
            {
                document.forms[i].vol.value = n;
            }
        }
    }
}

function select_oneway(no_update)
{
	if (document.bus_search)
	{
		document.bus_search.return_date.value = '';
		conditional_update();
	}
}

function select_roundtrip(d)
{
	if (document.bus_search)
	{
		var rd_obj = document.bus_search.return_date;
		if (d == null)
		{
			d = document.bus_search.filter_date.value;
			var darray = d.split("-");
			var start_d = new Date(darray[0], darray[1]-1, darray[2]);
			var r_d = new Date(start_d.valueOf() + 172800000);
			var m = r_d.getMonth() + 1;
			if (m < 10)
			{
				m = "0" + m;
			}
			var dt = r_d.getDate();
			if (dt < 10)
			{
				dt = "0" + dt;
			}
			rd_obj.value = r_d.getFullYear() + '-' + m + '-' + dt;
		}
		conditional_update();
	}
}

function enable_roundtrip()
{
        if (document.bus_search)
        {
                document.bus_search.b_roundtrip.checked = true;
                var t_obj = document.getElementById("timeList");
                if (t_obj && t_obj.innerHTML != "")
                {
                        t_obj.innerHTML = "";
                }
                br_cal.select(document.bus_search.return_date,'br_date','yyyy-MM-dd');
        }
}

function select_preset()
{
	if (document.bus_search && document.bus_search.sbus_from)
	{
		document.bus_search.sbus_from.disabled = true;
		document.bus_search.sbus_to.disabled = true;
		document.bus_search.bus_from.disabled = false;
		document.bus_search.bus_to.disabled = false;
	}
}

function select_search()
{
    if (document.bus_search && document.bus_search.sbus_from)
    {
		document.bus_search.sbus_from.disabled = false;
		document.bus_search.sbus_to.disabled = false;
		document.bus_search.bus_from.disabled = true;
		document.bus_search.bus_to.disabled = true;
	}
}
///////////////////////////// list by states //////////

function list_by_states(f) {

	var bt_obj = get_bus_to_obj();
	var f_states = new Array();
	var opg_arr = new Array();

	for (var i=0; i<g_bus[f].length; i++)
	{

		var citys_arr = g_bus[f][i].split(/,\s+/);
		citys_arr.push(g_bus[f][i]);
		opg_arr.push(citys_arr);
		if( f_states.toString().indexOf(citys_arr[1])<0 ){

			f_states.push(citys_arr[1]);
		}

	}

	var opg_obj = new Array();

	for(var st in states ) {

		if(f_states.toString().indexOf(st) > -1){


			var opt = document.createElement("optgroup");

			for(var j=0; j<opg_arr.length; j++) {

				var o = document.createElement("option");
				o.value = opg_arr[j][2];

				o.innerHTML = opg_arr[j][0];

				if(st == opg_arr[j][1]) {

					opt.label = states[st];

					opt.appendChild(o);
				}
			}
			opg_obj.push(opt);

		}
	}

	for(var opg in opg_obj) {

		if(opg_obj[opg].hasChildNodes())
			bt_obj.appendChild(opg_obj[opg]);

	}
}

//////////////////////////////////// list_by_cities
function list_by_cities(f) {

		var bt_obj = get_bus_to_obj();

	if (f)
		{

		for (var i=0; i<g_bus[f].length; i++)
		{
			var j = i+1;
        	bt_obj.options[j] = new Option(g_bus[f][i], g_bus[f][i]);
	}
	}

}

function update_bus_to(f)
{
	var bt_obj = get_bus_to_obj();

	while(bt_obj.hasChildNodes())
	{
		bt_obj.removeChild(bt_obj.lastChild);

	}
	var op = document.createElement("option");
	op.value = "";
	op.style.color = '#555555';
	op.innerHTML = "Arrival City";

	bt_obj.appendChild(op);
	if (f)
    {
		if(g_bus[f].length >10 && listing_style == 'states')
		{
			list_by_states(f);
		}
		else
		{
			list_by_cities(f);
        }
	}
	conditional_clear();
}

function get_bus_from_obj()
{
	return window.document.bus_search.bus_from;
}

function get_sbus_from_obj()
{
       	return window.document.bus_search.sbus_from;
}

function get_bus_to_obj()
{
	return window.document.bus_search.bus_to;
}

function get_sbus_to_obj()
{
	return window.document.bus_search.sbus_to;
}

function set_selected(obj, v)
{
    for (var i=0; i<obj.options.length; i++)
    {
        if (obj.options[i].value == v)
        {
            obj.options.selectedIndex = i;
            return i;
        }
    }
    return -1;
}

function update_bus_from_to(f, t)
{
    var bf_obj = get_bus_from_obj();
    var index = 0;
    var sbus_from = document.getElementById("sbus_from_id");
    var sbus_to = document.getElementById("sbus_to_id");
    if (f)
    {
		if (g_bus[f] instanceof Array )
		{
			index = set_selected(bf_obj, f);
			if (sbus_from != null)
			{
				sbus_from.value = bf_obj.options[index].value;
			}
		}
    }
    else
    {
		index = bf_obj.selectedIndex;
		if (index > 0)
		{
			f = bf_obj.options[index].value;
		}
    }
    if (t)
    {
		if (g_bus[f] instanceof Array)
		{
			update_bus_to(f);
			var bt_obj = get_bus_to_obj();
			index = set_selected(bt_obj, t);
			if (index > -1 &&  sbus_to != null)
			{
				sbus_to.value = bt_obj.options[index].value;
			}
    	}
    }
    else if (index > 0)
    {
       	update_bus_to(f);
    }
    return 0;
}

function jump_or_clear()
{
    var bf_obj = get_bus_from_obj();
    var bt_obj = get_bus_to_obj();
    var fv = bf_obj.options[bf_obj.selectedIndex].value;
    var tv = bt_obj.options[bt_obj.selectedIndex].value;
    if (fv == "Los Angeles, CA")
    {
    	if (tv == "Six Flags Magic Mountain, CA")
    	{
    		return ga("http://www.gotobus.com/cs/c1379/shuttleservice/latosixflagsmagicmountainroundtripshuttlebus.html");
    	}
    	if (tv == "Disneyland, CA")
    	{
    		return ga("http://www.gotobus.com/cs/c1379/shuttleservice/latodisneylandroundtripshuttlebus.html");
    	}	
    	if (tv == "Knott's Berry Farm, CA")
    	{
    		return ga("http://www.gotobus.com/cs/c1379/shuttleservice/latoknott_sberryfarmroundtripshuttlebus.html");
    	}	
    	if (tv == "Ontario Mills Outlet, CA")
    	{
    		return ga("http://www.gotobus.com/cs/c1379/shuttleservice/latoontariomillsoutletroundtripshuttlebus.html");
    	}	
    	if (tv == "Desert Hills Outlet, CA")
    	{
    		return ga("http://www.gotobus.com/cs/c1379/shuttleservice/latodeserthillsoutletroundtripshuttlebus.html");
    	}	
    	if (tv == "Citadel Outlet, CA")
    	{
    		return ga("http://www.gotobus.com/cs/c1379/shuttleservice/latocitadeloutletroundtripshuttlebus.html");
    	}	
    	if (tv == "Ronald Reagan Museum, CA")
    	{
    		return ga("http://www.gotobus.com/cs/c1379/shuttleservice/latoronaldreaganmuseumroundtripshuttlebus.html");
    	}	
    	if (tv == "Getty Museum, CA")
    	{
    		return ga("http://www.gotobus.com/cs/c1379/shuttleservice/latogettymuseumroundtripshuttlebus.html");
    	}	
    	if (tv == "Sea World, CA")
    	{
    		return ga("http://www.gotobus.com/cs/c1379/shuttleservice/latoseaworldroundtripshuttlebus.html");
    	}	
    	if (tv == "San Diego Zoo, CA")
    	{
    		return ga("http://www.gotobus.com/cs/c1379/shuttleservice/latosandiegozooroundtripshuttlebus.html");
    	}	
    }
    if (tv == "Turning Stone Casino, NY")
    {
        if (fv == "Albany, NY")
        {
            return ga("http://www.gotobus.com/cs/c1259/albanytoturningstonecasino/");
        }

    }
    if (tv == "Mohegan Sun Casino, CT")
    {
        if (fv == "Boston, MA" || fv == "Dorchester, MA" || fv == "Quincy, MA" || fv == "Lawrence, MA" || fv == "Lowell, MA" || fv == "Methuen, MA" || fv == "Worcester, MA"  || fv == "Malden, MA")
        {
            return ga("http://www.gotobus.com/sunshine/boston_mohegansuntour/");
        }
    }
    else if (tv == "Atlantic City, NJ")
    {
        if (fv == "Newark, DE" || fv == "Wilmington, DE" || fv == "New Castle, DE")
        {
            return ga("http://www.gotobus.com/creativetravel/");
        }
        if (fv == "Washington, DC" || fv == "Fairfax, VA" || fv == "Springfield, VA" || fv == "Wheaton, MD" || fv == "Bethesda, MD")
        {
            return ga("http://www.gotobus.com/rexbus/daytriptotajmahalatlanticcity/");
        }
	if (fv == "Capitol Heights, MD" || fv == "Clinton, MD" || fv == "Tysons Corner, VA")
        {
            return ga("http://www.gotobus.com/rexbus/daytriptotajmahalatlanticcity/daytriptotajmahalatlanticcity.html");
        }
    }
    else if (tv == "Reno, NV")
    {
        if (fv == "San Francisco, CA")
        {
            return ga("http://www.gotobus.com/usasia/sanfrancisco___reno/");
        }
    }
    else if (fv == "San Diego, CA")
    {
        if (tv == "Viejas Casino, CA" || tv == "Sycuan Casino, CA")
        {
            return ga("http://www.gotobus.com/sunfuntours/");
        }
    }
    else if (tv == "Foxwoods Casino, CT")
    {
		return ga("http://www.gotobus.com/shortline/citytour/foxwoodsresortandcasino1_daytour.html");
    }
    else if (tv == "Philadelphia Park Casino, PA" || tv == "Philly Park Casino, PA")    {
        return ga("http://www.gotobus.com/skybus/philadelphiaparkcasinotour/");
    }
    conditional_clear();
}

function conditional_clear()
{
	var t_obj = document.getElementById("timeList");
	if (t_obj)
	{
	    t_obj.innerHTML = "";
	}
}

function get_departure_date()
{
	return document.bus_search.filter_date;
}

function get_return_date()
{
	return document.bus_search.return_date;
}

function check_bus_data()
{
	if (document.bus_search.option.value == "Select")
	{
		if (document.bus_search.bus_from.value == "")
		{
			alert("Please select a valid Departure City!");
			document.bus_search.bus_from.focus();
			return false;
		}
		if (document.bus_search.bus_to.value == "")
		{
			alert("Please select a valid Arrival City!");
			document.bus_search.bus_to.focus();
			return false;
		}
	}
	else if (document.bus_search.option.value == "Search")
	{
		if (document.bus_search.sbus_from.value == "")
		{
			alert("Please enter a valid Departure City!");
			document.bus_search.sbus_from.focus();
			return false;
		}
		if (document.bus_search.sbus_to.value == "")
		{
			document.bus_search.sbus_to.focus();
			alert("Please enter a valid Arrival City!");
			return false;
		}
	}
    if (document.bus_search.filter_date.value == "")
    {
        alert("Please select a valid Departure Date!");
        document.bus_search.filter_date.focus();
        return false;
    }
    if (document.bus_search.b_roundtrip.checked == true && document.bus_search.return_date.value == "")
    {
        alert("Please select a valid Return Date!");
        document.bus_search.return_date.focus();
        return false;
    }
	return true;
}

function pickdaterange()
{
    var dateObj = document.getElementById("beforethisdate");
    var dateFilter = dateObj.options[dateObj.selectedIndex].value;
    if (document.bus_search && document.bus_search.filter_date)
    {
        document.bus_search.filter_date.value = dateFilter;
    }
    server_update();
    window.document.getElementById("beforethisdate").focus();
}

function conditional_update()
{
	var t_obj = document.getElementById("timeList");
	if (t_obj && t_obj.innerHTML != "")
	{
		server_update();
	}
}

function server_update()
{
	var from;
	var to;
	var vfrom;
	var vto;
	var vopt;
	var bss_id='';
	if (document.bus_search.option && document.bus_search.option.value == "Hidden")
	{
		from = document.bus_search.bus_from.value;
		to   = document.bus_search.bus_to.value;
		vopt = "option=Hidden";
        vfrom = "&bus_from=";
        vto = "&bus_to=";
	}
	else if (document.bus_search.option.value == "Select")
	{
		var bus_from_obj = get_bus_from_obj();
		if (bus_from_obj && bus_from_obj.value != "")
		{
			from = bus_from_obj.value;
		}
		else
		{
			conditional_clear();
			return;
		}
   		var bus_to_obj = get_bus_to_obj();
		if (bus_to_obj && bus_to_obj.value)
		{
			to = bus_to_obj.value;
		}
		else
		{
			conditional_clear();
			return;
		}
        vfrom = "&bus_from=";
        vto = "&bus_to=";
        vopt = "option=Select";
	}
	else
	{
		from = document.bus_search.sbus_from.value;
		to   = document.bus_search.sbus_to.value;
        vfrom = "&sbus_from=";
        vto = "&sbus_to=";
        vopt = "option=Search";
	}
	var date_obj = window.document.bus_search.filter_date;
	var date = "";
	if (date_obj)
	{
		date = date_obj.value;
	}
	else
	{
		date_obj = window.document.getElementById("beforethisdate");
		if (date_obj)
		{
            date = date_obj.value;
		}
    }
	var depart_bss = window.document.getElementById("depart_bss_id");
    if (depart_bss && depart_bss.value)
	{
        bss_id = "&depart_bss=" + depart_bss.value;
	}
	var arrival_bss = window.document.getElementById("arrival_bss_id");
    if (arrival_bss && arrival_bss.value)
	{
        bss_id = bss_id + "&arrival_bss=" + arrival_bss.value;
	}
	var keep_scale_param = ''
	var depart_scale_obj = window.document.getElementById("depart_bss_scale");
	if (depart_scale_obj && depart_scale_obj.value)
	{
		keep_scale_param = "&depart_scale=" + depart_scale_obj.value;
	}
	var depart_center_obj = window.document.getElementById("depart_bss_center");
	if (depart_center_obj && depart_center_obj.value)
	{
		keep_scale_param = keep_scale_param + "&depart_center=" + depart_center_obj.value;
	}
	var arrival_scale_obj = window.document.getElementById("arrival_bss_scale");
	if (arrival_scale_obj && arrival_scale_obj.value)
	{
		keep_scale_param = keep_scale_param + "&arrival_scale=" + arrival_scale_obj.value;
	}
	var arrival_center_obj = window.document.getElementById("arrival_bss_center");
	if (arrival_center_obj && arrival_center_obj.value)
	{
		keep_scale_param = keep_scale_param + "&arrival_center=" + arrival_center_obj.value;
	}
	var price_param='';
	if (typeof(price) != 'undefined')
	{
		var min_price_temp = 0;
		if (document.bus_search && document.bus_search.min_price)
		{
			min_price_temp = parseInt(document.bus_search.min_price.value);
		}
		if (document.bus_search && document.bus_search.left_point)
		{
			price_param = "&left_point=" + price.getSldPoint();
		}
		if (document.bus_search && document.bus_search.right_point)
		{
			price_param = price_param + "&right_point=" + price.getSldRightPoint();
		}
		if (document.bus_search && document.bus_search.max_price)
		{
			var temp_price_int = parseInt(price.getSldRightPoint()) + min_price_temp;
			price_param = price_param + "&max_price=" + temp_price_int;
		}
		if (document.bus_search && document.bus_search.lowest_price)
		{
			var temp_price_int = parseInt(price.getSldPoint()) + min_price_temp;
			price_param = price_param + "&lowest_price=" + temp_price_int;
		}
	}
	var time_param='';
	if (typeof(time_obj) != 'undefined')
	{
		if (document.bus_search && document.bus_search.time_left)
		{
			time_param = "&time_left=" + time_obj.getSldPoint();
		}
		if (document.bus_search && document.bus_search.time_right)
		{
			time_param = time_param + "&time_right=" + time_obj.getSldRightPoint();
		}		
	}
	var op_url = "";
//	if(flag == 0) commented by Jimmy Oct 16, 2009
	var operator_obj = window.document.getElementById("operatorList");
	if (operator_obj && operator_obj.value != "")
	{
		op_url = "&operator=" + operator_obj.value;
	}	
	var q_url = "";
	if (window.document.bus_search.quantity && window.document.bus_search.quantity.value > 1)
	{
		var quantity = window.document.bus_search.quantity.value;
		q_url = "&quantity=" + quantity;
	}
	var rt_url = "";
	var return_url = "";
	var roundtrip = -1;
	if (window.document.bus_search.roundtrip)
	{
	    if (document.bus_search.roundtrip[1].checked == true)
	    {
		roundtrip = 1;
	    }
	    else
	    {
	        roundtrip = 0;
	    }
        }
        if (document.bus_search.option && document.bus_search.option.value != "Hidden")
	{
            var return_obj = window.document.bus_search.return_date;
            if (return_obj)
            {
                var return_date = return_obj.value;
                return_url = "&return_date=" + return_date;
	    }
	    if (roundtrip < 0)
	    {
	       roundtrip = 1;
	    }
	}
	else
	{
	    roundtrip = 0;
	}
	rt_url = "&roundtrip=" + roundtrip;
        var nm_url = "";
        if (window.document.bus_search.nm && window.document.bus_search.nm.value != '')
        {
                var nm = window.document.bus_search.nm.value;
                nm_url = "&nm=" + nm;
        }
        var st_url = "";
        if (window.document.bus_search.st && window.document.bus_search.st.value != '')
        {
                var st = window.document.bus_search.st.value;
                st_url = "&st=" + st;
        }
    var selected_url = "&s_pid=" + document.getElementById("pid").value;
    if(document.getElementById("b_roundtrip").checked ==true)
    {

    	var pid_return_obj = document.getElementById("pid_return");
    	if (pid_return_obj != null)
    	{
    	 	selected_url = selected_url + "&s_return_pid=" + document.getElementById("pid_return").value;
    	}
    }
    ga("/cgi-bin/bus.cgi?" + vopt + vfrom + from + vto + to + "&filter_date=" + date + op_url + q_url + rt_url + return_url + nm_url + st_url+selected_url+price_param+bss_id+keep_scale_param+time_param);
}

function assignOperator(operator)
{
    var operatorObj = window.document.getElementById("operatorList");
	for (var i=0; i<operatorObj.options.length; i++)
	{
		if (operatorObj.options[i].value == operator)
        {
	        operatorObj.options[i].selected = true;
		    operatorFilter = operator;
		}
		else
		{
			operatorObj.options[i].selected = false;
		}
	}
	server_update();
}

function reverse_from_to()
{
    var option_obj = document.bus_search.option;
    if (option_obj)
    {
		var to   = document.bus_search.bus_from.value;
		var from = document.bus_search.bus_to.value;
		if (from)
		{
			update_bus_from_to(from, to);
			conditional_clear();
		}
	}
}

function copy_select_to_search()
{
    var f_obj = document.bus_search.bus_from;
    var t_obj = document.bus_search.bus_to;
    var sf_obj = document.bus_search.sbus_from;
    var st_obj = document.bus_search.sbus_to;
    if (t_obj.selectedIndex > 0)
    {
        st_obj.value = t_obj.options[t_obj.selectedIndex].value;
    }
    else
    {
    	st_obj.value = "Arrival City";
    }

    if (f_obj.selectedIndex > 0)
    {
        sf_obj.value = f_obj.options[f_obj.selectedIndex].value;
    }
    else
    {
    	sf_obj.value = "Departure City";
    }
}

function copy_search_to_select()
{
    var sf_obj = document.bus_search.sbus_from;
    var st_obj = document.bus_search.sbus_to;
    update_bus_from_to(sf_obj.value, st_obj.value);
}

function bus_where_switch()
{
    var option_obj = document.bus_search.option;
    if (option_obj)
    {
        conditional_clear();
        var select = document.getElementById("select_where");
        var search = document.getElementById("search_where");
        if (option_obj.value == "Select")
        {
            option_obj.value = "Search";
	    if (select && search)
            {
                select.className = "ivyDivHidden";
                search.className = "ivyDivShow";
            }
            copy_select_to_search();
            document.getElementById("bus_choice_switch").innerHTML = "Switch to Select";
        }
        else
        {
            option_obj.value = "Select";
            if (select && search)
            {
                select.className = "ivyDivShow";
                search.className = "ivyDivHidden";
            }
            copy_search_to_select();
            document.getElementById("bus_choice_switch").innerHTML = "Switch to Text";
        }
    }
}

function bus_departure_date_clicked(y,m,d)
{
	if (m < 10) m = '0' + m;
	if (d < 10) d = '0' + d;
	document.bus_search.filter_date.value = y + '-' + m + '-' + d;
	conditional_update();
}

function fast_day_select(day,isdepart)
{
	if (document.bus_search && document.bus_search.filter_date)
    {
    	if (isdepart)
    	{
        	document.bus_search.filter_date.value = day;
        }
        else
    	{
    		document.bus_search.return_date.value = day;    		
    	}
    	document.getElementById("bus_search").submit();
    }
}

function bus_return_date_clicked(y,m,d)
{
        if (m < 10) m = '0' + m;
        if (d < 10) d = '0' + d;
        document.bus_search.return_date.value = y + '-' + m + '-' + d;
        conditional_update();
}

function validate_form_selections(f)
{
    for (var i=0, j=f.elements.length; i<j; i++)
    {
        var t = f.elements[i].type;
        if (t.match(/select/))
		{
		    if (f.elements[i].value == '')
			{
				alert("Please Select " + f.elements[i].name + "!");
                f.elements[i].focus();
				return false;
			}
        }
    }
    if (f.Date != null && f.Date.value == '')
    {
        alert("Please select a valid Date!");
        return false;
    }
    if (f.time != null && f.time.value < 1.01)
    {
        return confirm("Important: It is a new date after passing 12:00am.\nYou have selected a very early schedule on " + f.Date.value + ".  Please confirm.");
    }
}

function check_oneway_image()
{
	if (document.getElementById('b_oneway').checked == true)
	{
		rd_popup.showPopup('r_text_date');
	}
	else
	{
		br_cal.select(document.bus_search.return_date,'br_date','yyyy-MM-dd');
	}
}

function check_oneway_text()
{
	if (document.getElementById('b_oneway').checked == true)
	{
		rd_popup.showPopup('r_text_date');
	}
}


function select_operator(operator, pid)
{
	var old_index = document.getElementById("operatorList").selectedIndex;
	if (document.getElementById("b_roundtrip").checked)
	{
		select_operator_change(operator)
		if (document.getElementById("operatorList").selectedIndex != old_index)
		{
			ajax_soap_bus_search(pid);
		}
	}
}

function select_operator_change(operator)
{
	var obj_operatorlist = document.getElementById("operatorList");
	for(var i=0;i<obj_operatorlist.length;i++)
	{
		if (obj_operatorlist.options[i].value == operator)
		{
			obj_operatorlist.selectedIndex =i;
			if(operator == "")
			{
				document.getElementById("pid").value = "";
			}
		}
	}
	if (document.getElementById("b_roundtrip").checked)
	{
		var obj_operatorlist_return = document.getElementById("operatorList_return");
		if (obj_operatorlist_return !=null)
		{
			for(var j=0;j<obj_operatorlist_return.length;j++)
			{
				if (obj_operatorlist_return.options[j].value == operator)
				{
					obj_operatorlist_return.selectedIndex =j;
					if(operator == "")
					{
						document.getElementById("pid_return").value = "";
					}
				}
			}
		}
	}

}


function set_hidden_value(return_spec,pid)
{
	document.getElementById("Date" + return_spec).value = document.getElementById('date'+pid).value;
	var time = document.getElementById("time"+ pid).value;
	var operator = document.getElementById("operator" + pid).value;
	var obj_pid = document.getElementById("pid" + return_spec);
	var obj_time =document.getElementById("time" + return_spec);

	var discount_obj = document.getElementById("Discount" + return_spec);
	var depart_obj = document.getElementById("Departure_form" + return_spec);
	var current_vol_obj = document.getElementById("vol" + return_spec + pid);
	var arrival_obj = document.getElementById("Arrival_form" + return_spec);
	var vol_obj = document.getElementById("vol" + return_spec);

	var departure_value;
	var discount_value;
	var arrival_value;
	var dd_arrival_value;
	var dd_departure_value;
	var has_operator;

	var arrival_pid_obj = document.getElementById('Arrival' + return_spec + pid);
	var departure_pid_obj = document.getElementById('Departure' + return_spec + pid);
	var discount_pid_obj = document.getElementById('Discount' + return_spec + pid);
	var operatorList_obj = document.getElementById("operatorList"  + return_spec);
	var dd_arrival_obj = document.getElementById("dd" + pid + "_Arrival");
	var dd_depart_obj = document.getElementById("dd" + pid + "_Departure");
        var st_obj = document.getElementById("st");

	if (arrival_pid_obj != null  )
	{
		arrival_value = arrival_pid_obj.value;
	}

	if (departure_pid_obj != null  )
	{
		departure_value = departure_pid_obj.value;
	}

	if (discount_pid_obj != null  )
	{
		discount_value = discount_pid_obj.value;
	}

	if (operatorList_obj != null && st_obj.value < 1)
	{
		has_operator = "true";
	}

	if (dd_arrival_obj != null  )
	{
		dd_arrival_value = dd_arrival_obj.value;
	}

	if (dd_depart_obj != null  )
	{
		dd_departure_value = dd_depart_obj.value;
	}

	depart_obj.value = departure_value;
	discount_obj.value = discount_value;
	arrival_obj.value = arrival_value;
	if (dd_arrival_value)
	{
		arrival_obj.value = dd_arrival_value ;
	}
	if(dd_departure_value)
	{
		depart_obj.value = dd_departure_value;
	}
	obj_pid.value = pid;
	obj_time.value = time;
	vol_obj.value = current_vol_obj.value;
	
 	if ( has_operator )
	{
		select_operator(operator, pid);
	}
}

function obj_value_change(value,current_pid,return_spec,operator)
{
	var pid_obj = document.getElementById("pid"+return_spec);
	var selected_pid = pid_obj.value;
	if (selected_pid =="" || current_pid != selected_pid)
	{
		document.getElementById("radselect" + return_spec + current_pid).checked =true;
		pid_obj.value = current_pid;
		var operatorList_obj = document.getElementById("operatorList"  + return_spec);
		if (operatorList_obj !=null)
		{
			select_operator(operator);
		}
	}
	set_hidden_value(return_spec,current_pid)
}


function validate_form()
{
	var pid = document.getElementById("pid").value;

	if(pid=="")
	{
		alert("Please select a departure schedule.");
		return false;
	}
	var depart_obj = document.getElementById('Departure_form');
	if (depart_obj.value =="")
	{
		alert("Please select a departure point from the drop down menu.");
		document.getElementById('Departure' + pid).focus();
		return false;
	}
	var arrival_obj = document.getElementById('Arrival' + pid);
	var departure_obj = document.getElementById('Departure' + pid);
	var discount_obj = document.getElementById('Discount' + pid);
	var ddl_arrival_obj = document.getElementById('dd' + pid + '_Arrival');
	var ddl_departure_obj = document.getElementById('dd' + pid + '_Departure');



	if (departure_obj != null  )
	{
		if (departure_obj.value =='')
		{
			alert("Please select a departure point from the drop down menu.");
        	departure_obj.focus();
			return false;
		}
	}

	if (ddl_departure_obj != null)
	{
		if (ddl_departure_obj.value =='')
		{
			alert("Please select a departure point from the drop down menu.");
        	ddl_departure_obj.focus();
			return false;
		}
		else
		{
			document.getElementById("Departure_form").value = ddl_departure_obj.value;
		}
	}

	if (arrival_obj != null  )
	{
		if ( arrival_obj.value =='' )
		{
			alert("Please Select Arrival of departure schedule!");
        	arrival_obj.focus();
			return false;
		}
	}

	if (ddl_arrival_obj != null)
	{
		if(ddl_arrival_obj.value =='')
		{
			alert("Please Select Arrival of departure schedule!");
        	ddl_arrival_obj.focus();
			return false;
		}
		else
		{
			document.getElementById("Arrival_form").value = ddl_arrival_obj.value;
		}
	}



	if (discount_obj != null)
	{
		if(discount_obj.value =='')
		{
			alert("Please Select Discount of departure schedule!");
        	discount_obj.focus();
			return false;
		}
	}

	if (document.getElementById("b_roundtrip").checked ==true)
	{
		var pid = document.getElementById("pid_return").value;
		if(document.getElementById("frmsearch").pid_return.value=="")
		{
			alert("Please select a return schedule.");
			return false;
		}
		var depart_obj_return = document.getElementById('Departure_form_return');
		if (depart_obj_return.value =="")
		{
			alert("Please select a departure point from the drop down menu.");
			document.getElementById('Departure_return' + pid).focus();
			return false;
		}

		var arrival_return_obj = document.getElementById('Arrival_return' + pid);
		var departure_return_obj = document.getElementById('Departure_return' + pid);
		var discount_return_obj = document.getElementById('Discount_return' + pid);
		var ddl_arrival_return_obj = document.getElementById('dd' + pid + '_Arrival');
		var ddl_departure_return_obj = document.getElementById('dd' + pid + '_Departure');


		if (departure_return_obj != null  )
		{
			if (departure_return_obj.value =='')
			{
				alert("Please select a departure point from the drop down menu.");
	        	departure_return_obj.focus();
				return false;
			}
		}

		if (ddl_departure_return_obj != null)
		{
			if (ddl_departure_return_obj.value =='')
			{
				alert("Please Select Reparture of return schedule!");
	        	ddl_departure_return_obj.focus();
				return false;
			}
			else
			{
				document.getElementById("Departure_form_return").value = ddl_departure_return_obj.value;
			}
		}

		if (arrival_return_obj != null  )
		{
			if ( arrival_return_obj.value =='' )
			{
				alert("Please Select Arrival of return schedule!");
	        	arrival_return_obj.focus();
				return false;
			}
		}


		if (ddl_arrival_return_obj != null)
		{
			if(ddl_arrival_return_obj.value =='')
			{
				alert("Please Select Arrival of return schedule!");
	        	ddl_arrival_return_obj.focus();
				return false;
			}
			else
			{
				document.getElementById("Arrival_form_return").value = ddl_arrival_return_obj.value;
			}
		}


		if (discount_return_obj != null)
		{
			if(discount_return_obj.value =='')
			{
				alert("Please Select Discount of return schedule!");
	        	discount_return_obj.focus();
				return false;
			}
		}


	}
	return true;
}

function form_submit()
{
	if (validate_form())
	{
		document.getElementById("frmsearch").submit();
	}
	else
	{
		return false;
	}
}

function pickdaterange_return()
{
    var dateObj = document.getElementById("beforethisdate_return");
    var dateFilter = dateObj.options[dateObj.selectedIndex].value;
    if (document.bus_search && document.bus_search.return_date)
    {
        document.bus_search.return_date.value = dateFilter;
    }
    server_update();
    window.document.getElementById("beforethisdate_return").focus();
}

function get_dynamic_price(pid,service_date,quick)
{
	document.getElementById("dynamic_price" + pid).innerHTML = "<font color='red'>Pricing..</font>";
	if(window.XMLHttpRequest) {
		dynamic_xml = new XMLHttpRequest();
	} else {
		dynamic_xml = new ActiveXObject("MSXML2.XMLHTTP");
	}
	var url = '/cgi-bin/ajax.cgi?type=dynamic_price&pid=' + pid + '&service_date=' + service_date + '&quick=' + quick;
	dynamic_xml.open("GET", url, true);
	dynamic_xml.onreadystatechange = function() {response_dynamic_price(pid);}
	dynamic_xml.setRequestHeader("If-Modified-Since","0");
	dynamic_xml.send("");
}

function response_dynamic_price(pid)
{
	if (dynamic_xml.readyState == 4)
	{
		var response = dynamic_xml.responseText;
		document.getElementById("dynamic_price" + pid).innerHTML = response;
	}
}

function dynamic_image(pid)
{
	var dynamic_image_html = document.getElementById("dynamic_price_hidden" + pid).innerHTML;
	document.getElementById("dynamic_price" + pid).innerHTML = dynamic_image_html;

}

function show_dynamic(pid)
{
	if (document.getElementById("return_flag" + pid ).value =="return")
	{
		get_dynamic_price(pid,document.getElementById('beforethisdate_return').value,1);
	}
	else
	{
		get_dynamic_price(pid,document.getElementById('beforethisdate').value,1);
	}
	setTimeout("dynamic_image('" + pid + "')",600000);
}

function show_dynamic_prices(pids, service_date, return_pids, return_date)
{
	if(window.XMLHttpRequest) {
		dynamic_xml_all = new XMLHttpRequest();
	} else {
		dynamic_xml_all = new ActiveXObject("MSXML2.XMLHTTP");
	}
	var url = '/cgi-bin/get_ajax_content.cgi?type=dynamic_prices&pids=' + pids + '&service_date=' + service_date + '&return_pids=' + return_pids + '&return_date=' + return_date;
	dynamic_xml_all.open("GET", url, true);
	dynamic_xml_all.onreadystatechange = function() {response_dynamic_prices(pids, return_pids);}
	dynamic_xml_all.setRequestHeader("If-Modified-Since","0");
	dynamic_xml_all.send("");
}

function response_dynamic_prices(pids, return_pids)
{
	if (dynamic_xml_all.readyState == 4)
	{
		var response = dynamic_xml_all.responseText;
		var arr_response = response.split("|");
		var index = 0;
		if (pids != '')
		{
			var pids_array = pids.split("|");
			for(i = 0; i < pids_array.length; i++)
			{
				document.getElementById("dynamic_price" + pids_array[i]).innerHTML = arr_response[i];
				index++;
			}
		}
		if (return_pids != '')
		{
			var return_pids_array = return_pids.split("|");
			for(i = 0; i < return_pids_array.length; i++)
			{
				document.getElementById("dynamic_price" + return_pids_array[i]).innerHTML = arr_response[i+index];
			}
		}
	}
}

//-->
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================


/* SOURCE FILE: AnchorPosition.js */

/* 
AnchorPosition.js
Author: Matt Kruse
Last modified: 10/11/02

DESCRIPTION: These functions find the position of an <A> tag in a document,
so other elements can be positioned relative to it.

COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the 
Macintosh platform.

FUNCTIONS:
getAnchorPosition(anchorname)
  Returns an Object() having .x and .y properties of the pixel coordinates
  of the upper-left corner of the anchor. Position is relative to the PAGE.

getAnchorWindowPosition(anchorname)
  Returns an Object() having .x and .y properties of the pixel coordinates
  of the upper-left corner of the anchor, relative to the WHOLE SCREEN.

NOTES:

1) For popping up separate browser windows, use getAnchorWindowPosition. 
   Otherwise, use getAnchorPosition

2) Your anchor tag MUST contain both NAME and ID attributes which are the 
   same. For example:
   <A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the 
   anchor tag correctly. Do not do <A></A> with no space.
*/ 

// getAnchorPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the page.
function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// getAnchorWindowPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the window
function getAnchorWindowPosition(anchorname) {
	var coordinates=getAnchorPosition(anchorname);
	var x=0;
	var y=0;
	if (document.getElementById) {
		if (isNaN(window.screenX)) {
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
			}
		else {
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
			}
		}
	else if (document.all) {
		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
		y=coordinates.y-document.body.scrollTop+window.screenTop;
		}
	else if (document.layers) {
		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
	}	
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
	}

/* 
PopupWindow.js
Author: Matt Kruse
Last modified: 02/16/04

DESCRIPTION: This object allows you to easily and quickly popup a window
in a certain place. The window can either be a DIV or a separate browser
window.

COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the 
Macintosh platform. Due to bugs in Netscape 4.x, populating the popup 
window with <STYLE> tags may cause errors.

USAGE:
// Create an object for a WINDOW popup
var win = new PopupWindow(); 

// Create an object for a DIV window using the DIV named 'mydiv'
var win = new PopupWindow('mydiv'); 

// Set the window to automatically hide itself when the user clicks 
// anywhere else on the page except the popup
win.autoHide(); 

// Show the window relative to the anchor name passed in
win.showPopup(anchorname);

// Hide the popup
win.hidePopup();

// Set the size of the popup window (only applies to WINDOW popups
win.setSize(width,height);

// Populate the contents of the popup window that will be shown. If you 
// change the contents while it is displayed, you will need to refresh()
win.populate(string);

// set the URL of the window, rather than populating its contents
// manually
win.setUrl("http://www.site.com/");

// Refresh the contents of the popup
win.refresh();

// Specify how many pixels to the right of the anchor the popup will appear
win.offsetX = 50;

// Specify how many pixels below the anchor the popup will appear
win.offsetY = 100;

NOTES:
1) Requires the functions in AnchorPosition.js

2) Your anchor tag MUST contain both NAME and ID attributes which are the 
   same. For example:
   <A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the 
   anchor tag correctly. Do not do <A></A> with no space.

4) When a PopupWindow object is created, a handler for 'onmouseup' is
   attached to any event handler you may have already defined. Do NOT define
   an event handler for 'onmouseup' after you define a PopupWindow object or
   the autoHide() will not work correctly.
*/ 

// Set the position of the popup window based on the anchor
function PopupWindow_getXYPosition(anchorname) {
	var coordinates;
	if (this.type == "WINDOW") {
		coordinates = getAnchorWindowPosition(anchorname);
		}
	else {
		coordinates = getAnchorPosition(anchorname);
		}
	this.x = coordinates.x;
	this.y = coordinates.y;
	}
// Set width/height of DIV/popup window
function PopupWindow_setSize(width,height) {
	this.width = width;
	this.height = height;
	}
// Fill the window with contents
function PopupWindow_populate(contents) {
	this.contents = contents;
	this.populated = false;
	}
// Set the URL to go to
function PopupWindow_setUrl(url) {
	this.url = url;
	}
// Set the window popup properties
function PopupWindow_setWindowProperties(props) {
	this.windowProperties = props;
	}
// Refresh the displayed contents of the popup
function PopupWindow_refresh() {
	if (this.divName != null) {
		// refresh the DIV object
		if (this.use_gebi) {
			document.getElementById(this.divName).innerHTML = this.contents;
			}
		else if (this.use_css) { 
			document.all[this.divName].innerHTML = this.contents;
			}
		else if (this.use_layers) { 
			var d = document.layers[this.divName]; 
			d.document.open();
			d.document.writeln(this.contents);
			d.document.close();
			}
		}
	else {
		if (this.popupWindow != null && !this.popupWindow.closed) {
			if (this.url!="") {
				this.popupWindow.location.href=this.url;
				}
			else {
				this.popupWindow.document.open();
				this.popupWindow.document.writeln(this.contents);
				this.popupWindow.document.close();
			}
			this.popupWindow.focus();
			}
		}
	}
// Position and show the popup, relative to an anchor object
function PopupWindow_showPopup(anchorname) {
	this.getXYPosition(anchorname);
	this.x += this.offsetX;
	this.y += this.offsetY;
	if (!this.populated && (this.contents != "")) {
		this.populated = true;
		this.refresh();
		}
	if (this.divName != null) {
		// Show the DIV object
		if (this.use_gebi) {
			document.getElementById(this.divName).style.left = this.x + "px";
			document.getElementById(this.divName).style.top = this.y + "px";
			document.getElementById(this.divName).style.visibility = "visible";
			}
		else if (this.use_css) {
			document.all[this.divName].style.left = this.x;
			document.all[this.divName].style.top = this.y;
			document.all[this.divName].style.visibility = "visible";
			}
		else if (this.use_layers) {
			document.layers[this.divName].left = this.x;
			document.layers[this.divName].top = this.y;
			document.layers[this.divName].visibility = "visible";
			}
		}
	else {
		if (this.popupWindow == null || this.popupWindow.closed) {
			// If the popup window will go off-screen, move it so it doesn't
			if (this.x<0) { this.x=0; }
			if (this.y<0) { this.y=0; }
			if (screen && screen.availHeight) {
				if ((this.y + this.height) > screen.availHeight) {
					this.y = screen.availHeight - this.height;
					}
				}
			if (screen && screen.availWidth) {
				if ((this.x + this.width) > screen.availWidth) {
					this.x = screen.availWidth - this.width;
					}
				}
			var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled );
			this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");
			}
		this.refresh();
		}
	}
// Hide the popup
function PopupWindow_hidePopup() {
	if (this.divName != null) {
		if (this.use_gebi) {
			if (document.getElementById(this.divName))
			{
				document.getElementById(this.divName).style.visibility = "hidden";
			}
			}
		else if (this.use_css) {
			document.all[this.divName].style.visibility = "hidden";
			}
		else if (this.use_layers) {
			document.layers[this.divName].visibility = "hidden";
			}
		}
	else {
		if (this.popupWindow && !this.popupWindow.closed) {
			this.popupWindow.close();
			this.popupWindow = null;
			}
		}
	}
// Pass an event and return whether or not it was the popup DIV that was clicked
function PopupWindow_isClicked(e) {
	if (this.divName != null) {
		if (this.use_layers) {
			var clickX = e.pageX;
			var clickY = e.pageY;
			var t = document.layers[this.divName];
			if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) {
				return true;
				}
			else { return false; }
			}
		else if (document.all) { // Need to hard-code this to trap IE for error-handling
			var t = window.event.srcElement;
			while (t.parentElement != null) {
				if (t.id==this.divName) {
					return true;
					}
				t = t.parentElement;
				}
			return false;
			}
		else if (this.use_gebi && e) {
			var t = e.originalTarget;
			while (t.parentNode != null) {
				if (t.id==this.divName) {
					return true;
					}
				t = t.parentNode;
				}
			return false;
			}
		return false;
		}
	return false;
	}

// Check an onMouseDown event to see if we should hide
function PopupWindow_hideIfNotClicked(e) {
	if (this.autoHideEnabled && !this.isClicked(e)) {
		this.hidePopup();
		}
	}
// Call this to make the DIV disable automatically when mouse is clicked outside it
function PopupWindow_autoHide() {
	this.autoHideEnabled = true;
	}
// This global function checks all PopupWindow objects onmouseup to see if they should be hidden
function PopupWindow_hidePopupWindows(e) {
	for (var i=0; i<popupWindowObjects.length; i++) {
		if (popupWindowObjects[i] != null) {
			var p = popupWindowObjects[i];
			p.hideIfNotClicked(e);
			}
		}
	}
// Run this immediately to attach the event listener
function PopupWindow_attachListener() {
	if (document.layers) {
		document.captureEvents(Event.MOUSEUP);
		}
	window.popupWindowOldEventListener = document.onmouseup;
	if (window.popupWindowOldEventListener != null) {
		document.onmouseup = new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();");
		}
	else {
		document.onmouseup = PopupWindow_hidePopupWindows;
		}
	}
// CONSTRUCTOR for the PopupWindow object
// Pass it a DIV name to use a DHTML popup, otherwise will default to window popup
function PopupWindow() {
	if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }
	if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }
	if (!window.listenerAttached) {
		window.listenerAttached = true;
		PopupWindow_attachListener();
		}
	this.index = popupWindowIndex++;
	popupWindowObjects[this.index] = this;
	this.divName = null;
	this.popupWindow = null;
	this.width=0;
	this.height=0;
	this.populated = false;
	this.visible = false;
	this.autoHideEnabled = false;
	
	this.contents = "";
	this.url="";
	this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";
	if (arguments.length>0) {
		this.type="DIV";
		this.divName = arguments[0];
		}
	else {
		this.type="WINDOW";
		}
	this.use_gebi = false;
	this.use_css = false;
	this.use_layers = false;
	if (document.getElementById) { this.use_gebi = true; }
	else if (document.all) { this.use_css = true; }
	else if (document.layers) { this.use_layers = true; }
	else { this.type = "WINDOW"; }
	this.offsetX = 0;
	this.offsetY = 0;
	// Method mappings
	this.getXYPosition = PopupWindow_getXYPosition;
	this.populate = PopupWindow_populate;
	this.setUrl = PopupWindow_setUrl;
	this.setWindowProperties = PopupWindow_setWindowProperties;
	this.refresh = PopupWindow_refresh;
	this.showPopup = PopupWindow_showPopup;
	this.hidePopup = PopupWindow_hidePopup;
	this.setSize = PopupWindow_setSize;
	this.isClicked = PopupWindow_isClicked;
	this.autoHide = PopupWindow_autoHide;
	this.hideIfNotClicked = PopupWindow_hideIfNotClicked;
	}

function b_text(obj, text,event)
{
	var b_obj = document.getElementById('balloon').style;
	var tt = "<table bgcolor=#999999 width=100% cellpadding=3 cellspacing=1><tr><td bgcolor=#ffffff class=\"balloon_text\">" + text + "</td></tr></table>";
	document.getElementById('balloon').innerHTML = tt;
	var pos = el_pos(obj,event);
	b_obj.top = pos.y + 4;
	b_obj.left = pos.x + 4;
	b_obj.visibility = "visible";
	b_obj.display = "block";
}

function show_bus_station_info(diplay_obj,text,mark)
{
	var counts_str = "counts" + mark;
	var counts_obj = document.getElementById(counts_str);
	var count=counts_obj.value;
	var display_value = "display_value" + mark + diplay_obj;
	var current_display = "display" +  mark + diplay_obj;
	var div_listarea = document.getElementById("listarea");
	var div_listarea_return = document.getElementById("listarea_return");
	var radselect_objs = document.getElementsByName("radselect");
	var count1=radselect_objs.length;
	document.getElementById(display_value).innerHTML = text;	
	for (var i=1; i<=count; i++)
    {
    	var display_id = "display" + mark + i;
	var click_here_id = "click_here" + i;
		var click_here_obj = document.getElementById(click_here_id);
    	if (document.getElementById(display_id) && display_id != current_display)
    	{
	    	var div_display = document.getElementById(display_id).style;
	    	if (div_display.display != "none")
	    	{
	    		div_display.display = "none";
	    		click_here_obj.innerHTML = "Click for Bus Stations and Details";
	    	}
	    }
    }    
    var click_here_id = "click_here" + diplay_obj;
	var click_here_obj = document.getElementById(click_here_id);
    var current_div = document.getElementById(current_display).style;
    if (current_div.display != "")
	{
		if (div_listarea != null && mark == 'b')
		{
			var listarea_height
			listarea_height = 12 * 56 + 50;
			if ( count1 <= 12 )
			{
				listarea_height = count1 * 56 + 180;		    	
				div_listarea.style.overflow = "auto";
			}			
			div_listarea.style.height = listarea_height + 'px';	
		}
		if (div_listarea_return != null && mark == 'c')
		{
			var listarea_height
			listarea_height = 12 * 56 + 50;
			if ( count1 <= 12 )
			{
				listarea_height = count1 * 56 + 180;		    	
				div_listarea_return.style.overflow = "auto";
			}			
			div_listarea_return.style.height = listarea_height + 'px';	
		}
		current_div.display = "";
		if (click_here_obj != null)
		{
			click_here_obj.innerHTML = "Hide details";	
		}
	}
	else
	{
		if (div_listarea != null && mark == 'b')
		{
			var listarea_height
			listarea_height = 12 * 56 + 50;
			if ( count1 <= 12 )
			{
				listarea_height = count1 * 56 + 10;	
				div_listarea.style.overflow = "hidden";
			}
			div_listarea.style.height = listarea_height + 'px';
		}
		if (div_listarea_return != null && mark == 'c')
		{
			var listarea_height
			listarea_height = 12 * 56 + 50;
			if ( count1 <= 12 )
			{
				listarea_height = count1 * 56 + 10;	
				div_listarea_return.style.overflow = "hidden";
			}
			div_listarea_return.style.height = listarea_height + 'px';
		}
		current_div.display = "none";
		if (click_here_obj != null)
		{
			click_here_obj.innerHTML = "Click for Bus Stations and Details";	
		}
	}		
}

function no_b_text()
{
	var b_obj = document.getElementById('balloon').style;
	b_obj.visibility = "hidden";
	b_obj.display = "none";
}

function onBalloonOver()
{
	var b_obj = document.getElementById('balloon').style;
	b_obj.visibility = "visible";
	b_obj.display = "block";
}

function onBalloonOut()
{
        var b_obj = document.getElementById('balloon').style;
        b_obj.visibility = "hidden";
        b_obj.display = "none";
}

function el_pos(obj,event)
{
    var xOffset, yOffset;
	if (event)
	{
		xOffset =  event.clientX + document.body.scrollLeft -10;
		yOffset = event.clientY + document.body.scrollTop -10;
	}
	else
	{
    	if(obj.offsetTop != 'undefined'){
        	yOffset = (obj.offsetTop?obj.offsetTop:0);
        	xOffset = (obj.offsetLeft?obj.offsetLeft:0);
        	yOffset -= (obj.scrollTop?obj.scrollTop:0);
        	xOffset -= (obj.scrollLeft?obj.scrollLeft:0);
        	elParent = obj.offsetParent;
        	while(elParent){
            	yOffset += (elParent.offsetTop?elParent.offsetTop:0);
            	xOffset += (elParent.offsetLeft?elParent.offsetLeft:0);
	    		yOffset -= (elParent.scrollTop?elParent.scrollTop:0);
            	xOffset -= (elParent.scrollLeft?elParent.scrollLeft:0);
            elParent = elParent.offsetParent;
        }
    	} else if(typeof obj.y != 'undefined'){
	alert(obj.y);
        yOffset = obj.y;
        xOffset = obj.x;
    	} else {      //information is not available
        yOffset = -1;
        xOffset = -1;
    } 
	}
    return {x:xOffset,y:yOffset};
}

function long_option_clicked(popup_obj, div_name)
{
	var div_obj = document.getElementById(div_name);
	var i_obj = document.getElementById('i' + div_name);
	var style_obj = div_obj.style;
	var pos = el_pos(i_obj);
	popup_obj.offsetY = 20;
	popup_obj.offsetX = -200;
	popup_obj.showPopup("i" + div_name);
}

function long_option_closed(popup_obj, div_name)
{
	popup_obj.hidePopup();
}

function long_option_selected(obj, div_name, popup_obj)
{
	document.getElementById('d' + div_name).value = obj.value;
	long_option_closed(popup_obj, div_name);
}

function validate_form_selections(f)
{
	var plObj = document.getElementById("Provide_Later");
	var check_text = true;
	if (plObj != null && plObj.checked)
	{
		check_text = false;
	}
	var total_people_count = -1;
	var room_array = [];
	var room_count = 0;
    for (var i=0, j=f.elements.length; i<j; i++)
    {
        var t = f.elements[i].type;
        if (t.match(/select/))
        {
			var sname = f.elements[i].name;
			if (sname.match(/^Room(.)(Adult|Child)/i))
			{
				if (total_people_count == -1)
				{
					total_people_count = 0;
				}
				var pnum =  parseInt(f.elements[i].value);
				total_people_count += pnum;

				if (pnum > 0)
				{
					var room_no = parseInt(sname[4])-1;
					if (room_array[room_no] == undefined)
					{
						room_array[room_no] = 0;
					}
					room_array[room_no] += pnum;
					if (room_no+1 > room_count)
					{
						room_count = room_no+1;
					}
				}
			}
            if (f.elements[i].value == '')
            {
                alert("Please Select " + f.elements[i].name + "!");
                f.elements[i].focus();
                return false;
            }
        }
		else if (t.match(/text/) && check_text)
	{
	    if (f.elements[i].value == '')
	    {
	    	alert("Please enter a value the text field!");
	    	f.elements[i].focus();
		return false;
	    }
	}
    }

	if (total_people_count == 0)
	{
		alert("Please select adult/child number!");
        return false;
	}

	var max_capacity = 4;
	for ( i=0; i < room_count; i++)
	{
		if (room_array[i] > max_capacity)
		{
			alert("The number of passengers cannot be greater than 4 for each room.");
			return false;
		}
	}

    if (f.Date != null && f.Date.value == '')
    {
        alert("Please select a valid Date!");
        return false;
    }
    if (f.time != null && f.time.value < 1.01)
    {
        return confirm("Important: It is a new date after passing 12:00am.\nYou have selected a very early schedule on " + f.Date.value + ".  Please confirm.");
    }
}

document.write('<link href=\"http://www.gotobus.com/css/searchbox.css\" rel=\"stylesheet\" type=\"text/css\">');
document.write('<div ID=\"calendarDiv\" style=\"position:absolute;visibility:hidden;background-color:#ffffff;layer-background-color:#ffffff;\"></div>');
document.write('<table width=\"100%\" align=\"center\" cellspacing=\"2\" bgcolor=\"#cc0000\" border=\"0\" cellpadding=\"0\">');
document.write('<tr>');
document.write('  <td bgcolor=\"#ffffff\" width=\"98%\" align=\"center\">');
document.write('  	<script language=\"JavaScript\">');
document.write('     var bd_cal = new CalendarPopup(\"calendarDiv\");');
document.write('	 bd_cal.offsetX = -85;');
document.write('	 bd_cal.offsetY = 16;');
document.write('	 bd_cal.setCssPrefix(\'Bus_\');');
document.write('     var br_cal = new CalendarPopup(\"calendarDiv\");');
document.write('	 br_cal.offsetX = -85;');
document.write('	 br_cal.offsetY = 16;');
document.write('	 br_cal.setCssPrefix(\'Bus_\');');
document.write('     var last_date = new Date(past_date.valueOf() + 90 * aDay);');
document.write('     bd_cal.addDisabledDates(null,formatDate(past_date,\"yyyy-MM-dd\"));');
document.write('     bd_cal.addDisabledDates(formatDate(last_date, \"yyyy-MM-dd\"),null);');
document.write('	 bd_cal.setReturnFunction(\'bus_departure_date_clicked\');');
document.write('     br_cal.addDisabledDates(null,formatDate(past_date,\"yyyy-MM-dd\"));');
document.write('     br_cal.addDisabledDates(formatDate(last_date, \"yyyy-MM-dd\"),null);');
document.write('	 br_cal.setReturnFunction(\'bus_return_date_clicked\');');
document.write('	</script>');
document.write('<form name=\"bus_search\" class=\"ivySearchForm\" method=\"get\" onSubmit=\"return check_bus_data();\" action=\"http://search.gotobus.com/cgi-bin/bus.cgi\">');
document.write('<input type=\"hidden\" name=\"nm\" value=\"__AFFID__\"> <input type=\"hidden\" name=\"st\" value=\"4048\"> <input type=\"hidden\" name=\"option\" value=\"Select\">');
document.write('<table align=\"center\" width=\"98%\" cellspacing=\"0\" cellpadding=\"1\" border=\"0\">');
document.write('<tr>');
document.write('  <td colspan=\"2\" height=\"36\">');
document.write('    <input type=\"radio\" id=\"b_oneway\" name=\"roundtrip\" value=\"0\" onClick=\"select_oneway();\"><b>One Way</b>');
document.write('	<input type=\"radio\" id=\"b_roundtrip\" name=\"roundtrip\" value=\"1\" onClick=\"select_roundtrip();\"><b>Roundtrip</b>');
document.write(' </td>');
document.write('</tr>');
document.write('<tr>');
document.write('  <td width=\"72%\" height=\"44\">');
document.write('	  <table width=\"100%\" cellspacing=2 cellpadding=2 border=\"0\" height=\"44\">');
document.write('  <tr>');
document.write('	<td width=\"50%\" valign=\"top\"><small>Select or Enter Departure:</small><br>');
document.write('    <div style=\"position:absolute;\"><span style=\"margin-left:142px;width:18px;overflow:hidden;\">');
document.write('        <select id=\"bus_from\" name=\"bus_from\" class=\"textbox\" style=\"width:160px;margin-left:-142px\" onChange=\"this.parentNode.nextSibling.value=this.value;document.getElementById(\'sbus_to_id\').value=\'\';update_bus_to(this.options[this.selectedIndex].value);copy_select_to_search();\">');
document.write('      <option>Departure City</option>');
document.write('	</select>');
document.write('        </span><input class=\"textbox\" type=\"text\" size=\"18\" name=\"sbus_from\"  style=\"width:142px;position:absolute;left:0px;\" class=\"textbox\" onChange=\"conditional_clear();\"');
document.write('	 	onclick=\'this.select();\' id=\"sbus_from_id\" autocomplete=\"off\" onfocus=\"setComplete(this, b_cities);\"  onblur=\"copy_search_to_select();document.getElementById(\'sbus_to_id\').value=\'\';\">');
document.write('   	      <div id=\"sbus_from_cnt\" style=\"display:none;border:1px solid black;background-color:white;cursor:pointer;height:100px;overflow:auto;\"></div>');
document.write('    </div>');
document.write('	</td>');
document.write('	<td valign=\"top\">');
document.write('      <small>Select or Enter Arrival:</small><br>');
document.write('       <div style=\"position:absolute;\"> <span style=\"margin-left:142px;width:18px;overflow:hidden;\">');
document.write('        <select id=\"bus_to\" name=\"bus_to\"  class=\"textbox\" style=\"width:160px;margin-left:-142px\" onChange=\"this.parentNode.nextSibling.value=this.value;jump_or_clear();copy_select_to_search();\" >');
document.write('      <option>Arrival City</option>');
document.write('      </select>');
document.write('        </span><input class=\"textbox\" type=\"text\" size=\"18\" name=\"sbus_to\"  onChange=\"conditional_clear();\" style=\"width:142px;position:absolute;left:0px;\" class=\"textbox\"');
document.write('	    onclick=\'this.select();\' id=\"sbus_to_id\" autocomplete=\"off\"  onfocus=\"setComplete(this, document.getElementById(\'sbus_from_id\').value);update_bus_to(document.getElementById(\'sbus_from_id\').value);\"  onblur=\"copy_search_to_select();\">');
document.write('  	<div id=\"sbus_to_cnt\" style=\"display:none;border:1px solid black;background-color:white;cursor:pointer;height:100px;overflow:auto;\"></div>');
document.write('        </div>');
document.write('	</td>');
document.write('  </tr>');
document.write('  </table>');
document.write('');
document.write('  </td>');
document.write('  <td><a href=\"#\" onclick=\"reverse_from_to();\">Reverse</a></td>');
document.write('</tr>');
document.write('<tr>');
document.write('  <td height=\"48\">');
document.write('  <table width=\"100%\" cellspacing=2 cellpadding=2 border=0>');
document.write('  <tr>');
document.write('    <td width=\"50%\">');
document.write('	  <small>Depart Date:</small><br>');
document.write('      <input type=\"text\" name=\"filter_date\" value=\"\" onChange=\"conditional_update();\" style=\"font-size: 12px; font-family: Arial; width:72px;\">');
document.write('      <a href=\"#\" onClick=\"bd_cal.select(document.bus_search.filter_date,\'bd_date\',\'yyyy-MM-dd\'); return false;\" NAME=\"bd_date\" ID=\"bd_date\"><img border=0 alt=\"Popup Calendar\" src=\"http://www.gotobus.com/images/calendar.gif\"></a>');
document.write('    </td>');
document.write('	<td width=\"50%\">');
document.write('	  <small>Return Date:</small><br>');
document.write('	  <script language=\"JavaScript\">');
document.write('        var rd_popup = new PopupWindow(\"rdate_popup\");');
document.write('	    rd_popup.offsetY = 24;');
document.write('		rd_popup.autoHide();');
document.write('	  </script>');
document.write('');
document.write('	  <div id=\"rdate_popup\" style=\"position:absolute;visibility:hidden;\">');
document.write('	    <table bgcolor=\'#999999\' width=130 cellpadding=3 cellspacing=1>');
document.write('		<tr>');
document.write('		  <td bgcolor=\'#ffffe1\' style=\"font-family:ariel,sans-serif;font-size:9pt\">');
document.write('		  <center>Change to roundtrip?</center><br>');
document.write('		  <table align=center>');
document.write('		  <tr>');
document.write('		    <td>');
document.write('			<input type=\'button\' value=\'Yes\' onClick=\"rd_popup.hidePopup();enable_roundtrip();\">');
document.write('			</td>');
document.write('			<td>');
document.write('			<input type=\'button\' value=\'No\' onClick=\'rd_popup.hidePopup();\'>');
document.write('			</td>');
document.write('		  </tr>');
document.write('		  </table>');
document.write('		  </td>');
document.write('		</tr>');
document.write('		</table>');
document.write('	  </div>');
document.write('');
document.write('	  <span NAME=\"r_text_date\" ID=\"r_text_date\">');
document.write('	  <input type=\"text\" name=\"return_date\" onClick=\"check_oneway_text();\" value=\"\" onChange=\"conditional_update();\" style=\"font-size: 12px; font-family: Arial; width:72px;\"></span>');
document.write('	  <span onClick=\"check_oneway_image();\" NAME=\"br_date\" ID=\"br_date\"><img border=0 alt=\"Popup Calendar\" src=\"http://www.gotobus.com/images/calendar.gif\"></span>');
document.write('     </td>');
document.write('  </tr>');
document.write('  </table>');
document.write('  </td>');
document.write('  <td>');
document.write('  <small>Qty:</small><br>');
document.write('      <select name=\"quantity\" onChange=\"change_passengers(this.value);\">');
document.write('		<option value=\"1\" selected>1</option>');
document.write('		<option value=\"2\">2</option>');
document.write('		<option value=\"3\">3</option>');
document.write('		<option value=\"4\">4</option>');
document.write('		<option value=\"5\">5</option>');
document.write('		<option value=\"6\">6</option>');
document.write('		<option value=\"7\">7</option>');
document.write('		<option value=\"8\">8</option>');
document.write('		<option value=\"9\">9</option>');
document.write('		<option value=\"10\">10</option>');
document.write('		<option value=\"11\">11</option>');
document.write('		<option value=\"12\">12</option>');
document.write('		<option value=\"13\">13</option>');
document.write('		<option value=\"14\">14</option>');
document.write('		<option value=\"15\">15</option>');
document.write('		<option value=\"16\">16</option>');
document.write('		<option value=\"17\">17</option>');
document.write('		<option value=\"18\">18</option>');
document.write('		<option value=\"19\">19</option>');
document.write('		<option value=\"20\">20</option>');
document.write('		<option value=\"21\">21</option>');
document.write('		<option value=\"22\">22</option>');
document.write('		<option value=\"23\">23</option>');
document.write('		<option value=\"24\">24</option>');
document.write('		<option value=\"25\">25</option>');
document.write('		<option value=\"26\">26</option>');
document.write('		<option value=\"27\">27</option>');
document.write('		<option value=\"28\">28</option>');
document.write('		<option value=\"29\">29</option>');
document.write('		<option value=\"30\">30</option>');
document.write('      </select>');
document.write('');
document.write('  &nbsp; <input type=\"submit\" value=\"Search\">');
document.write('  </td>');
document.write('</tr>');
document.write('</table>');
document.write('</form>');
document.write('');
document.write('		<script language=\"javascript\" src=\"/js/aff/bus4048.js\"></script>');
document.write('		<script type=\"text/javascript\" src=\"http://search.gotobus.com/js/soap_search.js\"></script>');
document.write('		<script language=\"javascript\" src=\"/js/balloon_option.js\"></script>');
document.write('		<script type=\"text/javascript\" src=\"/js/ac/actb.js\"></script>');
document.write('		<script type=\"text/javascript\" src=\"/js/ac/common.js\"></script>');
document.write('		');
document.write('		<script language=\"javascript\">');
document.write('');
document.write('	update_bus_from();');
document.write('if (document.bus_search.filter_date.value == \'\')');
document.write('{');
document.write('	var b_date = new Date(past_date.valueOf() + aDay);');
document.write('	document.bus_search.filter_date.value = formatDate(b_date, \"yyyy-MM-dd\");');
document.write('}');
document.write('');
document.write('var bf_obj = get_bus_from_obj();');
document.write('var bt_obj = get_bus_to_obj();');
document.write('var sbf_obj = get_sbus_from_obj();');
document.write('var sbt_obj = get_sbus_to_obj();');
document.write('if (bf_obj.options.selectedIndex > 0)');
document.write('{');
document.write('');
document.write('	var bt_index = bt_obj.options.selectedIndex;');
document.write('	update_bus_to(bf_obj.options[bf_obj.selectedIndex].value);');
document.write('	if (bt_index >= 0)');
document.write('	{');
document.write('		bt_obj.options.selectedIndex = bt_index;');
document.write('		sbf_obj.value = bt_obj.options[bt_index].value;');
document.write('	}');
document.write('}');
document.write('else');
document.write('{');
document.write('	var cf = get_cookie(\'gbfrom\');');
document.write('	var ct = get_cookie(\'gbto\');');
document.write('	update_bus_from_to(cf, ct);');
document.write('	if (cf == null || cf ==\"\" || bf_obj.options.selectedIndex <=0)');
document.write('	{');
document.write('		sbf_obj.value = \"Departure City\";');
document.write('	}');
document.write('	else');
document.write('	{');
document.write('		sbf_obj.value = cf;');
document.write('	}');
document.write('	if (ct == null || ct ==\"\" || bt_obj.options.selectedIndex <=0)');
document.write('	{');
document.write('		sbt_obj.value = \"Arrival City\";');
document.write('	}');
document.write('	else');
document.write('	{');
document.write('		sbt_obj.value = ct;');
document.write('	}');
document.write('}');
document.write('if (document.bus_search.b_roundtrip.checked == false)');
document.write('{');
document.write('	document.bus_search.b_oneway.checked = true;');
document.write('}');
document.write('</script>');
document.write('');
document.write('  </td>');
document.write('</tr>');
document.write('</table>');
document.write('<script language=\"javascript\">');
document.write('update_bus_from();');
document.write('if (document.bus_search.filter_date.value == \'\')');
document.write('{');
document.write('	var b_date = new Date(past_date.valueOf() + aDay);');
document.write('	document.bus_search.filter_date.value = formatDate(b_date, \"yyyy-MM-dd\");');
document.write('}');
document.write('');
document.write('var bf_obj = get_bus_from_obj();');
document.write('var bt_obj = get_bus_to_obj();');
document.write('var sbf_obj = get_sbus_from_obj();');
document.write('var sbt_obj = get_sbus_to_obj();');
document.write('if (bf_obj.options.selectedIndex > 0)');
document.write('{');
document.write('');
document.write('	var bt_index = bt_obj.options.selectedIndex;');
document.write('	update_bus_to(bf_obj.options[bf_obj.selectedIndex].value);');
document.write('	if (bt_index >= 0)');
document.write('	{');
document.write('		bt_obj.options.selectedIndex = bt_index;');
document.write('		sbf_obj.value = bt_obj.options[bt_index].value;');
document.write('	}');
document.write('}');
document.write('else');
document.write('{');
document.write('	var cf = get_cookie(\'gbfrom\');');
document.write('	var ct = get_cookie(\'gbto\');');
document.write('	update_bus_from_to(cf, ct);');
document.write('	if (cf == null || cf ==\"\" || bf_obj.options.selectedIndex <=0)');
document.write('	{');
document.write('		sbf_obj.value = \"Departure City\";');
document.write('	}');
document.write('	else');
document.write('	{');
document.write('		sbf_obj.value = cf;');
document.write('	}');
document.write('	if (ct == null || ct ==\"\" || bt_obj.options.selectedIndex <=0)');
document.write('	{');
document.write('		sbt_obj.value = \"Arrival City\";');
document.write('	}');
document.write('	else');
document.write('	{');
document.write('		sbt_obj.value = ct;');
document.write('	}');
document.write('}');
document.write('if (document.bus_search.b_roundtrip.checked == false)');
document.write('{');
document.write('	document.bus_search.b_oneway.checked = true;');
document.write('}');
document.write('if (aff_id != null)');
document.write('{');
document.write('	document.bus_search.nm.value = aff_id;');
document.write('}');
document.write('if (document.bus_search.gid)');
document.write('{');
document.write('	document.bus_search.gid.value = aff_id;');
document.write('}');
document.write('if (typeof(preset_departure) != \'undefined\')');
document.write('{');
document.write('	if (preset_departure !=\'\' && preset_arrival != \'\')	');
document.write('	{');
document.write('		update_bus_from_to(preset_departure, preset_arrival);');
document.write('	}');
document.write('}');
document.write('</script>');
