function ch_pwd()
{
	var w=250;
	var h=160;
	var ch_w=window.open('change_pwd.php','ch_w','status=yes,scrollbars=no,width='+w+',height='+h+','+set_wc(w,h));
}
function ord( string ) {
    var str = string + '';
    var code = str.charCodeAt(0);
    if (0xD800 <= code && code <= 0xDBFF) { // High surrogate (could change last hex to 0xDB7F to treat high private surrogates as single characters)
        var hi = code;
        if (str.length === 1) {
            return code; // This is just a high surrogate with no following low surrogate, so we return its value;
                                    // we could also throw an error as it is not a complete character, but someone may want to know
        }
        var low = str.charCodeAt(1);
        if (!low) {
            
        }
        return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
    }
    if (0xDC00 <= code && code <= 0xDFFF) { // Low surrogate
        return code; // This is just a low surrogate with no preceding high surrogate, so we return its value;
                                // we could also throw an error as it is not a complete character, but someone may want to know
    }
    return code;
}
function ch_tbcolor(x,y)
{
	x.style.backgroundColor=y;
}
function go_y()
{

	//var y=document.body.scrollTop;
	//document.getElementsByName("form1")[0].bar_y.value=y;
	var y=document.getElementsByName("form1")[0].bar_y.value;
	window.scroll(0,y);
}
function go_url(x)
{
	location.href=x;
}
function logout()
{
	parent.location.href='logout.php';
}
function set_wc(x,y)
{
	s_w=(screen.width-x)/2;
	s_h=(screen.height-y)/2-10;
	return 'left='+s_w+',top='+s_h;
}
function show_big(x)
{
	var pic_w=window.open('show_pic.php?pic_name='+x,'pic_w','scrollbars=yes,top=0,left=0,resizable=0,width=100,height=100');
        pic_w.focus();
}
function count_w(x,y)
{
	var count_num="目前字數："+x.value.length+"/";
	document.getElementById(y).innerText=count_num;
}
function ch_page(x)
{
	if(x)
	{
		var p1=document.getElementsByName("form1")[0].page;
		var p2=document.getElementsByName("form1")[0].page1
		var p3=document.getElementsByName("form1")[0].page2
		if(p1)p1.value=x;
		if(p2)p2.value=x;
		if(p3)p3.value=x;
	}
	document.getElementsByName("form1")[0].target='_self';
	document.getElementsByName("form1")[0].action='';
	document.getElementsByName("form1")[0].submit();
}
function download(x,y)
{
	iframe1.location.href='download.php?save_file='+x+'&f_name='+y;
}
function show_pic(x,y)
{
	var pic=document.getElementById(y);
	if(pic && x.value)
		document.getElementById("small_"+y).innerHTML="<img src='"+x.value+"'  border=0>";
}
function get_date(x,y)
{
	var w=250;
	var h=220;
	if(!y)y='';
	if(x)
	var date_w=window.open('calendar.php?col_name='+x+'&old_date='+y,'date_w','status=yes,scrollbars=yes,width='+w+',height='+h+','+set_wc(w,h));
	date_w.focus();
}
function chk_id(x)
{
	x=x.toUpperCase();
	if (x.length != 10) 
	{
		alert('身份證字號為無效的身份證字號，請重新檢查一次');
    		return false;
    	}
	var get_id = new Array(10)
  	for (i=0; i<10; i++) 
	{ 
		get_id[i] = x.charAt(i) 
	}
  	var first_w = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  	get_id[0]   = first_w.indexOf(get_id[0])
  	if (get_id[0] == -1) 
	{
      		alert('身份證字號開頭必須為大寫英文字母，請重新檢查一次');
	      	return false;
  	}
	if (get_id[1] !=1 && get_id[1] !=2) 
	{
      		alert('身份證字號無效，請重新檢查一次');
      		return false;
  	}
  	var id_n  = new Array(26)
	id_n=[1,10,19,28,37,46,55,64,39,73,82,2,11,20,48,29,38,47,56,65,74,83,21,3,12,30];
  	var chk_num = id_n[get_id[0]]
  	for (i=1; i<10; i++) 
	{
		var num_w = '0123456789'
      		get_id[i] = num_w.indexOf(get_id[i])
	    	if (get_id[i] == -1) 
		{
			alert('身份證字號無效，請重新檢查一次');
			return false;
	    	} 
		else 
		{
			chk_num += get_id[i] * (9-i)
	    	}
  	}
  	chk_num += 1 * get_id[9]
	if (chk_num % 10 != 0) 
	{
		alert('身份證字號無效，請重新檢查一次');
		return false;
  	}
	return true;
}
function ch_city(x,y,z)
{
	document.getElementsByName("form1")[0].target='iframe1';
	document.getElementsByName("form1")[0].action='area.php';
	document.getElementsByName("form1")[0].postid.value='';
	document.getElementsByName("form1")[0].act.value=y;
	document.getElementsByName("form1")[0].col_name.value=z;
	document.getElementsByName("form1")[0].submit();
}