var http=createRequestObject();

function createRequestObject() {
    var tmpXmlHttpObject;
    
    //depending on what the browser supports, use the right way to create the XMLHttpRequest object
    if (window.XMLHttpRequest) { 
        // Mozilla, Safari would use this method ...
        tmpXmlHttpObject = new XMLHttpRequest();
	
    } else if (window.ActiveXObject) { 
        // IE would use this method ...
        tmpXmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    return tmpXmlHttpObject;
}

function rating(nick_name, type){
	document.getElementById('result_'+type).innerHTML = "";
	if(nick_name == 'yes'){
		document.getElementById('yes_'+type).className = 'rating_yes_click';
		document.getElementById('no_'+type).className = 'rating_no';
	}else{
		document.getElementById('yes_'+type).className = 'rating_yes';
		document.getElementById('no_'+type).className = 'rating_no_click';
	}

	if (http) 
	{
		var url =getBaseURL()+'rating.php?action='+nick_name+'&value='+type;
		var mycontent = '';
		http.open ("GET", url, true);
		http.send (mycontent);
		http.onreadystatechange = function () {
			if (http.readyState == 4) {
				responsestring = http.responseText;
					document.getElementById('yes_'+type).style.display = "none";
					document.getElementById('no_'+type).style.display = "none";		
					//document.getElementById('result_'+type).innerHTML = responsestring;
			}
			
		}			
	}
}


function set_words(value){
	document.getElementById('tag_loc').innerHTML = value;
	document.getElementById('tag_loc').href = getBaseURL()+"/index.php/category/"+value;
}

function getBaseURL() {
    var url = location.href;  // entire url including querystring - also: window.location.href;
    var baseURL = url.substring(0, url.indexOf('/', 14));


    if (baseURL.indexOf('http://localhost') != -1) {
        // Base Url for localhost
        var url = location.href;  // window.location.href;
        var pathname = location.pathname;  // window.location.pathname;
        var index1 = url.indexOf(pathname);
        var index2 = url.indexOf("/", index1 + 1);
        var baseLocalUrl = url.substr(0, index2);

        return baseLocalUrl + "/";
    }
    else {
        // Root Url for domain name
        return baseURL + "/";
    }

}