﻿  var http_request = false;
   function makeRequest(url) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      http_request.onreadystatechange = alertContents;
      http_request.open('GET', url, true);
      http_request.send(null);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('myspan').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }

    function uname(theform) { 

      if (theform.M_uname.value == "") {
        document.getElementById('myspan').innerHTML="<font color=red>6자리 이상 20자리 이내의 유저네임을 입력하세요.</font>";       
        theform.M_uname.focus();
        return;
        }
      if ((theform.M_uname.value.length < 5) || (theform.M_uname.value.length > 19)) {
       document.getElementById('myspan').innerHTML="<font color=red>6자리 이상 20자리 이내의 유저네임을 입력하세요.</font>";  
       theform.M_uname.focus();
       return;
      }              	

     document.getElementById('myspan').innerHTML = "<img src='/js/loading.gif'> Requesting content...";                    
     makeRequest("/common/ajax_checkuser.cfm?M_uname="+theform.M_uname.value);
    }       







   function submit_register(theform) {  
       
        function IsNumericBLN(objField) {
	var blnNumeric = true
	
	// SCAN string for non-numeric characters.
	for (var i = 0; i < objField.value.length; i++) {
	
		var strDigit = objField.value.charAt(i)
	
		if (strDigit < "0" || strDigit > "9") {	//non-numeric character has been found.
			blnNumeric = false
			break
		}
	}		
	return blnNumeric	
       }

      function EMailValidBLN(objField) {        	
	if (objField.value.indexOf ('@', 0) == -1 || objField.value.indexOf ('.', 0) == -1) {	// address does not contain the "@" and "." characters.					  
		return false;      
	}	
	else {	// the address is acceptable.
		return true;      
	}   
      }

	   if (theform.M_lname.value == "")  {
        document.getElementById('myspan').innerHTML="<font color=red>Last Name(성)을   입력하세요.</font>";
        theform.M_lname.focus();
        return;
        }

		 if (theform.M_fname.value == "")  {
        document.getElementById('myspan').innerHTML="<font color=red>First Name(이름) 입력하세요.</font>";
        theform.M_fname.focus();
        return;
        }
       
        // VALIDATE email address.
        if (!EMailValidBLN(theform.M_email) || (theform.M_email.value.length < 9)) {
        document.getElementById('myspan').innerHTML="<font color=red>정확한 이메일 아이디를 입력하세요.</font>";  
        theform.M_email.focus();
        return;
        }

        if ((theform.M_uname.value == "") || (theform.M_uname.value.length < 6)) {
        document.getElementById('myspan').innerHTML="<font color=red>6자리 이상의 영문, 숫자 조합의 유저네임을 입력하세요.</font>";
        theform.M_uname.focus();
        return;
        }
  
        if ((theform.M_pass.value == "") || (theform.M_pass.value.length < 6)) {
        document.getElementById('myspan').innerHTML="<font color=red>6자리 이상의 비밀번호를 입력하세요.</font>";
        theform.M_pass.focus();
        return;
        }
             
		 
         if ((theform.M_city.value == "") || (theform.M_city.value.length < 2)) {
        document.getElementById('myspan').innerHTML="<font color=red>거주하시는 지역의 도시명을 입력하세요.</font>";
        theform.M_city.focus();
        return;
        }
        
		 if (typeof theform.M_country!="undefined" && theform.M_country.selectedIndex < 1) {
         document.getElementById('myspan').innerHTML="<font color=red>거주 하시는 국가를 선택하세요.</font>";         
         theform.M_country.focus();
         return;
           }    

        if (theform.checkterms.checked == false){
        document.getElementById('myspan').innerHTML="<font color=red>회원등록에 관한 약관에 동의하십니까?</font>"; 
        theform.checkterms.focus();
        return;
        }

        theform.action="http://www.sisadaily.com/common/account.cfm?amode=add";
        theform.submit();   
}
