
//-Begin Section -tag_repeater.js-\\
// JScript File

function tagRepeater(clientId, requestId, strName, strUrl, blnDisableForm, strLoadResultsEvent, strResultsLoadedEvent)
{
	this.ClientID = clientId;
	this.RequestId = requestId;
	this.Url = strUrl;
	this.Name = strName;
	this.DisableForm = blnDisableForm;
	this.LoadResultsEvent = strLoadResultsEvent;
	this.ResultsLoadedEvent = strResultsLoadedEvent;
	
	this.loadResults = function(eventArg, strCustomKeyword1, strCustomKeyword2, strCustomKeyword3)
	{
		try
		{
			if(typeof(eventArg) == 'undefined')
			{
				eventArg = '';
			}
			
			if(this.LoadResultsEvent != '')
			{
				eval(this.LoadResultsEvent);
			}
			
			if((typeof(strCustomKeyword1) == 'undefined')||(strCustomKeyword1 == null))
			{
				strCustomKeyword1 = '*NULL*'
			}
			if((typeof(strCustomKeyword2) == 'undefined')||(strCustomKeyword2 == null))
			{
				strCustomKeyword2 = '*NULL*'
			}
			if((typeof(strCustomKeyword3) == 'undefined')||(strCustomKeyword3 == null))
			{
				strCustomKeyword3 = '*NULL*'
			}
			
			if((eventArg != '')&&(this.DisableForm))
			{
				formDisable(true);
			}
			
			ajaxSimpleSendRequest(this.Url, this.Name + '.resultsLoaded', eventArg, 'resultsLoaded', new ajaxArg('client_id',this.ClientID), new ajaxArg('request_id',this.RequestId), new ajaxArg('custom_keyword1',strCustomKeyword1), new ajaxArg('custom_keyword2',strCustomKeyword2), new ajaxArg('custom_keyword3',strCustomKeyword3));
		}
		catch(ex)
		{
			raiseMessage('stoperror', ex.description, '');
			if((eventArg != '')&&(this.DisableForm))
			{
				formDisable(false);
			}
		}
		
	}
	
	
	this.resultsLoaded = function(objResponse)
	{
		var xmlAjax = objResponse.getElementsByTagName('result')[0];
		var intStatus = GetXmlNodeText(xmlAjax.getElementsByTagName('status')[0]);
		var strErrorMessage = GetXmlNodeText(xmlAjax.getElementsByTagName('error_message')[0]);
		var innerHtml = '';
		var strAction = 'd';

		try
		{
			if(intStatus != 0)
			{
				raiseMessage('stoperror', strErrorMessage, '');
			}
			else
			{
				innerHtml = GetXmlNodeText(xmlAjax.getElementsByTagName('html')[0]);
				strAction = GetXmlNodeText(xmlAjax.getElementsByTagName('action')[0]);
				this.Control.innerHTML = innerHtml;
				
				if(this.ResultsLoadedEvent != '')
				{
					eval(this.ResultsLoadedEvent);
				}
			}
		}
		catch(ex)
		{
			raiseMessage('stoperror', ex.description, '');
		}
		if((strAction != '')&&(this.DisableForm))
		{			
			formDisable(false);
		}
		
	}
	
	this.init = function()
	{
		this.Control = $(this.ClientID);
	}
	
	this.pageSizeChanged = function(that, e)
	{
		this.loadResults('~PageSizeChange|' + that.value);
	}
	
	this.keywordFilter = function(that, e)
	{
		this.loadResults('~FilterByKeyword|' + that.value);
	}
	
}

tagRepeater.prototype.ClientID = '';
tagRepeater.prototype.RequestID = '';
tagRepeater.prototype.Name = '';
tagRepeater.prototype.Url = '';
tagRepeater.prototype.Control = null;
tagRepeater.prototype.DisableForm = true;
tagRepeater.prototype.LoadResultsEvent = '';
tagRepeater.prototype.ResultsLoadedEvent = '';


//-End Section -tag_repeater.js-\\


//-Begin Section -_wood-gmap_metafilter.js-\\

// this variable will collect the html which will eventually be placed in the sidebar
var sidebar_html = "";
// this is the handle to the map
var map = "";
// arrays to hold copies of the markers and html used by the sidebar
// because the function closure trick doesnt work there
var gmarkers = [];
var htmls = [];
var gInt = 0;
// arrays to hold variants of the info window html with get direction forms open
var to_htmls = [];
var from_htmls = [];
var mintCounter = 0;

var prefix = '';

//var intZoom = 9;

var sidebar_mode = 0;
var sidebar_title = '';
var map_title = '';

var center_lat = '';
var center_lon = '';

var enable_overview = 1;

var blnDirections = 'true';





if (GBrowserIsCompatible()) {





	// Download the data in data.xml and load it on the map. The format we
	// expect is:
	// <markers>
	//   <marker lat="37.441" lng="-122.141" title="blah" desc="comp name1"/>
	//   <marker lat="37.322" lng="-121.213" title="blah" desc="comp name2"/>
	// </markers>
	function initGmap(blnLoad, blnReset) {
        if(blnLoad==true)
        {	
            
			var blnAsync = false; //synch
            var request = GXmlHttp.create();
            request.open("GET", xmlFile, blnAsync); 
			
			if(blnAsync)
			{
				request.onreadystatechange = function() 
				{
					if (request.readyState == 4) 
					{
						MapDocumentReady(request, blnReset);
					}
				}
			}

			
            request.send(null);

			if(!blnAsync)
			{
				MapDocumentReady(request, blnReset);
			}            
        }
        else
        {
            map = new GMap2(document.getElementById("mapcont"));
            map.addControl(new GLargeMapControl()); //pan & zoom
            map.addControl(new GMapTypeControl());  //map type: map, satellite, hybrid
            //map.addControl(new GOverviewMapControl());                   
        
            map.setCenter(new GLatLng('54.7209','-3.6562'), 5);

			
        }
    }
    
    //addEvent(window, 'load', initGmap, false);
    //addEvent(window, 'unload', GUnload, false);
	
	
	Event.observe(document, 'dom:loaded', initGmap);
	Event.observe(window, 'unload', GUnload);
}
else 
{
  alert('Sorry, the Google Maps API is not compatible with this browser');
}  
 
 
function MapDocumentReady(request, blnReset)
{

	if(blnReset==true)
	{

		// clear existing markers
		gmarkers.length = 0;
		mintCounter = 0;
		gInt = 0;
		htmls.length = 0;
		to_htmls.length = 0;
		from_htmls.length = 0;

		var xmlDoc = request.responseXML;
		var mode_check = xmlDoc.getElementsByTagName("metadata");
		
		if(mode_check.length==1) 
		{
			//meta data xml
			
			//create the map and add a couple of toolbars
			map = new GMap2(document.getElementById("mapcont"));
			map.addControl(new GLargeMapControl()); //pan & zoom
			map.addControl(new GMapTypeControl());  //map type: map, satellite, hybrid
			//map.addControl(new GOverviewMapControl());    
			//window.setTimeout("overview = new GOverviewMapControl();map.addControl(overview)",500); 							
			
			// Mouse Scroll Zooom
			map.enableScrollWheelZoom();        
			GEvent.addDomListener(map.getContainer(), "DOMMouseScroll", wheelevent);
			map.getContainer().onmousewheel = wheelevent;                             
			
			
			blnDirections = true;
			//var intZoom = 6;
 
			var dblTotalLongitude = 0;
			var dblTotalLatitude = 0;
			var intZoom = 5;      
			var intCounter = 0;
				
			var markers = xmlDoc.getElementsByTagName("item");
			for (var i = 0; i < markers.length; i++) 
			{
			
				var gpsLon = parseFloat(GetXmlNodeText(markers[i].getElementsByTagName("gpslongitude")[0]));
				var gpsLat = parseFloat(GetXmlNodeText(markers[i].getElementsByTagName("gpslatitude")[0]));
				
				
				if(i==0) 
				{

					switch(mstrKeyword1) 
					{
						default:
							// United Kingdom
							//center near blackpool
							map.setCenter(new GLatLng(parseFloat('54.6021'), parseFloat('-4.3636')), intZoom, null);                                
					}
					
					
				}
				
				var iconColour = '';
				try 
				{
					iconColour = GetXmlNodeText(markers[i].getElementsByTagName("mapiconcolour")[0]);
				}
				catch(e) {}
				if(iconColour=='') iconColour = 'red';
				
				if(!isNaN(gpsLon) && !isNaN(gpsLat)) 
				{
				
					intCounter++;
				
					if(typeof(dblSmallestLatitude) === 'undefined')
					{
					   var dblSmallestLatitude = gpsLat;
					}
					if(typeof(dblSmallestLongitude) === 'undefined')
					{
					   var dblSmallestLongitude = gpsLon;
					}
					if(typeof(dblLargestLatitude) === 'undefined')
					{
					   var dblLargestLatitude = gpsLat;
					}
					if(typeof(dblLargestLongitude) === 'undefined')
					{
					   var dblLargestLongitude = gpsLon;
					}
					if(gpsLon > dblLargestLongitude)
					{
					   dblLargestLongitude = gpsLon;
					}
					if(gpsLat > dblLargestLatitude)
					{
					   dblLargestLatitude = gpsLat;
					}
					if(gpsLon < dblSmallestLongitude)
					{
					   dblSmallestLongitude = gpsLon;
					}
					if(gpsLat < dblSmallestLatitude)
					{
					   dblSmallestLatitude = gpsLat;
					}

					dblTotalLongitude += gpsLon;
					dblTotalLatitude += gpsLat;    
					
					
					var point = new GPoint(gpsLon,gpsLat);
					
					var title = GetXmlNodeText(markers[i].getElementsByTagName("name")[0]);
					var link = GetXmlNodeText(markers[i].getElementsByTagName("link")[0]);
					var address1 = GetXmlNodeText(markers[i].getElementsByTagName("address")[0]);
					var address2 = GetXmlNodeText(markers[i].getElementsByTagName("address2")[0]);
					var town = GetXmlNodeText(markers[i].getElementsByTagName("town")[0]);
					var county = GetXmlNodeText(markers[i].getElementsByTagName("county")[0]);
					var postcode = GetXmlNodeText(markers[i].getElementsByTagName("postcode")[0]);
					var telephone = GetXmlNodeText(markers[i].getElementsByTagName("phonenumber")[0]);

 
					var desc = ''; // html displayed within the map
					
					desc  = '<ul>';
					desc += '<li><strong>' + title + '</strong><!-- ' + gpsLon + '-' + gpsLat + ' --></li>';
					if(address1!='')
					{
						desc += '<li>' + address1 + ',</li>';
					}
					if(address2!='')
					{
						desc += '<li>' + address2 + ',</li>';
					}
					if(town!='')
					{
						desc += '<li>' + town + '</li>';
					}
					if(county!='')
					{
						desc += '<li>' + county + '</li>';
					}

					if(postcode!='')
					{
						desc += '<li>' + postcode + '</li>';
					}
					desc += '<li>&nbsp;</li>';
					if(telephone!='')
					{                                
						desc += '<li>Tel: ' + telephone + '</li>';
					}

					//  desc += '<li>&nbsp;</li>';
					desc += '</ul>';

		  
					var marker = createMarker(point,'',desc,iconColour);
					map.addOverlay(marker);
				}
			} 
				
				
			if (markers.length>0)
			{
				var dblLongitudeGap = dblLargestLongitude - dblSmallestLongitude;
				var dblLatitudeGap = dblLargestLatitude - dblSmallestLatitude;
				
				if(dblLongitudeGap > (dblLatitudeGap/2))
				{
				   //works out gap in degrees and from that the zoom factor required
				   var dblGap = dblLongitudeGap;
				}
				else
				{
				   var dblGap = dblLatitudeGap;
				}
				
				dblLatitude = dblTotalLatitude / intCounter;
				dblLongitude = dblTotalLongitude / intCounter;

				if(dblGap >= 0)
				{
					intZoom = 3;
				}
				if(dblGap >= 0.004)
				{
					intZoom = 3;
				}
				if(dblGap >= 0.01)
				{
					intZoom = 3;
				}
				if(dblGap >= 0.02)
				{
					intZoom = 5;
				}
				if(dblGap >= 0.1)
				{
					intZoom = 7;
				}
				if(dblGap >= 0.5)
				{
					intZoom = 7;
				}
				if(dblGap > .8)
				{
					intZoom = 8;
				}
				if(dblGap > 1.5)
				{
					intZoom = 10;
				}
				if(dblGap > 4)
				{
					intZoom = 9;
				}
				if(dblGap > 8)
				{
					intZoom = 10;
				}
				if(dblGap > 16)
				{
					intZoom = 11;
				}
				if(dblGap > 64)
				{
					intZoom = 12;
				}

				//alert(dblGap);
				intZoom = 16 - intZoom ; // fix for v2 gmap api

				if(!isNaN(dblLatitude) && !isNaN(dblLongitude)) 
				{
					map.setCenter(new GLatLng(parseFloat(dblLatitude), parseFloat(dblLongitude)), parseInt(intZoom), null);
				}
				if(intCounter == 1)
				{
				   firstClick();
				}
			}
			
		}
		else {
		
			//create the map and add a couple of toolbars
			map = new GMap2(document.getElementById("mapcont"));
			map.addControl(new GLargeMapControl()); //pan & zoom
			map.addControl(new GMapTypeControl());  //map type: map, satellite, hybrid


			var properties = xmlDoc.documentElement.getElementsByTagName("property");
			for (var i = 0; i < properties.length; i++) {
				if(properties[i].getAttribute("name") == 'company_name') {
					prefix = GetXmlNodeText(properties[i]);   
				}
				else if (properties[i].getAttribute("name") == 'sidebar_mode') {
					sidebar_mode = GetXmlNodeText(properties[i]);
				}
				else if (properties[i].getAttribute("name") == 'sidebar_title') {
					sidebar_title = GetXmlNodeText(properties[i]);
				}
				else if (properties[i].getAttribute("name") == 'map_title') {
					map_title = GetXmlNodeText(properties[i]);
				}
				else if (properties[i].getAttribute("name") == 'zoom') {
					intZoom = parseInt(GetXmlNodeText(properties[i]));
				}
				else if (properties[i].getAttribute("name") == 'directions') {
					blnDirections = GetXmlNodeText(properties[i]);
				}
				else if (properties[i].getAttribute("name") == 'center_lat') {
					center_lat = GetXmlNodeText(properties[i]);
				}
				else if (properties[i].getAttribute("name") == 'center_lon') {
					center_lon = GetXmlNodeText(properties[i]);
				}
				else if (properties[i].getAttribute("name") == 'enable_overview') {
					enable_overview = GetXmlNodeText(properties[i]);
				}
				 
			}	

			if(parseInt(enable_overview) == 1)
			{
				map.addControl(new GOverviewMapControl());    
			}
			
			
			if(map_title != '') {
				
				var objMap = document.getElementById("mapcont");
				if(objMap) {
					var objTitle = document.createElement('h1');
					objTitle.innerText = map_title;
					objTitle.className = 'MapTitle';
					objMap.insertAdjacentElement('beforeBegin', objTitle);
					
				}
			}                
					
			var markers = xmlDoc.documentElement.getElementsByTagName("marker");
			for (var i = 0; i < markers.length; i++) {
				if(i==0) {
					//center near first point
					if(center_lat=='')
					{
					   map.setCenter(new GLatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng"))), intZoom, null);
					}
					else
					{
						map.setCenter(new GLatLng(parseFloat(center_lat), parseFloat(center_lon)), intZoom, null);
					}
				}
				
				try {
					var iconColour = markers[i].getAttribute("icon").toString()
				}
				catch(e) {
					var iconColour = 'red';
				}
				var point = new GPoint(parseFloat(markers[i].getAttribute("lng")),parseFloat(markers[i].getAttribute("lat")));
				var title = markers[i].getAttribute("title").toString();
				var desc = markers[i].getAttribute("desc").toString();
				var marker = createMarker(point,title,desc,iconColour);
				map.addOverlay(marker);
			}
		}

		// put the assembled sidebar_html contents into the sidebar div
		//sidebar_html = '<h1 class="elContentTitle">Contact Us</h1>' + sidebar_html;
		if(document.getElementById("sidebar")) {
			if(sidebar_title!='') {
				sidebar_title = '<h1 class="SideBarTitle"><span>'+sidebar_title+'</span>'+sidebar_title+'</h1>';
			}
			document.getElementById("sidebar").innerHTML = sidebar_title + sidebar_html;
		}
	}
	else
	{
// not blnReset
		/* ------------------------------------ */
		var xmlDoc = request.responseXML;
		var mode_check = xmlDoc.getElementsByTagName("metadata");
		
		if(mode_check.length==1) 
		{
			//meta data xml

			blnDirections = true;

			var dblTotalLongitude = 0;
			var dblTotalLatitude = 0;
			var intZoom = 5;      
			var intCounter = 0;

			var markers = xmlDoc.getElementsByTagName("item");

			if(markers.length==0)
			{
				//window.open(xmlFile);
			}

			for (var i = 0; i < markers.length; i++) 
			{
			
				var gpsLon = parseFloat(GetXmlNodeText(markers[i].getElementsByTagName("gpslongitude")[0]));
				var gpsLat = parseFloat(GetXmlNodeText(markers[i].getElementsByTagName("gpslatitude")[0]));
				var custid = GetXmlNodeText(markers[i].getElementsByTagName("customerid")[0]);

				if(i==0) 
				{
					map.setCenter(new GLatLng(parseFloat('54.6021'), parseFloat('-4.3636')), intZoom, null);
				}
				
				try 
				{
					var iconColour = GetXmlNodeText(markers[i].getElementsByTagName("mapiconcolour")[0]);
				}
				catch(e) 
				{
					var iconColour = 'red';
				}
				
				if(!isNaN(gpsLon) && !isNaN(gpsLat)) 
				{
				
					intCounter++;
				
					if(typeof(dblSmallestLatitude) === 'undefined')
					{
					   var dblSmallestLatitude = gpsLat;
					}
					if(typeof(dblSmallestLongitude) === 'undefined')
					{
					   var dblSmallestLongitude = gpsLon;
					}
					if(typeof(dblLargestLatitude) === 'undefined')
					{
					   var dblLargestLatitude = gpsLat;
					}
					if(typeof(dblLargestLongitude) === 'undefined')
					{
					   var dblLargestLongitude = gpsLon;
					}
					if(gpsLon > dblLargestLongitude)
					{
					   dblLargestLongitude = gpsLon;
					}
					if(gpsLat > dblLargestLatitude)
					{
					   dblLargestLatitude = gpsLat;
					}
					if(gpsLon < dblSmallestLongitude)
					{
					   dblSmallestLongitude = gpsLon;
					}
					if(gpsLat < dblSmallestLatitude)
					{
					   dblSmallestLatitude = gpsLat;
					}

					dblTotalLongitude += gpsLon;
					dblTotalLatitude += gpsLat;
				}
			} 
				
				
			if (markers.length>0)
			{
				var dblLongitudeGap = dblLargestLongitude - dblSmallestLongitude;
				var dblLatitudeGap = dblLargestLatitude - dblSmallestLatitude;
				
				if(dblLongitudeGap > (dblLatitudeGap/2))
				{
				   //works out gap in degrees and from that the zoom factor required
				   var dblGap = dblLongitudeGap;
				}
				else
				{
				   var dblGap = dblLatitudeGap;
				}
				
				dblLatitude = dblTotalLatitude / intCounter;
				dblLongitude = dblTotalLongitude / intCounter;

				if(dblGap >= 0)
				{
					intZoom = 0;
				}
				if(dblGap >= 0.004)
				{
					intZoom = 1;
				}
				if(dblGap >= 0.01)
				{
					intZoom = 2;
				}
				if(dblGap >= 0.02)
				{
					intZoom = 4;
				}
				if(dblGap >= 0.1)
				{
					intZoom = 6;
				}
				if(dblGap >= 0.5)
				{
					intZoom = 7;
				}
				if(dblGap > 1)
				{
					intZoom = 10;
				}
				if(dblGap > 2)
				{
					intZoom = 11;
				}
				if(dblGap > 4)
				{
					intZoom = 11;
				}
				if(dblGap > 8)
				{
					intZoom = 12;
				}
				if(dblGap > 16)
				{
					intZoom = 12;
				}
				if(dblGap > 64)
				{
					intZoom = 13;
				}

				intZoom = 16 - intZoom; // fix for v2 gmap api

				if(!isNaN(dblLatitude) && !isNaN(dblLongitude)) 
				{
					map.setCenter(new GLatLng(parseFloat(dblLatitude), parseFloat(dblLongitude)), parseInt(intZoom), null);
				}
				if(intCounter == 1)
				{

					  getMarkerByText(gpsLon+gpsLat);

				}
			}	
		}	
		/* ------------------------------------ */
	}
}
 
 
 
	function GetXmlNodeText(node)
	{ 
	    if(node && node.text)
	    { 
	        return node.text; 
	    }
	    else if(node && node.textContent)
	    { 
	        return node.textContent; 
	    } 
	    else
	    {
			return '';
	    }
	}

	function firstClick()
	{
	    myclick(0);   
	}

 
	// A function to create the marker and set up the event window
	function createMarker(point,name,html,iconcolour) {
		mintCounter++;

		var icon = new GIcon();
		icon.image = mstrAppPath + "_themes/googlemap/images/mm_20_" + iconcolour + ".png"; //
		icon.iconSize = new GSize(12, 20);
		icon.shadow = mstrAppPath + "_themes/googlemap/images/mm_20_shadow.png";
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(6, 20);
		icon.infoWindowAnchor = new GPoint(5, 1);   

		var marker = new GMarker(point, icon);
		var finalhtml;


		// The info window version with the "to here" form open
		to_htmls[gInt] = html + '<br><br>Directions: <b>To here</b> - <a href="javascript:fromhere(' + gInt + ')" class="popuplnk">From here</a>' +
		   '<br><br>Start address/postcode:<br><form action="http://maps.google.com/maps" method="get" target="_blank">' +
		   '<input type="text" size="30" maxlength="40" name="saddr" id="saddr" value="" /><br>' +
		   '<input value="Get Directions" type="submit">' +
		   '<input type="hidden" name="daddr" value="' +
		   point.y + ',' + point.x + "(" + prefix + ' - ' + name + ")" + '"/>';
		// The info window version with the "to here" form open
		from_htmls[gInt] = html + '<br><br>Directions: <a href="javascript:tohere(' + gInt + ')" class="popuplnk">To here</a> - <b>From here</b>' +
		   '<br><br>End address/postcode:<br><form action="http://maps.google.com/maps" method="get" target="_blank">' +
		   '<input type="text" size="30" maxlength="40" name="daddr" id="daddr" value="" /><br>' +
		   '<input value="Get Directions" type="submit">' +
		   '<input type="hidden" name="saddr" value="' +
		   point.y + ',' + point.x + "(" + prefix + ' - ' + name + ")" + '"/>';
		// The inactive version of the direction info
		finalhtml = '<strong>'+name + '</strong><br>' + html + '<br><br>Directions: <a href="javascript:tohere('+gInt+')" class="popuplnk">To here</a> - <a href="javascript:fromhere('+gInt+')" class="popuplnk">From here</a>';

		GEvent.addListener(marker, "click", function() 
		{
			marker.openInfoWindowHtml('<div class="popup">'+finalhtml+'</div>');
		});
		/*
		MOUSEOVER INSTEAD
		GEvent.addListener(marker, "mouseover", function() {
			marker.openInfoWindowHtml('<div class="popup">'+finalhtml+'</div>');
		});
		*/
		// save the info we need to use later for the sidebar
		gmarkers[gInt] = marker;
		htmls[gInt] = finalhtml;
		// add a line to the sidebar html
		if(sidebar_mode == 0) 
		{
			sidebar_html += '<div id="side'+mintCounter+'"><a href="javascript:myclick(' + gInt + ')" class="Office">' + name + '</a><br /></div>'; //' + html + '</div>';
		}
		else if(sidebar_mode == 1) 
		{
			sidebar_html += '<div id="side'+mintCounter+'"><a href="javascript:myclick(' + gInt + ')" class="Office">' + name + '</a><br />' + html + '</div>';
		}
		gInt++;
		return marker;
	}
	// This function picks up the click and opens the corresponding info window
	function myclick(intIndex) 
	{
		document.getElementById("mapcont").focus();    
		gmarkers[intIndex].openInfoWindowHtml('<div class="popup">'+htmls[intIndex]+'</div>');
	}
	// functions that open the directions forms
	function tohere(intIndex) 
	{
		gmarkers[intIndex].openInfoWindowHtml('<div class="popup">'+ to_htmls[intIndex]+'</div>');
	}
	function fromhere(intIndex) 
	{
		gmarkers[intIndex].openInfoWindowHtml('<div class="popup">'+ from_htmls[intIndex] +'</div>');
	}
	function getMarkerByText(strValue)
	{
		for(intIndex=0;intIndex<htmls.length;intIndex++)
		{
			if(htmls[intIndex].indexOf(strValue)!= -1)
			{
				document.location.href = '#listings';
				map.setZoom(11);
				myclick(intIndex);
				break;
			}
		}
	}
	function wheelevent(e)
	{

	    if (!e){
	        e = window.event
	    }
	    e.returnValue = false;

	}

//-End Section -_wood-gmap_metafilter.js-\\


//-Begin Section -_wood-metafilter.js-\\
var mstrSelected = '';
var mstrSelected2 = '';
var mobjSel1 = '';
var mobjSel2 = '';
var mobjSel3 = '';
var mobjBtn = '';
var mstrLast2 = '';
var mPreImg = new Image(112,112);
var mobjDiv = document.createElement('div');
var mstrLastLoadCountry = '';

function generateXmlForAjax(strKey1, strKey2)
{
    var xmlDoc = createXMLDOM();			
    var xmlTable = xmlDoc.createElement('metadata');
    var xmlRow = xmlDoc.createElement('metadataitem');
    xmlDoc.appendChild(xmlTable);
    xmlTable.appendChild(xmlRow);
    AddNodeToXml(xmlDoc, xmlRow, 'action', mstrAction);
    AddNodeToXml(xmlDoc, xmlRow, 'column1', mstrColumn1);
    AddNodeToXml(xmlDoc, xmlRow, 'column2', mstrColumn2);
    AddNodeToXml(xmlDoc, xmlRow, 'column3', mstrColumn3);
    AddNodeToXml(xmlDoc, xmlRow, 'keyword1', strKey1);
    AddNodeToXml(xmlDoc, xmlRow, 'keyword2', strKey2);
    AddNodeToXml(xmlDoc, xmlRow, 'tag', mstrTag);
    AddNodeToXml(xmlDoc, xmlRow, 'return_function', '');
    var strXml = getXmlString(xmlDoc);
    ajaxCall(mstrUrl, strXml, 'ajaxRecieve', false);
}
function initMetaFilter()
{
    
    mobjSel1 = $(mstrSel1);
    mobjSel2 = $(mstrSel2);
    mobjSel3 = $(mstrSel3);
    mobjBtn = $(mstrBtn);

    mPreImg.src = mstrAppPath + '_themes/pleasewait.gif';
    mobjDiv.className = 'PreImg';
    mobjDiv.appendChild(mPreImg)

    mobjSel1.onchange = function(event) {
        if(this.selectedIndex==0)
        {
            mobjSel2.selectedIndex = 0;
            mobjSel3.selectedIndex = 0;
            mobjSel2.options.length = 1;
            mobjSel3.options.length = 1;            
            return;   
        }
        mobjSel2.options.length = 1;
        mobjSel3.options.length = 1;
        mstrKeyword1 = this.options[this.selectedIndex].value;  
        mstrKeyword3 = '';      
        if(mstrKeyword2!='')
        {
            mstrLast2 = mstrKeyword2;

        }
        mstrKeyword2 = '';
        

        map.closeInfoWindow();
        generateXmlForAjax(mstrKeyword1, '');

        //    generateXmlForAjax(mstrKeyword1, mstrLast2);        

    }
    
    mobjSel2.onchange = function(event) {
        mobjSel3.options.length = 1;

        mstrKeyword3 = '';
        if(this.selectedIndex==0)
        {
            return;    
        }
        mstrKeyword2 = this.options[this.selectedIndex].value;
        mstrLast2 = mstrKeyword2;
        map.closeInfoWindow();
        generateXmlForAjax(mstrKeyword1, mstrKeyword2);

    }
    
    mobjSel3.onchange = function(event) {
        mstrKeyword3 = this.options[this.selectedIndex].value;
        map.closeInfoWindow();
    }

    mobjBtn.onclick = function(event) {
        if(mobjSel1.selectedIndex==0)
        {
            alert('You must select a Region');
            mobjSel1.focus();
            return; 
        }
		/*
        if(mobjSel2.selectedIndex==0)
        {
            alert('You must select a County');
            mobjSel2.focus();
            return; 
        }*/
        hideElements();
        window.setTimeout("LoadMap()",10);
    }
	
     generateXmlForAjax('', ''); 
	 
	
	if(mstrKeyword1!='')
	{
	 
	 hideElements();
	 generateXmlForAjax(mstrKeyword1, '');
	 window.setTimeout("LoadMap()",10);
	 
	 
	}
	 
	/*

    
    
    if(mstrKeyword1 != '' && mstrKeyword2 != '')
    { 

        generateXmlForAjax(mstrKeyword1, '');

        hideElements();
        
        generateXmlForAjax(mstrKeyword1, mstrKeyword2);
        
        window.setTimeout("LoadMap()",10);
    }    
    else if(mstrKeyword1 == '' && mstrKeyword2 == '')
    {
        mstrKeyword1 = '';
        switch(mstrAppPathComplete)
        {
            default : 
                mstrKeyword2 = '';
                break;

        }
        generateXmlForAjax(mstrKeyword1, '');
        
        hideElements();
        
        mstrLast2 = mstrKeyword2;
        
	if(mstrKeyword2!='')
	{
        	generateXmlForAjax(mstrKeyword1, mstrKeyword2);
	}        
        window.setTimeout("LoadMap()",10);
    }
	
	*/
}
function hideElements()
{

    mobjBtn.disabled = true;
    mobjBtn.innerHTML = 'Loading';
    document.body.style.cursor = 'wait';
    
    mobjSel1.disabled = true;
    mobjSel2.disabled = true;
    mobjSel3.disabled = true;
    
    //$('mapcont').style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=40)';


    formDisable(true);
    
    var formDis = $('divMainProtect');

    formDis.appendChild(mobjDiv); 
    
}
function showElements()
{
    mobjBtn.innerHTML = 'Display';
    mobjBtn.disabled = false;
    document.body.style.cursor = 'default';
    
    mobjSel1.disabled = false;
    mobjSel2.disabled = false;
    mobjSel3.disabled = false;
    
    //$('mapcont').style.filter = '';
    
    formDisable(false);
    var formDis = $('divMainProtect');
    formDis.removeChild(mobjDiv);     
    
}
function LoadMap()
{
	var strKeyword1 = mstrKeyword1;
	var strKeyword2 = mstrKeyword2;
	var strKeyword3 = mstrKeyword3;

    var blnReset = false;
    var blnFilter = false;
    
    if(strKeyword3!='')
    {
        if(mstrKeyword2!=mstrLastLoadCountry)
        {
            blnReset = true;
            blnFilter = true;
        }
    }
    else
    {
        blnReset = true;
    }
    
	mstrLastLoadCountry = mstrKeyword2;    

    if(!blnFilter)
    {
        xmlFile = mstrAppPath + 'metadata/' + mstrTagFilename + '?column1=' + mstrColumn1 + '&keyword1=' + encodeURI(mstrKeyword1) + '&column2=' + mstrColumn2 +  '&keyword2=' + encodeURI(mstrKeyword2) + '&column3=' + mstrColumn3 +  '&keyword3=' + encodeURI(mstrKeyword3);
        initGmap(true, blnReset);
    }
    else
    {
        // country selection is different, load country data
        xmlFile = mstrAppPath + 'metadata/' + mstrTagFilename + '?column1=' + mstrColumn1 + '&keyword1=' + encodeURI(mstrKeyword1) + '&column2=' + mstrColumn2 +  '&keyword2=' + encodeURI(mstrKeyword2);
        initGmap(true, blnReset);
        //filter country to selected region
        xmlFile = mstrAppPath + 'metadata/' + mstrTagFilename + '?column1=' + mstrColumn1 + '&keyword1=' + encodeURI(mstrKeyword1) + '&column2=' + mstrColumn2 +  '&keyword2=' + encodeURI(mstrKeyword2) + '&column3=' + mstrColumn3 +  '&keyword3=' + encodeURI(mstrKeyword3);
        initGmap(true, false);
    }

    strKeyword1 = (strKeyword1!='')?strKeyword1:'NULL';
    strKeyword2 = (strKeyword2!='')?strKeyword2:'NULL';
    strKeyword3 = (strKeyword3!='')?strKeyword3:'NULL';
    
    mobjGMTagRepeater.ResultsLoadedEvent = 'GotoTop()'; 
    
    mobjGMTagRepeater.loadResults('', strKeyword1, strKeyword2, strKeyword3);
    
    window.setTimeout("showElements()", 10);
}





function GotoTop()
{
    document.location.href='#top'; //'#listings';   
}

function ajaxRecieve(objResponse)
{

	var xmlAjax = objResponse.getElementsByTagName('result')[0];
	var intStatus = GetXmlNodeText(xmlAjax.getElementsByTagName('status')[0]);
	var strErrorMessage = GetXmlNodeText(xmlAjax.getElementsByTagName('error_message')[0]);
	
	try
	{
		if(intStatus != 0)
		{
			raiseMessage('stoperror', strErrorMessage, '');
		}
		else
		{


            var arrValues1 = xmlAjax.getElementsByTagName('Value1');
            var arrValues2 = xmlAjax.getElementsByTagName('Value2');
            var arrValues3 = xmlAjax.getElementsByTagName('Value3');
            var blnFirst = true;
            if(mobjSel1.options.length>1)
            {
                blnFirst = false;   
            }
            
            for (var intIndex = 0 ; intIndex < arrValues1.length ; intIndex++) 
            {
                  
    			var strValue1 = GetXmlNodeText(arrValues1[intIndex]);
    			var strValue2 = GetXmlNodeText(arrValues2[intIndex]);
    			var strValue3 = GetXmlNodeText(arrValues3[intIndex]);

                if((strValue1!='') && (strValue2=='') && blnFirst)
                {
                   mobjSel1.options[mobjSel1.options.length] = new Option(strValue1, strValue1);
               
                }
                else if((strValue2!='' && strValue3==''))
                {
                   mobjSel2.options[mobjSel2.options.length] = new Option(strValue2, strValue2);
                }
                else if(strValue3!='')
                {
                   mobjSel3.options[mobjSel3.options.length] = new Option(strValue3, strValue3);
                }
    
            }


                for(i=0;i<mobjSel1.options.length;i++)
                {
                    if(mobjSel1.options[i].value.toLowerCase() == mstrKeyword1.toLowerCase())
                    {
                            mobjSel1.selectedIndex = i;
                    }
                }

                for(i=0;i<mobjSel2.options.length;i++)
                {
                    //if(mstrKeyword2 == '' && mstrLast2 != '')
                    //{
                        if(mobjSel2.options[i].value.toLowerCase() == mstrLast2.toLowerCase())
                        {
                            mobjSel2.selectedIndex = i;
                        }
                    //}
                    else if(mobjSel2.options[i].value.toLowerCase() == mstrKeyword2.toLowerCase())
                    {
                            mobjSel2.selectedIndex = i;
                    }
                }        

		}
	}
	catch(ex) {}
}

//addEvent(window, 'load', initMetaFilter, false);
Event.observe(document, 'dom:loaded', initMetaFilter);


//-End Section -_wood-metafilter.js-\\

//-End File