function get_location(location , sub_location)
{
	if (location==0 || sub_location==0)
	{
		document.write("未填写");
	}else
	{
		//document.write(LOK[location][sub_location]);
		document.write($.ajax({url:"location.asp?provinceId="+location+"&cityId="+sub_location,async:false}).responseText);
	}
}

function get_school(location , sub_location)
{
	if (location==0 || sub_location==0)
	{
		document.write("未填写");
	}else
	{
		document.write(SOK[location][sub_location]);
	}
	
}

function init_location(location , sub_location, select_id)
{
	if (select_id=="user_university")
	{
		province = document.getElementById(select_id + '_location');
		school	 = document.getElementById(select_id);
		for(i=0;i<82;i++)
		{
			if(SSK[i] != undefined)
			{
				province.options[province.length] = new Option(SSK[i],i);
			}
		}
		province.value = location;
		
		if(location > 0 && sub_location > 0)
		{
			for(i=0;i<82;i++)
			{
				school_id = location*100+i;
				if(SOK[location][school_id] != undefined)
				{
					school.options[school.length] = new Option(SOK[location][school_id],school_id);
				}
			}
			school.value = sub_location;
		}
		else
		{
			school.options[school.length] = new Option(SOK[0][0],0);
		}
	}
	else
	{
/*		province = document.getElementById(select_id + '_location');
		city	 = document.getElementById(select_id + '_sublocation');
		for(i=0;i<100;i++)
		{
			if(LSK[i] != undefined)
			{
				province.options[province.length] = new Option(LSK[i],i);
			}
		}
		province.value = location;
		
		if(location > 0 && sub_location > 0)
		{
			for(i=0;i<100;i++)
			{
				city_id = location*100+i;
				if(LOK[location][city_id] != undefined)
				{
					city.options[city.length] = new Option(LOK[location][city_id],city_id);
				}
			}
			city.value = sub_location;
		}
		else
		{
			city.options[city.length] = new Option(LOK[0][0],0);
		}
*/	}
}
function change_location(location, select_id)
{
	if (select_id=="user_university")
	{
		school = document.getElementById(select_id);
		school.length = 0;
		for(i=0;i<3000;i++)
		{
			school_id = location * 10000 + i;
			if(SOK[location][school_id] != undefined)
			{
				school.options[school.length] = new Option(SOK[location][school_id],school_id);
			}
		}
	}
	else
	{
		city = document.getElementById(select_id + '_sublocation');
		city.length = 0;
		for(i=0;i<100;i++)
		{
			city_id = location * 100 + i;
			if(LOK[location][city_id] != undefined)
			{
				city.options[city.length] = new Option(LOK[location][city_id],city_id);
			}
		}
	}
}
function get_star(star)
{
	
	if(star == 0)
		return '';
	ret = '';
	for(i=1;i<=star;i++)
	{
		ret += '<img src="images/star.gif" />';
	}
	return ret;
}

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++;
    }
}


function build_day(first,def_value)
{
    document.getElementById("day").innerHTML = "";
    switch(first)
    {
        case 0:
            break;
        case "01":
            var second = 31;
            break;
        case "02":
            var second = 29;
            break;
        case "03":
            var second = 31;
            break;
        case "04":
            var second = 30;
            break;
        case "05":
            var second = 31;
            break;
        case "06":
            var second = 30;
            break;
        case "07":
            var second = 31;
            break;
        case "08":
            var second = 31;
            break;
        case "09":
            var second = 30;
            break;
        case "10":
            var second = 31;
            break;
        case "11":
            var second = 30;
            break;
        case "12":
            var second = 31;
            break;
        default:
            var second = 31;
            break;
    }

    if(def_value != "")
    {
        var sOption = document.createElement("OPTION");
        sOption.text = def_value;
        sOption.value = def_value;
        document.getElementById("day").options.add(sOption);
    }
    else
    {
        var k=1;
        for(var count=0; count<=second; count++)
        {
            var sOption = document.createElement("OPTION");
		    if(count == 0)
		    {
                sOption.text = "--请选择--";
                sOption.value = "0";
            }
            else if(count < 10)
            {
                sOption.text = "0" + count;
                sOption.value = "0" + count;
            }
            else
            {
                sOption.text = count;
                sOption.value = count;
            }
            document.getElementById("day").options.add(sOption,k);
            k++;
        }
    }
}
