
function openStationListFB() {
    stations = window.open('http://www.amtrak.com/html/stations_A.html','stationListWindow','width=530,height=450,directories=no,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes');    
    stations.focus();
}

function disableReturnData()
{
	var link = document.getElementById("calLink2");
	
	if(document.getElementById("oneway").checked){
		//alert("oneway");
		document.getElementById("wdfdate2").value = "";
		document.getElementById("wdfdate2").disabled = true;
		document.getElementById("tickets_ret_time").disabled = true;
		link.onclick = 'return false';
	}
	else
	{	
		//alert("return");
		document.getElementById("wdfdate2").disabled = false;
		document.getElementById("tickets_ret_time").disabled = false;
		link.onclick = '';
	}
}

<!--
function CheckMandatoryFFFields() {
var errorMsg ="";
var fieldList = "";
if ($('departs').value.empty()) {
fieldList += " -- From \n";
}
if ($('arrives').value.empty()) {
fieldList += " -- To \n";
}
if ($('wdfdate1').value.empty()) {
fieldList += " -- Departure Date \n";
}
if (document.getElementById('return').checked) {
if ($('wdfdate2').value.empty()) {
fieldList += " -- Return Date \n";
}
}

if (fieldList != "") {
errorMsg="The following information is needed to process your request:" + "\n" + fieldList+ "\n\n";
alert(errorMsg);
return false;
}
return true;
}

//-->


<!--
function getField(name,id){
 return document.getElementById(name+id);
}

function fieldExists(id){
 return (document.getElementById('wdfdate'+id)!=null);
}

function setDateDate(id,dt){
 setDate(id,dt.getFullYear(),dt.getMonth()+1,dt.getDate());
}

function setDate(id,year,month,day){
 var dateInput=getField('wdfdate',id);
 if (year==0 || month==0 || day==0){
   dateInput.value="";
 }else{
     var inputFieldName = dateInput.name;
      var dateInputFormat = inputFieldName.substring(inputFieldName.lastIndexOf(".") + 1, inputFieldName.length);
       if (dateInputFormat == "eudate") { // DMY
           dateInput.value=leadingZero(day)+'/'+leadingZero(month)+'/'+year;
       }
       if (dateInputFormat == "usdate") { // MDY
        dateInput.value=leadingZero(month)+'/'+leadingZero(day)+'/'+year;
       }
       if (dateInputFormat == "isodate") { // YMD
        dateInput.value=year+'/'+leadingZero(month)+'/'+leadingZero(day);
       }
     }
}

function leadingZero(value){
 if (value<10) value="0"+value;
 return value;
}

function getValidatedDateArray(id){
 var array=getDateArray(id);
 var year = parseInt(array[0],10);
 var month = parseInt(array[1],10);
 var day = parseInt(array[2],10);
 if (year!=-1 && year<100){
  year += 2000;
 }
 if (isNaN(year)||year<1900||year>9999){
  year=0;
 }
 if (isNaN(month)||month<1||month>12){
  month=0;
 }
 if (isNaN(day)||day<1||day>31){
  day=0;
 }


 var Tdt=new Date(year,month-1,day,0,0,0,1);

 var iCal = window['itd_cal'+id];
 if (iCal.toString().include('CalendarGroup')) {
   // Do we need to check isDateOOB for the CalendarGroup
 }
 else {
   // use the relevant calendar instance to check if the date is within the valid range for that calendar control
   if( iCal.isDateOOB(Tdt) ) {
	 // set year to zero, this will trigger the setErrorOn display
	 year = 0;
   }
  }
 return new Array(year,month,day);
}

function getDateArray(id){
 var date=getField('wdfdate',id).value;
 var amdate = date;
 date=date.replace(/[^0-9]/g,"/");   // only allow numbers and slashes
 date=date.replace(/[\/]+/g,"/");   // only single slashes
 var values = date.split("/");

 var inputFieldName = getField('wdfdate',id).name;
 var dateInputFormat = inputFieldName.substring(inputFieldName.lastIndexOf(".") + 1, inputFieldName.length);
   if (dateInputFormat == "eudate") { // DMY
    return new Array(values[2],values[1],values[0]);
   }
   if (dateInputFormat == "usdate") { // MDY
    return new Array(values[2],values[0],values[1]);
   }
   if (dateInputFormat == "isodate") { // YMD
    return new Array(values[0],values[1],values[2]);
   }
   if (dateInputFormat == "date") { // YMD
    if (date.blank()) {
      return new Array(values[0],values[1],values[2]);
    }
    else {
      values = amdate.split(", ");
      var dvalues = values[1].split(" ");
      var month = gsMonthNamesAbbr.indexOf(dvalues[0]) + 1;

      return new Array(values[2],month,dvalues[1]);
    }
   }
}

function isValidDate(array) {
 return (array[2]!=0 && array[1]!=0 && array[0]!=0);
}

var timer=false;
function dateChangedTimer(id){
 doDateChanged(id,-1);
 if (!timer){
  window.setTimeout('timer=false;dateChangedTimer('+id+');',1000);
  timer=true;
 }
}

function dateChangedComplete(id,daysGap){
 var returnradio = document.getElementById('wdfreturnradio');
 if (returnradio!=null && returnradio.checked){
  doDateChanged(id,daysGap);
 }
}

function doDateChanged(id,daysGap){
 if (id == 1) {
     var str=getField('wdfdate',id).value;
	 if (str.length>0){
		  var array=getValidatedDateArray(id);
			  if (!isValidDate(array)){
			    setErrorOn(id);
			  }else{
				   var dt=new Date(array[0],array[1]-1,array[2],0,0,0,1);
				   if (array[2]!=dt.getDate()){
				     setErrorOn(id);
				   }else{
				    setErrorOff(id);
				        // The second field is not updated at all if -1 is found.
				        // if zero or greater is found, then the second field would be updated to the value of the firstField plus daysGap
					    if (daysGap>=0){
					    	// setDate function does not do anything...
					     setDate(id,array[0],array[1],array[2]);
					     var returnradio = document.getElementById('return');
						 if (returnradio!=null && returnradio.checked){
						     if (getField('wdfdate',id+1)!=null){

						    	 // AIBE-2103 Get the return date and only update if depart date is > than return.
						    	 var rtnArray=getValidatedDateArray(id+1);
						    	 var rtnDt=new Date(rtnArray[0],rtnArray[1]-1,rtnArray[2],0,0,0,1);
						    	 if(dt > rtnDt) {
								     dt=new Date(dt.getFullYear(),dt.getMonth(),dt.getDate()+daysGap,0,0,0,1);
								     var retDate = $('wdfdate2');
									 retDate.value = formatDate(dt);
						    	 }
						     }
						  }
					  }
				  }
		      }
	     }
	 }
 updateDateState();
}

function setErrorOn(id){
 var cls=getField('wdfdate',id).className;
 if (cls.indexOf('invalid')==-1){
  getField('wdfdate',id).className=cls+' invalid';
 }
}

function setErrorOff(id){
 var cls=getField('wdfdate',id).className;
 if (cls.indexOf('invalid')>=0){
  getField('wdfdate',id).className=cls.substring(0,cls.indexOf('invalid'));
 }
}

function updateDateState(){
 if (self.updateRadioState) updateRadioState();
 if (self.updateDowState) updateDowState();
 if (self.updateTimeState) updateTimeState();
}

//-->


<!--
var defTime=null;
function updateTimeState() {

 if (defTime==null){
  // this block of code stores off the default values of any timefields present on the page,
  //  this is only done once for a page, and only if the user changes a date field (now amended to also call this if they change a time field)
  defTime=new Array("");
  // Caution!
  // remember that the id of the first time field on the page is >> "wdftime1"
  // Starting with an id of zero, >> var id=0;
  // preIncrement to 1, then check if field exists >> getField('wdftime',++id)!=null
  // or >> ||
  // again preIncrement, so value goes to 2, then check if field exists >> getField('wdftime',++id)!=null
  // loop continues as long as condition evaluates to true.
  // the double condition means time fields 1,2,4 can be saved off.. so if one number is missing from the sequence it will still work. I'm not sure why this is required.
  //  It may be used to break up field pairs, so one does not advance the next field. A missing digit could be used as a pair separator.
  for (var id=0; getField('wdftime',++id)!=null || getField('wdftime',++id)!=null; ) {
   defTime[id]=getField('wdftime',id).value;
  }
 }

 for (var id=0; getField('wdftime',++id)!=null || getField('wdftime',++id)!=null; ) {
  var select=getField('wdftime',id);

  // this returns the contents of the specified DATE field in Y,M,D format.. it is not concerned with the time field.
  // it validates crudely that the month is 1-12, and days are 1-31, if a value is invalid it is set to zero.
  var array=getValidatedDateArray(id);

  // this checks if a zero was returned for any of the Y,M,D values..
  // an empty date field is considered invalid
  if (!isValidDate(array)){
    // set to default value which we stored earlier
    setTimeField(select,defTime[id]);
  }

 }
}

function setTimeField(fld,val) {
 for (var i=0; i<fld.options.length; i++) {
  if (fld.options[i].value==val) {
   fld.selectedIndex=i;
   break;
  }
 }
}

function timeChanged() {

}
function setonewayDate(){

	var depDate = document.getElementById('wdfdate1'); 
	dateOnPageObj = new Date();
    	depDate .value = formatDate(dateOnPageObj);
}


function setStart(){
	setonewayDate();
	blankReturnDate(false);
	window.onload=setStart;
}

//-->

