
 
 function activeArt(tg)   
  {   
    tg.style.backgroundColor = "#EEEEEE";   
  }   
    
  function deactiveArt(tg)   
  {   
    tg.style.backgroundColor = "";   
  }   

  function checkformatemail( f ){
  if ( !(/[0-9a-zA-Z_\.\-]+@[0-9a-zA-Z_\.\-]+\.[a-zA-Z][a-zA-Z]+/ig).test( f ) ){
    return true; 
  } else {
    return false;
  }
}

  function check2value( a , b ){	
        if( a != b ) 
			{
				return true;
		}
		else 
			  {
					return false;
			}
  }


function ckblk(chkval)
{
	if(chkval == "")
		return false;
	else if(chkval.indexOf(' ') == 0)
		return false;
	else if(chkval.indexOf('"') == 0)	 
		return false;
	else if(chkval == "'")	 
		return false;
	else
		return true;
}


function checkformatdate(j_day_,j_month_,j_year_)
		{
			if( isNaN(j_day_) || isNaN(j_year_) || (j_year_ == "" ) )
					{
									return true;	
					}

					if(j_month_ == 2) {
									if( j_day_ > 29 )  {											
												return true;
										}						
							}

						if((j_month_ == 4) || (j_month_ == 6) || (j_month_ == 9) || (j_month_ == 11)  ) {
										if((j_day_ > 30) )  {
												return true;
										}
							}
							else {
										if(j_day_ > 31 )  {
										return true;
										}
								}
				return false;
			}


function popupWindow(link_,winname_,top_,left_,width_,height_)  
	{	
		window.open(link_,winname_,'scrollbars=no,resizable=no,top=' + top_ + ',left=' + left_ + ',width=' + width_ + ',height=' + height_ ); 
	}
	
	function popUpWindowCenter(URLStr, width, height)
	{
		LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
		
		popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+LeftPosition+', top='+TopPosition+',screenX='+LeftPosition+',screenY='+TopPosition+'');

}
	
	function popUpWindowCenter2(URLStr, width, height)
	{
		LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
		
		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='+LeftPosition+', top='+TopPosition+',screenX='+LeftPosition+',screenY='+TopPosition+'');

}

	function popUpWindowCenterHaveMenu(URLStr, width, height)
	{
		LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
		
		popUpWin = open(URLStr, 'popUpWin', 'menubar=yes,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+LeftPosition+', top='+TopPosition+',screenX='+LeftPosition+',screenY='+TopPosition+'');

}

	
		function goclose() 
			{
				   window.opener.location.reload();
					window.close()
			}
				

	
		function Checkall(field) 
		{
					if ( form1.chk.length )
								{
											for (uu = 0; uu < form1.chk.length; uu++)
														 {
													    	  form1.chk[uu].checked = field;
														}   
					}	
					else {
								form1.chk.checked = field;
					}		    
		}
	
	function checkAllForm(chk,field) 
		{
					if ( chk.length )
								{
											for (uu = 0; uu < chk.length; uu++)
														 {
													    	  chk[uu].checked = field;
														}   
					}	
					else {
								chk.checked = field;
					}		    
		}
		
	function checkformchkbox(frm) {
				var checkvar = frm.chk;
				var arrchkvar = frm.arrchk;
				arrchkvar.value = "";
				var check = "";				
				
				if ( checkvar.length )
					{
													
										for (uuu = 0; uuu < checkvar.length; uuu++) {
												if (checkvar[uuu].checked){
													  check = "Y";							 							 
													  arrchkvar.value = arrchkvar.value + "&" + checkvar[uuu].value
												}
										  }
					}	
					else {
					
										if (checkvar.checked){
													  check = "Y";							 							 
													  arrchkvar.value = "&" + checkvar.value
										}
					
					}


			  if (check=="") {
		    alert("กรุณาเลือก Record ที่ต้องการลบ อย่างน้อย 1 Record โดย เลือก ทำเครื่องหมายที่ CheckBox ตรงแถวที่ต้องการลบ");
					    return false;
			  }else{
			  					
			  				 if ( confirm('Do you want to delete this item ?')  )
										{
												return true;
										}   
								else
										{
												return false;
										}
			  }
	}
		
	function checkformchkboxForm() {
				var checkvar = document.form3.chk;
				var arrchkvar = document.form3.arrchk;
				arrchkvar.value = "";
				var check = "";				
				
				if ( checkvar.length )
					{
													
										for (uuu = 0; uuu < checkvar.length; uuu++) {
												if (checkvar[uuu].checked){
													  check = "Y";							 							 
													  arrchkvar.value = arrchkvar.value + "&" + checkvar[uuu].value
												}
										  }
					}	
					else {
					
										if (checkvar.checked){
													  check = "Y";							 							 
													  arrchkvar.value = "&" + checkvar.value
										}
					
					}


			  if (check=="") {
		    alert("กรุณาเลือก Record ที่ต้องการลบ อย่างน้อย 1 Record โดย เลือก ทำเครื่องหมายที่ CheckBox ตรงแถวที่ต้องการลบ");
					    return false;
			  }else{
			  					
			  				 if ( confirm('Do you want to delete this item ?')  )
										{
												return true;
										}   
								else
										{
												return false;
										}
			  }
	}
	
	
	
		
	var uploadWin=0;
	function upload(obj1,obj2,obj3,obj4)
	//function upload(obj1,obj2,obj3)
	{
			  if(uploadWin)
			  {
				if(!uploadWin.closed) uploadWin.close();
			  }
	width = 600;
	height = 450;
	LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	window.param1 = obj1;
	window.param2 = obj2;
	window.param3 = obj3;
	window.param4 = obj4;
	  uploadWin = open('../upload/upload.php', 'uploadWin', 'toolbar=no,location=no,directories=no,status=yes,menub ar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+LeftPosition+', top='+TopPosition+',screenX='+LeftPosition+',screenY='+TopPosition+'');
	}
	
	
	var uploadWinf=0;
	function upload_f(obj1,obj2,obj3,obj4)
	//function upload_f(obj1,obj2,obj3)
	{
			  if(uploadWinf)
			  {
				if(!uploadWinf.closed) uploadWinf.close();
			  }
	width = 600;
	height = 450;
	LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	window.param1 = obj1;
	window.param2 = obj2;
	window.param3 = obj3;
	window.param4 = obj4;
	  uploadWinf = open('../upload/upload_f.php', 'uploadWinf', 'toolbar=no,location=no,directories=no,status=yes,menub ar=no,scrollbars=yes,resizable=no,copyhistory=yes');
	}
	
	
	// ***** at_show_aux *****



function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ***** at_show *****

function at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);
 at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

// ***** at_hide *****

function at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

// ***** at_click *****

function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

// ***** at_attach *****

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name	
function at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  //alert(p.id);alert(c.id);
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;
//alert(p["at_parent"]);alert( c["at_parent"]);
  c.style.position   = "absolute";
  c.style.visibility = "hidden";

  if (cursor != undefined) p.style.cursor = cursor;
//alert(cursor);alert(p.style.cursor);
  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
	 // alert("hover"+p.onmouseover);
      break;
  }
}








