
/*
REM JavaScript functions for Make/Model selector ("YMM Lite")
REM Works on both NetScape (4.0+) and IE (4.0+).
REM Look at \source\misc\home.asp for an example of how to use these functions.
*/
function mmInitialize(parent, make, model, make_caption, model_caption, bnew)
{
    mmInitializeEx(parent, make, model, make_caption, model_caption, bnew, false);
}


function mmInitializeEx(parent, make, model, make_caption, model_caption, bnew, buse_short_name)
    {
    var rgMake;

    if (parent.mmType)
      setDefaultByText(parent.mmType, bnew == 'true' ? 'New' : 'Used');

    clearList(parent.Make);
    
    addElement(parent.Make, make_caption, 0);
    
    if (bnew == 'true')
        {
        for (var i = 0; i < mmMkN.length; i++)
            {
            if (mmMkN[i])
                {
                rgMake = mmMkN[i].split('#');
                addElement(parent.Make, rgMake[0], rgMake[1]);
                }
            }
        }
    else
        {
        for (var i = 0; i < mmMkU.length; i++)
            if (mmMkU[i])
                {
                rgMake = mmMkU[i].split('#');
                addElement(parent.Make, rgMake[0], rgMake[1]);
                }
        }

    if (make)
        {
        setDefaultByText(parent.Make, make);
        
        if (model_caption != "none")
            mmChangeMakeEx(parent, bnew, model_caption, buse_short_name);
        
        if (model)
            setDefaultByText(parent.Model, model);
        }
    else
        {
        parent.Make.selectedIndex = 0;
        mmChangeMakeEx(parent, bnew, model_caption, buse_short_name);
        }
    }


function mmChangeMake(parent, bnew, model_caption)
    {
    mmChangeMakeEx(parent, bnew, model_caption, false);
    }


function mmChangeMakeEx(parent, bnew, model_caption, buse_short_name)
    {
    if (bnew == 'true')
        var ModelList = mmMdN[parent.Make.options[parent.Make.selectedIndex].value];
    else
        var ModelList = mmMdU[parent.Make.options[parent.Make.selectedIndex].value];

    clearList(parent.Model);
    addElement(parent.Model, model_caption, 0);
    if(ModelList)
        {
        var rgModels = ModelList.split(',');
        for (var i = 0; i < rgModels.length; i++)
            {
            if (rgModels[i])
                {
                var rgModel = rgModels[i].split('#');
                addElement(parent.Model, (buse_short_name == true ? MakeShortName(rgModel[0]) : rgModel[0]), rgModel[1]);
                }
            }
        parent.Model.disabled = false;
        }
    else
        {
        parent.Model.disabled = true;
        }

    parent.Model.selectedIndex = 0;
    } 

// In order for model names to fit within the 130px-wide LeftNav control we need to modify
// some of the model names so that they fit.  Any name "tweaks" here must go through 
// editorial...
function MakeShortName(sName)
{
    switch(sName)
    {
        case "3-Series Sport Wagon":
            return("3-Series Sprt Wgn");
        case "5-Series Sport Wagon":
            return("5-Series Sprt Wgn");
        case "Passat Wagon (2001.5)":
            return("Passat Wgn (01.5)");
        case "Caprice Classic Wagon":
            return("Caprice Clssic Wgn");
        case "Power Ram 50 Sport Cab":
            return("Pwr Ram 50 Sport");
        case "Explorer  Sport Trac":
            return("Explorer Sport Trac");
        case "LTD Crown Victoria Wagon":
            return("LTD Crown Vic Wgn");
        case "Grand Marquis Wagon":
            return("Grand Marquis Wgn");
        case "Cutlass Ciera Wagon":
            return("Cutlass Ciera Wgn");
        default:
            return(sName);    
    }
}
