function select_browser(){
	/*if (window.XMLHttpRequest)
		reqnew=new XMLHttpRequest();
	else if (window.ActiveXObject)
		reqnew=new ActiveXObject("Microsoft.XMLHTTP");
	else{
		alert("Browser not support");
		return false;
	}*/
	reqnew=new ActiveXObject("Microsoft.XMLHTTP");
	return reqnew;
}
function  true_regis(){
	if(document.member_form.email.value==""){
		alert("กรุณากรอก E-mail ให้ถูกต้อง");
		return false;
	}
	if(document.member_form.name.value==""){
		alert("กรุณากรอก ชื่อ-สกุลให้ถูกต้อง");
		return false;
	}
		if(document.member_form.password1.value==""){
		alert("กรุณากรอก Passwordให้ถูกต้อง");
		return false;
	}
}
function chpass(){
	if(document.member_form.password1.value!=document.member_form.password2.value)
	{document.getElementById('pfalse').style.display ='';
		document.getElementById('ptrue').style.display ='none';
	}else{
		document.getElementById('pfalse').style.display ='none';
		document.getElementById('ptrue').style.display ='';
	}
}
function chemail(){
	a=document.member_form.email.value
	 if (a.indexOf('@')==-1)
	 {
		alert ('E-mail ไม่ถูกต้องครับ');
		document.member_form.email.focus();
	 }
	 else
	{
		 document.getElementById('etrue').style.display ='';
	 }
}
function loginnew(){
	 document.getElementById('old').style.display ='none';
	 document.getElementById('username').style.display ='';
}
function imagech(){
	 document.getElementById('image1').style.display ='none';
	 document.getElementById('image').style.display ='';
	document.getElementById('member').style.display ='';
}
function namech(){
	 document.getElementById('full_name').style.display ='none';
	 document.getElementById('fo_name').style.display ='';
	document.getElementById('member').style.display ='';
}
function swxch(){
	 document.getElementById('icon_sex').style.display ='none';
	 document.getElementById('sex').style.display ='';
	document.getElementById('member').style.display ='';
}
function psch(){
	window.open('chps.php','win1','width=300,height=250');
}
function coin(){
	window.open('coin.php','win1','width=250,height=200');
}
function mailch(){
	document.getElementById('chmail').style.display ='none';
	 document.getElementById('fomail').style.display ='';
	document.getElementById('member').style.display ='';
}
function chwrite(){
	if (document.form_write.subject.value=="")
	{
		alert('กรุณาป้อน ชื่อเรื่องด้วยครับ!');
		document.form_write.subject.focus();
		return false;
	}
}
function reply(a){
	document.getElementById('reply').style.display ='';
	document.replyans.reply.value=a;
}
function pagei(a){
	document.getElementById(a).style.background ='#9999FF';
}
function pageo(a){
	document.getElementById(a).style.background ='none';
}
function bgforum(a){
		document.getElementById(a).style.background ='#D7E9FF';
}
function bgforumo(a){
		document.getElementById(a).style.background ='white';
}
function searchselect(){
	document.search.keyword.value="";
}
function chmember()
{
	select_browser();
	reqnew.onreadystatechange = statechange;
	
	na=document.member_form.username.value;
	ch="chmember.php?member="+na;
	reqnew.open("GET",ch,true);
	reqnew.send(null);
}
function statechange()
{
	if (reqnew.readyState==4) {
		if (reqnew.responseText==0)
		{
			document.getElementById("memberch").innerHTML="<font color='green' size='1'>Username นี้สามารถใช้ได้</font>";
		}else{
		document.getElementById("memberch").innerHTML="<font color='red' size='1'>Username นี้มีผู้ใช้แล้ว</font>";
		/*alert("Username นี้มีผู้ใช้แล้ว กรุณาใช้ชื่ออื่นนะครับ!");
		document.member_form.username.focus();*/
		}

	}
	else{
		var x=document.getElementById("memberch");
		x.innerHTML="<img src='images/wait.gif'> Please wait...";
	}
}
function captchar1()
{
select_browser();
	reqnew.onreadystatechange = statechange1;
	ran=Math.random();
	reqnew.open("GET","lookcaptchar.php?one="+ran,true);
	reqnew.Send(null);
}
function statechange1()
{
	if (reqnew.readyState==4) {
			document.getElementById("captchar1").innerHTML=reqnew.responseText;
		   document.getElementById("waitre1").innerHTML="<img src='images/refresh.gif' alt='เปลี่ยนภาพใหม่' onclick='captchar1()'>";
}
	else{
		var x=document.getElementById("waitre1");
		x.innerHTML="<img src='images/waitre.gif'>";
	}
}
function checkeng() {
     var obj=member_form.username;
     var str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-" 
     var val=obj.value
     var valOK = true;
    
     for (i=0; i<val.length & valOK; i++){
          valOK = (str.indexOf(val.charAt(i))!= -1) 
     }
    
     if (!valOK) {
          alert("ใช้ภาษาอังกฤษเท่านั้นนะครับ !")
          obj.focus()
          return false
     } chmember();
}
function click_chat(){
	send_text.value="";
}
function send_chat(){
	if(send_text.value=="ใส่ข้อความทักทายเพื่อนๆ กันเลย"){
		alert("กรุณาป้อนข้อความด้วยครับ !");
	}else{
		select_browser();
	reqnew.onreadystatechange = statechange1;
	ran=Math.random();
	if(send_text.value==""){
		alert("กรุณาป้อนข้อความด้วยครับ !");
		link="chat_today.php?one="+ran;
	}else{
		link="chat_today.php?newchat="+send_text.value+"&one="+ran;
	}
	
	reqnew.open("GET",link,true);
	reqnew.Send(null);
function statechange1()
{
	if (reqnew.readyState==4) {
			document.getElementById("text_chat").innerHTML=reqnew.responseText;
			send_text.value="ใส่ข้อความทักทายเพื่อนๆ กันเลย";
			alert("ข้อความของคุณ ถูกส่งเรียบร้อยครับ");
}
	else{
		var x=document.getElementById("text_chat");
		x.innerHTML="<img src='images/waitre.gif'> โปรดรอกำลังส่งข้อความ";
	}
}
	}
}
function cl_idcard()
{
	document.true_money.id_card.value="";
}
function gotopage(id_forum){
	window.location="forum&select-"+id_forum+"&page"+page_select.value+".html";
}
function gotopage_topic(id_forum,id){
	window.location="forum&select-"+id_forum+"&view"+id+"&pageview"+page_select.value+".html";
}
function send_money(){
	
		select_browser();
	reqnew.onreadystatechange = statechange1;
	ran=Math.random();
		link="ad_money.php?one="+ran+"&id_true="+id_card.value;
	reqnew.open("GET",link,true);
	reqnew.Send(null);
function statechange1()
{
	if (reqnew.readyState==4) {
		if(reqnew.responseText==0){
			alert("ขอบคุณที่สนับสนุนเว็บครับ จะตรวจสอบความถูกต้อง และจะมอบเหรียญตอบแทนให้ไวที่สุดครับ.");
		}else{
			alert("กรุณา Login เข้าสู่ระบบ ก่อนครับ !");
		}
}
}
}
if(top.location!=location){
	//alert("หน้านี้ถูกแสดงในกรอบที่ไม่ได้รับอนุญาติ  เราจะพาคุณไปหน้าปกติครับ");
	//top.location.href=location;
}
// นับถอยหลังปีใหม่
TargetDate = "2/14/2010 00:00 AM";
BackColor = "#5F4B96";
ForeColor = "white";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "เหลือเวลาอีก %%D%% วัน, %%H%% ชั่วโมง, %%M%% นาที, %%S%% วินาที  ก็จะถึงวันแห่งความรักแล้ว";
FinishMessage = "Thaighost.Net  :  Happy Valentine's Day ขอให้คนไทยรักกันมากๆ นะครับ";


function calcage(secs, num1, num2) {
  s = ((Math.floor(secs/num1))%num2).toString();
  if (LeadingZero && s.length < 2)
    s = "0" + s;
  return "<b>" + s + "</b>";
}

function CountBack(secs) {
  if (secs < 0) {
    document.getElementById("cntdwn").innerHTML = FinishMessage;
    return;
  }
  DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
  DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
  DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
  DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));

  document.getElementById("cntdwn").innerHTML = DisplayStr;
  if (CountActive)
    setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}

function putspan(backcolor, forecolor) {
 //document.write("<span id='cntdwn' style='background-color:" + backcolor + "; color:" + forecolor + "'></span>");
}

if (typeof(BackColor)=="undefined")
  BackColor = "white";
if (typeof(ForeColor)=="undefined")
  ForeColor= "black";
if (typeof(TargetDate)=="undefined")
  TargetDate = "12/31/2020 5:00 AM";
if (typeof(DisplayFormat)=="undefined")
  DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CountActive)=="undefined")
  CountActive = true;
if (typeof(FinishMessage)=="undefined")
  FinishMessage = "";
if (typeof(CountStepper)!="number")
  CountStepper = -1;
if (typeof(LeadingZero)=="undefined")
  LeadingZero = true;


CountStepper = Math.ceil(CountStepper);
if (CountStepper == 0)
  CountActive = false;
var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
putspan(BackColor, ForeColor);
var dthen = new Date(TargetDate);
var dnow = new Date();
if(CountStepper>0)
  ddiff = new Date(dnow-dthen);
else
  ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
//CountBack(gsecs);
