var poly = false;
function seeDays(value){
        divob=document.getElementById("duration");
        if (value){
                divob.style.display="";
			
        }else{
                divob.style.display="none";
        }
}

function load(lat,lon,site,points,center){
if (!GBrowserIsCompatible()) {
        alert('Sorry, your browser is not compatible');
 }else{
	if ((lat=='')&&(lon)==''){
        var point = new GLatLng(39.5,-113.5);
	var zoom=5;
	}else{
        	var point = new GLatLng(lat,lon);
		if (center){
			var zoom=7;
		}else{
			var zoom=10;
		}
	}
        var map = new GMap2(document.getElementById("map_canvas"), {draggableCursor: 'pointer'});
	map.addOverlay(new GScreenOverlay('shadowedgeleft.png', new GScreenPoint(0,0,'pixels','pixels'), new GScreenPoint(0,0,'pixels','pixels'), new GScreenSize(10,720,'pixels','pixels')));
	map.addOverlay(new GScreenOverlay('shadowedgetop.png', new GScreenPoint(0,1,'fraction','fraction'), new GScreenPoint(0,10,'pixels','pixels'), new GScreenSize(720,10,'pixels','pixels')));
        map.addMapType(G_PHYSICAL_MAP);
        map.removeMapType(G_NORMAL_MAP);
        map.setCenter(point, zoom,G_PHYSICAL_MAP);
G_PHYSICAL_MAP.getMinimumResolution=function (){ return 6 };
G_PHYSICAL_MAP.getMaximumResolution=function (){ return 10 };
        GEvent.addListener(map, "click", function(overlay,point){
		if (overlay) return;
                if (point){
			var formOb=document.getElementById("getLocationWT");
			var checked='';
			var duration='';
			var interval='';
			if (formOb.table!=null){
				if (formOb.table[0].checked){
					checked='&table=custom';
				}else if (formOb.table[1].checked){
					checked='&table=xml';
				}else if (formOb.table[2].checked){
					checked='&table=totalf';
				}else if (formOb.table[3].checked){
					checked='&table=pfm';
				}else if (formOb.table[4].checked){
					checked='&table=tab';
				}else if (formOb.table[5].checked){
					checked='&table=graph';
				}
				if (formOb.duration[0].checked){
					duration='&duration=1';
				}else if (formOb.duration[1].checked){
					duration='&duration=2';
				}else if (formOb.duration[2].checked){
					duration='&duration=3';
				}else if (formOb.duration[3].checked){
					duration='&duration=4';
				}else if (formOb.duration[4].checked){
					duration='&duration=5';
				}else if (formOb.duration[5].checked){
					duration='&duration=6';
				}else if (formOb.duration[6].checked){
					duration='&duration=7';
				}
				if (formOb.interval[0].checked){
					interval='&interval=1';
				}else if (formOb.interval[1].checked){
					interval='&interval=3';
				}else if (formOb.interval[2].checked){
					interval='&interval=6';
				}
			}
                        var list='?lat='+point.y+'&lon='+point.x+site;
                        parent.location.href='/forecast/wxtables/index.php'+list+checked+duration+interval;
		}
                
        });//end addListener function
        map.addControl(new GLargeMapControl());
        // put polygon on map (from gTopoMap.js)
	if(points){
		var polygon = new GPolygon(points, "#f33f00",1,1,"#ff0000");
		map.addOverlay(polygon);
	}
	var crosshair = new GIcon();
	crosshair.image = 'crosshair.png';
	crosshair.iconAnchor = new GPoint(8,8);
	map.addOverlay(new GMarker(new GLatLng(lat,lon), {
		icon: crosshair,
		clickable: false,
		title: 'Requested location'
	}));
}
}

function putPolygon(map, points){
	var polygon = new GPolygon(points, "#f33f00",1,1,"#ff0000");
	map.addOverlay(polygon);
	var tooltip
	//enableToolTip(polygon);

	function enableToolTip(polygon){
		function placeTooltip(mousePosition){
		    currtype = map.getCurrentMapType().getProjection();
		    startPoint = currtype.fromLatLngToPixel(map.fromDivPixelToLatLng(new GPoint(50, 60), true), map.getZoom());
		    var offset = currtype.fromLatLngToPixel(mousePosition, map.getZoom());
		    var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(offset.x - startPoint.x, offset.y - startPoint.y));
		    pos.apply(tooltip);
		}
		var gridSize=Math.round(polygon.getArea()/100000)/10;
		tooltip=document.createElement("div");
		tooltip.className="tooltip";
		tooltip.style.width="100px";
		tooltip.style.fontSize="11px";
		tooltip.style.fontFamily="Arial";
		tooltip.style.color="black";
		tooltip.style.background="white";
		tooltip.innerHTML='The Forecast Displayed is for This '+gridSize+' square km Area';
		tooltip.style.display="none";
		map.getPane(G_MAP_FLOAT_PANE).appendChild(tooltip);
		GEvent.addListener(map, 'mousemove', placeTooltip);
	
		var inPolys=false;
		GEvent.addListener(polygon, 'mouseover', function(){
			polygon.color="#ffff00";
			polygon.redraw(true);
			tooltip.style.display="block";
			inPolys=true;
		});
		GEvent.addListener(polygon, 'mouseout', function(){
			polygon.color="#f33f00";
			polygon.redraw(true);
			inPolys=false;
			if (!inPolys)
				tooltip.style.display="none";
		});
	}
}


