function rateBlog(blogid) {
    
	var http_request = false;
	var url = "ajax/rate-blog.asp?b="+blogid;
	
    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    http_request.onreadystatechange = function() { submitRating(http_request); };
    http_request.open('GET', url, true);
    http_request.send(null);

}

function submitRating(http_request) {
     
     if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            var xmldoc = http_request.responseXML;
            
			// check for the xml node called "blog"
			if (xmldoc.getElementsByTagName('blog')[0]) {
				var blog = xmldoc.getElementsByTagName('blog');
				var avgRating = blog[0].childNodes[0].nodeValue;
				var blogid = blog[0].getAttribute('id');
				updateBlogRating(avgRating, blogid);
			}
			else //otherwise usr is not an active member
				{
				var user = xmldoc.getElementsByTagName('user');
				var isMember = user[0].getAttribute('member');
				var isActive = user[0].getAttribute('active');

				if (isMember) {
					window.location.href = "member_subscription.asp";
				}
			}
            
        } else {
            alert('Sorry, there was a problem with the request.');
        }
    }
}

function updateBlogRating(avgRating, blogid) {
	var isIE = true;
	if (window.XMLHttpRequest) {isIE = false;}
	
	var blograting = "blog" + blogid + "rating";
	//var ratingWidth = parseInt(avgRating * 25);
	var ratingWidth = parseInt(1 * 25);
	var stars = document.getElementById(blograting);
	if (isIE) {
		stars.style.width = ratingWidth;
	}
	else {
		sa(stars, "style", "width:"+ratingWidth+"px;");
	}
	//alert('Your rating has been submitted!');
	document.getElementById("VoteCount").innerHTML = avgRating;
}

// instead of setAttribute
function sa(obj,attr,val) {
    obj.setAttribute(attr,val);
}