function isValidAgree(agree) {
   if (!agree.checked) {
      alert("You must accept the handling of personal information.");
      agree.focus();
      return false;
   }

   return true;
}

function isValidName(name) {
   if (name.value.blank()) {
      alert("Enter the name.");
	    name.focus();
	    return false;
   }

   var isKRName = /^[가-힣\s]+$/.test(name.value);
   var isENName = /^[A-Za-z\s]+$/.test(name.value);
   var isJPName = /^[\u3040-\u30FF\u4E00-\u9FCF\s]+$/.test(name.value);

   if (isKRName || isJPName) {
      if (name.value.strip() != name.value.space()) {
         alert(((isKRName) ? "Hangul" : "Chinese") + "Enter the name without a space.");         
         name.focus();
         return false;
      }
   }
   else {
      if (!isENName) {
         alert("Hangul statement, or the alphabet, to enter Chinese characters.");         
         name.focus();
         return false;
      }
   }

   if (name.value.space().length < 2){
      alert("Name the 2-20 characters.");
      name.focus();
      return false;
   }

   return true;
}

function isValidKorRegNo(regNo1, regNo2) {   
   var regNo = (regNo1.value + regNo2.value).split("");
   var code  = [2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5];
   var sum   = 0; 
   
   for (i = 0; i <= 11; i++) {
      sum += regNo[i] * code[i];
   }

   if ((11 - sum % 11) % 10 != regNo[12]) {      
      return false;
   }

   return true;
}

function isValidForRegNo(regNo1, regNo2) {   
   var regNo = (regNo1.value + regNo2.value).split("");

   if (regNo[11] < 6 || (regNo[7] * 10 + regNo[8] * 1) % 2) {      
      return false;
   }

   var code = [2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5];
   var sum  = 0;    

   for (i = 0; i <= 11; i++) {
      sum += regNo[i] * code[i];
   }

   sum = 11 - sum % 11;

   if (sum >= 10) {
      sum -= 10;
   }

   sum += 2;

   if (sum >= 10) {
      sum -= 10;
   }

   if (sum != regNo[12]) {      
      return false;
   }

   return true;
}

function isValidRegNo(regNo1, regNo2) {
   if (regNo1.value.blank()) {
      alert("Enter your first a social security number.");
      regNo1.focus();
      return false;
   }

   if (regNo1.value.length < 6) {
      alert("Enter your first a social security number is 6 characters.");
	    regNo1.focus();
	    return false;
   }

   if (regNo2.value.blank()) {
      alert("Enter your second a social security number.");
	    regNo2.focus();
	    return false;
   }

   if (regNo2.value.length < 7) {
      alert("Enter your second a social security number is 7 characters.");
	    regNo2.focus();
	    return false;
   }

   if (!(isValidKorRegNo(regNo1, regNo2) || isValidForRegNo(regNo1, regNo2))) {
      alert(" It is not a valid social security number. ");
	    regNo1.focus();
	    return false;
   }

   return true;
}

function isValidParent(parent) {
   if (!parent[0].checked && !parent[1].checked) {
      alert("학부모님 구분을 선택하세요.");
      return false;
   }

   return true;
}

function isValidID(id) {
   if (id.value.blank()) {
      alert("Enter your ID.");
	    id.focus();
	    return false;
   }

   if (id.value.length < 4) {
      alert("ID is 4~14 characters.");
	    id.focus();
	    return false;
   }

   return true;
}

function isValidPW(pw, msg) {
   if (!msg) {
      msg = "";
   }

   if (pw.value.blank()) {
      alert(msg + "Enter your password.");
	    pw.focus();
	    return false;
   }

   if (pw.value.length < 6) {
      alert("Enter your password is 6-14 characters.");
	    pw.focus();
	    return false;
   }

   return true;
}

function isValidPWConfirm(pw, pwConfirm) {  
   if (pwConfirm.value == "") {
      alert("Check your password.");
      pwConfirm.focus();
      return false;
   }

   if (pw.value != pwConfirm.value) {
      alert("Your password correctly, could not be verified.");
      pwConfirm.focus();
      return false;
   }

   return true;
}

function isValidPhone(phone2, phone3, msg) {
   if (phone2.value.blank()) {
      alert(msg + "Enter your phone number to the center of.");
      phone2.focus();
      return false;
   }

   if (phone2.value.length < 3) {
      alert(msg + "phone number to the center is 3-4 characters.");
      phone2.focus();
      return false;
   }

   if (phone3.value.blank()) {
      alert(msg + "Enter your phone number in the last of.");
      phone3.focus();
      return false;
   }

   if (phone3.value.length < 4) {
      alert(msg + "phone number to the last is 4 characters.");
      phone3.focus();
      return false;
   }

   return true;
}

function isValidAddress(address1, address2) {
   if (address1.value.blank()) {
      alert("Postal code, Enter your search using the address.");
      return false;
   }

   if (address2.value.blank()) {
      alert("Enter the address details.");
	    address2.focus();
	    return false;
   }

   return true;
}

function isValidEmail(email) {
   if (email.value.blank()) {
      alert("Enter the your email address.");
      email.focus();
      return false;
   }

   var regExp = /^[_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+)*@[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)+$/;

   if (!regExp.test(email.value)) {
      alert("It is not a valid e-mail address.");
      email.focus();
      return false;
   }

   return true;
}

function isValidSchool(school) {
   if (!school[0].checked && !school[1].checked) {
      alert("Select a distinction between schools.");
      return false;
   }

   return true;
}

function isValidTitle(title, msg) {
   if (!msg) {
      msg = " title.";
   }

   if (title.value.blank()) {
      alert("Enter the" +msg);
	    title.focus();
	    return false;
   }

   return true;
}

function isValidContent(content, msg) {
   if (content) {
      if (!msg) {
         msg = "";
      }

      if (content.value.blank()) {
         alert(msg + "Enter the contents.");
		     content.focus();
		     return false;
	    }
   }
   else {
      var editor = FCKeditorAPI.GetInstance("content");
      var xhtml  = editor.GetXHTML(true);

      if (xhtml.blank()) {
         alert("Enter the contents.");
	       editor.Focus();
         return false;		 
      }
   }

   return true;
}

function isValidComment(comment) {
   if (comment.value.blank()) {
      alert("Enter the comment.");
	    comment.focus();
	    return false;
   }

   return true;
}

function isValidReply(reply) {
   if (reply.value.blank()) {
      alert("Enter the reply.");
	    reply.focus();
	    return false;
   }

   return true;
}

function isValidMovie(movie) {   
   if (movie.value.blank()) {
      alert("Upload your video.");	    
	    return false;
   }

   return true;
}

function isValidCateName(name) {
   if (name.value.blank()) {
      alert("Enter the label name.");
	    name.focus();
	    return false;
   }

   if (name.value.search(/\\|:|\*|\?|\"|<|>|\|/) > -1) {
      alert("Category, you can not use the name of the character.\n\n             \\  :  *  ?  \"  <  >  |");
	    name.focus();
	    return false;
   }

   return true;
}

function isValidCateNo(no) {
   if (no.value == "-1") {
      alert("Choose your category.");
	    no.focus();
	    return false;
   }

   return true;
}

function isValidKeyword(keyword) {
   if (keyword.value.blank()) {
      alert("Enter the search term.");
      keyword.focus();
      return false;
   }

   return true;
}

function isValidTime(time) {
   if (time.value.blank()) {
      alert("Enter the time.");
      time.focus();
      return false;
   }

   return true;
}

function isValidPlace(place) {
   if (place.value.blank()) {
      alert("Enter the place.");
      place.focus();
      return false;
   }

   return true;
}

function isValidMaximum(maximum) {
   if (maximum.value.blank()) {
      alert("Enter the maximum capacity.");
      maximum.focus();
      return false;
   }

   if (maximum.value == 0) {
      alert("Enter 1, more than the maximum capacity.");
      maximum.focus();
      return false;
   }

   return true;
}

function isValidPersonnel(maximum, personnel) {
   if (personnel.value.blank()) {
      alert("Enter the number of people with a visit.");
      personnel.focus();
      return false;
   }

   if (personnel.value == 0) {
      alert("Capacity in a visit to at least enter 1.");
      personnel.focus();
      return false;
   }

   if (Number(personnel.value) > maximum.value) {
      alert("Capacity in a visit to enter the maximum capacity or less.");
      personnel.focus();
      return false;
   }

   return true;
}

function isValidDeparture(departure) {
   for (i = 0; i < departure.length; i++) {
      if (!departure[i].value.blank()) {
         return true;
      }
   }

   alert("Enter the ride.");
   return false;
}

function isValidPercent11(primary, middle) {   
   if (primary.value.blank()) {
      alert("Enter the percentage of elementary school.");
      primary.focus();
      return false;
   }

   if (primary.value > 100) {
      alert("Enter the percentage of elementary school less than 100%.");
      primary.focus();
      return false;
   }

   if (middle.value.blank()) {
      alert("Enter the percentage of middle school.");
      middle.focus();
      return false;
   }

   if (middle.value > 100) {
      alert("Enter middle school, the percentage of less than 100%.");
      middle.focus();
      return false;
   }

   if (Number(primary.value) + Number(middle.value) != 100) {
      alert("Elementary and junior high percentage of the sum is not 100%.");         
      return false;
   }

   return true;
}

function isValidPercent2(middle, high) {   
   if (middle.value.blank()) {
      alert("Enter the percentage of middle school.");
      middle.focus();
      return false;
   }

   if (middle.value > 100) {
      alert("Enter middle school, the percentage of less than 100%.");
      middle.focus();
      return false;
   }

   if (high.value.blank()) {
      alert("Enter the percentage of high school.");
      high.focus();
      return false;
   }

   if (high.value > 100) {
      alert("Enter the percentage of high school less than 100%.");
      high.focus();
      return false;
   }

   if (Number(middle.value) + Number(high.value) != 100) {
      alert("Middle school and high school, the percentage of the sum is not 100%.");         
      return false;
   }

   return true;
}

function isValidParticipate(school) {
   if (!school[0].checked && !school[1].checked) {
      alert("Choose participate in the presentation.");
      return false;
   }

   return true;
}

function isValidGrade(grade) {
   if (grade.value.blank()) {
      alert("Choose your membership level.");
      return false;
   }

   return true;
}

function isValidSize(width, height, msg) {
   if (width.value.blank()) {
      alert(msg + "Enter the horizontal size.");
      width.focus();
      return false;
   }

   if (height.value.blank()) {
      alert(msg + "Enter the vertical size.");
      height.focus();
      return false;
   }

   return true;
}

function isValidPosition(left, top, msg) {
   if (left.value.blank()) {
      alert(msg + "Enter the horizontal position.");
      left.focus();
      return false;
   }

   if (top.value.blank()) {
      alert(msg + "Enter the vertical position.");
      top.focus();
      return false;
   }

   return true;
}

function isValidDetailURL(detailURL) {
   if (detailURL.value.blank()) {
      alert("Learn more about enter a URL.");
      detailURL.focus();
      return false;
   }

   return true;
}

function isValidDate(year) {
   if (year.value.blank()) {
      alert("Enter a date using the calendar.");	  
      return false;
   }

   return true;
}


