/* Open new Windows */
function newwin(URLStr,width, height)
{
	  var popUpWin=0;
	  var left = (screen.width/2) - width/2;
	  var top = (screen.height/2) - height/2;
	  if(popUpWin)
	  {
		  if(!popUpWin.closed) popUpWin.close();
	   }
	   popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function popup(URLStr,width,height)
	{
			  var popUpWin=0;
			  var left = (screen.width/2) - width/2;
			  var top = (screen.height/2) - height/2;
			
				  if(popUpWin)
					  {
						if(!popUpWin.closed) popUpWin.close();
					  }
			  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
			  popUpWin.focus();return false;
	}
	function RELOAD(xtime)
	{
	   window.opener.location.reload();
	   setTimeout("self.close()",xtime);
	}

	/* function close windows auto */
	function AUTO_CLOSE(xtime)
	{
	   setTimeout("self.close()",xtime);
	}

	//menu
	function Toggle(item)
		{
			   obj=document.getElementById(item);
			   visible=(obj.style.display!="none")
			   key=document.getElementById("x" + item);
			   if (visible) {
					 obj.style.display="none";
					 key.innerHTML="<img src='../images/arr_up.gif' width='24' height='24' hspace='0' vspace='0' border='0' align='absmiddle' alt='ขยายเมนู'>";
			   } else {
					  obj.style.display="block";
					  key.innerHTML="<img src='../images/arr_down_over.gif' width='24' height='24' hspace='0' vspace='0' border='0' align='absmiddle' alt='ย่อเมนู'>";
			   }
		}
function Expand() {
   divs=document.getElementsByTagName("div");
   for (i=0;i<divs.length;i++) {
     divs[i].style.display="block";
     key=document.getElementById("x" + divs[i].id);
     key.innerHTML="<img src='../images/arr_down_over.gif' width='24' height='24' hspace='0' vspace='0' border='0' align='absmiddle' alt='ย่อเมนู'>";
   }
}

function Collapse() {
   divs=document.getElementsByTagName("div");
   for (i=0;i<divs.length;i++) {
     divs[i].style.display="none";
     key=document.getElementById("x" + divs[i].id);
     key.innerHTML="<img src='../images/arr_up.gif' width='24' height='24' hspace='0' vspace='0' border='0' align='absmiddle' alt='ขยายเมนู'>";
   }
}

function checkAll(formname,checkn, exby) {
  var check=eval("document.forms."+formname+"['"+checkn+"']");
  if(check){
	  for (i = 0; i < check.length; i++)
	  check[i].checked = exby.checked? true:false
  }
}

function AlertMS(text) 
{
	alert(text);
}
function Confirm(link,text) 
{
  if (confirm(text))
     window.location=link
}
  function delConfirm(obj){
	var status=false;
	for(var i=0 ; i < obj.elements.length ; i++ ){
		if(obj[i].type=='checkbox'){
			if(obj[i].checked==true){
				status=true;
			}
		}
	}
	if(status==false){
		alert('กรุณาเลือกข้อมูลที่ต้องการลบ.');
		return false;
	}else{
		if(confirm('คุณมั่นใจในการลบข้อมูล?')){
			return true;
		}else{
			return false;
		}
	}
}