	var xmlHttp;

	function createXMLHttpRequest() {
	 if (window.ActiveXObject) {
		    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		 } 
			else if (window.XMLHttpRequest) {
			 xmlHttp = new XMLHttpRequest();
			 }
		}



    function startRequest_post() {
		   createXMLHttpRequest();
            var pForm = document.forms.pForm1;
            var pBody = getRequestBody(pForm);                
            xmlHttp.open("post", pForm.action, true);
            xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            
            xmlHttp.onreadystatechange = function () {
		  document.getElementById("maincontent").innerHTML='<div id="wait"><br /><img src=images/Progressbar.gif><br />กำลังโหลด...<br /><br /></div>';
                if (xmlHttp.readyState == 4) {
                    if (xmlHttp.status == 200) {
                        displayInfo(xmlHttp.responseText);
                    } else {
                        displayInfo("พบข้อผิดพลาด " + xmlHttp.statusText);
                    }
                }            
            };
            xmlHttp.send(pBody);        
        }

        function startRequest_post1() {
		   createXMLHttpRequest();
            var pForm = document.forms[0];
            var pBody = getRequestBody(pForm);                
            xmlHttp.open("post", pForm.action, true);
            xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            
            xmlHttp.onreadystatechange = function () {
		  document.getElementById("maincontent").innerHTML='<div id="wait"><br /><img src=images/Progressbar.gif><br />กำลังโหลด...<br /><br /></div>';
                if (xmlHttp.readyState == 4) {
                    if (xmlHttp.status == 200) {
                        displayInfo(xmlHttp.responseText);
                    } else {
                        displayInfo("พบข้อผิดพลาด " + xmlHttp.statusText);
                    }
                }            
            };
            xmlHttp.send(pBody);        
        }


        function startRequest_post2() {
		   createXMLHttpRequest();
            var pForm = document.forms.pFormcart;
            var pBody = getRequestBody(pForm);                
            xmlHttp.open("post", pForm.action, true);
            xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            
            xmlHttp.onreadystatechange = function () {
		  document.getElementById("maincontent").innerHTML='<div id="wait"><br /><img src=images/Progressbar.gif><br />กำลังโหลด...<br /><br /></div>';
                if (xmlHttp.readyState == 4) {
                    if (xmlHttp.status == 200) {
                        displayInfo(xmlHttp.responseText);
						addcart(":||:../");
                    } else {
                        displayInfo("พบข้อผิดพลาด " + xmlHttp.statusText);
                    }
                }            
            };
            xmlHttp.send(pBody);        
        }


        function getRequestBody(pForm) {
            var nParams = new Array();
            
            for (var i=0 ; i < pForm.elements.length; i++) {
                var pParam = encodeURIComponent(pForm.elements[i].name);
                pParam += "=";
                pParam += encodeURIComponent(pForm.elements[i].value);
                nParams.push(pParam);
            } 
            
            return nParams.join("&");        
        }


                
		// เสดงข้อมูล
        function displayInfo(pMessage) {
            var divStatus = document.getElementById("maincontent");
			addcart(":||:../");
            divStatus.innerHTML =  pMessage;            
        }

  function callback() {
	  document.getElementById("maincontent").innerHTML='<div id="wait"><br /><img src=images/Progressbar.gif><br />กำลังโหลด...<br /><br /></div>';
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("maincontent").innerHTML = xmlHttp.responseText;
				   addcart(":||:../");
              }
            }
        }
	function mainpage(element) {                    
            createXMLHttpRequest();
            var url = "main.php?data=" + new Date().getTime() + Math.random() + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = callback;
																											// dddddddddddddddddddddddddddd
            xmlHttp.send(null);
        }

	function maindata(element) {                    
            createXMLHttpRequest();
            var url = "main.php?data=" + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = callback;
            xmlHttp.send(null);
        }


	function mangepage(element) {                    
            createXMLHttpRequest();
            var url = "main.php?data="  + new Date().getTime() + Math.random() + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = showmangepage;
            xmlHttp.send(null);
        } 
		
		function showmangepage() {
				  document.getElementById("mangepage").innerHTML='<div id="wait"><br /><img src=images/Progressbar.gif><br />กำลังโหลด...<br /><br /></div>';
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("mangepage").innerHTML = xmlHttp.responseText;
              }
            }
        }

	function showdetail(element) {                    
            createXMLHttpRequest();
            var url = "product_data/showproduct_detail.php?data="  + new Date().getTime() + Math.random() + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = resshowdetail;
            xmlHttp.send(null);
        } 
		
		function resshowdetail() {
			//document.getElementById("showdetail").innerHTML='<div id="wait"><br /><br /><img src=images/Progressbar.gif><br /><br/>กรุณารอสักครู่...</div>';
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("showdetail").innerHTML = xmlHttp.responseText;
              }
            }
        }

	function showproductmain(element) {                    
            createXMLHttpRequest();
            var url = "product_data/showproduct_main.php?data="  + new Date().getTime() + Math.random() + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = resproductmain;
            xmlHttp.send(null);
        } 


	function showproductsearch(element) {                    
            createXMLHttpRequest();
            var url = "product_search/process_keyword.php?data="  + new Date().getTime() + Math.random() + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = resproductmain;
            xmlHttp.send(null);
        } 
		
		function resproductmain() {
			//	  document.getElementById("showproductmain").innerHTML='<div id="wait"><br /><br /><img src=images/Progressbar.gif><br /><br /><br/>กรุณารอสักครู่...</div>';
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("showproductmain").innerHTML = xmlHttp.responseText;
              }
            }
        }

// ค้นหาประเภท
function searchtype(element) {                    
            createXMLHttpRequest();
            var url = "product_search/search_type.php?data="  + new Date().getTime() + Math.random() + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = restmainsearch;
            xmlHttp.send(null);
        } 
// ค้นหาสินค้าใหม่
function newproduct(element) {                    
            createXMLHttpRequest();
            var url = "product_search/search_type.php?data="  + new Date().getTime() + Math.random() + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = restmainsearch;
            xmlHttp.send(null);
        } 	
		
// ค้นหาสินค้าพิเศษ
function speproduct(element) {                    
            createXMLHttpRequest();
            var url = "product_search/search_type.php?data="  + new Date().getTime() + Math.random() + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = restmainsearch;
            xmlHttp.send(null);
        } 	

		// เพิ่มตระกร้าสินค้า
	function addcart(element) {                    
            createXMLHttpRequest();
            var url = "shopping_cart/cart_main.php?data="  + new Date().getTime() + Math.random() + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = showmycart;
            xmlHttp.send(null);
        }

  function showmycart() {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("listmycart").innerHTML = xmlHttp.responseText;
              }
            }
        }

		// จัดการตระกร้าสินค้า
function managecart(element) {                    
            createXMLHttpRequest();
            var url = "main.php?data="  + new Date().getTime() + Math.random() + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = restmainsearch;
            xmlHttp.send(null);
        } 	


		function restmainsearch() {
		    document.getElementById("maincontent").innerHTML='<div id="wait"><br /><img src=images/Progressbar.gif><br />กำลังโหลด...<br /><br /></div>';
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("maincontent").innerHTML = xmlHttp.responseText;
              }
            }
        }

/// ค้นหารหัสสินค้าที่จะเพิ่ม
	function searchcode(element) {                    
            createXMLHttpRequest();
            var url = "product_data/searchcode.php?data="  + new Date().getTime() + Math.random() + ":||:" + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = searchproductcode;
            xmlHttp.send(null);
        }

  function searchproductcode() {
	  	  document.getElementById("searchproductid").innerHTML='<div id="wait1">&nbsp;<img src=images/ms_progcircle.gif></div>';
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("searchproductid").innerHTML = xmlHttp.responseText;
              }
            }
        }



/// ค้นหารหัสสินค้าที่จะเพิ่ม
	function searchshowname(element) {                    
            createXMLHttpRequest();
            var url = "member/searchshowname.php?data="  + new Date().getTime() + Math.random() + ":||:" + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = search_showname;
            xmlHttp.send(null);
        }

  function search_showname() {
	  	  document.getElementById("searchshowname").innerHTML='<div id="wait1">&nbsp;<img src=images/ms_progcircle.gif></div>';
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("searchshowname").innerHTML = xmlHttp.responseText;
              }
            }
        }



/// ค้นหาชื่อเข้าใช้งานระบบ
	function searchlogin(element) {                    
            createXMLHttpRequest();
            var url = "member/searchloginname.php?data="  + new Date().getTime() + Math.random() + ":||:" + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = search_login;
            xmlHttp.send(null);
        }

  function search_login() {
	  	  document.getElementById("searchlogin").innerHTML='<div id="wait1">&nbsp;<img src=images/ms_progcircle.gif></div>';
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("searchlogin").innerHTML = xmlHttp.responseText;
              }
            }
        }

/// ค้นหารหัสผ่าน
	function searchpass(element) {                    
            createXMLHttpRequest();
            var url = "member/searchpass.php?data="  + new Date().getTime() + Math.random() + ":||:" + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = search_pass;
            xmlHttp.send(null);
        }

  function search_pass() {
	  	  document.getElementById("searchpass").innerHTML='<div id="wait1">&nbsp;<img src=images/ms_progcircle.gif></div>';
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("searchpass").innerHTML = xmlHttp.responseText;
              }
            }
        }
		
/// ค้นหาอำเภอ
	function searchamphur(element) {            
            createXMLHttpRequest();
            var url = "other_data/amphur.php?data="  + new Date().getTime() + Math.random() + ":||:" + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = search_amphur;
            xmlHttp.send(null);
        }

  function search_amphur() {
	  	   if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("showamphur").innerHTML = xmlHttp.responseText;
				   searchdistric(1);
              }
            }
        }

/// ค้นหาตำบล
	function searchdistric(element) {                    
            createXMLHttpRequest();
            var url = "other_data/distric.php?data="  + new Date().getTime() + Math.random() + ":||:" + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = search_distric;
            xmlHttp.send(null);
        }

  function search_distric() {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("showdistric").innerHTML = xmlHttp.responseText;
              }
            }
        }


/// ที่อยู่ในการส่งสินค้า ขณะทำการสั่งซื้อ
	function address_to_tran(element) {                    
            createXMLHttpRequest();
            var url = "main.php?data="  + new Date().getTime() + Math.random() + ":||:../:||:shopping_cart:||:address_to_tran:||:" + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = address_show;
            xmlHttp.send(null);
        }

  function address_show() {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("order_address").innerHTML = xmlHttp.responseText;
              }
            }
        }


/// ที่อยู่ในการส่งสินค้า ขณะทำการสั่งซื้อ
	function addpro(element) {                    
            createXMLHttpRequest();
            var url = "admin/addproform.php?data="  + new Date().getTime() + Math.random() + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = addpro_form;
            xmlHttp.send(null);
        }

  function addpro_form() {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("addproform").innerHTML = xmlHttp.responseText;
              }
            }
        }


/// บันทึกเวลาส่งสินค้า
	function addtran(element) {                    
            createXMLHttpRequest();
            var url = "admin/addtransmit.php?data="  + new Date().getTime() + Math.random() + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = add_transmit;
            xmlHttp.send(null);
        }

  function add_transmit() {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("addtransmit").innerHTML = xmlHttp.responseText;
              }
            }
        }

/// แสดงข้อมูลสินค้า
	function mainproduct(element) {                    
            createXMLHttpRequest();
            var url = "product_data/product.php?data="  + new Date().getTime() + Math.random() + element;            
            xmlHttp.open("GET", url, true);
            xmlHttp.onreadystatechange = showlistproduct;
            xmlHttp.send(null);
        }

  function showlistproduct() {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                   document.getElementById("showlistproduct").innerHTML = xmlHttp.responseText;
              }
            }
        }