
function showTab(selTab) {
	if (selTab == "tabMV01") {
		document.getElementById("mostRead").style.display = "block";
		document.getElementById("mostCommented").style.display = "none";
		document.getElementById("mostRated").style.display = "none";
		document.getElementById("mostReadImg").src = "/template/ver1-0/images/mostReadAlt.gif";
		document.getElementById("mostReadImg").style.width = "80px";
		document.getElementById("mostReadImg").style.height = "27px";
		document.getElementById("mostCommentedImg").src = "/template/ver1-0/images/mostCommented.gif";
		document.getElementById("mostCommentedImg").style.width = "112px";
		document.getElementById("mostCommentedImg").style.height = "27px";
		document.getElementById("mostRatedImg").src = "/template/ver1-0/images/HighlyRated.gif";
		document.getElementById("mostRatedImg").style.width = "97px";
		document.getElementById("mostRatedImg").style.height = "27px";
	} else {
		if (selTab == "tabMV02") {
			document.getElementById("mostRead").style.display = "none";
			document.getElementById("mostCommented").style.display = "block";
			document.getElementById("mostRated").style.display = "none";
			document.getElementById("mostReadImg").src = "/template/ver1-0/images/mostRead.gif";
			document.getElementById("mostReadImg").style.width = "80px";
			document.getElementById("mostReadImg").style.height = "27px";
			document.getElementById("mostCommentedImg").src = "/template/ver1-0/images/mostCommentedAlt.gif";
			document.getElementById("mostCommentedImg").style.width = "112px";
			document.getElementById("mostCommentedImg").style.height = "27px";
			document.getElementById("mostRatedImg").src = "/template/ver1-0/images/HighlyRated.gif";
			document.getElementById("mostRatedImg").style.width = "97px";
			document.getElementById("mostRatedImg").style.height = "27px";
		} else {
			document.getElementById("mostRead").style.display = "none";
			document.getElementById("mostCommented").style.display = "none";
			document.getElementById("mostRated").style.display = "block";
			document.getElementById("mostReadImg").src = "/template/ver1-0/images/mostRead.gif";
			document.getElementById("mostReadImg").style.width = "80px";
			document.getElementById("mostReadImg").style.height = "27px";
			document.getElementById("mostCommentedImg").src = "/template/ver1-0/images/mostCommented.gif";
			document.getElementById("mostCommentedImg").style.width = "112px";
			document.getElementById("mostCommentedImg").style.height = "27px";
			document.getElementById("mostRatedImg").src = "/template/ver1-0/images/HighlyRatedAlt.gif";
			document.getElementById("mostRatedImg").style.width = "97px";
			document.getElementById("mostRatedImg").style.height = "27px";
		}
	}
}
function createXMLHttpRequestStatistics() {
	var req;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return req;
}
function getAutonomyStatistics(XMLHttpRec, articleIds, divId) {

	XMLHttpRec.onreadystatechange = function () {
	};
	XMLHttpRec.abort();
	var urlMapping = "";
	if (urlMapping == "") {
		urlMapping = "";
	} else {
		urlMapping = "/" + urlMapping;
	}
	var url = urlMapping + "/sectorDataServlet?articleIds=" + articleIds + "&action=statisticsData";
	XMLHttpRec.open("GET", url, true);
	XMLHttpRec.onreadystatechange = function () {
		callbackStatistics(XMLHttpRec, divId);
	};
	XMLHttpRec.send(null);
} // end of function
function callbackStatistics(req, divId) {
	if (req.readyState == 4) {
		if (req.status == 200) {
			if (window.ActiveXObject) {
				msPopulateStatistics(req, divId);
			} else {
				if (window.XMLHttpRequest) {
					nonMSPopulateStatistics(req, divId);
				}
			}
		}
	}
}
function nonMSPopulateStatistics(r, divId) {
// alert("Inside  nonMSPopulate");
	var resp = r.responseText;
//alert("Inside  nonmsPopulate : " + resp);
	var myJSONObject = eval("(" + resp + ")");
	displayStatistics(myJSONObject, divId);
}
function msPopulateStatistics(r, divId) {
// alert("Inside  msPopulate");
	var resp = r.responseText;
// alert("Inside  msPopulate : " + resp);
	var myJSONObject = eval("(" + resp + ")");
	displayStatistics(myJSONObject, divId);
}
function displayStatistics(infoObj, divId) {
	var i;
	var mostHTML = "";
	if (typeof (infoObj.autnResponse) == "undefined") {
		mostHTML += "No Data Found";
		return;
	}
	for (i = 0; i < infoObj.autnResponse.length; i++) {
		var mostId = infoObj.autnResponse[i];
		if (typeof (mostId.articleTitle) != "undefined") {
			mostHTML += "<div class='mostData' style='width:286px;'><span class='mostImage'>";
			mostHTML += "<img src='/template/ver1-0/images/whiteSqure.gif' height='5' width='4' border='0' /></span>";
			mostHTML += "<span class='mostInnerTxt'><a href='" + mostId.articleUrl + "?autnRef=" + mostId.articleReference + "'>" + ((mostId.articleTitle).substring(0, 35)) + "...</a></span></div>";
		}
	}
	document.getElementById(divId).innerHTML = mostHTML;
}


