var uagent=navigator.userAgent.toLowerCase();var is_safari=((uagent.indexOf('safari')!=-1)||(navigator.vendor=="Apple Computer, Inc."));var is_opera=(uagent.indexOf('opera')!=-1);var is_webtv=(uagent.indexOf('webtv')!=-1);var is_ie=((uagent.indexOf('msie')!=-1)&&(!is_opera)&&(!is_safari)&&(!is_webtv));var is_ie4=((is_ie)&&(uagent.indexOf("msie 4.")!=-1));var is_ie7=((is_ie)&&(uagent.indexOf("msie 7.")!=-1));var is_moz=(navigator.product=='Gecko');var is_ns=((uagent.indexOf('compatible')==-1)&&(uagent.indexOf('mozilla')!=-1)&&(!is_opera)&&(!is_webtv)&&(!is_safari));var is_ns4=((is_ns)&&(parseInt(navigator.appVersion)==4));var is_kon=(uagent.indexOf('konqueror')!=-1);var is_win=((uagent.indexOf("win")!=-1)||(uagent.indexOf("16bit")!=-1));var is_mac=((uagent.indexOf("mac")!=-1)||(navigator.vendor=="Apple Computer, Inc."));function tag(tag,value){document.getElementById("menucolor").innerHTML = "";document.getElementById("menusize").innerHTML = "";this.starttag = '';this.endtag = '';if (tag == 'bold' ) { this.starttag = '[b]'; }if (tag == 'italic' ) { this.starttag = '[i]'; }if (tag == 'underline' ) { this.starttag = '[u]'; }if (tag == 'strikethrough' ) { this.starttag = '[s]'; }if (tag == 'superscript' ) { this.starttag = '[sup]'; }if (tag == 'subscript' ) { this.starttag = '[sub]'; }if (tag == 'justifyleft' ) { this.starttag = '[left]'; }if (tag == 'justifycenter' ) { this.starttag = '[center]'; }if (tag == 'justifyright' ) { this.starttag = '[right]'; }if (tag == 'img' ) { this.starttag = '[img]'; }if (tag == 'link' ) { this.starttag = '[url]'; }if (tag == 'youtube' ) { this.starttag = '[youtube]'; }if (tag == 'mthai' ) { this.starttag = '[mthai]'; }if (tag == 'quote' ) { this.starttag = '[quote]'; }if (tag == 'undo' ) { this.starttag = ''; }if (tag == 'redo' ) { this.starttag = ''; }if (tag == 'unlink' ) { this.starttag = ''; }if (tag == 'forecolor' ) { this.starttag = '[color='+value+']'; this.endtag = '[/color]';}if (tag == 'fontsize' ) { this.starttag = '[size='+value+']'; this.endtag = '[/size]';}if (tag == 'space' ) { this.starttag = ''; this.endtag = '[space]'; addtag('');}if ( this.starttag){	if(!this.endtag){this.endtag = this.starttag.replace(/\[/g,"[/"); }	if(this.is_moz || this.is_opera){ var startselection = document.getElementById('textarea').selectionStart; var endselection = document.getElementById('textarea').selectionEnd; var selection = document.getElementById('textarea').value.substr(startselection, endselection-startselection);	}else{ selection = document.selection.createRange().text; }	if(selection){addtag(selection);	}else{showpop(this.starttag);}}}function showpop(starttag){if (starttag == '[url]' ) { label = 'ใส่ URL ที่คุณต้องการสร้างเป็นลิงค์'; }if (starttag == '[img]' ) { label = 'ใส่ URL ของรูปที่คุณต้องการให้แสดงในคำตอบของคุณ'; }if (starttag == '[quote]' ) { label = 'ใส่ข้อความที่คุณต้องการอ้างอิง'; }if (starttag == '[b]' ) { label = 'ใส่ข้อความที่คุณต้องการทำเป็นตัวหนา'; }if (starttag == '[i]' ) { label = 'ใส่ข้อความที่คุณต้องการทำเป็นตัวเอียง'; }if (starttag == '[u]' ) { label = 'ใส่ข้อความที่คุณต้องการให้มีเส้นใต้'; }if (starttag == '[s]' ) { label = 'ใส่ข้อความที่คุณต้องการให้มีเส้นขั้น'; }if (starttag == '[sup]' ) { label = 'ใส่ข้อความที่คุณต้องการให้เป็นตัวยก'; }if (starttag == '[sub]' ) { label = 'ใส่ข้อความที่คุณต้องการให้เป็นตัวห้อย'; }if (starttag == '[left]' ) { label = 'ใส่ข้อความที่คุณต้องการจัดชิดซ้าย'; }if (starttag == '[center]' ) { label = 'ใส่ข้อความที่คุณต้องการจัดกลาง'; }if (starttag == '[right]' ) { label = 'ใส่ข้อความที่คุณต้องการจัดชิดขวา'; }if (starttag == '[youtube]' ) { label = 'ใส่URL ของ youtube เพื่อแสดง clip'; }if (starttag == '[mthai]' ) { label = 'ใส่URL ของ mthai เพื่อแสดง clip'; }if (starttag == '[quote]' ) { label = 'ใส่ ข้อความที่ต้องการอ้างอิง'; }if (starttag == '[url]' ) { var urllink=window.prompt('Enter URL for link','http://'); }if (endtag == '[/color]' ) { label = 'ใส่ข้อความที่ต้องการให้แสดงเป็นสี '; }if (endtag == '[/size]' ) { label = 'ใส่ข้อความที่ต้องการกำหนดขนาด'; }var temp = window.prompt(label,''); if(temp){	temp = temp.replace(/^\s*|\s*$/g,""); /*trim*/	addtag(temp,urllink);}}function addtag(text,urllink){	var txtarea = document.getElementById('textarea');	if(text == "is_emo") { text = "[:"+urllink+":]";}	else if(urllink){	text =  "[url="+urllink+"]"+text+this.endtag;} 	else {	text =  this.starttag+text+this.endtag; 	}	if (this.is_ie) {if( !document.getElementById('textarea').focus() ) document.getElementById('textarea').focus();        document.selection.createRange().text=text;	} else {var startselection = document.getElementById('textarea').selectionStart; var endselection = document.getElementById('textarea').selectionEnd; var textbefor = document.getElementById('textarea').value.substr(0, startselection);var textafter = document.getElementById('textarea').value.substr(endselection);document.getElementById('textarea').value = textbefor +text +textafter;	}}function showmenu(type){	if(type == "color"){var color = ['000000','666666','999999','BBBBBB','006600','008800','00BB00','BBAA00','994400','CC4400','FF6600','CC7700','880000','FF0000','FF4444','FF0066','6600FF','8800FF','BB00FF','FF00FF','0000AA','0000FF','0088FF','00AADD'];var colorbox = "<div style='width:88px;position:absolute;border:1px solid #999999;background-color:#F5F5F5;padding:2px;')'>";for (var i in color) {	colorbox +=  "<img src='image/blank.gif' width='20' height='15' style='margin:1px;background:#"+color[i]+";cursor:hand;cursor:pointer;' alt='' onclick='tag(\"forecolor\",\""+color[i]+"\")' />";}colorbox +=  "<div style='text-align:right;'><img src='image/icon_close.gif' style='width:32px;height:12px;margin-top:2px;cursor:hand;cursor:pointer;' onclick='hidemenu()'></div></div>";document.getElementById("menucolor").innerHTML = colorbox;	}	if(type == "size"){var sizebox = "<div style='width:40px;position:absolute;border:1px solid #999999;background-color:#F5F5F5;padding:2px;'>";for (i=1;i<=7;i++){	sizebox  += "<div style='border-bottom:1px solid #CCCCCC;text-align:center;'><a href='javascript:tag(\"fontsize\",\""+i+"\")' style='display:block;cursor:hand;cursor:pointer;'><font size='"+i+"'>"+i+"</font></a></div>";}sizebox  += "<div style='text-align:center;'><img src='image/icon_close.gif' style='width:32px;height:12px;margin-top:2px;cursor:hand;cursor:pointer;' onclick='hidemenu()'></div></div>";document.getElementById("menusize").innerHTML = sizebox;	}}function hidemenu(){	document.getElementById("menusize").innerHTML = "";	document.getElementById("menucolor").innerHTML = "";}function validate(){	 if (document.post.name.value == "") {	alert("กรุณากรอก ชื่อผู้ตอบ กระทู้");	document.post.name.focus();	return false;     }	 if (document.post.captchanum.value == "") {	alert("กรุณากรอกตัวเลข 4 หลัก ตามภาพ");	document.post.captchanum.focus();	return false;     }	 if (document.post.note.value == "") {	alert("กรุณาใส่รายละเอียดการตอบกระทู้");	document.post.note.focus();	return false;     }}