//***********************************************************************************//
//Ajax 《 新增詢價產品 》 的資料 Function;
//***********************************************************************************//
function Chk_buyList(i_products_id, type_flag, vc_session_id, Btn_id, Msg_id)
{
   var url       = '/manager/include/ajax_lib/aj_buyList_Check.php';
   var postStr   = 'i_products_id=' + i_products_id + '&type_flag=' + type_flag + '&vc_session_id=' + vc_session_id + '&parm=' + new Date().getTime();
   var XmlHR_Obj = InitXMLHttpRequestObject();

//   obj.innerHTML = '<font color="#FF0000">Loading..........  Please Wait!!</font>';

   document.getElementById(Btn_id).disabled = true;
   document.getElementById(Msg_id).innerHTML =  '<font color="#FF0000">Loading...!!</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;
          if(parseInt(retren_Val) == 1) {
             temp = confirm("Add Complete,\n\n Would you want to go 《 Inquiry cart 》？");
             if(temp == true ) 
                document.location.replace('buyList.php');
             }
          else {
             alert('Product is not found. ');
             }

          document.getElementById(Btn_id).disabled  = false;
          document.getElementById(Msg_id).innerHTML =  '';

          }

      }//End of XmlHR_Obj.onreadystatechange = function();

   }//End of if(XmlHR_Obj);

}//End of function Chk_buyList(i_products_id, type_flag, vc_session_id, Btn_id, Msg_id);



//***********************************************************************************//
//Ajax 《 修正詢價數量 》 的資料 Function;
//***********************************************************************************//
function Mod_buyList(i_inq_tmp_id, type_flag, i_qty, Btn_id, Msg_id)
{
   var url       = '/manager/include/ajax_lib/aj_buyList_Check.php';
   var postStr   = 'i_inq_tmp_id=' + i_inq_tmp_id + '&type_flag=' + type_flag + '&i_qty=' + i_qty + '&parm=' + new Date().getTime();
   var XmlHR_Obj = InitXMLHttpRequestObject();

//   obj.innerHTML = '<font color="#FF0000">Loading..........  Please Wait!!</font>';

   document.getElementById(Btn_id).disabled = true;
   document.getElementById(Msg_id).innerHTML =  '<font color="#FF0000">Loading...!!</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;
          if(parseInt(retren_Val) == 1) {
             alert("Modify Complete");
             }
          else {
             alert('Product is not found. ');
             }
          }

       document.getElementById(Btn_id).disabled  = false;
       document.getElementById(Msg_id).innerHTML =  '';
       
      }//End of XmlHR_Obj.onreadystatechange = function();

   }//End of if(XmlHR_Obj);

}//End of function Mod_buyList(i_inq_tmp_id, type_flag, i_qty, Btn_id, Msg_id);




//***********************************************************************************//
//詢價單 所需檢查的欄位值;
//***********************************************************************************//
function CheckbuyList_1()
{
   var Error_Msg = 'Please input the Company !!';
   if(document.getElementById('the_company').value == "") {
      alert(Error_Msg);
      document.getElementById('the_company').focus();
      document.getElementById('the_company').select();
      return false;
      }

   var Error_Msg = 'Please input the Name !!';
   if(document.getElementById('the_name').value == "") {
      alert(Error_Msg);
      document.getElementById('the_name').focus();
      document.getElementById('the_name').select();
      return false;
      }			

   var Error_Msg = 'Please input the Email !!';
   if(document.getElementById('the_email').value == "") {
      alert(Error_Msg);
      document.getElementById('the_email').focus();
      document.getElementById('the_email').select();
      return false;
      }			


   var Error_Msg = 'Please input the correct Email format !!';
   if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('the_email').value))) {
      alert(Error_Msg);
      document.getElementById('the_email').focus();
      document.getElementById('the_email').select();
      return false;
      }

   var Error_Msg = 'Please input the Tel !!';
   if(document.getElementById('the_tel').value == "") {
      alert(Error_Msg);
      document.getElementById('the_tel').focus();
      document.getElementById('the_tel').select();
      return false;
      }


   return true;

}

//***********************************************************************************//
//END
//***********************************************************************************//
