/*
* **************************************************************************
lp.js
Interactive Local Plan
Tonbridge and Malling Borough 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 (7)
var nofInsets = 7;
theinsetsmaps[0] = new Array("inset_01",572695,158627,602.819,572700,158600,573350,159250,200,50,4,4);
theinsetsmaps[1] = new Array("inset_02",560577,157006,454.77,560500,157000,561150,157500,200,50,3,4);
theinsetsmaps[2] = new Array("inset_03",563265,149531,501.452,563200,149500,563850,150150,200,50,4,4);
theinsetsmaps[3] = new Array("inset_04",570148,161485,694.295,570100,161500,570900,162150,200,50,4,5);
theinsetsmaps[4] = new Array("inset_05",558418,145807,1482.26,558500,145800,559900,147350,200,50,10,9);
theinsetsmaps[5] = new Array("inset_06",567668,157621,549.594,567600,157600,568250,158250,200,50,4,4);
theinsetsmaps[6] = new Array("proposals",553625,143956,22950,553000,144000,577250,167500,1000,250,31,32);
// ^^^^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 a new window
		//window.close("mapOV");
		//winName = "mapindex";
		//features = "toolbar=yes,scrollbars=yes,resizable=yes,status=yes,width=780,height=600";
		//window.open(theNewHTML,winName,features); 

		//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
//vvv Insert pre- generated code below (js_openmapatcentre.txt) vvv
function openMapAtCentre(theMap,source){

var newMap;
if(theMap.toLowerCase() == "aylesford"){
  newMap = "map_htm/inset_01/inset_01_010.htm";
}
else if(theMap.toLowerCase() == "borough green"){
  newMap = "map_htm/inset_02/inset_02_006.htm";
}
else if(theMap.toLowerCase() == "hadlow"){
  newMap = "map_htm/inset_03/inset_03_006.htm";
}
else if(theMap.toLowerCase() == "snodland"){
  newMap = "map_htm/inset_04/inset_04_008.htm";
}
else if(theMap.toLowerCase() == "tonbridge"){
  newMap = "map_htm/inset_05/inset_05_049.htm";
}
else if(theMap.toLowerCase() == "west malling"){
  newMap = "map_htm/inset_06/inset_06_007.htm";
}
else if(theMap.toLowerCase() == "proposals map"){
  newMap = "map_htm/proposals/proposals_496.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 (Map index page 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 = 22950; 								//Width of main overview image in metres
	var tileHeight = 22950;								//Width of main overview image in metres

	var pixpermetreX =  tileWidth /imageWidth;
	var pixpermetreY =  tileHeight /imageHeight;

	var tileOriginX = 553625;							//Origin of main overview image in ground metres
	var tileOriginY = 143956;	
	
	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 a new window 	
			//winName = "mapOV";
			//features = "toolbar=no,scrollbars=yes,resizable=no,width=450,height=500";
			//window.open(theURL,winName,features);
			//break;
						
			//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 = "Aylesford";
}
else if(theMapNo.toLowerCase() == "inset_02"){
  theTitle = "Borough Green";
}
else if(theMapNo.toLowerCase() == "inset_03"){
  theTitle = "Hadlow";
}
else if(theMapNo.toLowerCase() == "inset_04"){
  theTitle = "Snodland";
}
else if(theMapNo.toLowerCase() == "inset_05"){
  theTitle = "Tonbridge";
}
else if(theMapNo.toLowerCase() == "inset_06"){
  theTitle = "West Malling";
}
else if(theMapNo.toLowerCase() == "proposals"){
  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															
		polIndex(thePolRef,theDoc);									//Open the policy list
	}		
}	


//*********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.close(winName);
		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 == "pol21"){
	  thePolName = "Sustainability P2/1";
	}
	else if(polNum == "pol22"){
	  thePolName = "Development allocations at Kings Hill P2/2";
	}
	else if(polNum == "pol23"){
	  thePolName = "Quality of Development at Kings Hill P2/3";
	}
	else if(polNum == "pol24"){
	  thePolName = "Phasing of Development at Kings Hill P2/4";
	}
	else if(polNum == "pol25"){
	  thePolName = "East of Wouldham village P2/5";
	}
	else if(polNum == "pol26"){
	  thePolName = "Development allocations at Peters Pit P2/6";
	}
	else if(polNum == "pol27"){
	  thePolName = "Peters Pit P2/7";
	}
	else if(polNum == "pol28"){
	  thePolName = "Bushey Wood P2/8";
	}
	else if(polNum == "pol29"){
	  thePolName = "Development at the Botany, Tonbridge P2/9";
	}
	else if(polNum == "pol210"){
	  thePolName = "TonbridgeTown Centre sites for mixed uses P2/10";
	}
	else if(polNum == "pol211"){
	  thePolName = "Tonbridge Town Centre P2/11";
	}
	else if(polNum == "pol212"){
	  thePolName = "Tonbridge Upper High Street P2/12";
	}
	else if(polNum == "pol213"){
	  thePolName = "Pedestrian Priority, Tonbridge High Street P2/13";
	}
	else if(polNum == "pol214"){
	  thePolName = "Service Access Tonbridge High Street P2/14";
	}
	else if(polNum == "pol215"){
	  thePolName = "Tonbridge Town Centre Parking Area P2/15";
	}
	else if(polNum == "pol216"){
	  thePolName = "Countryside Protection P2/16";
	}
	else if(polNum == "pol217"){
	  thePolName = "Safeguarded Land P2/17";
	}
	else if(polNum == "pol218"){
	  thePolName = "Strategic Gap P2/18";
	}
	else if(polNum == "pol219"){
	  thePolName = "Green Wedges P2/19";
	}
	else if(polNum == "pol31"){
	  thePolName = "Sites of Special Scientific Interest P3/1";
	}
	else if(polNum == "pol32"){
	  thePolName = "Sites of Nature Conservation Interest P3/2";
	}
	else if(polNum == "pol33"){
	  thePolName = "Ancient Woodland P3/3";
	}
	else if(polNum == "pol34"){
	  thePolName = "Impact of Development on Nature Conservation P3/4";
	}
	else if(polNum == "pol35"){
	  thePolName = "Areas of Outstanding Natural Beauty P3/5";
	}
	else if(polNum == "pol36"){
	  thePolName = "Special Landscape Areas P3/6";
	}
	else if(polNum == "pol37"){
	  thePolName = "Areas of Local Landscape Importance P3/7";
	}
	else if(polNum == "pol38"){
	  thePolName = "Trees and woodlands P3/8";
	}
	else if(polNum == "pol39"){
	  thePolName = "Agricultural Land P3/9";
	}
	else if(polNum == "pol310"){
	  thePolName = "Treatment of damaged land P3/10";
	}
	else if(polNum == "pol311"){
	  thePolName = "Adverse Ground Conditions P3/11";
	}
	else if(polNum == "pol312"){
	  thePolName = "Hazardous Installations P3/12";
	}
	else if(polNum == "pol313"){
	  thePolName = "Water Supply P3/13";
	}
	else if(polNum == "pol314"){
	  thePolName = "Water Quality P3/14";
	}
	else if(polNum == "pol315"){
	  thePolName = "Flood Protection P3/15";
	}
	else if(polNum == "pol316"){
	  thePolName = "Outputs to Air, Land and Water P3/16";
	}
	else if(polNum == "pol317"){
	  thePolName = "Noise P3/17";
	}
	else if(polNum == "pol318"){
	  thePolName = "Light P3/18";
	}
	else if(polNum == "pol319"){
	  thePolName = "Energy Efficiency through Building Design P3/19";
	}
	else if(polNum == "pol320"){
	  thePolName = "Renewable Energy P3/20";
	}
	else if(polNum == "pol41"){
	  thePolName = "Listed Buildings P4/1";
	}
	else if(polNum == "pol42"){
	  thePolName = "Scheduled Ancient Monuments P4/2";
	}
	else if(polNum == "pol43"){
	  thePolName = "Non-scheduled Archaeological Sites or Monuments P4/3";
	}
	else if(polNum == "pol44"){
	  thePolName = "Development affecting Conservation Areas P4/4";
	}
	else if(polNum == "pol45"){
	  thePolName = "Development within Conservation Areas P4/5";
	}
	else if(polNum == "pol46"){
	  thePolName = "Historic Parks and Gardens P4/6";
	}
	else if(polNum == "pol47"){
	  thePolName = "Areas of Historic Character P4/7";
	}
	else if(polNum == "pol48"){
	  thePolName = "Areas of Special Character P4/8";
	}
	else if(polNum == "pol49"){
	  thePolName = "Low Density Residential Areas P4/9";
	}
	else if(polNum == "pol410"){
	  thePolName = "Important Green Spaces P4/10";
	}
	else if(polNum == "pol411"){
	  thePolName = "Quality of New Development P4/11";
	}
	else if(polNum == "pol412"){
	  thePolName = "Residential Extensions P4/12";
	}
	else if(polNum == "pol413"){
	  thePolName = "Shopfront Design P4/13";
	}
	else if(polNum == "pol414"){
	  thePolName = "Riverside Environment P4/14";
	}
	else if(polNum == "pol415"){
	  thePolName = "Refuse Storage, Collection and Recycling P4/15";
	}
	else if(polNum == "pol416"){
	  thePolName = "Environmental Enhancements P4/16";
	}
	else if(polNum == "pol51"){
	  thePolName = "Housing Allocations P5/1";
	}
	else if(polNum == "pol52"){
	  thePolName = "Sites suitable for residential development P5/2";
	}
	else if(polNum == "pol53"){
	  thePolName = "Maximising residential accommodation P5/3";
	}
	else if(polNum == "pol54"){
	  thePolName = "Residential Conversions P5/4";
	}
	else if(polNum == "pol55"){
	  thePolName = "Affordable Housing on Large Sites P5/5";
	}
	else if(polNum == "pol56"){
	  thePolName = "Special Needs Housing P5/6";
	}
	else if(polNum == "pol57"){
	  thePolName = "Site for Travelling Showpeople at Snodland P5/7";
	}
	else if(polNum == "pol58"){
	  thePolName = "Travelling Show People P5/8";
	}
	else if(polNum == "pol59"){
	  thePolName = "Employment Areas P5/9";
	}
	else if(polNum == "pol510"){
	  thePolName = "Expansion of existing firms P5/10";
	}
	else if(polNum == "pol511"){
	  thePolName = "Small Firms P5/11";
	}
	else if(polNum == "pol512"){
	  thePolName = "Constrained employment sites P5/12";
	}
	else if(polNum == "pol513"){
	  thePolName = "Bad Neighbour Sites P5/13";
	}
	else if(polNum == "pol514"){
	  thePolName = "Open Storage Sites P5/14";
	}
	else if(polNum == "pol515"){
	  thePolName = "Sites Suitable for Business Use P5/15";
	}
	else if(polNum == "pol516"){
	  thePolName = "Areas and Buildings Suitable for Conversion to Business Use P5/16";
	}
	else if(polNum == "pol517"){
	  thePolName = "New Employment Development Outside Existing Employment Areas P5/17";
	}
	else if(polNum == "pol518"){
	  thePolName = "New Retail Development P5/18";
	}
	else if(polNum == "pol519"){
	  thePolName = "Retail Warehousing P5/19";
	}
	else if(polNum == "pol520"){
	  thePolName = "District Shopping Centres P5/20";
	}
	else if(polNum == "pol521"){
	  thePolName = "Development in areas adjoining District Centres P5/21";
	}
	else if(polNum == "pol522"){
	  thePolName = "Improvements to Snodland Shopping Centre P5/22";
	}
	else if(polNum == "pol523"){
	  thePolName = "Urban Local Centres P5/23";
	}
	else if(polNum == "pol524"){
	  thePolName = "Areas for conversion to Tourist accommodation P5/24";
	}
	else if(polNum == "pol525"){
	  thePolName = "Tourist facilities at Tonbridge Castle P5/25";
	}
	else if(polNum == "pol61"){
	  thePolName = "RS2 Settlements P6/1";
	}
	else if(polNum == "pol62"){
	  thePolName = "RS3(a) Settlements P6/2";
	}
	else if(polNum == "pol63"){
	  thePolName = "RS3(b) Settlements P6/3";
	}
	else if(polNum == "pol64"){
	  thePolName = "Infill Villages within the Green Belt P6/4";
	}
	else if(polNum == "pol65"){
	  thePolName = "Rural Settlements with a linear street character P6/5";
	}
	else if(polNum == "pol66"){
	  thePolName = "Kits Coty P6/6";
	}
	else if(polNum == "pol67"){
	  thePolName = "Rural Affordable Housing P6/7";
	}
	else if(polNum == "pol68"){
	  thePolName = "Development of new permanent agricultural or forestry dwellings P6/8";
	}
	else if(polNum == "pol69"){
	  thePolName = "Removal of agricultural or forestry occupancy conditions P6/9";
	}
	else if(polNum == "pol610"){
	  thePolName = "Householder Development in Rural Areas P6/10";
	}
	else if(polNum == "pol611"){
	  thePolName = "Gypsy Accommodation P6/11";
	}
	else if(polNum == "pol612"){
	  thePolName = "Recreation, Leisure and Tourism Uses in rural areas P6/12";
	}
	else if(polNum == "pol613"){
	  thePolName = "Horses and Stables P6/13";
	}
	else if(polNum == "pol614"){
	  thePolName = "Conversion of Rural Buildings to Employment Uses P6/14";
	}
	else if(polNum == "pol615"){
	  thePolName = "Conversion of Rural Buildings to Dwellings P6/15";
	}
	else if(polNum == "pol616"){
	  thePolName = "Converted Rural Buildings P6/16";
	}
	else if(polNum == "pol617"){
	  thePolName = "Major Developed Sites within the Green Belt P6/17";
	}
	else if(polNum == "pol618"){
	  thePolName = "Sites in the Green Belt suitable for Redevelopment P6/18";
	}
	else if(polNum == "pol619"){
	  thePolName = "Rural Lanes P6/19";
	}
	else if(polNum == "pol620"){
	  thePolName = "Rural Local Centres and Village Shops P6/20";
	}
	else if(polNum == "pol621"){
	  thePolName = "Development in area adjoining West Malling Local Centre P6/21";
	}
	else if(polNum == "pol622"){
	  thePolName = "Local Community Facilities outside confines of settlements P6/22";
	}
	else if(polNum == "pol623"){
	  thePolName = "Castle Lake, Leybourne P6/23";
	}
	else if(polNum == "pol624"){
	  thePolName = "Mereworth Woods Visitor Centre P6/24";
	}
	else if(polNum == "pol625"){
	  thePolName = "Beltring Hop Farm P6/25";
	}
	else if(polNum == "pol71"){
	  thePolName = "Passenger facilities and car parking at railway stations P7/1";
	}
	else if(polNum == "pol72"){
	  thePolName = "Car Parking at Barming, Snodland & New Hythe Stations P7/2";
	}
	else if(polNum == "pol73"){
	  thePolName = "Rail Sidings on employment sites P7/3";
	}
	else if(polNum == "pol74"){
	  thePolName = "Light Rail Depot and Park and Ride site at Holborough P7/4";
	}
	else if(polNum == "pol75"){
	  thePolName = "Coach-based Park and Ride Facility at Blue Bell Hill P7/5";
	}
	else if(polNum == "pol76"){
	  thePolName = "Buses and Taxis P7/6";
	}
	else if(polNum == "pol77"){
	  thePolName = "Adopted Road Schemes P7/7";
	}
	else if(polNum == "pol78"){
	  thePolName = "Development-related Road Schemes P7/8";
	}
	else if(polNum == "pol79"){
	  thePolName = "Roadside and Motorway Services P7/9";
	}
	else if(polNum == "pol710"){
	  thePolName = "Roadside facilities west of Hale Street Bypass, East Peckham P7/10";
	}
	else if(polNum == "pol711"){
	  thePolName = "River Transport P7/11";
	}
	else if(polNum == "pol712"){
	  thePolName = "Cycling P7/12";
	}
	else if(polNum == "pol713"){
	  thePolName = "Access for Pedestrians in development proposals P7/13";
	}
	else if(polNum == "pol714"){
	  thePolName = "Public Rights of Way P7/14";
	}
	else if(polNum == "pol715"){
	  thePolName = "Riverside Footpath P7/15";
	}
	else if(polNum == "pol716"){
	  thePolName = "Telecommunications P7/16";
	}
	else if(polNum == "pol717"){
	  thePolName = "Remedial measures to combat traffic impacts P7/17";
	}
	else if(polNum == "pol718"){
	  thePolName = "Vehicle Parking P7/18";
	}
	else if(polNum == "pol719"){
	  thePolName = "Residents' Parking P7/19";
	}
	else if(polNum == "pol81"){
	  thePolName = "Service and Community Infrastructure in new developments P8/1";
	}
	else if(polNum == "pol82"){
	  thePolName = "Provision of Open Playing Space P8/2";
	}
	else if(polNum == "pol83"){
	  thePolName = "Sites suitable for Open Playing Space P8/3";
	}
	else if(polNum == "pol84"){
	  thePolName = "Loss of Open Playing Space P8/4";
	}
	else if(polNum == "pol85"){
	  thePolName = "Expansion at Larkfield Leisure Centre P8/5";
	}
	else if(polNum == "pol86"){
	  thePolName = "Sites for Informal Recreation P8/6";
	}
	else if(polNum == "pol87"){
	  thePolName = "Leybourne Lakes P8/7";
	}
	else if(polNum == "pol88"){
	  thePolName = "Marina proposal at Tonbridge P8/8";
	}
	else if(polNum == "pol89"){
	  thePolName = "Safeguarding of land for new educational facilities P8/9";
	}
	else if(polNum == "pol810"){
	  thePolName = "Allotments P8/10";
	}
	else if(polNum == "pol811"){
	  thePolName = "Medway Crematorium P8/11";
	}
	else if(polNum == "pol812"){
	  thePolName = "Land safeguarded for new reservoirs P8/12";
	}
	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 = 22950; 								//Width of main overview image in metres
	var pixpermetre =  tileWidth /imageWidth;
	var tileOriginX = 553625;							//Origin of main overview image in ground metres
	var tileOriginY = 143956;
	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 map index page
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 + "'");
	//Open in new window
	//theURL = selObj.options[selObj.selectedIndex].value ;	
	//winName = "mapWindow";
	//features = "toolbar=no,scrollbars=no,resizable=no,width=450,height=500";
	//window.open(theURL,winName,features);
  	if (theSource == 1){
		selObj.selectedIndex=0;
	}
}

//*********Defines how the map list is shown on the map index page (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 + "'");
	//Open in new window
	//theURL = selObj.options[selObj.selectedIndex].value ;	
	//winName = "mapWindow";
	//features = "toolbar=no,scrollbars=no,resizable=no,width=450,height=500";
	//window.open(theURL,winName,features);
								
}

//******************************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 + "'");
		}
	}		

}

//********Open a list of policies (called on click/keypress on the icon in the legend).
function getPol(thePolRef,theDoc){
	if(thePolRef != ""){													
		theURL = "pol_index2.htm?" + thePolRef + "&" + theDoc;		
		eval("parent.location='" + theURL + "'");
	}		
}	

/*
***********END of Script
*/
