// JScript source code
var point;
var map;
var m;
var ctryArr=[]; 
 var busnameArr=[]; 
 var bustypeArr=[];
 var busidArr=[]; 
 var bustelArr=[]; 
 var buswebArr=[]; 
 var bustownArr=[];  
 var buslatArr=[]; 
 var buslonArr=[]; 
 var gmarkers = [];
 var side_bar_html = "";
 var htmls = []; 
 var maxhtmls = [];
 var to_htmls = [];
 var from_htmls = [];
 var int_bus_cnt ;
var gdir;
var saddr;
var daddr;
 var strhtml = [];
 var dbl_lat = 0;
 var dbl_lon = 0;
 var dbl_lev = 0;
 var dblLev;
 var dbl_prev_lev = 1;
 var dbl_mapCenLat = 0;
 var dbl_mapCenLon = 0;
var _mFlags={};
var j=0;
var i=0;
var html_1;
var html_2;
var html_3;

var str_htmlCAD;
var str_htmlMAP;
var str_htmlC3D;
var str_html_loc=[]; 
var str_html_loc_2; 
var str_html_loc_3; 
//"Digital Media Centre<br>County Way<br>Barnsley<br>South Yorkshire<br>S70 2HG<br><b>Tel:</b> 01226 720 700"
//http://www.oxin.co.uk/centre/portsmouth#portsmouth-travel-info
str_html_loc[0] = "<h1>W'boro Innovation Centre</h1><br>Church Street<br>Wellingborough<br>Northamptonshire<br>NN8 4PD<br><b>Tel:</b> 01933 303034<br>Web:<a href='http://www.oxin.co.uk/centre/wellingborough#wellingborough-travel-info' target='_blank'>www.oxin.co.uk/centre/wellingborough</a>";
str_html_loc[1] = "<h1>Silverstone Innovation Centre</h1><br>Silverstone Circuit<br>Silverstone<br>Northamptonshire<br>NN12 8GX<br><b>tel</b>: 01327 856000<br>Web:<a href='http://www.oxin.co.uk/centre/silverstone#silverstone-travel-info' target='_blank'>www.oxin.co.uk/centre/Silverstone</a>";
str_html_loc[2] = "<h1>Autodesk Offices</h1><br>Farnborough<br>1 Meadow Gate Avenue<br>Farnborough Business Park<br>Farnborough<br>GU14 6FG<br><b>Tel:</b> 01252 456 600<br>Web:<a href='http://www.autodesk.co.uk' target='_blank'>www.autodesk.com</a>";
str_html_loc[3] = "<h1>National Railway Museum</h1><br>Leenman Road<br>York<br>YO26 4XJ <br><b>tel:</b> 08448 153139<br>Web:<a href='http://www.nrm.org.uk/home/home.asp' target='_blank'>www.nrm.org.uk</a>";
//str_html_loc[2] = "<h1>Adelphi Centre</h1><br>Glasgow<br>12 Commercial Road<br>Glasgow<br>G5 0PQ<br><b>Tel:</b> 0141 429 6006 <br>Web:<a href='http://www.adelphicentre.org/index.htm' target='_blank'>www.adelphicentre.org</a>";
str_html_loc[4] = "<h1>Portsmouth Technopole</h1><br>Leenman Road<br>York<br>YO26 4XJ <br><b>tel:</b> 08448 153139<br>Web:<a href='http://www.oxin.co.uk/centre/portsmouth#portsmouth-travel-info' target='_blank'>www.oxin.co.uk/centre/portsmouth</a>";
str_html_loc[5] = "<h1>Bristol Zoo Gardens</h1><br>Clifton<br>Bristol<br>BS8 3HA<br><b>tel:</b> 0117 974 7300<br>Web:<a href='http://www.bristolzoo.org.uk/' target='_blank'>www.bristolzoo.org.uk</a>";
str_html_loc[6] = "<h1>National Space Centre</h1><br>Exploration Drive<br>Leicester<br>LE4 5NS<br><b>&nbsp;</b> <br>Web:<a href='http://www.spacecentre.co.uk/' target='_blank'>www.spacecentre.co.uk</a>";
str_html_loc[7] = "<h1>Scotch Whisky Heritage Centre</h1><br>354 Castlehill<br>Edinburgh<br>EH1 2NEA<br><b>tel:</b> 0131 220 0441<br>Web:<a href='http://www.scotchwhiskyexperience.co.uk/index.html' target='_blank'>www.scotchwhiskyexperience.co.uk</a>";
str_html_loc[8] = "<h1>Key-Systems Offices</h1><br> Systems House<br> Burnt Meadow Road<br> Moons Park<br> Redditch Worcestershire<br> B98 9PA<br><b>tel:</b> 01527 68888<br>Web:<a href='#' target='_blank'></a>";

function fnc_load_map()
{
    var str_url = new String(window.location);
    //str_url = window.location;
    
   if(str_url.length > 1)
 //   alert(str_url.length);
        str_map = str_url.substring(str_url.length-1);
//    alert(str_map);
    if (str_map =="m")
    {
        fnc_load(51.0396, -0.3342, 11);
    }


}
function fnc_load(dbl_lat, dbl_lon, int_lev, str_map) {
    side_bar_html = "<div id='fform'><fieldset><legend class='legendh2'>Destinations</legend><span class='howtouse'>Here are some suggested Honeymoon destinations. Click a location below for more details</span><div id='mnu_flow'><ul id='vert-nav'>";
    dbl_lat=parseFloat(dbl_lat);
	dbl_lon=parseFloat(dbl_lon);
	int_lev=parseInt(int_lev);
 
//ert("load");
// top.topFrame.hdLat.value="<%= request("lat")%>";
//top.topFrame.hdLon.value="<%= request("lon")%>";
// top.topFrame.hdLev.value="<%= request("scale")%>";
      if (GBrowserIsCompatible()) {
//alert(document.body.clientHeight);
//alert(window.innerHeight);

		var m = document.getElementById("map");
		var mapObj = document.getElementById("map");
//		m.style.height = (window.innerHeight-250) + "px";
//alert (m.style.height);		
		//m.style.width = document.body.clientWidth/1.5 + "px";
		//m.style.height = (document.body.clientHeight-300) + "px";
	//	m.style.width = "400px";

        map = new GMap2(m);
        map.addControl(new GLargeMapControl(),  new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(1, 1)));
	//	map.addControl(new GOverviewMapControl()); 
       gdir=new GDirections(map, document.getElementById("directions"));
   //  ======== Add a map overview ==========
      map.addControl(new GOverviewMapControl(new GSize(75,75)));

      //  ======== A function to adjust the positioning of the overview ========


      //  ======== Cause the overview to be positioned AFTER IE sets its initial position ======== 
      setTimeout("positionOverview(58,54)",1);

   // }

       
             //var gdir=new GDirections(map, document.getElementById("directions"));

      // === Array for decoding the failure codes ===
      var reasons=[];
      reasons[G_GEO_SUCCESS]            = "Success";
      reasons[G_GEO_MISSING_ADDRESS]    = "Missing Address: The address was either missing or had no value.";
      reasons[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address:  No corresponding geographic location could be found for the specified address.";
      reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
      reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
      reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
      reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
      reasons[G_GEO_BAD_REQUEST]        = "A directions request could not be successfully parsed.";
      reasons[G_GEO_MISSING_QUERY]      = "No query was specified in the input.";
      reasons[G_GEO_UNKNOWN_DIRECTIONS] = "The GDirections object could not compute directions between the points.";

      // === catch Directions errors ===
      GEvent.addListener(gdir, "error", function() {
        var code = gdir.getStatus().code;
        var reason="Code "+code;
        if (reasons[code]) {
          reason = reasons[code]
        } 

        alert("Failed to obtain directions, "+reason);
      });


       // map.addControl(new GMapTypeControl(),  new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(20, 5)));
	//   map.addControl(new GScaleControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(20, 5)));
       map.setCenter(new GLatLng(dbl_lat, dbl_lon), int_lev); // Shefford
 //map.setCenter(new GLatLng(55.5419, -4.2419), 5); // national UK

        map.enableDoubleClickZoom() ;

        function createMarker(point) {

            alert("here");
	var icon = new GIcon();
//icon.image="none";
icon.iconSize=new GSize(24,24);
   icon.shadowSize=new GSize(32,32);
   icon.iconAnchor=new GPoint(12,12);
   icon.infoWindowAnchor=new GPoint(12,12);
       
        var marker = new GMarker(point, {icon: icon, title:'x'});
 return marker;
      }
	  	  
//		var point = new GLatLng(dbl_lat, dbl_lon);
//		var marker = createMarker(point);
	
//  		map.addOverlay(marker);
//  		if (str_map =="hm")
//  		{
//  		html ="<div style='width:325px; height: 50%;'><h4 class='hdr_infowindow'>Quick Instructions</h4><ul style='width: 300px; text-align: left;'><li>Click the aeroplane icon on the map for more details.</li><br><li>Alternatvely, click the destination in the list opposite.</li><br><br><li>Double click <b>left</b> mouse button to Zoom In</li><br><li>Double click <b>right</b> mouse button to Zoom Out</li><br/></ul><a id='ft' href=javascript:map.getInfoWindow().maximize();> Read more...></a><p>Click the map to hide this message</p></div>";
//		}
//		else
//		{
//html ="<div style='width:325px; height: 50%;'><h4 class='hdr_infowindow'>Quick Instructions</h4><ul style='width: 300px; text-align: left;'><li>1.&nbsp;Choose your <b>Region</b> of interest</li><br><li>2.&nbsp;<b>Display Businesses</b> of interest</li><br><br><li>Double click <b>left</b> mouse button to Zoom In</li><br><li>Double click <b>right</b> mouse button to Zoom Out</li><br/></ul><a id='ft' href=javascript:map.getInfoWindow().maximize();> Read more...></a><p>Click the map to hide this message</p></div>";		
//		}
		
	//	maxhtml = "./gm_instructions.htm";
	//	marker.openInfoWindowHtml(html, {maxUrl: maxhtml});

  }

			//BEGIN SCROLL-WHEEL ZOOM CODE

			GMap2.prototype.wheelZoom = function(event) { 
			        if(event.cancelable) { 
			                event.preventDefault(); 
			        } 
			        if((event.detail || -event.wheelDelta) < 0) { 
			                zoom('in'); 
			        } else { 
			                zoom('out'); 
			        } 
			        return false;
			} 

			GEvent.addDomListener(mapObj, "DOMMouseScroll", map.wheelZoom); 
			GEvent.addDomListener(mapObj, "mousewheel", map.wheelZoom); 
			GEvent.addListener(map, "mousemove", 
			        function(point) { 
			                mouselat = point.y.toFixed(6); 
			                mouselng = point.x.toFixed(6); 
			                //you can stick these into a div somewhere to show the current position 
			        } 
			); 

			function zoom(a) { 
			        var m = map.fromLatLngToDivPixel(new GLatLng(mouselat,mouselng)); 
			        var c = map.fromLatLngToDivPixel(map.getCenter()); 
			        if (a == 'in') { 
			                var x = c.x - ((m.x - c.x) * -.5); 
			                var y = c.y - ((m.y - c.y) * -.5); 
			                var n = map.fromDivPixelToLatLng(new GPoint(x,y)); 
			                map.setCenter(n); 
			                map.zoomIn(); 
			        } else { 
			                var x = c.x - (m.x - c.x); 
			                var y = c.y - (m.y - c.y); 
			                var n = map.fromDivPixelToLatLng(new GPoint(x,y)); 
			                map.setCenter(n); 
			                map.zoomOut(); 
			        }
			}

			//END SCROLL-WHEEL ZOOM CODE

      function positionOverview(x,y) {
        var omap=document.getElementById("map_overview");
   //    omap.style.left = x+"px";
    //    omap.style.top = y+"px";
//        
        //// == restyling ==
        omap.firstChild.style.border = "1px solid gray";
//
        omap.firstChild.firstChild.style.left="2px";
        omap.firstChild.firstChild.style.top="2px";
        omap.firstChild.firstChild.style.width="40px";
        omap.firstChild.firstChild.style.height="40px";
        omap.secondChild.secondChild.style.left="24px";
      }

GEvent.addListener(map, "click", function(marker, point){ 
  if (!marker) { 
    map.closeInfoWindow(); 
  } 


}); 

	  
}  


//------------------------------------------------------------------------------
// function: fnc_zoom_region()
// zooms to the selected map region
//------------------------------------------------------------------------------
function fnc_zoom_region()
{
//alert("here in zm reg");
	var str_loc = "";
	for (i = 0; i < document.frm_region.sel_regions.length; i++)
	{
		if (document.frm_region.sel_regions[i].selected)
		{

		str_loc = document.frm_region.sel_regions[i].value;

		intposLon = str_loc.indexOf('lon');
		dblLat = str_loc.substring(5,intposLon-1);
		intposLev = str_loc.indexOf('scale');
		dblLon = str_loc.substring(intposLon+4, intposLev-1);
		dblLev = str_loc.substring(intposLev+6);
		fnc_zoom(dblLat, dblLon, dblLev);
		}
		
	}	
}

//*****************************************************************************
// function: fnc_zoom(dblLat,dblLon, dblLev)
// accepts lat & lon and zoom level values 
//*****************************************************************************
function fnc_zoom(dblLat,dblLon, dblLev)
{
dbl_prev_lev = map.getZoom();
//alert("map get zopom " + dbl_prev_lev);
//var pnt = new GLatLng
 dbl_mapCenLat = map.getCenter().lat();
  dbl_mapCenLon = map.getCenter().lng();
 dbl_mapLev = map.getZoom();  
//alert(dblLat + ": " +  dblLon + ":" + dbl_prev_lev);
	dblLat=parseFloat(dblLat);
	dblLon=parseFloat(dblLon);
	dblLev=parseInt(dblLev);
	map.setCenter(new GLatLng(dblLat, dblLon), dblLev);
}

//****************************************************************************
// eof fnc_zoom
//*****************


//*****************************************************************************
// function: fnc_zoom(dblLat,dblLon, dblLev)
// accepts lat & lon and zoom level values 
//*****************************************************************************
function fnc_zoom_find(dblLat,dblLon, dblLev)
{
dbl_prev_lev = map.getZoom();
//alert("map get zopom " + dbl_prev_lev);
//var pnt = new GLatLng
 dbl_mapCenLat = map.getCenter().lat();
  dbl_mapCenLon = map.getCenter().lng();
 dbl_mapLev = map.getZoom();  
//alert(dblLat + ": " +  dblLon + ":" + dbl_prev_lev);
	dblLat=parseFloat(dblLat);
	dblLon=parseFloat(dblLon);
	dblLev=parseInt(dblLev);
	map.setCenter(new GLatLng(dblLat, dblLon), dblLev);
	
	// alert(top.document.form1.chk_layer_type[0].name);
	 //   alert(top.document.form1.chk_layer_type.length);
	    var theone;
        for (i=0;i<top.document.form1.chk_layer_type.length;i++){
            if (top.document.form1.chk_layer_type[i].checked==true){
            theone=i;
            parent.document.form1.chk_layer_type[i].click();
            break //exist for loop, as 
            }
        }    
}

//****************************************************************************
// eof fnc_zoom
//*****************




//*****************************************************************************
// function: fnc_zoom_in()
// accepts lat & lon and zoom level values 
//*****************************************************************************
function fnc_zoom_in(int_lev)
{
dbl_prev_lev = map.getZoom();

//get marker location
//alert("map get zopom " + dbl_prev_lev);
//var pnt = new GLatLng
 //dblLat = marker.getPoint().lat();
 //dblLon = marker.getPoint().lng(); 
 //alert("here");
 //dbl_mapCenLat = marker.getPoint().lat();
 //dbl_mapCenLon = marker.getPoint().lng(); 
 
 //dblLat = map.getZoom(); 
 //dblLon = map.getZoom(); 
 
 dbl_mapCenLat = dblLat; 
 dbl_mapCenLon = dblLon;
  
 dblLev = dbl_mapLev + 1;

	dblLat=parseFloat(dblLat);
	dblLon=parseFloat(dblLon);
	dblLev=parseInt(int_lev);
	map.setCenter(new GLatLng(dblLat, dblLon), dblLev);
	marker=map.getInfoWindow();
map.closeInfoWindow();
//gmarkers[i].openInfoWindowHtml(htmls[i], {maxUrl: maxhtmls[i]});
// open the info window again

}

//****************************************************************************
// eof fnc_zoom
//*****************


function fnc_mapnotice(int_cnt,html)
{

//' get map center
    dblLat = map.getCenter().lat();
    dblLon = map.getCenter().lng();
    point = new GLatLng(dblLat, dblLon);
    dblLev = map.getZoom();
    if (dblLev > 7)
    {
     dblLev = dblLev - 3;
    }
    else
    {
    dblLev = 5;
    dblLat = 53.348;
    dblLon = -1.459;
    } 
    var icon = new GIcon();
str_business_type = "none";

 	var marker = createMarker(point,{icon: icon});
//	var marker = new GMarker(point, );
 //return marker;
  		map.addOverlay(marker);
  		html = html + "<div style='width:325px; height: 120px;'><h4 class='hdr_infowindow'>No Businesses Registered</h4><p>There are no businesses registered with your search category in the current map extents. </p></ul></div>";
		html = html + "</div><div id='zoom_bar'> <a href= javascript:fnc_zoom_find(" + dblLat + "," + dblLon + "," + dblLev + ");>Zoom out and search again?</a>";
html = html + "<br /></div>";

		maxhtml = "./gm_instructions.htm";
		marker.openInfoWindowHtml(html);
		


}



//*****************************************************************************
// function: fnc_addPoint(dblLat,dblLon, str_business_name, str_business_type)
// accepts lat & lon values as well as business name, and business type
// - icon changes depending on business type
//*****************************************************************************

      // ==================================================
      // A function to create a tabbed marker and set up the event window
      // This version accepts a variable number of tabs, passed in the arrays htmls[] and labels[]
      function createTabbedMarker(point,htmls,labels, icon) {
          //  var marker = new GMarker(point);

         // alert(str_business_type);
          var icon = new GIcon();
          //
          //alert(str_business_type);

          switch (str_business_type) {
              case 'Web Directory':
                  icon.image = "./images/ico/sym_home.png";
                  break;
              case 'trn':
                  //alert("confernece");
                                    icon.image = "./images/icons/ico_trn.png";
                  //icon.image = "http://maps.google.com/mapfiles/kml/pal3/icon19.png ";

                  break;
              case 'none':
                  // str_business_type == "Venue";
                  icon.image = "none";
                  break;

              default:
                  //icon.image = "http://labs.google.com/ridefinder/images/mm_20.png";
                  icon.image = "./images/icons/ico_conf.png";

          }
          //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
          icon.iconSize = new GSize(27, 27);
          icon.shadowSize = new GSize(32, 32);
          icon.iconAnchor = new GPoint(12, 12);
          icon.infoWindowAnchor = new GPoint(12, 12);

str_tool_tip =  str_business_name;
//alert(str_tool_tip);
//var marker = new GMarker(point,{icon: icon, title:str_tool_tip});
var marker = new GMarker(point,{icon: icon, title:str_tool_tip});
        GEvent.addListener(marker, "click", function() {
          // adjust the width so that the info window is large enough for this many tabs
          if (htmls.length > 2) {
            htmls[0] = '<div style="width:300px">' + htmls[0] + '</div>';
          }
          var tabs = [];
          for (var i=0; i<htmls.length; i++) {
            tabs.push(new GInfoWindowTab(labels[i],htmls[i]));
          }
          marker.openInfoWindowTabsHtml(tabs);
        });
        return marker;
      }
      // ==================================================

function fnc_addPointEvent(int_cnt,dblLat,dblLon, str_type, str_location, str_id, str_sem_date1, str_sem_title1, str_sem_date2, str_sem_title2, str_sem_date3, str_sem_title3, str_infourl, str_tel, str_web)
{


html_start = "<div style='width:300px; height: auto;' >";
html_end = "</td></tr></table><i>Onsite courses and alternative dates available.<i></div>";

str_htmlCAD = html_start + "<table><tr><td class=tab_h2>AutoCAD/AutoCAD LT Refresher Course</td></tr>";
str_htmlCAD = str_htmlCAD + "<tr><td><b>Date:</b> 30th September - 1st October 2009<br>&nbsp;&nbsp;  &nbsp;&nbsp;3rd - 4th November 2009<b>Location:</b> Wellingborough<br><b>Details:</b> <a href=../pdf/training/TRN_AIT_ATC_ACAD_Refresher.pdf target=_blank>Course Details</a>";
str_htmlCAD = str_htmlCAD + html_end;

str_htmlMAP = html_start + "<table><tr><td class=tab_h2>AutoCAD Map Entry Level Workshop</td></tr> ";
str_htmlMAP = str_htmlMAP + "<tr><td><b>Date:</b> 13th October 2009<br><b>Location:</b> Wellingborough<br><b>Details:</b> <a href=./pdf/training/TRN_AIT_Map_Entry-Level_Workshop.pdf target=_blank>Course Details</a></td></tr>";
str_htmlMAP = str_htmlMAP + "<tr><td class=tab_h2>Learn AutoCAD Map 3D</td><tr><td><b>Date:</b> 27th -28th October 2009 <br><b>Location:</b> Wellingborough<br><b>Details:</b> <a href=http://www.aitspatial.co.uk/training.cfm?id=37&pg=1 >Course Details</a>";
str_htmlMAP = str_htmlMAP + html_end;



str_htmlC3D = html_start + "<table><tr><td class=tab_h2>Learn AutoCAD Civil 3D</td></tr> ";
str_htmlC3D = str_htmlC3D + "<tr><td><b>Date:</b> 19th - 21st October 2009<br><b>&nbsp;&nbsp;  &nbsp;&nbsp;</b> or 23rd - 25th November 2009<br><b>Location:</b> Wellingborough<br><b>Details:</b> <a href=http://www.aitspatial.co.uk/training.cfm?id=30&pg=1 >Course Details</a></td></tr>";
str_htmlC3D = str_htmlC3D + html_end;


///alert(int_cnt);
j = int_cnt;
 busnameArr[j]=str_location; 
 bustypeArr[j]=str_type; 
 busidArr[j]=str_id; 
 bustelArr[j]=str_tel; 
 bustownArr[j]=str_sem_date1;
 buswebArr[j]=str_web; 
 buslatArr[j]=dblLat;
 buslonArr[j]=dblLon;
 //var m = document.getElementById("map");
  //map = new GMap2(m);
// alert(busidArr[j]);
//alert("add pnt: " + dblLat + ", " + dblLon + "; " + str_type + " ; " + str_location + "; " + str_id);
 point = new GLatLng(dblLat, dblLon);
str_business_type = str_type;
str_business_name = str_location;
//alert(str_business_name + " is a " + str_business_type);
		int_bus_cnt++;

			str_name = str_business_name;
			//alert("here is the name " + str_name);
infourl = "inc/" + str_infourl;
//alert(infourl);
html = "<div style='width:300px; height: auto;' >";
html = html + "<h1>" + str_sem_title1 + "</h1>"


html= html + "<table cellspacing=5 cellpadding=5><tr>";
/*
if (str_infourl != "-" && str_infourl != "")
{
    html = html + "<p class='strap_line'>" + str_infourl + "</p>";
}
html = html + "<ul id='infowindow'>";
if (str_tel != '-')
{
    html = html +  "<li  class='tel'>" + str_tel + "</li><br/>";
}
*/
if (str_business_type != 'xm')
{
	//html_1 = html + "  <tr><td align='right'>" + str_sem_date1 + "</td><td align='left'>" + str_sem_title1 + "</td>";
	html_1 = html + "  <tr><td><b>Date: </b>" + str_sem_date1 + "</td>";
	html_1 = html_1 + "  <td align='right'>" + str_sem_date2 + "</td></tr>";
	//html_1 = html_1 + "  <tr><td align='right'>" + str_sem_date3 + "</td><td align='left'>" + str_sem_title3 + "</td></tr>";
	html_1= html_1 + "</tr></table>";
// remove the comment below when seminars are scheduled
	//
	//html_1 = html_1 + "<p class='pdf'><a href='" + str_web + "' target='_blank'>" + " Seminar Brochure </a> <span>&nbsp; &nbsp; &nbsp;</span><a href=mailto:info@a-i-t.co.uk?Subject=" + str_location + "-Seminar>Email to Register</a></p>";
	html_1 = html_1 + "<p class='pdf'><a href='" + str_tel + "' target='_blank'>" + " Agenda </a> <span>&nbsp; &nbsp; &nbsp;</span><a href='" + str_web + "' target='_blank'>" + " Click to Register</a></p></p>";
	//html_1 = html_1 + "<p><a href='" + str_web + "' target='_blank'>" + " Click to Register</a></p>";

}
else
{
  html = html + "  <li class='addr'>" + str_sem_date1 + "</li><br/>";
}
//alert(str_web);
if (str_web != ''){
str_web = "<a href='include/referrer.asp?url=http://" + str_web + "&bid=" + str_id + "' target='_blank'>" + str_web + "</a>";
//alert(str_web);
html = html + " <li class='web'>" + str_web + "</li>";
}
else
{
html = html + " <li></li>";
}
//alert("here");
if (str_business_type != 'honeymoon')
{
//alert(html);
html = html + "<iframe height=0 width=0 src='include/referrer.asp?cid=" + str_id + "' frameborder=0 visible=false'></iframe>";
}
//alert(html);
html = html + "<br/></ul><a id='ft' href=javascript:map.getInfoWindow().maximize();> Read morex...></a><p></p><div id='bubble_bot'>&nbsp;</div>";
if (str_business_type == 'honeymoon')
{
html = html + "<div id='zoom_bar'> <a href= javascript:fnc_zoom_in(9);><img name='img_zm' src='./images/ico/zoom_in_24x24_t.gif' border=0 width='24' height='24' alt='Click to zoom in'/></a>";
html = html + "<a href= javascript:fnc_zoom_prev();><img name='img_zmp' src='./images/ico/zoom_prev_24x24_t.gif' border=0 width='24' height='24' alt='Click to return to the previous view'/></a><br /></div>";
}
//alert(html);
//alert(infourl);

	
	    
    //  var point = new GLatLng(53.82589,-0.10040);
	i = j-1;
	//alert(j);
	var marker = createTabbedMarker(point, [html_1, str_html_loc[i]], ["Event","Location"]);
      map.addOverlay(marker);
      
/*      var point = new GLatLng(53.72589,-0.8);
      var marker = createTabbedMarker(point, ["Tab 1 contents", "Tab 2 contents","Tab 3 contents","Tab 4 contents"],["One","Two","Three","Four"]);
      map.addOverlay(marker);
      
      var point = new GLatLng(53.65654,-0.90138);
      var marker = createTabbedMarker(point, ["is the time for all good men<br>to come to the aid of the party", "a dangerous temptation comes to us<br>in gay, fine colours"],["Now", "Many"]);
      map.addOverlay(marker);

      var point = new GLatLng(53.8,-0.3);
      var marker = createTabbedMarker(point, ["This marker has no tabs"],["Nothing"]);
      map.addOverlay(marker);
	
	*/
	
	
}
//****************************************************************************
// eof fnc_addPointEvent
//*****************

function fnc_addPointTraining(int_cnt, dblLat, dblLon, str_type, str_location, str_id, str_sem_date1, str_sem_title1, str_sem_date2, str_sem_title2, str_sem_date3, str_sem_title3, str_infourl, str_tel, str_web) {


    html_start = "<div style='width:300px; height: auto;' >";
    html_end = "</td></tr></table><i>Onsite courses and alternative dates available.<i></div>";


    str_htmlCAD = html_start + "<table cellpadding=1 cellspacing=1 width=250><tr><td class=tab_h2 colspan=2>Learn AutoCAD/AutoCAD LT</td></tr>";
    str_htmlCAD = str_htmlCAD + "<tr><td width= 30%><b>Date:</b><td> Contact Us <br></td></tr><tr><td><b>Details:</b></td><td> <a  class='' href=./training.cfm?id=35&pg=1 target=_blank>Course Details</a>";
    str_htmlCAD = str_htmlCAD + html_end;

    str_htmlMAP = html_start + "<table cellpadding=1 cellspacing=1 width=250>";
    str_htmlMAP = str_htmlMAP + "<tr><td class=tab_h2 colspan=2>Learn AutoCAD Map 3D</td><tr><td width=25%><b>Date:</b></td><td>11th & 12th October<br>22nd & 23rd November</td></tr><tr><td><b>Details:</b></td><td> <a class=pdf href=./pdf/training/TRN_AIT_Map_Entry-Level_Workshop.pdf target=_blank >Course Details</a>";
    //str_htmlMAP = str_htmlMAP + "<tr><td class=tab_h2 colspan=2>OS MasterMap Management Workshop</td></tr> ";
    //str_htmlMAP = str_htmlMAP + "<tr><td width= 30%><b>Date:</b></td><td>Contact Us</td></tr><tr><td><b>Details:</b> </td><td><a href=./training.cfm?id=25&pg=1 target=_blank>Course Details</a></td></tr>";
    
    str_htmlMAP = str_htmlMAP + html_end;



    str_htmlC3D = html_start + "<table cellpadding=1 cellspacing=1 width=250><tr><td class=tab_h2 colspan=2>Learn AutoCAD Civil 3D</td></tr> ";
    str_htmlC3D = str_htmlC3D + "<tr><td width=30%><b>Date:</b></td>1st - 3rd November<br>6th - 8th December</td></tr><tr><td><b>Details:</b></td><td> <a href=http://www.aitspatial.co.uk/training.cfm?id=30&pg=1 target=_blank>Course Details</a></td></tr>";
    str_htmlC3D = str_htmlC3D + html_end;


  str_html_other = html_start + "<table cellpadding=1 cellspacing=1 width=250>";
  str_html_other = str_html_other + "<tr><td class=tab_h2 colspan=3>Autodesk MapGuide & Studio Essentials</td></tr>";
  str_html_other = str_html_other + "<tr><td width= 30%><b>Date:</b></td><td colspan=2>25th & 26th October<br>29th & 30th November</td></tr><tr><td><b>Details:</b> </td><td><a href=./training.cfm?id=36&pg=1 target=_blank >Course Details</a></td></tr>";
//  str_html_other = str_html_other + "</table>";
  str_html_other = str_html_other + "<tr><td class=tab_h2 colspan=3>Autodesk 3ds Max for Visualisation </td></tr> ";
  str_html_other = str_html_other + "<tr><td><b>&nbsp;Date:</b></td><td>&nbsp;Contact Us </td><td></td></tr>";
//  str_html_other = str_html_other + "<tr><td></td><td>&nbsp;6th - 10th Sept</td><td></td></tr>";
//  str_html_other = str_html_other + "<tr><td></td><td>&nbsp;1st - 5th Nov</td><td></td></tr>";
  str_html_other = str_html_other + "<tr><td><b>Details:</b></td><td> <a href=http://www.aitspatial.co.uk/training.cfm?id=38&pg=1 target=_blank>Course Details</a></td></tr>";
  //  str_html_other = str_html_other + "<tr><td>&nbsp;</td><td>&nbsp;8th Dec</td><td><a class=pdf href=../pdf/training/TRN_AIT_AU_Virtual_Classes_GIS_091009_dg_v2.pdf target=_blank>GIS</a></td></tr>";
   // str_html_other = str_html_other + "<tr><td>&nbsp;</td><td>&nbsp;11th Dec</td><td><a class=pdf href=../pdf/training/TRN_AIT_AU_Virtual_Classes_Programming_091009_dg_v2.pdf target=_blank>Programming</a></td></tr>";
    //str_html_other = str_html_other + "<tr><td><b>Location:</b></td><td colspan=2>Wellingborough</td></tr>";
    str_html_other = str_html_other + html_end;

    ///alert(int_cnt);
    j = int_cnt;
    busnameArr[j] = str_location;
    bustypeArr[j] = str_type;
    busidArr[j] = str_id;
    bustelArr[j] = str_tel;
    bustownArr[j] = str_sem_date1;
    buswebArr[j] = str_web;
    buslatArr[j] = dblLat;
    buslonArr[j] = dblLon;
    //var m = document.getElementById("map");
    //map = new GMap2(m);
    // alert(busidArr[j]);
    //alert("add pnt: " + dblLat + ", " + dblLon + "; " + str_type + " ; " + str_location + "; " + str_id);
    point = new GLatLng(dblLat, dblLon);
    str_business_type = str_type;
    str_business_name = str_location;
    //alert(str_business_name + " is a " + str_business_type);
    int_bus_cnt++;

    str_name = str_business_name;
    //alert("here is the name " + str_name);
    infourl = "inc/" + str_infourl;
    //alert(infourl);
    html = "<div style='width:300px; height: auto;' >";
    html = html + "<p class=tab_h2>" + str_sem_title1 + "</p>"


    html = html + "<table cellspacing=5 cellpadding=5><tr>";
    /*
    if (str_infourl != "-" && str_infourl != "")
    {
    html = html + "<p class='strap_line'>" + str_infourl + "</p>";
    }
    html = html + "<ul id='infowindow'>";
    if (str_tel != '-')
    {
    html = html +  "<li  class='tel'>" + str_tel + "</li><br/>";
    }
    */
    if (str_business_type != 'xm') {
        //html_1 = html + "  <tr><td align='right'>" + str_sem_date1 + "</td><td align='left'>" + str_sem_title1 + "</td>";
        html_1 = html + "  <tr><td colspan=2>" + str_htmlMAP + "</td>";
        //html_1 = html_1 + "  <tr><td align='right'>" + str_sem_date2 + "</td><td align='left'>" + str_sem_title2 + "</td></tr>";
        //html_1 = html_1 + "  <tr><td align='right'>" + str_sem_date3 + "</td><td align='left'>" + str_sem_title3 + "</td></tr>";
        html_1 = html_1 + "</tr></table>";
        // remove the comment below when seminars are scheduled
        //
        html_1 = html_1 + "<p class='pdf'><a href='" + str_web + "' target='_blank'>" + " Seminar Brochure </a> <span>&nbsp; &nbsp; &nbsp;</span><a href=mailto:info@a-i-t.co.uk?Subject=" + str_location + "-Seminar>Email to Register</a></p>";
    }
    else {
        html = html + "  <li class='addr'>" + str_sem_date1 + "</li><br/>";
    }
    //alert(str_web);
    if (str_web != '') {
        str_web = "<a href='include/referrer.asp?url=http://" + str_web + "&bid=" + str_id + "' target='_blank'>" + str_web + "</a>";
        //alert(str_web);
        html = html + " <li class='web'>" + str_web + "</li>";
    }
    else {
        html = html + " <li></li>";
    }
    //alert("here");
    if (str_business_type != 'honeymoon') {
        //alert(html);
        html = html + "<iframe height=0 width=0 src='include/referrer.asp?cid=" + str_id + "' frameborder=0 visible=false'></iframe>";
    }
    //alert(html);
    html = html + "<br/></ul><a id='ft' href=javascript:map.getInfoWindow().maximize();> Read morex...></a><p></p><div id='bubble_bot'>&nbsp;</div>";
    if (str_business_type == 'honeymoon') {
        html = html + "<div id='zoom_bar'> <a href= javascript:fnc_zoom_in(9);><img name='img_zm' src='./images/ico/zoom_in_24x24_t.gif' border=0 width='24' height='24' alt='Click to zoom in'/></a>";
        html = html + "<a href= javascript:fnc_zoom_prev();><img name='img_zmp' src='./images/ico/zoom_prev_24x24_t.gif' border=0 width='24' height='24' alt='Click to return to the previous view'/></a><br /></div>";
    }
    //alert(html);
    //alert(infourl);



    //  var point = new GLatLng(53.82589,-0.10040);
    i = j - 1;
    //alert(j);
    var marker = createTabbedMarker(point, [str_htmlCAD, str_htmlMAP, str_htmlC3D, str_html_other], ["AutoCAD/LT", "Map", "Civil 3D", "Other"]);
    map.addOverlay(marker);

    /*      var point = new GLatLng(53.72589,-0.8);
    var marker = createTabbedMarker(point, ["Tab 1 contents", "Tab 2 contents","Tab 3 contents","Tab 4 contents"],["One","Two","Three","Four"]);
    map.addOverlay(marker);
      
    var point = new GLatLng(53.65654,-0.90138);
    var marker = createTabbedMarker(point, ["is the time for all good men<br>to come to the aid of the party", "a dangerous temptation comes to us<br>in gay, fine colours"],["Now", "Many"]);
    map.addOverlay(marker);

      var point = new GLatLng(53.8,-0.3);
    var marker = createTabbedMarker(point, ["This marker has no tabs"],["Nothing"]);
    map.addOverlay(marker);
	
	*/


}
//****************************************************************************
// eof fnc_addPoint
//*****************



      
/*
      // Display the map, with some controls and set the initial location 
//      var map = new GMap2(document.getElementById("map"));
//      map.addControl(new GLargeMapControl());
//      map.addControl(new GMapTypeControl());
//      map.setCenter(new GLatLng(43.907787,-79.359741), 9);
    
      // ==================================================
      // Set up the tabbed markers
    
      var point = new GLatLng(43.82589,-79.10040);
      var marker = createTabbedMarker(point, ["Tab 1 contents", "Tab 2 contents","Tab 3 contents"],["One","Two","Three"]);
      map.addOverlay(marker);
      
      var point = new GLatLng(43.72589,-79.8);
      var marker = createTabbedMarker(point, ["Tab 1 contents", "Tab 2 contents","Tab 3 contents","Tab 4 contents"],["One","Two","Three","Four"]);
      map.addOverlay(marker);
      
      var point = new GLatLng(52.0730018616 ,-1.01645004749);
      var marker = createTabbedMarker(point, ["is the time for all good men<br>to come to the aid of the party", "a dangerous temptation comes to us<br>in gay, fine colours"],["Now", "Many"]);
      map.addOverlay(marker);

      var point = new GLatLng(43.8,-79.3);
      var marker = createTabbedMarker(point, ["This marker has no tabs"],["Nothing"]);
      map.addOverlay(marker);
      

    }

    

*/

      // A function to create the marker and set up the event window
function createMarkerxx(point,number,html) {
      //alert("create_marker");
   if (str_business_type =="honeymoon" )
    {
        maxhtml = "./rep_hm_detail.asp?ID=" + busidArr[number];
  
        dbl_lev = 9;
    }
    else
    {
	//alert("here");
    maxhtml = "./tooltip_v3.asp"; // + busidArr[number];
    dbl_lev=13;
    }
   //   maxhtml = "./rep_hm_detail.asp?ID=" + busidArr[number];
        htmls[j] = html;
        maxhtmls[j] = maxhtml;
       alert(maxhtml);
        
        // Our info window content
var icon = new GIcon();
//
//alert(str_business_type);

	switch(str_business_type)
	{
    case 'Web Directory':
			icon.image = "./images/ico/sym_home.png";
			break;									
    case 'g_rec':
            str_business_type == "Venue";
			icon.image = "./images/ico/sym_marquees_yel.png";
			break;				
	case 'none':
           // str_business_type == "Venue";
			icon.image = "none";
			break;				
	
		default:
			//icon.image = "http://labs.google.com/ridefinder/images/mm_20.png";
						icon.image = "http://maps.google.com/mapfiles/kml/pal3/icon19.png ";

	}			
	//icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon.iconSize=new GSize(27,27);
   icon.shadowSize=new GSize(32,32);
   icon.iconAnchor=new GPoint(12,12);
   icon.infoWindowAnchor=new GPoint(12,12);

// Place a marker in the center of the map and open the info window
// automatically
str_tool_tip =  str_business_name;
alert(str_tool_tip);
var marker = new GMarker(point,{icon: icon, title:str_tool_tip});
        if (str_business_type == "honeymoonx" ) // change operator
        {
                // The info window version with the "to here" form open
        to_htmls[j] = html + '<br>Directions: <b>To here</b> - <a href="javascript:fromhere(' + j + ')">From here</a>' +
           '<br>Start address:<form action="javascript:getDirections()">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
           '<input type="text" id="daddr" value="'+name+"@"+ point.lat() + ',' + point.lng() + 
           '"/>dest';
        // The info window version with the "to here" form open
        from_htmls[j] = html + '<br>Directions: <a href="javascript:tohere(' + j + ')">To here</a> - <b>From here</b>' +
           '<br>End address:<form action="javascript:getDirections()">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br>' +
           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
           '<input type="text" id="saddr" value="'+name+"@"+ point.lat() + ',' + point.lng() +
           '"/>start';
        // The inactive version of the direction info
        html = html + '<br/>Directions: <a href="javascript:tohere('+j+')">To here</a> - <a href="javascript:fromhere('+j+')">From here</a>';
//alert(html);
}
   //     GEvent.addListener(marker, "click", function() {
 //         marker.openInfoWindowHtml(html);
//        });

  //      var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          dblLat = marker.getPoint().lat();
  dblLon = marker.getPoint().lng();
  //alert(number);
          marker.openInfoWindowHtml(html, {maxUrl: maxhtmls[number]});
        });
    
        gmarkers[j] = marker;
     
        
        // ======= Add the sidebar entry to one of the sidebars =====
       side_bar_html += '<li><a class="hm" href="javascript:myclick(' + number + ')">' +  busnameArr[number] + '</a>&nbsp;</li>';
        side_bar_html[j] += side_bar_html;
        
        j++;
        return marker;
      }
      
      
//=========================================================================================================================================      
//****************************************************************************
// eof fnc_createMarker
//*****************
		

function fnc_getsidebar(){
        //side_bar_html = side_bar_html + "</ul></div></fieldset></div>";
        side_bar_html = side_bar_html + "</ul></div></fieldset></div>";
      // alert("sidebar" + side_bar_html);
          document.getElementById("sidebarx").innerHTML = side_bar_html;
}          

//****************************************************************************
// eof fnc_getsidebar
//*****************



//*****************************************************************************
// function: fnc_clear_overlay
// - clears existing map overlays
//************************************************************************
function fnc_clear_overlay()
{
	map.clearOverlays();
}
//****************************************************************************
// eof fnc_clear_overlay
//*****************



//*****************************************************************************
// function: fnc_zoom_prev
// - returns to previous zoom
//************************************************************************
function fnc_zoom_prev()
{
	dblLat=parseFloat(dbl_mapCenLat);
	dblLon=parseFloat(dbl_mapCenLon);
	dblLev=parseInt(dbl_prev_lev);
	//alert(dblLat + "  ,  " + dblLon + "  ,  " +dblLev);
	fnc_zoom(dblLat,dblLon,dblLev);
	map.closeInfoWindow();
}
//****************************************************************************
// eof fnc_zoom_prev
//*****************



  function myclick(i) {
  //i = i-1;
 // alert(i);
  
  dblLat = gmarkers[i].getPoint().lat();
  dblLon = gmarkers[i].getPoint().lng();
fnc_zoom(dblLat, dblLon, 4);
        gmarkers[i].openInfoWindowHtml(htmls[i], {maxUrl: maxhtmls[i]});
      }

//*****************************************************************************
// function: fnc_marker_click
// - opens the info window when sidebar object is clicked
//************************************************************************
function fnc_marker_click(j) {
alert("xx" + j);
alert(htmls[j]);
             gmarkers[j].openInfoWindowHtml(htmls[j]);
               //GEvent.trigger(gmarkers[j], "click");
      }

//****************************************************************************
// eof fnc_addPoint
//*****************



      // ===== request the directions =====
      function getDirections() {
      alert("from: " + document.getElementById("saddr").value + " to : " + document.getElementById("daddr").value);
        saddr = document.getElementById("saddr").value
        daddr = document.getElementById("daddr").value
        gdir.load("from: "+saddr+" to: "+daddr);
      }

      // functions that open the directions forms
      function tohere(i) {
        gmarkers[i].openInfoWindowHtml(to_htmls[i]);
      }
      function fromhere(i) {
        gmarkers[i].openInfoWindowHtml(from_htmls[i]);
      }


      // create the map
//      var map = new GMap2(document.getElementById("map"));
 //     map.addControl(new GLargeMapControl());
 //     map.addControl(new GMapTypeControl());
 //     map.setCenter(new GLatLng(43.907787,-79.359741), 9);



function fnc_get_location()
{
    dblLat = map.getCenter().lat();
    dblLon = map.getCenter().lng();
    dblLev = map.getZoom();  
//alert(dblLat + ": " +  dblLon + ":" + dblLev);
str_loc = "?lat=" + dblLat + "\&lon=" + dblLon + "\&scale=" + dblLev;
//alert(str_loc);
return str_loc;

}
