/* Version: 2008-07-02 */
var $j = jQuery;

/* Journey Planner
----------------------------------------------- */

function JourneyPlannerInit() {

	/* Data Format Options */
	Date.format = 'dd/mm/yyyy';

	/* Resets date input fields if left empty. */
	function JourneyPlannerValueReset(jQObj) {
		if ( jQObj.val() == 'DD/MM/YYYY' ) {
			jQObj.val('');
		} else if ( jQObj.val() === '' ) {
			jQObj.val('DD/MM/YYYY');
		}
	}
	/* Adds 'first' class to the first th and td of each tr for styling. */
	function JourneyPlannerCalendarInit() {
		$j('th:first, td:first', '.jCalendar tr').css({borderLeft: 'none', paddingRight: '6px'});
	}
	/* Applies datePicker to each .frow-date */
	function JourneyPlannerCalendarApply(jQObj) {
		jQObj.val('DD/MM/YYYY');
		jQObj.datePicker( {
			clickInput: true, createButton: false, displayClose: true, horizontalPosition: '0', horizontalOffset: '-167', showYearNavigation: false,
			renderCallback:function($td) {
				if ($td.hasClass('other-month')) { $td.addClass('disabled'); }
			}
		}).bind('dpDisplayed', function() {
			JourneyPlannerCalendarInit();
		}).bind('dpMonthChanged', function() {
			JourneyPlannerCalendarInit();
		}).bind('blur', function() {
			JourneyPlannerValueReset(jQObj);
		}).bind('dpClosed', function() {
			/* Reformat the date to DD/MM 
			jQObj.val(jQObj.val().substring(0,5));*/
		});
	}
	
	$j('.jdate input').each(function() {
		jQObj = $j(this);
		JourneyPlannerCalendarApply(jQObj);
	});
	
	

}

/* Run when DOM ready
----------------------------------------------- */
$j(document).ready(function() {
	JourneyPlannerInit();
	/*$('.cusdate input').datePicker({}); */
	
	$('.railcardwrap').hide();
	

$("#showrailcards").click(function () {
		$('#displayrailcards').hide();
		$('.railcardwrap').show('slow');
	});

	
	
});