	/* main google maps fuctions */
    var marker;
    var centreLat=10.0;
    var centreLon=-15.0;
    var initialZoom=1;
    var map; //the GMap2 itself
    var mt=""; //map type
    var allowedBounds;
    var ldiv;
    var stmarkers = [];
    var alertmarkers = [];
    var searchNby = []; //search near by popups
    var zoomlevel;
    var gLocalSearch;
	var gcGCG; //G client geocoder
	var gcaddr = []; //address search array
	var gcreason = []; //client geocoder reasons
	var gcstandards = [];
	
	//var endLines = ["Shady Grove","Glenmont","Vienna/Fairfax-GMU","New Carrolton","Franconia-Springfield","Largo Town Center","Huntington","Branch Ave","Greenbelt"];
	
	/* customGetTileURL - new tiles for fail map */
    function customGetTileURL(a,b) {
      //converts tile x,y into keyhole string
      var c=Math.pow(2,b);
      var d=a.x;
      var e=a.y;
      var f="t";
        for(var g=0;g<b;g++){
            c=c/2;
            if(e<c){
                if(d<c){f+="q"}
                else{f+="r";d-=c}
            }
            else{
                if(d<c){f+="t";e-=c}
                else{f+="s";d-=c;e-=c}
            }
        }
		
        //return "wmata_source_map5-tiles/"+f+".jpg"
		return "wmata-zoom-tiles/"+f+".jpg"
		
    }
	/* getWindowHeight */
    function getWindowHeight() {
        if (window.self&&self.innerHeight) {
            return self.innerHeight;
        }
        if (document.documentElement&&document.documentElement.clientHeight) {
            return document.documentElement.clientHeight;
        }
        return 0;
    }
    function resizeMapDiv() {
        //Resize the height of the div containing the map.
        //Do not call any map methods here as the resize is called before the map is created.
    	var d=document.getElementById("map");
        var offsetTop=0;
        for (var elem=d; elem!=null; elem=elem.offsetParent) {
            offsetTop+=elem.offsetTop;
        }
        var height=getWindowHeight()-offsetTop-16;
        if (height>=0) {
            d.style.height=height+"px";
        }
    }
	/* load - main load for map */
    function load(x) {
      if (GBrowserIsCompatible()) 
	  {
		
        resizeMapDiv();
		mt = "rail";
		//setting default zoomlevel
		zoomlevel = 2;
        var copyright = new GCopyright(1,
                              new GLatLngBounds(new GLatLng(-90, -180),
                                                new GLatLng(90, 180)),
                              0,
                              "<a href=\"http://www.casa.ucl.ac.uk\">CASA</a>");
        var copyrightCollection = new GCopyrightCollection("GMapImgCutter");
        copyrightCollection.addCopyright(copyright);
	 copyright = new GCopyright(2,
                              new GLatLngBounds(new GLatLng(-90, -180),
                                                new GLatLng(90, 180)),
                              0,
                              "& <a href=\"http://www.filnetinc.com\">Filnet Inc.</a>");
	copyrightCollection.addCopyright(copyright);
	// setup Google Search /  G  Client Geocoder (
	gLocalSearch = new GlocalSearch();
	gLocalSearch.setAddressLookupMode(GlocalSearch.ADDRESS_LOOKUP_DISABLED);
	gLocalSearch.setResultSetSize(GSearch.LARGE_RESULTSET);
	
	//gLocalSearch.markerimages = markerimages;		
        //create a custom picture layer
        var pic_tileLayers = [ new GTileLayer(copyrightCollection , 0, 17)];
        pic_tileLayers[0].getTileUrl = customGetTileURL;
        pic_tileLayers[0].isPng = function() { return false; };
        pic_tileLayers[0].getOpacity = function() { return 1.0; };
		/*
        var pic_customMap = new GMapType(pic_tileLayers, new GMercatorProjection(6), "Pic",
            {maxResolution:5, minResolution:2, errorMessage:"Data not available "});*/
			var pic_customMap = new GMapType(pic_tileLayers, new GMercatorProjection(6), "Pic",
            {maxResolution:5, minResolution:2, errorMessage:"Data not available "});
        //Now create the custom map. Would normally be G_NORMAL_MAP,G_SATELLITE_MAP,G_HYBRID_MAP
        map = new GMap2(document.getElementById("map"),{backgroundColor:"#FFFFFF",mapTypes:[pic_customMap]});
	 	 
	 map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.enableDoubleClickZoom();
	 map.enableContinuousZoom();
	 map.enableScrollWheelZoom();
	 // per rail link in info window
	 if (x == "")
	 {
		map.setCenter(new GLatLng(centreLat, centreLon), initialZoom, pic_customMap);
	}
	  else
	{
		//we can from rail link station obj array index = x
		map.setCenter(new GLatLng(station_arr[x].lat, station_arr[x]._long), 4, pic_customMap);
		// redraw makers an stuff
		zoomlevel = 4;
	}

	ldiv = new loadDiv();
    map.addOverlay(ldiv);
	map.addControl(new toggleControl());
	// Add a zoom listener to swap alert icon based on zoom levels
	GEvent.addListener(map,"zoomend",function(){
	zoomlevel = map.getZoom();
		if (zoomlevel >=4)
		{	
			resetStIcons("b");
			resetAlertIcons("b");
		}
		else
		{		
			resetAlertIcons("s");
			resetStIcons("s");
		}		
	});
        // Add a move listener to restrict the bounds range
        GEvent.addListener(map, "move", function() {
        	checkBounds();
        });
      // The allowed region which the whole map must be within
      allowedBounds = new GLatLngBounds(new GLatLng(-120,-150), new GLatLng(120,150));
	// set markers for stations
	var al_counter =0;
	searchNby = [];
	stmarkers = [];
	alertmarkers = [];
	//stcds = [];
	for (var x=0;x < station_arr.length; x++)
	{	
		marker = createMarker(station_arr[x],"s");
		map.addOverlay(marker);
		stmarkers.push(marker);		
		//stcds.push(station_arr[x].id);
		station_arr[x].st_mk_ar_pos = x;
		searchNby.push(createNBSearchPopup(station_arr[x],x));	

		if (station_arr[x].alert_status=="1")
		{
			marker = createAlertMarker(station_arr[x]);
			map.addOverlay(marker);
			station_arr[x].al_mk_ar_pos = al_counter;
			// add marker to array for zooming
			alertmarkers.push(marker);		
			al_counter ++;

		}									
	 }
    }
	ldiv.hide();
    }
	/* load2 -load wmata map and search near by and google map link(info window) station via*/
    function load2(lt,lg, zl, loadt,x)
    {
	var mt = "";
	if (GBrowserIsCompatible()) 
	{
		map = new GMap2(document.getElementById("map"));
		map.setCenter(new GLatLng(parseFloat(lt),parseFloat(lg)), parseInt(zl));
		// setup Google Search		
		gLocalSearch = new GlocalSearch();
		gLocalSearch.setAddressLookupMode(GlocalSearch.ADDRESS_LOOKUP_DISABLED);
		gLocalSearch.setResultSetSize(GSearch.LARGE_RESULTSET);		
		//gLocalSearch.markerimages = markerimages;
		
		if (x=="")
		{
		map.addControl(new toggleControl());		
		}
		
		ldiv = new loadDiv();
		map.addOverlay(ldiv);
		DrawMapLines();
		loadMarkers2();
				
		if (loadt =="snby")
		{
			//loadMarkers2();
			performLocalQuery(new GLatLng(parseFloat(lt),parseFloat(lg)), document.getElementById('search_nby').value );
		}
      }	
    }
	
/* performLocalQuery (search near by ) */
function performLocalQuery(point, query) {

	gLocalSearch.setSearchCompleteCallback(null, function(){
		performLocalQueryCallback();
	});
	gLocalSearch.setCenterPoint(point);
	gLocalSearch.execute(query);
}
/* performLocalQueryCallback (search near by) */
function performLocalQueryCallback() {

	// init search result array, on first run only
	if(!gLocalSearch.arrSearchResultMarkers) gLocalSearch.arrSearchResultMarkers = Array();
	// remove previous search results, if any
	while(gLocalSearch.arrSearchResultMarkers.length){
		map.removeOverlay(gLocalSearch.arrSearchResultMarkers[gLocalSearch.arrSearchResultMarkers.length-1]);
		gLocalSearch.arrSearchResultMarkers.pop();
	}
	if ((!gLocalSearch.results) || (0 == gLocalSearch.results.length)) {
		QuietAlert("no results");
		return;
	}
	var attribution = gLocalSearch.getAttribution();
	if (null == attribution) {
		attribution = "";
	}

	for (var i = 0; i < gLocalSearch.results.length; i++) {

		var result = gLocalSearch.results[i];
		marker = createSearchNbyMarker(result);
		map.addOverlay(marker);
	}

	return marker;
}

    		 /* createMarkers   */      
    function createMarker(station_obj, t)	
	{
		var mark;
		
		if (t =="s" | t == "b")
		{
			ico = setIcon();
			point = new GLatLng(station_obj.lat,station_obj._long);
		}
		else if (t =="wm")
		{
			// create markers based on wmata map
			// Create our "tiny" marker icon	
			
			ico = new GIcon();
			ico.image = "img/pylon.png";
			//ico.shadow = "http://www.wmata.com/maps/images/pylon_shadow.png";
			ico.iconSize = new GSize(10, 20);
			ico.shadowSize = new GSize(10, 10);
			ico.iconAnchor = new GPoint(4, 4);
			ico.infoWindowAnchor = new GPoint(5, 1);
			
			if ( null != station_obj)
			{
				point = new GLatLng(station_obj.glat,station_obj.glong);
			}
			
		}
		
		var markerOptions = { icon:ico};		
		mark =  new GMarker(point,markerOptions);
		GEvent.addListener(mark, "click", function() {
			ldiv.show();
			var ntd = [];
			var cnt = 0;
			var cnt2 = 0;
			var el = 0;
			var es = 0;
			var d = 0;
			$.getJSON("/rider_tools/pids/showpid_json.cfm?station_id="+station_obj.id, function(j){			
				try
				{
					for(var x=0; x < j.signs.length; x++)
					{
						if (j.signs[x].arrivalData.length > 2) //not enough data
						{
						  for(var y=0; y < j.signs[x].arrivalData.length; y++)
						  {	
								if (lineExists(j.signs[x].arrivalData[y]))
								{	
									if (j.signs[x].arrivalData[y].line != "LN" && j.signs[x].arrivalData[y].line !="--")
									{
									  ntd[cnt] = j.signs[x].arrivalData[y].line+","+j.signs[x].arrivalData[y].dest+","+j.signs[x].arrivalData[y].time;						  
									  cnt ++;
									}
								}
								else //end of line data (4 fields but data is not consitant)
								{
									var tmpdata;
									try{
										if (j.signs[x].arrivalData[y].signtext != "***")
										{
											if (cnt2 <= 3)
											{
												if (cnt2 == 0)
												{
													ntd[cnt] = j.signs[x].arrivalData[y].signtext.replace("LINE","");
												}
												else if (cnt2 != 2 )
												{	
													
													if (cnt2 == 3)
													{
														//this should be number if not then data no good put in dash
														tmpdata = j.signs[x].arrivalData[y].signtext.replace("MINUTES","");
														tmpdata = trim(tmpdata);
														if (! IsNumeric(tmpdata))
														{
															tmpdata = "";
														}
													}
													else
													{
														tmpdata = j.signs[x].arrivalData[y].signtext;
													}
													
													ntd[cnt] += tmpdata;
													
												}
												
												if (cnt2 < 3 && cnt2 != 2)
												{
													ntd[cnt] += ",";
												}	
												//ntd[cnt] = j.signs[x].arrivalData[y].signtext[0].Replace("LINE","")+","+j.signs[x].arrivalData[y].signtext[1]+","+j.signs[x].arrivalData[y].signtext[2]+" "+j.signs[x].arrivalData[y].signtext[3];						
											}
											if (cnt2 == 3)
											{
												cnt2 = 0;
												if (tmpdata !="")
												{
													cnt ++;
												}
												
											}else
											{
												cnt2++;
											}
										}	
									}
									catch(e)
									{//alert(e);
									}
								}
						  }
						  
						 }
					}
				}
				catch (e)
				{
				}
				$.getJSON("metro_map_ajax.cfm?rid="+station_obj.id, function(d){
				for (var x=0; x < d.length; x++)
				{
					if (d[x].val.length > 0)
					{						
						if (d[x].val == "ELE")
						{ el ++;}
						if (d[x].val == "ESC")
						{ es ++;	}
						if (d[x].val == "DIS")
						{ d ++;}						
					}
					// check for elevator, escalator and disruptions									
				} 
				
				var tm = getTime();
				var str_html;//popup html has to pieces due to various element data that has to displayed				
				str_html =  station_obj.ph;
				str_html += st_lines(station_obj.lines);
				str_html += st_alerts(d,el,es,station_obj);
				str_html += station_obj.pm;
				str_html += st_train_data(ntd,tm,station_obj.lines, station_obj.id);
				str_html += st_popup_footer(station_obj);
				ldiv.hide();
				mark.openInfoWindowHtml(str_html);
                });				
				});			
		});
		
		return mark;
	} 	 
	
	function lineExists(obj)
	{
		
		try
		{
			//j.signs[x].arrivalData[y].line.length
			if (obj.line.length > 0)
			{
				return true;
			}
			
		}
		catch(e)
		{
			return false;
		}
				
		return true;
		
	}
	
	function endOfLine(stname)
	{
		
	}
	
	
	/* setIcon - set icon based for custom map on zoom level */
	function setIcon()
	{
		
		var ico;
		var zl;
		if (zoomlevel == null)
		{
			zl = 2;
		}else
		{
			zl =zoomlevel; 
		}

		switch (zl)
		{									
			case 2:
				ico = new GIcon(G_DEFAULT_ICON,"img/clear_marker_10x10.gif");
				//ico = new GIcon(G_DEFAULT_ICON,"img/gray_10x10.gif");
				ico.shadow = "";
				ico.iconSize = new GSize(10,10);
				ico.iconAnchor = new GPoint(5,10);
				ico.infoWindowAnchor = new GPoint(5,10);
				ico.imageMap = [0,0,10,0,10,10,0,10];
				break;
			
			case 3:
				ico = new GIcon(G_DEFAULT_ICON,"img/clear_marker_20x20.gif");
				//ico = new GIcon(G_DEFAULT_ICON,"img/gray_20x20.gif");
				ico.shadow = "";
				ico.iconSize = new GSize(20,20);
				ico.iconAnchor = new GPoint(10,20);
				ico.infoWindowAnchor = new GPoint(10,20);
				ico.imageMap = [0,0,20,0,20,20,0,20];
				break;
			
			case 4:
				ico = new GIcon(G_DEFAULT_ICON,"img/clear_marker_30x30.gif");
				//ico = new GIcon(G_DEFAULT_ICON,"img/gray_30x30.gif");
				ico.shadow = "";
				ico.iconSize = new GSize(30,30);
				ico.iconAnchor = new GPoint(15,30);
				ico.infoWindowAnchor = new GPoint(15,30);
				ico.imageMap = [0,0,30,0,30,30,0,30];
				break;
				
			case 5:
				ico = new GIcon(G_DEFAULT_ICON,"img/clear_marker_40x40.gif");
				//ico = new GIcon(G_DEFAULT_ICON,"img/gray_40x40.gif");
				ico.shadow = "";
				ico.iconSize = new GSize(40,40);
				ico.iconAnchor = new GPoint(20,40);
				ico.infoWindowAnchor = new GPoint(20,40);
				ico.imageMap = [0,0,40,0,40,40,0,40];
				break;						

		}		

		return ico;
	}

	/* createAlertMarker - create alert markers */
	function createAlertMarker(station_obj)	
	{
		var mark;
		var str_html;
				
		// icons
		if ( zoomlevel >=4)
		{		

			ico = new GIcon(G_DEFAULT_ICON,"img/alert_big.gif");	
			ico.shadow = "";
			ico.iconSize = new GSize(46,45);
			ico.iconAnchor = new GPoint(23,45);
			ico.infoWindowAnchor = new GPoint(18,23);
			ico.imageMap = [22,2,42,36,4,37];				
		}
		else
		{
			ico = new GIcon(G_DEFAULT_ICON,"img/Alert_small.gif");
			ico.shadow = "";
			ico.iconSize = new GSize(14,14);
			ico.iconAnchor = new GPoint(7,14);
			ico.infoWindowAnchor = new GPoint(5,10);	
			ico.imageMap = [7,1,12,12,0,12];			
		}		
		var markerOptions = { icon:ico};
		//point = alertPoint(station_obj,distance, direction);
		point = new GLatLng(parseFloat(station_obj.lat)+parseFloat(station_obj.alert_x),parseFloat(station_obj._long)+parseFloat(station_obj.alert_y));
		mark =  new GMarker(point,markerOptions);
		str_html = station_obj.alert_popup_html;
		GEvent.addListener(mark, "click", function() {
			mark.openInfoWindowHtml(str_html);
		});
		//html to for markers to be swapped when thing are reset or changes
 		alert_info_html.push(str_html);
		return mark;
	}  

	/* load/create new markers (wmata google map) */
	function loadMarkers2()
	{
		// loop through station markers 
		var mk;
		for(var x=0; x < stmarkers.length; x++ )
		{
			//remove station markers.
			map.removeOverlay(stmarkers[x]);			
		}
		//recreate based on station objs
		stmarkers = [];
		searchNby = [];
		//stcds = [];
		for (var x=0;x < station_arr.length; x++)
		{			
			mk = createMarker(station_arr[x],"wm");
			station_arr[x].cnt = x;
			map.addOverlay(mk);
			stmarkers.push(mk);
			searchNby.push(createNBSearchPopup(station_arr[x],x));			
			//stcds.push(station_arr[x].code);
		}
	}

	/*  createSearchNbyMarker */
	function createSearchNbyMarker(rslt)
	{
		var mark;
		var point = new GLatLng(rslt.lat, rslt.lng); 		
		//create and add marker
		mark = new GMarker(point);		
		GEvent.addListener(mark, "click", function() {
			mark.openInfoWindowHtml(rslt.html);
		});
		return mark;
	}
	
	/* resetStIcons  */
	function resetStIcons(t)
	{
		// loop through station markers is a clear gif for hot spot
		var mk;
		for(var x=0; x < stmarkers.length; x++ )
		{
			//remove station markers.
			map.removeOverlay(stmarkers[x]);			
		}
		//recreate based on station objs
		stmarkers = [];
		//searchNby = [];	
		//stcds = [];
		for (var x=0;x < station_arr.length; x++)
		{
				
			mk = createMarker(station_arr[x],t);
			map.addOverlay(mk);
			stmarkers.push(mk);
			//searchNby.push(createNBSearchPopup(station_arr[x],x));			
			//stcds.push(station_arr[x].code);
		}
	}	

	/* resetAlertIcons */
	function resetAlertIcons(t)
	{
		// loop through alert markers
		var mk;
		for(var x=0; x < alertmarkers.length; x++ )
		{
			map.removeOverlay(alertmarkers[x]);
		}
		alertmarkers = [];
		for (var x=0;x < station_arr.length; x++)
		{
			
			if (station_arr[x].alert_status=="1")
			{
				mk = createAlertMarker(station_arr[x]);
				map.addOverlay(mk);
				// add marker to array for zooming
				alertmarkers.push(mk);				
			}
		}		
	}

	/* checkBounds - for rail map */
       function checkBounds() {
        // Perform the check and return if OK
        if (allowedBounds.contains(map.getCenter())) {
          return;
        }
        // It`s not OK, so find the nearest allowed point and move there
        var C = map.getCenter();
        var X = C.lng();
        var Y = C.lat();

        var AmaxX = allowedBounds.getNorthEast().lng();
        var AmaxY = allowedBounds.getNorthEast().lat();
        var AminX = allowedBounds.getSouthWest().lng();
        var AminY = allowedBounds.getSouthWest().lat();

        if (X < AminX) {X = AminX;}
        if (X > AmaxX) {X = AmaxX;}
        if (Y < AminY) {Y = AminY;}
        if (Y > AmaxY) {Y = AmaxY;}
        //alert ("Restricting "+Y+" "+X);
        // try to center a little better
        if (X < 0){X = X + 30;}
        if (X > 0){X = X - 30;}
        
		if (Y < 0){Y = Y + 45;}
		if (Y > 0){Y = Y - 45;}
        
        map.setCenter(new GLatLng(Y,X));
                
      }
      /* loadDiv - custom loading div */
    function loadDiv()
	{
		var point;
		var div_;
		var map_;
		this.point = new GLatLng(0, 0);
		
		// Is this IE, if so we need to use AlphaImageLoader
	        var agent = navigator.userAgent.toLowerCase();
        
       	 if ((agent.indexOf("msie") > -1) && (agent.indexOf("opera") < 1)){this.ie = true} else {this.ie = false}
	        this.hidden = false;
	}
		
	loadDiv.prototype = new GOverlay();
	loadDiv.prototype.initialize = function(map) {
		var div = document.createElement("div");
		var p = map.fromLatLngToDivPixel(this.point);
		div.style.position = "absolute";					
		div.zIndex = "9999";
		div.setAttribute("id","loadDiv");
		div.style.width = "100px";
		div.style.height = "32px";
		div.style.border = "thin solid gray";
		div.style.backgroundColor = "#E8E8E8";
		div.style.textAlign = "center";
		div.style.left = (p.x - 100)+"px";
		div.style.top =  (p.y - 75)+"px";		
		div.innerHTML ="<p><img src='img/a-l_c_lines.gif'></p>";
		if (this.zindex < 0) {
	           map.getPane(G_MAP_MAP_PANE).appendChild(div);
       	 } else {
	           map.getPane(1).appendChild(div);
       	 }
	        this.map_ = map;
       	 this.div_ = div;
	
	}
	loadDiv.prototype.redraw = function(force)
	{

	}
	
	loadDiv.prototype.remove = function(){
		this.div_.parentNode.removedChild(this.div_);
	}

	loadDiv.prototype.show = function()
	{
		this.div_.style.display="";
		this.hidden = false;		

	}

	loadDiv.prototype.hide = function()
	{

		this.div_.style.display="none";
		this.hidden = true;	

	}
	/* end loadDiv - custom loading div */

     /* upper right toggle controls */
	function toggleControl() {  }
    toggleControl.prototype = new GControl();

    toggleControl.prototype.initialize = function(map) {
    var container = document.createElement("div");
	container.style.width = "150px";
	var tb = document.createElement("table");
	tb.style.margin = "0px";	
	tb.style.width = "150px";
	var tbb = document.createElement("tbody");
	var tr = document.createElement("tr");
	var td1 = document.createElement("td");	
	this.setButtonStyle_(td1);
	//set color
	 if (mt=="rail")
      {
	      td1.style.color = "gray";         
	}else
	{
		td1.style.color = "#0000cc";
	}
	td1.align = "center";
	td1.appendChild(document.createTextNode(" Rail Map "));
	GEvent.addDomListener(td1, "click", function() {load('');});
	tr.appendChild(td1);
	//space td
	var td2 = document.createElement("td");	
	td2.appendChild(document.createTextNode(" "));
	td2.width = "5px";
	tr.appendChild(td2);
	var td3 = document.createElement("td");
	this.setButtonStyle_(td3);
	//set color
 	if (mt=="rail")
      {
	      td3.style.color = "#0000cc";         
	}else
	{
		td3.style.color = "gray";
	}
    td3.align = "center";
	td3.appendChild(document.createTextNode(" Google Map "));
	GEvent.addDomListener(td3, "click", function() {load2("38.898303","-77.028099","11","wm","");});
	tr.appendChild(td3);
	tbb.appendChild(tr);
	tb.appendChild(tbb);
	container.appendChild(tb);

      map.getContainer().appendChild(container);
      return container;
    }

    toggleControl.prototype.getDefaultPosition = function() {
      return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(5,5));
    }

    toggleControl.prototype.setButtonStyle_ = function(button) {
      button.style.textDecoration = "none";
      button.style.backgroundColor = "white";
      button.style.font = "x-small Arial";
      button.style.border = "1px solid black";
      button.style.padding = "1px 5px 1px 5px";
      button.style.marginBottom = "1px";
      button.style.textAlign = "center";
      button.style.width = "60px";
      button.style.cursor = "pointer";
      }

	// pop up funcitons  
  /* closePopOpnalrt   */
   function closePopOpnAlrt(x,y)
   {
	
	map.closeInfoWindow();		
	GEvent.trigger(alertmarkers[y],"click");
   }
    
	/* - onblur event to save data   */
   function saveSNBY(data)
   {
	// save to hidden field on form
	document.getElementById('search_nby').value = data;
	
   }
	/*openNBSearch*/
   function openNBSearch(i)
   {
	// user0; station objects array (should be just 1 maker)	
	stmarkers[i].openInfoWindowHtml(searchNby[i]);
   }

  
	/* send to phone - save data to hidden fields */
  function showSndToPhone(x)
  {
		// display data
		var pdv = document.getElementById('mnph');
		document.getElementById('st_arr_pos').value = x;
		document.getElementById('snd_stname').innerHTML = station_arr[x].name;
		document.getElementById('snd_staddr').innerHTML = station_arr[x].addr;
		document.getElementById('snd_stcst').innerHTML = station_arr[x].city_st;
		document.getElementById('feedback').innerHTML = "";
		document.getElementById('mnph').style.fontWeight = "bold";
		$('#dialog').jqm().jqmShow();
		
   }
	 /* hideSendToPhone  */
  function hideSendToPhone()
 {
	// send data via ajax call
	$('#window2').jqmHide();
}

	/*sendToPhone */
function sendTo(action)
{
	//station_arr[x];
	//we'll return info
	var x = document.getElementById('st_arr_pos').value;	
	var sendto;
	
	document.getElementById('feedback').innerHTML = "";
	//validation	 
	if (action =="phone")
	{
		var ndx = document.getElementById('carrier').selectedIndex;
		var carrier = document.getElementById('carrier').options[ndx].value;	
		var phonenum = document.getElementById('phonenum').value;

		if (carrier == "")
		{
			document.getElementById('feedback').innerHTML = "Please select a carrier";
			return;
		}
		if (phonenum == "")
		{
			document.getElementById('feedback').innerHTML = "Please enter a phone number";		
			return;
		}
		sendto = phonenum+carrier;	
	}
	else
	{	
		var em = document.getElementById('email').value;
		if (em == "")
		{
			document.getElementById('feedback').innerHTML = "Please enter a email address";
			return;
		}

		sendto = em;
	}
	
	$.getJSON("metro_map_ajax.php?ajax_req=yes&function=send2phone&st_name="+station_arr[x].name+"&st_addr="+station_arr[x].addr+"&st_cst="+station_arr[x].city_st+"&sendto="+sendto, function(j){			
		// reset/clear fields
		document.getElementById('phonenum').value = "";
		document.getElementById('carrier').selectedIndex = 0;
		document.getElementById('feedback').innerHTML = "Message sent";
		document.getElementById('carrier').selectedIndex = 0
		document.getElementById('phonenum').value = "";
		document.getElementById('email').value = "";
	});			

}
/* SndPhone */
function SndPhone()
{
	var ptb = document.getElementById('phone_tbl');
	var etb = document.getElementById('email_tbl');
	var pdv = document.getElementById('mnph');
	var edv = document.getElementById('mnem');
	
	ptb.style.display = "";
	etb.style.display = "none";
	pdv.style.fontWeight = "bold";
	edv.style.fontWeight = "normal";
}
/* SndEmail*/
function SndEmail()
{
	var ptb = document.getElementById('phone_tbl');
	var etb = document.getElementById('email_tbl');
	var pdv = document.getElementById('mnph');
	var edv = document.getElementById('mnem');
	
	ptb.style.display = "none";
	etb.style.display = "";
	pdv.style.fontWeight = "normal";
	edv.style.fontWeight = "bold";

}

