var http = createRequestObject(); var field = ''; function createRequestObject() { if (typeof XMLHttpRequest != 'undefined') { return new XMLHttpRequest(); } else if (window.ActiveXObject) { var aVersions = [ 'MSXML2.XMLHttp.5.0', 'MSXML2.XMLHttp.4.0', 'MSXML2.XMLHttp.3.0', 'MSXML2.XMLHttp', 'Microsoft.XMLHttp' ]; for (var i = 0; i < aVersions.length; i++) { try { var oXmlHttp = new ActiveXObject(aVersions[i]); return oXmlHttp; } catch (oError) { oXmlHttp=null; } } } throw new Error('XMLHttp object could be created.'); } function handleResponse() { try { if((http.readyState == 4)&&(http.status == 200)){ response = http.responseText; field.innerHTML = response; field.scrollIntoView(); if (response == 'OK') { root_id = encodeURIComponent(document.getElementById('root_id').value); num = encodeURIComponent(document.getElementById('num').value); type_comment = encodeURIComponent(document.getElementById('type_comment').value); load_pages('comment', num, root_id, type_comment, 1); } if(!response) window.location.href = root_url; } } catch(e){} finally{} } function load_pages(type,num,apr,id,page,xxx) { field = document.getElementById(type); field.innerHTML = loadingText; http.open('POST', file_default); http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.onreadystatechange = handleResponse; http.send('load_pages=1&type='+type+'&num='+num+'&apr='+apr+'&id='+id+'&page='+page+'&xxx='+xxx); return false; } //####################################### //# CONVERT NON MARK //####################################### function convert_non_mark(str){ str= str.replace(/\u00E1/g,'a'); str= str.replace(/\u00C1/g,'a'); str= str.replace(/\u00E0/g,'a'); str= str.replace(/\u00C0/g,'a'); str= str.replace(/\u1EA3/g,'a'); str= str.replace(/\u1EA2/g,'a'); str= str.replace(/\u00E3/g,'a'); str= str.replace(/\u00C3/g,'a'); str= str.replace(/\u1EA1/g,'a'); str= str.replace(/\u1EA0/g,'a'); str= str.replace(/\u0103/g,'a'); str= str.replace(/\u0102/g,'a'); str= str.replace(/\u1EAF/g,'a'); str= str.replace(/\u1EAE/g,'a'); str= str.replace(/\u1EB1/g,'a'); str= str.replace(/\u1EB0/g,'a'); str= str.replace(/\u1EB3/g,'a'); str= str.replace(/\u1EB2/g,'a'); str= str.replace(/\u1EB5/g,'a'); str= str.replace(/\u1EB4/g,'a'); str= str.replace(/\u1EB7/g,'a'); str= str.replace(/\u1EB6/g,'a'); str= str.replace(/\u00E2/g,'a'); str= str.replace(/\u00C2/g,'a'); str= str.replace(/\u1EA5/g,'a'); str= str.replace(/\u1EA4/g,'a'); str= str.replace(/\u1EA7/g,'a'); str= str.replace(/\u1EA6/g,'a'); str= str.replace(/\u1EA9/g,'a'); str= str.replace(/\u1EA8/g,'a'); str= str.replace(/\u1EAB/g,'a'); str= str.replace(/\u1EAA/g,'a'); str= str.replace(/\u1EAD/g,'a'); str= str.replace(/\u1EAC/g,'a'); str= str.replace(/\u00E9/g,'e'); str= str.replace(/\u00C9/g,'e'); str= str.replace(/\u00E8/g,'e'); str= str.replace(/\u00C8/g,'e'); str= str.replace(/\u1EBB/g,'e'); str= str.replace(/\u1EBA/g,'e'); str= str.replace(/\u1EBD/g,'e'); str= str.replace(/\u1EBC/g,'e'); str= str.replace(/\u1EB9/g,'e'); str= str.replace(/\u1EB8/g,'e'); str= str.replace(/\u00EA/g,'e'); str= str.replace(/\u00CA/g,'e'); str= str.replace(/\u1EBF/g,'e'); str= str.replace(/\u1EBE/g,'e'); str= str.replace(/\u1EC1/g,'e'); str= str.replace(/\u1EC0/g,'e'); str= str.replace(/\u1EC3/g,'e'); str= str.replace(/\u1EC2/g,'e'); str= str.replace(/\u1EC5/g,'e'); str= str.replace(/\u1EC4/g,'e'); str= str.replace(/\u1EC7/g,'e'); str= str.replace(/\u1EC6/g,'e'); str= str.replace(/\u00ED/g,'i'); str= str.replace(/\u00CD/g,'i'); str= str.replace(/\u00EC/g,'i'); str= str.replace(/\u00CC/g,'i'); str= str.replace(/\u1EC9/g,'i'); str= str.replace(/\u1EC8/g,'i'); str= str.replace(/\u0129/g,'i'); str= str.replace(/\u0128/g,'i'); str= str.replace(/\u1ECB/g,'i'); str= str.replace(/\u1ECA/g,'i'); str= str.replace(/\u00F3/g,'o'); str= str.replace(/\u00D3/g,'o'); str= str.replace(/\u00F2/g,'o'); str= str.replace(/\u00D2/g,'o'); str= str.replace(/\u1ECF/g,'o'); str= str.replace(/\u1ECE/g,'o'); str= str.replace(/\u00F5/g,'o'); str= str.replace(/\u00D5/g,'o'); str= str.replace(/\u1ECD/g,'o'); str= str.replace(/\u1ECC/g,'o'); str= str.replace(/\u01A1/g,'o'); str= str.replace(/\u01A0/g,'o'); str= str.replace(/\u1EDB/g,'o'); str= str.replace(/\u1EDA/g,'o'); str= str.replace(/\u1EDD/g,'o'); str= str.replace(/\u1EDC/g,'o'); str= str.replace(/\u1EDF/g,'o'); str= str.replace(/\u1EDE/g,'o'); str= str.replace(/\u1EE1/g,'o'); str= str.replace(/\u1EE0/g,'o'); str= str.replace(/\u1EE3/g,'o'); str= str.replace(/\u1EE2/g,'o'); str= str.replace(/\u00F4/g,'o'); str= str.replace(/\u00D4/g,'o'); str= str.replace(/\u1ED1/g,'o'); str= str.replace(/\u1ED0/g,'o'); str= str.replace(/\u1ED3/g,'o'); str= str.replace(/\u1ED2/g,'o'); str= str.replace(/\u1ED5/g,'o'); str= str.replace(/\u1ED4/g,'o'); str= str.replace(/\u1ED7/g,'o'); str= str.replace(/\u1ED6/g,'o'); str= str.replace(/\u1ED9/g,'o'); str= str.replace(/\u1ED8/g,'o'); str= str.replace(/\u00FA/g,'u'); str= str.replace(/\u00DA/g,'u'); str= str.replace(/\u00F9/g,'u'); str= str.replace(/\u00D9/g,'u'); str= str.replace(/\u1EE7/g,'u'); str= str.replace(/\u1EE6/g,'u'); str= str.replace(/\u0169/g,'u'); str= str.replace(/\u0168/g,'u'); str= str.replace(/\u1EE5/g,'u'); str= str.replace(/\u1EE4/g,'u'); str= str.replace(/\u01B0/g,'u'); str= str.replace(/\u01AF/g,'u'); str= str.replace(/\u1EE9/g,'u'); str= str.replace(/\u1EE8/g,'u'); str= str.replace(/\u1EEB/g,'u'); str= str.replace(/\u1EEA/g,'u'); str= str.replace(/\u1EED/g,'u'); str= str.replace(/\u1EEC/g,'u'); str= str.replace(/\u1EEF/g,'u'); str= str.replace(/\u1EEE/g,'u'); str= str.replace(/\u1EF1/g,'u'); str= str.replace(/\u1EF0/g,'u'); str= str.replace(/\u00FD/g,'y'); str= str.replace(/\u00DD/g,'y'); str= str.replace(/\u1EF3/g,'y'); str= str.replace(/\u1EF2/g,'y'); str= str.replace(/\u1EF7/g,'y'); str= str.replace(/\u1EF6/g,'y'); str= str.replace(/\u1EF9/g,'y'); str= str.replace(/\u1EF8/g,'y'); str= str.replace(/\u1EF5/g,'y'); str= str.replace(/\u1EF4/g,'y'); str= str.replace(/\u0110/g,'d'); str= str.replace(/\u0111/g,'d'); return str; } //####################################### //# SEARCH //####################################### function do_search() { keyword = document.getElementById('keyword').value; keyword = convert_non_mark(keyword); if (!keyword) alert(keyword_empty); else window.location.href = link_search+keyword+web_type; return false; } //####################################### //# COUNT WORDS //####################################### var submitcount=0; function checkSubmit() { if (submitcount == 0){ submitcount++; document.Surv.submit(); } } function wordCounter(field, countfield, maxlimit) { wordcounter=0; for (x=0;x 250) {field.value = field.value.substring(0, x);} else {countfield.value = maxlimit - wordcounter;} } } function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) {field.value = field.value.substring(0, maxlimit);} else {countfield.value = maxlimit - field.value.length;} } //####################################### //# COMMENT //####################################### function comment() { root_id = encodeURIComponent(document.getElementById('root_id').value); type_id = encodeURIComponent(document.getElementById('type_id').value); num = encodeURIComponent(document.getElementById('num').value); comment_poster = encodeURIComponent(document.getElementById('comment_poster').value); comment_sec = encodeURIComponent(document.getElementById('comment_sec').value); comment_content = encodeURIComponent(document.getElementById('comment_content').value); type_comment = encodeURIComponent(document.getElementById('type_comment').value); field = document.getElementById('comment_loading'); field.innerHTML = loadingText; field.style.display = 'block'; http.open('POST', file_default); http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.onreadystatechange = handleResponse; http.send('comment=1&root_id='+root_id+'&type_id='+type_id+'&num='+num+'&comment_sec='+comment_sec+'&comment_poster='+comment_poster+'&comment_content='+comment_content+'&type_comment='+type_comment); return false; } //####################################### //# RATING //####################################### function rating(root_id,star,type) { field = document.getElementById('rating_field'); field.innerHTML = loadingText; http.open('POST', file_default); http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.onreadystatechange = handleResponse; http.send(type+'=1&root_id='+root_id+'&star='+star); return false; } // pre-fetch image (new Image()).src = RATE_OBJECT_IMG; (new Image()).src = RATE_OBJECT_IMG_HALF; (new Image()).src = RATE_OBJECT_IMG_BG; function show_star(starNum,rate_text) { remove_star(); document.getElementById('rate_text_d').innerHTML = rate_text; full_star(starNum); } function full_star(starNum) { for (var i=0; i < starNum; i++) document.getElementById('star'+ (i+1)).src = RATE_OBJECT_IMG; } function remove_star() { for (var i=0; i < 5; i++) document.getElementById('star' + (i+1)).src = RATE_OBJECT_IMG_BG; // RATE_OBJECT_IMG_REMOVED; } function remove_all_star() { for (var i=0; i < 5; i++) document.getElementById('star' + (i+1)).src = RATE_OBJECT_IMG_BG; // RATE_OBJECT_IMG_REMOVED; document.getElementById('rate_text_d').innerHTML = 'Bình Chọn'; } function show_rating_process() { if(document.getElementById('rating_process')) document.getElementById('rating_process').style.display = 'block'; if(document.getElementById('rate_s')) document.getElementById('rate_s').style.display = 'none'; } function hide_rating_process() { document.getElementById('rating_process').style.display = 'none'; if(document.getElementById('rate_s')) document.getElementById('rate_s').style.display = 'block'; } //####################################### //# GIFT //####################################### function gift(url) { field = document.getElementById('gift_field'); field.innerHTML = ''; return false; } //####################################### //# BROKEN //####################################### function broken(x_id,y_id,type) { field = document.getElementById('broken_field'); field.innerHTML = loadingText; http.open('POST', file_default); http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.onreadystatechange = handleResponse; http.send(type+'=1&x_id='+x_id+'&y_id='+y_id); return false; } //####################################### //# WATCH //####################################### function _watch(root_id,type) { field = document.getElementById('watch_field'); field.innerHTML = loadingText; http.open('POST', file_default); http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.onreadystatechange = handleResponse; http.send(type+'=1&root_id='+root_id); return false; } //####################################### //# BOOKMARK SITE //####################################### function bookmarksite(title,url){ if (window.sidebar) // firefox window.sidebar.addPanel(title, url, ""); else if(window.opera && window.print){ // opera var elem = document.createElement('a'); elem.setAttribute('href',url); elem.setAttribute('title',title); elem.setAttribute('rel','sidebar'); elem.click(); } else if(document.all)// ie window.external.AddFavorite(url, title); }