function PostDelete(contentID, masterID, webSection) {
	if(confirm("คุณต้องการแจ้งลบข้อมูลนี้..??")) {
		var w=470, h=140;
		var left = (screen.width) ? (screen.width-w)/2 : 0;
		var top = (screen.height) ? (screen.height-h)/2 : 0;
		window.open("index.php?file=delmessage&c="+contentID+"&m="+masterID+"&w="+webSection+"","delmessage","title=no,resizable=no,scrollbars=no,toolbar=no,width="+w+",height="+h+",top="+top+",left="+left);
	}
}

function checkAll(pvalue,pBox) {
 if (pBox) {
 	var nbox=pBox.length;
	if (nbox==undefined) { pBox.checked=pvalue } 
	 else {
	    for (var j = 0; j < nbox; j++)  {
			if(pvalue)MO_2(pBox[j]);
			else MU_2(pBox[j]);
			pBox[j].checked=pvalue;
		}
	 }	
  }
}

function checkIt(pall,pbox,pvalue) {   
    if (pvalue.checked==false) { pall.checked=pvalue.checked; }
	 else {
	     var ibox=pbox.length;
	     for (var j = 0; j < ibox; j++)  {
			if (pbox[j].checked!=pvalue.checked) {	return; }}
		 pall.checked=pvalue.checked;
	 }	 
}

function checkValues(pbox) {
 var xID="";
 if (pbox) {
 	if (pbox.length==undefined) {
		if (pbox.checked==true) { xID=pbox.value}	
	} else
	 {
	  var nbox=pbox.length; 
 	   for (var j = 0; j < nbox; j++)  {
		  if (pbox[j].checked==true) {
		 		 if (xID=="") {	xID=pbox[j].value; } else {	xID=xID +"," +pbox[j].value;}	
			} /*Box Select */
		} /*for loop*/
	 } /*>1*/
 } 
 return xID;	
}
function delindex(IDparent , del , idDel  ) {
	if(confirm("ยืนยันการลบข้อมูล")) {
		window.location.replace("editActivity.php?IDparent="+IDparent+"&del="+del+"&idDel="+idDel);
	}
}
function delindex1(ID, del , idf ) {
	if(confirm("ยืนยันการลบข้อมูล")) {
		window.location.replace("editnews.php?ID="+ID+"&del="+del+"&idp="+idf);
	}
}
function delRecordAndSubAndImageMaster(tb, tb1, id, url, fid) {
	if(confirm("ยืนยันการลบข้อมูล")) {
		window.location.replace("../0library/delData.php?tb="+tb+"&tb1="+tb1+"&id="+id+"&url="+url+"&fid="+fid+"&img=true&master=true");
	}
}
function delRecordsAndSubsAndImagesMaster(tb, tb1, pbox, url, fid) {
	var xValue=checkValues(pbox);
	if (xValue=="") { 
		alert("กรุณาเลือกรายการที่ต้องการลบ");
	}
	else {
		aValue = xValue.split(',');
		if (confirm("ยืนยันการลบข้อมูล " + aValue.length + " รายการ")) {
			window.location.replace("../0library/delData.php?tb="+tb+"&tb1="+tb1+"&id="+xValue+"&url="+url+"&fid="+fid+"&img=true&master=true"); 
		}
	}
}

function delMasterColumn(tb, pbox, url) {
	var xValue=checkValues(pbox);
	if (xValue=="") { 
		alert("please, select any record");
	}
	else {
		aValue = xValue.split(',');
		if (confirm("Are you sure to Delete " + aValue.length + " record(s) and All sub in this record(s)")) {
			window.location.replace("../0library/delMasterData.php?tb="+tb+"&id="+xValue+"&url="+url); 
		}
	}
}

function delRecordAndSub(tb, tb1, id, url, fid) {
	if(confirm("ยืนยันการลบข้อมูล")) {
			window.location.replace("../../libs/delData.php?tb="+tb+"&tb1="+tb1+"&id="+id+"&url="+url+"&fid="+fid); 
	}
}
function delRecordsAndSubs(tb, tb1, pbox, url, fid) {
	var xValue=checkValues(pbox);
	if (xValue=="") { 
		alert("กรุณาเลือกรายการที่ต้องการลบ");
	}
	else {
		aValue = xValue.split(',');
		if (confirm("ยืนยันการลบข้อมูล " + aValue.length + " รายการ")) {
			window.location.replace("../../libs/delData.php?tb="+tb+"&tb1="+tb1+"&id="+xValue+"&url="+url+"&fid="+fid); 
		}
	}
}

function delRecord(tb, id, url) {
	if(confirm("ยืนยันการลบข้อมูล")) {
		window.location.replace("../0library/delData.php?tb="+tb+"&id="+id+"&url="+url);
	}
}

function delRecordAndDir(tb, id, url) {
	if(confirm("กรุณาเลือกรายการที่ต้องการลบ")) {
		window.location.replace("../0library/delData.php?tb="+tb+"&id="+id+"&url="+url+"&dir=true");
	}
}

function delTypeRecord(tb, id, ftb, fid, url) {
	if(confirm("ยืนยันการลบข้อมูล")) {
		window.location.replace("../../libs/chkBeforeDel.php?tb="+tb+"&id="+id+"&ftb="+ftb+"&fid="+fid+"&url="+url);
	}
}

function delRecords(tb, pbox, url) {
	var xValue=checkValues(pbox);
	if (xValue=="") { 
		alert("กรุณาเลือกรายการที่ต้องการลบ");
	}
	else {
		aValue = xValue.split(',');
		if (confirm("ยืนยันการลบข้อมูล " + aValue.length + " รายการ")) {
			window.location.replace("../0library/delData.php?tb="+tb+"&id="+xValue+"&url="+url); 
		}
	}
}

function delTypeRecords(tb, pbox, ftb, fid, url) {
	var xValue=checkValues(pbox);
	if (xValue=="") { 
		alert("กรุณาเลือกรายการที่ต้องการลบ");
	}
	else {
		aValue = xValue.split(',');
		if (confirm("ยืนยันการลบข้อมูล " + aValue.length + " รายการ")) {
			window.location.replace("../../libs/chkBeforeDel.php?tb="+tb+"&id="+xValue+"&ftb="+ftb+"&fid="+fid+"&url="+url); 
		}
	}
}

function delRecordAndImage(tb, id, url) {
	if(confirm("ยืนยันการลบข้อมูล")) {
		window.location.replace("../../libs/delData.php?tb="+tb+"&id="+id+"&url="+url+"&img=true");
	}
}

function delRecordsAndImages(tb, pbox, url) {
	var xValue=checkValues(pbox);
	if (xValue=="") { 
		alert("กรุณาเลือกรายการที่ต้องการลบ");
	}
	else {
		aValue = xValue.split(',');
		if (confirm("ยืนยันการลบข้อมูล " + aValue.length + " รายการ")) {
			window.location.replace("../0library/delData.php?tb="+tb+"&id="+xValue+"&url="+url+"&img=true"); 
		}
	}
}

function delRecordAndImageMaster(tb, id, url) {
	if(confirm("ยืนยันการลบข้อมูล")) {
		window.location.replace("../0library/delData.php?tb="+tb+"&id="+id+"&url="+url+"&img=true&master=true");
	}
}

function delRecordsAndImageMasters(tb, pbox, url) {
	var xValue=checkValues(pbox);
	if (xValue=="") { 
		alert("กรุณาเลือกรายการที่ต้องการลบ");
	}
	else {
		aValue = xValue.split(',');
		if (confirm("ยืนยันการลบข้อมูล " + aValue.length + " รายการ")) {
			window.location.replace("../0library/delData.php?tb="+tb+"&id="+xValue+"&url="+url+"&img=true&master=true"); 
		}
	}
}

function delImage(tb, id, url) {
	if(confirm("ยืนยันการลบข้อมูล")) {
		window.location.replace("../../libs/delImage.php?tb="+tb+"&id="+id+"&url="+url);
	}
}

function oneValues(pbox) {
 var xID="";
 if (pbox) {
 	if (pbox.length==undefined) {
		if (pbox.checked==true) { xID=pbox.value}	
	} else
	 {
	  var nbox=pbox.length; 
	  var iCount=0;
 	   for (var j = 0; j < nbox; j++)  {
		  if (pbox[j].checked==true) {xID=pbox[j].value; iCount = iCount+1;} /*Box Select */
		} /*for loop*/
	 } /*>1*/
 } 
 if (iCount>1) { xID = "-1"};
 return xID;	
}

function clickOne(pbox,purl,pQuerystring,pwidth,pheight,pNoselected,pSelectmore) {
  var xValue=oneValues(pbox);
  if (xValue=="") {alert(pNoselected);}
  else {
	if (xValue =="-1") {alert(pSelectmore);}
	 else {
       if (purl.indexOf("?")==-1) {
			openCenter(purl+"?"+pQuerystring+"="+xValue, "ClickDialog", pheight, pwidth); 
		} else 
		 {
		 	openCenter(purl+"&"+pQuerystring+"="+xValue, "ClickDialog", pheight, pwidth); 
		 } 		
	 }	 
   }	
}

function MO(e)
{
if (!e)
var e=window.event;
var S=e.srcElement;
while (S.tagName!="TR")
{S=S.parentElement;}
if (S.className!="R") { S.className="TR1"; }
}
function MU(e)
{
if (!e)
var e=window.event;
var S=e.srcElement;
while (S.tagName!="TR")
{S=S.parentElement;}
if (S.className!="R") { S.className="P"; }
}
function MO_2(m)
{
while (m.tagName!="TR")
{m=m.parentElement;}
m.className="R";
}
function MU_2(m)
{
while (m.tagName!="TR")
{m=m.parentElement;}
m.className="P";
}
function on(name){
  if (browserOK) {
     for (i = 0; i < objCount; i++) {
      if (document.images[pics[i][2]] != null)
        if (name != pics[i][2]) { 
          document.images[pics[i][2]].src = pics[i][0].src;
        } else {
           document.images[pics[i][2]].src = pics[i][1].src;
        }
    }
  }
}

function off(){
  if (browserOK) {
     for (i = 0; i < objCount; i++) {
      if (document.images[pics[i][2]] != null) 
        document.images[pics[i][2]].src = pics[i][0].src;
    }
  }
}

function GetActivate(id, url) {
	if(confirm("กรุณายืนยันอีกครั้ง")) {
		window.location.replace("../0library/activate.php?id="+id+"&url="+url);
	}
}

function MM_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}
