function checkrequirefields_bio(frm) {
          
   var selection = -1
    for (i=0; i<frm.bio_type.length; i++) {
       if (frm.bio_type[i].checked)
          selection = i;
    }
    if (selection == -1) {
       alert ("Please select one of the biography type.(Heroes or Other Notables?)");
       frm.bio_type[0].focus();
       return false;
    }
  
   if (frm.hero_on_home.checked == true){
      vObj = frm.title;
      if (vObj.value == ""){
         alert("Please enter the title that will be shown on the homepage.");
         vObj.focus();
         return false;
      }   
   }
      
   vObj = frm.firstname_en;
   if (vObj.value == "") {
      alert("Please enter the first name in English.");
      vObj.focus();
      return false; 
   }
   
   vObj = frm.lastname_en;
   if (vObj.value == "") {
      alert("Please enter the last name in English.");
      vObj.focus();
      return false; 
   }
       
   /*   
   vObj = frm.name_ch;
   if (vObj.value == "") {
      alert("Please enter the name in Chinese.");
      vObj.focus();
      return false; 
   }
   */
          
   var selection = -1
    for (i=0; i<frm.gender.length; i++) {
       if (frm.gender[i].checked)
          selection = i;
    }
    if (selection == -1) {
       alert ("Please select the gender.");
       frm.gender[0].focus();
       return false;
    }
   
   /*
   vObj = frm.current_location;
   if (vObj.value == "") {
      alert("Please enter the current location for this person.");
      vObj.focus();
      return false; 
   }
   */
   /*
   var Choice = frm.state.selectedIndex
     if (frm.state.options[Choice].value == "")
     {
       alert("You must select the state.");
       frm.state.focus();
       return false;
     } 
  */
   /*  
   vObj = frm.birth_date;
   if (vObj.value == "") {
      alert("Please enter this person's the date of birth.");
      vObj.focus();
      return false; 
   }
   */
       
   vObj = frm.birth_place;
   if (vObj.value == "") {
      alert("Where is the place of birth of this person.");
      vObj.focus();
      return false; 
   }
        
   vObj = frm.profession;
   if (vObj.value == "") {
      alert("Please enter the profession for this person.");
      vObj.focus();
      return false; 
   }
   
   /*     
   vObj = frm.education;
   if (vObj.value == "") {
      alert("Please enter the education for this person.");
      vObj.focus();
      return false; 
   }
   */
         
   /*vObj = frm.awards;
   if (vObj.value == "") {
      alert("Please list the awards for this person.");
      vObj.focus();
      return false; 
   }
  */
          
   var selection = -1
    for (i=0; i<frm.bio_category.length; i++) {
       if (frm.bio_category[i].checked){
          selection = i;
       }   
    }
    
    if (selection == -1) {
       alert ("Please check at least one of the category.");
       frm.bio_category[0].focus();
       return false;
    }
                                                                           
   return true;
 } 
 
 function checkrequirefields_bio_edit(frm) {
     
    vObj = frm.comment;
   if (vObj.value == "") {
      alert("Please describe the detail in the comment box.");
      vObj.focus();
      return false; 
   }
         
   var selection = -1
    for (i=0; i<frm.bio_type.length; i++) {
       if (frm.bio_type[i].checked)
          selection = i;
    }
    if (selection == -1) {
       alert ("Please select one of the biography type.(Heroes or Other Notables?)");
       frm.bio_type[0].focus();
       return false;
    }
  
   if (frm.hero_on_home.checked == true){
      vObj = frm.title;
      if (vObj.value == ""){
         alert("Please enter the title that will be shown on the homepage.");
         vObj.focus();
         return false;
      }   
   }
      
   vObj = frm.firstname_en;
   if (vObj.value == "") {
      alert("Please enter the first name in English.");
      vObj.focus();
      return false; 
   }
      
   vObj = frm.lastname_en;
   if (vObj.value == "") {
      alert("Please enter the last name in English.");
      vObj.focus();
      return false; 
   }
       
   /*   
   vObj = frm.name_ch;
   if (vObj.value == "") {
      alert("Please enter the name in Chinese.");
      vObj.focus();
      return false; 
   }
   */
          
   var selection = -1
    for (i=0; i<frm.gender.length; i++) {
       if (frm.gender[i].checked)
          selection = i;
    }
    if (selection == -1) {
       alert ("Please select the gender.");
       frm.gender[0].focus();
       return false;
    }
   /*
   vObj = frm.current_location;
   if (vObj.value == "") {
      alert("Please enter the current location for this person.");
      vObj.focus();
      return false; 
   }
   */
   /*
   var Choice = frm.state.selectedIndex
     if (frm.state.options[Choice].value == "")
     {
       alert("You must select the state.");
       frm.state.focus();
       return false;
     } 
  */
   /*    
   vObj = frm.birth_date;
   if (vObj.value == "") {
      alert("Please enter this person's the date of birth.");
      vObj.focus();
      return false; 
   }
   */
       
   vObj = frm.birth_place;
   if (vObj.value == "") {
      alert("Where is the place of birth of this person.");
      vObj.focus();
      return false; 
   }
        
   vObj = frm.profession;
   if (vObj.value == "") {
      alert("Please enter the profession for this person.");
      vObj.focus();
      return false; 
   }
   
   /*     
   vObj = frm.education;
   if (vObj.value == "") {
      alert("Please enter the education for this person.");
      vObj.focus();
      return false; 
   }
   */
   /*      
   vObj = frm.awards;
   if (vObj.value == "") {
      alert("Please list the awards for this person.");
      vObj.focus();
      return false; 
   }
   */       
   var selection = -1
    for (i=0; i<frm.bio_category.length; i++) {
       if (frm.bio_category[i].checked){
          selection = i;
       }   
    }
    
    if (selection == -1) {
       alert ("Please check at least one of the category.");
       frm.bio_category[0].focus();
       return false;
    }
   
                                                                                 
   return true;
 } 
 
 function checkrequirefields_history(frm) {
          
   vObj = frm.historical_date;
   if (vObj.value == "") {
      alert("Please enter the date.");
      vObj.focus();
      return false; 
   }
   
   vObj = frm.description;
   if (vObj.value == "") {
      alert("Please enter the description.");
      vObj.focus();
      return false; 
   }
   
   vObj = frm.synopsis;
   if (vObj.value == "") {
      alert("Please enter the synopsis.");
      vObj.focus();
      return false; 
   }
  
                                              
   return true;
 } 
 
 function checkrequirefields_news(frm) {
          
   vObj = frm.news_date;
   if (vObj.value == "") {
      alert("Please enter the date.");
      vObj.focus();
      return false; 
   }
   
   vObj = frm.subject;
   if (vObj.value == "") {
      alert("Please enter the subject.");
      vObj.focus();
      return false; 
   }
   
   frm.CONTENT1.value = oEdit1.getHTMLBody();
    	  
   return true;
 } 
 
 
 function checkrequirefields_news_edit(frm) {
          
   vObj = frm.news_date;
   if (vObj.value == "") {
      alert("Please enter the date.");
      vObj.focus();
      return false; 
   }
   
   vObj = frm.subject;
   if (vObj.value == "") {
      alert("Please enter the subject.");
      vObj.focus();
      return false; 
   }
   
    vObj = frm.comment;
   if (vObj.value == "") {
      alert("Please describe the changes in the comment box.");
      vObj.focus();
      return false; 
   }
             
   frm.CONTENT1.value = oEdit1.getHTMLBody();
    	  
   return true;
 } 
 
function checkrequirefields_contact(frm) {    
   
   
  if (frm.strCAPTCHA.value == "")
  {
    alert("Please enter a value in the image.");
    frm.strCAPTCHA.focus();
    return (false);
  }
     
   vObj = frm.firstname;
   if (vObj.value == "") {
      alert("Please enter your first name.");
      vObj.focus();
      return false; 
   }
   
   vObj = frm.lastname;
   if (vObj.value == "") {
      alert("Please enter your last name.");
      vObj.focus();
      return false; 
   }
   
   vObj = frm.email;
   if (vObj.value == "") {
      alert("Please enter your email.");
      vObj.focus();
      return false; 
   }
   
   vObj = frm.messages;
   if (vObj.value == "") {
      alert("Please enter your comments.");
      vObj.focus();
      return false; 
   }
   
   return true;
   
}
 
function previewit()
{
    var aForm;
    aForm = document.form1.elements;
    var myObject = new Object();
    document.form1.CONTENT1.value = oEdit1.getHTMLBody();
    
    myObject.content1 = aForm.CONTENT1.value;
       
    //myObject.pending_id = aForm.pending_id.value;
    
	// The object "myObject" is sent to the modal window.
	url = "preview_detail.asp";	
	
    window.showModalDialog(url, myObject, "dialogWidth:500px;dialogHeight:500px;edge:Raised;center:1;help:0;resizable:1;maximize:1"); 
}

 
function previewit_history()
{
    var aForm;
    aForm = document.form1.elements;
    var myObject = new Object();
    
    myObject.historical_date = aForm.historical_date.value;
       
    myObject.description = aForm.description.value;
    myObject.synopsis = aForm.synopsis.value;
        
	// The object "myObject" is sent to the modal window.
	url = "preview_detail.asp";	
	
    window.showModalDialog(url, myObject, "dialogWidth:500px;dialogHeight:500px;edge:Raised;center:1;help:0;resizable:1;maximize:1"); 
}

 function WordsChecking(field){
    if (CountWords(field, false, false) > 40){
       alert("Please enter the synopsis less than 40 words.");
       field.focus();
    }
 }
 
 //Check numbers only 
function validate_number(field) {
  var valid = "0123456789"
  var ok = "yes";
  var temp;
  for (var i=0; i<field.value.length; i++) {
  temp = "" + field.value.substring(i, i+1);
  if (valid.indexOf(temp) == "-1") ok = "no";
  }
  if (ok == "no") {
     alert("Invalid entry!  Only numbers are accepted!");
     field.focus();
     field.select();
   }
} 

function check_email(emailfield)
{ 
    vObj = emailfield;
  
    var re=/^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/;
    if (vObj.value != "")
    {
      if (!re.test(vObj.value))
      {
         alert("Invalid email address!");
         vObj.focus();
         vObj.select();
         return false;
      }
    }  
    return true;
}    

