// definitions for function variables
	var x
	var y;
	var flag = 0;
	var moveStatus = "OUT";
	var workStatus = "DONE";
	var txt;
	var lindex;

// definitions for location of points for rollover event (anchor map)
	var coordsPoint = new Array()

	coordsPoint[0] = new Point(195,226);
	coordsPoint[1] = new Point(223,219);
	coordsPoint[2] = new Point(310,226);
	coordsPoint[3] = new Point(369,244);
	coordsPoint[4] = new Point(393,192);
	coordsPoint[5] = new Point(425,266);
	coordsPoint[6] = new Point(461,268);
	coordsPoint[7] = new Point(433,222);
	coordsPoint[8] = new Point(417,172);
	coordsPoint[9] = new Point(378,150);
	coordsPoint[10] = new Point(397,156);
	coordsPoint[11] = new Point(430,72);
	coordsPoint[12] = new Point(465,126);
	coordsPoint[13] = new Point(435,150);
	coordsPoint[14] = new Point(436,105);



// function to preload images
  function doPreload(img) {
	var a=new Image();
	a.src=img;
	return a;
  }


// function to write text to div under uk map
function doWriteText(lyr, txt, num) {

var newindent;
		qtc = '"';
		if (!num) {
		    num = 200;
		}
		newindent = getScreenIndentW(num);
	
		if(document.all) {
			if (lyr == "textDivUK") {
			  newindent -= 400;
			}
			if ((txt) && (txt != " ")) { 
			  lyr.innerHTML = txt;
			  lyr.style.left = newindent;
			} else {
			  lyr.innerHTML = " ";
			}
	
		} else if (document.layers) {
			if (lyr == "textDivUK") {
			  newindent += 100;
			}
			if ((txt) && (txt != " ")) {
			lyr.left = newindent;
			lyr.document.open();
			lyr.document.write("<HTML><BODY><DIV ID='newdiv' STYLE='font-family:arial; font-size:12pt; font-weight:bold;'><BR><BR><B>" + txt + "</B></DIV></BODY></HTML>");
			} else {
			   lyr.document.write(" ");
			}
			lyr.document.close();
	
		}

	}


// function to display animated circle around points on map (NETSCAPE ONLY)
// dynamically detects position of map, and snaps new image to coords of link trigering the rollover event
function moveHandlerNS(index) {
		if (document.layers) {
			if (moveStatus == "OVER") {
			
			        messagetxt = "Click for details on our " + getMessageText(index);
			        doWriteText(document.layers['textDiv'], messagetxt);

			        x = document.images[2].x + coordsPoint[index].x;
			        y = document.images[2].y + coordsPoint[index].y;

			        var result = "<HTML><BODY><A HREF='locations" + (lindex) + ".html' TARGET='center'><IMG SRC='images/circleover.gif' VALIGN='bottom' BORDER='0'></A></BODY></HTML>"

			        document.layers['circleOver'].document.open();
			        document.layers['circleOver'].document.write(result);
		 	        document.layers['circleOver'].document.close();
		 	        document.layers['circleOver'].top = y;
		 	        document.layers['circleOver'].left = x;
		 	        document.layers['circleOver'].visibility = "visible";
//			        status = getMessageText(index);
	  		        timereturn = setTimeout("document.layers['circleOver'].visibility = 'hidden'; doWriteText(document.layers['textDiv'], ' ');", 1500);
	
			}
		}

}


// function to display animated circle around points on map (INTERNET EXPLORER ONLY)
// uses 'document.mousemove' event to detect mouse position and displays image at mouse coords.
function moveHandlerIE(){
		if (document.all) {
		 	if (moveStatus == "OVER") {
	
			        messagetxt = "Click for details on our " + getMessageText(lindex);
			        doWriteText(textDiv, messagetxt);

			        document.onmousemove = "";
			        x = (document.body.scrollLeft+event.clientX - 15);
			        y = (document.body.scrollTop+event.clientY - 15);
			        document.all.circleOver.innerHTML = "<HTML><BODY><A HREF='locations" + (lindex) + ".html' TARGET='center' onmouseover='status=getMessageText(lindex);' onmouseout='status=' ';'><IMG SRC='images/circleover.gif' BORDER='0'></A></BODY></HTML>";
			        document.all.circleOver.style.top = y;
			        document.all.circleOver.style.left = x;
			        document.all.circleOver.style.visibility = "visible";
			        timereturn = setTimeout("moveStatus = 'OUT'; document.onmousemove = moveHandlerIE; document.all.circleOver.style.visibility = 'hidden'; doWriteText(textDiv, ' ');", 1500);
	
			} else if (moveStatus == "OUT") {
			        document.all.circleOver.style.visibility = "hidden";

			}
	      
		}

}


// function to asign correct text to image
function getMessageText(index) {
	    switch(lindex) {
	        case 1: txt = "Bideford store..."; break;
	        case 2: txt = "Barnstaple store..."; break;
	        case 3: txt = "Taunton store..."; break;
	        case 4: txt = "Yeovil store..."; break;
	        case 5: txt = "Norton store..."; break;
	        case 6: txt = "Poole store..."; break;
	        case 7: txt = "Bournemouth store..."; break;
	        case 8: txt = "Salisbury store..."; break;
	        case 9: txt = "Bath stores..."; break;
	        case 10: txt = "Bishopsworth store..."; break;
	        case 11: txt = "Brislington store..."; break;
	        case 12: txt = "Swindon store..."; break;
	        case 13: txt = "Gloucester store..."; break;
	        case 14:txt = "Tetbury store..."; break;
	        case 15:txt = "Chippenham store..."; break;
	        defaut: txt = ""; break;
	    }
	    return txt;
}

// function to show properties of any object
function showprops(obj){
	    var result = ''; 
	    for (var prop in obj){
	        if (obj[prop]){
	            result += prop + ': \'' + obj[prop] + '\'\n';
	        }
	    }
	alert(result);
}


// function to return the horizontal screen indent (half available screen width, less given margin)
function getScreenIndentW(num) {
	    if (window.innerWidth) {
	        var scrindentW=(((window.innerWidth - 75) - num) / 2);
	    return parseInt(scrindentW);
	    } else if (document.body) {
	        var scrindentW=(((document.body.clientWidth - 75) - num) /2);
	        return parseInt(scrindentW);
	    } else{
	        return -1;
	    }
}


// function to return the vertical screen indent (half available screen height, less given margin)
function getScreenIndentH(num) {
	    if (window.innerHeight) {
	        var scrindentH=(((window.innerHeight - 25) - num) /2);
	        return parseInt(scrindentH);
	    } else if (document.body) {
	        var scrindentH=(((document.body.clientHeight - 25) - num) /2);
	        return parseInt(scrindentH);
	    } else{
	        return -1;
	    }
}

	
// function to create a new point
function Point(x, y){
	    this.x = 0;
	    this.y = 0;
	    if (x) this.x = x;
	    if (y) this.y = y;
	    return this;
}
	