// NOTE: a commented, unobfuscated version of this code is at:
// http://slice-of-thai.com/util.full.js   License for this code:
//
// If you use this code, in part or in full, you must include a prominent
// notice to that effect in the end-user-visible portion of your website
// or application (or your API documentation, for libraries only) that
// includes a link to:
//
//    http://slice-of-thai.com/
//
// along with the other information (such as the copyright statement)
// required by the GNU Affero General Public License.
//
// Copyright 2008 Chris Pirazzi chris@pirazzi.net slice-of-thai.com
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You can find a copy of the GNU Affero General Public License
// at <http://lurkertech.com/agpl-3.0.txt> and also at
// <http://www.gnu.org/licenses/>.
//
// If you use this code, please host your own copy of this file
// rather than cross-linking to slice-of-thai.com.  The copy on
// slice-of-thai.com may be removed, renamed or modified at any
// time.
//

var user_agent=navigator.userAgent.toLowerCase();var is_msie=(user_agent.indexOf("msie")!=-1)&&(user_agent.indexOf("opera")==-1);function ei(A){return document.getElementById(A)}function get_class_style(C){for(var A=0;A<document.styleSheets.length;A++){if(document.styleSheets[A].rules){for(var B=0;B<document.styleSheets[A].rules.length;B++){if(document.styleSheets[A].rules[B].selectorText=="."+C){return document.styleSheets[A].rules[B]}}}else{if(document.styleSheets[A].cssRules){for(var B=0;B<document.styleSheets[A].cssRules.length;B++){if(document.styleSheets[A].cssRules[B].selectorText=="."+C){return document.styleSheets[A].cssRules[B]}}}}}return null}function get_cookie(B){var A=document.cookie.match("(^|;) ?"+B+"=([^;]*)(;|$)");if(A){return(unescape(A[2]))}else{return null}}function set_cookie(B,G,I,F,H,J,E,A){var D=B+"="+escape(G);if(I){var C=new Date(I,F,H);D+="; expires="+C.toGMTString()}if(J){D+="; path="+escape(J)}if(E){D+="; domain="+escape(E)}if(A){D+="; secure"}document.cookie=D}function assert(A){if(!A){alert("assertion failure")}}function is_dom_node(A){return("object"==typeof (A))&&("nextSibling" in A)}function appl(B,A){return B(A)}function telt(A){return document.createTextNode(A)}function elt(){var H=Array.prototype.slice.call(arguments);var J=H.shift();assert("string"==typeof (J));var I=H.shift();assert(undefined!==I&&"object"==typeof (I));var C=(H.length>0&&"function"==typeof (H[0]))?H.shift():undefined;assert(undefined===C||"function"==typeof (C));var B=H.shift();assert(0===H.length);if(is_msie){if(I.hasOwnProperty("name")){J="<"+J+' name="'+I.name+'">'}}var E=document.createElement(J);for(var G in I){if(!I.hasOwnProperty(G)){continue}E.setAttribute(G,I[G],0)}E._tips={};if(undefined!==B){if(!(B instanceof Array)){B=[B]}assert(B instanceof Array);for(var F=0;F<B.length;F++){var D=B[F];assert(undefined!==D);if(!is_dom_node(D)){assert("string"==typeof (D)||"number"==typeof (D));D=document.createTextNode(D)}assert("object"==typeof (D));assert(is_dom_node(D));E.appendChild(D);if(undefined!==D._tips){for(var A in D._tips){if(!D._tips.hasOwnProperty(A)){continue}E._tips[A]=D._tips[A]}}}}if(undefined!==C){C(E)}return E}function get_itip(A,B){while(undefined!==A){if(A.hasOwnProperty("_tips")&&A._tips.hasOwnProperty(B)){return A._tips[B]}A=A.parentNode}assert(0)}var current_sound_button_span_id;function set_fake_sound_button(E,C){var D=ei(E);while(null!==D.firstChild){D.removeChild(D.firstChild)}if(undefined!==D.sound_url){C=D.sound_url}else{assert(undefined!==C);D.sound_url=C}var A="";var B;if(is_msie){B=document.createElement("span");B.style.display="inline-block";B.style.position="relative";B.style.height="17px";B.style.width="17px";B.style.verticalAlign="baseline";B.style.margin="0px 0px 5px 0px";B.style.padding="0px 0px 0px 0px";B.style.border="0px";B.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+A+"/playbutton.png');"}else{B=document.createElement("img");B.src=A+"/playbutton.png";B.width=17;B.height=17;B.border=0}B.onclick=function(){if(undefined!==current_sound_button_span_id){set_fake_sound_button(current_sound_button_span_id)}var G=A+"/musicplayer_f6.swf?song_url="+C+"&autoplay=true&autoload=true";var F=new SWFObject(G,"so"+E,"17","17","6");F.addVariable("movie",G);F.write(E);current_sound_button_span_id=E};D.appendChild(B)}function ts_fs_get(){var A=get_class_style("ts").style.fontSize;A=A.replace("%","");A=A-0;return A}function ts_fs_eset(A){if(0===A){A=136}set_cookie("ts_fs",A,undefined,undefined,undefined,"/",undefined,undefined);get_class_style("ts").style.fontSize=A+"%"}function ts_fs_set(B){var A=ei("ts_fs_i");if(null!==A){A.value=B}ts_fs_eset(B)}function ts_fs_adj(A){ts_fs_set(ts_fs_get()+4*A)}function ts_fs_set_default(){var B=ts_fs_get();var A=get_cookie("ts_fs");if(null!==A){B=A}ts_fs_set(B)}var font_test_string="font_test:ABCDEFGHIJKLMNOpqrstuvwxyz()[]{}";var base_font="cursive";var base_width;var base_height;var test_div;var test_span;function has_font(C){var B=document.getElementsByTagName("body")[0];if(undefined===test_div){test_div=document.createElement("div");test_span=document.createElement("span");test_div.appendChild(test_span);test_div.style.fontFamily=base_font;test_span.style.fontFamily=base_font;test_span.style.fontSize="100px";test_span.innerHTML=font_test_string;B.appendChild(test_div);base_width=test_span.offsetWidth;base_height=test_span.offsetHeight;B.removeChild(test_div)}B.appendChild(test_div);test_span.style.fontFamily=C+", "+base_font;var D=test_span.offsetWidth;var A=test_span.offsetHeight;B.removeChild(test_div);return !(D==base_width&&A==base_height)}function detect_dotted_circle(B){var A=document.getElementsByTagName("body")[0];var C;C=document.createElement("span");C.style.fontFamily=B;C.style.fontSize="100px";C.innerHTML="ก็";A.appendChild(C);var D=C.offsetWidth;A.removeChild(C);C.innerHTML="-็";A.appendChild(C);var E=C.offsetWidth;A.removeChild(C);return(E>1.5*D)}var ts_ff_list=["Arial Unicode MS","Tahoma","Microsoft Sans Serif","Thonburi","Lucida Grande","Silom","Ayuthaya","Sathu","Krungthep","Garuda","Kinnari","Loma","Norasi","Purisa","Sawasdee","Tlwg Typist","TlwgMono","TlwgTypewriter","Umpush","Waree","ST-TT-Garuda","ST-TT-Garuda Oblique","ST-TT-Kinnari","ST-TT-Kinnari Oblique","ST-TT-Loma","ST-TT-Loma Oblique","ST-TT-Norasi","ST-TT-Norasi Oblique","ST-TT-Tlwg Typist","ST-TT-Tlwg Typist Oblique","ST-TT-TlwgMono","ST-TT-TlwgMono Oblique","ST-TT-TlwgTypewriter","ST-TT-TlwgTypewriter Oblique","ST-TT-Umpush","ST-TT-Umpush Light Oblique","ST-TT-Umpush Light","ST-TT-Umpush Oblique","ST-TT-Waree","ST-TT-Waree Oblique"];function ts_ff_set(A){var D=ts_ff_list[A];set_cookie("ts_ff",D,undefined,undefined,undefined,"/",undefined,undefined);var B=D+", Garuda, Arial Unicode MS, Thonburi, Tahoma, Lucida Grande, Arial, sans-serif";get_class_style("ts").style.fontFamily=B;var C=ei("ts_ff_rb_"+A);if(null!==C){C.checked=true}if(detect_dotted_circle(D)){get_class_style("ts_dc0").style.display="none";get_class_style("ts_dc1").style.display="inline"}else{get_class_style("ts_dc0").style.display="inline";get_class_style("ts_dc1").style.display="none"}}function ts_ff_set_default(){var A;var D=ei("ts_ff_tbody");if(null!==D){while(null!==D.firstChild){D.removeChild(D.firstChild)}}for(var E=0;E<ts_ff_list.length;E++){var C=ts_ff_list[E];if(!has_font(C)){continue}if(undefined===A){A=E}if(C.search(/garuda/i)>=0){var B=ei("ts_ff_garuda");if(null!==B){B.style.display="none"}}if(null===D){continue}var H=elt("tr",{id:"ts_ff_tr_"+E,valign:"middle"},[elt("td",{bgcolor:"#eeeeee"},function(I){I.noWrap=true},elt("input",{type:"radio",name:"ts_ff",id:"ts_ff_rb_"+E},function(J){var I=E;J.onclick=function(){ts_ff_set(I)}})),elt("th",{bgcolor:"#eeeeee"},function(I){I.noWrap=true},C),elt("td",{width:"100%"},function(I){I.noWrap=true;I.className="ts";I.style.fontFamily=C},"คุณ เก็บ เสื้อ ไว้ ไหน")]);D.appendChild(H)}if(undefined===A){var F=ei("ts_ff_error");if(null!==F){F.style.display="block"}var B=ei("ts_ff_garuda");if(null!==B){B.style.display="none"}A=0}var G=get_cookie("ts_ff");if(null!==G){for(var E=0;E<ts_ff_list.length;E++){if(G==ts_ff_list[E]){A=E;break}}}ts_ff_set(A)}var idx_to_token=["1","0","7","2","3","8","6","10","9","4","11","5"];function tp_check_cookie(C){var B=idx_to_token[C];var A=get_cookie("tp"+B);var D;if("true"==A){D=true}else{if("false"==A){D=false}else{D=(0===C)}}return D}function tp_ch(){var D=false;for(var C=0;C<12;C++){var B=idx_to_token[C];var F=ei("tp_cb_"+B);var E;if(null===F){E=tp_check_cookie(C)}else{E=F.checked}if(E){get_class_style("tp"+B).style.display="inline";get_class_style("tps"+B).style.display=(D?"inline":"none");D=true}else{get_class_style("tp"+B).style.display="none";get_class_style("tps"+B).style.display="none"}set_cookie("tp"+B,E,undefined,undefined,undefined,"/",undefined,undefined)}var A=ei("tp_none_selected");if(null!==A){A.style.display=(D?"none":"inline")}}function set_tp_cb_default(B){var C=tp_check_cookie(B);var A=idx_to_token[B];ei("tp_cb_"+A).checked=C};