

function set_obj_val(obj, val){
	document.getElementById(obj).value = val;
}
function get_obj_val(obj){
	return document.getElementById(obj).value;
}
function set_obj_html(obj, val){
	document.getElementById(obj).innerHTML = val;
}
function get_obj_html(obj){
	return document.getElementById(obj).innerHTML;
}
function set_obj_disabled(obj, val){
	document.getElementById(obj).disabled = val;
}
function set_obj_checked(obj, val){
	document.getElementById(obj).checked = val;
}
function get_obj_class(obj){
	return document.getElementById(obj).className;
}
function set_obj_class(obj, val){
	document.getElementById(obj).className	= val;
}	
function set_display(obj, val){
	document.getElementById(obj).style.display	= val;
}
function set_focus(obj){
	document.getElementById(obj).focus();
}
function window_location(url){
	window.location = url;
}
function window_reload(){
	window.location.reload();	
}	
function disable_button(obj){
	set_obj_disabled(obj,true);
}
function enable_button(obj){
	set_obj_disabled(obj,false);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function replaceAll(OldString,FindString,ReplaceString) {  
	var SearchIndex = 0;  
	var NewString = "";   
	while (OldString.indexOf(FindString,SearchIndex) != -1) {  
		NewString += OldString.substring(SearchIndex,OldString.indexOf(FindString,SearchIndex));  
		NewString += ReplaceString;  
		SearchIndex = (OldString.indexOf(FindString,SearchIndex) + FindString.length);   
	}  
	NewString += OldString.substring(SearchIndex,OldString.length);  
	return NewString;  
}
function chkDate(elemDD,elemMM,elemYY){
	
	var loop,show,day,month,year
	
	day=document.getElementById(elemDD).value;
	month=document.getElementById(elemMM).value;
	year=document.getElementById(elemYY).value;
	
	if(month=="2"){

		if(((year%4==0) && (year%100!=0)) || (year%400==0)){
			loop=29;
		}else{ 
			loop=28;
		}	
		
	}else if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){
		loop=31;
	}else{
		loop=30;
	}
	
	document.getElementById(elemDD).length=0;
	for(i=1; i<=loop; i++){
		show=""+i;
		if(show.length<2) show="0"+show;
		
		document.getElementById(elemDD)[i-1] = new Option(show,i);		
		if(i==day){
			document.getElementById(elemDD)[i-1].selected=true;
		}
	}	
	return true;
}
function popupImage(url_popup, title_popup , w , h) {											
	var win = new Window({	
						 	className: "dialog",
							width:w,
							height:h,
							zIndex: 100,
							resizable: true,
							title: title_popup,						
							url: url_popup ,
							showEffect:Effect.BlindDown,
							hideEffect: Effect.SwitchOff,
							draggable:true,
							wiredDrag: true							
							});
	win.showCenter();
}
function movePageGame(page, cid, keyword){
	if(keyword){
		var url = page + '?page=1&cid=' + cid + '&keyword=' + encodeURIComponent(keyword);
	} else{
		var url = page + '?page=1&cid=' + cid;
	}
	window_location(url);
}
function movePageLesson(page, cid, sid, keyword){
	if(keyword){
		var url = page + '?page=1&cid=' + cid + '&sid=' + sid + '&keyword=' + encodeURIComponent(keyword);
	} else{
		var url = page + '?page=1&cid=' + cid + '&sid=' + sid;
	}
	window_location(url);
}
function delCart(shop_id, product_id){
	if(confirm('คุณต้องการลบรายการสินค้าที่นี้ออกจากตะกร้าสินค้า')){
		xajax_delCart(shop_id, product_id);	
	}
}