﻿function mm_openbrwindow ( theurl, winname, features )
{
    window.open( theurl, winname, features );
}
/*
function check_uid ( uid )
{
	if( uid.length <= 0 )
		return( "請填入貴公司的統一編號 !\n\n" );
	var testInt = /^\d{8}$/;
	
	if(!testInt.test(uid)){
	    return("統一編號請輸入八位數的數字！\n\n");
	}
	
	return "";
/*
if ( !(uid.charAt(0)>= 'a' && uid.charAt(0) <= 'z') ) {
return( "您的帳號第一字元只能為小寫字母 !\n" );
}
for( idx = 0 ; idx <uid.length ; idx++ )
{
if( uid.charAt(idx)>= 'A' && uid.charAt(idx) <= 'Z' )
return( "帳號不可以含有大寫字元 !\n" );
if( !( ( uid.charAt(idx)>= 'a' && uid.charAt(idx) <= 'z' ) || ( uid.charAt(idx)>= '0' && uid.charAt(idx) <= '9' ) || ( uid.charAt(idx) == '_' ) ) )
return( "您的帳號只能是數字,英文字母及「_」等符號,其他的符號都不能使用 !\n" );
if( uid.charAt(idx) == '_' && uid.charAt(idx-1) == '_' )
return( "「_」符號不可相連 !\n" );
}
if( uid.indexOf( "kimo" )>= 0 || uid.indexOf( "yahoo" )>= 0 )
return( "您的帳號不能含有 'kimo' 與 'yahoo' 的字眼 !\n" );
if( uid.charAt( uid.length - 1 ) == '_' )
return( "「_」符號不可在最後 !\n" );
return "";

}
*/
/*
function check_oldID ( uid )
{
if( uid.length <= 0 )
return( "您的帳號還沒填呢 !\n" );
if( uid.length> 32 )
return( "您的帳號長度只能小於 32 個字元 !\n" );
for( idx = 0 ; idx <uid.length ; idx++ )
{
if( uid.charAt(idx)>= 'A' && uid.charAt(idx) <= 'Z' )
return( "帳號不可以含有大寫字元 !\n" );
if( !( ( uid.charAt(idx)>= 'a' && uid.charAt(idx) <= 'z' ) || ( uid.charAt(idx)>= '0' && uid.charAt(idx) <= '9' ) || ( uid.charAt(idx) == '_' ) || ( uid.charAt(idx) == '-' ) || ( uid.charAt(idx) == '.' ) ) )
return( "您的帳號只能是數字,英文字母及「_」「-」「.」等符號,其他的符號都不能使用 !\n" );
}
return "";
}
*/
function check_blogurl(str) {
    if (str == '') {
        return "請輸入您的部落格網址！\n\n";
    } else {
    return "";
    }
}

function check_favorite(str) {
    if (str == '') {
        return "請輸入您最喜歡的一樣3C產品！\n\n";
    } else {
        return "";
    }
}

function check_hypocorism(hypocorism){
    if(hypocorism == '') {
        return "暱稱不可以空白！\n\n";
    }
    return "";
}


function check_passwd( pw1, pw2 )
{
    if( pw1 == '' ) {
        return ("密碼不可以空白 !\n\n");
    }
    for( var idx = 0 ; idx <pw1.length ; idx++ )
        if( pw1.charAt(idx) == ' ' || pw1.charAt(idx) == '\"' )
            return ("密碼不可以含有空白、雙引號及其他符號 !\n\n");
    if( pw1.length <6 || pw1.length> 12 )
        return( "密碼長度只能 6 到 12 個字 !\n\n" );
    if( pw1 != pw2 )
        return("密碼二次輸入不一樣,請重新輸入 !\n\n");

    return "";
}

function check_passwd1(pw1){
    if(pw1 == ''){
        return "密碼不可以空白！\n\n";
    }
    for(i=0; i<pw1.length; i++){
        if(pw1.charAt(i)==' ' || pw1.charAt(i) == '\"'){
            return "密碼不可以含有空白、雙引號及其他符號！\n\n";
        }
    }
    return "";
}

function check_cn(cn){
	if(cn == '') {
		return("服務單位或學校名稱不可以空白！\n\n");
	}
	return "";
}

/*
function check_ht ( ht )
{
if( ht == '' )
return( "密碼提示不可以空白 !\n" );
return "";
}
*/



function check_cnaddr(cnaddr){
	if(cnaddr=='') {
		return("地址不可以空白！\n\n");
	}
	return "";
}

function check_inaddr(inaddr){
	if(inaddr=='') {
		return("發票地址不可以空白！\n\n");
	}
	return "";
}

function check_yn(yn) {
    if(yn == '') {
        return("姓名不可以空白！\n\n");
    }
    return "";
}

function check_contactName(str){
    if(str == ''){
        return "請輸入聯絡人姓名！\n\n";
    }
    return "";
}

function check_contactEmail(email){
    var len = email.length;
    if(len==0)
        return("請輸入聯絡人email address！\n\n");
    for(var i=0;i<len;i++)
    { 
        var c= email.charAt(i);
        if(!((c>="A"&&c<="Z")||(c>="a"&&c<="z")||(c>="0"&&c<="9")||(c=="-")||(c=="_")||(c==".")||(c=="@")))
            return("您的聯絡人email address只能是數字,英文字母及'-','_'等符號,其他的符號都不能使用 !\n\n");
    }

    if((email.indexOf("@")==-1)||(email.indexOf("@")==0)||(email.indexOf("@")==(len-1)))
        return("您的聯絡人email address不合法 !\n\n");
    if((email.indexOf("@")!=-1)&&(email.substring(email.indexOf("@")+1,len).indexOf("@")!=-1))
        return("您的聯絡人email address不合法 !\n\n");
    if((email.indexOf(".")==-1)||(email.indexOf(".")==0)||(email.lastIndexOf(".")==(len-1)))
        return("您的聯絡人email address不完全 !\n\n");
    return "";
}

function check_jb(jb){
    if(jb == ''){
        return("職稱不可以空白！\n\n");
    }
    return "";
}

function check_telareaCode(no){
    if(no == ''){
        return "請輸入您的電話區碼！\n\n";
    }
    
    if(no.length > 4){
        return "台灣電話區號最多4位數！\n\n";
    }
    
    var error = false;
    
    for(i=0; i<no.length; i++) {
                if(!(no.charAt(i)>='0' && no.charAt(i)<='9')){
            error = true;
        }
    }
    
    if(error == true){
        return "電話區號請輸入數字，也請不要填入括號！\n\n";
    }
    
    return "";
}

function check_postno(no){
    if(no == ''){
        return("請輸入郵遞區號！\n\n");
    }
    
    var error = false;
    
    if(no.length > 3){
        return("台灣郵遞區號僅3位數！\n\n");
    }
    
    for(i=0; i<no.length; i++) {
                if(!(no.charAt(i)>='0' && no.charAt(i)<='9')){
            error = true;
        }
    }
    
    if(error == true){
        return("郵遞區號請輸入數字，也請不要填入括號！\n\n");
    }
    
    return "";
}

function check_schooling(str){
    if(str == ''){
        return "請輸入您目前就讀學校！\n\n";
    }
    return "";
}

function check_departmentalism(str){
    if(str == ''){
        return "請輸入您所讀的科系！\n\n";
    }
    return "";
}

function check_tall(str) {
    if (str == '') {
        return "請輸入您的身高！\n\n";
    } else {
        var error = false;

        for (idx = 0; idx < str.length; idx++) {
            if (!(str.charAt(idx) >= '0' && str.charAt(idx) <= '9')) {
                error = true;
            }
        }

        if (error == true) {
            return ("身高請輸入數字！\n\n");
        }
        return "";
    }
}

function check_telext(telext){  
    var error = false;
    
    for(idx=0; idx<telext.length; idx++) {
        if(!(telext.charAt(idx)>='0' && telext.charAt(idx)<='9')){
            error = true;
        }
    }
    
    if(error == true){
        return("電話分機請輸入數字，也請不要填入括號！\n\n");
    }
    return "";
}

function check_telephonenumber ( number )
{
	var error = false;
	if( number.length <= 0 )
		return "您的聯絡電話還沒填！\n\n";
	
	for( idx = 0 ; idx <number.length ; idx++ ) {
		if( !( ( number.charAt(idx)>= '0' && number.charAt(idx) <= '9' ) ) ) {
			error = true;
			break;
		}
	}
	
	if( error == true )
		return "您的通訊電話只能是數字, 也不要填入符號 !\n\n";
	return "";
}

function check_fax(fax){
    if(fax.length<=0){
        return "請填入貴公司的傳真號碼！\n\n";
    }
    

    var error = false;
    
	for( idx = 0 ; idx <fax.length ; idx++ ) {
		if( !( ( fax.charAt(idx)>= '0' && fax.charAt(idx) <= '9' ) ) ) {
			error = true;
			break;
		}
	}
	
	if(error == true) {
	    return("您的傳真號碼只能用數字，也不要填入符號！\n\n");
	}
	return "";
}

function check_poster(str){
    if(str==''){
        return "請輸入您在哪看到此宣傳海報！\n\n";
    }
    return "";
}

function check_coolcar(str){
    if(str==''){
        return "請輸入您在哪看到此酷卡！\n\n";
    }
    return "";
}

function check_website(str){
    if(str==''){
        return "請輸入您在哪個網站得知海報徵選的訊息！\n\n";
    }
    return "";
}

function check_else(str){
    if(str==''){
        return "請輸入您是經由什麼管道得知海報徵選的訊息！\n\n";
    }
    return "";
}

function check_email ( email, emop )
{
	var alt = check_radio( emop, "聯絡信箱" );
	if( alt.length> 0 )
		return alt;
	var len = email.length;
	if( emop[1].checked == true && len == 0 )
		return "您的聯絡信箱選擇備用電子信箱, 所以備用電子信箱不可以空白 !\n";
	var ck =0;
	if(len==0)
		return "";
	for(var i=0;i<len;i++)
	{
		var c= email.charAt(i);
		if(!((c>="A"&&c<="Z")||(c>="a"&&c<="z")||(c>="0"&&c<="9")||(c=="-")||(c=="_")||(c==".")||(c=="@")))
			return "您的電子郵件地址只能是數字,英文字母及'-','_'等符號,其他的符號都不能使用 !\n";
	}
	if((email.indexOf("@")==-1)||(email.indexOf("@")==0)||(email.indexOf("@")==(len-1)))
		return "您的電子郵件地址不合法 !\n";
	if((email.indexOf("@")!=-1)&&(email.substring(email.indexOf("@")+1,len).indexOf("@")!=-1))
		return "您的電子郵件地址不合法 !\n";
	if((email.indexOf(".")==-1)||(email.indexOf(".")==0)||(email.lastIndexOf(".")==(len-1)))
		return "您的電子郵件地址不完全 !\n";
	var idx = email.indexOf("@");
	var name = email.substring( 0, idx );
	var domain = email.substring( idx+1, email.length).toLowerCase();
	email = name + "@" + domain;
	/*
	if((email.indexOf("@kimo.com")>=0) || (email.indexOf("@yahoo.com")>=0))
		return "您的備用電子信箱不能是Yahoo!奇摩電子信箱 !\n";
	if( email == "tw-abuse@yahoo-inc.com" )
		return "您的電子郵件地址不合法 !\n";
	*/
	return "";
}

function check_amail ( email, emop )
{
var len = email.length;
if( emop.type == "checkbox" ) {
if( !emop.checked && len == 0 )
return "您的聯絡信箱選擇備用電子信箱, 所以備用電子信箱不可以空白 !\n";
}
if(len==0)
return "";
for(var i=0;i<len;i++)
{ var c= email.charAt(i);
if(!((c>="A"&&c<="Z")||(c>="a"&&c<="z")||(c>="0"&&c<="9")||(c=="-")||(c=="_")||(c==".")||(c=="@")))
return "您的電子郵件地址只能是數字,英文字母及'-','_'等符號,其他的符號都不能使用 !\n";
}
if((email.indexOf("@kimo.com")>=0) || (email.indexOf("@yahoo.com")>=0))
return "您的備用電子信箱不能是Yahoo!奇摩電子信箱 !\n";
if( email == "tw-abuse@yahoo-inc.com" )
return "您的電子郵件地址不合法 !\n";
if((email.indexOf("@")==-1)||(email.indexOf("@")==0)||(email.indexOf("@")==(len-1)))
return "您的電子郵件地址不合法 !\n";
if((email.indexOf("@")!=-1)&&(email.substring(email.indexOf("@")+1,len).indexOf("@")!=-1))
return "您的電子郵件地址不合法 !\n";
if((email.indexOf(".")==-1)||(email.indexOf(".")==0)||(email.lastIndexOf(".")==(len-1)))
return "您的電子郵件地址不完全 !\n";
return "";
}


function check_email1 ( email )
{
    var len = email.length;
    if(len==0)
        return("請輸入您的email address！\n\n");
    for(var i=0;i<len;i++)
    { 
        var c= email.charAt(i);
        if(!((c>="A"&&c<="Z")||(c>="a"&&c<="z")||(c>="0"&&c<="9")||(c=="-")||(c=="_")||(c==".")||(c=="@")))
            return("您的email address只能是數字,英文字母及'-','_'等符號,其他的符號都不能使用 !\n\n");
    }
/*
if((email.indexOf("@kimo.com.tw")>=0) || (email.indexOf("@kimo.com")>=0))
return "您的備用電子信箱不能是奇摩電子信箱 !\n";
if( email == "tw-abuse@yahoo-inc.com" )
return "您的電子郵件地址不合法 !\n";
*/
    if((email.indexOf("@")==-1)||(email.indexOf("@")==0)||(email.indexOf("@")==(len-1)))
        return("您的email address不合法 !\n\n");
    if((email.indexOf("@")!=-1)&&(email.substring(email.indexOf("@")+1,len).indexOf("@")!=-1))
        return("您的email address不合法 !\n\n");
    if((email.indexOf(".")==-1)||(email.indexOf(".")==0)||(email.lastIndexOf(".")==(len-1)))
        return("您的email address不完全 !\n\n");
    return "";
}

function check_mobilePhone(phone){
    if(phone.length==0){
        return("請輸入您的手機號碼！\n\n");
    }else{
    
        var numPattern = /^\d{10}$/;
        
        if(!numPattern.test(phone)){
            return("手機請填入10位數字，不加任何符號！\n\n");
        }
    }
    return "";
}

function check_ContactMobilePhone(phone){
    if(phone.length==0){
        return("請輸入聯絡人手機號碼！\n\n");
    }else{
    
        var numPattern = /^\d{10}$/;
        
        if(!numPattern.test(phone)){
            return("聯絡人手機請填入10位數字，不加任何符號！\n\n");
        }
    }
    return "";    
}

function check_LastNum1(num1){
    if(num1.length!=4){
        return("請務必填入您的營利證末4 碼！\n\n");
    }
    
    //var error = false;
    
    var datePattern = /^d{4}$/;
    
    if(num1.match(datePattern)){
        return("營利證請輸入數字！\n\n");
    }
    
    /*
    for(i=0; i<num.length; i++) {
        if(!(phone.charAt(i)>='0'&&phone.charAt(i)<='9')){
            error = true;
        }
    }
    
    if(error == true){
        return("營利證請輸入數字！\n\n");
    }
    */
    return "";
}

function check_identity1(id){
    if(id.length == 0){
        return '您的身分證字號(護照號碼)還沒填呢！\n\n';
    }
    
        var myid = id;
        myid = myid.toUpperCase();
        id = myid;
        if(myid.length>10)
            return "您的身分證字號超過10個字 !\n\n";
        if(myid.length<10)
            return "您的身分證字號不滿10個字 !\n\n";
        var c = myid.charAt(0);
        if(c<"A" || c> "Z")
            return "您的身分證字號第一碼必須是大寫的英文字母 !\n\n";
        c = myid.charAt(1);
        if(c!="1" && c!="2")
            return "您的身分證字號第二碼有問題 !\n\n";
        for(i=1;i<10;i++)
            if(isNaN(parseFloat(myid.charAt(i))))
                return "您的身分證字號第二到十碼有問題 !\n\n";
        var alph = new Array("A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","X","Y","W","Z","I","O");
        var num = new Array("10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35");
        var n=0;
        for(i=0;i<alph.length;i++)
            if(myid.charAt(0)==alph[i])
                n=i;
        var tot1 = parseFloat(num[n].charAt(0)) + (parseFloat(num[n].charAt(1)) * 9);
        var tot2 = 0;
        for(i=1;i<myid.length-1;i++)
            tot2 = tot2 + parseFloat(myid.charAt(i))*(9-i);
        var tot3 = parseFloat(myid.charAt(9));
        var tot4 = tot1 + tot2 + tot3;
        if((tot4 % 10)!=0)
            return "您的身分證字號有問題 !\n\n";

    return "";
}

function check_identity ( id, radio )
{
    if(id.length == 0){
        return '您的身分證字號(護照號碼)還沒填呢！\n\n';
    }
    
    if(radio == 1){
        var myid = id;
        myid = myid.toUpperCase();
        id = myid;
        if(myid.length>10)
            return "您的身分證字號超過10個字 !\n\n";
        if(myid.length<10)
            return "您的身分證字號不滿10個字 !\n\n";
        var c = myid.charAt(0);
        if(c<"A" || c> "Z")
            return "您的身分證字號第一碼必須是大寫的英文字母 !\n\n";
        c = myid.charAt(1);
        if(c!="1" && c!="2")
            return "您的身分證字號第二碼有問題 !\n\n";
        for(i=1;i<10;i++)
            if(isNaN(parseFloat(myid.charAt(i))))
                return "您的身分證字號第二到十碼有問題 !\n\n";
        var alph = new Array("A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","X","Y","W","Z","I","O");
        var num = new Array("10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35");
        var n=0;
        for(i=0;i<alph.length;i++)
            if(myid.charAt(0)==alph[i])
                n=i;
        var tot1 = parseFloat(num[n].charAt(0)) + (parseFloat(num[n].charAt(1)) * 9);
        var tot2 = 0;
        for(i=1;i<myid.length-1;i++)
            tot2 = tot2 + parseFloat(myid.charAt(i))*(9-i);
        var tot3 = parseFloat(myid.charAt(9));
        var tot4 = tot1 + tot2 + tot3;
        if((tot4 % 10)!=0)
            return "您的身分證字號有問題 !\n\n";
    }
    /*
    if( ! (radio[0].checked || radio[1].checked) )
        return '您的身分證字號（護照號碼）還沒填呢 !\n';
    if( radio[0].checked == true ) {
        var myid = id;
        myid = myid.toUpperCase();
        id = myid;
        if(myid.length>10)
            return "您的身分證字號超過10個字 !\n";
        if(myid.length<10)
            return "您的身分證字號不滿10個字 !\n";
        var c = myid.charAt(0);
        if(c<"A" || c> "Z")
            return "您的身分證字號第一碼必須是大寫的英文字母 !\n";
        c = myid.charAt(1);
        if(c!="1" && c!="2")
            return "您的身分證字號第二碼有問題 !\n";
        for(i=1;i<10;i++)
            if(isNaN(parseFloat(myid.charAt(i))))
                return "您的身分證字號第二到十碼有問題 !\n";
        var alph = new Array("A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","X","Y","W","Z","I","O");
        var num = new Array("10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35");
        var n=0;
        for(i=0;i<alph.length;i++)
            if(myid.charAt(0)==alph[i])
                n=i;
        var tot1 = parseFloat(num[n].charAt(0)) + (parseFloat(num[n].charAt(1)) * 9);
        var tot2 = 0;
        for(i=1;i<myid.length-1;i++)
            tot2 = tot2 + parseFloat(myid.charAt(i))*(9-i);
        var tot3 = parseFloat(myid.charAt(9));
        var tot4 = tot1 + tot2 + tot3;
        if((tot4 % 10)!=0)
            return "您的身分證字號有問題 !\n";
    } else {
        if ( id.length <= 0 ) return '您的身分證字號（護照號碼）還沒填呢 !\n';
    }
    */
    return "";
}


/*
function check_null ( column, name )
{
if( column.length == 0 )
return name + "不可以空白 !\n";
return "";
}
*/

/*
function check_select ( select, name )
{
if( select.options[0].selected == true )
return name + "必須選擇 !\n";
return "";
}
*/

/*
function check_radio ( radio, name )
{
var error = true;
for( i=0; i <radio.length; i++ )
if( radio[i].checked == true ) {
error = false;
break;
}
if( error == true )
return name + "必須選擇 !\n";
return "";
}
*/

/*
function check_birthday_year( year )
{
var error = false;
if( year.length != 4 )
return ("您的生日年份必須是四個數字, 例如 1980 年 !\n");
for( idx = 0 ; idx <year.length ; idx++ ) {
if( !( year.charAt(idx)>= '0' && year.charAt(idx) <= '9' ) ) {
error = true;
break;
}
}
if( error == true )
return ("您的生日年份必須是四個數字, 例如 1980 年 !\n");
return "";
}
*/

/*
function check_mobilephone ( number, radio )
{
	var alt = check_radio( radio, "行動電話" );
	if( alt.length> 0 )
		return alt;
	var error = false;
	if( radio[1].checked == true ) {
		if( number.length <= 0 )
			return "您的行動電話還沒填呢 !\n";
		if( number.length >= 24 )
			return "您的行動電話有問題 !\n";
		for( idx = 0 ; idx <number.length ; idx++ ) {
			if( !( number.charAt(idx)>= '0' && number.charAt(idx) <= '9' ) && number.charAt(idx)!='-' && number.charAt(idx)!='+' ) {
				error = true;
			break;
			}
		}
	}
	if( error == true )
		return "您的行動電話只能是數字, 其他的符號都不能使用 !\n";
	else
		return "";
}

/*
function delete_pid ( pid, done )
{
	if( confirm( "您是否要刪除此網路身份?" ) )
		location.href = 'ct?t=p&pid=' + pid + '&f=d&done=' + done;
}
*/

function y2k(number) {
	return (number<1000) ? number+1900 : number;
}
 
function checkDateExist(day, month, year) {
	var today=new Date();
	year=((!year) ? y2k(today.getYear()):year);
	month=((!month) ? today.getMonth():month-1);
 
	if(!day){return false;}
		var test=new Date(year,month,day);
	if((y2k(test.getYear()) == year) && (month == test.getMonth()) && (day == test.getDate())) {
		return true;
	}
	else {
		return false;
	}
}
 
function check_birthday(dates) {
    if (dates.length != '') {
        var datePattern = /^\d{4}\/(0[1-9]|1[0-2])\/(3[0-1]|[0-2][0-9])$/;

        if (dates.match(datePattern)) {
            if (checkDateExist(dates.substring(8, 10), dates.substring(5, 7), dates.substring(0, 4)) == true) {
                return ("");
            } else {
                return ("輸入的生日日期不存在\n\n");
            }
        }
        else {
            return ("生日日期格式錯誤!\n請依照下列格式輸入日期：\n[ yyyy/MM/dd ]\n\n");
        }
    } else {
        return ("請輸入生日！\n\n");
    }
	return "";
}
