function check_form_error(err_msg){
	err_msg =	"發生以下錯誤：\n" + 
				"=========================\n" +
				err_msg;
	alert(err_msg);
	$("#is_submitted").val(""); // re-enable the submit function
	return false;
}




function daysInMonth(year, month)
{
	 // month is zero based, so take away 1
	 month = --month;
	 // first day of the following month
	 var nextDay;
	 // if last month of year, then use first day of following year
	 if(month == 11)
	 {
	  nextDay = new Date(++year, 0);
	 }
	 // otherwise use next day of current year
	 else
	 {
	  nextDay = new Date(year, ++month);
	 }
	 // take away a millisecond to get required date
	 var requiredDate = new Date(nextDay - 1);
	 // return the day
	 return requiredDate.getDate();
}












// Checks if a given date string is in    
// one of the valid formats:   
// a) M/D/YYYY format   
// b) M-D-YYYY format   
// c) M.D.YYYY format   
// d) M_D_YYYY format
// test function to test the isDate function   
/*
function test_isDate()   
{   
    var arrDates = [    
        '2008/05/15', '2008-05-15',    
        '2008.05.15', '2008_05_15',   
        '2008/15/15', '2008/05/35',   
		'2008/2/29', '2007/2/29',   
        '1908/05/15', '2008-15-15',   
        '2008/a/1b', 'a008/05/30' ];   
           
    for (var d in arrDates)    
        document.writeln("isDate('" + arrDates[d] + "') : " + isDate(arrDates[d]) + "<BR>");   
} 
*/
function is_date(s)   
{      
    // make sure it is in the expected format   
    if (s.search(/^\d{4}[\/|\-|\.|_]\d{1,2}[\/|\-|\.|_]\d{1,2}/g) != 0)   
        return false;   
  
    // remove other separators that are not valid with the Date class              
    s = s.replace(/[\-|\.|_]/g, "/");   
               
    // convert it into a date instance   
    var dt = new Date(Date.parse(s));          
  
    // check the components of the date   
    // since Date instance automatically rolls over each component   
    var arrDateParts = s.split("/");   
    return (   
		dt.getFullYear() == arrDateParts[0] &&   
        dt.getMonth() == arrDateParts[1]-1 &&   
        dt.getDate() == arrDateParts[2]        
    );             
}   


function is_time(s){
	var re = "^((([0]?[1-9]|1[0-2])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?( )?(AM|am|aM|Am|PM|pm|pM|Pm))|(([0]?[0-9]|1[0-9]|2[0-3])(:|\.)([0-9]|[0-5][0-9])((:|\.)([0-9]|[0-5][0-9]))?))$";
	if(s.match(re)){
		return true;
	}else{
		return false;
	}

}



function is_email(s){
	var re = "^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$";
	if(s.match(re)){
		return true;
	}else{
		return false;
	}

}


	function openWindow(){

		window.open('mail.php','mywindow','width=330,height=200')
	}

