﻿$().ready(function()
{
$("#stationTextBox").autocomplete(data,{
mustMatch:true,
formatItem:function(row,i,max){return row.d;},
formatMatch:function(row,i,max){return row.d;},
formatResult:function(row){return row.d;},
formatInput:function(str){function replaceAll(str,search,repl){while(str.indexOf(search)!=-1) str=str.replace(search,repl);return str;}
var norm=new Array('_','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','ø','ù','ú','û','ü','ý','ý','þ','ÿ');
var spec=new Array('-','A','A','A','A','A','A','A','C','E','E','E','E','I','I','I','I','D','N','O','O','O','0','O','O','U','U','U','U','Y','b','s','a','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i','d','n','o','o','o','o','o','o','u','u','u','u','y','y','b','y');
for(var i=0;i<spec.length;i++) str=replaceAll(str,norm[i],spec[i]);return str;}});
function findValue1Callback(event,data,formatted){$("#stationIdHiddenField").val(!data ? "":data.i);}
$("#stationTextBox").result(findValue1Callback).focus().click(function(){this.value='';$("#trainNumberTextBox").val('');});
$("#trainNumberTextBox").click(function(){this.value='';$("#stationTextBox").val('');$("#stationIdHiddenField").val('');});
$('#trainNumberTextBox').bind('keypress',function(e){return(e.which!=8 && e.which!=13 && e.which!=0 && (e.which<48 || e.which>57)) ? false:true;});
$(".ButtonHand").click(function(){$('body').css('cursor','wait');});
disableSelection(document.body);
});
function ShowLegend(language){window.open('Legend'+language+'.htm','Legend','width=700,height=400,resizable=yes,location=no,scrollbars=yes');return false;}
function disableSelection(target){
if(typeof target.onselectstart!="undefined") target.onselectstart=function(){return false}
else if(typeof target.style.MozUserSelect!="undefined") target.style.MozUserSelect="none"
else target.onmousedown=function(){return false}
target.style.cursor="default"}
function S(p){__doPostBack('S',p);}