 var ts_version = "1.30"; var ts_browser_agt = navigator.userAgent.toLowerCase(); var ts_browser_is_ie = ((ts_browser_agt.indexOf("msie") != -1) && (ts_browser_agt.indexOf("opera") == -1)); var sortInit = false; function delCookie(name)
{ document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/";}
function saveIt(name,x)
{ Cookies.create(name,x,100);}
function readIt(name)
{ return Cookies[name];}
var fdTableSort = { sort_col_title : "Click here to Sort!", sort_col_asc_title : "Sorted in ascending order", sort_col_desc_title : "Sorted in descending order", sort_col_class : "abc", sort_col_style : "this.style.background-color: '#FFCCFF'", sort_col_class_post_sort : "def", sort_col_style_post_sort : "text-decoration:none; font-weight:bold", sort_col_mouseover : "this.style.color='#FFCCFF'", use_ctrl_alt_click : true, sort_only_sortable : true, minimum_sort_row : 4, no_sort_above_click : false, default_sort_asc : true, forcesort_msg : 'This column can only be sorted in one way!', nosort_title : 'No sorting on this column!', cookie_days : 0, default_date_style : 'euro', table_head_row : 0, table_nohead_row : 1, skiprows : 1, table_content_might_change : false, preserve_style : "", tell_me_time_consumption : false, smallest_int : -2147483648000, cookie_table_idx : 0, get_doc_name : function()
{ var regex = /.+\/(.+)\??/; var results = regex.exec(window.location.href); if(results) return results[1].replace(/[^A-Za-z0-9]+/g, '');}, set_vars : function(event)
{ var e = (event)? event : window.event; var element = (event)? ((event.target)? event.target : event.srcElement) : window.event.srcElement; fdTableSort.clicked_td = fdTableSort.getParent(element,'TD') || fdTableSort.getParent(element,'TH'); fdTableSort.clicked_table = fdTableSort.getParent(element,'TABLE'); if(!fdTableSort.clicked_table || fdTableSort.clicked_table.rows.length < 1 || !fdTableSort.clicked_td) return; var clicked_cell = fdTableSort.clicked_table.rows[0].cells[fdTableSort.clicked_td.cellIndex]; if (e.ctrlKey && e.altKey && fdTableSort.use_ctrl_alt_click) fdTableSort.resortTable(clicked_cell);}, set_skiprows : function(td)
{ fdTableSort.clicked_tr = fdTableSort.getParent(td,'TR'); fdTableSort.clicked_table = fdTableSort.getParent(td,'TABLE'); if(fdTableSort.clicked_tr)
{ if(fdTableSort.no_sort_above_click)
{ fdTableSort.skiprows = 0; if(fdTableSort.clicked_table && fdTableSort.clicked_table.rows.length >= fdTableSort.minimum_sort_row)
{ for (var j=0; j < fdTableSort.clicked_table.rows.length; j++)
{ if(fdTableSort.clicked_table.rows[j] == fdTableSort.clicked_tr) break; if(fdTableSort.clicked_table.rows[j].parentNode.tagName.toLowerCase() == 'tbody')
fdTableSort.skiprows++;}
}
}
else
fdTableSort.skiprows = (fdTableSort.table_has_header(fdTableSort.clicked_table))? fdTableSort.table_head_row : fdTableSort.table_nohead_row;}
}, makeSortable: function(table)
{ if (table.rows && table.rows.length > 0)
{ var rowidx = table.getAttribute("ts_linkrow") || 0; var firstRow = table.rows[rowidx];}
if (!firstRow) return; var sortCell; if(this.cookie_days > -1)
{ if(!table.id)
{ this.cookie_table_idx = this.cookie_table_idx + 1; table.cookieid = this.get_doc_name() + this.cookie_table_idx;}
else table.cookieid = this.get_doc_name() + table.id; var tmp = this.get_cookie(table.cookieid); if(tmp)
{ var oldVals = tmp.split(':'); sortCell = firstRow.cells[oldVals[0]]; sortCell.setAttribute('sortdir', oldVals[1]);}
}
/* Following code added by Viji*/
var sortcellInnerText = "";
var url = window.location.href; 
var url1=url.substr(url.lastIndexOf("/")); 
var URLSplit=url1.split("&")[0]; 
URLSplit=URLSplit.substr(1,URLSplit.length);
if(URLSplit.toLowerCase().indexOf("t=departure") > -1 ||URLSplit.toLowerCase().indexOf("naptan.aspx?chkbus=on") > -1 ||URLSplit.toLowerCase().indexOf("naptan.aspx?chktram=on") > -1   || URLSplit.toLowerCase().indexOf("searchbystopnumber") > -1|| URLSplit.toLowerCase().indexOf("txtstopnumber") > -1)
{ sortcellInnerText = "currentorder"; }
else
{
URLSplit = URLSplit.split("?")[0];
URLSplit = URLSplit.toLowerCase();
}
if(sortcellInnerText.length == 0)
{
switch(URLSplit)
{
case "network.aspx": sortcellInnerText = "severity"; break;
case "carpark.aspx": case "naptan.aspx": sortcellInnerText = "name"; break;
case "vms.aspx": if(firstRow.cells.length == 4) { sortcellInnerText = "name"; } else { sortcellInnerText = "location"; } break;
}
}
for (var i=0;i<firstRow.cells.length;i++)
{  var cell = firstRow.cells[i]; if(cell.getAttribute("ts_nosort"))
{ if(this.nosort_title) cell.innerHTML = '<span title="'+ this.nosort_title +'">' + cell.innerHTML + '</span>';}
else
{ var txt = cell.innerHTML; 
cell.innerText = txt;
if(cell.innerText.toLowerCase() == sortcellInnerText)
{ sortCell = cell; }
/*if(cell.getAttribute("sortdir"))
{ if(sortCell) cell.removeAttribute('sortdir'); else sortCell = cell;}*/
cell.innerHTML = '<a style="'+this.sort_col_style+'" onMouseOver="this.oldstyle=this.style.cssText;'+this.sort_col_mouseover+'" onMouseOut="this.style.cssText=this.oldstyle;" class="'+this.sort_col_class+'" href="#" title="'+this.sort_col_title+'" onclick="javascript:fdTableSort.resortTable(this.parentNode);return false">'+txt+'</a>';}
}


if(sortCell) this.resortTable(sortCell);}, sortables_init : function()
{ if(sortInit)
{ return;}
sortInit = true; if (!document.getElementsByTagName) return; var tbls = document.getElementsByTagName("table"); for (var ti=0;ti<tbls.length;ti++) { thisTbl = tbls[ti]; if(!fdTableSort.sort_only_sortable || thisTbl.className.match(/sortable/i))
fdTableSort.makeSortable(thisTbl);}
var url1=url.substr(url.lastIndexOf("/")); var URLSplit=url1.split("&")[0]; URLSplit=URLSplit.substr(1,URLSplit.length); URLSplit1=URLSplit.split("=")[1]; if(URLSplit.toLowerCase().indexOf("naptan.aspx?t=districts") > -1 || URLSplit.toLowerCase().indexOf("naptan.aspx?t=adminareas")>-1|| URLSplit.toLowerCase().indexOf("naptan.aspx?t=vectors")>-1|| URLSplit.toLowerCase().indexOf("naptan.aspx?t=localities")>-1|| URLSplit.toLowerCase().indexOf("naptan.aspx?t=departure")>-1 || URLSplit.toLowerCase().indexOf("txtstopnumber") > -1)
{ if(readIt("pagecookie")!=undefined)
{ if(readIt("pagecookie")!=URLSplit1)
{ saveIt("pagecookie",URLSplit1)
Cookies.erase("naptoncookie"); saveIt("naptoncookie","1")
}
}
else
{ saveIt("pagecookie",URLSplit1)
}
delCookie("naptoncookie");}
}, getParent : function(el, pTagName)
{ if (el == null) return null; else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())
return el; else
return this.getParent(el.parentNode, pTagName);}, getInnerText : function(el)
{ if (typeof el == "string") return el; if (typeof el == "undefined") { return el }; if (el.innerText) return el.innerText; var str = ""; var cs = el.childNodes; var l = cs.length; for (var i = 0; i < l; i++) { switch (cs[i].nodeType) { case 1:
str += this.getInnerText(cs[i]); break; case 3:
str += cs[i].nodeValue; break;}
}
return str;}, match_date_format : function(value, format)
{ format = format.replace(/\//g, '[-,. \\/]');
this.set_date_array(format); if(!isNaN(this.convert_date(this.getInnerText(value.cells[this.sort_column_index])))) return true; return false;}, get_sortfn : function(warn_type, user_type)
{ var sortfn = this.sort_caseinsensitive; var table = this.clicked_table; var td = this.clicked_td; var column = this.sort_column_index; if(!table || table.rows.length < fdTableSort.minimum_sort_row || !td) return sortfn; var type = user_type || table.rows[0].cells[column].getAttribute("ts_type"); this.replace_pattern = ''; var itm; for(var rowcount = 0, i = 0; i < table.rows.length; i++)
{if(rowcount++ < fdTableSort.skiprows) continue; var t = table.rows[i].parentNode.tagName.toLowerCase(); if(t == 'tbody' && table.rows[i].cells.length >= column + 1)
{ itm = this.getInnerText(table.rows[i].cells[column]); if(itm.match(/\S/)) break;}
}
if(i == table.rows.length) return sortfn; itm = ml_trim(itm); if(!type || (!user_type && this.table_content_might_change))
{ if (this.default_date_style == 'euro' && this.match_date_format(table.rows[i], 'D/M/Y'))
{ sortfn = this.sort_date; type = 'euro_date' }
else if (this.match_date_format(table.rows[i], 'M/D/Y'))
{ sortfn = this.sort_date; type = 'date' }
else if (itm.match(/^[ĄŁ€$]/))
{ sortfn = this.sort_currency; type = 'money' }
else if (itm.match(/^\d{1,3}(\.\d{1,3}){3}$/))
{ sortfn = this.sort_ip; type = 'ip' }
else if (itm.match(/^[+-]?\s*[0-9]+(?:\.[0-9]+)?(?:\s*[eE]\s*[+-]?\s*\d+)?$/))
{ sortfn = this.sort_numeric; type = 'number' }
}
else if(type == 'string') sortfn = this.sort_caseinsensitive; else if(type == 'date')
{ if(this.match_date_format(table.rows[i], 'M/D/Y')) sortfn = this.sort_date; else if(warn_type) alert('The data is not standard time stamp and cannot be parsed! The column will be sorted alphabetically instead.');}
else if(type == 'euro_date')
{ if(this.match_date_format(table.rows[i], 'D/M/Y')) sortfn = this.sort_date; else if(warn_type) alert('The data is not standard time stamp and cannot be parsed! The column will be sorted alphabetically instead.');}
else if(type == 'year_month_date')
{ if(this.match_date_format(table.rows[i], 'Y/M/D')) sortfn = this.sort_date; else if(warn_type) alert('The data is not standard time stamp and cannot be parsed! The column will be sorted alphabetically instead.');}
else if(type == 'year_date_month')
{ if(this.match_date_format(table.rows[i], 'Y/D/M')) sortfn = this.sort_date; else if(warn_type) alert('The data is not standard time stamp and cannot be parsed! The column will be sorted alphabetically instead.');}
else if(type == 'other_date')
{ this.set_date_array(td.getAttribute("ts_date_format").replace(/\//g, '[-. \\/]'));
sortfn = this.sort_date;}
else if(type == 'number') sortfn = this.sort_numeric; else if(type == 'ip') sortfn = this.sort_ip; else if(type == 'money') sortfn = this.sort_currency; else if(type == 'custom') { this.custom_code = td.getAttribute("ts_sortfn"); sortfn = this.custom_sortfn }
else if(warn_type) { /*alert("unsupported sorting type!");*/}
table.rows[0].cells[column].setAttribute("ts_type", type); return sortfn;}, table_has_header : function(table)
{ if(table.tHead && table.tHead.rows.length > 0) return true; return false;}, resortTable : function(td)
{ 
if(td == null) 
return; 
var column = 0; // td.cellIndex; 
/* The following for loop is added by Viji to get the cell index after including the hidden columns */
for(var cellIndex = 0; cellIndex < td.parentNode.cells.length; cellIndex++)
{
    if(td.innerText.toLowerCase() == td.parentNode.cells[cellIndex].innerText.toLowerCase())
    { column = cellIndex; break; }
}
var url = window.location.href; 
var url1=url.substr(url.lastIndexOf("/")); 
var URLSplit=url1.split("&")[0]; 
URLSplit=URLSplit.substr(1,URLSplit.length); 

if(td.innerText.toLowerCase() == "departure time")
{  column = 4; }
//if(URLSplit.toLowerCase().indexOf("naptan.aspx") > -1)
//{
////alert(td.cellIndex);
////if(td.cellIndex==2)
//if(td.innerText.toLowerCase() == "departure time")
//{ column =5; }
//}
if(URLSplit.toLowerCase().indexOf("network.aspx") > -1 && td != null)
{ if(td.innerText.toLowerCase() == "type")
{ column =0;}
else if(td.innerText.toLowerCase() == "severity")
{ column =1;}
}
var table = this.getParent(td,'TABLE'); this.sort_column_index = column; if(table.rows[0].cells[column].getAttribute("ts_nosort")) return; this.clicked_table = table; if(table == null || table.rows.length < fdTableSort.minimum_sort_row) return; this.set_skiprows(td); this.clicked_td = td; var newRows = new Array(); var headcount = 0; var alt = false; for (var i=0,j=0,rowcount=0;j<table.rows.length;j++)
{ var t = table.rows[j].parentNode.tagName.toLowerCase(); if(t == 'tbody')
{ if(rowcount++ < fdTableSort.skiprows) continue; else if(table.rows[j].cells.length >= column + 1)alt=true; newRows[i++] = table.rows[j];}
else if(t == 'thead') headcount++;}
if(newRows.length == 0) return; var time2 = new Date(); var lastSortCell = table.getAttribute("ts_sortcell") || 0; lastSortCell--; var lastSkipRows = table.getAttribute("ts_skiprows") || -1; var lastSortType = table.rows[0].cells[column].getAttribute("ts_type"); var sortingSameColumnAndRow = (table == this.last_sorted_table && column == lastSortCell
&& (!fdTableSort.no_sort_above_click || fdTableSort.skiprows == lastSkipRows)); table.setAttribute('ts_skiprows',fdTableSort.skiprows); var initSortDir = td.getAttribute("sortdir"); var lastSortDir; if(td.getAttribute("ts_forcesort"))
lastSortDir = (td.getAttribute("ts_forcesort") == 'desc')? 'asc' : 'desc'; else
lastSortDir = (sortingSameColumnAndRow)? table.getAttribute("ts_sortdir") : ( (initSortDir == 'desc')? 'asc' : (initSortDir == 'asc')? 'desc' : ( (this.default_sort_asc)? 'desc' : 'asc')); if(!td.getAttribute("ts_forcesort") && !this.table_content_might_change && sortingSameColumnAndRow)
newRows.reverse(); else if(td.getAttribute("ts_forcesort") && !this.table_content_might_change
&& sortingSameColumnAndRow && td.getAttribute("ts_forcesort") == table.getAttribute("ts_sortdir"))
{ if(this.forcesort_msg) alert(this.forcesort_msg); return;}
else
{ var sortfn = this.get_sortfn(true); table.setAttribute("ts_sortcell", column+1); newRows.sort(sortfn); if (lastSortDir == 'asc') newRows.reverse();}
var rowidx = table.getAttribute("ts_linkrow") || 0; if(lastSortCell > -1 && table.rows[rowidx].cells[lastSortCell].firstChild.style)
{ table.rows[rowidx].cells[lastSortCell].firstChild.oldstyle = this.sort_col_style; table.rows[rowidx].cells[lastSortCell].firstChild.style.cssText = this.sort_col_style; table.rows[rowidx].cells[lastSortCell].firstChild.className = this.sort_col_class;}
if(table.rows[rowidx].cells[column].firstChild.style)
{ table.rows[rowidx].cells[column].firstChild.oldstyle = this.sort_col_style_post_sort; table.rows[rowidx].cells[column].firstChild.style.cssText = this.sort_col_style_post_sort; table.rows[rowidx].cells[column].firstChild.className = this.sort_col_class_post_sort;}
if (lastSortDir == 'desc') table.setAttribute('ts_sortdir','asc'); else table.setAttribute('ts_sortdir','desc'); if(this.cookie_days > -1) this.set_cookie(table.cookieid, column + ':' + table.getAttribute('ts_sortdir')); if(lastSortCell > -1 && table.rows[rowidx].cells[lastSortCell].firstChild.tagName) table.rows[rowidx].cells[lastSortCell].firstChild.title = this.sort_col_title; if(table.rows[rowidx].cells[column].firstChild.tagName) table.rows[rowidx].cells[column].firstChild.title = ((lastSortDir == 'desc')? this.sort_col_asc_title : this.sort_col_desc_title); this.last_sorted_table = table; var time3 = new Date(); var alt = false; var ps = table.getAttribute("preserve_style") || this.preserve_style; if(ps == 'row' && !ts_browser_is_ie)
{ var tmp = new Array(newRows.length); for (var i = 0; i < newRows.length; i++) tmp[i] = newRows[i].innerHTML; for (var i = 0; i < newRows.length; i++) table.rows[i+headcount+fdTableSort.skiprows].innerHTML = tmp[i];}
else
{ var alt = false; var tmp = new Array(newRows.length); for (var i = 0; i < newRows.length; i++)
for (var j = 0; j < newRows[i].cells.length; j++)
{ if(!tmp[i]) tmp[i] = new Array(newRows[i].cells.length); tmp[i][j] = newRows[i].cells[j].innerHTML;}
for (var i = 0; i < newRows.length; i++)
for (var j = 0; j < newRows[i].cells.length; j++)
{ table.rows[i+headcount+fdTableSort.skiprows].cells[j].innerHTML = tmp[i][j];}
}
var time4 = new Date(); if(this.tell_me_time_consumption)
{ alert('it took ' + this.diff_time(time3, time2) + ' seconds to do sorting!'); alert('it took ' + this.diff_time(time4, time3) + ' seconds to do redrawing!');}
}, diff_time : function(time2, time1)
{ return (time2.getTime() - time1.getTime())/1000;}, set_date_array : function(f)
{ var tmp = [['D', f.indexOf('D')], ['M', f.indexOf('M')], ['Y', f.indexOf('Y')]]; tmp.sort(function(a,b){ return a[1] - b[1]}); this.date_order_array = new Array(3); for(var i = 0; i < 3; i++) this.date_order_array[tmp[i][0]] = '$' + (i + 2); this.replace_pattern = f.replace(/[DMY]([^DMY]+)[DMY]([^DMY]+)[DMY]/, '^(.*?)(\\d+)$1(\\d+)$2(\\d+)(.*)$');}, process_year : function(y)
{ var tmp = parseInt(y); if(tmp < 32) return '20' + y; else if(tmp < 100) return '19' + y; else return y;}, convert_date : function(a)
{ var re = 'RegExp.$1+RegExp.'+this.date_order_array['M']+'+\'/\'+RegExp.'+this.date_order_array['D']+'+\'/\'+this.process_year(RegExp.'+this.date_order_array['Y']+')+RegExp.$5'; var code = 'if(a.match(/'+this.replace_pattern+'/)) (' + re + '); else a;'; return Date.parse(eval(code));}, sort_date : function(a,b)
{ var atext = fdTableSort.getInnerText(a.cells[fdTableSort.sort_column_index]); var btext = fdTableSort.getInnerText(b.cells[fdTableSort.sort_column_index]); var aa, bb; if(atext && atext.match(/\S/))
{ aa = fdTableSort.convert_date(atext); if(isNaN(aa)) aa = Date.parse(atext); if(isNaN(aa)) aa = 0;}
else aa = fdTableSort.smallest_int; if(btext && btext.match(/\S/))
{ bb = fdTableSort.convert_date(btext); if(isNaN(bb)) bb = Date.parse(btext); if(isNaN(bb)) bb = 0;}
else bb = fdTableSort.smallest_int; return aa - bb;}, sort_currency : function(a,b)
{ return fdTableSort.sort_num(fdTableSort.getInnerText(a.cells[fdTableSort.sort_column_index]).replace(/[^-0-9.+]/g,''), fdTableSort.getInnerText(b.cells[fdTableSort.sort_column_index]).replace(/[^-0-9.+]/g,''));}, sort_num : function(a, b)
{ var aa, bb; if(a && a.match(/\S/))
{ if(!isNaN(a)) aa = a; else if(a && a.match(/^[^0-9.+-]*([+-]?\s*[0-9]+(?:\.[0-9]+)?(?:\s*[eE]\s*[+-]?\s*\d+)?)/))
aa = parseFloat(RegExp.$1.replace(/\s+/g, '')); else aa = 0;}
else aa = fdTableSort.smallest_int; if(b && b.match(/\S/))
{ if(!isNaN(b)) bb = b; else if(b && b.match(/^[^0-9.+-]*([+-]?\s*[0-9]+(?:\.[0-9]+)?(?:\s*[eE]\s*[+-]?\s*\d+)?)/))
bb = parseFloat(RegExp.$1.replace(/\s+/g, '')); else bb = 0;}
else bb = fdTableSort.smallest_int; return aa - bb;}, sort_numeric : function(a,b)
{ return fdTableSort.sort_num(fdTableSort.getInnerText(a.cells[fdTableSort.sort_column_index]), fdTableSort.getInnerText(b.cells[fdTableSort.sort_column_index]));}, sort_ip : function(a,b)
{ var aa = fdTableSort.getInnerText(a.cells[fdTableSort.sort_column_index]).split('.'); var bb = fdTableSort.getInnerText(b.cells[fdTableSort.sort_column_index]).split('.'); return fdTableSort.sort_num(aa[0], bb[0]) || fdTableSort.sort_num(aa[1], bb[1]) || fdTableSort.sort_num(aa[2], bb[2]) || fdTableSort.sort_num(aa[3], bb[3]);}, sort_caseinsensitive : function(a,b)
{ var aa = fdTableSort.getInnerText(a.cells[fdTableSort.sort_column_index]).toLowerCase(); var bb = fdTableSort.getInnerText(b.cells[fdTableSort.sort_column_index]).toLowerCase(); if (aa==bb) return 0; if (aa<bb) return -1; return 1;}, custom_sortfn : function(aa,bb)
{ var a = fdTableSort.getInnerText(aa.cells[fdTableSort.sort_column_index]); var b = fdTableSort.getInnerText(bb.cells[fdTableSort.sort_column_index]); return eval(fdTableSort.custom_code);}, set_cookie : function(name, value)
{ var date = new Date(); var expires = ''; if(fdTableSort.cookie_days > 0)
{ date.setTime(date.getTime() + fdTableSort.cookie_days * 24 * 360000); expires = '; expires=' + date.toGMTString();}
document.cookie = name + '=' + value + expires;}, get_cookie : function(name)
{ if(document.cookie)
{ var st = document.cookie.indexOf(name); if (st > -1)
{ st = st + name.length + 1; var end = document.cookie.indexOf(';', st); if(end == -1) end = document.cookie.length; return unescape(document.cookie.substring(st, end));}
}
}
}; function ml_trim(text)
{ if(!text) return text; var tmp = text.replace(/^\s+/, ''); return tmp.replace(/\s+$/, '');}
function saveIt(name,x) { Cookies.create(name,x,0);}
function readIt(name) { return Cookies[name];}
function eraseIt(name) { Cookies.erase(name);}
var Cookies = { init: function () { var allCookies = document.cookie.split('; '); for (var i=0;i<allCookies.length;i++) { var cookiePair = allCookies[i].split('='); this[cookiePair[0]] = cookiePair[1];}
}, create: function (name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(36000)); var expires = "; expires="+date.toGMTString();}
else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; this[name] = value;}, erase: function (name) { this.create(name,'',-1); this[name] = undefined;}
}; Cookies.init(); var url = window.location.href; var url2 = url.substr(0,url.lastIndexOf("?")); var url3=url2.substr(url2.lastIndexOf("/"),url2.length); var url4=url3.split(".aspx")[0]; url4=url4.substr(1,url4.length); if(url4.toUpperCase()=="NAPTAN" || url4.toUpperCase()=="PUBLIC-TRANSPORT" || url4.toUpperCase()=="PUBLICTRANSPORT")
{ }
else
{ delCookie("naptoncookie");}
var el=""; function togCell(col)
{ if (typeof event!=='undefined')
el=event.srcElement
for (var i = 0; i < el.parentNode.cells.length; i++)
el.parentNode.cells[i].style.backgroundColor=''
el.style.backgroundColor=col
}

if (window.addEventListener)
    window.addEventListener('click', function(e){el=e.target}, true)

function ts_addEvent(elm, evType, fn, useCapture)
{ if (elm.addEventListener){ elm.addEventListener(evType, fn, useCapture); return true;} else if (elm.attachEvent){ var r = elm.attachEvent("on"+evType, fn); return r;} else { alert("Handler could not be removed"); return false;}
}
ts_addEvent(window, "click", fdTableSort.set_vars); ts_addEvent(window, "load", fdTableSort.sortables_init); 

function FindNextBus()
{var stopNo = document.getElementById("txtStopNo").value;
window.location="http://wypte.acislive.com/pip/stop_simulator.asp?naptan="+stopNo+"&pscode=&dest=&offset=0";
}
function FindDepartures()
{
var trainStation= document.getElementById("MainControl_SubHomePage_ZoneRight_realTime_trainStation").value;
window.location="http://realtime.nationalrail.co.uk/ldb/sumdep.aspx?T="+trainStation+"&R=1&A=0"
}