﻿function fnSearch()
{ var path=window.location.href.split("/")[0]; var s=window.location.href.split("/").length; for(i=1;i<s-1;i++)
{ path=path+"/"+window.location.href.split("/")[i];}
if(document.getElementById("searchslt").value=="~/naptan.aspx"||document.getElementById("searchslt").value=="naptan.aspx")
{ window.location.href=path+"/naptan.aspx?op=2&t=stoppoints&format="+document.getElementById("format").value+"&search="+document.getElementById("search").value; focus(document.getElementById("searchslt").value == "Search Stops");}
else if(document.getElementById("searchslt").value=="networksearch.aspx")
{ window.location.href=path+"/Search.aspx?op=1&t=searchnetwork&format="+document.getElementById("format").value+"&search="+document.getElementById("search").value; focus(document.getElementById("searchslt").value == "Search Network");}
else if(document.getElementById("searchslt").value=="search-results.aspx")
{ window.location.href=path+"/search-results.aspx?op=0&search="+document.getElementById("search").value; focus(document.getElementById("searchslt").value == "Search Site");}
}
function fnCheckForEnterKey()
{ var e = window.event; if (e != null){ if (e.keyCode == 13)
{ fnSearch();} }
}
document.onkeypress=function(e)
{ var e = window.event; if (e != null){ if (e.which == 13)
{ fnSearch();} }
}
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(); tablePaginater = { tableInfo: {}, uniqueID:0, text: ["First Page","Previous Page (Page %p)","Next Page (Page %p)","Last Page (Page %t)","Page %p of %t"], addEvent: function(obj, type, fn, tmp) { tmp || (tmp = true); if( obj.attachEvent ) { obj["e"+type+fn] = fn; obj[type+fn] = function(){obj["e"+type+fn]( window.event );}; obj.attachEvent( "on"+type, obj[type+fn] );} else { obj.addEventListener( type, fn, true );};}, addClass: function(e,c) { if(new RegExp("(^|\\s)" + c + "(\\s|$)").test(e.className)) return; e.className += ( e.className ? " " : "" ) + c;}, removeClass: function(e,c) { e.className = !c ? "" : e.className.replace(new RegExp("(^|\\s)" + c + "(\\s|$)"), " ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');}, init: function(tableId) { var tables = tableId && typeof(tableId) == "string" ? [document.getElementById(tableId)] : document.getElementsByTagName('table'); var hook, maxPages, visibleRows, numPages, cp, cb, rowList; for(var t = 0, tbl; tbl = tables[t]; t++)
{ if(tbl.className.search(/paginate-([0-9]+)/) == -1) { continue;}; if(!tbl.id) { tbl.id = "fdUniqueTableId_" + tablePaginater.uniqueID++;}; maxPages = tbl.className.search(/max-pages-([0-9]+)/) == -1 ? null : Number(tbl.className.match(/max-pages-([0-9]+)/)[1]); if(maxPages % 2 == 0 && maxPages > 1) { maxPages--;}; hook = tbl.getElementsByTagName('tbody'); hook = (hook.length) ? hook[0] : tbl; visibleRows = tablePaginater.calculateVisibleRows(hook); if(maxPages > (visibleRows / Number(tbl.className.match(/paginate-([0-9]+)/)[1])))
{ maxPages = null;}; numPages = Math.ceil(visibleRows / Number(tbl.className.match(/paginate-([0-9]+)/)[1])); if(numPages < 2 && !(tbl.id in tablePaginater.tableInfo))
{ continue;}; cp = (tbl.id in tablePaginater.tableInfo) ? Math.min(tablePaginater.tableInfo[tbl.id].currentPage, numPages) : 1; cb = tbl.className.search(/paginationcallback-([\S-]+)/) == -1 ? "" : tbl.className.match(/paginationcallback-([\S]+)/)[1]; cb = cb.replace("-", "."); tablePaginater.tableInfo[tbl.id] = { rowsPerPage:Number(tbl.className.match(/paginate-([0-9]+)/)[1]), currentPage:cp, totalRows:hook.getElementsByTagName('tr').length, hook:hook, maxPages:maxPages, numPages:numPages, rowStyle:tbl.className.search(/rowstyle-([\S]+)/) != -1 ? tbl.className.match(/rowstyle-([\S]+)/)[1] : false, callback:cb || "paginationCallback"
}; tablePaginater.showPage(tbl.id); hook = null;};}, calculateVisibleRows: function(hook) { var trs = hook.rows; var cnt = 0; var reg = /(^|\s)invisibleRow(\s|$)/; for(var i = 0, tr; tr = trs[i]; i++) { if(tr.parentNode != hook || tr.getElementsByTagName("th").length || (tr.parentNode && tr.parentNode.tagName.toLowerCase().search(/thead|tfoot/) != -1)) continue; if(tr.className.search(reg) == -1) { cnt++;};}; return cnt;}, createButton: function(details, ul, pseudo) { var li = document.createElement("li"); var but = document.createElement(pseudo ? "div" : "a"); var span = document.createElement("span"); if(!pseudo) { but.href = "#";}; if(!pseudo) { but.title = details.title;}; but.className = details.className; ul.appendChild(li); li.appendChild(but); but.appendChild(span); span.appendChild(document.createTextNode(details.text)); if(!pseudo) { li.onclick = but.onclick = tablePaginater.buttonClick;}; if(!pseudo && details.id) { but.id = details.id;}; li = but = span = null;}, removePagination: function(tableId) { var wrapT = document.getElementById(tableId + "-fdtablePaginaterWrapTop"); var wrapB = document.getElementById(tableId + "-fdtablePaginaterWrapBottom"); if(wrapT) { wrapT.parentNode.removeChild(wrapT);}; if(wrapB) { wrapB.parentNode.removeChild(wrapB);};}, buildPagination: function(tblId) { if(!(tblId in tablePaginater.tableInfo)) { return;}; tablePaginater.removePagination(tblId); var details = tablePaginater.tableInfo[tblId]; if(details.numPages < 2) return; function resolveText(txt, curr) { curr = curr || details.currentPage; return txt.replace("%p", curr).replace("%t", details.numPages);}; if(details.maxPages) { findex = Math.max(0, Math.floor(Number(details.currentPage - 1) - (Number(details.maxPages - 1) / 2))); lindex = findex + Number(details.maxPages); if(lindex > details.numPages) { lindex = details.numPages; findex = Math.max(0, details.numPages - Number(details.maxPages));};} else { findex = 0; lindex = details.numPages;}; var wrapT = document.createElement("div"); wrapT.className = "fdtablePaginaterWrap"; wrapT.id = tblId + "-fdtablePaginaterWrapTop"; var wrapB = document.createElement("div"); wrapB.className = "fdtablePaginaterWrap"; wrapB.id = tblId + "-fdtablePaginaterWrapBottom"; var ulT = document.createElement("ul"); ulT.id = tblId + "-tablePaginater"; var ulB = document.createElement("ul"); ulB.id = tblId + "-tablePaginaterClone"; ulT.className = ulB.className = "fdtablePaginater"; wrapT.appendChild(ulT); wrapB.appendChild(ulB); if(details.maxPages) { tablePaginater.createButton({title:tablePaginater.text[0], className:"first-page", text:"\u00ab"}, ulT, !findex); tablePaginater.createButton({title:tablePaginater.text[0], className:"first-page", text:"\u00ab"}, ulB, !findex);}; if(details.numPages > 2) { tablePaginater.createButton({title:resolveText(tablePaginater.text[1], details.currentPage-1), className:"previous-page", text:"\u2039", id:tblId+"-previousPage"}, ulT, details.currentPage == 1); tablePaginater.createButton({title:resolveText(tablePaginater.text[1], details.currentPage-1), className:"previous-page", text:"\u2039", id:tblId+"-previousPageC"}, ulB, details.currentPage == 1);}; for(var i = findex; i < lindex; i++) { tablePaginater.createButton({title:resolveText(tablePaginater.text[4], i+1), className:i != (details.currentPage-1) ? "page-"+(i+1) : "currentPage page-"+(i+1), text:(i+1), id:i == (details.currentPage-1) ? tblId + "-currentPage" : ""}, ulT); tablePaginater.createButton({title:resolveText(tablePaginater.text[4], i+1), className:i != (details.currentPage-1) ? "page-"+(i+1) : "currentPage page-"+(i+1), text:(i+1), id:i == (details.currentPage-1) ? tblId + "-currentPageC" : ""}, ulB);}; if(details.numPages > 2) { tablePaginater.createButton({title:resolveText(tablePaginater.text[2], details.currentPage + 1), className:"next-page", text:"\u203a", id:tblId+"-nextPage"}, ulT, details.currentPage == details.numPages); tablePaginater.createButton({title:resolveText(tablePaginater.text[2], details.currentPage + 1), className:"next-page", text:"\u203a", id:tblId+"-nextPageC"}, ulB, details.currentPage == details.numPages);}; if(details.maxPages) { tablePaginater.createButton({title:resolveText(tablePaginater.text[3], details.numPages), className:"last-page", text:"\u00bb"}, ulT, lindex == details.numPages); tablePaginater.createButton({title:resolveText(tablePaginater.text[3], details.numPages), className:"last-page", text:"\u00bb"}, ulB, lindex == details.numPages);}; if(document.getElementById(tblId+"-paginationListWrapBottom")) { document.getElementById(tblId+"-paginationListWrapBottom").appendChild(wrapB);} else { document.getElementById(tblId).parentNode.insertBefore(wrapB, document.getElementById(tblId).nextSibling);};}, redraw: function(tableid, identical) { if(!tableid || !(tableid in fdTableSort.tableCache) || !(tableid in tablePaginater.tableInfo)) { return;}; var dataObj = fdTableSort.tableCache[tableid]; var data = dataObj.data; var len1 = data.length; var len2 = len1 ? data[0].length - 1 : 0; var hook = dataObj.hook; var colStyle = dataObj.colStyle; var rowStyle = dataObj.rowStyle; var colOrder = dataObj.colOrder; var page = tablePaginater.tableInfo[tableid].currentPage - 1; var d1 = tablePaginater.tableInfo[tableid].rowsPerPage * page; var d2 = Math.min(tablePaginater.tableInfo[tableid].totalRows, d1 + tablePaginater.tableInfo[tableid].rowsPerPage); var cnt = 0; var rs = 0; var reg = /(^|\s)invisibleRow(\s|$)/; var tr, tds, cell, pos; for(var i = 0; i < len1; i++) { tr = data[i][len2]; if(colStyle) { tds = tr.cells; for(thPos in colOrder) { if(!colOrder[thPos]) tablePaginater.removeClass(tds[thPos], colStyle); else tablePaginater.addClass(tds[thPos], colStyle);};}; if(tr.className.search(reg) != -1) { continue;}; if(!identical) { cnt++; if(cnt > d1 && cnt <= d2) { if(rowStyle) { if(rs++ & 1) tablePaginater.addClass(tr, rowStyle); else tablePaginater.removeClass(tr, rowStyle);}; tr.style.display = "";} else { tr.style.display = "none";}; hook.appendChild(tr);};}; tr = tds = hook = null;}, showPage: function(tblId, pageNum) { if(!(tblId in tablePaginater.tableInfo)) { return;}; 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")
{ if (readIt('naptoncookie') != undefined)
{ if(tablePaginater.tableInfo[tblId].numPages < readIt('naptoncookie'))
{ var varTempName="naptoncookie"; document.cookie = varTempName+ "=; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/";}
else
{ tablePaginater.tableInfo[tblId].currentPage=readIt('naptoncookie'); saveIt('naptoncookie',tablePaginater.tableInfo[tblId].currentPage);}
}
}
var page = !pageNum ? tablePaginater.tableInfo[tblId].currentPage - 1 : pageNum - 1; var d1 = tablePaginater.tableInfo[tblId].rowsPerPage * page; var d2 = Math.min(tablePaginater.tableInfo[tblId].totalRows, d1 + tablePaginater.tableInfo[tblId].rowsPerPage); var trs = tablePaginater.tableInfo[tblId].hook.rows; var cnt = 0; var rc = 0; var len = trs.length; var rs = tablePaginater.tableInfo[tblId].rowStyle; var reg = /(^|\s)invisibleRow(\s|$)/; for(var i = 0; i < len; i++) { if(trs[i].getElementsByTagName("th").length || (trs[i].parentNode && trs[i].parentNode.tagName.toLowerCase().search(/thead|tfoot/) != -1)) continue; if(trs[i].className.search(reg) != -1) { continue;}; cnt++; if(cnt > d1 && cnt <= d2) { if(rs) { if(rc++ & 1) { tablePaginater.addClass(trs[i], rs);} else { tablePaginater.removeClass(trs[i], rs);}
}; trs[i].style.display = "";} else { trs[i].style.display = "none";};}; tablePaginater.buildPagination(tblId); tablePaginater.callback(tblId);}, callback: function(tblId) { var func; if(tablePaginater.tableInfo[tblId].callback.indexOf(".") != -1) { var split = tablePaginater.tableInfo[tblId].callback.split("."); func = window; for(var i = 0, f; f = split[i]; i++) { if(f in func) { func = func[f];} else { func = ""; break;};};} else if(tablePaginater.tableInfo[tblId].callback in window) { func = window[tablePaginater.tableInfo[tblId].callback];}; if(typeof func == "function") { func(tblId);}; func = null;}, buttonClick: function(e) { e = e || window.event; var a = this.tagName.toLowerCase() == "a" ? this : this.getElementsByTagName("a")[0]; if(a.className.search("currentPage") != -1) return false; var ul = this; while(ul.tagName.toLowerCase() != "ul") ul = ul.parentNode; var tblId = ul.id.replace("-tablePaginaterClone","").replace("-tablePaginater", ""); tablePaginater.tableInfo[tblId].lastPage = tablePaginater.tableInfo[tblId].currentPage; var showPrevNext = 0; if(a.className.search("previous-page") != -1) { tablePaginater.tableInfo[tblId].currentPage = tablePaginater.tableInfo[tblId].currentPage > 1 ? tablePaginater.tableInfo[tblId].currentPage - 1 : tablePaginater.tableInfo[tblId].numPages; showPrevNext = 1;} else if(a.className.search("next-page") != -1) { tablePaginater.tableInfo[tblId].currentPage = tablePaginater.tableInfo[tblId].currentPage < tablePaginater.tableInfo[tblId].numPages ? tablePaginater.tableInfo[tblId].currentPage + 1 : 1; showPrevNext = 2;} else if(a.className.search("first-page") != -1) { tablePaginater.tableInfo[tblId].currentPage = 1;} else if(a.className.search("last-page") != -1) { tablePaginater.tableInfo[tblId].currentPage = tablePaginater.tableInfo[tblId].numPages;} else { tablePaginater.tableInfo[tblId].currentPage = parseInt(a.className.match(/page-([0-9]+)/)[1]) || 1;}; 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")
{ saveIt('naptoncookie',tablePaginater.tableInfo[tblId].currentPage);}; tablePaginater.showPage(tblId); if(showPrevNext == 1) { var elem = document.getElementById(ul.id.search("-tablePaginaterClone") != -1 ? tblId + "-previousPageC" : tblId + "-previousPage");} else if(showPrevNext == 2) { var elem = document.getElementById(ul.id.search("-tablePaginaterClone") != -1 ? tblId + "-nextPageC" : tblId + "-nextPage");} else { var elem = document.getElementById(ul.id.search("-tablePaginaterClone") != -1 ? tblId + "-currentPageC" : tblId + "-currentPage");}; if(elem && elem.tagName.toLowerCase() == "a") { elem.focus();}; if(e.stopPropagation) { e.stopPropagation(); e.preventDefault();}; return false;}, onUnLoad: function(e) { var tbl, lis, pagination, uls; for(tblId in tablePaginater.tableInfo) { uls = [tblId + "-tablePaginater", tblId + "-tablePaginaterClone"]; for(var z = 0; z < 2; z++) { pagination = document.getElementById(uls[z]); if(!pagination) { continue;}; lis = pagination.getElementsByTagName("li"); for(var i = 0, li; li = lis[i]; i++) { li.onclick = null; if(li.getElementsByTagName("a").length) { li.getElementsByTagName("a")[0].onclick = null;};};};};}
}; tablePaginater.addEvent(window, "load", tablePaginater.init); tablePaginater.addEvent(window, "unload", tablePaginater.onUnLoad); 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");}
window.onload=function()
{ var url1=url.substr(url.lastIndexOf("/")); var URLSplit=url1.split("&")[0]; URLSplit=URLSplit.substr(1,URLSplit.length); URLSplit1=URLSplit.split("=")[1]; if(URLSplit=="naptan.aspx?t=districts" || URLSplit=="naptan.aspx?t=adminareas"|| URLSplit=="naptan.aspx?t=vectors"|| URLSplit=="naptan.aspx?t=localities"|| URLSplit=="naptan.aspx?t=departure")
{ if(readIt("pagecookie")!=undefined)
{ if(readIt("pagecookie")!=URLSplit1)
{ saveIt("pagecookie",URLSplit1)
Cookies.erase("naptoncookie"); saveIt("naptoncookie","1")
}
}
else
{ saveIt("pagecookie",URLSplit1)
}
delCookie("naptoncookie");}
}
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];}
function CheckandChangeStatus(checkBoxId)
{ 
if(document.getElementById("uxLatestDisruptions") == null)
    return;
    
    var tblFilters = document.getElementById("filters"); var cntRow = tblFilters.rows.length; var cntColumn; if(checkBoxId.indexOf("uxLatestDisruptions") > -1)
{ for(var row = 0; row < cntRow; row++)
{ cntColumn = tblFilters.rows[row].cells.length; for(var column = 0; column < cntColumn; column++)
{ if(tblFilters.rows[row].cells[column] != null && tblFilters.rows[row].cells[column].childNodes.length > 0)
{ for(var cntChild = 0; cntChild < tblFilters.rows[row].cells[column].childNodes.length; cntChild++)
{ if(tblFilters.rows[row].cells[column].childNodes[cntChild].type == "checkbox" && tblFilters.rows[row].cells[column].childNodes[cntChild].id != "uxLatestDisruptions")
{ tblFilters.rows[row].cells[column].childNodes[cntChild].checked = false;}
}
}
}
}
}
else if(document.getElementById("uxLatestDisruptions") != null)
{ document.getElementById("uxLatestDisruptions").checked = false; document.getElementById("uxLatestDisruptions").checked = "";}
    
if((checkBoxId=="uxLatestDisruptions") &&  document.getElementById("uxLatestDisruptions").checked==true)
    {
    document.getElementById("DPC_txtFromDate").disabled=true;
    document.getElementById("sltFromHour").disabled=true;
    document.getElementById("DPC_txtToDate").disabled=true;
    document.getElementById("sltToHour").disabled=true;
    document.getElementById("chkToClear").disabled=true;
     document.getElementById("hdnGrayId").value="true";
    }
    else
    {
    document.getElementById("DPC_txtFromDate").disabled=false;
    document.getElementById("sltFromHour").disabled=false;
    document.getElementById("DPC_txtToDate").disabled=false;
    document.getElementById("sltToHour").disabled=false;
    document.getElementById("chkToClear").disabled=false;
    document.getElementById("hdnGrayId").value="false";
    }
}

function CheckForNoDays(sltId)
{ var year = 0; var month = 0; var isFrom = false; var baseId = "sltFromDate_"; if(sltId.indexOf("From") > -1)
{ year = parseInt(document.getElementById("sltFromYear")[document.getElementById("sltFromYear").value].text); month = document.getElementById("sltFromMonth").value; isFrom = true;}
else if(sltId.indexOf("To") > -1)
{ year = parseInt(document.getElementById("sltToYear")[document.getElementById("sltToYear").value].text); month = document.getElementById("sltToMonth").value; baseId = "sltToDate_";}
var noDays = 31; if(month == 1)
{ if(year % 4 == 0)
noDays = 29; else
noDays = 28;}
else if(month == 3 || month == 5 || month == 8 || month == 10)
{ noDays = 30;}
var currentDay = 0; for(var i = 28; i <= 31; i++)
{ var curSltDate = baseId + i.toString(); if(document.getElementById(curSltDate).style.display == "inline" && document.getElementById(curSltDate).style.visibility == "visible")
{ currentDay = document.getElementById(curSltDate).value;}
}
var sltDate = baseId + noDays.toString(); for(var i = 28; i <= 31; i++)
{ var curSltDate = baseId + i.toString(); if(sltDate == curSltDate)
{ document.getElementById(curSltDate).style.display = "inline"; document.getElementById(curSltDate).style.visibility = "visible"; if(currentDay < document.getElementById(curSltDate).length)
document.getElementById(curSltDate).value = currentDay;}
else
{ document.getElementById(curSltDate).style.display = "none"; document.getElementById(curSltDate).style.visibility = "hidden";}
}
}

function DisableCalendar(chkId)
{ if(document.getElementById(chkId).disabled)
return; var disableFrom = false; var disableTo = false; var both = false; if(chkId == "chkDisableCalendar")
{ disableFrom = true; disableTo = true; both = true;}
else if(chkId == "chkToday")
{ disableFrom = true;}
else if(chkId == "chkDisableEndDate")
{ disableTo = true;}
else { return;}
var isDisabled = document.getElementById(chkId).checked; if(both)
{ document.getElementById("chkToday").disabled = isDisabled; document.getElementById("chkDisableEndDate").disabled = isDisabled; document.getElementById("chkToday").checked = ""; document.getElementById("chkDisableEndDate").checked = "";}
var baseId = "sltFromDate_"; var startIndex = 1; var endIndex = 2; if(!both)
{ if(disableFrom) { endIndex = 1;}
if(disableTo) { startIndex = 2;}
}
for(var cntDates = startIndex; cntDates <= endIndex; cntDates++)
{ if(cntDates == 2) { baseId = "sltToDate_";}
for(var i = 28; i <= 31; i++)
{ document.getElementById(baseId + i.toString()).disabled = isDisabled;}
}
if(disableFrom)
{ document.getElementById("sltFromMonth").disabled = isDisabled; document.getElementById("sltFromYear").disabled = isDisabled; document.getElementById("sltFromHour").disabled = isDisabled; document.getElementById("sltFromMinute").disabled = isDisabled; document.getElementById("sltFromDayNight").disabled = isDisabled;}
if(disableTo)
{ document.getElementById("sltToMonth").disabled = isDisabled; document.getElementById("sltToYear").disabled = isDisabled; document.getElementById("sltToHour").disabled = isDisabled; document.getElementById("sltToMinute").disabled = isDisabled; document.getElementById("sltToDayNight").disabled = isDisabled;}
}

function SetStartandEndDates()
{ 


  eraseIt('networkcookie');
if(document.getElementById("DPC_txtFromDate") ==null)
return; document.getElementById("hdnFromDate").value = ""; document.getElementById("hdnToDate").value = ""; if(!document.getElementById("chkToClear").checked)
{ if(document.getElementById("DPC_txtFromDate").value.length > 0 && document.getElementById("sltFromHour").value.length > 0)
document.getElementById("hdnFromDate").value = document.getElementById("DPC_txtFromDate").value + ";" + document.getElementById("sltFromHour").selectedIndex; if(document.getElementById("DPC_txtToDate").value.length > 0 && document.getElementById("sltToHour").value.length > 0)
document.getElementById("hdnToDate").value = document.getElementById("DPC_txtToDate").value + ";" + document.getElementById("sltToHour").selectedIndex;}
if(document.getElementById("DPC_txtFromDate").value.length == 0 && document.getElementById("DPC_txtToDate").value.length == 0)
document.getElementById("chkToClear").checked = true; document.getElementById("hdnChkValues").value = document.getElementById("chkToClear").checked; if(document.getElementById("hdnFromDate").value.length > 0)
document.getElementById("hdnFromDateString").value = document.getElementById("DPC_txtFromDate").value + " " + document.getElementById("sltFromHour").value; else
document.getElementById("hdnFromDateString").value = ""; if(document.getElementById("hdnToDate").value.length > 0)
document.getElementById("hdnToDateString").value = document.getElementById("DPC_txtToDate").value + " " + document.getElementById("sltToHour").value; else
document.getElementById("hdnToDateString").value = "";}
function UncheckAllDates()
{ if(document.getElementById("chkToClear") != null)
document.getElementById("chkToClear").checked = false;}
function ClearDates(chkToClear)
{ if(document.getElementById("DPC_txtFromDate") ==null)
return; if(document.getElementById(chkToClear).checked == true)
{ document.getElementById("DPC_txtFromDate").value = ""; document.getElementById("sltFromHour").value = ""; document.getElementById("DPC_txtToDate").value = ""; document.getElementById("sltToHour").value = "";}
else
{ document.getElementById("DPC_txtFromDate").value = document.getElementById("hdnDefaultFromDate").value; document.getElementById("sltFromHour").selectedIndex = 1; document.getElementById("DPC_txtToDate").value = document.getElementById("hdnDefaultToDate").value; document.getElementById("sltToHour").selectedIndex = 25;}
}
function onZeroIndex(sltHour)
{ if(document.getElementById("DPC_txtFromDate") ==null)
return; if(document.getElementById(sltHour).selectedIndex == 0)
document.getElementById(sltHour).selectedIndex = 1; if(sltHour == "sltFromHour" && document.getElementById("DPC_txtFromDate").value.length == 0)
{ document.getElementById("DPC_txtFromDate").value = document.getElementById("hdnDefaultFromDate").value;}
if(sltHour == "sltToHour" && document.getElementById("DPC_txtToDate").value.length == 0)
{ document.getElementById("DPC_txtToDate").value = document.getElementById("hdnDefaultToDate").value;}
}
function SelectZeroHour(isFromDate)
{ if(document.getElementById("DPC_txtFromDate") ==null)
return; if(isFromDate)
{ if(document.getElementById("DPC_txtFromDate").value.length > 0 && document.getElementById("sltFromHour").selectedIndex == 0)
{ document.getElementById("sltFromHour").selectedIndex = 1;}
}
else
{ if(document.getElementById("DPC_txtToDate").value.length > 0 && document.getElementById("sltToHour").selectedIndex == 0)
{ document.getElementById("sltToHour").selectedIndex = 1;}
if(document.getElementById("DPC_txtToDate").value.length > 0 && document.getElementById("DPC_txtFromDate").value.length == 0)
{ document.getElementById("DPC_txtFromDate").value = document.getElementById("hdnDefaultFromDate").value; document.getElementById("sltFromHour").selectedIndex = 1;}
}
}
function SetHighlightFault()
{ document.getElementById("hdnUser").value = document.getElementById("txtUser").value; document.getElementById("hdnPhoneNo").value = document.getElementById("txtEmailaddress").value; document.getElementById("hdnEmailaddress").value = document.getElementById("txtPhoneNo").value; document.getElementById("hdnComments").value = document.getElementById("txtComments").value;}
function SetStartandEndDates_old()
{ if(document.getElementById("sltFromMonth") == null)
return; var fromDate; var toDate; var fromDateString; var toDateString; var baseId = "sltFromDate_"; for(var cntDates = 1; cntDates <= 2; cntDates++)
{ if(cntDates == 2) { baseId = "sltToDate_";}
for(var i = 28; i <= 31; i++)
{ var curSltDate = baseId + i.toString(); if(document.getElementById(curSltDate).style.display == "inline" && document.getElementById(curSltDate).style.visibility == "visible")
{ if(cntDates == 1)
{ fromDate = document.getElementById(curSltDate).value - 1; fromDateString = document.getElementById(curSltDate)[document.getElementById(curSltDate).value - 1].text;}
else if(cntDates == 2)
{ toDate = document.getElementById(curSltDate).value - 1; toDateString = document.getElementById(curSltDate)[document.getElementById(curSltDate).value - 1].text;}
}
}
}
document.getElementById("hdnFromDate").value = fromDate + ";" + document.getElementById("sltFromMonth").value + ";" + document.getElementById("sltFromYear").value + ";" + (document.getElementById("sltFromHour").value - 1) + ";" + (document.getElementById("sltFromMinute").value - 1) + ";" + document.getElementById("sltFromDayNight").value; document.getElementById("hdnToDate").value = toDate + ";" + document.getElementById("sltToMonth").value + ";" + document.getElementById("sltToYear").value + ";" + (document.getElementById("sltToHour").value - 1) + ";" + (document.getElementById("sltToMinute").value - 1) + ";" + document.getElementById("sltToDayNight").value; document.getElementById("hdnChkValues").value = document.getElementById("chkDisableCalendar").checked + ";" + document.getElementById("chkToday").checked + ";" + document.getElementById("chkDisableEndDate").checked; document.getElementById("hdnFromDateString").value = fromDateString + "/" + document.getElementById("sltFromMonth")[document.getElementById("sltFromMonth").value].text + "/" + document.getElementById("sltFromYear")[document.getElementById("sltFromYear").value].text + " " + document.getElementById("sltFromHour")[document.getElementById("sltFromHour").value - 1].text + ":" + document.getElementById("sltFromMinute")[document.getElementById("sltFromMinute").value].text + " " + document.getElementById("sltFromDayNight")[document.getElementById("sltFromDayNight").value].text; document.getElementById("hdnToDateString").value = toDateString + "/" + document.getElementById("sltToMonth")[document.getElementById("sltToMonth").value].text + "/" + document.getElementById("sltToYear")[document.getElementById("sltToYear").value].text + " " + document.getElementById("sltToHour")[document.getElementById("sltToHour").value - 1].text + ":" + document.getElementById("sltToMinute")[document.getElementById("sltToMinute").value].text + " " + document.getElementById("sltToDayNight")[document.getElementById("sltToDayNight").value].text;}
function GetTitle(e) { var top = 0, left = 0; if (!e) { e = window.event;}
var myTarget = e.currentTarget; if (!myTarget) { myTarget = e.srcElement;}
else if (myTarget == "undefined") { myTarget = e.srcElement;}
while(myTarget!= document.body) { top += myTarget.offsetTop; left += myTarget.offsetLeft; myTarget = myTarget.offsetParent;}
var result ; result = "left: "+left + "; top:" +top+";"; if(top > 200)
alert(result);}

/* Add to Favourites */
function bookmarksite(url,desc){
	var bookmarkurl      = url;
	var bookmarktitle    = desc;
	var nonie            = 'Sorry, only Mozilla Firefox and Internet Explorer support this method to add a bookmark/favourite\n But please feel free to visit the site\'s home page to add a bookmark manually';

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(bookmarktitle, bookmarkurl,"");
	} else if(window.opera && window.print){
          var elem = document.createElement('a');
          elem.setAttribute('href',bookmarkurl);
          elem.setAttribute('title',bookmarktitle);
          elem.setAttribute('rel','sidebar');
          elem.click();
    } else if(document.all){ // IE Favourites
		window.external.AddFavorite(bookmarkurl,bookmarktitle);
	}else {
		alert(nonie);
	}
}

function ClearSearchType(objectId)
{
    SetValue("hdnSearchType", "");
    
    switch(objectId)
        {
            case "txtStopnumber":
                SetValue("txtStopname", "");
            break;
            case "txtStopname":
                SetValue("txtStopnumber", "");
            break;
        }
}

function SetSearchType(e, object)
{
    if(e.keyCode == 13)
    {
        var trimmedText = Trim(object.id);
        switch(object.id)
        {
            case "txtStopnumber":
                CheckandSubmitForm(1);
            break;
            case "txtStopname":
                CheckandSubmitForm(2);
            break;
            case "txtLocality":
                CheckandSubmitForm(3);
            break;
        }
    }
}

function SearchByMap()
{
    document.getElementById("hdnMode").value = SetStopMode();
    var virtualPathString = window.location.pathname.split("/");
    var virtualPath = "";
    if(virtualPathString.length == 3)
        virtualPath = "/" + virtualPathString[1];
    
    if(document.getElementById("hdnMode").value.length > 0)
        window.location.href = virtualPath + document.getElementById("hdnMapURL").value + "&stopmode=" + document.getElementById("hdnMode").value;
    else
        window.location.href = virtualPath + document.getElementById("hdnMapURL").value;
}
function SearchByArea()
{
    document.getElementById("hdnMode").value = SetStopMode();
    
    if(document.getElementById("hdnMode").value.length > 0)
        window.location.href = "naptan.aspx?t=searchbyarea&stopmode=" + document.getElementById("hdnMode").value;
    else
        window.location.href = "naptan.aspx?t=searchbyarea";
}

function Trim(id)
{
    var str = document.getElementById(id).value;
    return str.replace(/^\s*/, "").replace(/\s*$/, "");
}

function SearchByLocality()
{
    CheckandSubmitForm(3);
}

function SearchCriteriaForNaptan(searchType)
{  
    CheckandSubmitForm(searchType);
}

function CheckandSubmitForm(searchType)
{
    var canSearch = false;
    if(searchType < 3)
    {
        if(document.getElementById("hdnMode") != null)
            SetValue("hdnMode", SetStopMode());
    }
    
    switch(searchType)
    {
        case 1:
            var trimmedText = Trim("txtStopnumber");
            if(trimmedText.length > 0)
            {
                SetValue("hdnSearchType", "searchbystopnumber");
                SetValue("hdnSearchValue", trimmedText);
            }
        break;
        case 2:
            var trimmedText = Trim("txtStopname");
            if(trimmedText.length > 0)
            {
                SetValue("hdnSearchType", "searchbystopname");
                SetValue("hdnSearchValue", trimmedText);
            }
        break;
        case 3:
            var trimmedText = Trim("txtLocality");
            SetValue("hdnSearchType", "searchbylocality");
            SetValue("hdnSearchValue", trimmedText);
        break;
    }
    var i = 0;
    var foundForm = false;
    for(i = 0; i < document.forms.length; i++)
    {
        if(document.forms[i].id == "uxNaptanSearchForm")
        {
            foundForm = true;
            break;
        }
    }
    if(!foundForm)
    { i = 0; }
    document.forms[i].submit();
}
function SetValue(id, text)
{
    document.getElementById(id).value = text;
}
function SetStopMode()
{
    var stopType = "";
    if(document.getElementById("chkBus").checked)
        stopType = "bus";
    if(document.getElementById("chkTram") != null && document.getElementById("chkTram").checked)
    {
        if(stopType.length > 0)
            stopType = stopType + "/";
        stopType = stopType + "tmu";
    }
    if(document.getElementById("chkRail").checked)
    {
        if(stopType.length > 0)
            stopType = stopType + "/";
        stopType = stopType + "rail";
    }
    return stopType;
}
function CheckForTick(objectId)
{
    if(!document.getElementById(objectId).checked)
    {
        switch(objectId)
        {
            case "chkBus":
            if(document.getElementById("chkTram") != null)
            {
                if(!document.getElementById("chkTram").checked && !document.getElementById("chkRail").checked)
                    document.getElementById(objectId).checked = true;
            }
            else
            {
                if(!document.getElementById("chkRail").checked)
                    document.getElementById(objectId).checked = true;
            }
            break;
            case "chkTram":
                if(!document.getElementById("chkBus").checked && !document.getElementById("chkRail").checked)
                document.getElementById(objectId).checked = true;
            break;
            case "chkRail":
            if(document.getElementById("chkTram") != null)
            {
                if(!document.getElementById("chkBus").checked && !document.getElementById("chkTram").checked)
                    document.getElementById(objectId).checked = true;
            }
            else
            {
                if(!document.getElementById("chkBus").checked)
                    document.getElementById(objectId).checked = true;
            }
            break;
        }
    }
}
/*function SearchCriteriaForNaptan(searchType)
{
    switch(searchType)
    {
        case 1:
//            alert("Stop Number");
            document.getElementById("hdnSearchType").value = "searchbystopnumber";
            document.getElementById("hdnSearchValue").value = document.getElementById("txtStopnumber").value;
        break;
        case 2:
//            alert("Stop Name");
            document.getElementById("hdnSearchType").value = "searchbystopname";
            document.getElementById("hdnSearchValue").value = document.getElementById("txtStopname").value;
        break;
        case 3:
//            alert("Locality");
            document.getElementById("hdnSearchType").value = "searchbylocality";
            document.getElementById("hdnSearchValue").value = document.getElementById("txtLocality").value;
        break;
    }
//    alert(document.getElementById("hdnSearchType").value);
//    alert(document.getElementById("hdnSearchValue").value);
}
*/
function Alerts(x)
{
    document.getElementById("hdnCarId").value=x;
    //alert(document.getElementById("ComboName").value);
    document.forms[0].submit();
    eraseIt('carcookie');
}

function SignalAlerts(x)
{
    document.getElementById("hdnTrafficId").value=x;
    //alert(document.getElementById("ComboName").value);
    document.forms[0].submit();

}

function eraseIt(name) {

                Cookies.erase(name);

}