function magicin(obj){
	if(obj.value == obj.defaultValue){
		obj.value = "";
	}
}

function magicout(obj){
	if(obj.value == ""){
		obj.value = obj.defaultValue;
	}
}

function diffTime(t1, t2){
		var c = Math.abs(t1-t2);

		var day = 24*60*60*1000;
		var str = "";
		if(c>day){
			str = "more than a day";
		}else{
			ms = c%1000;
			s = Math.floor((c%60000)/1000);
			m = Math.floor((c%3600000)/60000);
			h = Math.floor((c%day)/3600000);
			if(h>0){
				var ht = new String(h);
				str = "ประมาณ " + ht + " ชั่วโมง";
			}else if(m>0){
				var mt = new String(m);
				str = "ประมาณ " + mt + " นาที";
			}else if(s>0){
				var st = new String(s);
				str = "ประมาณ " + st + " วินาที";
			}else{
				str = "น้อยกว่าวินาที";
			}
		}
		//alert(t1.toString() + "\n" + str);
		return  str;
	}

function toDate(str){
	// This function only for YYYY-MM-DD HH:MM:SS 
	str = str.replace(/[\:\-]/gi, ' ');
	var a = str.split(" ");
	return new Date(a[0], a[1]-1, a[2], a[3], a[4], a[5]);
}

function gotoProfile(){
	if((!userinfo) || (userinfo.mem_id<1)){
		alert("กรุณาล๊อกอิน");
		return;
	}
	location.href = "/myroom/action";
}