var xmlHttp;
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}
  
 function handleStateChange() {
    if(xmlHttp.readyState == 4) {
           document.getElementById("playTV").innerHTML = xmlHttp.responseText;
    }else{
			document.getElementById("playTV").innerHTML =".. ใจเย็นๆ นะครับ..กำลังโหลดข้อมูลมาให้..โปรดรอสักครู่";
		}

}
function requestTV(ch) {
    createXMLHttpRequest();
	xmlHttp.onreadystatechange = handleStateChange;
	var query;
	query="?";
	query+="ch="+ch;
	query+="&";
	query+="r="+Math.random();
	xmlHttp.open("GET", "tv/show.php"+query, true);
    xmlHttp.send(null);

}

function clearTV() {
  createXMLHttpRequest();
    if(xmlHttp.readyState == 4) {

           document.getElementById("playTV").innerHTML = xmlHttp.responseText;
    }else{
			document.getElementById("playTV").innerHTML ="สามารถดูทีวีออนไลน์ ได้โดยคลิกช่องที่ท่านต้องการดู";
		}

}

function tvplayback() {
    createXMLHttpRequest();
				xmlHttp.onreadystatechange = handleStateChange;

			var url = 'tv/tvplayback.php';
	        var pmeters = "CH=" + encodeURI( document.getElementById("CH").value) +
						"&DD=" + encodeURI( document.getElementById("DD").value ) +
						"&MM=" + encodeURI( document.getElementById("MM").value ) +
						"&YY=" + encodeURI( document.getElementById("YY").value ) +
						"&TT=" + encodeURI( document.getElementById("TT").value );

			xmlHttp.open('POST',url,true);
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xmlHttp.setRequestHeader("Content-length", pmeters.length);
			xmlHttp.setRequestHeader("Connection", "close");
			xmlHttp.send(pmeters);
}




 function StateSong() {
    if(xmlHttp.readyState == 4) {
           document.getElementById("playMusic").innerHTML = xmlHttp.responseText;
    }else{
			document.getElementById("playMusic").innerHTML =".. ใจเย็นๆ นะครับ..กำลังโหลดเพลงมาให้..โปรดรอสักครู่";
		}

}
function requestSong(mid) {
    createXMLHttpRequest();
	xmlHttp.onreadystatechange = StateSong;
	var query;
	query="?";
	query+="mid="+mid;
	query+="&";
	query+="r="+Math.random();
	xmlHttp.open("GET", "music/play.php"+query, true);
    xmlHttp.send(null);

}

function clearSong() {
  createXMLHttpRequest();
    if(xmlHttp.readyState == 4) {

           document.getElementById("playMusic").innerHTML = xmlHttp.responseText;
    }else{
			document.getElementById("playMusic").innerHTML ="<a href=\"http://www.phranorn.com\" target=\"_blank\"><img src=\"images/ads468x60/watphranorn.gif\" border=\"0\"></a>";
		}

}




function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
<!--
       function inputjob(form1) {

				 if(form1.keyword.value == "") {
				        alert("ระบุคำค้นของตำแหน่งงานที่คุณต้องการด้วย เช่น คอมพิวเตอร์ , ธุรการ ฯลฯ");
						form1.keyword.focus();
						return false;			
				}else{
				      return true;
				}
		}


function requestShortNews() {
    createXMLHttpRequest();
	xmlHttp.onreadystatechange =  function() {
    if(xmlHttp.readyState == 4) {
           document.getElementById("shortNews").innerHTML = xmlHttp.responseText;
    }else{
			document.getElementById("shortNews").innerHTML =".. โปรดรอสักครู่ ..จะแสดงข่าวต่อไป";
		}

}
	setTimeout("requestShortNews();",45000) // 1 Second = 1000
	var query;
	query="?";
	query+="r="+Math.random();
	xmlHttp.open("GET", "shortNews.php"+query, true);
    xmlHttp.send(null);

}

// นับถอยหลัง
var timeCountdown = 45;
function repeat(){

	setTimeout("repeat()",1000);

	if (timeCountdown>0) {
		timeCountdown = timeCountdown -1;
		 document.getElementById('showCountdown').innerHTML=timeCountdown;

	}
	
	if (timeCountdown==0) {

		document.getElementById('showCountdown').innerHTML=timeCountdown;		
		timeCountdown=45;
		
	}
}
