function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// 
// Next section is used by index.htm and displays a randomly chosen image when page appears
//
// This script was supplied free by Hypergurl
// http://www.hypergurl.com
<!--
    // JavaScript to interpolate random images into a page.
    var ic = 12;     // Number of alternative images
    var xoxo = new Array(ic);  // Array to hold filenames
        
xoxo[0] = "images/map_barking.gif";
xoxo[1] = "images/map_wp1.gif";
xoxo[2] = "images/map_wp2.gif";
xoxo[3] = "images/map_leytonstone.gif";
xoxo[4] = "images/map_lm.gif";
xoxo[5] = "images/map_wqr.gif";
xoxo[6] = "images/map_br.gif";
xoxo[7] = "images/map_st.gif";
xoxo[8] = "images/map_hgl.gif";
xoxo[9] = "images/map_ch.gif";
xoxo[10] = "images/map_uh.gif";
xoxo[11] = "images/map_go.gif";

function pickRandom(range) {
if (Math.random)
return Math.round(Math.random() * (range-1));
else {
var now = new Date();
return (now.getTime() / 1000) % range;
}
}
// Write out an IMG tag, using a randomly-chosen image name.
var choice = pickRandom(ic);
// -->  
//
//

function openUp() {
  window.open("temp_page1.htm", "", "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no")
}

function OpenWindow() { 
  // 'new' button
  var newwindow = window.open("slideshow.htm","1981","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=500,height=360");
  newwindow.focus();
  newwindow.moveTo(60,60);
  }

function show_alert_window() {
  window.open('alert_window.htm', 'BGO_line', 'width=200,height=500,left=100,top=100,resizable=yes,scrollbars=yes');
  return true;
}

function openUp(inVar) {
// http://www.standardmusicvenue.co.uk
// http://www.walthamforest-fc.co.uk/
// http://www.abfly.org.uk 
// http://www.heart-of-wales.co.uk
   // used on links page
   if (inVar == 1) {
      window.open("http://www.mylinkspage.com/rail.html")
   }
   else if (inVar == 2) {
      window.open("http://www.thameswater.co.uk/cps/rde/xchg/corp/hs.xsl/6253.htm")
   }
   else if (inVar == 3) {
      window.open("http://www.cityoflondon.gov.uk/Corporation/LGNL_Services/Environment_and_planning/Parks_and_open_spaces/Hampstead_Heath/")
   }
   else if (inVar == 4) {
      window.open("http://www.railpassengers.org.uk/")
   }
   else if (inVar == 5) {
      window.open("http://www.londontravelwatch.org.uk/")
   }
   else if (inVar == 6) {
      window.open("http://www.walthamforest.gov.uk/index/education/.../brooks-farm.htm")
   }
   else if (inVar == 7) {
      window.open("http://www.railfuture.org.uk")
   }
   else if (inVar == 8) {
      window.open("http://eorailway.co.uk")
   }
   else if (inVar == 9) {
      window.open("http://www.cityoflondon.gov.uk/wansteadflatsplayingfields")
   }
   else if (inVar == 10) {
      window.open("http://www.cityoflondon.gov.uk/Corporation/LGNL_Services/Environment_and_planning/Parks_and_open_spaces/Hampstead_Heath/")
   }
   else if (inVar == 11) {
      window.open("http://www.visitsouthend.co.uk/")
   }
   else if (inVar == 12) {
      window.open("http://www.leevalleypark.org.uk/")
   }
   else if (inVar == 13) {
      window.open("http://www.walthamforest.gov.uk/walthamstow-wetlands-project")
   }
   else if (inVar == 14) {
      window.open("temp_page2.htm", "", "width=600,height=600,fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no")
   }
   else if (inVar == 15) {
      window.open("temp_page3.htm", "", "width=600,height=600,fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no")
   }
   else if (inVar == 16) {
      window.open("http://www.lorol.co.uk")
   }
   else if (inVar == 17) {
      window.open("http://www.tfl.gov.uk")
   }
   else if (inVar == 18) {
      window.open("http://www.walthamforest.gov.uk/index/education/.../brooks-farm.htm")
   }
   else if (inVar == 19) {
      window.open("http://www.walthamforest.gov.uk/index/.../walthamstow-market.htm")
   }
   else if (inVar == 20) {
      window.open("http://www.cityoflondon.gov.uk/wansteadflatsplayingfields")
   }
   else if (inVar == 21) {
     window.open("alert_window.htm", "", "width=600,height=600,fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no")
   }
   else if (inVar == 22) { 
      window.open("http://www.walthamforestbig6.co.uk")
   }
   else if (inVar == 23) { 
      window.open("http://www.btp.police.uk/neighbourhood_policing/london_north/london_overground_npts/london_overground_east_npt.aspx")
   }
}  

function textCounter(field, countfield, maxlimit ) {
  // count number of characters entered into a field
  var v1 = document.tagform.check_char_count.value;

  if ( field.value.length > (maxlimit - 20))
  {
    document.tagform.check_char_count.value = 1;
    if (v1 == 0) {
       field.value = field.value.substring( 0, maxlimit );
       alert( 'You have 20 characters remaining!!' );
       return true;
    }
  }

  if ( field.value.length > maxlimit )
  {
    field.value = field.value.substring( 0, maxlimit );
    alert( 'Comments can be max. ' + maxlimit + ' characters long.' );
    return false;
  }
  else
  {
    countfield.value = maxlimit - field.value.length;
  }

}

// ========================================================================================================
// Following functions are for slideshow window
var rotate_delay = 2000; // delay in milliseconds (5000 = 5 secs)
current = 0;
function next() {
if (document.slideform.slide[current+1]) {
  document.images.show.src = document.slideform.slide[current+1].value;
  document.slideform.slide.selectedIndex = ++current;}
}

function previous() {
if (current-1 >= 0) {
  document.images.show.src = document.slideform.slide[current-1].value;
  document.slideform.slide.selectedIndex = --current; }
}

function ap(text) {
document.slideform.slidebutton.value = (text == "Stop") ? "Start" : "Stop";
rotate();}

function change() {
current = document.slideform.slide.selectedIndex;
document.images.show.src = document.slideform.slide[current].value;}

function rotate() {
if (document.slideform.slidebutton.value == "Stop") {
  current = (current == document.slideform.slide.length-1) ? 0 : current+1;
  document.images.show.src = document.slideform.slide[current].value;
  document.slideform.slide.selectedIndex = current;
  window.setTimeout("rotate()", rotate_delay);  }
}
// End of slideshow functions
// ========================================================================================================

// ========================================================================================================
// 
// Following functions are for displaying tooltips
// they are used in conjunction with tooltips.css
//
// ========================================================================================================
var xPos;
var yPos;

function showToolTip(title,msg,evt){
    if (evt) {
        var url = evt.target;
    }
    else {
        evt = window.event;
        var url = evt.srcElement;
    }
    xPos = evt.clientX;
    yPos = evt.clientY;

   var toolTip = document.getElementById("toolTip");
   toolTip.innerHTML = "<h1>"+title+"</h1><p>"+msg+"</p>";
   toolTip.style.top = parseInt(yPos)+2 + "px";
   toolTip.style.left = parseInt(xPos)+2 + "px";
   toolTip.style.visibility = "visible";
   
}

function hideToolTip(){
   var toolTip = document.getElementById("toolTip");
   toolTip.style.visibility = "hidden";
}
// End of tooltips functions
// ========================================================================================================

function show_date_time()  {
  var currentDate = new Date();
  var day = currentDate.getDate();
  var month1 = currentDate.getMonth() + 1;
  var month2;
  var year = currentDate.getFullYear();

  var currentTime = new Date();
  var hours = currentTime.getHours();
  var minutes = currentTime.getMinutes();

  if (hours < 10)
    hours = "0" + minutes;
  if (minutes < 10)
    minutes = "0" + minutes;

  if (month1 == 1) {month2 = 'Jan';}
     else if (month1 == 2) {month2 = 'Feb';} 
     else if (month1 == 3) {month2 = 'Mar';} 
     else if (month1 == 4) {month2 = 'Apr';} 
     else if (month1 == 5) {month2 = 'May';} 
     else if (month1 == 6) {month2 = 'Jun';} 
     else if (month1 == 7) {month2 = 'Jul';} 
     else if (month1 == 8) {month2 = 'Aug';} 
     else if (month1 == 9) {month2 = 'Sep';} 
     else if (month1 == 10) {month2 = 'Oct';} 
     else if (month1 == 11) {month2 = 'Nov';} 
     else {month2 = 'Dec';} 

  document.write('<b>' + day +  '-' + month2 + '-' + year + ', ' +  hours + ':' + minutes + ' ' + '</b>');
}


function show_alert() {alert('WEEKEND ENGINEERING WORKS 28-29 JANUARY\nBUSES REPLACE TRAINS BETWEEN SOUTH TOTTENHAM AND GOSPEL OAK Also details of works on London Overground and London Underground and national rail services which connect with the Barking - Gospel Oak Line have been summarised, click on the rail replacement bus logo on our Home page\n\nLINKS PAGE UPDATED\nOur links page has recently been updated to include more leisure destinations accessable from the Barking - Gospel Oak Line as well as LOROL, TfL, BTP, London Travelwatch and Passenger Focus. We hope you will find this useful.');

// alert('25-October-2010\n\nStart here \'words in quotes\' end of sentence.');

return true;
}

