String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function showContainer(which) {
	document.getElementById(which).style.display = 'block';
}

function hideContainer(which) {
	document.getElementById(which).style.display = 'none';
}

function ajaxCaller(url,where) {
	var xmlHttp;
	try {
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	if (where != '') {
		document.getElementById(where).innerHTML = '<div class="loading">Va rugam asteptati...</div>';
		xmlHttp.onreadystatechange = function() {
			if(xmlHttp.readyState == 4) {
				document.getElementById(where).innerHTML = xmlHttp.responseText;
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function ToggleMostRead(channel,time) {
	for(i=1; i<=3; i++) {
		if (i == time) {
			var divDisplay = document.getElementById("contentArea_"+channel+"_"+time);
			var spanDisplay = document.getElementById("mostread_"+channel+"_"+time);
			if (divDisplay.style.display == "block") {
				divDisplay.style.display = "none";
				document.getElementById("mostread_"+channel+"_"+time).setAttribute("class", "inactive_mostread"); 
				document.getElementById("mostread_"+channel+"_"+time).setAttribute("className", "inactive_mostread"); 
			}
			else {
				divDisplay.style.display = "block";
				document.getElementById("mostread_"+channel+"_"+time).setAttribute("class", "active_mostread"); 
				document.getElementById("mostread_"+channel+"_"+time).setAttribute("className", "active_mostread"); 
			}
		}
		else {
			document.getElementById("contentArea_"+channel+"_"+i).style.display = "none";
			document.getElementById("mostread_"+channel+"_"+i).setAttribute("class", "inactive_mostread"); 
			document.getElementById("mostread_"+channel+"_"+i).setAttribute("className", "inactive_mostread"); 
		}
	}
	url = documentRoot + 'libs/function.mostread.php?channel=' + channel + '&time=' + time;
	ajaxCaller(url,'contentArea_'+channel+'_'+time);
}
