/*
* **************************************************************************
lp.js
Interactive Local Plan
Tesy Valley Borough Council
Ver 1.0
Lovell Johns Ltd.
03/07
****************************************************************************
*/

//*********************GLOBALS
// Insert output from 'js_navrray.txt' below		
//Set up the array for required info about each inset maps.
//Map name,origin X of overview inset frame,origin Y of overview inset frame,width of overview inset frame,blx of map grid,bly of map grid,trx of map grid,try of map grid,Grid Size,Grid Overlap,no. of rows,no. of cols
var theinsetsmaps = new Array (56)
var nofInsets = 56;
theinsetsmaps[0] = new Array("inset_55",438217,139915,2007.81,438200,140200,440350,141750,200,50,10,14);
theinsetsmaps[1] = new Array("inset_53",429869,145733,1390,429800,145900,431350,147000,200,50,7,10);
theinsetsmaps[2] = new Array("inset_54",431011,146115,1390,431200,146100,432300,147650,200,50,10,7);
theinsetsmaps[3] = new Array("inset_51",428254,118188,2007.81,428200,118400,430350,119950,200,50,10,14);
theinsetsmaps[4] = new Array("inset_52",429955,118109,1390,430100,118100,431200,119500,200,50,9,7);
theinsetsmaps[5] = new Array("inset_50",426616,129294,1390,426800,129200,427900,130750,200,50,10,7);
theinsetsmaps[6] = new Array("inset_49",425169,126606,1390,425300,126600,426400,128100,300,100,7,5);
theinsetsmaps[7] = new Array("inset_48",427769,137129,2007.81,427700,137400,429850,138950,200,50,10,14);
theinsetsmaps[8] = new Array("inset_47",429526,135823,1390,429500,136000,431050,137100,200,50,7,10);
theinsetsmaps[9] = new Array("inset_46",433256,155832,1390,433200,156000,434750,157100,200,50,7,10);
theinsetsmaps[10] = new Array("inset_45",435422,154513,1390,435600,154500,436700,156050,200,50,10,7);
theinsetsmaps[11] = new Array("inset_44",439082,131774,1390,439200,131700,440300,133250,200,50,10,7);
theinsetsmaps[12] = new Array("inset_43",433913,124231,1390,434100,124200,435200,125750,200,50,10,7);
theinsetsmaps[13] = new Array("inset_42",434755,134041,2007.81,434700,134300,436850,135850,200,50,10,14);
theinsetsmaps[14] = new Array("inset_41",422357,144711,1390,422300,144900,423850,146000,200,50,7,10);
theinsetsmaps[15] = new Array("inset_40",434551,120582,1400,434700,120500,435800,122050,200,50,10,7);
theinsetsmaps[16] = new Array("inset_38",426671,143313,1390,426800,143300,427900,144850,200,50,10,7);
theinsetsmaps[17] = new Array("inset_36",434189,113527,5600,434900,113500,439050,119150,400,150,22,16);
theinsetsmaps[18] = new Array("inset_35",430077,122576,1390,430200,122500,431300,124050,200,50,10,7);
theinsetsmaps[19] = new Array("inset_34",432001,126435,1390,432200,126400,433300,127950,200,50,10,7);
theinsetsmaps[20] = new Array("inset_33",430413,143476,2007.81,430400,143700,432550,145250,200,50,10,14);
theinsetsmaps[21] = new Array("inset_32",433913,125535,1390,434100,125500,435200,127050,200,50,10,7);
theinsetsmaps[22] = new Array("inset_31",435205,136340,1390,435400,136300,436500,137850,200,50,10,7);
theinsetsmaps[23] = new Array("inset_30",441400,143173,2007.81,441700,143100,443100,145250,200,50,14,9);
theinsetsmaps[24] = new Array("inset_29",442692,143173,2007.81,443000,143100,444400,145250,200,50,14,9);
theinsetsmaps[25] = new Array("inset_28",428824,125435,2007.81,428800,125700,430950,127250,200,50,10,14);
theinsetsmaps[26] = new Array("inset_27",436866,136931,1390,437000,136900,438100,138450,200,50,10,7);
theinsetsmaps[27] = new Array("inset_26",435244,129982,2007.81,435200,130200,437350,131750,200,50,10,14);
theinsetsmaps[28] = new Array("inset_25",427364,146258,1390,427500,146200,428600,147750,200,50,10,7);
theinsetsmaps[29] = new Array("inset_24",437289,152409,2008.61,437200,152700,439350,154250,200,50,10,14);
theinsetsmaps[30] = new Array("inset_23",432852,130241,2007.81,432800,130500,434950,132050,200,50,10,14);
theinsetsmaps[31] = new Array("inset_22",433528,131941,1390,433700,131900,434800,133450,200,50,10,7);
theinsetsmaps[32] = new Array("inset_21",433772,149614,2007.8,433700,149900,435850,151450,200,50,10,14);
theinsetsmaps[33] = new Array("inset_19",427144,141278,1390,427300,141200,428400,142750,200,50,10,7);
theinsetsmaps[34] = new Array("inset_20",425454,140034,2007.81,425700,140000,427250,142150,200,50,14,10);
theinsetsmaps[35] = new Array("inset_18",435273,141240,2007.81,435500,141200,437050,143350,200,50,14,10);
theinsetsmaps[36] = new Array("inset_17",428247,145163,2007.8,428500,145100,430050,147250,200,50,14,10);
theinsetsmaps[37] = new Array("inset_16",436453,148305,2007.81,436400,148600,438500,150100,300,100,7,10);
theinsetsmaps[38] = new Array("inset_15",429226,144542,1390.36,429400,144500,430500,146050,200,50,10,7);
theinsetsmaps[39] = new Array("inset_14",431252,125478,1390,431400,125400,432500,126950,200,50,10,7);
theinsetsmaps[40] = new Array("inset_13",438883,114277,5600,438800,115000,444700,119150,400,150,16,23);
theinsetsmaps[41] = new Array("inset_12",438218,138803,2007.81,438200,139100,440350,140650,200,50,10,14);
theinsetsmaps[42] = new Array("inset_11",430109,131941,2007.81,430400,131900,431950,134050,200,50,14,10);
theinsetsmaps[43] = new Array("inset_10",436645,123952,2007.81,436900,123900,438450,126050,200,50,14,10);
theinsetsmaps[44] = new Array("inset_09",442734,140187,2007.81,442700,140400,444850,141950,200,50,10,14);
theinsetsmaps[45] = new Array("inset_08",431073,123047,2007.81,431300,123000,432850,125150,200,50,14,10);
theinsetsmaps[46] = new Array("inset_07",429543,147950,2007.81,429800,147900,431350,150050,200,50,14,10);
theinsetsmaps[47] = new Array("inset_06",434231,142549,2007.81,434200,142800,436350,144350,200,50,10,14);
theinsetsmaps[48] = new Array("inset_05",435875,144912,1202.21,436000,144900,436950,146150,200,50,8,6);
theinsetsmaps[49] = new Array("inset_03",428743,143065,2007.81,429000,143000,430550,145150,200,50,14,10);
theinsetsmaps[50] = new Array("inset_02",439347,122534,2007.81,439300,122800,441450,124350,200,50,10,14);
theinsetsmaps[51] = new Array("inset_01",432405,142432,2007.81,432400,142700,434550,144250,200,50,10,14);
theinsetsmaps[52] = new Array("inset_37",432377,146876,1390,432500,146800,433600,148350,200,50,10,7);
theinsetsmaps[53] = new Array("inset_39",434564,117141,8309.1,434500,118400,442900,124300,400,150,23,33);
theinsetsmaps[54] = new Array("inset_04",431813,141658,8309.1,431800,143000,440200,148650,400,150,22,33);
theinsetsmaps[55] = new Array("inset_56",411250,113150,47500,418000,113000,453000,162000,3000,1000,24,17);
// ^^^^Insert output from 'js_navarray.txt' above ^^^^^^^^


//*********************BROWSER CHECKING
// Ultimate client-side JavaScript client sniff. Version 3.03
// (C) Netscape Communications 1999-2001.  Permission granted to reuse and distribute.
// Revised 17 May 99 to add is_nav5up and is_ie5up (see below).
// Revised 20 Dec 00 to add is_gecko and change is_nav5up to is_nav6up
//                      also added support for IE5.5 Opera4&5 HotJava3 AOLTV
// Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4, 
//                      correct Opera 5 detection
//                      add support for winME and win2k
//                      synch with browser-type-oo.js
// Revised 26 Mar 01 to correct Opera detection
// Revised 02 Oct 01 to add IE6 detection

// Everything you always wanted to know about your JavaScript client
// but were afraid to ask. Creates "is_" variables indicating:
// (1) browser vendor:
//     is_nav, is_ie, is_opera, is_hotjava, is_webtv, is_TVNavigator, is_AOLTV
// (2) browser version number:
//     is_major (integer indicating major version number: 2, 3, 4 ...)
//     is_minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
// (3) browser vendor AND major version number
//     is_nav2, is_nav3, is_nav4, is_nav4up, is_nav6, is_nav6up, is_gecko, is_ie3,
//     is_ie4, is_ie4up, is_ie5, is_ie5up, is_ie5_5, is_ie5_5up, is_ie6, is_ie6up, is_hotjava3, is_hotjava3up,
//     is_opera2, is_opera3, is_opera4, is_opera5, is_opera5up
// (4) JavaScript version number:
//     is_js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
// (5) OS platform and version:
//     is_win, is_win16, is_win32, is_win31, is_win95, is_winnt, is_win98, is_winme, is_win2k
//     is_os2
//     is_mac, is_mac68k, is_macppc
//     is_unix
//     is_sun, is_sun4, is_sun5, is_suni86
//     is_irix, is_irix5, is_irix6
//     is_hpux, is_hpux9, is_hpux10
//     is_aix, is_aix1, is_aix2, is_aix3, is_aix4
//     is_linux, is_sco, is_unixware, is_mpras, is_reliant
//     is_dec, is_sinix, is_freebsd, is_bsd
//     is_vms
//
// See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
// http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
// for detailed lists of userAgent strings.
//
// Note: you don't want your Nav4 or IE4 code to "turn off" or
// stop working when new versions of browsers are released, so
// in conditional code forks, use is_ie5up ("IE 5.0 or greater") 
// is_opera5up ("Opera 5.0 or greater") instead of is_ie5 or is_opera5
// to check version in code which you want to work on future
// versions.

    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);


    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);
    var is_aol5  = (agt.indexOf("aol 5") != -1);
    var is_aol6  = (agt.indexOf("aol 6") != -1);

    var is_opera = (agt.indexOf("opera") != -1);
    var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);

    var is_webtv = (agt.indexOf("webtv") != -1); 

    var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
    var is_AOLTV = is_TVNavigator;

    var is_hotjava = (agt.indexOf("hotjava") != -1);
    var is_hotjava3 = (is_hotjava && (is_major == 3));
    var is_hotjava3up = (is_hotjava && (is_major >= 3));

    // *** JAVASCRIPT VERSION CHECK ***
    var is_js;
    if (is_nav2 || is_ie3) is_js = 1.0;
    else if (is_nav3) is_js = 1.1;
    else if (is_opera5up) is_js = 1.3;
    else if (is_opera) is_js = 1.1;
    else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2;
    else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3;
    else if (is_hotjava3up) is_js = 1.4;
    else if (is_nav6 || is_gecko) is_js = 1.5;
    // NOTE: In the future, update this code when newer versions of JS
    // are released. For now, we try to provide some upward compatibility
    // so that future versions of Nav and IE will show they are at
    // *least* JS 1.x capable. Always check for JS version compatibility
    // with > or >=.
    else if (is_nav6up) is_js = 1.5;
    // NOTE: ie5up on mac is 1.4
    else if (is_ie5up) is_js = 1.3

    // HACK: no idea for other browsers; always check for JS version with > or >=
    else is_js = 0.0;

    // *** PLATFORM ***
    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.
    var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    var is_win16 = ((agt.indexOf("win16")!=-1) || 
               (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 
               (agt.indexOf("windows 16-bit")!=-1) );  

    var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                    (agt.indexOf("windows 16-bit")!=-1));

    var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
    var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".
    var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    var is_win32 = (is_win95 || is_winnt || is_win98 || 
                    ((is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

    var is_os2   = ((agt.indexOf("os/2")!=-1) || 
                    (navigator.appVersion.indexOf("OS/2")!=-1) ||   
                    (agt.indexOf("ibm-webexplorer")!=-1));

    var is_mac    = (agt.indexOf("mac")!=-1);
    // hack ie5 js version for mac
    if (is_mac && is_ie5up) is_js = 1.4;
    var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) || 
                               (agt.indexOf("68000")!=-1)));
    var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) || 
                                (agt.indexOf("powerpc")!=-1)));

    var is_sun   = (agt.indexOf("sunos")!=-1);
    var is_sun4  = (agt.indexOf("sunos 4")!=-1);
    var is_sun5  = (agt.indexOf("sunos 5")!=-1);
    var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));
    var is_irix  = (agt.indexOf("irix") !=-1);    // SGI
    var is_irix5 = (agt.indexOf("irix 5") !=-1);
    var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
    var is_hpux  = (agt.indexOf("hp-ux")!=-1);
    var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));
    var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));
    var is_aix   = (agt.indexOf("aix") !=-1);      // IBM
    var is_aix1  = (agt.indexOf("aix 1") !=-1);    
    var is_aix2  = (agt.indexOf("aix 2") !=-1);    
    var is_aix3  = (agt.indexOf("aix 3") !=-1);    
    var is_aix4  = (agt.indexOf("aix 4") !=-1);    
    var is_linux = (agt.indexOf("inux")!=-1);
    var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
    var is_unixware = (agt.indexOf("unix_system_v")!=-1); 
    var is_mpras    = (agt.indexOf("ncr")!=-1); 
    var is_reliant  = (agt.indexOf("reliantunix")!=-1);
    var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || 
           (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || 
           (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); 
    var is_sinix = (agt.indexOf("sinix")!=-1);
    var is_freebsd = (agt.indexOf("freebsd")!=-1);
    var is_bsd = (agt.indexOf("bsd")!=-1);
    var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux || 
                 is_sco ||is_unixware || is_mpras || is_reliant || 
                 is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

    var is_vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));

//***********END OF BROWSER CHECK


//*********Image click (Overview map page > main mappping) This functionality only works for IE and Opera
function gotoMainMap(e){

	//Get the current overview image.
	var cmdString = String(document.location.search);
	var theName = cmdString.substring(1,cmdString.length);		
		
	//Define the current overview.	
	for(i=0;i<nofInsets;i++){														
		if(theName.toUpperCase() == theinsetsmaps[i][0].toUpperCase()){
			var useIndex = i;
		}
	}
	
	var imageWidth = 400; 																		//Width of opening overview image in pixels
	var pixpermetre =  theinsetsmaps[useIndex][3] / imageWidth;
	var origTLY = theinsetsmaps[useIndex][2] + theinsetsmaps[useIndex][3];						//Make origin top left

	//Get user clicked location x,y (pixels).
	var theX = event.offsetX;			
	var theY =  event.offsetY;

	//Convert to real world metres.
	theX = Number(theX) * pixpermetre;	
	theY = Number(theY) * pixpermetre; 
	theX =  theinsetsmaps[useIndex][1] + theX;
	theY =  origTLY - theY;

	//Define if user has clicked in the map area
	var outSideX = "false";
	var outSideY = "false";
	
	if((theX >= theinsetsmaps[useIndex][6]) | (theX <= theinsetsmaps[useIndex][4])){
		outSideX = "true";		
	}
	if((theY >= theinsetsmaps[useIndex][7]) | (theY <= theinsetsmaps[useIndex][5])){
		outSideY = "true";
	}

	//Define the new map image to load in.
	if((outSideX == "true") | (outSideY == "true")){			
		//alert("outside the area")
	}
	else{
		var distx = theX - theinsetsmaps[useIndex][4];
		var disty = theY - theinsetsmaps[useIndex][5];
		
		var gridcnt = theinsetsmaps[useIndex][8];
  		var thecol = 1; 
		while (gridcnt < distx){
			thecol = thecol + 1;
			gridcnt = gridcnt + (theinsetsmaps[useIndex][8] - theinsetsmaps[useIndex][9]);
		}	
 
		var gridcnt = theinsetsmaps[useIndex][8];
  		var therow = 1;  
		while (gridcnt < disty){
			therow = therow + 1;
			gridcnt = gridcnt + (theinsetsmaps[useIndex][8] - theinsetsmaps[useIndex][9]);
		}			
		
		var theTileNo =  ((therow -1) * theinsetsmaps[useIndex][11]) + thecol;

		//Adjust the tile number to agree with the standard "###"
		if(theTileNo < 10){
			theTileNo = "00" + theTileNo;
		}
		else if(theTileNo < 100){
			theTileNo = "0" + theTileNo;
		}
		else{
			theTileNo = String(theTileNo);
		}

		var theNewHTML = "map_htm/" + theName + "/" + theName + "_" + theTileNo + ".htm";

		//Open the selected tile in same window
 		eval("parent.location='" + theNewHTML + "'");

	}
	
}

//*********Open the main mapping -centre image called from overview map page. This functionality only works for IE and Opera
function openMapAtCentre(theMap,source){
	var newMap;
	if(theMap.toLowerCase() == "wherwell"){
	  newMap = "map_htm/inset_55/inset_55_062.htm";
	}else if(theMap.toLowerCase() == "weyhill west"){
	  newMap = "map_htm/inset_53/inset_53_035.htm";
	}else if(theMap.toLowerCase() == "weyhill east"){
	  newMap = "map_htm/inset_54/inset_54_025.htm";
	}else if(theMap.toLowerCase() == "west wellow"){
	  newMap = "map_htm/inset_51/inset_51_077.htm";
	}else if(theMap.toLowerCase() == "west wellow east"){
	  newMap = "map_htm/inset_52/inset_52_032.htm";
	}else if(theMap.toLowerCase() == "west tytherley"){
	  newMap = "map_htm/inset_50/inset_50_040.htm";
	}else if(theMap.toLowerCase() == "west dean"){
	  newMap = "map_htm/inset_49/inset_49_018.htm";
	}else if(theMap.toLowerCase() == "over wallop"){
	  newMap = "map_htm/inset_48/inset_48_089.htm";
	}else if(theMap.toLowerCase() == "nether wallop"){
	  newMap = "map_htm/inset_47/inset_47_035.htm";
	}else if(theMap.toLowerCase() == "vernham dean"){
	  newMap = "map_htm/inset_46/inset_46_035.htm";
	}else if(theMap.toLowerCase() == "upton"){
	  newMap = "map_htm/inset_45/inset_45_031.htm";
	}else if(theMap.toLowerCase() == "up somborne"){
	  newMap = "map_htm/inset_44/inset_44_032.htm";
	}else if(theMap.toLowerCase() == "timsbury"){
	  newMap = "map_htm/inset_43/inset_43_025.htm";
	}else if(theMap.toLowerCase() == "stockbridge"){
	  newMap = "map_htm/inset_42/inset_42_063.htm";
	}else if(theMap.toLowerCase() == "shipton bellinger"){
	  newMap = "map_htm/inset_41/inset_41_035.htm";
	}else if(theMap.toLowerCase() == "romsey town centre"){
	  newMap = "map_htm/inset_40/inset_40_039.htm";
	}else if(theMap.toLowerCase() == "romsey and north baddesley and valley park"){
	  newMap = "map_htm/inset_39/inset_39_472.htm";
	}else if(theMap.toLowerCase() == "quarley"){
	  newMap = "map_htm/inset_38/inset_38_018.htm";
	}else if(theMap.toLowerCase() == "nursling and rownhams"){
	  newMap = "map_htm/inset_36/inset_36_153.htm";
	}else if(theMap.toLowerCase() == "newtown"){
	  newMap = "map_htm/inset_35/inset_35_054.htm";
	}else if(theMap.toLowerCase() == "mottisfont"){
	  newMap = "map_htm/inset_34/inset_34_018.htm";
	}else if(theMap.toLowerCase() == "monxton"){
	  newMap = "map_htm/inset_33/inset_33_063.htm";
	}else if(theMap.toLowerCase() == "michelmersh"){
	  newMap = "map_htm/inset_32/inset_32_038.htm";
	}else if(theMap.toLowerCase() == "longstock"){
	  newMap = "map_htm/inset_31/inset_31_039.htm";
	}else if(theMap.toLowerCase() == "longparish west"){
	  newMap = "map_htm/inset_30/inset_30_061.htm";
	}else if(theMap.toLowerCase() == "longparish east"){
	  newMap = "map_htm/inset_29/inset_29_093.htm";
	}else if(theMap.toLowerCase() == "lockerley"){
	  newMap = "map_htm/inset_28/inset_28_051.htm";
	}else if(theMap.toLowerCase() == "leckford"){
	  newMap = "map_htm/inset_27/inset_27_038.htm";
	}else if(theMap.toLowerCase() == "kings somborne"){
	  newMap = "map_htm/inset_26/inset_26_077.htm";
	}else if(theMap.toLowerCase() == "kimpton"){
	  newMap = "map_htm/inset_25/inset_25_026.htm";
	}else if(theMap.toLowerCase() == "hurstbourne tarrant and ibthorpe"){
	  newMap = "map_htm/inset_24/inset_24_050.htm";
	}else if(theMap.toLowerCase() == "houghton south"){
	  newMap = "map_htm/inset_23/inset_23_092.htm";
	}else if(theMap.toLowerCase() == "houghton north"){
	  newMap = "map_htm/inset_22/inset_22_032.htm";
	}else if(theMap.toLowerCase() == "hatherden and wildhern"){
	  newMap = "map_htm/inset_21/inset_21_095.htm";
	}else if(theMap.toLowerCase() == "grateley"){
	  newMap = "map_htm/inset_19/inset_19_032.htm";
	}else if(theMap.toLowerCase() == "grateley station and palestine"){
	  newMap = "map_htm/inset_20/inset_20_076.htm";
	}else if(theMap.toLowerCase() == "goodworth clatford"){
	  newMap = "map_htm/inset_18/inset_18_074.htm";
	}else if(theMap.toLowerCase() == "fyfield and thruxton"){
	  newMap = "map_htm/inset_17/inset_17_096.htm";
	}else if(theMap.toLowerCase() == "enham alamein, little london and smannell"){
	  newMap = "map_htm/inset_16/inset_16_012.htm";
	}else if(theMap.toLowerCase() == "east cholderton"){
	  newMap = "map_htm/inset_15/inset_15_038.htm";
	}else if(theMap.toLowerCase() == "dunbridge"){
	  newMap = "map_htm/inset_14/inset_14_032.htm";
	}else if(theMap.toLowerCase() == "chilworth"){
	  newMap = "map_htm/inset_13/inset_13_306.htm";
	}else if(theMap.toLowerCase() == "chilbolton"){
	  newMap = "map_htm/inset_12/inset_12_063.htm";
	}else if(theMap.toLowerCase() == "broughton"){
	  newMap = "map_htm/inset_11/inset_11_073.htm";
	}else if(theMap.toLowerCase() == "braishfield"){
	  newMap = "map_htm/inset_10/inset_10_094.htm";
	}else if(theMap.toLowerCase() == "barton stacey"){
	  newMap = "map_htm/inset_09/inset_09_062.htm";
	}else if(theMap.toLowerCase() == "awbridge"){
	  newMap = "map_htm/inset_08/inset_08_075.htm";
	}else if(theMap.toLowerCase() == "appleshaw"){
	  newMap = "map_htm/inset_07/inset_07_055.htm";
	}else if(theMap.toLowerCase() == "anna valley and upper clatford"){
	  newMap = "map_htm/inset_06/inset_06_092.htm";
	}else if(theMap.toLowerCase() == "andover town centre"){
	  newMap = "map_htm/inset_05/inset_05_027.htm";
	}else if(theMap.toLowerCase() == "andover"){
	  newMap = "map_htm/inset_04/inset_04_517.htm";
	}else if(theMap.toLowerCase() == "amport"){
	  newMap = "map_htm/inset_03/inset_03_076.htm";
	}else if(theMap.toLowerCase() == "ampfield"){
	  newMap = "map_htm/inset_02/inset_02_034.htm";
	}else if(theMap.toLowerCase() == "abbotts ann and anna valley"){
	  newMap = "map_htm/inset_01/inset_01_060.htm";
	}else if(theMap.toLowerCase() == "penton grafton and penton mewsey"){
	  newMap = "map_htm/inset_37/inset_37_032.htm";
	}else if(theMap.toLowerCase() == "proposals map"){
	  newMap = "map_htm/inset_56/inset_56_195.htm";
	}else{
	  newMap = "";
	}
	
	//Go to map location
	if(newMap != ""){
	  if(source == "propmap"){
				  newMap = "../../" + newMap;
	  }
	  eval("parent.location='" + newMap + "'");
	}
}
//^^^Insert pre- generated code above ^^^


//*********Image click (Proposals Maps map > overview map ) This functionality only works for IE and Opera
function openOverview(e){

	//Set-up
	var imageWidth = 400; 								//Width of main overview image in pixels
	var imageHeight = 400; 								//Width of main overview image in pixels

	var tileWidth = 47500; 								//Width of main overview image in metres
	var tileHeight = 47500;								//Width of main overview image in metres

	var pixpermetreX =  tileWidth /imageWidth;
	var pixpermetreY =  tileHeight /imageHeight;

	var tileOriginX = 411250;							//Origin of main overview image in ground metres
	var tileOriginY = 113150;	
	
	tileOriginY = tileOriginY + tileHeight; 			//Make origin top left

	//Get user clicked location x,y (pixels).
	var theX = event.offsetX			
	var theY = event.offsetY

	//Convert to real world metres.
	theX = Number(theX) * pixpermetreX;	
	theY = Number(theY) * pixpermetreY; 
	theX =  tileOriginX + theX;
	theY =  tileOriginY - theY;
	
	//Check if the user clicked in an inset map area.		
	for(i=0;i<nofInsets;i++){
		
		//Define extent of each inset map area
		ovblx = theinsetsmaps[i][4]; 
		ovbly = theinsetsmaps[i][5]; 
		ovtrx = theinsetsmaps[i][6];
		ovtry = theinsetsmaps[i][7];
		var outSideX = "false";
		var outSideY = "false";
				
		if((theX >= ovtrx) | (theX <= ovblx)){
			outSideX = "true";		
		}
		if((theY >= ovtry) | (theY <= ovbly)){
			outSideY = "true";
		}

		if((outSideX == "false") & (outSideY == "false")){			//User has clicked within an inset map						
			var distx = theX - ovblx;
			var disty = theY - ovbly;
			
			var gridcnt = theinsetsmaps[i][8];
			var thecol = 1;
			while (gridcnt < distx){
				thecol = thecol + 1;
				gridcnt = gridcnt + (theinsetsmaps[i][8] - theinsetsmaps[i][9]);  
			}	
	 
			var gridcnt = theinsetsmaps[i][8];
			var therow = 1;  
			while (gridcnt < disty){
				therow = therow + 1;
				gridcnt = gridcnt + (theinsetsmaps[i][8] - theinsetsmaps[i][9]);  
			}			
			
			var theTileNo =  ((therow -1) * theinsetsmaps[i][11]) + thecol;

			//Adjust the tile number to agree with the standard "###"
			if(theTileNo < 10){
				theTileNo = "00" + theTileNo;
			}
			else if(theTileNo < 100){
				theTileNo = "0" + theTileNo;
			}
			else{
				theTileNo = String(theTileNo);
			}				

			theURL = "map_opening.htm?" + theinsetsmaps[i][0];
						
			//Open the selected tile in same window 
			eval("parent.location='" + theURL + "'");				
			break;																	//Quit the loop as the inset map has been found.
		}
	
	}		
}

//*********Define the Browser window title to = map/inset name.
//vvv Insert pre- generated code below (js_definemaptitle.txt) vvv
function defineMapTitle(theMapNo){
	if(theMapNo.toLowerCase() == "inset_55"){
	  theTitle = "Wherwell";
	}else if(theMapNo.toLowerCase() == "inset_53"){
	  theTitle = "Weyhill west";
	}else if(theMapNo.toLowerCase() == "inset_54"){
	  theTitle = "Weyhill east";
	}else if(theMapNo.toLowerCase() == "inset_51"){
	  theTitle = "West Wellow";
	}else if(theMapNo.toLowerCase() == "inset_52"){
	  theTitle = "West Wellow east";
	}else if(theMapNo.toLowerCase() == "inset_50"){
	  theTitle = "West Tytherley";
	}else if(theMapNo.toLowerCase() == "inset_49"){
	  theTitle = "West Dean";
	}else if(theMapNo.toLowerCase() == "inset_48"){
	  theTitle = "Over Wallop";
	}else if(theMapNo.toLowerCase() == "inset_47"){
	  theTitle = "Nether Wallop";
	}else if(theMapNo.toLowerCase() == "inset_46"){
	  theTitle = "Vernham Dean";
	}else if(theMapNo.toLowerCase() == "inset_45"){
	  theTitle = "Upton";
	}else if(theMapNo.toLowerCase() == "inset_44"){
	  theTitle = "Up Somborne";
	}else if(theMapNo.toLowerCase() == "inset_43"){
	  theTitle = "Timsbury";
	}else if(theMapNo.toLowerCase() == "inset_42"){
	  theTitle = "Stockbridge";
	}else if(theMapNo.toLowerCase() == "inset_41"){
	  theTitle = "Shipton Bellinger";
	}else if(theMapNo.toLowerCase() == "inset_40"){
	  theTitle = "Romsey Town Centre";
	}else if(theMapNo.toLowerCase() == "inset_39"){
	  theTitle = "Romsey and North Baddesley and Valley Park";
	}else if(theMapNo.toLowerCase() == "inset_38"){
	  theTitle = "Quarley";
	}else if(theMapNo.toLowerCase() == "inset_36"){
	  theTitle = "Nursling and Rownhams";
	}else if(theMapNo.toLowerCase() == "inset_35"){
	  theTitle = "Newtown";
	}else if(theMapNo.toLowerCase() == "inset_34"){
	  theTitle = "Mottisfont";
	}else if(theMapNo.toLowerCase() == "inset_33"){
	  theTitle = "Monxton";
	}else if(theMapNo.toLowerCase() == "inset_32"){
	  theTitle = "Michelmersh";
	}else if(theMapNo.toLowerCase() == "inset_31"){
	  theTitle = "Longstock";
	}else if(theMapNo.toLowerCase() == "inset_30"){
	  theTitle = "Longparish west";
	}else if(theMapNo.toLowerCase() == "inset_29"){
	  theTitle = "Longparish east";
	}else if(theMapNo.toLowerCase() == "inset_28"){
	  theTitle = "Lockerley";
	}else if(theMapNo.toLowerCase() == "inset_27"){
	  theTitle = "Leckford";
	}else if(theMapNo.toLowerCase() == "inset_26"){
	  theTitle = "King's Somborne";
	}else if(theMapNo.toLowerCase() == "inset_25"){
	  theTitle = "Kimpton";
	}else if(theMapNo.toLowerCase() == "inset_24"){
	  theTitle = "Hurstbourne Tarrant and Ibthorpe";
	}else if(theMapNo.toLowerCase() == "inset_23"){
	  theTitle = "Houghton south";
	}else if(theMapNo.toLowerCase() == "inset_22"){
	  theTitle = "Houghton north";
	}else if(theMapNo.toLowerCase() == "inset_21"){
	  theTitle = "Hatherden and Wildhern";
	}else if(theMapNo.toLowerCase() == "inset_19"){
	  theTitle = "Grateley";
	}else if(theMapNo.toLowerCase() == "inset_20"){
	  theTitle = "Grateley Station and Palestine";
	}else if(theMapNo.toLowerCase() == "inset_18"){
	  theTitle = "Goodworth Clatford";
	}else if(theMapNo.toLowerCase() == "inset_17"){
	  theTitle = "Fyfield and Thruxton";
	}else if(theMapNo.toLowerCase() == "inset_16"){
	  theTitle = "Enham Alamein, Little London and Smannell";
	}else if(theMapNo.toLowerCase() == "inset_15"){
	  theTitle = "East Cholderton";
	}else if(theMapNo.toLowerCase() == "inset_14"){
	  theTitle = "Dunbridge";
	}else if(theMapNo.toLowerCase() == "inset_13"){
	  theTitle = "Chilworth";
	}else if(theMapNo.toLowerCase() == "inset_12"){
	  theTitle = "Chilbolton";
	}else if(theMapNo.toLowerCase() == "inset_11"){
	  theTitle = "Broughton";
	}else if(theMapNo.toLowerCase() == "inset_10"){
	  theTitle = "Braishfield";
	}else if(theMapNo.toLowerCase() == "inset_09"){
	  theTitle = "Barton Stacey";
	}else if(theMapNo.toLowerCase() == "inset_08"){
	  theTitle = "Awbridge";
	}else if(theMapNo.toLowerCase() == "inset_07"){
	  theTitle = "Appleshaw";
	}else if(theMapNo.toLowerCase() == "inset_06"){
	  theTitle = "Anna Valley and Upper Clatford";
	}else if(theMapNo.toLowerCase() == "inset_05"){
	  theTitle = "Andover Town Centre";
	}else if(theMapNo.toLowerCase() == "inset_04"){
	  theTitle = "Andover";
	}else if(theMapNo.toLowerCase() == "inset_03"){
	  theTitle = "Amport";
	}else if(theMapNo.toLowerCase() == "inset_02"){
	  theTitle = "Ampfield";
	}else if(theMapNo.toLowerCase() == "inset_01"){
	  theTitle = "Abbotts Ann and Anna Valley";
	}else if(theMapNo.toLowerCase() == "inset_37"){
	  theTitle = "Penton Grafton and Penton Mewsey";
	}else if(theMapNo.toLowerCase() == "inset_56"){
	  theTitle = "Proposals Map";
	}else{
		theTitle = "";
	}
	return theTitle;
}

//^^^Insert pre- generated code above ^^^

//********Get the attribute and open the written doc in new window or open a list of policies (called on main map click/keypress).
function getatt(thePolRef,theDoc){

	if(theDoc.indexOf("inset") != -1){								//*****User has clicked on Inset hotpot -open the new inset map
		openMapAtCentre(thePolRef,'propmap');	
	}
	else if(thePolRef != ""){										//*****User has clicked on policy hotpot - open policy list or written statement
		var comm = thePolRef.indexOf(",");
		if(comm == -1){												//Only one policy selected - Open written statement
		
			//Remove any specifics eg (1) etc. from the policy reference.
			var test = thePolRef.indexOf(" ");
			if(test != -1){
				var newPolRef = thePolRef.substring(0,test);
				thePolRef = newPolRef;
			}			
			theURL = "../../written/cpt" + theDoc + ".htm#" + thePolRef.toLowerCase();	
			winName =  "Written";  
			features = "menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes,width=800,height=500";
			window.open(theURL,winName,features);
		}
		else														//More than one policy selected - Open the policy list
		{
			polIndex(thePolRef,theDoc);
		}
	}		
}	


//*********Opens index of policies realating to selected site the user has clicked on.
function polIndex(thePolRef,theDoc){
	var distFromTop = self.screenTop;
	var distFromLeft = self.screenLeft;
	var xPos = distFromLeft + 480;
	var yPos = distFromTop + 100;

	//Open in new window;																	
	theURL = "../../pol_index.htm?" + thePolRef + "&" + theDoc;	
	winName = "thePolIndex";
	features = "menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes,width=500,height=500,left=" + xPos + ",top=" + yPos;;
	var theWin = window.open(theURL,winName,features);
	theWin.focus();									//Ensure map window is visible on top		
}


//*******************Function to remove the space code %20 and ampersand code %38
function removePercentCode(theTitle){
	//Remove space code '%20'
	var newstring = "";																	
	var pos = theTitle.indexOf("%20");
	
	if(pos != -1){
		newstring = newstring + theTitle.substring(0,pos) + " "	;
		test = theTitle.substring((pos+3),theTitle.length);	
		pos = test.indexOf("%20");
	
		while (pos != -1){
			newstring = newstring + test.substring(0,pos) + " ";
			test = test.substring((pos+3),test.length);	
			pos = test.indexOf("%20");
		}
		
		newstring = newstring + test.substring(0,test.length);
	}
	else{
		newstring = theTitle;
	}

	//Remove ampersand code '%38'
	var newstring2 = "";																	
	var pos = newstring.indexOf("%38");
	
	if(pos != -1){
		newstring2 = newstring2 + newstring.substring(0,pos) + "&";	
		test = newstring.substring((pos+3),newstring.length);	
		pos = test.indexOf("%38");
	
		while (pos != -1){
			newstring2 = newstring2 + test.substring(0,pos) + "&";
			test = test.substring((pos+3),test.length);	
			pos = test.indexOf("%38");
		}
		
		newstring2 = newstring2 + test.substring(0,test.length);
	}
	else{
		newstring2 = newstring;
	}

	//Remove trailing and leading spaces.
	if(newstring2.indexOf(" ") == 0){
		newstring3 = newstring2.substring(1,newstring2.length);
	}
	else{
		newstring3 = newstring2;
	}
	if(newstring3.indexOf(" ") == (newstring3.length -1)){
		newstring4 = newstring3.substring(0,(newstring3.length-1));
	}
	else{
		newstring4 = newstring3;
	}
	
	return(newstring4);

}	

//*******************Function to remove any quotes from strings
function removeQuote(theTitle){

	//Remove space code '%20'
	var newstring = "";																	
	var pos = theTitle.indexOf("'");
	
	if(pos != -1){
		newstring = newstring + theTitle.substring(0,pos);
		test = theTitle.substring((pos+1),theTitle.length);	
		pos = test.indexOf("'");
	
		while (pos != -1){
			newstring = newstring + test.substring(0,pos);
			test = test.substring((pos+1),test.length);	
			pos = test.indexOf("'");
		}
		
		newstring = newstring + test.substring(0,test.length);
	}
	else{
		newstring = theTitle;
	}
	return(newstring);

}

//*******************Replaces the policy ref number with the policy name (Used when printed to the policy index page pol_index.htm)
//vvv Insert pre- generated code below (js_getpolicyname.txt) vvv
function getPolicyName(polNum){
	if(polNum == "AND01.1"){
	  thePolName = "New Community East of Icknield Way";
	}
	else if(polNum == "AND01.2"){
	  thePolName = "Landscape Features East of Icknield Way";
	}
	else if(polNum == "AND01.3"){
	  thePolName = "Recreational Facilities East of Icknield Way";
	}
	else if(polNum == "AND01.4"){
	  thePolName = "Community Facilities East of Icknield Way";
	}
	else if(polNum == "AND01.5"){
	  thePolName = "On-site Transport Measures East of Icknield Way";
	}
	else if(polNum == "AND01.6"){
	  thePolName = "Off-site Transport Measures East of Icknield Way";
	}
	else if(polNum == "AND02.1"){
	  thePolName = "New Community at Picket Twenty";
	}
	else if(polNum == "AND02.2"){
	  thePolName = "Landscape Features at Picket Twenty";
	}
	else if(polNum == "AND02.3"){
	  thePolName = "Recreational Facilities at Picket Twenty";
	}
	else if(polNum == "AND02.4"){
	  thePolName = "Community Facilities at Picket Twenty";
	}
	else if(polNum == "AND02.5"){
	  thePolName = "On-site Transport Measures at Picket Twenty";
	}
	else if(polNum == "AND02.6"){
	  thePolName = "Off-site Transport Measures at Picket Twenty";
	}
	else if(polNum == "AND03.1"){
	  thePolName = "Extension to Walworth Estate";
	}
	else if(polNum == "AND03.2"){
	  thePolName = "Landscape Features at Walworth Estate";
	}
	else if(polNum == "AND03.3"){
	  thePolName = "On-site Transport Measures at Walworth Estate";
	}
	else if(polNum == "AND03.4"){
	  thePolName = "Off-site Transport Measures at Walworth Estate";
	}
	else if(polNum == "AND04.1"){
	  thePolName = "Employment Land at Andover Business Park";
	}
	else if(polNum == "AND04.2"){
	  thePolName = "New Landscape Features at Andover Business Park";
	}
	else if(polNum == "AND04.3"){
	  thePolName = "On-site Transport Measures at Andover Business Park";
	}
	else if(polNum == "AND04.4"){
	  thePolName = "Off-site Transport Measures at Andover Business Park";
	}
	else if(polNum == "AND05.1"){
	  thePolName = "New Recreation Ground at London Road";
	}
	else if(polNum == "AND05.2"){
	  thePolName = "New Landscape Features at London Road";
	}
	else if(polNum == "AND05.3"){
	  thePolName = "On-site Transport Measures at London Road";
	}
	else if(polNum == "AND05.4"){
	  thePolName = "Off-site Transport Measures at London Road";
	}
	else if(polNum == "AND06.1"){
	  thePolName = "Open Space at Ladies Walk";
	}
	else if(polNum == "AND07.1"){
	  thePolName = "Ground Floor Uses in the Andover Town Centre Shopping Areas";
	}
	else if(polNum == "AND07.2"){
	  thePolName = "Ground Floor Uses in the Andover Primary Shopping Areas";
	}
	else if(polNum == "AND07.3"){
	  thePolName = "Chantry Centre Extension";
	}
	else if(polNum == "AND07.4"){
	  thePolName = "Off-site Transport Measures at Chantry Street";
	}
	else if(polNum == "AND07.5"){
	  thePolName = "Andover Bus Station";
	}
	else if(polNum == "AND07.6a"){
	  thePolName = "Off Site Transport Measures at West Street";
	}
	else if(polNum == "AND08.1"){
	  thePolName = "Riverside Walk Adjoining the River Anton";
	}
	else if(polNum == "ESN16"){
	  thePolName = "Employment Development within Settlements";
	}
	else if(polNum == "ESN17"){
	  thePolName = "Major Retail Development and Other Key Town Centre Uses";
	}
	else if(polNum == "ENV02"){
	  thePolName = "Internationally Important Wildlife Sites";
	}
	else if(polNum == "ENV03"){
	  thePolName = "Sites of Special Scientific Interest";
	}
	else if(polNum == "ENV04"){
	  thePolName = "Sites of Importance for Nature Conservation";
	}
	else if(polNum == "ENV06"){
	  thePolName = "New Forest National Park";
	}
	else if(polNum == "ENV07"){
	  thePolName = "North Wessex Downs Area of Outstanding Natural Beauty";
	}
	else if(polNum == "ENV14"){
	  thePolName = "Demolition in Conservation Areas";
	}
	else if(polNum == "ENV15"){
	  thePolName = "Development in Conservation Areas";
	}
	else if(polNum == "ENV16"){
	  thePolName = "Registered Historic Parks and Gardens";
	}
	else if(polNum == "SET01"){
	  thePolName = "Housing within Settlements";
	}
	else if(polNum == "SET02"){
	  thePolName = "Residential Areas of Special Character";
	}
	else if(polNum == "SET03"){
	  thePolName = "Development in the Countryside";
	}
	else if(polNum == "SET04"){
	  thePolName = "Strategic Gaps";
	}
	else if(polNum == "SET05"){
	  thePolName = "Local Gaps";
	}
	else if(polNum == "SET06"){
	  thePolName = "Frontage Infill Policy Areas in the Countryside";
	}
	else if(polNum == "STV01.1"){
	  thePolName = "University of Southampton Science Park Policy Area";
	}
	else if(polNum == "STV02.1"){
	  thePolName = "Housing at the Former Bordens / AEP Site";
	}
	else if(polNum == "STV02.2"){
	  thePolName = "Landscape Features at the Former Bordens / AEP Site";
	}
	else if(polNum == "STV02.3"){
	  thePolName = "Recreational Facilities at the Former Bordens / AEP Site";
	}
	else if(polNum == "STV02.4"){
	  thePolName = "On-site Transport Measures at the Former Bordens / AEP Site";
	}
	else if(polNum == "STV02.5"){
	  thePolName = "Off-site Transport Measures at the Former Bordens / AEP Site";
	}
	else if(polNum == "STV03.1"){
	  thePolName = "Safeguarded Employment Land at Adanac Park";
	}
	else if(polNum == "STV03.2"){
	  thePolName = "Landscape Features at Adanac Park";
	}
	else if(polNum == "STV03.3"){
	  thePolName = "On-site Transport Measures at Adanac Park";
	}
	else if(polNum == "STV03.4"){
	  thePolName = "Off-site Transport Measures at Adanac Park";
	}
	else if(polNum == "STV04.1"){
	  thePolName = "Safeguarded Site for a Park and Ride Facility at Junction 1 of the M271";
	}
	else if(polNum == "STV05.1"){
	  thePolName = "Retention of Storage and Distribution Uses at Nursling Estate";
	}
	else if(polNum == "STV05.2"){
	  thePolName = "Storage and Distribution Uses at Dairy Lane";
	}
	else if(polNum == "STV05.3"){
	  thePolName = "Recreation at Abbottswood";
	}
	else if(polNum == "STV06.1"){
	  thePolName = "Housing at Romsey Brewery";
	}
	else if(polNum == "STV06.2"){
	  thePolName = "Landscape Features at Romsey Brewery";
	}
	else if(polNum == "STV06.3"){
	  thePolName = "Recreation Facilities at Romsey Brewery";
	}
	else if(polNum == "STV06.4"){
	  thePolName = "On-site Transport Measures at Romsey Brewery";
	}
	else if(polNum == "STV06.5"){
	  thePolName = "Off-site Transport Measures at Romsey Brewery";
	}
	else if(polNum == "STV07.1"){
	  thePolName = "Reserve Housing Site at Abbottswood";
	}
	else if(polNum == "STV07.2"){
	  thePolName = "Landscape Features at Abbottswood";
	}
	else if(polNum == "STV07.3"){
	  thePolName = "Nature Conservation at Abbottswood";
	}
	else if(polNum == "STV07.5"){
	  thePolName = "On-site Transport Measures at Abbottswood";
	}
	else if(polNum == "STV07.6"){
	  thePolName = "Off Site Transport Measures at Abbottswood";
	}
	else if(polNum == "STV08.1"){
	  thePolName = "Ground Floor Uses in the Romsey Town Centre Shopping Areas";
	}
	else if(polNum == "STV08.2"){
	  thePolName = "Ground Floor Uses in the Romsey Primary Shopping Areas";
	}
	else if(polNum == "STV09.1"){
	  thePolName = "Sports Pitches at Ganger Farm";
	}
	else if(polNum == "STV09.4"){
	  thePolName = "On-site Transport Measures at Ganger Farm";
	}
	else if(polNum == "STV09.5"){
	  thePolName = "Off-site Transport Measures at Ganger Farm";
	}
	else{
	  thePolName = "";
	}
	
	return(thePolName);

}
//^^^Insert pre- generated code above ^^^

//**********Updates the main map by clicking the region overview map. This functionality only works for IE and Opera
function updatemap1(e){

	//Set-up
	var imageWidth = 200; 								//Width of main overview image in pixels
	var tileWidth = 47500; 								//Width of main overview image in metres
	var pixpermetre =  tileWidth /imageWidth;
	var tileOriginX = 411250;							//Origin of main overview image in ground metres
	var tileOriginY = 113150;		
		
	tileOriginY = tileOriginY + tileWidth; 				//Make origin top left

	//Get user clicked location x,y (pixels).
	var theX = event.offsetX;			
	var theY = event.offsetY;
	
	//Convert to real world metres.
	theX = Number(theX) * pixpermetre;	
	theY = Number(theY) * pixpermetre;  
	theX = tileOriginX + theX;
	theY = tileOriginY - theY;
	
	//Check if the user clicked in an inset map area.		
	for(i=0;i<nofInsets;i++){		
		//Define extent of each inset map area
		ovblx = theinsetsmaps[i][4]; 
		ovbly = theinsetsmaps[i][5]; 
		ovtrx = theinsetsmaps[i][6]; 
		ovtry = theinsetsmaps[i][7];
		var outSideX = "false";
		var outSideY = "false";
				
		if((theX >= ovtrx) | (theX <= ovblx)){
			outSideX = "true";		
		}
		if((theY >= ovtry) | (theY <= ovbly)){
			outSideY = "true";
		}

		if((outSideX == "false") & (outSideY == "false")){			//User has clicked within an inset map						
			var distx = theX - ovblx;
			var disty = theY - ovbly;
			
			var gridcnt = theinsetsmaps[i][8];
			var thecol = 1; 
			while (gridcnt < distx){
				thecol = thecol + 1;
				gridcnt = gridcnt + (theinsetsmaps[i][8] - theinsetsmaps[i][9]);  
			}	
	 
			var gridcnt = theinsetsmaps[i][8];
			var therow = 1;  
			while (gridcnt < disty){
				therow = therow + 1;
				gridcnt = gridcnt + (theinsetsmaps[i][8] - theinsetsmaps[i][9]);  
			}			
			
			var theTileNo =  ((therow -1) * theinsetsmaps[i][11]) + thecol;

			//Adjust the tile number to agree with the standard "###"
			if(theTileNo < 10){
				theTileNo = "00" + theTileNo;
			}
			else if(theTileNo < 100){
				theTileNo = "0" + theTileNo;
			}
			else{
				theTileNo = String(theTileNo);
			}

			//Update main map frame
			var newloc = "../../map_htm/" + theinsetsmaps[i][0] + "/" + theinsetsmaps[i][0] + "_" + theTileNo + ".htm";		
			parent.window.location = newloc;	
			break;																	//Quit the loop as the inset map has nbeen found.
		}
	
	}

}

//**********Updates the main map by clicking the inset overview map. This functionality only works for IE and Opera
function updatemap2(e){

	//Get the current overview image.
	var cmdString = String(parent.document.location);
	
	var theSep;
	for (n=0;n<cmdString.length; n++){
		var teststring = cmdString.substring(n,(n + 1));
		if(teststring == "/"){
			theSep = n;
		}
	}
	var tempstring = cmdString.substring((theSep +1),(cmdString.length));
	for (n=0;n<tempstring.length; n++){
		var teststring =  tempstring.substring(n,(n + 1));
		if(teststring == "_"){
			theSep = n;
		}
	}	
	var theName = tempstring.substring(0,theSep);		
		
	//Define the current overview.	
	for(i=0;i<nofInsets;i++){
		if(theName.toUpperCase() == theinsetsmaps[i][0].toUpperCase()){
			var useIndex = i;
		}
	}
	
	var imageWidth = 200 ;																		//Width of inset overview image in pixels
	var pixpermetre =  theinsetsmaps[useIndex][3] / imageWidth;
	var origTLY  = theinsetsmaps[useIndex][2] + theinsetsmaps[useIndex][3];		//Make origin top left

	//Get user clicked location x,y (pixels).
	var theX = event.offsetX;			
	var theY =  event.offsetY;

	//Convert to real world metres.
	theX = Number(theX) * pixpermetre;	
	theY = Number(theY) * pixpermetre ;  
	theX =  theinsetsmaps[useIndex][1] + theX;
	theY =  origTLY - theY;

	//Define if user has clicked in the map area
	var outSideX = "false";
	var outSideY = "false";
	
	if((theX >= theinsetsmaps[useIndex][6]) | (theX <= theinsetsmaps[useIndex][4])){
		outSideX = "true";		
	}
	if((theY >= theinsetsmaps[useIndex][7]) | (theY <= theinsetsmaps[useIndex][5])){
		outSideY = "true";
	}

	//Define the new map image to load in.
	if((outSideX == "true") | (outSideY == "true")){			
		//alert("outside the area")
	}
	else{
		var distx = theX - theinsetsmaps[useIndex][4];
		var disty = theY - theinsetsmaps[useIndex][5];
		
		var gridcnt = theinsetsmaps[useIndex][8];
  		var thecol = 1; 
		while (gridcnt < distx){
			thecol = thecol + 1;
			gridcnt = gridcnt + (theinsetsmaps[useIndex][8] - theinsetsmaps[useIndex][9]);  
		}	
 
		var gridcnt = theinsetsmaps[useIndex][8];
  		var therow = 1; 
		while (gridcnt < disty){
			therow = therow + 1;
			gridcnt = gridcnt + (theinsetsmaps[useIndex][8] - theinsetsmaps[useIndex][9]);  
		}			
		
		var theTileNo =  ((therow -1) * theinsetsmaps[useIndex][11]) + thecol;

		//Adjust the tile number to agree with the standard "###"
		if(theTileNo < 10){
			theTileNo = "00" + theTileNo;
		}
		else if(theTileNo < 100){
			theTileNo = "0" + theTileNo;
		}
		else{
			theTileNo = String(theTileNo);
		}
		
		//Update main map frame
		var newloc =  theName + "_" + theTileNo + ".htm"; 
		parent.window.location = newloc;

	}	
}

//*********Opens mapping from the Proposals Maps
function openMap(selObj,theSource){ 
	//Get the inset number
	if (theSource == 1){
		var inString = selObj.options[selObj.selectedIndex].value;
	}
	else{
		var inString = selObj;
	}
	
	//Get the inset number
	var sep = inString.indexOf("_");
	var string1 = inString.substring(0,(sep+1));
	var string2 = inString.substring((sep+1),inString.length);
	var sep2 = string2.indexOf("_");
	if(sep2 != -1){
		var insetNo = string1 + string2.substring(0,sep2);
	}else{
		var insetNo = string1.substring(0,(string1.length -1));
	}

	//If using IE or opera open intermediate window for the user to select exact map location
	if(((is_ie == true) && (is_ie5up == true))|| ((is_opera == true) && (is_opera5up == true))){				//IE or Opera open overview mapping
		var mapLoc = "map_opening.htm?" + insetNo;				 
	}else{
		var mapLoc = "map_htm/" + insetNo + "/" + inString + ".htm";
	}

	//Open in current window
 	eval("parent.location='" + mapLoc + "'");

  	if (theSource == 1){
		selObj.selectedIndex=0;
	}
}

//*******************************Defines the map to load from the postcode search.
function getSelectedPC(selObj){
	//Passed tile location.
	var tileLoc = selObj.options[selObj.selectedIndex].value;
	
	if(tileLoc != "#"){
			
		//Get the inset number
		var sep = tileLoc.indexOf("_");
		var string1 = tileLoc.substring(0,(sep+1));
		var string2 = tileLoc.substring((sep+1),tileLoc.length);
		var sep2 = string2.indexOf("_");
		if(sep2 != -1){
			var insetNo = string1 + string2.substring(0,sep2);
		}else{
			var insetNo = string1.substring(0,(string1.length -1));
		}
	
		//Get the path of the selected tile
		var mapLoc = "map_htm/" + insetNo + "/" + tileLoc + ".htm";
	
		//Open in current window
		eval("parent.location='" + mapLoc + "'");
	}									
}

//******************************Opens a map from a link on the written statement
function goToMapLoc(theMapRef){
	 if(theMapRef != ""){	
		var comm = theMapRef.indexOf(",");
		if(comm == -1){												//Only one location go straight to the map.						
			//Get the inset number
			var sep = theMapRef.indexOf("_");
			var string1 = theMapRef.substring(0,(sep+1));
			var string2 = theMapRef.substring((sep+1),theMapRef.length);
			var sep2 = string2.indexOf("_");
			if(sep2 != -1){
				var insetNo = string1 + string2.substring(0,sep2);
			}
			else{
				var insetNo = string1.substring(0,(string1.length -1));
			}
			
			var mapLoc = "../map_htm/" + insetNo + "/" + theMapRef + ".htm";
			    	     
			//Open in current window
 			eval("parent.location='" + mapLoc + "'");
		}else{														//More than one location open intermediate window for user to choose.
			var theURL = "../loc_index.htm?" + theMapRef ;	
 			eval("parent.location='" + theURL + "'");
		}
	}		
}

//******************************Opens a driagram window from the written statement
function openDiagram(theMapRef){
	//Open in new window;
	theURL = "diag.htm?" + theMapRef;	
	winName = "Diagram";
	features = "toolbar=no,scrollbars=yes,resizable=yes,width=500,height=500";
	window.open(theURL,winName,features);		
}

//******************************Opens a legend window in a new window over the mapping
function openLegend(theLegend){
	var distFromTop = self.screenTop;
	var distFromLeft = self.screenLeft;
	var xPos = distFromLeft + 480;
	var yPos = distFromTop;

	//Open in new window;
	theURL = "../../" + theLegend + ".htm";	
	winName = "Diagram";
	features = "toolbar=no,scrollbars=yes,resizable=yes,width=450,height=800,left=" + xPos + ",top=" + yPos;
	var theWin = window.open(theURL,winName,features);
	theWin.focus();									//Ensure map window is visible on top	
}

/*
***********END of Script
*/