function ajaxSend(ajaxMethod, ajaxUrl, ajaxDiv, ajaxOutput)
{ 
	function ajaxObject()
	{ 
		if (document.all && !window.opera)
		{ 
			obj = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else
		{ 
			obj = new XMLHttpRequest();
		}
	return obj;
	}
	var ajaxHttp = ajaxObject(); 
	ajaxHttp.open(ajaxMethod, ajaxUrl); 
	ajaxHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

	ajaxHttp.onreadystatechange = function()
	{ 
		if(ajaxHttp.readyState == 1){
				document.getElementById(ajaxDiv).innerHTML = 'Loading...';
		}
		if(ajaxHttp.readyState == 4)
		{ 
			var ajaxResponse = ajaxHttp.responseText;

			if (ajaxOutput == "innerHTML")
			{ 
				if(ajaxResponse == "logined"){
						window.location = "quinL_member_management.php";
				}else if(ajaxResponse == "adminlogined"){
						window.location = "backend_management.php";
				}else if(ajaxResponse == "registered"){
						ajaxSend('POST', 'congratulations.php', 'regisDiv', 'innerHTML'); //----------------------
				}else if(ajaxResponse == "passwordchanged"){
							document.getElementById("centerDIV").innerHTML="แก้ไขรหัสผ่านสำเร็จ !";
				}else if(ajaxResponse == "registerupdated"){
							document.getElementById("centerDIV").innerHTML="แก้ไขข้อมูลส่วนตัวสำเร็จ !";
				}else if(ajaxResponse == "refresh"){
						window.location = "?";
				}else if(ajaxResponse == "addprovinced"){
						ajaxSend('POST', 'provincemanager.php', 'centerDIV', 'innerHTML');
				}else if(ajaxResponse == "addcatgoriesd"){
						ajaxSend('POST', 'catgoriesmanager.php', 'centerDIV', 'innerHTML');
				}else if(ajaxResponse == "addmembered"){
						ajaxSend('POST', 'membermanager.php', 'centerDIV', 'innerHTML');
				}else if(ajaxResponse == "addnewsed"){
						ajaxSend('POST', 'news.php?shownews=new', 'regisDIV', 'innerHTML');
				}else if(ajaxResponse == "deleted"){
						ajaxSend('POST', 'del.php', 'regisDIV', 'innerHTML');
				}else if(ajaxResponse == "newsdeleted"){
						ajaxSend('POST', 'delnews.php', 'regisDIV', 'innerHTML');
				}else if(ajaxResponse == "UpdatedMenu"){
						ajaxSend('POST', 'menu_edit.php', 'regisDIV', 'innerHTML');
				}
				else{
						document.getElementById(ajaxDiv).innerHTML = ajaxResponse;
				}
			}
			else if (ajaxOutput == "value"){ 
				document.getElementById(ajaxDiv).value = ajaxResponse;
			}
		}
	}
	ajaxHttp.send(null);
}

function ajaxSendUrl(ajaxMethod, ajaxUrl)
{ 
	function ajaxObject()
	{ 
		if (document.all && !window.opera)
		{ 
			obj = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else
		{ 
			obj = new XMLHttpRequest();
		}
	return obj;
	}
	var ajaxHttp = ajaxObject(); 
	ajaxHttp.open(ajaxMethod, ajaxUrl); 
	ajaxHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

	ajaxHttp.onreadystatechange = function()
	{ 
		if(ajaxHttp.readyState == 1){
				
		}
		if(ajaxHttp.readyState == 4)
		{ 
			var ajaxResponse = ajaxHttp.responseText;
		}
	}
	ajaxHttp.send(null);
}
