function clearStation(len)
{
    var i;
    for (i=0; i<len; i++){
        document.search_form.station.options[i] = null;
    }
}

function clearESchool(len)
{
    var i;
    for (i=0; i<len; i++){
        document.search_form.elementary_school.options[i] = null;
    }
}

function clearJHSchool(len)
{
    var i;
    for (i=0; i<len; i++){
        document.search_form.junior_high_school.options[i] = null;
    }
}

function setLineStation(n)
{
    optlen = document.search_form.station.options.length;
    while(optlen > 0){
        clearStation(optlen);
        optlen = document.search_form.station.options.length;
    }
    
    if (LineStationItem[n].length > 0){
        for (i=0; i<LineStationItem[n].length; i+=2){
            document.search_form.station.options[i/2] = new Option(LineStationItem[n][i+1],LineStationItem[n][i]);
        }
    }
}

function setCity(n)
{
    setESchoolItem(n);
    setJHSchoolItem(n);
}

function setESchoolItem(n)
{
    optlen = document.search_form.elementary_school.options.length;
    while(optlen > 0){
        clearESchool(optlen);
        optlen = document.search_form.elementary_school.options.length;
    }
    
    if (ESchoolItem[n].length > 0){
        for (i=0; i<ESchoolItem[n].length; i+=2){
            document.search_form.elementary_school.options[i/2] = new Option(ESchoolItem[n][i+1],ESchoolItem[n][i]);
        }
    }
}

function setJHSchoolItem(n)
{
    optlen = document.search_form.junior_high_school.options.length;
    while(optlen > 0){
        clearJHSchool(optlen);
        optlen = document.search_form.junior_high_school.options.length;
    }
    
    if (JHSchoolItem[n].length > 0){
        for (i=0; i<JHSchoolItem[n].length; i+=2){
            document.search_form.junior_high_school.options[i/2] = new Option(JHSchoolItem[n][i+1],JHSchoolItem[n][i]);
        }
    }
}

function setContact(url)
{
    document.form_details.action = url + "/estate/contact.html";
    document.form_details.submit();
}

