//***********************************************************************************//
//Ajax 重新產生《驗證碼》的 Function;
//***********************************************************************************//
function Re_NewNumber(divID, MSG_LANG, Class_Name)
{
   var obj       = document.getElementById(divID);
   var url       = '/manager/include/ajax_lib/VCode_aj_ReNo.php';
   var postStr   = 'MSG_LANG=' + MSG_LANG + '&Class_Name=' + Class_Name + '&parm=' + new Date().getTime();
   var XmlHR_Obj = InitXMLHttpRequestObject();

//   obj.innerHTML = '<font color="#FF0000">Loading..........  Please Wait!!</font>';

   if(XmlHR_Obj)
   {
      XmlHR_Obj.open('POST', url, true);
      XmlHR_Obj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
      XmlHR_Obj.send(postStr);

      XmlHR_Obj.onreadystatechange = function()
      {
       if(XmlHR_Obj.readyState == 4 && XmlHR_Obj.status == 200) {
          obj.innerHTML = XmlHR_Obj.responseText;
          }
      }//End of XmlHR_Obj.onreadystatechange = function();

   }//End of if(XmlHR_Obj);

}//End of function Re_NewNumber(divID, MSG_LANG, Class_Name);



//***********************************************************************************//
//Ajax 確認《帳號》是否重複 的資料 Function;
//***********************************************************************************//
function Chk_OnSubmit(Verify_Code, MSG_LANG)
{
	var Error_Msg; 

	if(MSG_LANG == 'EN')
	   Error_Msg = 'Please input the Code!';
	else
     Error_Msg = '請輸入驗證碼!';
	
   if(Verify_Code == '') {
      alert(Error_Msg);
      document.getElementById('Verify_Code').focus();
      document.getElementById('Verify_Code').select();
      return false;
      } 

   var obj_Form  = document.getElementById('Contact_Form');
   var url       = '/manager/include/ajax_lib/VCode_aj_ChkNo.php';
   var postStr   = 'Verify_Code=' + Verify_Code + '&MSG_LANG=' + MSG_LANG + '&parm=' + new Date().getTime();
   var XmlHR_Obj = InitXMLHttpRequestObject();

//   obj.innerHTML = '<font color="#FF0000">Loading..........  Please Wait!!</font>';

   if(XmlHR_Obj)
   {
      XmlHR_Obj.open('POST', url, true);
      XmlHR_Obj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
      XmlHR_Obj.send(postStr);

      XmlHR_Obj.onreadystatechange = function()
      {
       if(XmlHR_Obj.readyState == 4 && XmlHR_Obj.status == 200) {
          var retren_Val = XmlHR_Obj.responseText.split('|');

          if(parseInt(retren_Val[0]) > 0) {
	           obj_Form.submit();
             }
          else {
             alert(retren_Val[1]);
	           document.getElementById(retren_Val[2]).focus();
	           document.getElementById(retren_Val[2]).select();
             return false;
             }

          }

      }//End of XmlHR_Obj.onreadystatechange = function();

   }//End of if(XmlHR_Obj);

}//End of function Chk_OnSubmit(Verify_Code, MSG_LANG);



//***********************************************************************************//
//Contact Us 所需檢查的欄位值;
//***********************************************************************************//
function CheckValue_TW()
{

   if(document.getElementById('the_name').value == "") {
      alert("請輸入姓名 !!");
      document.getElementById('the_name').focus();
      document.getElementById('the_name').select();
      return false;
      }			

   if(document.getElementById('the_email').value == "") {
      alert("請輸入E-MAIL !!");
      document.getElementById('the_email').focus();
      document.getElementById('the_email').select();
      return false;
      }			

   if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('the_email').value))) {
      alert("請輸入正確的 E-MAIL 格式!!");
      document.getElementById('the_email').focus();
      document.getElementById('the_email').select();
      return false;
		  }


   if(document.getElementById('the_tel').value == "") {
      alert("請輸入電話 !!");
      document.getElementById('the_tel').focus();
      document.getElementById('the_tel').select();
      return false;
      }

   if(document.getElementById('the_subject').value == "") {
      alert("請輸入留言標題 !!");
      document.getElementById('the_subject').focus();
      document.getElementById('the_subject').select();
      return false;
      }

   if(document.getElementById('the_content').value == "") {
      alert("請輸入留言內容 !!");
      document.getElementById('the_content').focus();
      document.getElementById('the_content').select();
      return false;
      }

   if(document.getElementById('Verify_Code').value.length != 5 ) {
      alert("請輸入驗證碼 !!");
      document.getElementById('Verify_Code').focus();
      document.getElementById('Verify_Code').select();
      return false;
      }

   Chk_OnSubmit(document.getElementById('Verify_Code').value, 'TW');

}


//***********************************************************************************//
//Contact Us 所需檢查的欄位值;
//***********************************************************************************//
function CheckValue_EN()
{

   if(document.getElementById('the_name').value == "") {
      alert("Please input the Name !!");
      document.getElementById('the_name').focus();
      document.getElementById('the_name').select();
      return false;
      }			

   if(document.getElementById('the_email').value == "") {
      alert("Please input the E-MAIL !!");
      document.getElementById('the_email').focus();
      document.getElementById('the_email').select();
      return false;
      }			

   if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('the_email').value))) {
      alert("Please enter the correct E-Mail Format !!");
      document.getElementById('the_email').focus();
      document.getElementById('the_email').select();
      return false;
		  }


   if(document.getElementById('the_tel').value == "") {
      alert("Please input the Tel !!");
      document.getElementById('the_tel').focus();
      document.getElementById('the_tel').select();
      return false;
      }

   if(document.getElementById('the_subject').value == "") {
      alert("Please input the Subject !!");
      document.getElementById('the_subject').focus();
      document.getElementById('the_subject').select();
      return false;
      }

   if(document.getElementById('the_content').value == "") {
      alert("Please input the Message !!");
      document.getElementById('the_content').focus();
      document.getElementById('the_content').select();
      return false;
      }

   if(document.getElementById('Verify_Code').value.length != 5 ) {
      alert("Please input the Code !!");
      document.getElementById('Verify_Code').focus();
      document.getElementById('Verify_Code').select();
      return false;
      }

   Chk_OnSubmit(document.getElementById('Verify_Code').value, 'EN');

}
//***********************************************************************************//
//END
//***********************************************************************************//
