﻿﻿var dist = new Array(18);
var newWin=null;

dist[0] = "全選"

dist[1] = "中西區"
dist[2] = "東區"
dist[3] = "南區"
dist[4] = "灣仔"

dist[5] = "九龍城"
dist[6] = "觀塘"
dist[7] = "深水埗"
dist[8] = "黃大仙"
dist[9] = "油尖旺"

dist[10] = "葵青"
dist[11] = "北區"
dist[12] = "西貢"
dist[13] = "沙田"
dist[14] = "大埔"
dist[15] = "荃灣"
dist[16] = "屯門"
dist[17] = "元朗"
dist[18] = "天水圍"


function UpdateDistrict(theForm)
{
    var area = document.getElementById('dropdown_area');
    var district = document.getElementById('dropdown_district');
        
    
	var area_id = area.options[area.selectedIndex].value;
	var district_id = document.getElementById('hfld_district').value;

// Reset Option	
	for(i=district.options.length;i>0;i--)
	{
		district.options[i]=null;
	}	

// Create New Option
	district.options[0] = new Option(dist[0],'');

	if(area_id=="0")
	{	
		for(i=1;i<=4;i++) {
		    var j = i;
			district.options[i] = new Option(dist[j],j);			
			if (district_id == j) { district.selectedIndex = i; }
		}
	} else if (area_id=="1")
	{	
		for(i=1;i<=5;i++) {
		    var j = 4+i;
			district.options[i] = new Option(dist[j],j);
			if (district_id == j) { district.selectedIndex = i; }
		}
	} else if(area_id=="2")
	{	
		for(i=1;i<=9;i++) {
		    var j = 9+i;
			district.options[i] = new Option(dist[j],j);
			if (district_id == j) { district.selectedIndex = i; }
		}
	}

	if (area_id == "" || area_id == "3") {
	    district.disabled = true;
	} else {
	    district.disabled = false;
	}

    document.getElementById('hfld_area').value = area_id;
	document.getElementById('hfld_district').value = (district.selectedIndex > 0? district_id: "");
}

function SetDistrict() {
    var district = document.getElementById('dropdown_district');
    document.getElementById('hfld_district').value = district.options[district.selectedIndex].value;
}

function SelectService(type)
{
    var s = new String(document.getElementById('servicetype'+ type).src);

    if (document.getElementById('servicetype'+ type).src.indexOf("_on.gif") > 0) {
        document.getElementById('servicetype'+ type).src = s.replace("_on.gif", ".gif");
    } else {
        document.getElementById('servicetype'+ type).src = s.replace(".gif", "_on.gif");
    }
}

function updateProgress() 
{
    if (document.getElementById('hfld_service')) {
        var arr = document.getElementById('hfld_service').value.split("");

        for (var type=1;type<=8;type++) {
            var s = new String(document.getElementById('servicetype'+ type).src);
            if (document.getElementById('servicetype'+ type).src.indexOf("_on.gif") > 0) {
                arr[type-1] = "1";
            } else {
                arr[type-1] = "0";
            }
        }
        document.getElementById('hfld_service').value = arr.join("");
    }

    if (document.getElementById('resultContent')) {
        document.getElementById('resultContent').innerHTML = "<div id='literalResultTotal' style='height:300px;'><img src='../images/blank.gif' border='0' width='1' height='20' /><br/>搜尋中...</div>";
    }
    
    return true;
}

