function SelectRailCard(railCardType,railCardNumber){

                Event.observe(railCardType,'change', function(){		
		            if(railCardType.value == 'None'){
		                railCardNumber.value=0;
		               
		            }
		            else{
		             if(railCardNumber.value == 0){
		                    railCardNumber.value=1;
		                }
		            }
                   });
                   
                   
                   Event.observe(railCardNumber,'change', function(){		
		            if(railCardNumber.value == 0){
		                railCardType.value='None';		               
		            }		            		            
                   });
}

function updatePromotionCode(){
    $('PromotionalCode').value = $('PromotionalCodeDisplay').value;
    return true;
    }
 

document.observe("dom:loaded", function(){
	removeNonJsElements();
	showJsElements();	
	registerHandlerForNewJourneySearch();
}); 

function registerHandlerForNewJourneySearch(){
	$('cmd_advancedsearch') && $('cmd_advancedsearch').observe('click', function(){
		new CookieJar('filtermatrix').empty();
		new CookieJar('categorymatrix').empty();
	});
	$('TimeTableWithMatrixButton ') && $('TimeTableWithMatrixButton ').observe('click', function(){
		new CookieJar('categorymatrix').empty();
	});
	$('TimeTableWithMatrixButton') && $('TimeTableWithMatrixButton').observe('click', function(){
		new CookieJar('categorymatrix').empty();
	});
}

function removeNonJsElements(){
	$('nonjsOutwardDay') && $('nonjsOutwardDay').remove();
	$('nonjsOutwardMonth') && $('nonjsOutwardMonth').remove();
	$('nonjsInwardDay') && $('nonjsInwardDay').remove();
	$('nonjsInwardMonth') && $('nonjsInwardMonth').remove();
	$('moreOptionsSpan') && $('moreOptionsSpan').hide();
}

function showJsElements(){
	$('jsOutwardDate') && $('jsOutwardDate').show();
	$('jsInwardDate') && $('jsInwardDate').show();
	$('returnDate') && $('returnDate').enable();
	if($('SingleJourneyCheckBox') && $('SingleJourneyCheckBox').checked)
		$('returnDate') && $('returnDate').disable();
	//$('simpleSearch') && $('simpleSearch').removeClassName('invisible');
	$('todayTommorow') && $('todayTommorow').show();
	$('sameDayNextDay') && $('sameDayNextDay').show();
	if ($('AdvanceSearchLinkButton'))
		$('AdvanceSearchLinkButton').style.display='inline';  	
}
