$(document).ready(function(){
	
    function findValueCallback(event, data, formatted) { $("<li>").html( !data ? "No match!" : "Selected: " + formatted).appendTo("#result"); }
    function formatItem(row) { return row[0] + "<strong>id: " + row[1] + "<"+"/"+"strong>"; }
    function formatResult(row) { return row[0].replace(/(<.+?>)/gi, ''); }
	
	if (typeof stations != 'undefined' && stations instanceof Array) {
		$(".stationcomplete").autocomplete(stations ,{
			delay:100,
			max:100
		});
	}
	
	if (typeof locations != 'undefined' && locations instanceof Array) {
		$(".buy_stationcomplete").autocomplete(locations ,{
			delay:100,
			max:100
		});
	}
	
    $("#plannerform").bind("keypress", function(event) { if(event.keyCode == 13) { return false; } });

	$(function()
	{
		var dayOfWeek = {
			0 : 'Sunday',
			1 : 'Monday',
			2 : 'Tuesday', 
			3 : 'Wednesday',
			4 : 'Thursday',
			5 : 'Friday',
			6 : 'Saturday'
		};
		
		var month = {
			0 : 'Jan',
			1 : 'Feb',
			2 : 'Mar',
			3 : 'Apr',
			4 : 'May',
			5 : 'Jun',
			6 : 'Jul',
			7 : 'Aug',
			8 : 'Sep',
			9 : 'Oct',
			10 : 'Nov',
			11 : 'Dec'
		};
					
		$('.jpds_out')
			.datePicker({createButton:false})
			.bind(
				'click',
				function()
				{
					$(this).dpDisplay();
					this.blur();
					return false;
				}
			)
			.bind(
				'dateSelected',
				function(e, selectedDate, $td)
				{
					//alert('You selected ' + selectedDate);
					var dpad = selectedDate.getDate();
					var mpad = selectedDate.getMonth()+1;
					dpad = dpad.toString();
					mpad = mpad.toString();
					if (dpad.length == 1) { dpad = '0'+dpad; }
					if (mpad.length == 1) { mpad = '0'+mpad; }
					$('#out_date').val(dpad);
					$('#out_month').val(mpad);
				}
			);
		$('.jpds_ret')
			.datePicker({createButton:false})
			.bind(
				'click',
				function()
				{
					$(this).dpDisplay();
					this.blur();
					return false;
				}
			)
			.bind(
				'dateSelected',
				function(e, selectedDate, $td)
				{
					//alert('You selected ' + selectedDate);
					var dpad = selectedDate.getDate();
					var mpad = selectedDate.getMonth()+1;
					dpad = dpad.toString();
					mpad = mpad.toString();
					if (dpad.length == 1) { dpad = '0'+dpad; }
					if (mpad.length == 1) { mpad = '0'+mpad; }
					$('#ret_date').val(dpad);
					$('#ret_month').val(mpad);
				}
			);
		
		$('.journey_out')
			.datePicker({createButton:false,
						displayClose: true,
						endDate: (new Date((new Date()).getTime() + (84 * 24 * 60 * 60 * 1000))).asString(),
						horizontalOffset: -178,
						showYearNavigation: false,
						startDate: (new Date()).toString(),
						verticalOffset: 20})
			.bind(
				'click',
				function()
				{
					$(this).dpDisplay();
					this.blur();
					return false;
				}
			)
			.bind(
				'dateSelected',
				function(e, selectedDate, $td)
				{			
					var outDate = selectedDate.getFullYear() + '-' 
					+ (((selectedDate.getMonth() < 9) ? '0' : '') + (selectedDate.getMonth() + 1)) + '-' 
					+ (((selectedDate.getDate() < 10) ? '0' : '') + selectedDate.getDate());
					var format = dayOfWeek[selectedDate.getDay()] + ' ' + selectedDate.getDate() + ' ' + month[selectedDate.getMonth()] + ' ' + selectedDate.getFullYear();
					$('#sidebar_planner .plan_form #outDate').val(outDate);
					$('#sidebar_planner .plan_form #format_outDate').val(format);
				}
			);
			
		$('#format_outDate')
			.datePicker({createButton:false,
						displayClose: true,
						endDate: (new Date((new Date()).getTime() + (84 * 24 * 60 * 60 * 1000))).asString(),
						showYearNavigation: false,
						startDate: (new Date()).toString(),
						verticalOffset: 24})
			.bind(
				'click',
				function()
				{
					$(this).dpDisplay();
					this.blur();
					return false;
				}
			)
			.bind(
				'dateSelected',
				function(e, selectedDate, $td)
				{			
					var outDate = selectedDate.getFullYear() + '-' 
					+ (((selectedDate.getMonth() < 9) ? '0' : '') + (selectedDate.getMonth() + 1)) + '-' 
					+ (((selectedDate.getDate() < 10) ? '0' : '') + selectedDate.getDate());
					var format = dayOfWeek[selectedDate.getDay()] + ' ' + selectedDate.getDate() + ' ' + month[selectedDate.getMonth()] + ' ' + selectedDate.getFullYear();
					$('#sidebar_planner .plan_form #outDate').val(outDate);
					$('#sidebar_planner .plan_form #format_outDate').val(format);
				}
			);
			
		$('.journey_return')
			.datePicker({createButton:false,
						displayClose: true,
						endDate: (new Date((new Date()).getTime() + (84 * 24 * 60 * 60 * 1000))).asString(),
						horizontalOffset: -178,
						showYearNavigation: false,
						startDate: (new Date()).toString(),
						verticalOffset: 20})
			.bind(
				'click',
				function()
				{
					$(this).dpDisplay();
					this.blur();
					return false;
				}
			)
			.bind(
				'dateSelected',
				function(e, selectedDate, $td)
				{			
					var outDate = selectedDate.getFullYear() + '-' 
					+ (((selectedDate.getMonth() < 9) ? '0' : '') + (selectedDate.getMonth() + 1)) + '-' 
					+ (((selectedDate.getDate() < 10) ? '0' : '') + selectedDate.getDate());
					var format = dayOfWeek[selectedDate.getDay()] + ' ' + selectedDate.getDate() + ' ' + month[selectedDate.getMonth()] + ' ' + selectedDate.getFullYear();
					$('#sidebar_planner .plan_form #returnDate').val(outDate);
					$('#sidebar_planner .plan_form #format_returnDate').val(format);
				}
			);
			
		$('#format_returnDate')
			.datePicker({createButton:false,
						displayClose: true,
						endDate: (new Date((new Date()).getTime() + (84 * 24 * 60 * 60 * 1000))).asString(),
						showYearNavigation: false,
						startDate: (new Date()).toString(),
						verticalOffset: 24})
			.bind(
				'click',
				function()
				{
					$(this).dpDisplay();
					this.blur();
					return false;
				}
			)
			.bind(
				'dateSelected',
				function(e, selectedDate, $td)
				{			
					var outDate = selectedDate.getFullYear() + '-' 
					+ (((selectedDate.getMonth() < 9) ? '0' : '') + (selectedDate.getMonth() + 1)) + '-' 
					+ (((selectedDate.getDate() < 10) ? '0' : '') + selectedDate.getDate());
					var format = dayOfWeek[selectedDate.getDay()] + ' ' + selectedDate.getDate() + ' ' + month[selectedDate.getMonth()] + ' ' + selectedDate.getFullYear();
					$('#sidebar_planner .plan_form #returnDate').val(outDate);
					$('#sidebar_planner .plan_form #format_returnDate').val(format);
				}
			);
			
		$('.outward_date, #day_outward, #month_outward')
			.datePicker({createButton: false,
						displayClose: true,
						showYearNavigation: false,
						startDate: (new Date()).toString(),
						verticalOFfeset: 24})
			.bind(
				  'click',
				  function()
				  {
						$(this).dpDisplay();
						this.blur();
						return false;
				  })
			.bind(
				  'dateSelected',
				  function(e, selectedDate, $td)
				  {
					$('#full_date_outward').val((selectedDate.getFullYear() + '-' 
					+ (((selectedDate.getMonth() < 9) ? '0' : '') + (selectedDate.getMonth() + 1)) + '-' 
					+ (((selectedDate.getDate() < 10) ? '0' : '') + selectedDate.getDate())));
					$('#day_outward').val(((selectedDate.getDate() < 10) ? '0' : '') + selectedDate.getDate());
					$('#month_outward').val(((selectedDate.getMonth() < 9) ? '0' : '') + (selectedDate.getMonth() + 1));
				  }
			);
			
		$('.return_date, #day_return, #month_return')
			.datePicker({createButton: false,
						displayClose: true,
						showYearNavigation: false,
						startDate: (new Date()).toString(),
						verticalOFfeset: 24})
			.bind(
				  'click',
				  function()
				  {
						$(this).dpDisplay();
						this.blur();
						return false;
				  })
			.bind(
				  'dateSelected',
				  function(e, selectedDate, $td)
				  {
					$('#full_date_return').val((selectedDate.getFullYear() + '-' 
					+ (((selectedDate.getMonth() < 9) ? '0' : '') + (selectedDate.getMonth() + 1)) + '-' 
					+ (((selectedDate.getDate() < 10) ? '0' : '') + selectedDate.getDate())));
					$('#day_return').val(((selectedDate.getDate() < 10) ? '0' : '') + selectedDate.getDate());
					$('#month_return').val(((selectedDate.getMonth() < 9) ? '0' : '') + (selectedDate.getMonth() + 1));
				  }
			);
	});
	$("#out_date").bind("click", function(event) { if (this.value == 'DD') { this.value=''; } } );
	$("#out_month").bind("click", function(event) { if (this.value == 'MM') { this.value=''; } } );
	
	$("#ret_date").bind("click", function(event) { if (this.value == 'DD') { this.value=''; } } );
	$("#ret_month").bind("click", function(event) { if (this.value == 'MM') { this.value=''; } } );

	//var pageheadings = document.getElementsByTagName('h2');
	//for (i=0;i<pageheadings.length;i++) {
		//pageheadings[i].innerHTML = '<a href="#"><span>TEST</span></a>'; //'+pageheadings[i].innerHTML+'</span>';
	//}
	
	
	/**
	 * @Enable lightbox
	 *
	 */
	$('a[rel*=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel	
	
	//Prepend a span to the tabbed anchor elements for rounded edges
	if($('.tabset_tabs li').length) {$('.tabset_tabs li a').prepend("<span>&nbsp;</span>");}
	
	var headline_count;
	var headline_interval;
	var old_headline = 0;
	var current_headline = 0;
	
	$(document).ready(function(){
		headline_count = $(".headline").size();
		$(".headline:eq("+current_headline+")").css('top','5px');
		
		headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
		$('#scrollup').hover(function() {
			clearInterval(headline_interval);
		}, function() {
			headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
			headline_rotate();
		});
	});
	
	function headline_rotate() {
		current_headline = (old_headline + 1) % headline_count; 
	
		$(".headline:eq(" + old_headline + ")").animate({top: -205},"slow", function() {
			$(this).css('top','210px');
		});
		$(".headline:eq(" + current_headline + ")").show().animate({top: 5},"slow");  
		old_headline = current_headline;
	}
	
});


/*
 * Dropdown Compatibility fix for IE6
 */ 
window.onload = function() {	
		
	var nav = document.getElementById('nav');
	var lis = nav.getElementsByTagName('li');
	for(i = 0; i < lis.length; i++)	{
		var li = lis[i];
		
		if (li.className != '' || li.className != null)	{
			
			li.onmouseover = function() { 
				if(this.getElementsByTagName('div').item(0) != null ){
					this.getElementsByTagName('div').item(0).style.display = 'block';
					this.getElementsByTagName('a')[0].className = 'active';
				}
			}
			li.onmouseout = function() {
				if(this.getElementsByTagName('div').item(0) != null ){ 
					this.getElementsByTagName('div').item(0).style.display = 'none';
					this.getElementsByTagName('a')[0].className = '' ;
				}
			}
		}
	}
	
	/* External links */
	if (document.getElementsByTagName) {
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
	var anchor = anchors[i];
	if (anchor.getAttribute("href") &&
	   anchor.getAttribute("rel") == "external")
	 anchor.target = "_blank";
	}
	}
	
	/* FAQ toggles */
	$('div.CollapsiblePanelContent').hide();
	$("div.CollapsiblePanelTab").click(function () {
      $(this).parent().children('div.CollapsiblePanelContent').toggle("fast");
    });
	
	/*
	 * IE6 ONLY
	 */	
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	
	if (browser=="Microsoft Internet Explorer" && version<=6) {		
	
		$(".navnews a, .navcommunity a, .navtraveltools a ").mouseover(function(){ 
			$('#quickcontrols #out_hour, #quickcontrols #out_min, #quickcontrols #ret_hour, #quickcontrols #ret_min').hide();
			
		}).mouseout(function(){ 
			$('#quickcontrols #out_hour, #quickcontrols #out_min, #quickcontrols #ret_hour, #quickcontrols #ret_min').show();
			
		}); 
		
		/*
		$("#northern-page .navnews a, #northern-page .navcommunity a").mouseover(function(){ 
			$('#mynorthernlogin h2').hide();			
		}).mouseout(function(){ 
			$('#mynorthernlogin h2').show();			
		});
		
		*/
	}
	
}


// IE5.5+ PNG Alpha Fix v2.0 Alpha: Background Tiling Support
// (c) 2008 Angus Turnbull http://www.twinhelix.com

// This is licensed under the GNU LGPL, version 2.1 or later.
// For details, see: http://creativecommons.org/licenses/LGPL/2.1/

var IEPNGFix = window.IEPNGFix || {};

IEPNGFix.tileBG = function(elm, pngSrc, ready) {
	// Params: A reference to a DOM element, the PNG src file pathname, and a
	// hidden "ready-to-run" passed when called back after image preloading.

	var data = this.data[elm.uniqueID],
		elmW = Math.max(elm.clientWidth, elm.scrollWidth),
		elmH = Math.max(elm.clientHeight, elm.scrollHeight),
		bgX = elm.currentStyle.backgroundPositionX,
		bgY = elm.currentStyle.backgroundPositionY,
		bgR = elm.currentStyle.backgroundRepeat;

	// Cache of DIVs created per element, and image preloader/data.
	if (!data.tiles) {
		data.tiles = {
			elm: elm,
			src: '',
			cache: [],
			img: new Image(),
			old: {}
		};
	}
	var tiles = data.tiles,
		pngW = tiles.img.width,
		pngH = tiles.img.height;

	if (pngSrc) {
		if (!ready && pngSrc != tiles.src) {
			// New image? Preload it with a callback to detect dimensions.
			tiles.img.onload = function() {
				this.onload = null;
				IEPNGFix.tileBG(elm, pngSrc, 1);
			};
			return tiles.img.src = pngSrc;
		}
	} else {
		// No image?
		if (tiles.src) ready = 1;
		pngW = pngH = 0;
	}
	tiles.src = pngSrc;

	if (!ready && elmW == tiles.old.w && elmH == tiles.old.h &&
		bgX == tiles.old.x && bgY == tiles.old.y && bgR == tiles.old.r) {
		return;
	}

	// Convert English and percentage positions to pixels.
	var pos = {
			top: '0%',
			left: '0%',
			center: '50%',
			bottom: '100%',
			right: '100%'
		},
		x,
		y,
		pc;
	x = pos[bgX] || bgX;
	y = pos[bgY] || bgY;
	if (pc = x.match(/(\d+)%/)) {
		x = Math.round((elmW - pngW) * (parseInt(pc[1]) / 100));
	}
	if (pc = y.match(/(\d+)%/)) {
		y = Math.round((elmH - pngH) * (parseInt(pc[1]) / 100));
	}
	x = parseInt(x);
	y = parseInt(y);

	// Handle backgroundRepeat.
	var repeatX = { 'repeat': 1, 'repeat-x': 1 }[bgR],
		repeatY = { 'repeat': 1, 'repeat-y': 1 }[bgR];
	if (repeatX) {
		x %= pngW;
		if (x > 0) x -= pngW;
	}
	if (repeatY) {
		y %= pngH;
		if (y > 0) y -= pngH;
	}

	// Go!
	this.hook.enabled = 0;
	if (!({ relative: 1, absolute: 1 }[elm.currentStyle.position])) {
		elm.style.position = 'relative';
	}
	var count = 0,
		xPos,
		maxX = repeatX ? elmW : x + 0.1,
		yPos,
		maxY = repeatY ? elmH : y + 0.1,
		d,
		s,
		isNew;
	if (pngW && pngH) {
		for (xPos = x; xPos < maxX; xPos += pngW) {
			for (yPos = y; yPos < maxY; yPos += pngH) {
				isNew = 0;
				if (!tiles.cache[count]) {
					tiles.cache[count] = document.createElement('div');
					isNew = 1;
				}
				var clipR = (xPos + pngW > elmW ? elmW - xPos : pngW),
					clipB = (yPos + pngH > elmH ? elmH - yPos : pngH);
				d = tiles.cache[count];
				s = d.style;
				s.behavior = 'none';
				s.left = xPos + 'px';
				s.top = yPos + 'px';
				s.width = clipR + 'px';
				s.height = clipB + 'px';
				s.clip = 'rect(' +
					(yPos < 0 ? 0 - yPos : 0) + 'px,' +
					clipR + 'px,' +
					clipB + 'px,' +
					(xPos < 0 ? 0 - xPos : 0) + 'px)';
				s.display = 'block';
				if (isNew) {
					s.position = 'absolute';
					s.zIndex = -999;
					if (elm.firstChild) {
						elm.insertBefore(d, elm.firstChild);
					} else {
						elm.appendChild(d);
					}
				}
				this.fix(d, pngSrc, 0);
				count++;
			}
		}
	}
	while (count < tiles.cache.length) {
		this.fix(tiles.cache[count], '', 0);
		tiles.cache[count++].style.display = 'none';
	}

	this.hook.enabled = 1;

	// Cache so updates are infrequent.
	tiles.old = {
		w: elmW,
		h: elmH,
		x: bgX,
		y: bgY,
		r: bgR
	};
};


IEPNGFix.update = function() {
	// Update all PNG backgrounds.
	for (var i in IEPNGFix.data) {
		var t = IEPNGFix.data[i].tiles;
		if (t && t.elm && t.src) {
			IEPNGFix.tileBG(t.elm, t.src);
		}
	}
};
IEPNGFix.update.timer = 0;

if (window.attachEvent && !window.opera) {
	window.attachEvent('onresize', function() {
		clearTimeout(IEPNGFix.update.timer);
		IEPNGFix.update.timer = setTimeout(IEPNGFix.update, 100);
	});
}

$(document).ready(function() {
	
	$('#searchterm').focus(function() {
		if ($('#searchterm').not('.search').val() == 'Search the site') {
			$('#searchterm').val('');
		}
	});
	
	$('#searchterm').blur(function() {
		if ($('#searchterm').not('.search').val() == 'Search the site') {
			$('#searchterm').val('Search the site');
		}
	});
	
	if ($('#searchterm').not('.search').val().length == 0) {
		$('#searchterm').val('Search the site');	
	}
});

/* WebTIS Planner */

$(document).ready(function() {
						   
		var dayOfWeek = {
			0 : 'Sunday',
			1 : 'Monday',
			2 : 'Tuesday', 
			3 : 'Wednesday',
			4 : 'Thursday',
			5 : 'Friday',
			6 : 'Saturday'
		};
		
		var month = {
			0 : 'Jan',
			1 : 'Feb',
			2 : 'Mar',
			3 : 'Apr',
			4 : 'May',
			5 : 'Jun',
			6 : 'Jul',
			7 : 'Aug',
			8 : 'Sep',
			9 : 'Oct',
			10 : 'Nov',
			11 : 'Dec'
		};
		
	$('#single, #return').click(function(a) {

		if ($('#single').attr('checked') != undefined && $('#single').attr('checked') == 'checked') {
			$('#openReturn, #returnDate, #returnArriveDepart, #returnHour, #returnMin').attr('disabled', 'disabled');
			$('.optionReturn').hide('fast');	
		} else {
			$('#openReturn, #returnDate, #returnArriveDepart, #returnHour, #returnMin').removeAttr('disabled');
			$('.optionReturn').show('fast');	
		}
	});
	
	$('.additional').click(function(a) {
		if ($('.route.hidden').css('display') != 'block' && $('.route.hidden').css('display') != 'inline') {
			$('#route').removeAttr('disabled');
			$('#routeStation').removeAttr('disabled');
			$('.route').show('fast');
			$('.route').css('display', 'inline');
			a.preventDefault();
		} else {
			$('#route').attr('disabled', 'disabled');
			$('#routeStation').attr('disabled', 'disabled');
			$('.route').hide('fast');
			a.preventDefault();
		}
	});
	
	$('.date_today').click(function(a) {
		var date = new Date();
		$('#outDate').val(date.getFullYear() + '-' + (((date.getMonth() < 9) ? '0' : '') + (date.getMonth() + 1)) + '-' + (((date.getDate() < 10) ? '0' : '') + date.getDate()));
		$('#format_outDate').val(dayOfWeek[date.getDay()] + ' ' + date.getDate() + ' ' + month[date.getMonth()] + ' ' + date.getFullYear());
		a.preventDefault();
	});
	
	$('.date_tomorrow').click(function(a) {
		var curr = new Date();
		var date = new Date();
		date.setDate(curr.getDate() + 1);
		$('#outDate').val(date.getFullYear() + '-' + (((date.getMonth() < 9) ? '0' : '') + (date.getMonth() + 1)) + '-' + (((date.getDate() < 10) ? '0' : '') + date.getDate()));
		$('#format_outDate').val(dayOfWeek[date.getDay()] + ' ' + date.getDate() + ' ' + month[date.getMonth()] + ' ' + date.getFullYear());
		a.preventDefault();
	});
	
	$('.date_sameday').click(function(a) {
		if ($('#outDate').val().length > 0) {
			var outdate = $('#outDate').val();
			var part = outdate.split('-');
			var chosenDate = new Date(part[0], part[1] - 1, part[2]);
			$('#returnDate').val(chosenDate.getFullYear() + '-' + (((chosenDate.getMonth() < 9) ? '0' : '') + (chosenDate.getMonth() + 1)) + '-' + (((chosenDate.getDate() < 10) ? '0' : '') + chosenDate.getDate()));
			$('#format_returnDate').val(dayOfWeek[chosenDate.getDay()] + ' ' + chosenDate.getDate() + ' ' + month[chosenDate.getMonth()] + ' ' + chosenDate.getFullYear());
			a.preventDefault();
		} else {
			$('#returnDate, #format_returnDate').val('');
			a.preventDefault();
		}
	});
	
	$('.date_next').click(function(a) {
		if ($('#outDate').val().length > 0) {
			var outdate = $('#outDate').val();
			var part = outdate.split('-');
			var chosenDate = new Date(part[0], part[1] - 1, part[2]);
			chosenDate.setDate(chosenDate.getDate() + 1);
			if (chosenDate.getTime() < (new Date((new Date()).getTime() + (84 * 24 * 60 * 60 * 1000)).getTime())) {
				$('#returnDate').val(chosenDate.getFullYear() + '-' + (((chosenDate.getMonth() < 9) ? '0' : '') + (chosenDate.getMonth() + 1)) + '-' + (((chosenDate.getDate() < 10) ? '0' : '') + chosenDate.getDate()));
				$('#format_returnDate').val(dayOfWeek[chosenDate.getDay()] + ' ' + chosenDate.getDate() + ' ' + month[chosenDate.getMonth()] + ' ' + chosenDate.getFullYear());
			}
			a.preventDefault();
		} else {
			$('#returnDate, #format_returnDate').val('');
			a.preventDefault();
		}
	});
	
	$('#format_outDate').blur(function() {
		if ($('#format_outDate').val().length == 0) {
			$('#outDate').val('');	
		}
	});
	
	$('#format_returnDate').blur(function() {
		if ($('#format_returnDate').val().length == 0) {
			$('#returnDate').val('');	
		}
	});
	
	$('#operatorSwitchShow').change(function() {
		if ($('.operatorSwitch.hidden').css('display') != 'block') {
			$('#operatorSwitch, #operator').removeAttr('disabled');
			$('.operatorSwitch.hidden').show('fast');
			if ($('#operator').val() != '') {
				$('#operator').removeAttr('disabled');
				$('.operators.hidden').show('fast');	
			}
		} else {
			$('#operatorSwitch, #operator').attr('disabled', 'disabled');
			$('.operatorSwitch.hidden, .operators.hidden').hide('fast');
		}
	});
	
	$('#operatorSwitch').change(function() {
		if ($(this).val() == 'showOnly' || $(this).val() == 'showExcept') {
			$('#operator').removeAttr('disabled');
			$('.operators.hidden').show('fast');
		} else {
			$('#operator').attr('disabled', 'disabled');
			$('.operators.hidden').hide('fast');
		}
	});
	
	$('#railcard_display').click(function() {
		if ($('.railcard.hidden').css('display') != 'block' && $('.railcard.hidden').css('display') != 'inline') {
			$('#railcard').removeAttr('disabled');
			$('.railcard.hidden').show('fast');
			$('.railcard.hidden').css('display', 'inline');
		} else {
			$('#railcard').attr('disabled', 'disabled');
			$('.railcard.hidden').hide('fast');	
		}
	});
	
	$('#promoCode_display').click(function() {
		if ($('.promoCode.hidden').css('display') != 'block' && $('.promocode.hidden').css('display') != 'inline') {
			$('#promoCode').removeAttr('disabled');
			$('.promoCode.hidden').show('fast');
			$('.promoCode.hidden').css('display', 'inline');
		} else {
			$('#promoCode').attr('disabled', 'disabled');
			$('.promoCode.hidden').hide('fast');
		}
	});
	
	$('#openReturn').click(function() {
		if ($('.return').css('display') != 'block') {
			$('#returnDate').removeAttr('disabled');
			$('.return').show('fast');
		} else {
			$('#returnDate').attr('disabled', 'disabled');
			$('.return').hide('fast');	
		}
	});
	
	$('#submit').click(function(a) {
		if ($('#origin').val() == '' || $('#destination').val() == '') {
			a.preventDefault();	
		}
	});
});
