
function AreYouSure()
{
	return confirm('Are You Sure?');
}

function showTrafficInfo(bShow){
    if(bShow) trafficInfo.show();
    else trafficInfo.hide();
}

function IconType(iconType){
    this._iconType = iconType;
}

IconType.prototype.toInt = function(){ return this._iconType; };
IconType.Camera = new IconType(0);
IconType.Incident = new IconType(1);
IconType.Construction = new IconType(2);
function addIcon(iconType, nLat, nLong, hoverText, bodyText, map, id){
    var icon = new GIcon();
    if(iconType == IconType.Camera){
        icon.image = "images/cam.gif";
        icon.iconSize = new GSize(20,13);
        icon.shadowSize = new GSize(20,13);
    }
    else if(iconType == IconType.Incident) {
        icon.image = "images/incident.gif";
        icon.iconSize = new GSize(25,25);
        icon.shadowSize = new GSize(25,25);
    }
    else if(iconType == IconType.Construction){
        icon.image = "images/construction.gif";
        icon.iconSize = new GSize(32,32);
        icon.shadowSize = new GSize(32,32);
    }
    icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
    icon.iconAnchor = new GPoint(10,10);
    icon.infoWindowAnchor = new GPoint(5,1);
    var point = new GLatLng(nLat, nLong);
    if(iconType == IconType.Camera){
        window['CameraMarker' + id] = new GMarker(point, {icon: icon, title: hoverText});
        GEvent.addListener(window['CameraMarker' + id], "click", 
            function(){
                var camSrc = "CameraImage.aspx?CameraID=" + id + "&dt=" + new Date().getTime();
                var insertHtml = "<iframe width='380' height='300' frameborder='0' scrolling='no' src='" + camSrc + "'></iframe>";
                window['CameraMarker' + id].openInfoWindowHtml(insertHtml);
            }
        );
        map.addOverlay(window['CameraMarker' + id]);
    }
    else if(iconType == IconType.Incident) {
        window['IncidentMarker' + id] = new GMarker(point, {icon: icon, title: hoverText});
        GEvent.addListener(window['IncidentMarker' + id], "click", 
            function(){
                window['IncidentMarker' + id].openInfoWindowHtml(bodyText);
            }
        );
        map.addOverlay(window['IncidentMarker' + id]);
    }
    else if(iconType == IconType.Construction) {
        window['ConstructionMarker' + id] = new GMarker(point, {icon: icon, title: hoverText});
        GEvent.addListener(window['ConstructionMarker' + id], "click", 
            function(){
                window['ConstructionMarker' + id].openInfoWindowHtml(bodyText);
            }
        );
        map.addOverlay(window['ConstructionMarker' + id]);
    }
}

var trafficInfo;
function load(latCenter, lngCenter, initZoom) {
  preloadimages('/images/downPtz_pressed.jpg','/images/upPtz_pressed.jpg','/images/leftPtz_pressed.jpg','/images/rightPtz_pressed.jpg', '/images/zoomNear_pressed.jpg', '/images/zoomFar_pressed.jpg', '/images/focusNear_pressed.jpg', '/images/focusFar_pressed.jpg');
  if (GBrowserIsCompatible()) {
    trafficInfo = new GTrafficOverlay();
    var map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(latCenter, lngCenter), initZoom);
    var mapControl = new GMapTypeControl();
    map.addControl(mapControl);
    map.addControl(new GLargeMapControl());
    loadCameras(map);
    loadIncidents(map);
    loadConstructions(map);
    map.addOverlay(trafficInfo);
  }
}
var clickedCam = -1;
function clickCam(id) {
    clickedCam = id;
    setTimeout("popupCam()", 10);
    document.location.hash = "map";
}

function popupCam() {
    if (window['CameraMarker' + clickedCam] != null)
        GEvent.trigger(window['CameraMarker' + clickedCam], 'click');
    clickedCam = -1;
}