﻿var markers=new Array();
var closedMarkers=new Array();

var workzones
var workzones_future
var incidents
var conditions
var flood

var toolTip2

function removePointsAndLines(){
    
    for (c=0;c<markers.length;c++){
        map.removeOverlay(markers[c]);
    }
    
    for (c=0;c<closedMarkers.length;c++){
        map.removeOverlay(closedMarkers[c]);
    }
    
    for (c=0;c<lines.length;c++){
        map.removeOverlay(lines[c]);
    }
    lines.length=0;
    
    for (c=0;c<closedLines.length;c++){
        map.removeOverlay(closedLines[c]);
    }
    closedLines.length=0;
    
    for (c=0;c<workzoneLines.length;c++){
        map.removeOverlay(workzoneLines[c]);
    }
    for (c=0;c<workzoneLines_Future.length;c++){
        map.removeOverlay(workzoneLines_Future[c]);
    }

    for (c=0;c<incidentLines.length;c++){
        map.removeOverlay(incidentLines[c]);
    }

    for (c=0;c<conditionStateLines.length;c++){
        map.removeOverlay(conditionStateLines[c]);
    }
    
    for (c=0;c<conditionLines.length;c++){
        map.removeOverlay(conditionLines[c]);
    }
    
    for (c=0;c<floodLines.length;c++){
        map.removeOverlay(floodLines[c]);
    }
    
    if (selectedRoute)map.removeOverlay(selectedRoute);
}

function clearPoints(type){
    for (c=0;c<markers.length;c++){
        if (markers[c].type.toUpperCase()==type.toUpperCase()&&markers[c].inMap){
            map.removeOverlay(markers[c]);
            markers[c].inMap=false;
        }
    }
    chkEnable();
    hideLoading();
}

function createPointArray(pointArray,type){

	var globalPoints = pointArray.split("#");

    var thePoints=globalPoints[0].split(";");
    var theAttributes=globalPoints[1].split(";");
    var pointvalues;

    var gPoints=[];
    
    for (c=0;c<thePoints.length;c++){
        gPoints[c]=new Array();
	var thePointsSplit = thePoints[c].split(",");
        gPoints[c][0]=new GLatLng(thePointsSplit[0],thePointsSplit[1]);

        pointvalues=theAttributes[c].split(",");
        
        for (n=0;n<pointvalues.length;n++){
            gPoints[c][n+1]=pointvalues[n];
        }
    }

    switch (type.toUpperCase()) {
        case 'CONDITIONS':
            conditions=gPoints;
            break;
       case 'WORKZONES_FUTURE':
            workzones_future=gPoints;
            break;
        case 'WORKZONES':
            workzones=gPoints;
            break;
        case 'INCIDENTS':
            incidents=gPoints;
            break;
        case 'FLOOD':
            flood=gPoints;
            break;
    }
}

function addPointsToMap(type){

    var left=map.getBounds().getSouthWest().lng();
    var bottom=map.getBounds().getSouthWest().lat();
    var top=map.getBounds().getNorthEast().lat();
    var right=map.getBounds().getNorthEast().lng();
   
    for (c=0;c<markers.length;c++){
        if (markers[c].type.toUpperCase()==type.toUpperCase()){
            if (bottom<markers[c].getPoint().lat()&&top>markers[c].getPoint().lat()&&left<markers[c].getPoint().lng()&&right>markers[c].getPoint().lng()){
                markers[c].inMap=true;
                map.addOverlay(markers[c]);
            }
        }
    }

    chkEnable();
    hideLoading();
}

function getDesg(desg){
    switch (desg.toUpperCase()){
        case "IS":
            return "Interstate";
            break;
        case "US":
            return "US";
            break;
        case "MO": case "RT":
            return "State Route";
            break;
        case "SP":
            return "Spur";
            break;
        case "BU":
            return "Business";
            break;
        case "LP":
            return "Loop";
            break;
        case "AL":
            return "Alt";
            break;
        case "RP":
            return "Ramp";
            break;
        case "OR":
            return "Outer Road";
            break;
        case "CRD": case "CST":
            return "";
            break;
        case "RA":
            return "Rest Area";
            break;
    }
}

function getDir(dir){
    switch (dir.toUpperCase()){
        case "E":
            return "East";
            break;
        case "N":
            return "North";
            break;
        case "S":
            return "South";
            break;
        case "W":
            return "West";
            break;
    }
}

function createMarkers(pointArray){
    var description
    var holddesc
    var holdtooltip
    
	// winter weather special zoom
    	var winterWeatherClosureEnvelope = null;
    
    switch (pointArray.toUpperCase()) {
        case 'INCIDENTS':
            if (incidents){
                for (c=0;c<incidents.length;c++){
                    description='';
                              
                    if (incidents[c][4].toUpperCase()=='PLANNED'){
                        description+='<span style="color:red; font-weight:bold; font-size:larger;">FUTURE ROAD CLOSURE</span><br/><br/>';
                        if (incidents[c][23]=='D'){
                            description+='<strong>' + getDesg(incidents[c][1].replace(/^\s+|\s+$/g,"")) + ' ' + incidents[c][2].replace(/^\s+|\s+$/g,"") + ' ' + getDir(incidents[c][3].replace(/^\s+|\s+$/g,"")) + '</strong><br />';
                        }
                        else {
                            description+='<strong>' + getDesg(incidents[c][1].replace(/^\s+|\s+$/g,"")) + ' ' + incidents[c][2].replace(/^\s+|\s+$/g,"") + '</strong><br />';
                        }
                        
                        description+=incidents[c][14].replace(/^\s+|\s+$/g,"").toProperCase()+' County<br /><br />';
                        if (incidents[c][25]){
                            description+=incidents[c][25]+'<br/><br/>';
                        }
                        description+='Closure scheduled on ' + incidents[c][5] + ', beginning at ' + incidents[c][6] + ',<br />';
                        
                        if (parseFloat(incidents[c][7])>=96){
                            description+='Road scheduled to be closed until further notice.<br />';
                        }
                        else {
                            description+='Road closure estimated to last ' + incidents[c][7] + ' hour(s), ending on ' + incidents[c][11] + '.<br />';
                        }
                        
                        holdtooltip=description;
                        
                        closedMarkers.push(createMarker(incidents[c][0],createIcon('Images/PlannedClosure.gif'),'incidents',null,holdtooltip,null,description,incidents[c][24],incidents[c][15],incidents[c][16],incidents[c][17],incidents[c][18]));
                    }
                    else if (incidents[c][4].toUpperCase()=='WINTER WEATHER CLOSURE'){
                        description+='<span style="color:red; font-weight:bold; font-size:larger;">ROAD CLOSED</span><br/><br/>';
                        if (incidents[c][23]=='D'){
                            description+='<strong>' + getDesg(incidents[c][1].replace(/^\s+|\s+$/g,"")) + ' ' + incidents[c][2].replace(/^\s+|\s+$/g,"") + ' ' + getDir(incidents[c][3].replace(/^\s+|\s+$/g,"")) + '</strong><br />';
                        }
                        else {
                            description+='<strong>' + getDesg(incidents[c][1].replace(/^\s+|\s+$/g,"")) + ' ' + incidents[c][2].replace(/^\s+|\s+$/g,"") + '</strong><br />';
                        }
                        description+=incidents[c][14].replace(/^\s+|\s+$/g,"").toProperCase()+' County<br /><br />';
                        description+='Road closed due to winter weather.<br /><br />';
                        if (incidents[c][25]){
                            description+=incidents[c][25]+'<br/><br/>';
                        }
                        description+='Road reported closed at ' + incidents[c][6] + ' on ' + incidents[c][5] + '.<br />';
                        
                        if (parseFloat(incidents[c][7])>=96){
                            description+='Road closed until further notice.<br />';
                        }
                        else {
                            description+='Road closure estimated to last ' + incidents[c][7] + ' hour(s), ending on ' + incidents[c][11] + '.<br />';
                        }
                        
                        holdtooltip=description;
                        
                        closedMarkers.push(createMarker(incidents[c][0],createIcon('Images/CoveredIconRed.gif'),'incidents',null,holdtooltip,null,description,incidents[c][24],incidents[c][15],incidents[c][16],incidents[c][17],incidents[c][18]));
			
			// winter weather special zoom
			if(winterWeatherClosureEnvelope == null)
			{
				winterWeatherClosureEnvelope = { 
					xmin: incidents[c][0].x - 0.1,
					xmax: incidents[c][0].x + 0.1,
					ymin: incidents[c][0].y - 0.1,
					ymax: incidents[c][0].y + 0.1
				}
			}
			else
			{
				if(incidents[c][0].x < winterWeatherClosureEnvelope.xmin)  winterWeatherClosureEnvelope.xmin = incidents[c][0].x;
				if(incidents[c][0].x > winterWeatherClosureEnvelope.xmax)  winterWeatherClosureEnvelope.xmax = incidents[c][0].x;
				if(incidents[c][0].y < winterWeatherClosureEnvelope.ymin)  winterWeatherClosureEnvelope.ymin = incidents[c][0].y;
				if(incidents[c][0].y > winterWeatherClosureEnvelope.ymax)  winterWeatherClosureEnvelope.ymax = incidents[c][0].y;
			}
                    }
                    else {
                        if (incidents[c][26].toUpperCase()=='CLOSED'||incidents[c][26].toUpperCase()==''){
                            description+='<span style="color:red; font-weight:bold; font-size:larger;">ROAD CLOSED</span><br/><br/>';
                        }
                        if (incidents[c][23]=='D'){
                            description+='<strong>' + getDesg(incidents[c][1].replace(/^\s+|\s+$/g,"")) + ' ' + incidents[c][2].replace(/^\s+|\s+$/g,"") + ' ' + getDir(incidents[c][3].replace(/^\s+|\s+$/g,"")) + '</strong><br />';
                        }
                        else {
                            description+='<strong>' + getDesg(incidents[c][1].replace(/^\s+|\s+$/g,"")) + ' ' + incidents[c][2].replace(/^\s+|\s+$/g,"") + '</strong><br />';
                        }
                        description+=incidents[c][14].replace(/^\s+|\s+$/g,"").toProperCase()+' County<br /><br />';
                        description+=incidents[c][4].replace(/^\s+|\s+$/g,"").toProperCase() + '<br /><br />';
                        if (incidents[c][25]){
                            description+=incidents[c][25]+'<br/><br/>';
                        }
                        //description+='Incident located ' + incidents[c][12] + '.<br />';
                        description+='Incident reported at ' + incidents[c][6] + ' on ' + incidents[c][5] + '.<br />';
                        
                        
                        if (parseFloat(incidents[c][7])>=96){
                            if (incidents[c][26].toUpperCase()=='CLOSED'||incidents[c][26].toUpperCase()==''){
                                description+='Road closed until further notice.<br />';
                            }
                            else {
                                description+='Traffic will be impacted until further notice.<br />';
                            }
                        }
                        else {
                            if (incidents[c][26].toUpperCase()=='CLOSED'){
                                description+='Road closure estimated to last ' + incidents[c][7] + ' hour(s), ending on ' + incidents[c][11] + '.<br />';
                            }
                            else {
                                description+='Incident estimated to last ' + incidents[c][7] + ' hour(s), ending on ' + incidents[c][11] + '.<br />';
                            }
                        }
                        
                        holdtooltip=description;
                        
                        switch (incidents[c][26].toUpperCase()){
                            case 'POSSIBLE DELAYS':
                                markers.push(createMarker(incidents[c][0],createIcon('Images/IncidentIconYellow.gif'),'incidents',null,holdtooltip,null,description,incidents[c][24],incidents[c][15],incidents[c][16],incidents[c][17],incidents[c][18]));
                                break;
                            case 'EXPECT DELAYS':
                                markers.push(createMarker(incidents[c][0],createIcon('Images/IncidentIconOrange.gif'),'incidents',null,holdtooltip,null,description,incidents[c][24],incidents[c][15],incidents[c][16],incidents[c][17],incidents[c][18]));
                                break;
                            default:
                                closedMarkers.push(createMarker(incidents[c][0],createIcon('Images/IncidentIcon2.gif'),'incidents',null,holdtooltip,null,description,incidents[c][24],incidents[c][15],incidents[c][16],incidents[c][17],incidents[c][18]));
                                break;
                        }
                    }
                }
		
		// winter weather special zoom
		//point = new GLatLng(39.85,-96.2);
		//var _mkr = createMarker(point,createIcon('Images/Snow_zoom_in.jpg'),'conditions',null,'Right click for zoom options',null,'no description',null,'39','-94','40','-93','Images/Snow_zoom_in.gif',100,35);
		//if(winterWeatherClosureEnvelope != null)
		//{
		//	_mkr.specialEnvelope = winterWeatherClosureEnvelope;
		//}
		//closedMarkers.push(_mkr);
            }
            break;
        case 'FLOOD':
            if (flood){
                for (c=0;c<flood.length;c++){
                    
                    description='';
                    description+='<span style="color:red; font-weight:bold; font-size:larger;">ROAD CLOSED</span><br/><br/>';
                    if (flood[c][16]=='D'){
                        description+='<strong>' + getDesg(flood[c][9].replace(/^\s+|\s+$/g,"")) + ' ' + flood[c][10].replace(/^\s+|\s+$/g,"") + ' ' + getDir(flood[c][11].replace(/^\s+|\s+$/g,"")) + '</strong><br />';
                    }
                    else {
                        description+='<strong>' + getDesg(flood[c][9].replace(/^\s+|\s+$/g,"")) + ' ' + flood[c][10].replace(/^\s+|\s+$/g,"") + '</strong><br />';
                    }
                    description+=flood[c][3].replace(/^\s+|\s+$/g,"").toProperCase() + ' County<br /><br />';
                    description+='Road closed due to flooding<br/>';
                    description+='since ' + flood[c][7] + '.<br /><br />';
                    
                    if (flood[c][5]){
                        description+=flood[c][5].toProperCase() + '<br /><br />';
                    }
                    
                    //if (flood[c][6]){
                    //    description+='Estimated water depth: ' + flood[c][6] + '.<br />';
                    //}
                    
                    holdtooltip='';
                    //holdtooltip+=flood[c][9].replace(/^\s+|\s+$/g,"") + ' ' + flood[c][10].replace(/^\s+|\s+$/g,"") + ' ' + flood[c][11].replace(/^\s+|\s+$/g,"") + '<br/>Flood';
                    holdtooltip=description;
                    
                    closedMarkers.push(createMarker(flood[c][0],createIcon('Images/Flood-red-water.gif'),'flood',null,holdtooltip,null,description,null,flood[c][12],flood[c][13],flood[c][14],flood[c][15]));
                }
            }
            break;
        case 'CONDITIONS':
            if (conditions){
                for (c=0;c<conditions.length;c++){
                
                    description='';
                    if (conditions[c][3].toUpperCase()=='CLOSED'){
                        description+='<span style="color:red; font-weight:bold; font-size:larger;">ROAD CLOSED</span><br/><br/>';
                        description+='<strong>'+getDesg(conditions[c][4])+' '+conditions[c][5]+'<br/><br/>Road closed due to winter weather.<strong/><br/>';
                    }
                    else {
                        description+='<strong>'+getDesg(conditions[c][4])+' '+conditions[c][5]+'<br/><br/>'+conditions[c][3]+'<strong/><br/>';
                    }
                    
                    description+='From ' + conditions[c][1] + ' to ' + conditions[c][2] + '.';
                    
                    holdtooltip=description;
                   
                    switch (conditions[c][3].toUpperCase()){
                        case 'DRY':
                            markers.push(createMarker(conditions[c][0],createIcon('Images/greendotlarge.gif'),'conditions','DRY',holdtooltip,conditions[c][4],description));
                            break;
                        case 'WET':
                            markers.push(createMarker(conditions[c][0],createIcon('Images/WetIcon.gif'),'conditions','WET',holdtooltip,conditions[c][4],description));
                            break;
                        case 'PARTLY COVERED':
                            markers.push(createMarker(conditions[c][0],createIcon('Images/PartiallyCoveredIcon.gif'),'conditions','PARTLY COVERED',holdtooltip,conditions[c][4],description));
                            break;
                        case 'COVERED':
                            markers.push(createMarker(conditions[c][0],createIcon('Images/CoveredIcon.gif'),'conditions','COVERED',holdtooltip,conditions[c][4],description));
                            break;
                        case 'CLOSED':
                            closedMarkers.push(createMarker(conditions[c][0],createIcon('Images/CoveredIconRed.gif'),'conditions','CLOSED',holdtooltip,conditions[c][4],description,null,conditions[c][6],conditions[c][7],conditions[c][8],conditions[c][9]));
                            break;
                    }
                }
            }
            else {
                rcEmpty=true;
            }
            break;
        case 'WORKZONES':
            if (workzones){
                for (c=0;c<workzones.length;c++){

                    description='';
                    if (workzones[c][15].toUpperCase()=='CLOSED')description+='<span style="color:red; font-weight:bold; font-size:larger;">ROAD CLOSED</span><br/><br/>';
                    if (workzones[c][25]=='D'){
                        description+='<strong>' + getDesg(workzones[c][1].replace(/^\s+|\s+$/g,"")) + ' ' + workzones[c][2].replace(/^\s+|\s+$/g,"") + ' ' + getDir(workzones[c][3].replace(/^\s+|\s+$/g,"")) + '</strong><br />';
                    }
                    else {
                        description+='<strong>' + getDesg(workzones[c][1].replace(/^\s+|\s+$/g,"")) + ' ' + workzones[c][2].replace(/^\s+|\s+$/g,"") + '</strong><br />';
                    }
                    description+=workzones[c][24].toProperCase() + ' County<br /><br />';
                    description+=workzones[c][8].replace(/^\s+|\s+$/g,"").toProperCase() + ' scheduled<br />';
                    description+='from ' + workzones[c][6].replace(/^\s+|\s+$/g,"") + ' to ' + workzones[c][7].replace(/^\s+|\s+$/g,"") + '<br/><br/>';
                    
                   // if (workzones[c][15].toUpperCase()=="CLOSED"){
                   //     description+='Please seek an alternate route.';
                   // }
		if (workzones[c][15].toUpperCase()=="CLOSED"){
                        if(workzones[c][26]=="133517" ||workzones[c][26]=="133516"){
                        description+='Free ferry services available 6 30am to 6 30pm.<br /> ';
                        }
                        description+='Please seek an alternate route.';
                    	}
                    else {
                        switch (workzones[c][9].replace(/^\s+|\s+$/g,"")){
                            case "24 HOUR":
                                description+='Work will be done around the clock, ';
                                break;
                            case "DAY":
                                description+='Work will be done during daylight hours, ';
                                break;
                            case "NIGHT":
                                description+='Work will be done at night, ';
                                break;
                        }
                        
                        switch (workzones[c][10].replace(/^\s+|\s+$/g,"")){
                            case "BOTH":
                                description+='7 days a week.<br />';
                                break;
                            case "NONE":
                                description+='on weekdays only.<br />';
                                break;
                            case "SATURDAY":
                                description+='on weekdays and Saturdays.<br />';
                                break;
                            case "SUNDAY":
                                description+='on weekdays and Sundays.<br />';
                                break;
                        }
                        
                        //description+='Work will begin on ' + workzones[c][6].replace(/^\s+|\s+$/g,"") + ', and end on ' + workzones[c][7].replace(/^\s+|\s+$/g,"") + '<br />';
                        
                        switch (workzones[c][14].replace(/^\s+|\s+$/g,"")){
                            case "RIGHT":
                                description+='Work will be done on the right lanes.<br />';
                                break;
                            case "LEFT":
                                description+='Work will be done on the left lanes.<br />';
                                break;
                            case "MIDDLE":
                                description+='Work will be done on the middle lanes.<br />';
                                break;
                            case "NONE":
                                description+='Work will not be done on any driving lanes.<br />';
                                break;
                            case "VARIOUS":
                                description+='Work will be done on various lanes.<br />';
                                break;
                        }
                    }
                    
                    holdtooltip='';
                    //holdtooltip+=workzones[c][1].replace(/^\s+|\s+$/g,"") + ' ' + workzones[c][2].replace(/^\s+|\s+$/g,"") + ' ' + workzones[c][3].replace(/^\s+|\s+$/g,"") + '<br/>' + workzones[c][8].replace(/^\s+|\s+$/g,"");
                    holdtooltip=description;
                    
                    switch (workzones[c][15].toUpperCase()){
                        case 'LOW':
                            markers.push(createMarker(workzones[c][0],createIcon('Images/Flaggergreen.gif'),'workzones','LOW',holdtooltip,workzones[c][1],description,workzones[c][26],workzones[c][16],workzones[c][17],workzones[c][18],workzones[c][19],'Images/HeaderModot.jpg','298','59'));
                            break;
                        case 'MEDIUM':
                            markers.push(createMarker(workzones[c][0],createIcon('Images/Flaggeryellow.gif'),'workzones','MEDIUM',holdtooltip,workzones[c][1],description,workzones[c][26],workzones[c][16],workzones[c][17],workzones[c][18],workzones[c][19],'Images/HeaderModot.jpg','298','59'));
                            break;
                        case 'HIGH':
                            markers.push(createMarker(workzones[c][0],createIcon('Images/WorkZoneIcon.gif'),'workzones','HIGH',holdtooltip,workzones[c][1],description,workzones[c][26],workzones[c][16],workzones[c][17],workzones[c][18],workzones[c][19],'Images/HeaderModot.jpg','298','59'));
                            break;
                        case 'CLOSED':
                            closedMarkers.push(createMarker(workzones[c][0],createIcon('Images/Flaggerred.gif'),'workzones','CLOSED',holdtooltip,workzones[c][1],description,workzones[c][26],workzones[c][16],workzones[c][17],workzones[c][18],workzones[c][19],'Images/HeaderModot.jpg','298','59'));
                            break;
                    }
                }
            }
            break;
            case 'WORKZONES_FUTURE':
            if (workzones_future){
                for (c=0;c<workzones_future.length;c++){

                    description='<span style="color:blue; font-weight:bold; font-size:larger;">Future Work Zone</span><br/><br/>';
                    if (workzones_future[c][15].toUpperCase()=='CLOSED')description+='<span style="color:blue; font-weight:bold; font-size:larger;">Future Road Closure</span><br/><br/>';
                    if (workzones_future[c][25]=='D'){
                        description+='<strong>' + getDesg(workzones_future[c][1].replace(/^\s+|\s+$/g,"")) + ' ' + workzones_future[c][2].replace(/^\s+|\s+$/g,"") + ' ' + getDir(workzones_future[c][3].replace(/^\s+|\s+$/g,"")) + '</strong><br />';
                    }
                    else {
                        description+='<strong>' + getDesg(workzones_future[c][1].replace(/^\s+|\s+$/g,"")) + ' ' + workzones_future[c][2].replace(/^\s+|\s+$/g,"") + '</strong><br />';
                    }
                    description+=workzones_future[c][24].toProperCase() + ' County<br /><br />';
                    description+=workzones_future[c][8].replace(/^\s+|\s+$/g,"").toProperCase() + ' scheduled<br />';
                    description+='from ' + workzones_future[c][6].replace(/^\s+|\s+$/g,"") + ' to ' + workzones_future[c][7].replace(/^\s+|\s+$/g,"") + '<br/><br/>';
                    
                    if (workzones_future[c][15].toUpperCase()=="CLOSED"){
                        description+='Please seek an alternate route.';
                    }
                    else {
                        switch (workzones_future[c][9].replace(/^\s+|\s+$/g,"")){
                            case "24 HOUR":
                                description+='Work will be done around the clock, ';
                                break;
                            case "DAY":
                                description+='Work will be done during daylight hours, ';
                                break;
                            case "NIGHT":
                                description+='Work will be done at night, ';
                                break;
                        }
                        
                        switch (workzones_future[c][10].replace(/^\s+|\s+$/g,"")){
                            case "BOTH":
                                description+='7 days a week.<br />';
                                break;
                            case "NONE":
                                description+='on weekdays only.<br />';
                                break;
                            case "SATURDAY":
                                description+='on weekdays and Saturdays.<br />';
                                break;
                            case "SUNDAY":
                                description+='on weekdays and Sundays.<br />';
                                break;
                        }
                        
                        //description+='Work will begin on ' + workzones_future[c][6].replace(/^\s+|\s+$/g,"") + ', and end on ' + workzones_future[c][7].replace(/^\s+|\s+$/g,"") + '<br />';
                        
                        switch (workzones_future[c][14].replace(/^\s+|\s+$/g,"")){
                            case "RIGHT":
                                description+='Work will be done on the right lanes.<br />';
                                break;
                            case "LEFT":
                                description+='Work will be done on the left lanes.<br />';
                                break;
                            case "MIDDLE":
                                description+='Work will be done on the middle lanes.<br />';
                                break;
                            case "NONE":
                                description+='Work will not be done on any driving lanes.<br />';
                                break;
                            case "VARIOUS":
                                description+='Work will be done on various lanes.<br />';
                                break;
                        }
                    }
                    
                    holdtooltip='';
                    //holdtooltip+=workzones_future[c][1].replace(/^\s+|\s+$/g,"") + ' ' + workzones_future[c][2].replace(/^\s+|\s+$/g,"") + ' ' + workzones_future[c][3].replace(/^\s+|\s+$/g,"") + '<br/>' + workzones_future[c][8].replace(/^\s+|\s+$/g,"");
                    holdtooltip=description;
                    
                    switch (workzones_future[c][15].toUpperCase()){
                        case 'LOW':
                            markers.push(createMarker(workzones_future[c][0],createIcon('Images/Flaggerblue.gif'),'workzones_future','LOW',holdtooltip,workzones_future[c][1],description,workzones_future[c][26],workzones_future[c][16],workzones_future[c][17],workzones_future[c][18],workzones_future[c][19],'Images/HeaderModot.jpg','298','59'));
                            break;
                        case 'MEDIUM':
                            markers.push(createMarker(workzones_future[c][0],createIcon('Images/Flaggerblue.gif'),'workzones_future','MEDIUM',holdtooltip,workzones_future[c][1],description,workzones_future[c][26],workzones_future[c][16],workzones_future[c][17],workzones_future[c][18],workzones_future[c][19],'Images/HeaderModot.jpg','298','59'));
                            break;
                        case 'HIGH':
                            markers.push(createMarker(workzones_future[c][0],createIcon('Images/Flaggerblue.gif'),'workzones_future','HIGH',holdtooltip,workzones_future[c][1],description,workzones_future[c][26],workzones_future[c][16],workzones_future[c][17],workzones_future[c][18],workzones_future[c][19],'Images/HeaderModot.jpg','298','59'));
                            break;
                        case 'CLOSED':
                           // closedMarkers.push(createMarker(workzones_future[c][0],createIcon('Images/Flaggerblue.jpg'),'workzones_future','CLOSED',holdtooltip,workzones_future[c][1],description,workzones_future[c][26],workzones_future[c][16],workzones_future[c][17],workzones_future[c][18],workzones_future[c][19],'Images/HeaderModot.jpg','298','59'));
                           markers.push(createMarker(workzones_future[c][0],createIcon('Images/Flaggerblue.gif'),'workzones_future','HIGH',holdtooltip,workzones_future[c][1],description,workzones_future[c][26],workzones_future[c][16],workzones_future[c][17],workzones_future[c][18],workzones_future[c][19],'Images/HeaderModot.jpg','298','59'));
                            break;
                    }
                }
            }
            break;
     }
}

function createMarker(point,icon,mtype,mseverity,mtooltip,mdesg,mdescription,fid,minY,minX,maxY,maxX,mImagePath,mImageWidth,mImageHeight) {
    var marker = new GMarker(point,{icon: icon,title:''});
    if (!marker.point)marker.point = marker.getPoint();
    if (mdescription)marker.html = mdescription;
    if (mImagePath)
    {
    	marker.image = new Object;
	marker.image.path = mImagePath;
	marker.image.width = mImageWidth;
	marker.image.height = mImageHeight;
    }
    marker.name='marker' + (markerCount);
    marker.inMap=false;
    if (mtype)marker.type=mtype;
    if (mdesg)marker.desg=mdesg;
    if (fid)marker.twfid=fid;
    if (minY)marker.minY=minY;
    if (minX)marker.minX=minX;
    if (maxY)marker.maxY=maxY;
    if (maxX)marker.maxX=maxX;
    //if (mtooltip){marker.toolTip='<div text-align="center" valign="center" style="color: #000080; font-size: 8pt; font-family: Arial; font-weight: bold; width: 80; height: 15; border-style: ridge; border-width: 2; background-color: #FFFFFF">' + mtooltip + '</div>';}
    if (mtooltip)marker.toolTip=mtooltip;
    GEvent.addListener(marker,"mouseover", function() {
        show_toolTip(marker);
        if(marker.twfid)window.status=marker.twfid;
    });
    GEvent.addListener(marker,"mouseout", function() {
        toolTip2.style.visibility='hidden';
        window.status='';
    });
    
    markerCount++;
  
    return marker;
}

function createIcon(path){
	/*
    var theIcon=new GIcon();
    theIcon.image=path;
    theIcon.iconSize=new GSize(23,23);
    theIcon.iconAnchor = new GPoint(6, 7);
    theIcon.infoWindowAnchor = new GPoint(10,10);
    return theIcon;
	*/
	switch (path)
	{
		case 'Images/CoveredIconRed.gif':
                	var theIcon=new GIcon();
                        theIcon.image=path;
                        theIcon.iconSize=new GSize(13,13);
                        theIcon.iconAnchor = new GPoint(6, 7);
                        theIcon.infoWindowAnchor = new GPoint(10,10);
                        break;
		case 'Images/Snow_zoom_in.jpg':
                	var theIcon=new GIcon();
                        theIcon.image=path;
                        theIcon.iconSize=new GSize(100,35);
                        theIcon.iconAnchor = new GPoint(6, 7);
                        theIcon.infoWindowAnchor = new GPoint(10,10);
                        break;
		default:
                	var theIcon=new GIcon();
                        theIcon.image=path;
                        theIcon.iconSize=new GSize(23,23);
                        theIcon.iconAnchor = new GPoint(6, 7);
                        theIcon.infoWindowAnchor = new GPoint(10,10);
	}
	return theIcon;
}

