function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	alert("Email address seems incorrect (check @ and .'s)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]
if (user.match(userPat)==null) {
    alert("The username doesn't seem to be valid.")
    return false
}
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name doesn't seem to be valid.")
    return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   alert("The address must end in a three-letter domain, or two letter country.")
   return false
}
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}
return true;
}
function Validate1(form) {
     if (document.frm01.upassword.value != "" ) {
     	if (document.frm01.upassword.value !== document.frm01.upassword2.value) { 
		alert('請輸入相同密碼');
	   document.frm01.upassword.focus();
		return false;
	   }
	 }
	   	
	
}
function Validate2(form) {
     if (document.frm02.yrange.value == "" ) {     
		alert('請輸入年份');
	   document.frm02.yrange.focus();
		return false;
	   }
	 if (document.frm02.studentname.value == "" ) {     
		alert('請輸入學生姓名');
	   document.frm02.studentname.focus();
		return false;
	   }
	   if (document.frm02.awardname.value == "" ) {     
		alert('請輸入成就');
	   document.frm02.awardname.focus();
		return false;
	   }   	
	
}
function Validate3(form) {
     if (document.frm03.sdate.value == "" ) {     
		alert('請輸入發報日期');
	   document.frm03.sdate.focus();
		return false;
	   }
	 if (document.frm03.title.value == "" ) {     
		alert('請輸入項目');
	   document.frm03.title.focus();
		return false;
	   }
	   if (document.frm03.content.value == "" ) {     
		alert('請輸入新聞內容');
	   document.frm03.content.focus();
		return false;
	   }   	
	
}
function Validate4(form) {
     if (document.frm04.yrange.value == "" ) {     
		alert('請輸入發報日期');
	   document.frm04.yrange.focus();
		return false;
	   }
	 if (document.frm04.studentname.value == "" ) {     
		alert('請輸入學生姓名');
	   document.frm04.studentname.focus();
		return false;
	   }
	   if (document.frm04.awardname.value == "" ) {     
		alert('請輸入成就');
	   document.frm04.awardname.focus();
		return false;
	   }   	
	
}
function Validate5(form) {
     if (document.frm05.sdate.value == "" ) {     
		alert('請輸入發報日期');
	   document.frm05.sdate.focus();
		return false;
	   }
	 if (document.frm05.title.value == "" ) {     
		alert('請輸入項目');
	   document.frm05.title.focus();
		return false;
	   }
	  
	
}
function Validate6(form) {
	 if (document.frm06.catid.selectedIndex == 0 ) {     
		alert('請輸入課程分類');	   
		return false;
	   }  		
     if (document.frm06.coursename.value == "" ) {     
		alert('請輸入課程名稱');
	   document.frm06.coursename.focus();
		return false;
	   }
	  if (document.frm06.coursecode.value == "" ) {     
		alert('請輸入課程編號');
	   document.frm06.coursecode.focus();
		return false;
	   }  
	   if (document.frm06.feature.value == "" ) {     
		alert('請輸入課程特色');
	   document.frm06.feature.focus();
		return false;
	   } 
	     if (document.frm06.oday.value == "" ) {     
		alert('請輸入開課日期');
	   document.frm06.oday.focus();
		return false;
	   } 
	    if (document.frm06.period.value == "" ) {     
		alert('請輸入修讀為期');
	   document.frm06.period.focus();
		return false;
	   } 
	    if (document.frm06.require.value == "" ) {     
		alert('請輸入入學要求');
	   document.frm06.require.focus();
		return false;
	   } 
	   if (document.frm06.content.value == "" ) {     
		alert('請輸入課程內容');
	   document.frm06.content.focus();
		return false;
	   } 
	    if (document.frm06.enquiry.value == "" ) {     
		alert('請輸入查詢');
	   document.frm06.enquiry.focus();
		return false;
	   } 	  
	
}
function Validate7(form) {
     if (document.frm07.locat.value == "" ) {     
		alert('請輸入學校地區');
	   document.frm07.locat.focus();
		return false;
	   }
	 if (document.frm07.district.value == "" ) {     
		alert('請輸入學校地區代碼');
	   document.frm07.district.focus();
		return false;
	   }
	  
	
}
function Validate8(form) {
     if (document.frm08.tcname.value == "" ) {     
		alert('請輸入班別名稱');
	   document.frm08.tcname.focus();
		return false;
	   }	 
	  
	
}
function Validate9(form) {
     if (document.frm09.tcsubject.value == "" ) {     
		alert('請輸入科目名稱');
	   document.frm09.tcsubject.focus();
		return false;
	   }	 
	  
	
}
function Validate11(form) {
     if (document.frm11.tcname.value == "" ) {     
		alert('請輸入班別名稱');
	   document.frm11.tcname.focus();
		return false;
	   }	 
	  
	
}
function Validate12(form) {
     if (document.frm12.studentNo.value == "" ) {     
		alert('請輸入學生編號');
	   document.frm12.studentNo.focus();
		return false;
	   }	 
	  if (document.frm12.FirstName.value == "" ) {     
		alert('請輸入學生名字');
	   document.frm12.FirstName.focus();
		return false;
	   }
	   if (document.frm12.LastName.value == "" ) {     
		alert('請輸入學生姓氏');
	   document.frm12.LastName.focus();
		return false;
	   }
	   if (document.frm12.email.value == "" ) {     
		alert('請輸入學生電郵');
	   document.frm12.email.focus();
		return false;
	   }
	   	if(!document.frm12.email.value.match(/[a-zA-Z\.\@\d\_]/)) {
           alert('電郵地址不乎');
  				document.frm12.email.focus();
         return false;
           }
		   if (!emailCheck (document.frm12.email.value) )
			{
				document.frm12.email.focus();
				return (false);
			} 	
	   if (document.frm12.spassword.value == "" ) {     
		alert('請輸入學生密碼');
	   document.frm12.spassword.focus();
		return false;
	   }
	   if (document.frm12.spassword.value != "" ) {
	      if (document.frm12.spassword2.value != document.frm12.spassword.value) {     
		alert('請輸入相同密碼');
	   document.frm12.spassword2.focus();
		return false;
		  }
	   }
	   if (document.frm12.locationid.selectedIndex == 0 ) {     
		alert('請選擇學校');	   
		return false;
	   }	 
	  if (document.frm12.classid.selectedIndex == 0 ) {     
		alert('請選擇班別');	   
		return false;
	   } 			
	
}
function Validate13(form) {
     if (document.frm13.locationid.selectedIndex == 0 ) {     
		alert('請選擇學校');	   
		return false;
	   }	 
	  if (document.frm13.classid.selectedIndex == 0 ) {     
		alert('請選擇班別');	   
		return false;
	   } 
	
}
function Validate14(form) {
     if (document.frm14.studentNo.value == "" ) {     
		alert('請輸入學生編號');
	   document.frm14.studentNo.focus();
		return false;
	   }	 
	  if (document.frm14.FirstName.value == "" ) {     
		alert('請輸入學生名字');
	   document.frm14.FirstName.focus();
		return false;
	   }
	   if (document.frm14.LastName.value == "" ) {     
		alert('請輸入學生姓氏');
	   document.frm14.LastName.focus();
		return false;
	   }
	   if (document.frm14.email.value == "" ) {     
		alert('請輸入學生電郵');
	   document.frm14.email.focus();
		return false;
	   }
	   	if(!document.frm14.email.value.match(/[a-zA-Z\.\@\d\_]/)) {
           alert('電郵地址不乎');
  				document.frm14.email.focus();
         return false;
           }
		   if (!emailCheck (document.frm14.email.value) )
			{
				document.frm14.email.focus();
				return (false);
			} 	
	   
	   if (document.frm14.spassword.value != "" ) {
	      if (document.frm14.spassword2.value != document.frm14.spassword.value) {     
		alert('請輸入相同密碼');
	   document.frm14.spassword2.focus();
		return false;
		  }
	   }
	   if (document.frm14.locationid.selectedIndex == 0 ) {     
		alert('請選擇學校');	   
		return false;
	   }	 
	  if (document.frm14.classid.selectedIndex == 0 ) {     
		alert('請選擇班別');	   
		return false;
	   } 			
	
}
function Validate15(form) {
     if (document.frm15.studentNo.value == "" ) {     
		alert('請輸入學生編號');
	   document.frm15.studentNo.focus();
		return false;
	   }	 
	  if (document.frm15.getFirstName.value == "" ) {     
		alert('請輸入學生名字');
	   document.frm15.getFirstName.focus();
		return false;
	   }
	   if (document.frm15.getLastName.value == "" ) {     
		alert('請輸入學生姓氏');
	   document.frm15.getLastName.focus();
		return false;
	   }
	   if (document.frm15.getEmail.value == "" ) {     
		alert('請輸入學生電郵');
	   document.frm15.getEmail.focus();
		return false;
	   }
	   	if(!document.frm15.getEmail.value.match(/[a-zA-Z\.\@\d\_]/)) {
           alert('電郵地址不乎');
  				document.frm15.getEmail.focus();
         return false;
           }
		   if (!emailCheck (document.frm15.getEmail.value) )
			{
				document.frm15.getEmail.focus();
				return (false);
			}	
}
function Validate16(form) {
     if (document.frm16.tutorid.value == "" ) {     
		alert('請輸入學生編號');
	   document.frm16.tutorid.focus();
		return false;
	   }	 
	  if (document.frm16.FirstName.value == "" ) {     
		alert('請輸入學生名字');
	   document.frm16.FirstName.focus();
		return false;
	   }
	   if (document.frm16.LastName.value == "" ) {     
		alert('請輸入學生姓氏');
	   document.frm16.LastName.focus();
		return false;
	   }
	   if (document.frm16.email.value == "" ) {     
		alert('請輸入學生電郵');
	   document.frm16.email.focus();
		return false;
	   }
	   	if(!document.frm16.email.value.match(/[a-zA-Z\.\@\d\_]/)) {
           alert('電郵地址不乎');
  				document.frm16.email.focus();
         return false;
           }
		   if (!emailCheck (document.frm16.email.value) )
			{
				document.frm16.email.focus();
				return (false);
			} 	
	   if (document.frm16.spassword.value == "" ) {     
		alert('請輸入學生密碼');
	   document.frm16.spassword.focus();
		return false;
	   }
	   if (document.frm16.spassword.value != "" ) {
	      if (document.frm16.spassword2.value != document.frm16.spassword.value) {     
		alert('請輸入相同密碼');
	   document.frm16.spassword2.focus();
		return false;
		  }
	   }
	   if (document.frm16.locationid.selectedIndex == 0 ) {     
		alert('請選擇學校');	   
		return false;
	   }	 
	  if (document.frm16.classid.selectedIndex == 0 ) {     
		alert('請選擇班別');	   
		return false;
	   } 			
	
}
function Validate17(form) {
     if (document.frm17.tutorid.value == "" ) {     
		alert('請輸入教師編號');
	   document.frm17.tutorid.focus();
		return false;
	   }	 
	  if (document.frm17.FirstName.value == "" ) {     
		alert('請輸入教師名字');
	   document.frm17.FirstName.focus();
		return false;
	   }
	   if (document.frm17.LastName.value == "" ) {     
		alert('請輸入教師姓氏');
	   document.frm17.LastName.focus();
		return false;
	   }
	   if (document.frm17.email.value == "" ) {     
		alert('請輸入教師電郵');
	   document.frm17.email.focus();
		return false;
	   }
	   	if(!document.frm17.email.value.match(/[a-zA-Z\.\@\d\_]/)) {
           alert('電郵地址不乎');
  				document.frm17.email.focus();
         return false;
           }
		   if (!emailCheck (document.frm17.email.value) )
			{
				document.frm17.email.focus();
				return (false);
			} 	
	   
	   if (document.frm17.spassword.value != "" ) {
	      if (document.frm17.spassword2.value != document.frm17.spassword.value) {     
		alert('請輸入相同密碼');
	   document.frm17.spassword2.focus();
		return false;
		  }
	   }
	   if (document.frm17.locationid.selectedIndex == 0 ) {     
		alert('請選擇學校');	   
		return false;
	   }	 
	  if (document.frm17.classid.selectedIndex == 0 ) {     
		alert('請選擇班別');	   
		return false;
	   } 			
	
}
function Validate18(form) {
     if (document.frm18.tutorid.value == "" ) {     
		alert('請輸入教師編號');
	   document.frm18.tutorid.focus();
		return false;
	   }	 
	  if (document.frm18.getFirstName.value == "" ) {     
		alert('請輸入教師名字');
	   document.frm18.getFirstName.focus();
		return false;
	   }
	   if (document.frm18.getLastName.value == "" ) {     
		alert('請輸入教師姓氏');
	   document.frm18.getLastName.focus();
		return false;
	   }
	   if (document.frm18.getEmail.value == "" ) {     
		alert('請輸入學生電郵');
	   document.frm18.getEmail.focus();
		return false;
	   }
	   	if(!document.frm18.getEmail.value.match(/[a-zA-Z\.\@\d\_]/)) {
           alert('電郵地址不乎');
  				document.frm18.getEmail.focus();
         return false;
           }
		   if (!emailCheck (document.frm18.getEmail.value) )
			{
				document.frm18.getEmail.focus();
				return (false);
			}	
}
function Validate19(form) {
	if (document.frm19.email.value == "" ) {     
		alert('請輸入電郵');
	   document.frm19.email.focus();
		return false;
	   }
	   	if(!document.frm19.email.value.match(/[a-zA-Z\.\@\d\_]/)) {
           alert('電郵地址不乎');
  				document.frm19.email.focus();
         return false;
           }
		   if (!emailCheck (document.frm19.email.value) )
			{
				document.frm19.email.focus();
				return (false);
			}	
}
function Validate21(form) {
if (document.frm21.spassword.value == "" ) {     
		alert('請輸入學生密碼');
	   document.frm21.spassword.focus();
		return false;
	   }
	   if (document.frm21.spassword.value != "" ) {
	      if (document.frm21.spassword2.value != document.frm21.spassword.value) {     
		alert('請輸入相同密碼');
	   document.frm21.spassword2.focus();
		return false;
		  }
	   }
}
function Validate23(form) {
if (document.frm23.getname.value == "" ) {     
		alert('請輸入名稱');
	   document.frm23.getname.focus();
		return false;
	   }
	
}
function popupIMAGE(pid) {
  var page = "";
  page += pid;
  windowprops = "width=800,height=800,left=50, top=100,screenX=50,screenY=100,location=no,scrollbars=yes,menubars=no,toolbars=no,resize=yes";
  window.open(page, "Popup", windowprops);
}
function deleteAlertSport(photoid,id){
var conBox = confirm("是否確定刪除此相片: " + photoid);
if(conBox){ 
location.href="delete_sport_photo.php?awardid="+ id +"&photoid=" + photoid;
}else{
return;
}
}
function deleteAlertGallery(photoid,id){
var conBox = confirm("是否確定刪除此相片: " + photoid);
if(conBox){ 
location.href="delete_gallery_photo.php?awardid="+ id +"&photoid=" + photoid;
}else{
return;
}
}
