//used to show message on status line
function StatusMsg(msgStr) { 
  window.status=msgStr;
  document.returnValue = true;
}

// used to clear the message on status line when a field looses focus
function LeaveField(){
	window.status=" ";
	document.returnValue = true;
}

function chgImg(name, image) {
if (document.images) {  // preload only if browser permits
	
	oxford = new Image;
	oxford.src = "images/oxford.jpg"
    	plain = new Image; 
	plain.src = "../images/wolv.jpg";
   	albion = new Image; 
	albion.src = "images/albionstreet.jpg";
	horseley = new Image;
	horseley.src = "images/horseley.jpg"
	maryannst = new Image;
	maryannst.src = "images/maryannst.jpg"
	shake = new Image
	shake.src = "images/shakespeare.jpg"
	shipton = new Image;
	shipton.src = "images/shiptonstreet.jpg";
	union = new Image;
	union.src = "images/unionstreet.jpg";
	walsall = new Image;
	walsall.src = "images/walsallstreet.jpg";
	ward = new Image;
	ward.src = "images/wardstreet.jpg";
	wharf = new Image;
	wharf.src = "images/wharfstreet.jpg";

	//images for northwich map
	allostock = new Image
	allostock.src = "images/allostock.jpg"
	barnton = new Image
	barnton.src = "images/barnton.jpg"
	bostock = new Image
	bostock.src = "images/bostock.jpg"
	budworth = new Image
	budworth.src = "images/budworth.jpg"
	castle = new Image
	castle.src = "images/castlenorthwich.jpg"
	davenham = new Image
	davenham.src = "images/davenham.jpg"
	greatbudworth = new Image
	greatbudworth.src = "images/greatbudworth.jpg"
	goostry = new Image
	goostry.src = "images/goostry.jpg"
	kinderton = new Image
	kinderton.src = "images/kinderton.jpg"
	leftwich = new Image
	leftwich.src = "images/leftwich.jpg"
	littleleigh = new Image
	littleleigh.src = "images/littleleigh.jpg"
	lostock = new Image
	lostock.src = "images/lostock.jpg"
	marston = new Image
	marston.src = "images/marston.jpg"
	middlewich = new Image
	middlewich.src = "images/middlewich.jpg"
	mooresbarrow = new Image
	mooresbarrow.src = "images/mooresbarrow.jpg"
	moulton = new Image
	moulton.src = "images/moulton.jpg"
	nether = new Image
	nether.src = "images/netherpeover.jpg"
	newton = new Image
	newton.src = "images/newton.jpg"
	northwich = new Image
	northwich.src = "images/northwich.jpg"
	north = new Image;
	north.src = "northwich.jpg"
	over = new Image
	over.src = "images/over.jpg"
	ravenscroft = new Image
	ravenscroft.src = "images/ravenscroft.jpg"
	rudheath = new Image
	rudheath.src = "images/rudheath.jpg"
	sproston = new Image
	sproston.src = "images/sproston.jpg"
	weaverham = new Image
	weaverham.src = "images/weaverham.jpg"
	wharton = new Image
	wharton.src = "images/wharton.jpg"
	wincham = new Image
	wincham.src = "images/wincham.jpg"
	winnington = new Image
	winnington.src = "images/winnington.jpg"
	witton = new Image
	witton.src = "images/witton.jpg"
	
    // add pair for each rollover wanted
}

	
    if (document.images) {
//	alert(name)
//	alert(eval(image + ".src"))
       document[name].src = eval(image + ".src");
    }
}


//used to show the date
function showDate(){

var now = new Date();
var month = (now.getMonth() + 1);
var date = now.getDate();
var year = now.getYear();
var season;
var txtGreet = "";
var dateMessage = "";

if (month == 1) season = "Winter";
if (month > 1 && month <= 3) season = "Winter";
if (month == 3 && date > 19) season = "Spring";
if (month > 3 && month <= 6) season = "Spring";
if (month == 6 && date > 20) season = "Summer";
if (month > 6 && month <= 9) season = "Summer";
if (month == 9 && date > 21) season = "Autumn";
if (month > 9 && month <= 12) season = "Autumn";
if (month == 12 && date > 20) season = "Winter";
document.write(season + " " + year+ "&nbsp;<br>");

var days=new Array(8);
days[1]= "Sunday";
days[2]= "Monday";
days[3]="Tuesday";
days[4]="Wednesday";
days[5]="Thursday";
days[6]="Friday";
days[7]="Saturday";

var months=new Array(13);
months[1]="January";
months[2]="Februay";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";

var dateObj=new Date()
var wday=days[dateObj.getDay() + 1]
var lmonth=months[dateObj.getMonth() + 1]
var date=dateObj.getDate()


now = new Date

var currentTime = new Date();
if (currentTime.getHours() < 12)
    txtGreet = "Good Morning"
else if (currentTime.getHours() < 17)
    txtGreet = "Good Afternoon"
else txtGreet = "Good Evening"



dateMessage = wday + ", " + lmonth +" "+date +  "&nbsp;<br>" +txtGreet
	

	return dateMessage
}

//must pass date as month/day/year
function checknew(date) {
var pic = "../images/updated.gif";
expdate = new Date(date);
curdate = new Date();
if (expdate.getTime() > curdate.getTime())
document.write("<img src=" + pic + ">");
}

function updated(date){
var pic = "../images/updated.gif";
expdate = new Date(date);
curdate = new Date();

if (expdate.getTime() > curdate.getTime())
document.write("<img src=" + pic + ">");
}

function checknew2(date) {
var pic = "../images/new.jpg";
expdate = new Date(date);
curdate = new Date();
if (expdate.getTime() > curdate.getTime())
document.write("<img src=" + pic + ">");
}

function newaddition(date){
var pic = "../images/new.jpg";
expdate = new Date(date);
curdate = new Date();
if (expdate.getTime() > curdate.getTime())
document.write("<img src=" + pic + ">");
}



var first, msgWidth = 570, bannerWidth;
var timerID, leftSide;
/* This function centers the banner window in the main browser window */
function centerBanner() {
  if (bannerWidth == null) setBannerWidth();
  var el = document.getElementById('canvas');
  var scrnWidth = (document.all ? document.body.clientWidth : window.innerWidth);
  el.style.left = parseInt(0.5*(scrnWidth - bannerWidth)) + "px";
  el.style.visibility = 'visible';
}

/* Gets the banner window width from the select box value */
function setBannerWidth() {
  var selEL = document.getElementById('banWidth');
  bannerWidth = parseInt(selEL.options[selEL.selectedIndex].text);
  document.getElementById('canvas').style.width = bannerWidth + "px";
  document.getElementById('canvasText').style.left = bannerWidth + "px";
  centerBanner();
}

/* Function to start and stop scrolling */
function scroll(type) {
   if (type == 'start') {
     first = true;            // set some initial variables
/* msgWidth is not really needed for IE other than its value needs
 * to be large enough so that the string text contained in
 * 'canvasText' occupies a single line without wrapping */
     leftSide = msgWidth;
     scrollIt(bannerWidth, 10, 250);
   } else 
     if (timerID != null) clearTimeout(timerID);
}

/* Function to reset the text layer for next scroll */
function clearText() {
  scroll('stop');
  var el = document.getElementById('canvasText');
/* The next statement not needed for IE */
  el.style.clip = "rect(0px, " + msgWidth + "px, 0px, 0px)";
  el.style.left = bannerWidth + "px";
}

/* Function which toggles the display of the script code.
 * Rather than going through the textNode creation shown here
 * the node value can be directly set to accomplish the
 * same thing */
function showCode() {
  var toggleEL = document.getElementById('toggleCode');
  var scrpEL = document.getElementById('scriptContainer');
  if (toggleEL.childNodes[0].nodeValue.indexOf('Show') != -1) {
     var eTEXT = document.createTextNode("Hide Script Code");
     toggleEL.replaceChild(eTEXT, toggleEL.childNodes[0]);
     scrpEL.className = 'scrShow';
  } else {
     var eTEXT = document.createTextNode("Show Script Code");
     toggleEL.replaceChild(eTEXT, toggleEL.childNodes[0]);
     scrpEL.className = 'scrHidden';
  }
  return false; 
}

/* Function that does the actually scrolling */
function scrollIt(Left, dx, speed) {
  var rightSide;
  var text = document.getElementById('canvasText');
  Left -= dx;
  if (document.all) {  // This branch is for the IE version
    if (first) {
      text.style.top = -1 + "px";
      msgWidth = 570;
      text.style.width =  msgWidth + "px";
      first = false;
    }
    text.style.left = Left + "px";
  } else {  // This branch is for the version in Gecko
    if (Left < 0) {
      rightSide = -Left;
      leftSide = (leftSide > 0 ? leftSide - dx : 0);
      text.style.clip = 'rect(0px, '+ leftSide + 'px, 0px, ' + rightSide + 'px)';
      text.style.left = Left + "px";
    } else {
      if (first) text.style.visibility = 'hidden';
      leftSide -= dx;
      text.style.clip = 'rect(0px, ' + leftSide + 'px, 0px, 0px)';
      text.style.left = Left + "px";
      if (first) {
        text.style.top = -0.5 + "px";  // this statement not needed in M12
        text.style.visibility = 'visible';
        first = false;
      }
    }
  }
  if (Left > -msgWidth)
    timerID = setTimeout("scrollIt(" + Left + ", " + dx + ", " + speed + ")", speed);
}
//-->