var map;
var vTrackingSent=0
var vContent="";
 
	  //var  vLocation='42.158,-85.485'
var vGPS=1
var ajaxRequestBubble=""
var ajaxRequest=""
var vPT=""
var vPublic
var vLC=0
var vPinCount=0
var lat;
var lng;
var vOffset=0
var vPinCountC=0
var vGPSPositionTimer=""
var vFirstTime=0
var point;
var olat;
var olng;
var vTC; //=setTimeout('fGPS()',5000)	
var vGPSRead=10000
var tGPS="" // setInterval("fGPSSend()",15000)
var tGPSC=0
var vBreadCrumbs=1;
var oldLat;
var oldLng;
var vPinsC=0
var vICU=0
var vTracking=0
var vLat="";
var vLng="";
var vGeo=0
var vLatLng;
var vMarkerEvent=0;
var vArea;
var vMapType="Road" // road
var vDat="";
var vTim="";
var vTmp2=""
var vTrackingPlaybackSpeed=15000
var vTest=0
var vMapSize=12
var sLat;
var sLng;
var oSLat;
var oSLng;
var vSChange=0;
var vMsg=""
var vICUDelay;
var vICUPagePause;
var wpid="";
var marker;
var map;
var LL;
var markersArray = [];  
var vMarkerMsgC
var vMarkerMsg=new Array()  
var oPage=""
var vDateTime="";
var wpid=false 
var map 
var z 
var op 
var prev_lat 
var prev_long 
var min_speed=0 
var max_speed=0 
var min_altitude=0 
var max_altitude=0 
var distance_travelled=0 
var min_accuracy=150 
var date_pos_updated="" 
var info_string=""
var vLog=0
var vGPSSend=0
 
	var now = new Date()
	var hour        = now.getHours();
	var minute      = now.getMinutes();
	var second      = now.getSeconds();
	var monthnumber = now.getMonth()+1;
	var monthday    = now.getDate();
	var year        = now.getYear();
	
var vLatDesktop=""
var vLngDesktop=""	
 
if (monthnumber<10){
	monthnumber="0" + monthnumber
}
 
 
 
	document.all.D3.value="30"
	document.all.DPace.value="30"
 
	vTrackingPlaybackSpeed=eval(document.all.DPace.value) * 1000
 
	//dDisplay.style.pixelTop=500
	dDisplay.style.pixelTop=0
	dDisplay.style.pixelLeft=-2000
	dMap_position.style.pixelTop=0
	dMap_position.style.pixelLeft=-1000
	dHow.style.pixelTop=0
	dHow.style.pixelLeft=0
	
 
 
 
 
 
 
 
 
 
	
	function fDAll(){
		document.all.TGPSFunction.value='fDAll()'
		dInfoContainer.style.pixelLeft=-1500
		dInfoContainer.style.pixelTop=-1000		
		dDisplay.style.pixelTop=0
       dDisplay.style.pixelLeft=-2000			
		// dMap_position
		
		switch (document.all.DAll.value){
			case "Settings":
			//dMap_position.style.pixelTop=700
			//dMap_position.style.pixelLeft=0
 
				dDisplay.style.pixelTop=700
				dDisplay.style.pixelLeft=0    			
				break;
			
			case "Map - Control Panel":
					dDisplay.style.pixelTop=700
					dDisplay.style.pixelLeft=0
					//dMap_position.style.pixelTop=700
					//dMap_position.style.pixelLeft=0					
				//alert("Not available at this time!")
				break;
				
				case "Sign On":
				document.all.TGPSName.focus()
				break;
				
				case "Sign On - Thread":
				document.all.TGPSThread.focus()
				break;
				
				case "Sign On - Password":
				document.all.TGPSPW.focus()
				break;
				
				case "Start Tracking":
				fTracking()
				break;
				
				case "History":
					dInfoContainer.style.pixelLeft=600
					dInfoContainer.style.pixelTop=0				
					break;
					
			default:
				alert(document.all.DAll.value)
	}
	/*
        <option value="Sign On">Sign On</option>
        <option>Start Tracking</option>
        <option value="Map - Control Panel">Map - Control Panel</option>
        <option value="Map - Center">Map - Center</option>
        <option value="Map - Frequency">Map - Frequency</option>
        <option value="Map - Hybrid">Map - Hybrid</option>
        <option value="Map - Roads">Map - Roads</option>
        <option value="Map - Satellite">Map - Satellite</option>
        <option selected value="Map - Terrain">Map - Terrain</option>
        <option value="Map - Locator">Map - Locator</option>
        <option value="Map - Notation">Map - Notation</option>
        <option value="Map - Overlays">Map - Overlays</option>
        <option value="Map - Type">Map - Type</option>
        <option value="Map - View">Map - View</option>
        <option value="5">5&nbsp;&nbsp; sec - Automobile - City</option>
        <option value="15">15 sec - Automobile - Highway</option>
        <option value="30">30 sec - Automobile - Trip</option>
        <option value="60">1&nbsp; min&nbsp; - Bike</option>
        <option value="120">2&nbsp; min&nbsp; - Running</option>
        <option value="300">5&nbsp; min&nbsp; - Walking</option>
        <option value="1800">30 min - Pause</option>        
        <option value=".25">ICU Quick Step</option>	
     */
	}
 
 
 
 
 
 
 
 
 
 
 
 
 
function fMapSize(){
 
	document.all.TGPSFunction.value='fMapSize()'
	vMapSize=eval(document.all.DMapSize.value	)
	
	switch (vMapType) {
		case "Road":
			fRoads()
			break;
		case "Terrain":
			fTerrain()
			break;
		case "Hybrid":
			fHybrid()
			break;
		case "Satellite":
			fSatellite()
			break;
		default:
		
	}
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  //vPT=setTimeout('ajaxFunctionReadBubbles()',vTrackingPlaybackSpeed)	
 
 
  
  function fSetMarker(){
  
  	document.all.TGPSFunction.value='fSetMarker()'
  	if (document.all.BSetMarker.value=="    Set Marker Off    "){
  		document.all.BSetMarker.value= "    Set Marker On     "
  		vMarkerEvent=1
  	} else {
  		vMarkerEvent=0  	
  		document.all.BSetMarker.value="    Set Marker Off    "
  	}
  }
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  function initialize0() {
	document.all.TGPSFunction.value='initialize0()'
 
 
	} 
 
 
  function initialize() {
 
	document.all.TGPSFunction.value='initialize()'
     // vLocation[2]=new google.maps.LatLng(42.16,-85.485);
     
        if(navigator.geolocation) { 
        
        } else {
        	vGeo=0
          fQFetch()
		    vArea = new google.maps.LatLng(document.all.TLat.value,document.all.TLng.value); // 42.158,-85.485);    
          
		    vTC=setTimeout('fRoads()',1000) // was 1500 08/07/2011
               //alert(vMapSize)
               //addMarker(vLatLng)		  
		  		//vTC2=setTimeout('addNewMarker(vArea)',4000)
          return
        }
	
        if(navigator.geolocation) { 
        
			wpid=navigator.geolocation.watchPosition(geo_success, geo_error, {enableHighAccuracy:true, maximumAge:30000, timeout:27000});
			//navigator.geolocation.clearWatch(wpid)
			
 			
			navigator.geolocation.getCurrentPosition(onPositionUpdate);
			
			document.all.TGPSFunction.value='initialize() back'
 
 
			vGeo=1
 
           }     
 
	vTC=setTimeout('fRoads()',2000) // was 1500 08/07/2011
  
	} 
	
function fCenterMap(){
 
	document.all.TGPSFunction.value='fCenterMap()'
	switch (vMapType) {
		case "Road":
			fRoads()
			break;
		case "Terrain":
			fTerrain()
			break;
		case "Hybrid":
			fHybrid()
			break;
		case "Satellite":
			fSatellite()
			break;
		default:
		
	}
	//initializer()
	return
 
  } 
/*  
http://maps.google.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap
&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318
&markers=color:red%7Ccolor:red%7Clabel:C%7C40.718217,-73.998284&sensor=false
*/
  function fRoads(){
  
  	document.all.TGPSFunction.value='fRoads()'
	vMapType="Road"
  	document.all.DMaps.value="Roads"
 
    vArea = new google.maps.LatLng(document.all.TLat.value,document.all.TLng.value); // 42.158,-85.485);  
    var mapOptions = {
      zoom: vMapSize,
      center: vArea,
      mapTypeId: google.maps.MapTypeId.ROADMAP // style=feature:road.local|element:labels
    };
    
    map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
 
    google.maps.event.addListener(map, 'click', function(event) {
    marker.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/marker99.png";
      addMarker(event.latLng);
    });  
	var vTC2=setTimeout('addNewMarker(vArea)',1000)    
    vTC=setTimeout('fGPS()',1000)
  }
  
  
  
  
  
  
  
  
  
  
  
  function fHybrid(){
  
  	document.all.TGPSFunction.value='fHybrid()'
	vMapType="Hybrid"
    document.all.DMaps.value="Hybrid"
    
    vArea = new google.maps.LatLng(document.all.TLat.value,document.all.TLng.value); // 42.158,-85.485);    
    var mapOptions = {
      zoom: vMapSize,
      center: vArea,
      mapTypeId: google.maps.MapTypeId.HYBRID
    };
    
    map = new google.maps.Map(document.getElementById("map_canvas"),
        mapOptions);
 
    google.maps.event.addListener(map, 'click', function(event) {
      addMarker(event.latLng);
    });  
	var vTC2=setTimeout('addNewMarker(vArea)',1000)    
    vTC=setTimeout('fGPS()',1000)
  }  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  function fSatellite(){
  
  	document.all.TGPSFunction.value='fSatellite()'
	vMapType="Satellite"
	document.all.DMaps.value="Satellite"
    vArea = new google.maps.LatLng(document.all.TLat.value,document.all.TLng.value); // 42.158,-85.485);    
    var mapOptions = {
      zoom: vMapSize,
      center: vArea,
      mapTypeId: google.maps.MapTypeId.SATELLITE
    };
    
    map = new google.maps.Map(document.getElementById("map_canvas"),
        mapOptions);
 
    google.maps.event.addListener(map, 'click', function(event) {
      addMarker(event.latLng);
    });  
	var vTC2=setTimeout('addNewMarker(vArea)',1000)    
    vTC=setTimeout('fGPS()',1000)
  }
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  function fTerrain(){
  
  	document.all.TGPSFunction.value='fTerrain()'
	vMapType="Terrain"
  	document.all.DMaps.value="Terrain"
     vArea = new google.maps.LatLng(document.all.TLat.value,document.all.TLng.value); // 42.158,-85.485);   
    var mapOptions = {
      zoom: vMapSize,
      center: vArea,
      mapTypeId: google.maps.MapTypeId.TERRAIN
    };
    
    
    
    map = new google.maps.Map(document.getElementById("map_canvas"),
        mapOptions);
 
    google.maps.event.addListener(map, 'click', function(event) {
      addMarker(event.latLng);
    });  
	var vTC2=setTimeout('addNewMarker(vArea)',1000)    
    vTC=setTimeout('fGPS()',1000)
  }  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  function addNewMarker(vLatLng) {
  
  	document.all.TGPSFunction.value='addNewMarker(vLatLng)'
  	
    marker = new google.maps.Marker({
      position: vLatLng,
      map: map
    });
    markersArray.push(marker);
 
  }
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
    // vLatLng was locaton
    
    
    
  function addMarker(vLatLng) {
  
  	document.all.TGPSFunction.value='addMarker(vLatLng)'
 
	  if (vMarkerEvent==0){
  			return
	  }
	if (vMarkerEvent==1 && document.all.TMarkerMsg.length<1){
		vMarkerMsgC=vMarkerMsgC+1
		vMarkerMsg[vMarkerMsgC]=document.all.TMarkerMsg.value
		label=document.all.TMarkerMsg.value
	}	    
	
    marker = new google.maps.Marker({
      
      position: vLatLng,
      map: map
    });
    markersArray.push(marker);
    //alert(location)
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 // Removes the overlays from the map, but keeps them in the array
  function clearOverlays() {
  
	document.all.TGPSFunction.value='clearOverlays()'  
    if (markersArray) {
      for (i in markersArray) {
        markersArray[i].setMap(null);
      }
    }
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  // Shows any overlays currently in the array
  function showOverlays() {
  
	document.all.TGPSFunction.value='showOverlays()'  
    if (markersArray) {
      for (i in markersArray) {
        markersArray[i].setMap(map);
      }
    }
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  // Deletes all markers in the array by removing references to them
  
  function deleteOverlays() {
  
	document.all.TGPSFunction.value='deleteOverlays()'  
    if (markersArray) {
      for (i in markersArray) {
        markersArray[i].setMap(null);
      }
      markersArray.length = 0;
    }
  }
  
  
  
  
  var vPTimer
  var vPC=0
  
function fViewPeeps1(){
	clearOverlays()
	//alert("Peeps found : " + vPeepsC)
	vPC=0
	if(vPC<vPeepsC){
		vPC=vPC+1
		vPTimer=setTimeout('fViewPeeps2()',1000)
	} else {
		alert("No Peeps trax!")
	}
 
}  
  
function fViewPeeps2(){
 
							 		var vHTHold=vPeeps[vPC]
							 		vHTPeeps=vHTHold.slice(0,vHTHold.indexOf("|"))
							 		var vHTHold=vHTHold.slice(vHTHold.indexOf("|")+1)
							 		var vHTLatLng=vHTHold.slice(vHTHold.indexOf("(")+1,vHTHold.indexOf(")"))
							 		vnLat=vHTLatLng.slice(0,vHTLatLng.indexOf(","))
 
							 		vnLng=vHTLatLng.slice(vHTLatLng.indexOf(",")+1)
																	    
								    vLatLng=new google.maps.LatLng(vnLat,vnLng);									
								    map.setCenter(vLatLng)
								    vLatLng=new google.maps.LatLng(vnLat,vnLng);								    
								 	addNewMarker(vLatLng)
			 					 	clearTimeout(vPTimer);
									//clearInterval(vPTimer); 
									vPTimer=""
									alert(vHTPeeps + " " + vHTHold)
								 	if (vPC<vPeepsC){
								 		vPC=vPC+1
								 		//alert("vPC = " + vPC + " of " + vPeepsC)
										vPTimer=setTimeout('fViewPeeps2()',2000)
								 	} else {
								 		alert("End of trex!")
								 		return
								 	}
}    
  
  
  
  
  

  
var vMarker=0  
var vPeeps=new Array()
var vPeepsC=0  
var vHTPeeps
 
function fICUPeeps(){
 
             			clearOverlays()
 
							 	for (i=1;i<=vPeepsC;i++){
							 		var vHTHold=vPeeps[i]
							 		vHTPeeps=vHTHold.slice(0,vHTHold.indexOf("|"))
							 		var vHTHold=vHTHold.slice(vHTHold.indexOf("|")+1)
							 		var vHTLatLng=vHTHold.slice(vHTHold.indexOf("(")+1,vHTHold.indexOf(")"))
							 		vnLat=vHTLatLng.slice(0,vHTLatLng.indexOf(","))
							 		//alert("vnLat = " + vnLat)
							 		vnLng=vHTLatLng.slice(vHTLatLng.indexOf(",")+1)
							 		//alert("vnLng = " + vnLng)
																	    
								    vLatLng=new google.maps.LatLng(vnLat,vnLng);									
								    map.setCenter(vLatLng)
								    vLatLng=new google.maps.LatLng(vnLat,vnLng);								    
								 	addNewMarker(vLatLng)
							 		//alert("vnLat = " + vnLat + "\nvnLng = " + vnLng)
							 		vLat=vnLat
							 		vLng=vnLng
								}
								
 
}
 
function fPeeps(i){
 
             			clearOverlays()
 
							 	//for (i=2;i<=vPeepsC;i++){
							 		var vHTHold=vPeeps[i]
							 		vHTPeeps=vHTHold.slice(0,vHTHold.indexOf("|"))
							 		var vHTHold=vHTHold.slice(vHTHold.indexOf("|")+1)
							 		var vHTLatLng=vHTHold.slice(vHTHold.indexOf("(")+1,vHTHold.indexOf(")"))
							 		vnLat=vHTLatLng.slice(0,vHTLatLng.indexOf(","))
							 		//alert("vnLat = " + vnLat)
							 		vnLng=vHTLatLng.slice(vHTLatLng.indexOf(",")+1)
							 		//alert("vnLng = " + vnLng)
																	    
								    vLatLng=new google.maps.LatLng(vnLat,vnLng);									
								    map.setCenter(vLatLng)
								    vLatLng=new google.maps.LatLng(vnLat,vnLng);								    
								 	addNewMarker(vLatLng)							 									 		
							 		//alert("vnLat = " + vnLat + "\nvnLng = " + vnLng)
							 		vLat=vnLat
							 		vLng=vnLng
							 		fPeepsNext()
 
 
}
 
function fPeepsNext(){
   //map = new GMap2(document.getElementById("map_canvas"));   
	//map.setCenter(new GLatLng(37.4419, -122.1419), 2);         
	// set map UI to default         
	//map.setUIToDefault(); 
	
   //place_marker(vLat,vLng)
 
	return
 
}
 
  
function ajaxFunctionReadBubbles() {
	
	document.all.TGPSFunction.value='ajaxFunctionReadBubbles()'	
	
	ajaxRequest=new XMLHttpRequest();
  
 	clearTimeout(vPT);
	clearInterval(vPT); 
	
	if (vICU==0){
		alert("ICU Off")
		return
	}	
	
	vPT=""
	//vTrackingPlaybackSpeed=eval(document.all.D3.value) * 1000
	vPT=setTimeout('ajaxFunctionReadBubbles()',5000)
	
 
	
	if (vTracking==1){
		vICU=0
		document.all.BICU.value="     ICU Off     "
		document.all.BICU.style.background="red"
		alert("ICU can not start while Tracking is on!")
		return
	}
	
	
	document.all.TCounter.value = eval(document.all.TCounter.value)+1
	

 
	var vM="Geo-" + document.all.TGPSThread.value + "-" + document.all.TGPSPW.value + "-" + document.all.DYear.value + "-" + document.all.DMonth.value + "-" + document.all.DDay.value + "-" + document.all.TPage.value + ".txt"

	if (vTest==0){
		ajaxRequest.open("GET", "Threads/" + vM, true);
	} else {
		ajaxRequest.open("GET", "http://www.GrandRapidsRVS.com/Threads/" + vM, true);
		//alert("vM = \n" + "http://www.GPSTrex.com/Threads/" + vM)
	}
	//alert("Testing this site, please return in 30 minutes." + "vTest = " + vTest)
	//return			
	
	//alert(vM)
	ajaxRequest.onreadystatechange = function(){
	
		document.all.TGPSFunction.value='ajaxRequest.onReady'
	
		if(ajaxRequest.readyState === 4) {
 
			vPublic=ajaxRequest.responseText
			
			//alert(vPublic)
 
			if (vPublic.toUpperCase().indexOf("<!DOCTYPE")>-1) {
				 	clearTimeout(vPT);
					clearInterval(vPT); 
					vPT=""						
 
             		if (vICU>0 && oPage!=document.all.TPage.value && eval(document.all.TPage.value)>0){
             			oPage=eval(document.all.TPage.value)
	             		document.all.D3.value="30"
						document.all.DPace.value="30"             		
       	      		vTrackingPlaybackSpeed=eval(document.all.DPace.value) * 1000
						vPT=setTimeout('ajaxFunctionReadBubbles()',vTrackingPlaybackSpeed)              		
						vMarker=0
						
             			alert(vPeepsC + " GPS Trexers found.\n\nTimer reset to every 30 seconds.")						
             			/*
             			
             			clearOverlays()
             			
							 	for (i=2;i<=vPeepsC;i++){
							 		var vHTHold=vPeeps[i]
							 		var vHTPeeps=vHTHold.slice(0,vHTHold.indexOf("|"))
							 		var vHTHold=vHTHold.slice(vHTHold.indexOf("|")+1)
							 		var vHTLatLng=vHTHold.slice(vHTHold.indexOf("(")+1,vHTHold.indexOf(")"))
							 		vnLat=vHTLatLng.slice(0,vHTLatLng.indexOf(","))
							 		//alert("vnLat = " + vnLat)
 
							 		vnLng=vHTLatLng.slice(vHTLatLng.indexOf(",")+1)
							 		//alert("vnLng = " + vnLng)
																	    
								    vLatLng=new google.maps.LatLng(vnLat,vnLng);									
								    map.setCenter(vLatLng)
								    vLatLng=new google.maps.LatLng(vnLat,vnLng);								    
								 	addNewMarker(vLatLng)							 									 		
							 		//alert("vnLat = " + vnLat + "\nvnLng = " + vnLng)
							 		alert(vHTPeeps + "\n" + vnLat + "      " + vnLng)
							 	}
							 		
						*/
 
             			//alert(vPeepsC + " Trex found.")
             			return
             		}
             
 
 
									
			} else {
					//alert("Page read : " + eval(document.all.TPage.value)+1)
					document.all.TPage.value = eval(document.all.TPage.value)+1
					
 
		var vGPSFrom
		
		var vGPSContent
		
		var vGPSTo					
		
		//alert("Found trax!")
		//alert(vPublic)
				
					if (vPublic.indexOf("|")>-1 && vPublic.indexOf("*")>-1) {
					
						//document.all.TPushPin.value=vPublic
						
//alert(vPublic)
 
						var vTmp1=""
					
						vGPSFrom=vPublic.slice(0,vPublic.indexOf("|"))
						vPublic=vPublic.slice(vPublic.indexOf("|")+1)
					
						vGPSContent=vPublic.slice(0,vPublic.indexOf("|"))
						vPublic=vPublic.slice(vPublic.indexOf("|")+1)
										
						vGPSTo=vPublic.slice(0,vPublic.indexOf("|"))
						vPublic=vPublic.slice(vPublic.indexOf("|")+1)
 
 
// ***** if there is a comment it will be picked up here!
 
						vTmp2=""
						
						 //document.all.TPushPinMsg.value=""
						 
						if (document.all.TTrackerPerson.value.toUpperCase()=="*"){
 
						  if (vGPSContent.indexOf("~")>-1){
						  	var vTmp1= vGPSContent.slice(0,vGPSContent.indexOf("~"))
						  	vGPSContent=vGPSContent.slice(vGPSContent.indexOf("~")+1)
						  	
							var vTmp2= vGPSContent.slice(0,vGPSContent.indexOf("~"))						  	
							vGPSContent=vGPSContent.slice(vGPSContent.indexOf("~")+1)
							
							var vTmp3=vGPSContent  // date
							
							vnLat=vTmp1.slice(0,vTmp1.indexOf(","))
							
							vnLng=vTmp1.slice(vTmp1.indexOf(",")+1)
							
							vDat=vTmp3.slice(0,vTmp3.indexOf("  "))
							
							vTim=vTmp3.slice(vTmp3.indexOf("  ")+2)
							
						} else {
							var vnLat=vGPSContent.slice(0,vGPSContent.indexOf(","))
							var vnLng=vGPSContent.slice(vGPSContent.indexOf(",")+1)
 
						}
							
							vLat=vnLat
							
							vLng=vnLng
							
						 
							if (vOffset==1){
								 	point=vnLat + eval(document.all.TLatOffset.value ) + "," + vnLng + eval(document.all.TLngOffset.value)
							 } else{
									 point=vnLat + "," + vnLng
							 }
							 
 
							 		if (vTrex==1){
							 		 clearOverlays()
							 		}
 
							 document.all.TPushPinMsg.value=vTmp2
							
						    vLatLng=new google.maps.LatLng(vnLat,vnLng);
						    
						    map.setCenter(vLatLng)
						    
						    
						    
						    if (vMarker==0){	
						    	vMarker=1	
						    	dPeepGrandRapidsRVS.innerHTML="<br>"				    
							 	addNewMarker(vLatLng)
							 	vPeepsC=0
							 	//vPeeps[vPeeps[vPeepsC]=vGPSFrom
							 } else {
							 	addNewMarker(vLatLng)
							 }
							 
							 	vMatch=0
 
							 	for (i=1;i<=vPeepsC;i++){
							 		var vHT=vPeeps[i].slice(0,vPeeps[i].indexOf("|"))
							 		if (vHT.toUpperCase()==vGPSFrom.toUpperCase()){
							 			vMatch=1
							 			i=vPeepsC
							 		}
							 	}
							 
							 if (vMatch==0){
							 	vPeepsC=vPeepsC+1
							 	//vPeeps[vPeepsC] = vGPSFrom + "|" + vLatLng + "|"
							 	vPeeps[vPeepsC] = vGPSFrom + "|" + vnLat + "," + vnLng + "|"
							 	dPeepGrandRapidsRVS.innerHTML=dPeepGrandRapidsRVS.innerHTML + '<p><font face="verdana" size="2" color="blue" Title="' + vGPSFrom + "  " + vDat + " " + vTim + '" onmouseover=style.cursor="hand";style.color="red" onmouseout=style.color="blue" onclick="fPeeps(' + vPeepsC + ')")>' + vGPSFrom + '</font></p>'
							 }
							 
							 
 
							
						    vPinCount=vPinCount+1
						    
						    document.all.TPinCount.value=vPinCount
						    
							 document.all.TDate.value=vDat	
							 					     
						    document.all.TTime.value=vTim
 
						}
						
						if (vLog==0){
						 	if (vTmp2.length>-1){
								 	dInfo.innerHTML=vDat + " - " + vTim + " - " + vGPSFrom + "<BR>" + vTmp2 + "<BR>" + dInfo.innerHTML
							 } else {
								 dInfo.innerHTML=vDat + " - " + vTim + " - " + vGPSFrom + "<BR>" + dInfo.innerHTML
							 }
						 } else {
						 	if (vTmp2.length>-1){
								 	dInfo.innerHTML=dInfor.innerHTML + vDat + " - " + vTim + "<BR><BR>" + vTmp2 + "<BR>"
							 } else {
								 dInfo.innerHTML=dInfo.innerHTML + vDat + " - " + vTim + "<BR>" 
							 }						 
						 
						 }
						 
						 //alert("- " + vGPSFrom)
						 
					 	clearTimeout(vPT);
						clearInterval(vPT); 
						vPT=""			
						vPT=setTimeout('ajaxFunctionReadBubbles()',vTrackingPlaybackSpeed)							 
						
						if (document.all.TPauseOn.value.length>1){
							if (vTmp2.length>1 && vTmp2.toUpperCase().indexOf(document.all.TPauseOn.value.toUpperCase())>-1){
							 	clearTimeout(vPT);
								clearInterval(vPT); 
								vPT=""
							
								vICU=0								
								vICUDelay=document.all.D3.value								
								vICUPagePause=document.all.TPage.value								
								document.all.BICU.value="  ICU Paused   "
								document.all.BICU.style.background="blue"
								document.all.BICUStep.style.background="blue"
								document.all.BICUStep2.style.background="blue"
			             		document.all.D3.value="1800"
								document.all.DPace.value="1800"
								document.all.dTracking.innerText="ICU Paused"	
 
	             				//vTrackingPlaybackSpeed=eval(document.all.DPace.value) * 1000
								//vPT=setTimeout('ajaxFunctionReadBubbles()',vTrackingPlaybackSpeed)              		
 
             					alert("Comment located!\n\nICU Paused!\n")
 
							}
						}
						
						if (document.all.TStopOn.value.length>1){
							if (vTmp2.length>1 && vTmp2.toUpperCase().indexOf(document.all.TStopOn.value.toUpperCase())>-1){
							 	clearTimeout(vPT);
								clearInterval(vPT); 
								vPT=""
			             		document.all.D3.value="30"
								document.all.DPace.value="30"
	             				vTrackingPlaybackSpeed=eval(document.all.DPace.value) * 1000
								vPT=setTimeout('ajaxFunctionReadBubbles()',vTrackingPlaybackSpeed)              		
								vICU=0
								document.all.dTracking.innerText="ICU Off"	
								document.all.BICU.value="     ICU Off     "
								document.all.BICU.style.background="red"								
alert("Comment located!\n\nICU Off\n\nTimer changed to every 30 seconds.")
								
							}
						}
						
 
					
 
					
				}					
			}
		}
	}
 
	ajaxRequest.send(null); 
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fOffset(){
 
	document.all.TGPSFunction.value='fOffset()'
	if (document.all.BOffset.value=="Offset On"){
		vOffset=0
		document.all.BOffset.value="Offset Off"
	} else {
		vOffset=1
		document.all.BOffset.value="Offset On"
	}
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fGPS(){
 
 
	document.all.TGPSFunction.value='fGPS()'
	document.all.TPage.style.background="white"
	
	clearTimeout(vTC)
	
	vTC=""	
	
 
/* 08/06/2011 disabled for desktop users
	
	if (vGeo==0){
		if (vTracking==1){
			//document.all.BStart.value="Start"
			dTracking.innerText="Tracking Off"
			document.all.BStart.value="Tracking Off"
			document.all.BStart.style.background="Red"
			document.all.BTracking.value="Tracking Off"
			document.all.BTracking.style.background="Red"
			vTracking=0		
			alert("Tracking turned off, no GPS connection!")	
		}
		//alert("Sorry, no GPS available!")
		vTC=setTimeout('fGPS()',vGPSRead)	
		return
	}
 
	*/
	
	if (vGeo==0){
		document.all.TLat.value=vLatDesktop	
		document.all.TLng.value=vLngDesktop	
	} else {
	
		document.all.TGPSFunction.value='fGPS()'
	
		navigator.geolocation.getCurrentPosition(onPositionUpdate);
	
		document.all.TGPSFunction.value='fGPS() back'
	
	}
 
}
 
 
 
 
 
 
 
 
 
 
 
 
 
//var vPosCount=0
 
 
 
 
function onPositionUpdate(position) { 
             
             //alert('onPositionUpdate(' + position + ')')
  
             	//document.all.TGPSFunction.value='onPositionUpdate()'
 
             	
             		//var wpid;
             		//var wpid
					//wpid=navigator.geolocation.watchPosition(geo_success, geo_error, {enableHighAccuracy:true, maximumAge:30000, timeout:27000});
					//alert(wpid)
					wpid=navigator.geolocation.watchPosition(geo_success, geo_error, {enableHighAccuracy:true, maximumAge:30000, timeout:27000});
             
				   document.all.TPage.style.background="Yellow"          
 
                 lat = position.coords.latitude;  
 
                 lng = position.coords.longitude;  
                 
                 document.all.TLat.value=lat;
                 
                 document.all.TLng.value=lng;                 
                 
                 vLat=lat
                 
                 vLng=lng
                 //alert(lat + ", " + lng)
                 
                 //alert("Bingo")
                 
//DSensitivity                 
 
 
                 
				SLat=Math.round(vLat * eval(document.all.DSensitivity.value))/eval(document.all.DSensitivity.value)
				
				SLng=Math.round(vLng * eval(document.all.DSensitivity.value))/eval(document.all.DSensitivity.value)
				
				
				
					
            if (document.all.BDetails.value=="Details On") {
            
                 if (oSLat!=SLat || oSLng!=SLng){
                 
	                 vMsg=""
	                 	
                 		if (oSLat!=SLat){
                 			vMsg="Latitude changed: " + eval(oSLat - SLat) + "\n"
                 		}
                 		if (oSLng!=SLng){
                 			vMsg=vMsg + "Longitude changed: " + eval(oSLng - SLng) + "\n"
                 		}
                 		document.all.TSLat.value=SLat
                 		document.all.TSLng.value=SLng
                 		oSLat=SLat
                 		oSLng=SLng
                 		vSChange=vSChange+1
                 		
                 		if (vSChange>1){
	                 		alert(vMsg)
	                 	}
                 }
         }
                 
                 if (olat!=lat || olng!=lng){
                 
              			olat=lat
              			olng=lng   
 
 
                 
                 if (vFirstTime==0){
	                 	vFirstTime=1
	                 	return
	                	vPinCount=0
                 } 
 
	                 
						     if (vOffset==1){
							 	point=lat + eval(document.all.TLatOffset.value ) + "," + lng + eval(document.all.TLngOffset.value)
							 } else{
								 point=lat + "," + lng
							 }
			 	
							 document.all.TPage.style.background="#CCCCCC"
						     vLatLng=new google.maps.LatLng(lat,lng);
						     vPinCount=eval(vPinCount)+1
						     document.all.TPinCount.value=vPinCount
						     addNewMarker(vLatLng)
 
             }  
             
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
             
             function fDPace(){
             
             	document.all.TGPSFunction.value='fDPace()'
				 	clearTimeout(vGPSRead);
					clearInterval(vGPSRead);
					vGPSRead=""             		
             		vGPSRead=eval(document.all.DPace.value) * 1000
             		vTrackingPlaybackSpeed=eval(document.all.DPace.value) * 1000             
             		document.all.D3.value=document.all.DPace.value
             }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
            
             function fTrackingPlayback(){
             
             	    document.all.TGPSFunction.value='fTrackingPlayback()'
				 	clearTimeout(vGPSRead);
					clearInterval(vGPSRead);
					vGPSRead=""             		
             		vGPSRead=eval(document.all.D3.value) * 1000
             		vTrackingPlaybackSpeed=eval(document.all.D3.value) * 1000
             		document.all.DPace.value=document.all.D3.value
             		
             }
 
 
 
 
 
 
 
 
 
 
 
 
 
             
             function fNewThread(){
	             	document.all.TGPSFunction.value='fNewThread()'
             		document.all.TPage.value=0
             		fGPS()
             }
             
 
 
 
 
 
function fQFetchPlace(){
	//return
	vGeo=0
	try {
	document.all.TGPSFunction.value='fQFetchPlace()'	
	yqlgeo.get('visitor',function(o){
	vLatDesktop=o.place.centroid.latitude	
	
	vLngDesktop=o.place.centroid.longitude
	
	document.all.TLat.value=o.place.centroid.latitude	
	document.all.TLng.value=o.place.centroid.longitude
	//vnLat=o.place.centroid.latitude	
	//vnLng=o.place.centroid.longitude
	//vLatLng=new google.maps.LatLng(o.place.centroid.latitude,o.place.centroid.longitude);
	//addNewMarker(vLatLng)	
	alert(o.place.name + ', ' + o.place.admin1.content + " - " +o.place.country.content +  ' ('+o.place.centroid.latitude+','+o.place.centroid.longitude+')\n')
	
	//alert("Transmitter Latitude, Longitude (" + o.place.centroid.latitude	+ "," + o.place.centroid.longitude + ")")
	}
	);
	} catch(e){
	}
} 
 
 
 
 
           
function fQFetch(){
	//return
	vGeo=0
	try {
	document.all.TGPSFunction.value='fQFetch()'	
	yqlgeo.get('visitor',function(o){
	
	if(o.error){
		alert('No GPS or Geo location detected!');
		vGPS=0
		return
	} else {
		vLatDesktop=o.place.centroid.latitude	
		vLngDesktop=o.place.centroid.longitude
	}
	
	document.all.TLat.value=o.place.centroid.latitude	
	document.all.TLng.value=o.place.centroid.longitude
	
	//vnLat=o.place.centroid.latitude	
	//vnLng=o.place.centroid.longitude
	vLatLng=new google.maps.LatLng(o.place.centroid.latitude,o.place.centroid.longitude);
 	
	alert("GeoLocation is not available on your device!\n\nUsing your device transmiter's IP : " + o.place.name + ', ' + o.place.admin1.content + " - " +o.place.country.content +  ' ('+o.place.centroid.latitude+','+o.place.centroid.longitude+')\n') // Transmitter Latitude, Longitude (' + o.place.centroid.latitude	+ ',' + o.place.centroid.longitude + ')')
	addNewMarker(vLatLng)
	fRoads()		
	//alert("Transmitter Latitude, Longitude (" + o.place.centroid.latitude	+ "," + o.place.centroid.longitude + ")")
	}
	);
	} catch(e){
		vGeo=0
	}
	
} 
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fGPSSendNewPinMsg(){	
 
	document.all.TGPSFunction.value='fGPSSendNewPinMsg()'
 
	oldLat=0	
	oldLng=0	
	vGPSSend=1
	fGPSSendLocation()
	
}
 
 
function fGPSSend(){
 
	ajaxRequest=new XMLHttpRequest();
	 
	document.all.TGPSFunction.value='fGPSSend()'
	/*
	if (vTracking==0){
		dTracking.innerText="Tracking Off"
		return
	}
	*/
 
/* 08/06/2011	
	if (vGeo==0){
		vTracking=0
	 	clearTimeout(vPT);
		clearInterval(vPT);
		vPT=""	
		dTracking.innerText="Tracking Off"
		alert("Sorry, no GPS available on this device!\Tracking turned off!")
		return
	}
	
*/
 
 
if (document.all.TGPSName.value.length<1){
	//dTracking.innerText="Tracking Off"
	//vTracking=0
 	//clearTimeout(vPT);
	//clearInterval(vPT);
	//vPT=""	
	alert("Name is missing!\nTracking turned off!")
	document.all.TGPSName.focus()	
	return
}
 
 
if (document.all.TGPSThread.value.length<1){
	//dTracking.innerText="Tracking Off"
	//vTracking=0	
 	//clearTimeout(vPT);
	//clearInterval(vPT);
	//vPT=""		
	alert("Thread is missing!\nTracking turned off!")	
	document.all.TGPSThread.focus()	
	return
}
 
 
if (document.all.TGPSPW.value.length<1){
	//vTracking=0	
 	//clearTimeout(vPT);
	//clearInterval(vPT);
	//vPT=""		
	alert("Password is missing!\nTracking turned off!")
	//dTracking.innerText="Tracking Off"
	document.all.TGPSPW.focus()
	return
}
 
 
 
		vTrackingPlaybackSpeed=eval(document.all.D3.value) * 1000
	 	clearTimeout(vPT);
		clearInterval(vPT);
		vPT=""		
		vPT=setTimeout('fGPSSendLocation()',vTrackingPlaybackSpeed)		
		
		
		
	//if (document.all.TPushPinMsg.focus==true){
	//	alert("Focus!")
	//	return
	//}		
	
 
 
if (oldLat==vLat && oldLng==vLng && document.all.TPushPinMsg.value.length==-1){
        document.all.TLat.style.background="white"
        document.all.TLng.style.background="white"
        return
}
 
		vnLat=vLat
		vnLng=vLng
 
	    vLatLng=new google.maps.LatLng(vnLat,vnLng);									
	    map.setCenter(vLatLng)
	    
	    
	    
	    vLatLng=new google.maps.LatLng(vnLat,vnLng);								    
	 	addNewMarker(vLatLng)
	 	
		fMapSize()
		
		document.all.TCounter.value=eval(document.all.TCounter.value)+1
		document.all.TCounter.background="white"
 
	//dTracking.innerText="Tracking...."
   //document.all.TCounter.background="yellow"	
   
	
	oldLat=vLat
	oldLng=vLng
	
	document.all.TLat.style.background="yellow"
	document.all.TLng.style.background="yellow"
 
	var vDate= new Date()
	
	if (vGPSSend==1){
		vContent=document.all.TPushPinMsg.value
	} else { vContent=""
	}
	
	vDateTime=vDate.getMonth()+1 + "/" + vDate.getDate()+"/" + vDate.getYear() + "   " + vDate.getHours() + ":" + vDate.getMinutes() + ":" + vDate.getSeconds()	
	var vP="vP=Geo-" + document.all.TGPSThread.value + "|" + document.all.TGPSPW.value + "-" + document.all.DYear.value + "-" + document.all.DMonth.value + "-" + document.all.DDay.value +  "|" + document.all.TGPSName.value + "|*|" + document.all.TLat.value + "," + document.all.TLng.value + "~" + vContent + "~" + vDateTime+ "|"
	//var vP="vP=Geo-" + document.all.TGPSThread.value + "|" + document.all.TGPSPW.value + "|" + document.all.TGPSName.value + "|" + document.all.TTrackerPerson.value + "|" + document.all.TLat.value + "," + document.all.TLng.value + "~" + vContent + "~" + vDateTime+ "|"
 
	if (vTest==0) {
		var msg1="asp/GRRVS.asp?" + vP		
	} else {
		var msg1="http://www.grandrapidsrvs.com/asp/grrvs.asp?" + vP
	}
	
    dTest.innerText=msg1
 
	ajaxRequest.open("GET", msg1, true);
 
	
	ajaxRequest.onreadystatechange=function() { 
	
	
		document.all.TGPSFunction.value='aJaxRequest called'
 
		if (ajaxRequest.readyState===4 && ajaxRequest.status===200) {			
		
 			//alert("Testing:  Send problem!")
		
		} else {
		//alert("Testing:  Message has been sent!")
			document.all.TLat.style.background="white"
			document.all.TLng.style.background="white"		
			//alert(vLat + ", " + vLng)		
			vTrackingSent=vTrackingSent+1
			document.all.TTrackingSent.value=vTrackingSent	
			document.all.TTrackingDate.value=vDateTime
			
			if (vContent.length>0 && vGPSSend==1){			
				alert("Content : \n\n" + vContent + "\nSent!") 
				vContent=""
				vGPSSend=0
				document.all.TPushPinMsg.value=""			
			}							
 
 
		}
	}
 
	ajaxRequest.send(null); 	
 
}
	
 
 
 
 
 
function fGPSSendLocation(){
 
	ajaxRequest=new XMLHttpRequest();
	
	document.all.TGPSFunction.value='fGPSSendLocation()'
	/*
	if (vTracking==0){
		dTracking.innerText="Tracking Off"
		return
	}
	*/
 
/* 08/06/2011	
	if (vGeo==0){
		vTracking=0
	 	clearTimeout(vPT);
		clearInterval(vPT);
		vPT=""	
		dTracking.innerText="Tracking Off"
		alert("Sorry, no GPS available on this device!\Tracking turned off!")
		return
	}
	
*/
 
 
if (document.all.TGPSName.value.length<1){
	//dTracking.innerText="Tracking Off"
	//vTracking=0
 	//clearTimeout(vPT);
	//clearInterval(vPT);
	//vPT=""	
	alert("Name is missing!\nTracking turned off!")
	document.all.TGPSName.focus()	
	return
}
 
 
if (document.all.TGPSThread.value.length<1){
	//dTracking.innerText="Tracking Off"
	//vTracking=0	
 	//clearTimeout(vPT);
	//clearInterval(vPT);
	//vPT=""		
	alert("Thread is missing!\nTracking turned off!")	
	document.all.TGPSThread.focus()	
	return
}
 
 
if (document.all.TGPSPW.value.length<1){
	//vTracking=0	
 	//clearTimeout(vPT);
	//clearInterval(vPT);
	//vPT=""		
	alert("Password is missing!\nTracking turned off!")
	//dTracking.innerText="Tracking Off"
	document.all.TGPSPW.focus()
	return
}
 
 
 
		vTrackingPlaybackSpeed=eval(document.all.D3.value) * 1000
	 	clearTimeout(vPT);
		clearInterval(vPT);
		vPT=""		
		vPT=setTimeout('fGPSSendLocation()',vTrackingPlaybackSpeed)		
		
		
		
	//if (document.all.TPushPinMsg.focus==true){
	//	alert("Focus!")
	//	return
	//}		
	
 
 
if (oldLat==vLat && oldLng==vLng && document.all.TPushPinMsg.value.length==-1){
        document.all.TLat.style.background="white"
        document.all.TLng.style.background="white"
        return
}
if (vGPS==0){
	dTest.innerText="No GPS found!"
	return
}

		vnLat=vLat
		vnLng=vLng
 
	    vLatLng=new google.maps.LatLng(vnLat,vnLng);									
	    map.setCenter(vLatLng)
	    
	    
	    
	    vLatLng=new google.maps.LatLng(vnLat,vnLng);								    
	 	addNewMarker(vLatLng)
	 	
		fMapSize()
		
		document.all.TCounter.value=eval(document.all.TCounter.value)+1
		document.all.TCounter.background="white"
 
	//dTracking.innerText="Tracking...."
   //document.all.TCounter.background="yellow"	
   
	
	oldLat=vLat
	oldLng=vLng
	
	document.all.TLat.style.background="yellow"
	document.all.TLng.style.background="yellow"
 
	var vDate= new Date()
	
	if (vGPSSend==1){
		vContent=document.all.TPushPinMsg.value
	} else { vContent=""
	}
	
	vDateTime=vDate.getMonth()+1 + "/" + vDate.getDate()+"/" + vDate.getYear() + "   " + vDate.getHours() + ":" + vDate.getMinutes() + ":" + vDate.getSeconds()	
	var vP="vP=Geo-" + document.all.TGPSThread.value + "|" + document.all.TGPSPW.value + "-" + document.all.DYear.value + "-" + document.all.DMonth.value + "-" + document.all.DDay.value +  "|" + document.all.TGPSName.value + "|*|" + document.all.TLat.value + "," + document.all.TLng.value + "~" + vContent + "~" + vDateTime+ "|"
	//var vP="vP=Geo-" + document.all.TGPSThread.value + "|" + document.all.TGPSPW.value + "|" + document.all.TGPSName.value + "|" + document.all.TTrackerPerson.value + "|" + document.all.TLat.value + "," + document.all.TLng.value + "~" + vContent + "~" + vDateTime+ "|"
 
	if (vTest==0) {
		var msg1="asp/grrvs.asp?" + vP		
	} else {
		var msg1="http://www.grandrapidsrvs.com/asp/grrvs.asp?" + vP
	}
	
    dTest.innerText=msg1
 
	ajaxRequest.open("GET", msg1, true);
 
	
	ajaxRequest.onreadystatechange=function() { 
	
	
		document.all.TGPSFunction.value='aJaxRequest called'
 
		if (ajaxRequest.readyState===4 && ajaxRequest.status===200) {			
		
 
		
		} else {
			//alert(vLat + ", " + vLng)		
			vTrackingSent=vTrackingSent+1
			document.all.TTrackingSent.value=vTrackingSent	
			document.all.TTrackingDate.value=vDateTime
			document.all.TLat.style.background="white"
			document.all.TLng.style.background="white"			
			//alert("Testing: Sent location, completed!")
			if (vContent.length>0 && vGPSSend==1){			
				alert("Content : \n\n" + vContent + "\nSent!") 
				vContent=""
				vGPSSend=0
				document.all.TPushPinMsg.value=""			
			}							
 
 
		}
	}
 
	ajaxRequest.send(null); 	
 
} 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fTracking(){
 
	document.all.TGPSFunction.value='fTracking()'
	 	clearTimeout(vPT);
		clearInterval(vPT);
		vPT=""
		document.all.TPage.background="white"				
		document.all.TPage.value="0"
		document.all.TCounter.value="0"
	       document.all.TCounter.background="red"
	if (document.all.BTracking.value=="Tracking Off"){
		document.all.BTracking.value="Tracking On"
		document.all.BStart.value="Tracking On"
		document.all.BStart.style.background="#008000"
		document.all.BTracking.style.background="#008000"		
		//BTracking" onclick=fTracking() style="background-color: #008000; color: #FFFF00; font-family: Verdana; font-weight: bold
		dTracking.innerText="Tracking On"
		vTracking=1
		oPage=0
		vICU=0
		vPinsC=0		
		vTrackingPlaybackSpeed=eval(document.all.D3.value) * 1000
		vPT=setTimeout('fGPSSendLocation()',vTrackingPlaybackSpeed)		
		oldLat=0
		oldLng=0
		//fGPSSend()
		initialize()
		//document.all.TCounter.value=0		
		//document.all.TPage.value=0
	} else {
		document.all.BTracking.value="Tracking Off"
		dTracking.innerText="Tracking Off"
		document.all.BStart.value="Tracking Off"
		document.all.BStart.style.background="Red"
		document.all.BTracking.style.background="Red"		
		//document.all.TPage.value=0
		vTracking=0
		vPinsC=0
	}
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fICU(){
 
	document.all.TGPSFunction.value='fICU()'
	 	clearTimeout(vPT);
		clearInterval(vPT);
		vPT=""
	if (document.all.BICU.value=="  ICU Paused   "){
 
								vICU=1								
								document.all.TPage.value=vICUPagePause
								document.all.BICU.value="      ICU On      " 
								document.all.BICU.style.background="green"
								document.all.BICUStep.style.background="green"
								document.all.BICUStep2.style.background="green"
			             		document.all.D3.value=vICUDelay
								document.all.DPace.value=vICUDelay								
								document.all.dTracking.innerText="ICU On"	
								vTrackingPlaybackSpeed=eval(document.all.D3.value) * 1000
								vPT=setTimeout('ajaxFunctionReadBubbles()',vTrackingPlaybackSpeed)								
		return
	}
		
	if (document.all.BICU.value=="     ICU Off     "){
		document.all.BICU.value="      ICU On      "		
		document.all.BICU.style.background="#008000"
		vICU=1
		oPage=0
		vTracking=0
		document.all.dTracking.innerText="ICU On"
		vTrackingPlaybackSpeed=eval(document.all.D3.value) * 1000
		vPT=setTimeout('ajaxFunctionReadBubbles()',vTrackingPlaybackSpeed)
		vPinCount=0		
		document.all.TCounter.value=0
       document.all.TCounter.background="#CCCCCC"
		document.all.TPage.value=0
		document.all.TPinCount.value=0
		document.all.TPushPinMsg.value=""
		dInfo.innerHTML=""		
	} else {
		document.all.BICU.value="     ICU Off     "		
		document.all.BICU.style.background="red"
		document.all.BICUStep.style.background="Red"
		document.all.BICUStep2.style.background="Red"
		vICU=0
	}
}
   
             
//  fGPS()
//  vPT  speed of tracking
// fTracking   vPT controls looking to see if lat or lng changed and sending in the data
// fTrackingPlayback  controls the speed of both tracking and reading
/*
retreive map with makers
http://maps.google.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap
&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318
&markers=color:red%7Ccolor:red%7Clabel:C%7C40.718217,-73.998284&sensor=false
*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function geo_success(position){
 
 
	document.all.TGPSFunction.value='geo_success(' + position + ')'
 
	// This is the function which is called each time the Geo location position is updated
 
	//alert("Stop button")
	
	info_string="";
 
	var d=new Date();     // Date object, used below for output messahe
	
	var h=d.getHours();
	
	var m=d.getMinutes();
	
	var s=d.getSeconds();
		
	
	var current_datetime=format_time_component(h)+":"+format_time_component(m)+":"+format_time_component(s);
 
	document.all.TGPSFunction.value='back to geo_success(' + position + ')'
	
		
	// Check that the accuracy of our Geo location is sufficient for our needs
 
	if(position.coords.accuracy<=min_accuracy)	{
	// We do not want to action anything if our position has not changed - we need this because on IPhone Safari at least, we get repeated readings of the same location with 
	// different accuracy which seems to count as a different reading - maybe it iss just a very slightly different reading or maybe altitude, accuracy etc has changed
 
	if(prev_lat!=position.coords.latitude || prev_long!=position.coords.longitude){
	
			if(position.coords.speed>max_speed)
				max_speed=position.coords.speed;
			else if(position.coords.speed<min_speed)
				min_speed=position.coords.speed;
				
			if(position.coords.altitude>max_altitude)
				max_altitude=position.coords.altitude;
			else if(position.coords.altitude<min_altitude)
				min_altitude=position.coords.altitude;			
				prev_lat=position.coords.latitude;
				prev_long=position.coords.longitude;			
 
			
			document.all.TLat.value=position.coords.latitude
			document.all.TLng.value=position.coords.longitude
			
			document.all.TLat.background="red"
			document.all.TLng.background="red"
			
			}
		
		//info_string="Accuracy not sufficient ("+Math.round(position.coords.accuracy, 1)+"m vs "+min_accuracy+"m) - last reading taken at: "+current_datetime;
 
}
 
if (document.all.BDetails.value=="Details On"){
			info_string="Current positon:\n" + "Latitude="+position.coords.latitude+ "\nLongitude="+position.coords.longitude + "\n\n" +
			" (accuracy " + Math.round(position.coords.accuracy, 1)+ "m)\n" +
			" Speed: min=" + (min_speed?min_speed:"Not recorded/0") + "m/s, max=" + (max_speed?max_speed:"Not recorded/0")+"m/s \n" +
			" Altitude: min=" + (min_altitude?min_altitude:"Not recorded/0")+"m, max="+(max_altitude?max_altitude:"Not recorded/0") + "m \n" + 
			" (accuracy " + Math.round(position.coords.altitudeAccuracy,1)+"m) \n" +
			" Last reading taken : " + current_datetime + "\n\n" +
			" Max altitude : " + max_altitude + "\n" +
			" Min altitude : " + min_altitude + "\n" +
			" Max speed: " + max_speed + "\n" + 
			" Min speed: " + min_speed + "\n" 
		
			document.all.TGeoStats.value=info_string
		} else {
			document.all.TGeoStats.value=""
		}
	}
	
	
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
	
function fDetails(){
 
	document.all.TGPSFunction.value='fDetails()'
	if (document.all.BDetails.value=="Details On"){
		document.all.BDetails.value="Details Off"
	} else {
		document.all.BDetails.value="Details On"
	}
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function geo_error(error){

	document.all.TGPSFunction.value='geo_error(' + error.TIMEOUT + ')'
	// This function is called each time navigator.geolocation.watchPosition() generates an error (i.e. cannot get a Geo location reading)
	switch(error.code)	{
		case 1:
			document.all.TGPSError.value="Permission Denied"
			break;
		case 2:
			document.all.TGPSError.value="Position unavailable"
			break;
		case 3:
			document.all.TGPSError.value="Timeout"
			break;
		case error.TIMEOUT:
			//alert("Timeout!")
			document.all.TGPSError.value="No Geo Reading...."
			break;
		default:
			document.all.TGPSError.value="Reading: " + vLatLng
			break;
	};
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function format_time_component(time_component){
 
 
	document.all.TGPSFunction.value='format_time_component(' + time_component + ')'
 
	// This function just adds a leading "0" to time/date components which are <10 (because there is no cross-browser way I know of to do this using the date object)
 
 
	if(time_component<10)
 
		time_component="0"+time_component;
 
	else if(time_component.length<2)
 
		time_component=time_component+"0";
 
	return time_component;
 
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fLog(){
 
	document.all.TGPSFunction.value='fLog()'
	if (document.all.BLog.value=="    Log (newest on top)    "){
		document.all.BLog.value="    Log (oldest on top)    "
		vLog=1
	} else {
		document.all.Blog.value="    Log (newest on top)    "
		vLog=0
	}
}
 
 
 
 
 
 
 
 
 
 
 
function TMsgSend(){
 
	document.all.TGPSFunction.value='TMsgSend()'
	//ajaxFunctionReadBubbles()
	vGPSSend=1
	fGPSSend()
	
	
	/* 08/06/2011
	if (vTracking==1){
		fGPSSendNewPinMsg()
	} else {
		alert("You need to turn Tracking On!")
	}
	*/
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fMaps(){
 
	document.all.TGPSFunction.value='fMaps()'
	switch (document.all.DMaps.value) {
	
		case "Hybrid":
		fHybrid()
		break;
		
		case "Roads":
		fRoads()
		break;
		
		case "Satellite":
		fSatellite()
		break;
		
		case "Terrain":
		fTerrain()
		break;
		
		default:
	}
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fMarkerMsg(){
 
	document.all.TGPSFunction.value='fMarkerMsg()'
	alert("Sorry Marker Messages is not available at this time!")
}
 
 
 
 
 
 
 
 
 
 
 
 
 
function fClearInfo(){
 
	document.all.TGPSFunction.value='fClearInfo()'
	dInfo.innerText=""
}
 
 
 
 
 
 
 
 
 
function fICUQuickStep(){
	dInfoContainer.style.pixelLeft=600
	dInfoContainer.style.pixelTop=0
 
	dDisplay.style.pixelTop=0
	dDisplay.style.pixelLeft=-2000
 
	
	document.all.TGPSFunction.value='fICUQuickStep()'
	oPage=0
	document.all.TPage.value="0"
	document.all.D3.value=".25"
	document.all.DPace.value=".25"
	document.all.BICU.value="      ICU On      "
	document.all.BICU.style.background="#008000" 
	vICU=1
	vTracking=0
	document.all.dTracking.innerText="ICU On"
	vPinCount=0		
	document.all.TCounter.value=0
   document.all.TCounter.background="#CCCCCC"
	document.all.TPinCount.value=0
	document.all.TPushPinMsg.value=""
	dInfo.innerHTML=""
	vTrackingPlaybackSpeed=eval(document.all.DPace.value) * 1000
	
   vPT=setTimeout('ajaxFunctionReadBubbles()',vTrackingPlaybackSpeed)	
 
	document.all.BTracking.value="Tracking Off"
	dTracking.innerText="Tracking Off"
	document.all.BStart.value="Tracking Off"
	document.all.BStart.style.background="Red"
	document.all.BTracking.style.background="Red"		
	vTracking=0
	vPinsC=0
	
}
 
var vTrex=0
 
function fICUTrex(){
  vTrex=1
  fICUQuickStep()
}
 
 
 
 
 
 
 
 
 
 
//	dHow.style.pixelLeft=200
//	dHow.style.pixelTop=150
	dHow.style.pixelLeft=0
	dHow.style.pixelTop=0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fHowGone(){
	document.all.TGPSFunction.value='fHowGone()'
    dHow.style.pixelLeft=-1000
    dHow.style.pixelTop=-1000
    
    dMap_position.style.pixelLeft=0
    dMap_position.style.pixelTop=0
	//dDisplay.style.pixelTop=700
	//dDisplay.style.pixelLeft=0    
    initialize()
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fHow(){
	document.all.TGPSFunction.value='fHow()'
	dHow.style.pixelLeft=200
	dHow.style.pixelTop=150
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fDeleteTracks(){
	document.all.TGPSFunction.value='fDeleteTracks()'
	document.all.TPushPinMsg.value="[DELETE]"
	fGPSSend()	
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fSensitivity(){
 
	document.all.TGPSFunction.value='fSensitivity()'
	vSChange=0
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
	//document.all.TDateStampMonth.value=monthnumber
	document.all.DMonth.value=monthnumber
	document.all.DDay.value=monthday
	document.all.DYear.value = year
	
// Add and remove Pins http://code.google.com/apis/maps/documentation/javascript/examples/overlay-remove.html	
// var stockholm = new google.maps.LatLng(document.all.TLat.value,document.all.TLng.value);	
// var stockholm = new google.maps.LatLng(59.32522, 18.07002);
// var parliament = new google.maps.LatLng(59.327383, 18.06747);  
	
// alert(Math.round(42.15822637081146 * 10000)/10000)
// alert(Math.round(-85.48327803611755 * 10000) / 10000)
// changed -0.0001000
// setting 10000
// changed 0.0536  & -0.0780
// changed -0.0514 & -0.04589999
// changed 0.05140000 & 0.04589999999
// changed -0.0514000000 & -0.046899999999
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  function initializer() {
  
	document.all.TGPSFunction.value='initializer()'  
 
  	if (document.all.TLat.value==""){
  		alert("Sorry, no GPS or IP found.")
  		return
  	}
  	
 
	  var vCenterMap = new google.maps.LatLng(document.all.TLat.value,document.all.TLng.value);  	
	  
    var mapOptions = {
      zoom: 13,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      center: vCenterMap
    };
 
    map = new google.maps.Map(document.getElementById("map_canvas"),
            mapOptions);
          
    
  
  
    marker = new google.maps.Marker({
      map:map,
      draggable:true,
      animation: google.maps.Animation.DROP,
      position: vCenterMap
    });
    google.maps.event.addListener(marker, 'click', toggleBounce);
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function toggleBounce() {
  
	document.all.TGPSFunction.value='toggleBounce()'  
 
    if (marker.getAnimation() != null) {
      marker.setAnimation(null);
      alert("Sorry bounce is not available!")
    } else {
      marker.setAnimation(google.maps.Animation.BOUNCE);
    }
  }
 
    var geocoder = null;
 
    function initializeReverseGeolocator() {
    
	document.all.TGPSFunction.value='initializeReverseGeolocator()'
	    
      if (GBrowserIsCompatible()) {
 
			if (document.all.TLat.value==""){
				document.all.TLat.value="42.15822637081146"
				document.all.TLng.value="-85.48327803611755"
			}
			
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(document.all.TLat.value,document.all.TLng.value), vMapSize);
        map.addControl(new GSmallZoomControl());
        geocoder = new GClientGeocoder();
        GEvent.addListener(map, "click", clicked);
        map.openInfoWindow(map.getCenter(), "Click map for location!");
      }
    }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    function clicked(overlay, latlng) {
    
	document.all.TGPSFunction.value='clicked(overlay, latlng'
    
 
		if (document.all.BReverse.value==" Reverse Geolocator Off "){          
		   return
		}    
		
      if (latlng) {
        geocoder.getLocations(latlng, function(addresses) {
          if(addresses.Status.code != 200) {
            alert("reverse geocoder failed to find an address for " + latlng.toUrlValue());
          }
          else {
            address = addresses.Placemark[0];
            var myHtml = address.address;
            //map.openInfoWindow(latlng, myHtml);
            
            var vThis=latlng.toUrlValue()
 
			dInfo.innerHTML='<p style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="2" color="#000000" onmouseover=style.cursor="hand";style.color="blue" onmouseout=style.color="black" TITLE="' + vThis + '" onclick=fShowLocation("' + vThis + '")>&nbsp;* ' + myHtml + '</font></p>' + dInfo.innerHTML
 
 
          }
        });
      }
    }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fReverse(){
 
	document.all.TGPSFunction.value='fReverse()'
 
	 if (document.all.BReverse.value==" Reverse Geolocator Off "){
		 document.all.BReverse.value=" Reverse Geolocator On "
		 initializeReverseGeolocator()
	 } else {
		document.all.BReverse.value=" Reverse Geolocator Off "
	 }
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function place_marker(vLat,vLng){
     // Set latitude and longitudes     
	var point = new google.maps.LatLng(vLat,vLng);     
// Move map to the particular point and zoom out the map     
map.setCenter(point,5);     
// Create our "tiny" marker icon     
var marker = new GIcon(G_DEFAULT_ICON,'images/red.png');     
marker.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png";     
// Set GMarkerOptions object     
markerOptions = { icon:marker };    
 // place marker that at location     
var latlng = new GLatLng(vLat,vLng);     
map.addOverlay(new GMarker(latlng, markerOptions)); 
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
function fShowLocation(LL){
 
	document.all.TGPSFunction.value='fShowLocation(LL)'
 
	document.all.TLat.value=LL.slice(0,LL.indexOf(","))
	
	document.all.TLng.value=LL.slice(LL.indexOf(",")+1)
 
 
   map = new GMap2(document.getElementById("map_canvas"));
   map.setCenter(new GLatLng(document.all.TLat.value,document.all.TLng.value), vMapSize);
   map.addControl(new GSmallZoomControl());
   geocoder = new GClientGeocoder();   
	  
    var mapOptions = {
      zoom: 13,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      center: LL
    };
 
  
}
 
// http://maps.gstatic.com/intl/en_us/mapfiles/332a/maps2.api/main.js
 
// TPushPinMsg
// fGPSSendNewPinMsg()
// You need to turn tracking on
 
dInfoContainer.style.pixelLeft=-1500
dInfoContainer.style.pixelTop=-1000
 
dDisplay.style.pixelTop=0
dDisplay.style.pixelLeft=-2000

var vIP=document.all.TExact.value
if (document.all.TGPSName.value.length<2){
for(i=1;i<vIP.length;i++){
	if (vIP.charAt(i)!="."){
		document.all.TGPSName.value=document.all.TGPSName.value+vIP.charAt(i)
	}else{
		document.all.TGPSName.value=document.all.TGPSName.value+"_"

	}
}
}

vTest=0

