
var xmlHttp;

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

function show_review(){
	createXMLHttpRequest();
	xmlHttp.open("get","ajax/review.php",true);
	xmlHttp.onreadystatechange = function(){
	
		if(xmlHttp.readyState == 1)
		  {
			 document.getElementById("review_news").innerHTML="<span class=\"style10\"><img src='images/loading.gif'>........กำลังโหลดเนื้อหาอยู่&nbsp;</span>";
		  }

		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
			document.getElementById("review_news").innerHTML=xmlHttp.responseText;
			//show_review2()
			}
		}
	}
	 xmlHttp.send(null); 
}


function show_mainreview(){
	createXMLHttpRequest();
	xmlHttp.open("get","../ajax/main_control.php",true);
	xmlHttp.onreadystatechange = function(){
	
		if(xmlHttp.readyState == 1)
		  {
			 document.getElementById("showdetail").innerHTML="<span class=\"style10\"><img src='images/loading.gif'>........กำลังโหลดเนื่อหาอยู่ </span>";
		  }

		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				
			 document.getElementById("showdetail").innerHTML=xmlHttp.responseText;
			}
			else
			{
				alert(xmlHttp.responseText);
			}
		}
	}
	 xmlHttp.send(null); 
}

function show_review2(){
	createXMLHttpRequest();
	xmlHttp.open("get","ajax/review2.php",true);
	xmlHttp.onreadystatechange = function(){
	
		if(xmlHttp.readyState == 1)
		  {
			 document.getElementById("review_news2").innerHTML="<span class=\"style10\"><img src='images/loading.gif'>........กำลังโหลดเนื่อหาอยู่ </span>";
		  }

		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				
			 document.getElementById("review_news2").innerHTML=xmlHttp.responseText;
			}
			else
			{
				alert(xmlHttp.responseText);
			}
		}
	}
	 xmlHttp.send(null); 
}


function delete_view(id){
	createXMLHttpRequest();
	xmlHttp.open("get","../ajax/delete_view.php?id="+id,true);
	xmlHttp.onreadystatechange = function(){
	
		if(xmlHttp.readyState == 1)
		  {
			 document.getElementById("showdetail").innerHTML="<span class=\"style10\"><br><br><img src='../images/loading.gif'>...กำลังโหลดเนื่อหาอยู่<br><br><br><br></span>";
		  }

		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				
			 alert(xmlHttp.responseText);
			 setTimeout("show_mainreview()", 5000);
			}
			else
			{
				alert(xmlHttp.responseText);
			}
		}
	}
	 xmlHttp.send(null); 
}

function edit_view(){
	createXMLHttpRequest();
	xmlHttp.open("get","../ajax/text.php",true);
	xmlHttp.onreadystatechange = function(){
	
		if(xmlHttp.readyState == 1)
		  {
			 document.getElementById("showdetail").innerHTML="<span class=\"style10\"><br><br><img src='../images/loading.gif'>...กำลังโหลดเนื่อหาอยู่<br><br><br><br></span>";
		  }

		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				
			 document.getElementById("showdetail").innerHTML=xmlHttp.responseText;
			}
			else
			{
				alert(xmlHttp.responseText);
			}
		}
	}
	 xmlHttp.send(null); 
}


function show_key_product(uid,pid,did){
	createXMLHttpRequest();
	xmlHttp.open("get","ajax/show_key.php?uid="+uid+"&pid"+pid,true);
	xmlHttp.onreadystatechange = function(){
	
		if(xmlHttp.readyState == 1)
		  {
			 document.getElementById("sup"+did).innerHTML="<span class=\"style10\"><img src='images/loading.gif'>........กำลังโหลดเนื่อหาอยู่</span>";
		  }

		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
			document.getElementById("sup"+did).innerHTML=xmlHttp.responseText;
			}
		}
	}
	 xmlHttp.send(null); 
}


////////////////////  Dedicated /////////////////////////
function show_mainmenu(){
	createXMLHttpRequest();
	xmlHttp.open("get","ajax/show_detail.php",true);
	xmlHttp.onreadystatechange = function(){
	
		if(xmlHttp.readyState == 1)
		  {
			 document.getElementById("showdetail").innerHTML="<br><br><img src='images/loading.gif'>...กำลังโหลดเนื่อหาอยู่";
		  }

		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				 document.getElementById("showdetail").innerHTML=xmlHttp.responseText;
			 //alert(xmlHttp.responseText);
			}
			else
			{
				alert(xmlHttp.responseText);
			}
		}
	}
	 xmlHttp.send(null); 
}

function clickchange(id){
	createXMLHttpRequest();
	xmlHttp.open("get","ajax/show_detail.php?id="+id,true);
	xmlHttp.onreadystatechange = function(){
	
		if(xmlHttp.readyState == 1)
		  {
			 document.getElementById("showdetail").innerHTML="<br><br><img src='images/loading.gif'>...กำลังโหลดเนื่อหาอยู่";
		  }

		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				 document.getElementById("showdetail").innerHTML=xmlHttp.responseText;
			// alert(xmlHttp.responseText);
			}
			else
			{
				alert(xmlHttp.responseText);
			}
		}
	}
	 xmlHttp.send(null); 
}


function clickchange2(mainID,subID){
	createXMLHttpRequest();
	xmlHttp.open("get","ajax/show_detail_2.php?mainid="+mainID+"&subid="+subID,true);
	xmlHttp.onreadystatechange = function(){
	
		if(xmlHttp.readyState == 1)
		  {
			 document.getElementById("showdetail").innerHTML="<br><br><img src='images/loading.gif'>...กำลังโหลดเนื่อหาอยู่";
		  }

		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				 document.getElementById("showdetail").innerHTML=xmlHttp.responseText;
			// alert(xmlHttp.responseText);
			}
			else
			{
				alert(xmlHttp.responseText);
			}
		}
	}
	 xmlHttp.send(null); 
}


//////////////////////////////////////////////////////////




function clickmoney(){
	createXMLHttpRequest();
	sid = document.getElementById("sid");
	check_array = document.getElementById("check_array[]");
	xmlHttp.open("get","ajax/show_money.php?id="+check_array+"&sid="+sid,true);
	xmlHttp.onreadystatechange = function(){
	
		if(xmlHttp.readyState == 1)
		  {
			 document.getElementById("money_detail").innerHTML="<img src='images/loading.gif'>...กำลังโหลดเนื่อหาอยู่";
		  }

		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				 document.getElementById("money_detail").innerHTML=xmlHttp.responseText;
			// alert(xmlHttp.responseText);
			}
			else
			{
				alert(xmlHttp.responseText);
			}
		}
	}
	 xmlHttp.send(null); 
}

function clickreport(sid,mid){
	createXMLHttpRequest();
	check_array = document.getElementById("check_array");
	alert("ajax/show_report.php?check_array="+check_array+"&sid="+sid+"&mid="+mid);
	xmlHttp.open("get","ajax/show_report.php?check_array="+check_array+"&sid="+sid+"&mid="+mid,true);
	xmlHttp.onreadystatechange = function(){
	
		if(xmlHttp.readyState == 1)
		  {
			 document.getElementById("showdetail").innerHTML="<img src='images/loading.gif'>...กำลังโหลดเนื่อหาอยู่";
		  }

		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				 document.getElementById("showdetail").innerHTML=xmlHttp.responseText;
			// alert(xmlHttp.responseText);
			}
			else
			{
				alert(xmlHttp.responseText);
			}
		}
	}
	 xmlHttp.send(null); 
}


///////////////////// Plus and minus ////////////////////////////
function klappe(id)
{
	var klappText = document.getElementById('k' + id);
	var klappBild = document.getElementById('pic' + id);

	if (klappText.style.display == 'none') {
	   klappText.style.display = 'block';
	   klappBild.src = 'images/minus.gif';
	}
	else {
	   klappText.style.display = 'none';
	   klappBild.src = 'images/plus.gif';
	}
}

function klappe2(id)
{
	var klappText = document.getElementById('kt' + id);
	var klappBild = document.getElementById('pict' + id);

	if (klappText.style.display == 'none') {
	   klappText.style.display = 'block';
	   klappBild.src = 'images/minus.gif';
	}
	else {
	   klappText.style.display = 'none';
	   klappBild.src = 'images/plus.gif';
	}
}

////////////////////////////////////////////////////////////////////




////////////////////  Rack /////////////////////////
function show_mainmenu_rack(){
	createXMLHttpRequest();
	xmlHttp.open("get","ajax/show_rack.php",true);
	xmlHttp.onreadystatechange = function(){
	
		if(xmlHttp.readyState == 1)
		  {
			 document.getElementById("showdetail").innerHTML="<br><br><img src='images/loading.gif'>...กำลังโหลดเนื่อหาอยู่";
		  }

		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				 document.getElementById("showdetail").innerHTML=xmlHttp.responseText;
			 //alert(xmlHttp.responseText);
			}
			else
			{
				alert(xmlHttp.responseText);
			}
		}
	}
	 xmlHttp.send(null); 
}

function clickchange_rack(id){
	createXMLHttpRequest();
	xmlHttp.open("get","ajax/show_rack.php?id="+id,true);
	xmlHttp.onreadystatechange = function(){
	
		if(xmlHttp.readyState == 1)
		  {
			 document.getElementById("showdetail").innerHTML="<br><br><img src='images/loading.gif'>...กำลังโหลดเนื่อหาอยู่";
		  }

		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				 document.getElementById("showdetail").innerHTML=xmlHttp.responseText;
			// alert(xmlHttp.responseText);
			}
			else
			{
				alert(xmlHttp.responseText);
			}
		}
	}
	 xmlHttp.send(null); 
}


function clickchange2_rack(mainID,subID){
	createXMLHttpRequest();
	xmlHttp.open("get","ajax/show_rack_2.php?mainid="+mainID+"&subid="+subID,true);
	xmlHttp.onreadystatechange = function(){
	
		if(xmlHttp.readyState == 1)
		  {
			 document.getElementById("showdetail").innerHTML="<br><br><img src='images/loading.gif'>...กำลังโหลดเนื่อหาอยู่";
		  }

		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				 document.getElementById("showdetail").innerHTML=xmlHttp.responseText;
			// alert(xmlHttp.responseText);
			}
			else
			{
				alert(xmlHttp.responseText);
			}
		}
	}
	 xmlHttp.send(null); 
}


//////////////////////////////////////////////////////////