﻿var path = "www.thaipbs.or.th";
//var path = "";
var folderPath = "/blog/";
//var path = "localhost";
//var folderPath = "/blogweb/";
var xmlHttp;var xmlHttp1;var xmlHttppic;

function temp()
{
    var d = new Date();
    return d.getTime();
}
var gallery_id;
xmlHttp=GetXmlHttpObject();
xmlHttp1=GetXmlHttpObject();
xmlHttppic=GetXmlHttpObject();
var focusObNamej;var focusObNamej1;var focusObNamejpic;
function printWindow(){
   var bV = parseInt(navigator.appVersion);
   if (bV >= 4) window.print();
}
function stateChanged() { 
    //alert("divObjName : "+divObjName);
	if (xmlHttp.readyState==4){ 
		document.getElementById(focusObNamej).innerHTML=xmlHttp.responseText;
		var innerHtmlData="";
	}
} 
function showX(url,divObjName) {
    focusObNamej=divObjName;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
    //url="http://"+path+folderPath+"ajaxpart/CatGroupDetail1stPage.aspx?catGRoupId=1";
	//alert("retUrl:" +url);
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url+'&'+temp(),true);
	xmlHttp.send(null);
}


function stateChanged1() { 
    //alert("divObjName : "+divObjName);
	if (xmlHttp1.readyState==4){ 
		document.getElementById(focusObNamej1).innerHTML=xmlHttp1.responseText;
		var innerHtmlData="";
	}
} 

function showX1(url1,divObjName1) {
    focusObNamej1=divObjName1;
	xmlHttp1=GetXmlHttpObject();
	if (xmlHttp1==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
    //url="http://"+path+folderPath+"ajaxpart/CatGroupDetail1stPage.aspx?catGRoupId=1";
	//alert("retUrl:" +url);
	//alert(url);
	xmlHttp1.onreadystatechange=stateChanged1;
	xmlHttp1.open("GET",url1+'&'+temp(),true);
	//xmlHttp1.open("GET",url1,true);
	xmlHttp1.send(null);
}


function showXpic(urlpic,divObjNamepic) {
    focusObNamejpic=divObjNamepic;
	xmlHttppic=GetXmlHttpObject();
	if (xmlHttppic==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
    //url="http://"+path+folderPath+"ajaxpart/CatGroupDetail1stPage.aspx?catGRoupId=1";
	//alert("retUrl:" +url);
	//alert(url);
	xmlHttppic.onreadystatechange=stateChangedpic;
	xmlHttppic.open("GET",urlpic+'&'+temp(),true);
	xmlHttppic.send(null);
}

function stateChangedpic() { 
    //alert("divObjName : "+divObjName);
	if (xmlHttppic.readyState==4){ 
		document.getElementById(focusObNamejpic).innerHTML=xmlHttppic.responseText;
		var innerHtmlData="";
	}
} 

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;
}

function popupNewWindows(url,popupName,intWidth,intHeight) {
	if (intWidth=="" || intHeight=="" ){
	newwindow = window.open( ""+url+"", ""+popupName+"", 
	"status = 1, resizable = 0" );
newwindow.focus();
	}else{
	newwindow = window.open( ""+url+"", ""+popupName+"", 
	"status = 1,scrollbars=1, height = "+intHeight+", width ="+intWidth+", resizable = 0" );
	newwindow.focus();
	}
	

}

function registerfriend(session_bid,b_id,txt)
{
 xmlHttp=GetXmlHttpObject();	
var text = escape(txt);
var url ="ajaxpart/Addfriend.aspx?text="+text+"&session_bid="+session_bid+"&b_id="+b_id+"";

		if(text.length == 0)
		{
			alert("คุณยังไม่ได้กรอกชื่อ");
		}else{}
		if(session_bid!="")
		{
			if (xmlHttp==null) {
			alert ("Your browser does not support AJAX!");
			return;
			} 
			try
			{
				xmlHttp.onreadystatechange=stateChanged_registerfriend;
				xmlHttp.open("GET",url,true);
				xmlHttp.send(null);
			}
			catch(e){
				alert(e.message)
			}
		}else{}
		
	 return text;
	}
	 //---------------------------------CHAGEPASS---------------------------------------------
function stateChanged_registerfriend() { 
//alert(xmlHttp.responseText);
	if (xmlHttp.readyState==4)
    {
	    if(xmlHttp.responseText==1)
	    {
	    alert('บันทึกเรียบร้อย');
	       window.location.reload();
	     }
	    else if(xmlHttp.responseText==2)
		{
		    alert('คุณได้ทำการแอดไปแล้ว');
		}
		else{ 
	        alert('การบันทึกผิดพลาด');
	        document.form1.textfield.value = "";
	     }
	}
} 
var aa =0;
//=========================data comment 
function insertDataComment(n,story_id,m_id)
{

var m_name ="";
var CodeNumberTextBox ="";
if(m_id =="1")
{
CodeNumberTextBox=escape(document.getElementById("CodeNumberTextBox").value);
if(CodeNumberTextBox ==""){
alert('ยังไม่ได้ใส่รหัสยืนยัน');
aa =1;
}else{}
}else{
CodeNumberTextBox = "1";
}

if(m_id == "1"){
m_name =escape(document.getElementById("namecomment").value);

	if(m_name == ""){
	m_name = "Guest";
	}else{}

}else {
	m_name = "Guest";
}
	

 xmlHttp=GetXmlHttpObject();	


var text1 = String(document.getElementById("wysiwyg"+n).contentWindow.document.body.innerHTML);
var text = escape(text1);
var url ="ajaxpart/Addstorycomment.aspx";
para =encodeURI("text="+text+"&story_id="+story_id+"&m_name="+m_name+"&CodeNumberTextBox="+CodeNumberTextBox);

		if(text.length == 0)
		{
			alert("คุณยังไม่ได้ใส่ข้อความ");
		}else{
		if(text.length != 0)
		{
			if (xmlHttp==null) { 
			alert ("Your browser does not support AJAX!");
			return;
			} 
			try
			{
			
		  xmlHttp.onreadystatechange=stateChanged_datacomment;
	    xmlHttp.open("POST",url,true);
	    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", para.length);
        xmlHttp.setRequestHeader("Connection", "close");
	    xmlHttp.send(para);   
		
				/*	xmlHttp.onreadystatechange=stateChanged_datacomment;
				xmlHttp.open("get",url,true);
				xmlHttp.send(null);	*/
			}
			catch(e){
				alert(e.message)
			}
		}else{}
		}
	 return text;
	}
	 //---------------------------------CHAGEPASS---------------------------------------------
function stateChanged_datacomment() {
//alert(xmlHttp.responseText);
	if (xmlHttp.readyState==4)
    {
	    if(xmlHttp.responseText==1)
	    {
	 //   alert('บันทึกเรียบร้อย');
	       window.location.reload();
	     }
	    else if (xmlHttp.responseText==2)
		{
		if(document.getElementById("CodeNumberTextBox").value !="")
		alert('รหัสยืนยันผิดพลาด');
		document.getElementById("CodeNumberTextBox").value="";
		}
		else{ 
	        alert('error Data Comment');
	        window.location.reload();
	     }
	}
}
 function urlEncode(inputString, encodeAllCharacter){
       var outputString = '';
       if (inputString != null){
         for (var i = 0; i < inputString.length; i++ ){
            var charCode = inputString.charCodeAt(i);
            var tempText = "";
            if (charCode < 128) {
                if (encodeAllCharacter)
                {
                  var hexVal = charCode.toString(16);
                  outputString += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();  
                } else {
                  outputString += String.fromCharCode(charCode);
                }
                            
            } else if((charCode > 127) && (charCode < 2048)) {
                tempText += String.fromCharCode((charCode >> 6) | 192);
                tempText += String.fromCharCode((charCode & 63) | 128);
                outputString += escape(tempText);
            } else {
                tempText += String.fromCharCode((charCode >> 12) | 224);
                tempText += String.fromCharCode(((charCode >> 6) & 63) | 128);
                tempText += String.fromCharCode((charCode & 63) | 128);
                outputString += escape(tempText);
            }
         }
       }
       return outputString;
    }





//-------------------------------- FORM REGISTER ----------------------------------
/*var sta1 = '';
function stateChanged_CheckUser() { 
	if (xmlHttp.readyState==4)
    {
	    if(xmlHttp.responseText==1)
	    {
	        alert("username false");
	        document.form1.textfield4.value='';
	        document.form1.textfield4.focus();
	     }
	    else if((xmlHttp.responseText==0)&&(sta1!=1))
	    {alert("ture");}
	    else if((xmlHttp.responseText==0)&&(sta1==1))
	    {   
	         if((document.form1.textfield42.value)!=(document.form1.textfield422.value))
                {
                    alert("password");
                     document.form1.textfield42.value = '';
                     document.form1.textfield422.value = '';document.form1.textfield42.focus();
                }
              else{ document.form1.submit(); }	             
	     }
	}
} 
function fncRegister1(user,sta)
{   sta1 = sta;
	xmlHttp=GetXmlHttpObject();
	var url = "http://"+path+folderPath+"ajaxpart/Member_Register.aspx";
	var para = encodeURI("check=check_user"+"&user="+user);
	
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_CheckUser;
	    xmlHttp.open("POST",url,true);
	    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", para.length);
        xmlHttp.setRequestHeader("Connection", "close");
	    xmlHttp.send(para);
	}
	catch(e){
        alert(e.message)
    }
}
var status = 0;var check;
function check_username()
{
      reg = /([a-zA-Z0-9-:]*)/;  
      var str = document.form1.textfield4.value;  
      reg.exec(str);   
      if((document.form1.textfield4.value.length==RegExp.$1.length)&&(RegExp.$1.length>=6)&&(RegExp.$1.length<=20))
      {
          fncRegister1(document.form1.textfield4.value,check);
      }
      else
      { 
        alert("ไม่");
        document.form1.textfield4.value = '';
        document.form1.textfield4.focus();
      }check='';
}
function check_all()
{
    check='';
      if( document.form1.radiobutton1.checked == true)
      { 
        if((document.form1.textfield4.value!="")&&(document.form1.textfield42.value!="")&&(document.form1.textfield422.value!="")&&(document.form1.textfield43.value!="")&&(document.form1.textarea.value!="")&&(document.form1.textfield432.value!="")&&(document.form1.textfield4322.value!=""))
        {
            check=1;
            check_username();     
        }
        else{alert("Data Error");}
}
        else { alert("Not chose Radiobutton"); }        
}*/
var check;
function stateChanged_CheckUser() { 
	if (xmlHttp.readyState==4)
    {
	    if(xmlHttp.responseText==1)
	    {
	        alert("username มีคนใช้แล้ว");
	        document.form1.textfield4.value='';
	        document.form1.textfield4.focus();
	     }
	    else if((xmlHttp.responseText==0)&&(sta1!=1))
	    {alert("สามารถใช้ username ได้");}
	    else if((xmlHttp.responseText==0)&&(sta1==1))
	    {   
	         if((document.form1.textfield42.value)!=(document.form1.textfield422.value))
                {
                    alert("password ผิดพลาด");
                     document.form1.textfield42.value = '';
                     document.form1.textfield422.value = '';document.form1.textfield42.focus();
                }
              else{ document.form1.submit(); }	             
	     }
	}
} 
function fncRegister1(url1,pa,sta)
{   sta1 = sta;
	xmlHttp=GetXmlHttpObject();
	var url = url1;
	var para = pa;
	
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_CheckUser;
	    xmlHttp.open("POST",url,true);
	    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", para.length);
        xmlHttp.setRequestHeader("Connection", "close");
	    xmlHttp.send(para);
	}
	catch(e){
        alert(e.message)
    }
}
function check_username(user)
{
      reg = /([a-zA-Z0-9-:]*)/;  
      var str = document.getElementById(user).value; 
      reg.exec(str);   
      if((document.getElementById(user).value.length==RegExp.$1.length)&&(RegExp.$1.length>=6)&&(RegExp.$1.length<=20))
      {
          fncRegister1('http://'+path+folderPath+'ajaxpart/Member_Register.aspx','check=check_user&user='+document.getElementById(user).value,check);
      }
      else
      { 
        alert("กรุณากรอก username ให้ถูกต้อง");
        document.getElementById(user).value = '';
        document.getElementById(user).focus();
      }check='';
}
function check_all(user)
{
      check='';
      if( document.form1.radiobutton1.checked == true)
      { 
        if((document.form1.textfield4.value!="")&&(document.form1.textfield42.value!="")&&(document.form1.textfield422.value!="")&&(document.form1.textfield43.value!="")&&(document.form1.textarea.value!="")&&(document.form1.textfield432.value!="")&&(document.form1.textfield4322.value!=""))
        {
            check=1;
            check_username(user);     
        }
        else{alert("กรุณากรอกข้อมูลให้ครบ");}
}
        else { alert("กรุณายอมรับก่อนทำการสมัคร"); }        
}
//---------------------------------CHAGEPASS---------------------------------------------

function stateChanged_Chagepass() { 
	if (xmlHttp.readyState==4)
    {
	    if(xmlHttp.responseText==1)
	    {
	    alert('เปลี่ยนรหัสผ่านเรียบร้อย');
	        window.close();
	     }
	    else { 
	        alert('รหัสผ่านเก่าผิดพลาด');
	        document.form1.textfield.value = "";
	     }
	}
} 
function fncChagepass(oldpass,newpass)
{   
	xmlHttp=GetXmlHttpObject();	
	var url = "ajaxpart/Member_Register.aspx?check=chagepass&oldpass="+oldpass+"&newpass="+newpass;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_Chagepass;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	catch(e){
        alert(e.message)
    }
}




//---------------------------------EDIT_PROFILE------------------------------------------
/*function stateChanged_insert() { 
	if (xmlHttp.readyState==4)
    {
	    if(xmlHttp.responseText==1)
	    {
	        alert("false");       
	     }
	}
} 
function fncInsert(pa)
{  
	try
	{xmlHttp=GetXmlHttpObject();
	var url = "http://"+path+folderPath+"ajaxpart/Member_Register.aspx";
	var para = pa;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	    xmlHttp.onreadystatechange=stateChanged_insert;
	    xmlHttp.open("POST",url,true);
	    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", para.length);
        xmlHttp.setRequestHeader("Connection", "close");
	    xmlHttp.send(para);
	    
	}
	catch(e){
        alert(e.message)
    }
}

function check_editprofile()
{ 
    if((document.form1.textfield.value!="")&&(document.form1.textfield2.value!="")&&(document.form1.textfield22.value!="")&&(document.form1.textfield222.value!="")&&(document.form1.textfield2222.value!="")&&(document.form1.textarea.value!=""))
    {
       var x = document.getElementsByName('radiobutton')
        for(var k=0;k<x.length;k++)
          if(x[k].checked)
          {
            var p = x[k].value;
       fncInsert("check=insert"+"&radiobutton="+p+"&textfield="+document.form1.textfield.value+"&textfield2="+document.form1.textfield2.value+"&textarea="+document.form1.textarea.value+"&textfield22="+document.form1.textfield22.value+"&select4="+document.form1.select4.value+"&textfield222="+document.form1.textfield222.value+"&select5="+document.form1.select5.value+"&textfield2222="+document.form1.textfield2222.value+"&textfield22222="+document.form1.textfield22222.value+"&user="+document.form1.user.value+"&pass="+document.form1.pass.value+"&id_card="+document.form1.id_card.value);
        document.form1.submit();
        }
    else{ } 
    }
    else{ alert("Data Error");}
}*/
function stateChanged_AjaxAll() { 
	if (xmlHttp.readyState==4)
    {
	    if(xmlHttp.responseText==1)
	    {
	        alert("false");       
	     }
	}
} 
function fncAjaxAll(url1,pa)
{  
	try
	{xmlHttp=GetXmlHttpObject();
	var url = url1;
	var para = pa;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	    xmlHttp.onreadystatechange=stateChanged_AjaxAll;
	    xmlHttp.open("POST",url,true);
	    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", para.length);
        xmlHttp.setRequestHeader("Connection", "close");
	    xmlHttp.send(para);
	    
	}
	catch(e){
        alert(e.message)
    }
}
function check_editprofile(status)
{ 
    if((document.form1.textfield.value!="")&&(document.form1.textfield2.value!="")&&(document.form1.textfield22.value!="")&&(document.form1.textfield222.value!="")&&(document.form1.textfield2222.value!="")&&(document.form1.textarea.value!=""))
    {
       var x = document.getElementsByName('radiobutton')
        for(var k=0;k<x.length;k++)
          if(x[k].checked)
          {
            var p = x[k].value;
            if(status =="insert")
            {
               fncAjaxAll("ajaxpart/Member_Register.aspx","check=insert"+"&radiobutton="+p+"&textfield="+document.form1.textfield.value+"&textfield2="+document.form1.textfield2.value+"&textarea="+document.form1.textarea.value+"&textfield22="+document.form1.textfield22.value+"&select4="+document.form1.select4.value+"&textfield222="+document.form1.textfield222.value+"&select5="+document.form1.select5.value+"&textfield2222="+document.form1.textfield2222.value+"&textfield22222="+document.form1.textfield22222.value+"&user="+document.form1.user.value+"&pass="+document.form1.pass.value+"&id_card="+document.form1.id_card.value+"&birthday="+document.form1.select.value+"-"+document.form1.select2.value+"-"+document.form1.select3.value);
             }
             else if(status=="update")
             {
                fncAjaxAll("ajaxpart/Member_Register.aspx","check=update"+"&radiobutton="+p+"&textfield="+document.form1.textfield.value+"&textfield2="+document.form1.textfield2.value+"&textarea="+document.form1.textarea.value+"&textfield22="+document.form1.textfield22.value+"&select4="+document.form1.select4.value+"&textfield222="+document.form1.textfield222.value+"&select5="+document.form1.select5.value+"&textfield2222="+document.form1.textfield2222.value+"&textfield22222="+document.form1.textfield22222.value+"&birthday="+document.form1.select.value+"-"+document.form1.select2.value+"-"+document.form1.select3.value);
                
                alert('Update');window.location='blog.aspx';     
             }
        }
    else{ } 
    }
    else{ alert("ข้อมูลผิดพลาด");}
}
//-----------------------------------My_Blog---------------------------------------------
function Blog(url1,divObjName,pa) {
try{
    focusObNamej=divObjName;
	xmlHttp=GetXmlHttpObject();
	var url = url1;
	var para = pa;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	    xmlHttp.onreadystatechange=stateChanged_Blog;
	    xmlHttp.open("POST",url,true);
	    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", para.length);
        xmlHttp.setRequestHeader("Connection", "close");
	    xmlHttp.send(para);
	    
	}
	catch(e){
        alert(e.message)
    }
}

function stateChanged_Blog() { 
    //alert("divObjName : "+divObjName);
	if (xmlHttp.readyState==4){ 
		document.getElementById(focusObNamej).innerHTML=xmlHttp.responseText;
		var innerHtmlData="";
	}
} 
function create()
{
    if((document.form1.textfield2.value!="")&&(document.form1.textarea.value!="")&&(document.form1.select.value!=""))
   {
        
	//reg = /([a-zA-Zก-๙]*)/;  
      var str = document.form1.textfield2.value; 
   //   reg.exec(str);   
      if((str.length>=2)&&(str.length<=14))
      {

//fncCreateBlog("textfield="+document.form1.textfield.value+"&textfield2="+document.form1.textfield2.value+"&textarea="+document.form1.textarea.value+"&textfield4="+document.form1.textfield4.value+"&select="+document.form1.select.value);
        fncAjaxAll('http://'+path+folderPath+'ajaxpart/Create_Blog.aspx',"check=update&b_id="+document.form1.b_id.value+"&b_title="+document.form1.textfield2.value+"&b_name="+escape(document.form1.textfield2.value)+"&b_desc="+document.form1.textarea.value+"&b_keyword="+document.form1.textfield4.value+"&b_group="+document.form1.select.value);
	alert('แก้ไขข้อมูลเรียบร้อย');
        document.form1.submit();
	}
else
{
	alert('กรุณากรอกชื่อ blog ให้ถูกต้อง');
}
   }
   else{alert("ข้อมูลผิดพลาด");}
}
//--------------------------------------############Create_Blog-------------------------------------
function stateChanged_createBlog() { 
	if (xmlHttp.readyState==4)
    {
	    if(xmlHttp.responseText==1)
	    {
	        alert("false");       
	     }
	}
} 
function fncCreateBlog(pa)
{  
	try
	{xmlHttp=GetXmlHttpObject();
	var url = "ajaxpart/Create_Blog.aspx";
	var para = pa;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	 
	    xmlHttp.onreadystatechange=stateChanged_createBlog;
	    xmlHttp.open("POST",url,true);
	    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", para.length);
        xmlHttp.setRequestHeader("Connection", "close");
	    xmlHttp.send(para);	    
	}
	catch(e){
        alert(e.message)
    }
}
//------------------------------------Msg_box-------------------------------
function Msg_home(url,divObjName) {
try{
    focusObNamej=divObjName;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	xmlHttp.onreadystatechange=stateChanged_Msg_home;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	}
	catch(e){
        alert(e.message)
    }
}

function stateChanged_Msg_home() { 
    //alert("divObjName : "+divObjName);
	if (xmlHttp.readyState==4){ 
		document.getElementById(focusObNamej).innerHTML=xmlHttp.responseText;
		var innerHtmlData="";
	}
} 
function methodDeleteMessage_Box()
{
var ch = '';
var x = document.getElementsByName('checkbox')
        for(var k=0;k<x.length;k++)
          if(x[k].checked){
            ch = 'c';
            }
            if(ch=='')
            {
            alert('กรุณาเลือกข้อความที่จะลบ');
            }
            else
            {
            if(confirm('คุณต้องการลบข้อความนี้')==true)
              {
                     var x = document.getElementsByName('checkbox')
                        for(var k=0;k<x.length;k++)
                          if(x[k].checked){
                            var p = x[k].value;
                            var url = "ajaxpart/Message_Box.aspx?status=delete&id="+p;
                    Msg_home(url,'home');}
              }
            }

}
//function methodDeleteMessage_Box()
//{
//if(confirm('คุณต้องการลบข้อความนี้')==true)
//{

//     var x = document.getElementsByName('checkbox')
//        for(var k=0;k<x.length;k++)
//          if(x[k].checked){
 //           var p = x[k].value;
 //           var url = "ajaxpart/Message_Box.aspx?status=delete&id="+p;
  //  Msg_home(url,'home');}
 //   }
//}
function methodDeleteMessage_id(id)
{
            if(confirm('คุณต้องการลบข้อความนี้')==true)
    {
            var url = "ajaxpart/Message_Box.aspx?status=delete_id&id="+id+"&"+temp();
    Msg_home(url,'home');
    }
}

function stateChanged_Msg() { 
	if (xmlHttp.readyState==4)
    {
            alert("ส่งข้อความเรียบร้อย");
	       window.close();

	}
} 
function fncMsg(pa)
{   
    //category = document.form1.textfield.value;
    //category_desc = document.form1.textarea.value;
	xmlHttp=GetXmlHttpObject();	
	var url = "ajaxpart/Message_Box.aspx"+pa;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_Msg;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	catch(e){
        alert(e.message)
    }
}
function methodInsertMessage(t,b)
{
    if(document.getElementById(t).value!="")
    {
    var p = "?status=insertmsg&msg="+escape(document.getElementById(t).value)+'&b_id='+b;
    fncMsg(p);
    }
    else
    {
        alert('กรุณากรอกข้อความ');
    }
    
}
function methodInsertMessage_Box(as,as1)
{
var a=document.getElementById(as1).value;
    if(document.getElementById(as1).value!="")
    {
		if((document.getElementById(as1).value).length<900)
		{
        var url = "ajaxpart/Message_Box.aspx?status=insert&id="+document.getElementById(as).value+"&msg="+escape(document.getElementById(as1).value);
		alert('ส่งข้อความเรียบร้อยแล้ว');
        Msg_home(url,'home');
		}
		else
		{
		alert('ข้อความยาวเกิน 900 ตัวอักษร');
		}
    }
    else{ alert('กรุณากรอกข้อความ');}
}
function methodCheckbox(str)
{
    if(str == 'check')
    {
        var inputs = document.getElementsByName('checkbox')
        var checkboxes = [];
        for (i = 0; i < inputs.length; i++) {
            inputs[i].checked = true;
        }
    }
    else if(str=='uncheck')
    {
         var inputs = document.getElementsByName('checkbox')
        var checkboxes = [];
        for (i = 0; i < inputs.length; i++) {
            inputs[i].checked = false;
        }
    }

}

function sh(n)
{
    var s = document.getElementById(n).value;
    alert(s);
   
}
/*function aa()
{
    var list = new Array("q1","q2","q3");
    for(var i=0;i<list.length;i++)
    {
	    var p = "";
	    var x = document.getElementsByName(list[i])
       	     for(var k=0;k<x.length;k++)
       	       if(x[k].checked){
           	     p = x[k].value;}
	    if(p!="")
	    { document.form1.submit(); }
	    else{ alert("ใส่ข้อมูลไม่ครบ");break;}
    }
return false;
}*/
//----------------------------------CREATE_BLOG--------------------------
var checkblog;
function stateChanged_CheckBlog() { 
	if (xmlHttp.readyState==4)
    {
	    if(xmlHttp.responseText==1)
	    {
	        //alert("ชื่อ  Url blog นี้มีคนใช้งานแล้วค่ะ");
			document.getElementById('WarnText').innerHTML = '<font color="red"><img src="images/false.gif" align="absmiddle" height="16" />&nbsp;ชื่อ Blog URL นี้มีคนใช้งานแล้วค่ะ</font>';
	        document.form1.textfield.value='';
	        document.form1.textfield.focus();
	     }
	    else if((xmlHttp.responseText==0)&&(sta1!=1))
	    {
		document.getElementById('WarnText').innerHTML = '<font color="green"><img src="images/ok.png" align="absmiddle" height="16"/>&nbsp;ชื่อ Blog URL นี้สามารถใช้งานได้ค่ะ</font>';
		//alert("ชื่อ  Url blog นี้สามารถใช้งานได้ค่ะ");
		}
	    else if((xmlHttp.responseText==0)&&(sta1==1))
	    {   
              	   insertblog();
		alert('สร้าง blog เรียบร้อย');
              	   window.location ='blog.aspx?'+temp();   
              //	window.location.reload(true);
	     }
	}
} 
function fncCreateBlog(url1,pa,sta)
{   sta1 = sta;

	xmlHttp=GetXmlHttpObject();
	var url = url1;
	var para = pa;
	
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{

	    xmlHttp.onreadystatechange=stateChanged_CheckBlog;
	    xmlHttp.open("POST",url,true);
	    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", para.length);
        xmlHttp.setRequestHeader("Connection", "close");
	    xmlHttp.send(para);
	}
	catch(e){
        alert(e.message+"a")
    }
}
function check_userblog(user)
{
      reg = /([a-zA-Z0-9]*)/;  
      var str = document.getElementById(user).value; 
      reg.exec(str);   
      if((document.getElementById(user).value.length==RegExp.$1.length)&&(RegExp.$1.length>=2)&&(RegExp.$1.length<=32))
      {
          fncCreateBlog(folderPath+'ajaxpart/Create_Blog.aspx','check=check_blog&url='+document.getElementById(user).value,check);
      }
      else
      { 
        //alert("กรุณากรอกข้อมูลให้ถูกต้อง");
		document.getElementById('WarnText').innerHTML = '<font color="orange"><img src="images/ImgInFormWarn.gif" align="absmiddle" height="16" />&nbsp;ชื่อ Blog ไม่ตรงตามลักษณะที่ถูกต้อง โปรดตรวจสอบค่ะ</font>';
		//document.getElementById('WarnText').innerHTML = 'กรุณากรอกข้อมูลให้ถูกต้อง';
     //   document.getElementById(user).value = '';
        document.getElementById(user).focus();
      }check='';
}
function check_allblog(user)
{
    try
    {
      check='';
	//reg = /([a-zA-Zก-๙]*)/;  
    //  var str = document.form1.textfield2.value; 
    //  reg.exec(str);   
      //if((document.form1.textfield2.value.length==RegExp.$1.length)&&(RegExp.$1.length>=2)&&(RegExp.$1.length<=20))
    //  {
        if((document.form1.textfield2.value!="")&&(document.form1.textarea.value!=""))
        {
            check=1;
check_userblog(user);
          //  insertblog();
            }
      //  }
        else{alert("กรุณากรอกข้อมูลให้ครบทุกช่องค่ะ");}
    // }
	//else
	//{
	//	alert('กรุณากรอกชื่อ blog ให้ถูกต้อง');
	//}
     }
     catch(e)
     {
        alert(e.message);
     }
}
function insertblog()
{
    //fncAjaxAll("ajaxpart/Create_Blog.aspx","check=insert"+"&url="+document.form1.textfield.value+"&blog_name="+escape(document.form1.textfield2.value)+"&blog_group="+document.form1.menu1.value+"&blog_desc="+document.form1.textarea.value+"&blog_title="+document.form1.textfield22.value); // เก่า
        fncAjaxAll(folderPath+"ajaxpart/Create_Blog.aspx","check=insert"+"&url="+document.form1.textfield.value+"&blog_name="+escape(document.form1.textfield2.value)+"&blog_group="+document.form1.menu1.value+"&blog_desc="+document.form1.textarea.value+"&blog_title="+document.form1.textfield2.value);
        window.location ='temp.aspx';  
}

//--------------------------------Login-------------------------------------------
function login()
{  
    fncCheckLogin(document.getElementById('textfield').value,document.getElementById('textfield2').value);
}
function stateChanged_CheckLogin() { 
	if (xmlHttp.readyState==4)
    {
	    if(xmlHttp.responseText==0)
	    {
	        
			window.location='blog.aspx?' + temp();
	     }
	    else { 
	        
			alert('ชื่อผู้ใช้ หรือ รหัสผ่าน ไม่ถูกต้อง\nกรุณาตรวจสอบอีกครั้ง');
	        document.getElementById('textfield').value="";document.getElementById('textfield').focus();
	        document.getElementById('textfield2').value="";
	     }
	}
} 
function fncCheckLogin(user,pass)
{   
	xmlHttp=GetXmlHttpObject();	
	//var url = "http://"+path+""+folderPath+"ajaxpart/Member_Register.aspx?check=login&user="+user+"&pass="+pass;
	var url = "ajaxpart/Member_Register.aspx?timestamp=" + temp() +"&check=login&user="+user+"&pass="+pass;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_CheckLogin;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	catch(e){
        alert(e.message)
    }
}
//-------------------------------------- Gallery -----------------------------------------------
var gallery_id = "";
function DeleteGallery(gallery_id1,b_id1)
{

    if(confirm('ยืนยันการ ลบ')==true)
   {
    fncDeleteGallery(gallery_id1,b_id1);
   }
}
function fncDeleteGallery(gallery_id1,b_id1)
{   
gallery_id = gallery_id1;
b_id=b_id1
	xmlHttp=GetXmlHttpObject();	
	var url = "ajaxpart/DeleteOnGallery.aspx?gallery_id="+gallery_id;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_DeleteGallery;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	catch(e){
        alert(e.message)
    }
}
function stateChanged_DeleteGallery() { 
	if (xmlHttp.readyState==4)
    {
		//parent.location='http://'+path+folderPath+'gallery_picture_setting_blog.aspx?b_id='+b_id'';
 window.location= "picture_setting_blog_edit.aspx?b_id="+b_id+"&page=1";
	 //       showX('http://'+path+folderPath+'ajaxpart/Story.aspx?check=3&b_id='+b_id,'story');

	}
} 
//-------------------------------------picture -----------------------------------------------
var picture_id = "";
 function DeletePicture(picture_id1,gallery_id1)
{

    if(confirm('ยืนยันการ ลบ')==true)
   {
    fncDeletePicture(picture_id1,gallery_id1);
   }
}
function fncDeletePicture(picture_id1,gallery_id1)
{ 
picture_id = picture_id1;
gallery_id=gallery_id1
  
	xmlHttp=GetXmlHttpObject();	
	var url = "ajaxpart/DeleteOnPicture.aspx?picture_id="+picture_id;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_DeletePicture;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	catch(e){
        alert(e.message)
    }
}
function stateChanged_DeletePicture() { 
	if (xmlHttp.readyState==4)
    {
		//parent.location='http://'+path+folderPath+'gallery_picture_setting_blog.aspx?b_id='+b_id'';
 window.location= "picture_edit_blog.aspx?gallery_id="+gallery_id+"";
	 //       showX('http://'+path+folderPath+'ajaxpart/Story.aspx?check=3&b_id='+b_id,'story');

	}
} 

//-------------------------------------Video -----------------------------------------------
var  video_id = "";
 function DeleteVideo(video_id1,b_id1)
{

    if(confirm('ยืนยันการ ลบ')==true)
   {
    fncDeleteVideo(video_id1,b_id1);
   }
}
function fncDeleteVideo(video_id1,b_id1)
{ 
video_id = video_id1;
b_id=b_id1
  
	xmlHttp=GetXmlHttpObject();	
	var url = "ajaxpart/DeleteOnVideo.aspx?video_id="+video_id;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_DeleteVideo;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	catch(e){
        alert(e.message)
    }
}
function stateChanged_DeleteVideo() { 
	if (xmlHttp.readyState==4)
    {
		//parent.location='http://'+path+folderPath+'gallery_picture_setting_blog.aspx?b_id='+b_id'';
 window.location= "video_setting_blog_edit.aspx?b_id="+b_id+"&page=1";
	 //       showX('http://'+path+folderPath+'ajaxpart/Story.aspx?check=3&b_id='+b_id,'story');

	}
} 



//-------------------------------------- Story -------------------------------------------------

var b_id="";var bfolder_id="";

function deleteBfolder(bfolder,b_id1)
{
	alert("เรื่องทั้งหมดจะถูกย้ายเข้าสู่โฟรเดอร์เริ่มต้น");
    if(confirm('ยืนยันการ ลบ')==true)
    {
     fncDeleteBfolder(bfolder,b_id1);
    }
}
function DeleteFavorite_Blog(fbb_id,b_id1)
{
    if(confirm('ยืนยันการ ลบ')==true)
    {
        fncDeleteFavorite_Blog(fbb_id,b_id1);
    }
}
function deleteStory(story_id,b_id1)
{
    if(confirm('ยืนยันการ ลบ')==true)
    {
     fncDeleteStory(story_id,b_id1);
    }
}
function stateChanged_DeleteStory() { 
	if (xmlHttp.readyState==4)
    {

	        window.location='story.aspx?b_id='+b_id;

	}
} 
function fncDeleteStory(story_id,b_id1)
{   
b_id=b_id1;
	xmlHttp=GetXmlHttpObject();	
	var url = "ajaxpart/Story.aspx?check=delete&story_id="+story_id;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_DeleteStory;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	catch(e){
        alert(e.message)
    }
}
function stateChanged_DeleteBfolder() { 
	if (xmlHttp.readyState==4)
    {
		window.location.reload();
	       // showX('http://'+path+folderPath+'ajaxpart/Story.aspx?check=3&b_id='+b_id,'story');

	}
} 
function fncDeleteBfolder(bfolder_id1,b_id1)
{   
bfolder_id = bfolder_id1;
b_id=b_id1
	xmlHttp=GetXmlHttpObject();	
	var url = "ajaxpart/Story.aspx?check=deleteBfolder&bfolder_id="+bfolder_id+"&b_id="+b_id;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_DeleteBfolder;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	catch(e){
        alert(e.message)
    }
}

function stateChanged_DeleteFavorite_Blog() { 
	if (xmlHttp.readyState==4)
    {

	        showX('http://'+path+folderPath+'ajaxpart/Story.aspx?check=5&b_id='+b_id,'story');

	}
} 
function fncDeleteFavorite_Blog(fbb_id,b_id1)
{   
b_id=b_id1
	xmlHttp=GetXmlHttpObject();	
	var url = "ajaxpart/Story.aspx?check=deleteFavorite_blog&fbb_id="+fbb_id;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_DeleteFavorite_Blog;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	catch(e){
        alert(e.message)
    }
}
//--------------------------------------------Story  Category-------------------------------------------
var  category = "";
var category_desc = "";
var upbfolder_id = "";
function showCategoryType(b1,b2,b3,b_id1)
{
       document.form1.textfield.value = b1; category = b1;
       document.form1.textarea.value = b2; category_desc = b2;
       upbfolder_id=b3;
       b_id=b_id1
}
function updatefolder()
{
    fncUpdateBfolder();
}

function stateChanged_UpdateBfolder() { 
	if (xmlHttp.readyState==4)
    {

	        showX('ajaxpart/Story.aspx?check=3&b_id='+b_id,'story');

	}
} 
function fncUpdateBfolder()
{   
    category = escape(document.form1.textfield.value);
    category_desc = escape(document.form1.textarea.value);
    
    reg = /([a-zก-๙A-Z0-9-:]*)/;  
      var str = document.form1.textfield.value;
      reg.exec(str);   
      if((document.form1.textfield.value.length==RegExp.$1.length)&&(RegExp.$1.length>=1)&&(RegExp.$1.length<=20))
      {

	xmlHttp=GetXmlHttpObject();	
	var url = "ajaxpart/Story.aspx?check=updateCategory&bfolder_id="+upbfolder_id+'&category='+category+'&category_desc='+category_desc;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_UpdateBfolder;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	catch(e){
        alert(e.message)
    }upbfolder_id="";
}
else
      { 
        alert("กรุณากรอกตัวอักษรและตัวเลขเท่านั้น");
}
}

//-------------------------------------forgetpassword---------------------------------------

function stateChanged_Forgetpass() { 
	if (xmlHttp.readyState==4)
    {
	    if(xmlHttp.responseText==1)
	    {
	    alert("ส่งรหัสผ่านไปยัง E-mail เรียบร้อยแล้ว\nกรุณารอ E-mail ตอบกลับ");
	        window.close();
	     }
	    else { 
	        alert('ชื่อผู้ใช้ หรือ E-mail ผิดพลาด\nกรุณาตรวจสอบอีกครั้ง');
	        
	        document.form1.textfield.value = "";
	        document.form1.textfield2.value = "";
	     }
	}
} 
function fncForgetpass(user,email)
{   
	xmlHttp=GetXmlHttpObject();	
	var url = "ajaxpart/Forgetpassword.aspx?user="+escape(user)+"&email="+escape(email);
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_Forgetpass;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	catch(e){
        alert(e.message)
    }
}
//===================== delete comment story ============
var story_id = "";
var b_id = "";
function deleteComment(comment_id1,b_id1,story_id1)
{

    if(confirm('ยืนยันการ ลบ')==true)
    {
     fncDeleteComment(comment_id1,b_id1,story_id1);
    }
}
function stateChanged_DeleteComment() { 
	if (xmlHttp.readyState==4)
    {

	        window.location='blog_preview.aspx?b_id='+b_id+'&story_id='+story_id;

	}
} 
function fncDeleteComment(comment_id1,b_id1,story_id1)
{   
  b_id=b_id1;
story_id =story_id1;
var  comment_id = comment_id1;
	xmlHttp=GetXmlHttpObject();	

	var url = "ajaxpart/Delete_Comment_Request_Story.aspx?comment_id="+comment_id+"&story_id="+story_id;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_DeleteComment;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	catch(e){
        alert(e.message)
    }
}

//====================== request comment ======================
function requestComment(comment_id1,b_id1,story_id1)
{

    if(confirm('ต้องการแจ้งลบ')==true)
    {
     fncrequestComment(comment_id1,b_id1,story_id1);
    }
}
function stateChanged_requestComment() { 
	if (xmlHttp.readyState==4)
    {

	        window.location='blog_preview.aspx?b_id='+b_id+'&story_id='+story_id;

	}
} 
function fncrequestComment(comment_id1,b_id1,story_id1)
{   
  b_id=b_id1;
story_id =story_id1;
var  comment_id = comment_id1;
	xmlHttp=GetXmlHttpObject();	

	var url = "ajaxpart/Comment_Request_Story.aspx?comment_id="+comment_id+"&story_id="+story_id;
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	try
	{
	    xmlHttp.onreadystatechange=stateChanged_requestComment;
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);
	}
	catch(e){
        alert(e.message)
    }
}


//-------------------------------------Story Edit-------------------------------------------
//function story_alert(b_id,text,select)
//{
//   var p = "";
//   var x = document.getElementsByName(select)
//   var y = document.getElementById(text).value;
//        for(var k=0;k<x.length;k++)
//        {
//      //  alert(x[k].value+' '+document.getElementById(text).value);
//            p = x[k].value;
////          if(x[k].checked)
////          {
////            var p = x[k].value;
////            alert(p);
////        }
//    }
//   serach('http://'+path+folderPath+'ajaxpart/Story.aspx?check=1&b_id='+b_id+'&topic='+y+'&bfolder_id='+p,'story');
//   //showX('http://'+path+folderPath+'ajaxpart/Story.aspx?check=1&b_id='+b_id+'&topic='+y+'&bfolder_id='+p,'story');
//}


//================================= icon ===========================================
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function forgetpassword(url){
    newwindow=window.open(url,'name','height=260,width=360');
    if (window.focus) {
    newwindow.focus()
    }
    return false;
}
//============================================story_Member=======================================

function text_member(value,check,symbol,last)
{
    showStory_member(value,last);
   // var c = document.getElementById('s').innerHTML;
    var tempc = check;
    if(value!='')
    {
        c = value;
    }
    document.getElementById('s').innerHTML = '';
    var c1 = parseInt(c);
//    if(symbol=='-')
//    {
//        c1 = parseInt(c)-4;
//        if(c1<=0){c1=1;}
//    }
//    if(symbol=='+')
//    {
//        if(c1>=last){ c1=parseInt(c)-4;}
//        if(c1<=0){c1=1;}
//    }

    if(check>1)
    {
    document.getElementById('s').innerHTML += "<a href =\"javascript:text_member('"+(check-5)+"','"+(tempc-5)+"','-','"+last+"');\"><</a> ";
    }
       for(var i=0;i<5;i++)
       {
            if(check>last){break;}
            if(check==value)
            {
             document.getElementById('s').innerHTML += "<a href =\"javascript:text_member('"+check+"','"+tempc+"','+','"+last+"');\"><span class=\"headTopic\">"+c1+"</span></a> ";
            }
            else{document.getElementById('s').innerHTML += "<a href =\"javascript:text_member('"+check+"','"+tempc+"','+','"+last+"');\">"+check+"</a> ";}
        check = parseInt(check)+1;        
       }
    if(check<last)
    {
        document.getElementById('s').innerHTML += "<a href =\"javascript:text_member('"+check+"','"+check+"','+','"+last+"');\">></a> ";
    }
    else if(check==last)
    {
        document.getElementById('s').innerHTML += "<a href =\"javascript:text_member('"+check+"','"+(check-4)+"','+','"+last+"');\">></a> ";
    }
    
}
function showStory_member(value,numStory)
{   

     // alert(document.getElementById("select3").value);
        //alert(first[0]+' '+first[1]);
        for(var j=1;j<=parseInt(numStory)*10;j++)
        {
            document.getElementById("t"+j).style.display='none';
            document.getElementById("tt1"+j).style.display='none';
        }
      //  alert(first[0]+' '+first[1]);
      var value1;
        if(value=='1')
        {
            value1 = '1';
        }
        if(value!='1'){value1 =parseInt(value)-1; value1=(value1*10)+1;}
        for(var i=value1;i<=parseInt(value)*10;i++)
        {
                document.getElementById("t"+i).style.display='';
                document.getElementById("tt1"+i).style.display='';

        }
} 

function log1(event)
{
       if(event.keyCode==13)
       {
           // document.form3.submit();
           login();
       }
} 
function Tempsave(b_id1)
{
var b_id = b_id1;
var btemp_id;
var url;
var x = document.getElementsByName('radiobutton')
        for(var k=0;k<x.length;k++)
          if(x[k].checked)
          {
            btemp_id = x[k].value;
			}
			else{ } 
	
	//"http://"+rootpath+rootfolder+"ajaxpart/insert_template_blog.aspx?btemplate_id="+btemp_id;
url ="ajaxpart/insert_template_blog.aspx?btemplate_id="+btemp_id+"&b_id="+ b_id;
	showX(url,'template');
   alert('ใช้งาน Template นี้เรียบร้อยแล้ว');        
window.location='Template_Blog.aspx?b_id='+b_id+"&page=1";
}
function valueCat(cat_id1)
{
var cat_id = cat_id1;
showX('ajaxpart/CatGroupDetail1stPage.aspx?catGroupId='+cat_id+'','boxDataBlogByCatId');

//alert(cat_id);
document.getElementById('catbox').value = cat_id;

}
function sendCat()
{
var cat_id = document.getElementById('catbox').value;
window.location = "member_all_cat.aspx?cat_id="+cat_id+"";
}
var  tdnumber ='1' ;

function valuegroup(value)
{
var value = value;
tdnumber = value;
var txtcolor = 'tagid'+value ;
if (value == '1')
{
document.getElementById('tagid'+value).className ='headOrage';
document.getElementById('tagid2').className='headWhite';
document.getElementById('tagid3').className='headWhite';
}else if(value == '2')
{
document.getElementById('tagid'+value).className ='headOrage';
document.getElementById('tagid1').className='headWhite';
document.getElementById('tagid3').className='headWhite';
}else{
document.getElementById('tagid'+value).className ='headOrage';
document.getElementById('tagid1').className='headWhite';
document.getElementById('tagid2').className='headWhite';
}

//alert(cat_id);
document.getElementById('groupbox').value = value;

}
function mountout (value)
{
if (value != tdnumber)
{
document.getElementById('tagid'+value).className ='headWhite';
}
}
function sendvaluegroup()
{
var groupbox = document.getElementById('groupbox').value;
window.location = "member_all_group.aspx?value="+groupbox+"";
}

// page _set <pok>
function page_next(url,pagegroup,pagesize)
{

/*for(var i = 1; i <= pagesize; i++)
{
if (i==pagegroup){
document.getElementById('page'+pagegroup).className ='headOrage';
}else{
document.getElementById('page'+pagegroup).className ='txtnormal';
}
}*/
//document.getElementById('page'+pagegroup).className ='headOrage';
window.location = url+"&page="+pagegroup;
}
// menusetting click
function menuclick(menuNum,b_id)
{
var url = new Array();
url[0] = 'story.aspx?check=1&b_id=' + b_id;
url[1] = 'setting_blog.aspx?b_id=' + b_id;
url[2] = 'Template_Blog.aspx?b_id=' + b_id + '&page=1';
url[3] = 'picture_setting_blog_edit.aspx?b_id=' + b_id + '&page=1';
url[4] = 'video_setting_blog_edit.aspx?b_id=' + b_id + '&page=1';
    for(var i=1;i<5;i++){
    if(i == parseInt(menuNum))
    document.getElementById('menu'+menuNum).className ='headOrage';
    else
    document.getElementById('menu'+i).className ='headWhite';
    }
        window.location = url[menuNum-1];
}
/// 
function $I(element) {
    if (Object.isString(element))
        element = document.getElementById(element);
    return element;
}

function $N(element) {
    if (Object.isString(element))
        element = document.getElementsByName(element);
    return element;
}

function $T(element) {
    if (Object.isString(element))
        element = document.getElementsByTagName(element);
    return element;
}

var mObject = (function() { })();
(function() {
    var _toString = Object.prototype.toString;
    
    function extend(destination, source) {
        for (var property in source)
            destination[property] = source[property];
        return destination;
    }
    function isString(object) { return _toString.call(object) == "[object String]"; }
    function isNumber(object) { return _toString.call(object) == "[object Number]"; }
    function isUndefined(object) { return typeof object === "undefined"; } 
      
    extend(Object, {
        isString:      isString,
        isNumber:      isNumber,
        isUndefined:   isUndefined
    });
})();

//////////////////////////////////////////////////////////////////////////////////////////////////////////////


function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 85); 
    var timer = 0; 
    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd){ 
        for(i = opacStart; i <= opacEnd; i++){
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++;	
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")";
}

function setOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")";
}



