﻿/// <reference path="jquery-1.4.1-vsdoc.js"/>

//global variables for the countries and cities comboboxes
var cbxModel;

function pageLoad() {
    // initialize the global variables
    // in this event all client objects 
    // are already created and initialized 
    cbxMan = $find("ctl00_ContentPlaceHolder1_cbxMan");
    cbxModel = $find("ctl00_ContentPlaceHolder1_cbxModel");
}

function LoadModels(combo, args) {
    var item = args.get_item();
    cbxModel.set_text("Loading...");
    cbxModel.clearSelection();

    // if a manufacturer is selected
    if (item.get_index() > 0) {
        // this will fire the ItemsRequested event of the 
        // models combobox passing the man_id as a parameter 
        cbxModel.requestItems(item.get_value(), false);
    }
    else {
        // the -Select a continent- item was chosen
        cbxModel.set_text(" ");
        cbxModel.clearItems();
    }
}

function ItemsLoaded(combo, eventArqs) {
    if (combo.get_items().get_count() > 0) {
        // pre-select the first item
        combo.set_text(combo.get_items().getItem(0).get_text());
        combo.get_items().getItem(0).highlight();
    }
    else 
    {
        var item = cbxMan.get_selectedItem();
        cbxModel.requestItems(item.get_value(), false);
    }
    combo.showDropDown();
}


if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();
