$(
	function() {
		$(".Railways input[type=checkbox]").attr("disabled", "disabled");
		$(".Areas:checked").each(function(){
			$(".Railway" + $(this).attr("id").slice(-1)).removeAttr("disabled");
		});
		$(".Areas").click(function() {
			if($(this).attr('checked') == true) {
				$(".Railway" + $(this).attr("id").slice(-1)).removeAttr("disabled");
			} else {
				$(".Railway" + $(this).attr("id").slice(-1)).attr("disabled", "disabled");
			}
		});
		$("#Clear").click(function() {
			$(".Railways input[type=checkbox]").attr("disabled", "disabled");
			$('input[type=checkbox]').removeAttr('checked');
			$('input[type=text]').val('');
			$('.error-message').remove();
		});
	}
);

function initInputRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('input');

	for (var i = 0; i < aImages.length; i++) {
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
			
			aImages[i].onclick = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}			
		}
	}
}


$(document).ready(initInputRollovers);
