// JavaScript Document
function createXMLHttpRequest(){
        var xmlHttp = false;  // Ajax
        if (!xmlHttp && typeof XMLHttpRequest != 'undefined') { // Mozilla
            xmlHttp = new XMLHttpRequest();
        } else if (window.ActiveXObject) { // IE
            try {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
            try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
        return xmlHttp;
}

function addCount(SN, DB) {
		var URL = "count.jsp";
		var postData = "sn=" + SN + "&db=" + DB;
        xmlHttp = createXMLHttpRequest();
        xmlHttp.onreadystatechange = function(){ handleStateChange() };
        xmlHttp.open("POST", URL,"false");
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xmlHttp.send(postData);
}

function handleStateChange() {
		var trim_responseText = null;
        	if(xmlHttp.readyState == 4) {
            	if(xmlHttp.status == 200) {	
					trim_responseText = trim(xmlHttp.responseText);	
				}
			}
}

function trim(strvalue) {
        ptntrim = /(^\s*)|(\s*$)/g;
        var val = strvalue.replace(ptntrim,"");
        return val;
}

function keywordAdd(SN) {
		var URL = "kw_count.jsp";
		var postData = "sn=" + SN;
    xmlHttp = createXMLHttpRequest();
    xmlHttp.onreadystatechange = function(){ handleStateChange() };
    xmlHttp.open("POST", URL,"false");
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.send(postData);
}