//Grab Index

function  loadGrabSub(menu,id,pages)
{ 
	  $(document).ready(function(){
		$("#GrabIndex").load("../ajax/grab.php"+"?page=GrabIndex&mode="+menu+"&ID="+id+"&pages="+pages);
	  });
}
function  loadGrabSub2(menu,id,pages)
{ 
	  $(document).ready(function(){
		$("#GrabIndex").load("ajax/grab3.php"+"?page=GrabIndex&mode="+menu+"&ID="+id+"&pages="+pages);
	  });
}

function  loadGrabSub3(menu,id,pages)
{ 
	  $(document).ready(function(){
		$("#GrabIndex").load("../ajax/grab3.php"+"?page=GrabIndex&mode="+menu+"&ID="+id+"&pages="+pages);
	  });
}

function  loadGrabIndex(menu,id,pages)
{ 
	  $(document).ready(function(){
		$("#GrabIndex").load("ajax/grab.php"+"?page=GrabIndex&mode="+menu+"&ID="+id+"&pages="+pages);
	  });
}

function  loadGrabIndex2(menu,id,pages)
{ 
	  $(document).ready(function(){
		$("#GrabIndex2").load("ajax/grab3.php"+"?page=GrabIndex&mode="+menu+"&ID="+id+"&pages="+pages);
	  });
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


function  saveGrabIndex(menu,objRadio,pages)
{ 
	var strID = getCheckedValue(objRadio);

	//alert(strID);
	  $(document).ready(function(){
		$("#GrabIndex").load("ajax/grab.php"+"?page=GrabIndex&mode="+menu+"&ID="+strID+"&pages="+pages);
	  });
}


//New List Index
function  loadNewsIndex(menu,id,pages)
{ 
	  $(document).ready(function(){
		$("#"+menu).load("ajax/index.php"+"?page=NewsIndex&mode="+menu+"&ID="+id+"&pages="+pages);
	  });
}

//New List Index2
function  loadNewsIndex2(menu,id,pages)
{ 
	  $(document).ready(function(){
		$("#"+menu).load("ajax/index2.php"+"?page=NewsIndex&mode="+menu+"&ID="+id+"&pages="+pages);
	  });
}

function  saveNewsIndex(menu,objCheckBoxes,pages)
{ 
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	var strID = "";

	// set the check value for all check boxes
	for(var i = 0; i < countCheckBoxes; i++) {
		if (objCheckBoxes[i].checked)
		{
			strID = strID+objCheckBoxes[i].value+",";
		}
	}
	//alert(strID);
	  $(document).ready(function(){
		$("#NewsIndex").load("ajax/index.php"+"?page=NewsIndexSave&mode="+menu+"&ID="+strID+"&pages="+pages);
	  });
}


function  loadNewsPerpage(menu,id,pages)
{ 
	//Check Max Min
	if (pages<1)
	{
		alert('ไม่สามารถลดจำนวนข่าวได้');
		return;
	} else if (pages>=20)
	{
		alert('ไม่สามารถเพิ่มจำนวนข่าวได้');
		return;
	}
	  $(document).ready(function(){
		$("#"+menu).load("ajax/index2.php"+"?page=NewsPerpage&mode="+menu+"&ID="+id+"&pages="+pages);
	  });
}


function  loadNewsPerpage2(menu,id,pages)
{ 
	//Check Max Min
	if (pages<1)
	{
		alert('ไม่สามารถลดจำนวนข่าวได้');
		return;
	} else if (pages>=20)
	{
		alert('ไม่สามารถเพิ่มจำนวนข่าวได้');
		return;
	}
	  $(document).ready(function(){
		$("#"+menu).load("ajax/index2.php"+"?page=NewsPerpage2&mode="+menu+"&ID="+id+"&pages="+pages);
	  });
}

//First Page
function  loadFirstpage(menu,id,pages)
{ 
	  $(document).ready(function(){
		$("#"+menu).load("ajax/firstpage.php"+"?page=firstpage&mode="+menu+"&ID="+id+"&pages="+pages);
	  });
}

//Ureport Index
function  loadUreportIndex(cid,menu,id,pages)
{ 
	  $(document).ready(function(){
		$("#UreportIndex").load("../ajax/ureport.php"+"?program=Ureport&cat_id="+cid+"&mode="+menu+"&sortkey="+id+"&pages="+pages);
	  });
}

function  loadUreport2layer(cid,menu,id,pages)
{ 
	  $(document).ready(function(){
		$("#UreportIndex").load("../ajax/ureport2layer.php"+"?program=Ureport&cat_id="+cid+"&mode="+menu+"&sortkey="+id+"&pages="+pages);
	  });
}

function  loadUreportHot(menu,id,pages)
{ 
	  $(document).ready(function(){
		$("#"+menu).load("../ajax/ureport_hot.php"+"?program=hotureport&mode="+menu+"&sortkey="+id+"&pages="+pages);
	  });
}

function  ureportComment(cid,menu,id,pages)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	
	var url="../ajax/ureport.php";
	url=url+"?program=Comment&cat_id="+cid+"&mode="+menu+"&ID="+id+"&pages="+pages;
	xmlHttp.onreadystatechange=returnComment ;
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send(null);
}

/*function  ureportComment(menu,id,pages)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	
	var url="../ajax/ureport.php";
	url=url+"?program=Comment&mode="+menu+"&ID="+id+"&pages="+pages;
	xmlHttp.onreadystatechange=returnComment ;
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send(null);
} */


//First Page2
function  loadFirstpage2(menu,id,pages)
{ 
	  $(document).ready(function(){
		$("#"+menu).load("ajax/firstpage2.php"+"?page=firstpage&mode="+menu+"&ID="+id+"&pages="+pages);
	  });
}

//loadSpecial
function  loadSpecial(menu,id,pages)
{ 
	  $(document).ready(function(){
		$("#"+menu).load("ajax/firstpage_spc_news.php"+"?page=firstpage&mode="+menu+"&ID="+id+"&pages="+pages);
	  });
}


//Video List Index
function  loadVideoNews(menu,id,pages)
{ 
	  $(document).ready(function(){
		  //alert("../ajax/video.php"+"?program=VideoNews&mode="+menu+"&sortkey="+id+"&pages="+pages);
		$("#VideoIndex").load("../ajax/video.php"+"?program=News&mode="+menu+"&sortkey="+id+"&pages="+pages);
	  });
}

function  loadVideoScoop(menu,id,pages)
{ 
	  $(document).ready(function(){
		  //alert("../ajax/video.php"+"?program=VideoNews&mode="+menu+"&sortkey="+id+"&pages="+pages);
		$("#ScoopIndex").load("../ajax/video.php"+"?program=Scoop&mode="+menu+"&sortkey="+id+"&pages="+pages);
	  });
}

//Comment
function  newsComment(menu,id,pages)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	
	var url="../ajax/ajax.php";
	url=url+"?page=newsComment&mode="+menu+"&id="+id+"&pages="+pages;
	//alert (url)
	xmlHttp.onreadystatechange=returnComment ;
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	//xmlHttp.send("value="+id);
	xmlHttp.send(null);
}

function  communityComment(menu,id,pages)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	
	var url="../ajax/community.php";
	url=url+"?page=communityComment&mode="+menu+"&ID="+id+"&pages="+pages;
	//alert (url)
	xmlHttp.onreadystatechange=returnComment ;
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	//xmlHttp.send("value="+id);
	xmlHttp.send(null);
}

function returnComment() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		document.getElementById("blogComment").innerHTML=xmlHttp.responseText;
 	 } 
}


function GetXmlHttpObject()
{
		var xmlHttp=null;
		try
		 {
				 // Firefox, Opera 8.0+, Safari
				 xmlHttp=new XMLHttpRequest();
		 }
		catch (e)
		 {
		 //Internet Explorer
		 try
			  {
				  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			  }
		 catch (e)
			  {
			  		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
		 }
		return xmlHttp;
}