function pageInit() {
    quickfindInit();
    myCitiesInit();
    cityTableInit();
}

function quickfindInit() {
    $("select.guideIndexJump").change(function() {
        if (this.value !== '')
            window.location.href = '/go/' + this.value + '/index.html';
    });

    $("select.guideIndexJump").show();
}

var MyCities;

function myCitiesInit() {
    MyCities = new myCities();
    try {
        MyCities.Init();
    } catch (e) {
        console.log(e);
    }

    $("li#myCitiesActionsRemove").click(function() {
        MyCities.DropAndSave();
    });

    $("li#myCitiesActionsGo").click(function() {
        MyCities.Go();
    })

    $("div#myCities").show();
}

function cityTableInit() {
    $("table.guideIndexCities tr").each(function() {
        this.onmouseover = function() {
            this.className = "guideIndexCity_over";
        }

        this.onmouseout = function() {
            this.className = "guideIndexCity";
        }

        this.onclick = function() {
            handleAddCity(this);
        }
    });

    $("div#guideIndexCitiesBox").show();
}

function handleAddCity(objRow) {
    MyCities.AddAndSave(objRow.id.replace("guideIndexCity_", ""));
}
