/*
* **************************************************************************
lp.js
Interactive Local Plan
East Hampshire District Council
Ver 1.0
Lovell Johns Ltd.
08/04
****************************************************************************
*/

//*********************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 (43)
var nofInsets = 43;
theinsetsmaps[0] = new Array("inset_01",469127,136839,5798,469100,137700,475200,141800,500,100,10,15);
theinsetsmaps[1] = new Array("inset_02",468270,137888,1410,468200,138100,469900,139400,500,100,3,4);
theinsetsmaps[2] = new Array("inset_03",477475,143023,1975,477400,143300,479500,145000,500,100,4,5);
theinsetsmaps[3] = new Array("inset_04",478465,142193,1405,478400,142400,480100,143700,500,100,3,4);
theinsetsmaps[4] = new Array("inset_05",465920,139583,1395,465900,139800,467600,141100,500,100,3,4);
theinsetsmaps[5] = new Array("inset_06",477629,133055,717,477700,133000,478400,133900,300,100,4,3);
theinsetsmaps[6] = new Array("inset_07",476780,140285,1405,476700,140500,478400,141800,500,100,3,4);
theinsetsmaps[7] = new Array("inset_08",480283,141440,715,480400,141400,480900,142300,300,100,4,2);
theinsetsmaps[8] = new Array("inset_09",474255,137406,1405,474200,137600,475900,138900,500,100,3,4);
theinsetsmaps[9] = new Array("inset_10",464995,132955,4115,464900,133500,469400,136800,500,100,8,11);
theinsetsmaps[10] = new Array("inset_11",481070,142685,1430,481300,142600,482600,144300,500,100,4,3);
theinsetsmaps[11] = new Array("inset_12",478325,137470,1390,478300,137700,480000,139000,500,100,3,4);
theinsetsmaps[12] = new Array("inset_13",470090,134160,1910,470000,134400,472100,136100,500,100,4,5);
theinsetsmaps[13] = new Array("inset_14",464448,133545,4090,465000,133500,468300,138000,500,100,11,8);
theinsetsmaps[14] = new Array("inset_16",462863,131834,702,462800,131900,463700,132600,300,100,3,4);
theinsetsmaps[15] = new Array("inset_17",473145,132515,1965,473400,132500,475100,134600,500,100,5,4);
theinsetsmaps[16] = new Array("inset_18",474900,142085,1430,475100,142000,476400,143700,500,100,4,3);
theinsetsmaps[17] = new Array("inset_19",480855,134403,4100,480800,135000,485300,137900,500,100,7,11);
theinsetsmaps[18] = new Array("inset_20",483648,132140,1435,483900,132100,485200,133800,500,100,4,3);
theinsetsmaps[19] = new Array("inset_21",485720,133628,2915,485700,134000,489000,136500,500,100,6,8);
theinsetsmaps[20] = new Array("inset_22",481450,130954,1400,481400,131100,483100,132400,500,100,3,4);
theinsetsmaps[21] = new Array("inset_23",482230,129400,4165,482200,130000,486700,133300,500,100,8,11);
theinsetsmaps[22] = new Array("inset_24",481420,133033,1405,481400,133200,483100,134500,500,100,3,4);
theinsetsmaps[23] = new Array("inset_25",477613,133215,4110,478200,133200,481500,137700,500,100,11,8);
theinsetsmaps[24] = new Array("inset_26",467555,121390,1405,467500,121600,469200,122900,500,100,3,4);
theinsetsmaps[25] = new Array("inset_27",476768,130000,1975,477000,130000,478700,132100,500,100,5,4);
theinsetsmaps[26] = new Array("inset_28",471030,126172,727,471000,126300,471900,126800,300,100,2,4);
theinsetsmaps[27] = new Array("inset_29",478130,125590,1410,478300,125500,479600,127200,500,100,4,3);
theinsetsmaps[28] = new Array("inset_30",469875,136883,1980,469800,137100,471900,138800,500,100,4,5);
theinsetsmaps[29] = new Array("inset_31",476570,126430,2920,477000,126400,479100,129700,500,100,8,5);
theinsetsmaps[30] = new Array("inset_32",472315,120825,5755,473100,120800,477600,126900,500,100,15,11);
theinsetsmaps[31] = new Array("inset_33",479960,135205,1960,479900,135400,482000,137100,500,100,4,5);
theinsetsmaps[32] = new Array("inset_34",471745,122905,1415,471700,123100,473400,124400,500,100,3,4);
theinsetsmaps[33] = new Array("inset_35",473275,119290,1430,473500,119200,474800,120900,500,100,4,3);
theinsetsmaps[34] = new Array("inset_36",467790,110725,4105,467700,111300,472200,114200,500,100,7,11);
theinsetsmaps[35] = new Array("inset_37",468388,113500,4100,469000,113500,471900,117600,500,100,10,7);
theinsetsmaps[36] = new Array("inset_38",470970,108345,4130,471500,108300,474800,112800,500,100,11,8);
theinsetsmaps[37] = new Array("inset_39",478750,141325,1435,479000,141300,480300,143000,500,100,4,3);
theinsetsmaps[38] = new Array("inset_40",466715,142110,1430,466900,142100,468200,143800,500,100,4,3);
theinsetsmaps[39] = new Array("inset_41",469293,141513,704,469200,141600,470100,142100,300,100,2,4);
theinsetsmaps[40] = new Array("inset_15",463365,131125,1970,463300,131400,465400,133100,500,100,4,5);
theinsetsmaps[41] = new Array("proposals1",453975,105750,40950,460000,105000,489000,147500,2000,500,28,19);
theinsetsmaps[42] = new Array("proposals2",453975,105750,40950,460000,105000,489000,147500,2000,500,28,19);
// ^^^^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() == "alton"){
	  newMap = "map_htm/inset_01/inset_01_051.htm";
	}
	else if(theMap.toLowerCase() == "beech"){
	  newMap = "map_htm/inset_02/inset_02_006.htm";
	}
	else if(theMap.toLowerCase() == "bentley"){
	  newMap = "map_htm/inset_03/inset_03_008.htm";
	}
	else if(theMap.toLowerCase() == "bentley station"){
	  newMap = "map_htm/inset_04/inset_04_006.htm";
	}
	else if(theMap.toLowerCase() == "bentworth"){
	  newMap = "map_htm/inset_05/inset_05_002.htm";
	}
	else if(theMap.toLowerCase() == "blackmoor"){
	  newMap = "map_htm/inset_06/inset_06_008.htm";
	}
	else if(theMap.toLowerCase() == "binsted"){
	  newMap = "map_htm/inset_07/inset_07_006.htm";
	}
	else if(theMap.toLowerCase() == "bucks horn oak"){
	  newMap = "map_htm/inset_08/inset_08_004.htm";
	}
	else if(theMap.toLowerCase() == "east worldham"){
	  newMap = "map_htm/inset_09/inset_09_006.htm";
	}
	else if(theMap.toLowerCase() == "four marks"){
	  newMap = "map_htm/inset_10/inset_10_026.htm";
	}
	else if(theMap.toLowerCase() == "holt pound"){
	  newMap = "map_htm/inset_11/inset_11_007.htm";
	}
	else if(theMap.toLowerCase() == "kingsley"){
	  newMap = "map_htm/inset_12/inset_12_006.htm";
	}
	else if(theMap.toLowerCase() == "farringdon"){
	  newMap = "map_htm/inset_13/inset_13_009.htm";
	}
	else if(theMap.toLowerCase() == "medstead"){
	  newMap = "map_htm/inset_14/inset_14_020.htm";
	}
	else if(theMap.toLowerCase() == "ropley dean"){
	  newMap = "map_htm/inset_16/inset_16_006.htm";
	}
	else if(theMap.toLowerCase() == "selborne"){
	  newMap = "map_htm/inset_17/inset_17_010.htm";
	}
	else if(theMap.toLowerCase() == "upper froyle"){
	  newMap = "map_htm/inset_18/inset_18_004.htm";
	}
	else if(theMap.toLowerCase() == "headley"){
	  newMap = "map_htm/inset_19/inset_19_039.htm";
	}
	else if(theMap.toLowerCase() == "bramshott"){
	  newMap = "map_htm/inset_20/inset_20_004.htm";
	}
	else if(theMap.toLowerCase() == "grayshott"){
	  newMap = "map_htm/inset_21/inset_21_029.htm";
	}
	else if(theMap.toLowerCase() == "griggs green"){
	  newMap = "map_htm/inset_22/inset_22_006.htm";
	}
	else if(theMap.toLowerCase() == "liphook"){
	  newMap = "map_htm/inset_23/inset_23_027.htm";
	}
	else if(theMap.toLowerCase() == "passfield common"){
	  newMap = "map_htm/inset_24/inset_24_006.htm";
	}
	else if(theMap.toLowerCase() == "bordon"){
	  newMap = "map_htm/inset_25/inset_25_044.htm";
	}
	else if(theMap.toLowerCase() == "east meon"){
	  newMap = "map_htm/inset_26/inset_26_006.htm";
	}
	else if(theMap.toLowerCase() == "greatham"){
	  newMap = "map_htm/inset_27/inset_27_010.htm";
	}
	else if(theMap.toLowerCase() == "high cross"){
	  newMap = "map_htm/inset_28/inset_28_002.htm";
	}
	else if(theMap.toLowerCase() == "hill brow"){
	  newMap = "map_htm/inset_29/inset_29_008.htm";
	}
	else if(theMap.toLowerCase() == "chawton"){
	  newMap = "map_htm/inset_30/inset_30_008.htm";
	}
	else if(theMap.toLowerCase() == "liss"){
	  newMap = "map_htm/inset_31/inset_31_012.htm";
	}
	else if(theMap.toLowerCase() == "petersfield"){
	  newMap = "map_htm/inset_32/inset_32_059.htm";
	}
	else if(theMap.toLowerCase() == "lindford"){
	  newMap = "map_htm/inset_33/inset_33_007.htm";
	}
	else if(theMap.toLowerCase() == "stroud"){
	  newMap = "map_htm/inset_34/inset_34_006.htm";
	}
	else if(theMap.toLowerCase() == "buriton"){
	  newMap = "map_htm/inset_35/inset_35_007.htm";
	}
	else if(theMap.toLowerCase() == "horndean"){
	  newMap = "map_htm/inset_36/inset_36_039.htm";
	}
	else if(theMap.toLowerCase() == "clanfield"){
	  newMap = "map_htm/inset_37/inset_37_032.htm";
	}
	else if(theMap.toLowerCase() == "rowlands castle"){
	  newMap = "map_htm/inset_38/inset_38_044.htm";
	}
	else if(theMap.toLowerCase() == "blacknest"){
	  newMap = "map_htm/inset_39/inset_39_039.htm";
	}
	else if(theMap.toLowerCase() == "lasham"){
	  newMap = "map_htm/inset_40/inset_40_002.htm";
	}
	else if(theMap.toLowerCase() == "shalden"){
	  newMap = "map_htm/inset_41/inset_41_006.htm";
	}
	else if(theMap.toLowerCase() == "ropley"){
	  newMap = "map_htm/inset_15/inset_15_008.htm";
	}
	else if(theMap.toLowerCase() == "proposals map 1"){
	  newMap = "map_htm/proposals1/proposals1_274.htm";
	}
	else if(theMap.toLowerCase() == "proposals map 2"){
	  newMap = "map_htm/proposals2/proposals2_274.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 = 40950; 								//Width of main overview image in metres
	var tileHeight = 40950;								//Width of main overview image in metres

	var pixpermetreX =  tileWidth /imageWidth;
	var pixpermetreY =  tileHeight /imageHeight;

	var tileOriginX = 453975;							//Origin of main overview image in ground metres
	var tileOriginY = 105750;	
	
	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_01"){
	  theTitle = "Alton";
	}
	else if(theMapNo.toLowerCase() == "inset_02"){
	  theTitle = "Beech";
	}
	else if(theMapNo.toLowerCase() == "inset_03"){
	  theTitle = "Bentley";
	}
	else if(theMapNo.toLowerCase() == "inset_04"){
	  theTitle = "Bentley Station";
	}
	else if(theMapNo.toLowerCase() == "inset_05"){
	  theTitle = "Bentworth";
	}
	else if(theMapNo.toLowerCase() == "inset_06"){
	  theTitle = "Blackmoor";
	}
	else if(theMapNo.toLowerCase() == "inset_07"){
	  theTitle = "Binsted";
	}
	else if(theMapNo.toLowerCase() == "inset_08"){
	  theTitle = "Bucks Horn Oak";
	}
	else if(theMapNo.toLowerCase() == "inset_09"){
	  theTitle = "East Worldham";
	}
	else if(theMapNo.toLowerCase() == "inset_10"){
	  theTitle = "Four Marks";
	}
	else if(theMapNo.toLowerCase() == "inset_11"){
	  theTitle = "Holt Pound";
	}
	else if(theMapNo.toLowerCase() == "inset_12"){
	  theTitle = "Kingsley";
	}
	else if(theMapNo.toLowerCase() == "inset_13"){
	  theTitle = "Farringdon";
	}
	else if(theMapNo.toLowerCase() == "inset_14"){
	  theTitle = "Medstead";
	}
	else if(theMapNo.toLowerCase() == "inset_16"){
	  theTitle = "Ropley Dean";
	}
	else if(theMapNo.toLowerCase() == "inset_17"){
	  theTitle = "Selborne";
	}
	else if(theMapNo.toLowerCase() == "inset_18"){
	  theTitle = "Upper Froyle";
	}
	else if(theMapNo.toLowerCase() == "inset_19"){
	  theTitle = "Headley";
	}
	else if(theMapNo.toLowerCase() == "inset_20"){
	  theTitle = "Bramshott";
	}
	else if(theMapNo.toLowerCase() == "inset_21"){
	  theTitle = "Grayshott";
	}
	else if(theMapNo.toLowerCase() == "inset_22"){
	  theTitle = "Griggs Green";
	}
	else if(theMapNo.toLowerCase() == "inset_23"){
	  theTitle = "Liphook";
	}
	else if(theMapNo.toLowerCase() == "inset_24"){
	  theTitle = "Passfield Common";
	}
	else if(theMapNo.toLowerCase() == "inset_25"){
	  theTitle = "Bordon";
	}
	else if(theMapNo.toLowerCase() == "inset_26"){
	  theTitle = "East Meon";
	}
	else if(theMapNo.toLowerCase() == "inset_27"){
	  theTitle = "Greatham";
	}
	else if(theMapNo.toLowerCase() == "inset_28"){
	  theTitle = "High Cross";
	}
	else if(theMapNo.toLowerCase() == "inset_29"){
	  theTitle = "Hill Brow";
	}
	else if(theMapNo.toLowerCase() == "inset_30"){
	  theTitle = "Chawton";
	}
	else if(theMapNo.toLowerCase() == "inset_31"){
	  theTitle = "Liss";
	}
	else if(theMapNo.toLowerCase() == "inset_32"){
	  theTitle = "Petersfield";
	}
	else if(theMapNo.toLowerCase() == "inset_33"){
	  theTitle = "Lindford";
	}
	else if(theMapNo.toLowerCase() == "inset_34"){
	  theTitle = "Stroud";
	}
	else if(theMapNo.toLowerCase() == "inset_35"){
	  theTitle = "Buriton";
	}
	else if(theMapNo.toLowerCase() == "inset_36"){
	  theTitle = "Horndean";
	}
	else if(theMapNo.toLowerCase() == "inset_37"){
	  theTitle = "Clanfield";
	}
	else if(theMapNo.toLowerCase() == "inset_38"){
	  theTitle = "Rowlands Castle";
	}
	else if(theMapNo.toLowerCase() == "inset_39"){
	  theTitle = "Blacknest";
	}
	else if(theMapNo.toLowerCase() == "inset_40"){
	  theTitle = "Lasham";
	}
	else if(theMapNo.toLowerCase() == "inset_41"){
	  theTitle = "Shalden";
	}
	else if(theMapNo.toLowerCase() == "inset_15"){
	  theTitle = "Ropley";
	}
	else if(theMapNo.toLowerCase() == "proposals1"){
	  theTitle = "Proposals Map 1";
	}
	else if(theMapNo.toLowerCase() == "proposals2"){
	  theTitle = "Proposals Map 2";
	}
	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=630,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){																		
		theURL = "../../pol_index.htm?" + thePolRef + "&" + theDoc;	
		winName = "thePolIndex";
		features = "menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes,width=630,height=500";
		window.open(theURL,winName,features);		
}


//*******************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);

}	

//*******************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 == "HE18"){
	  thePolName = "Historic Parks and Gardens";
	}
	else if(polNum == "C1"){
	  thePolName = "Area of Outstanding Natural Beauty";
	}
	else if(polNum == "C2"){
	  thePolName = "Nature Conservation";
	}
	else if(polNum == "C3"){
	  thePolName = "Nature Conservation";
	}
	else if(polNum == "C11"){
	  thePolName = "Gaps Between Settlements";
	}
	else if(polNum == "T5"){
	  thePolName = "New Recreational Footpaths";
	}
	else if(polNum == "H1"){
	  thePolName = "Baseline Housing Allocations";
	}
	else if(polNum == "H2"){
	  thePolName = "Reserve Housing Allocations";
	}
	else if(polNum == "H10"){
	  thePolName = "Special Housing Areas";
	}
	else if(polNum == "H9"){
	  thePolName = "Areas of Special Housing Character";
	}
	else if(polNum == "IB1"){
	  thePolName = "Industrial and Business Land Allocations";
	}
	else if(polNum == "IB5"){
	  thePolName = "Lasham Airfield";
	}
	else if(polNum == "IB6"){
	  thePolName = "Special Industrial Estates";
	}
	else if(polNum == "TC1"){
	  thePolName = "Development in Town and Village Centres";
	}
	else if(polNum == "S1"){
	  thePolName = "Retail Allocations";
	}
	else if(polNum == "S2"){
	  thePolName = "Non Retail Uses in Shopping Centres";
	}
	else if(polNum == "S3"){
	  thePolName = "Primary Shopping Frontages";
	}
	else if(polNum == "S4"){
	  thePolName = "Secondary Shopping Frontages";
	}
	else if(polNum == "TM4"){
	  thePolName = "Hotel Allocations";
	}
	else if(polNum == "UI2"){
	  thePolName = "Reservoir";
	}
	else if(polNum == "LC1"){
	  thePolName = "Leisure and Cultural Facility Allocations";
	}
	else if(polNum == "R4"){
	  thePolName = "Open Space Allocations";
	}
	else if(polNum == "GS2"){
	  thePolName = "Location of Development";
	}
	else if(polNum == "CA"){
	  thePolName = "Conservation Areas";
	}
	else if(polNum == "SAC"){
	  thePolName = "Special Area of Conservation";
	}
	else if(polNum == "SPA"){
	  thePolName = "Special Protection Area";
	}
	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 = 40950; 								//Width of main overview image in metres
	var pixpermetre =  tileWidth /imageWidth;
	var tileOriginX = 453975;							//Origin of main overview image in ground metres
	var tileOriginY = 105750;
	
	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 how the map list is shown on the Proposals Maps (Keyboard accessible list or combo box)
function getMapList(toShow){
	if(toShow == "combo"){									//Show combo box
		eval("parent.location='map_index.htm?false'");
	}
	else{													//Show as text list
		eval("parent.location='map_index.htm?true'");
	}
}

//*******************************Defines the map to load from the postcode search.
function getSelectedPC(selObj){
	
	//Passed tile location.
	var tileLoc = selObj.options[selObj.selectedIndex].value;
			
	//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 map from the list of towns.
function openTown(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));
	}

	var mapLoc = "map_htm/" + insetNo + "/" + inString + ".htm";

	//Open in current window
 	eval("parent.location='" + mapLoc + "'");
  	if (theSource == 1){
		selObj.selectedIndex=0;
	}
}

/*
***********END of Script
*/
