//-------------------------------------------------------------
// Load URL in a PopUp Window
//-------------------------------------------------------------
function popUp(url)
{
	window.open(url, 'Details', 'toolbar=0, scrollbars=1, location=0, statusbar=0, menubar=0, resizable=0, width=600, height=500, left=10, top=10');
}

//-------------------------------------------------------------
// Add to Shortlist
//-------------------------------------------------------------
function addToShortlist(url)
{
    if (confirm('Are you sure you want to add this vehicle to your Shortlist?'))
    {
        popUp(url);
    }
}

//-------------------------------------------------------------
// Select all checkboxes
//-------------------------------------------------------------
function selectAllCheckboxes(allChkBox)
{
    var state = allChkBox.checked;    
    var elements = allChkBox.form.elements;

    for (i = 0; i < elements.length; i++)
    {
        if ((elements[i].type == "checkbox") && (elements[i].id != allChkBox.id))
        {
            if (elements[i].checked != state)
            {
                elements[i].click();
            }
        }
    }
}

//-------------------------------------------------------------
// Populate makes and models
//-------------------------------------------------------------
function doLists(make, model)
{
	var i = 0;

    if (typeof getMakes == 'function' && typeof getModels == 'function' && typeof models == 'object' && typeof makeOptionValue == 'object' && typeof makeOptionText == 'object')
    {
        if (make == "")
        {
		    getMakes();
		    getModels(models[0]);
        }
        else
        {
	        getMakes(make);

            if (document.frmSearch && document.frmSearch.ddlMake && typeof document.frmSearch.ddlMake.selectedIndex == 'number')
            {
                i = document.frmSearch.ddlMake.selectedIndex;
            }

            getModels(models[i], model);
        }
    }
}

//-------------------------------------------------------------
// Populate makes
//-------------------------------------------------------------
function getMakes(make)
{
    var dropDown;
    var selectedIndex = 0;

    if (document.frmSearch && document.frmSearch.ddlMake)
    {
	    dropDown = document.frmSearch.ddlMake;
    }
    else if (document.search && document.search.ddlMake)
    {
	    dropDown = document.search.ddlMake;
    }
    else if (document.forms[0] && document.forms[0].ddlMake)
    {
	    dropDown = document.forms[0].ddlMake;
    }

    if (dropDown)
    {
        dropDown.length = 0;

        for (i = 0; i < makeOptionText.length; i++)
        {			
            dropDown[i] = new Option(makeOptionText[i], makeOptionValue[i]);

            if (makeOptionValue[i].toUpperCase() == make)
            {
                selectedIndex = i;
            }
        }

        dropDown.options[selectedIndex].selected = true;
    }
}

//-------------------------------------------------------------
// Populate models using makes
//-------------------------------------------------------------
function getModels(modelRange, model)
{
    selectedIndex = 0;
    var dropDown;

    if (document.frmSearch && document.frmSearch.ddlModel)
    {
	    dropDown = document.frmSearch.ddlModel;
    }
    else if (document.search && document.search.ddlModel)
    {
	    dropDown = document.search.ddlModel;
    }
    else if (document.forms[0] && document.forms[0].ddlModel)
    {
	    dropDown = document.forms[0].ddlModel;
    }

    if (dropDown)
    {
        dropDown.length = 0;

        for (i = 0; i < modelRange.length; i++)
        {
            if (modelRange[i] == "MODEL")
            {
	            dropDown[i] = new Option(modelRange[i], "ANY");
            }
            else if (modelRange[i] == "ANY MODEL")
            {
	            dropDown[i] = new Option(modelRange[i], "ANY");
            }
            else
            {
	            dropDown[i] = new Option(modelRange[i], modelRange[i]);
            }

            if (modelRange[i].toUpperCase() == model)
            {
	            selectedIndex = i;
            }
        }

        dropDown.options[selectedIndex].selected = true;
    }
}
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->