//select
function DBC2SBC (str) {
        var i;
        var result='';
        for(i=0; i < str.length; i++)
        {
                code = str.charCodeAt(i);

                if (code == 12290)
                {
                        result += String.fromCharCode(46);
                }
                else if (code == 183)
                {
                        result += String.fromCharCode(64);
                }
                else if(code >= 65281 && code<65373)
                {
                        result += String.fromCharCode(str.charCodeAt(i)-65248);
                }
                else
                {
                        result += str.charAt(i);
                }
        }
        return result;
}

function build_select(first_id,second_id,first_array,second_array,def_value)
{
    if(def_value == "" || def_value == "0")
    {
        var k=1000;
        for( key in first_array )       {
            var sOption = document.createElement("OPTION");
            sOption.text = first_array[key];
            sOption.value = key;
            document.getElementById(first_id).options.add(sOption,k);
            k--;
        }
    }
    else
    {
        pro_key = def_value.substr(0,2);
        var k=1000;
        for( key in first_array )
        {
            var sOption = document.createElement("OPTION");
            sOption.text = first_array[key];
            sOption.value = key;
            if(pro_key == key)
            {
                sOption.id = "sele_pro"+first_id;
            }
            document.getElementById(first_id).options.add(sOption,k);
            k--;
        }
        document.getElementById("sele_pro"+first_id).selected = true;
        var k=1000;
        for( key in second_array[pro_key] )     {
            var sOption = document.createElement("OPTION");
            sOption.text = second_array[pro_key][key];
            sOption.value = key;
            if(def_value == key)
            {
                sOption.id = "sele_city"+second_id;
            }
            document.getElementById(second_id).options.add(sOption,k);
        }
        k--;
        document.getElementById("sele_city"+second_id).selected = true;
    }
}


function build_second(first_value,second_id,second_array)
{
    document.getElementById(second_id).innerHTML = "";
    var k=1000;
    for( key in second_array[first_value]){
        var sOption = document.createElement("OPTION");
        sOption.text = second_array[first_value][key];
        sOption.value = key;
        document.getElementById(second_id).options.add(sOption,k);
    }
    k--;
}


function readSelectData(id,select_array,N)
{
	var k=1;
    for( key in select_array)
    {
		if (key == 0 && N == 1)
		{
			continue;
		}
        var sOption   = document.createElement("OPTION");
        sOption.text  = select_array[key];
        sOption.value = key;
        document.getElementById(id).options.add(sOption,k);
		k++;
    }
}

