if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else{// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","../XML/SWAPLANG_FREEDOM.xml",false); xmlhttp.send(); xmlDoc = xmlhttp.responseXML; var codeLang; // Thai var codeLang2; // Thai for ie document mode standards function setLangSwapLang(lang){ if(lang=="eng" || lang=="ENG"){ codeLang = 1; // Eng codeLang2 = 3; // Eng for ie document mode standards }else{ codeLang = 0; // Thai codeLang2 = 1; // Thai for ie document mode standards } } function swLang(key){ var x = xmlDoc.getElementsByTagName(key); if(chkIE() || chkSafari()) { // if ie or safari if(typeof(x[0].childNodes[codeLang].text)=="undefined") { try { document.write(x[0].childNodes[codeLang2].textContent.trim()); } catch(err){} }else{ document.write(x[0].childNodes[codeLang].text.trim()); } }else{ document.write(x[0].children[codeLang].childNodes[0].data.trim()); } } function getSwapLang(key){ var x = xmlDoc.getElementsByTagName(key); if(chkIE() || chkSafari()) { // if ie or safari if(typeof(x[0].childNodes[codeLang].text)=="undefined"){ try{ return x[0].childNodes[codeLang2].textContent.trim(); }catch(err){} }else{ return x[0].childNodes[codeLang].text.trim(); } }else{ return x[0].children[codeLang].childNodes[0].data.trim(); } } function chkIE() { var ua = window.navigator.userAgent; var msie = ua.indexOf("MSIE "); if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)){ // If Internet Explorer, return version number return true; }else{ // If another browser, return 0 return false; } } function chkSafari() { var is_safari = (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1); return is_safari; } if(typeof String.prototype.trim !== 'function') { String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }; }