/********************************************************************
 *
 * Manages DMS RSS 
 * Author: TTI, Michael Montgomery
 * Date:   July 7, 2008
 *
 * Uses code from TxDOT's scriptATMSInc.js written by TxDOT, Leobardo J. Landeros
 *
 *******************************************************************/

var ATMSIncTimer;
var veLayerATMSInc = null;
var bLayerATMSInc = false;
var kATMSIncRSSFile = "RSS/ATMS.xml?";
var ATMSIncReloadTime = 180000;

/**
 * Loads the ATMS Incidents Layer
 * Author: TxDOT. Leobardo J. Landeros
 */
function ConfigureATMSIcons(layer) //taken from Leo's code
{
    var iShapes = layer.GetShapeCount();
    for(var i=0; i < iShapes; ++i) {
        var shape = layer.GetShapeByIndex(i);
	  //idMess=shape.GetDescription().split("~");
        //shape.SetCustomIcon("<img src='../Images/atmsincident.gif' height='15px' width='17px' />");	
	  customIcon = new VECustomIconSpecification();
	  customIcon.CustomHTML = "<img src='../Images/atmsincident.gif'>";
	  shape.SetCustomIcon(customIcon);
    }
}

// Load Dynamic Message signs map layer -- Modified 7/7/8
// Created: Gabriel, 5/15/07
// Butchered and sewn back together for your viewing pleasure

function LoadATMSs(go)
{
	//return;
    showProgressIndicator("Loading ATMS Incidents");
    if (!go)
        //Time out to show the progress indicator
        //calls itself with a value to go to the ELSE portion
        setTimeout(function() { LoadATMSs(1); }, iAsyncDelay);
    else {
        if (!bLayerATMSInc) {
            veLayerATMSInc = new VEShapeLayer();        
            var veShapeSpec = new VEShapeSourceSpecification(VEDataType.GeoRSS, 
                              kATMSIncRSSFile + Math.random(), veLayerATMSInc); 
            //passes ConfigureDMSIcons the layer from veShapeSpec: "kATMSIncRSSFile"
            map.ImportShapeLayerData(veShapeSpec, ConfigureATMSIcons, false);
            bLayerATMSInc = true;
        }
        else veLayerATMSInc.Show();
        hideProgressIndicator();
    }
}
