﻿/* ajax_hotnews */

var xmlHttp2;
var var_id;

function createXMLHttpRequest2(){
	if(window.ActiveXObject){
		xmlHttp2  = new ActiveXObject("Microsoft.XMLHTTP");
	}else if(window.XMLHttpRequest){
		xmlHttp2  = new XMLHttpRequest();
	}
}

function loadHotNews(id) {
	createXMLHttpRequest2();
	document.getElementById('ajax_hotnews').innerHTML="กำลังโหลดข้อมูล กรุณารอซักครู่...";
	var_id = id;
	xmlHttp2.open("get","ajax_hotnews.php?id="+id,true);
	xmlHttp2.onreadystatechange = loadHotNewsChangeHandle;
	xmlHttp2.send(null);
}

function loadHotNewsChangeHandle() {
     if (xmlHttp2.readyState == 4) {
          if (xmlHttp2.status == 200) {
			  if(var_id >=1) {
				  //document.getElementById('ajax_hotnews_more').innerHTML="<a href=\"hotnews/?cate="+var_id+"\" target=\"_blank\">อ่านข่าวในหมวดนี้เพิ่มเติม &raquo;</a>";
			  }
			  document.getElementById('ajax_hotnews').innerHTML=""+xmlHttp2.responseText; 
			  //setTimeout("loadHotNewsNext()", 5000);
          }
     }
}

function loadHotNewsNext() {
	if(var_id <= 4 ) {
		var_id = var_id+1;
	}
	else {
		var_id = 1;
	}
	loadHotNews(var_id);
}
