function getXmlHttp () {
	var xmlhttp = false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest != "undefined") {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function closeComp() { document.getElementById('compdiv').className = 'hide'; }
function moreEducation(s) {
	document.getElementById('moreeducation[' + s++ + ']').className = 'hide';
	document.getElementById('education[' + s + ']').className = 'profile show';
}
function moreConcentrations(i) {
	if (document.getElementById('concentration' + i + '[1]').className == 'show') { document.getElementById('concentration' + i + '[2]').className = 'show'; document.getElementById('moreconcentrations' + i).className = 'hide'; }
	if (document.getElementById('concentration' + i + '[1]').className == 'hide') { document.getElementById('concentration' + i + '[1]').className = 'show'; }
}

function moreWork(s) {
	document.getElementById('morework[' + s++ + ']').className = 'hide';
	document.getElementById('work[' + s + ']').className = 'profile show';
}

function togglePresent(s, e) {
	if (e.checked) {
		document.getElementById('workto[' + s + ']').className = 'hide';
		document.getElementById('workpresent[' + s + ']').className = 'show';
	}
	else {
		document.getElementById('workto[' + s + ']').className = 'show';
		document.getElementById('workpresent[' + s + ']').className = 'hide';
	}
}

function moreScreenNames(s) {
	document.getElementById('morenames[' + s++ + ']').className = "hide";
	document.getElementById('screenname[' + s + ']').className = "show";
	if (s < 3) { document.getElementById('morenames[' + s + ']').className = "show" };
}

function moreAlerts(s) {
	if (s == 0) { document.getElementById('morealerts[' + s + ']').style.display = 'none'; document.getElementById('alerts[1]').style.display = ''; }
	if (s == 1) { document.getElementById('morealerts[' + s + ']').style.display = 'none'; document.getElementById('alerts[2]').style.display = ''; }
	if (s == 2) { document.getElementById('morealerts[' + s + ']').style.display = 'none'; document.getElementById('alerts[3]').style.display = ''; document.getElementById('morealerts[3]').style.display = 'none'; }
}

function closeComments(p) {
	document.getElementById(p + '_master').className = 'contentpaneopen show';
	document.getElementById(p + '_slave').className = 'contentpaneopen hide';
	document.getElementById(p).innerHTML = '';
	document.getElementById(p).className = 'contentpaneopen hide';
}

function showComments(p) {
	var xmlhttp = false;
	var objState = 0;
	var obj = document.getElementById(p);

	if (document.getElementById(p + '_master').className == 'contentpaneopen show') {
		document.getElementById(p + '_master').className = 'contentpaneopen hide';
		document.getElementById(p + '_slave').className = 'contentpaneopen show';
		document.getElementById(p).className = 'contentpaneopen show';
	}
	else {
		document.getElementById(p + '_master').className = 'contentpaneopen show';
		document.getElementById(p + '_slave').className = 'contentpaneopen hide';
		document.getElementById(p).className = 'contentpaneopen hide';
	}

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	xmlhttp.open("GET", 'index.php?option=com_ajax&task=fetchcomments&pid=' + p);

	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}

	xmlhttp.send(null);

}

function toggleMods(s) {
	var xmlhttp = false;
	var objState = 0;

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	if (document.getElementById(s).className == 'hide') {
		document.getElementById(s).className = 'show';
		document.getElementById(s + '_state').className = 'opened';
		objState = 1;
		if (s == 'wfridge') {
			document.getElementById('note').focus();
		}
	}
	else {
		document.getElementById(s).className = 'hide';
		document.getElementById(s + '_state').className = 'closed';
		objState = 0;
	}

	xmlhttp.open("GET", 'index.php?option=com_ajax&task=togglemods&id=' + s + '&state=' + objState);
	xmlhttp.send(null);
}

function toggleModsSession(s, p) {
	var xmlhttp = false;
	var objState = 0;

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	if (document.getElementById(s).className == 'hide') {
		document.getElementById(s).className = 'show';
		document.getElementById(s + '_state').className = 'opened';
		objState = 1;
		if (s == 'wfridge') {
			document.getElementById('note').focus();
		}
	}
	else {
		document.getElementById(s).className = 'hide';
		document.getElementById(s + '_state').className = 'closed';
		objState = 0;
	}

	xmlhttp.open("GET", 'index.php?option=com_ajax&task=togglemodssession&id=' + s + '&ssid=' + p + '&state=' + objState);
	xmlhttp.send(null);
}

function toggleModsNoSave(s) {
	if (document.getElementById(s).className == 'hide') {
		document.getElementById(s).className = 'show';
		document.getElementById(s + '_state').className = 'opened';
		objState = 1;
	}
	else {
		document.getElementById(s).className = 'hide';
		document.getElementById(s + '_state').className = 'closed';
		objState = 0;
	}
}

function submitVideo() {
	document.getElementById('vdown').className = 'hide';
	document.getElementById('vup').className = 'show';
	document.getElementById('usrmsg').innerHTML = '';
}

function callVideo(url, id, ssid) {
	var width = 560;
	var height = 340;

	document.cookie = "_usbdt_channel=" + id + "; path=/";
	document.cookie = "_usbdt_ssid=" + ssid + "; path=/";

	day = new Date();
	id = "page" + day.getTime();
	eval(id + " = window.open(url, 'meta', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left = 362,top = 234');");
}

function rateBox() {
	document.getElementById('cbox').className = 'profile show';
	document.getElementById('ccbox').focus();
}

function teamCategory(s) {
	var xmlhttp = false;
	var objState = 0;
	var obj = document.getElementById('teamcat');
	var objc1 = document.getElementById('teamsubcat');
	var objc2 = document.getElementById('teamchildcat');
	var objc3 = document.getElementById('teamother');

	objc1.innerHTML = "";
	objc2.innerHTML = "";
	objc3.innerHTML = "";

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	xmlhttp.open("GET", 'index.php?option=com_ajax&task=teamcat&id=' + s);

	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}

	xmlhttp.send(null);
}

function teamSubcategory(s) {
	var xmlhttp = false;
	var objState = 0;
	var obj = document.getElementById('teamsubcat');
	var objc1 = document.getElementById('teamchildcat');
	var objc2 = document.getElementById('teamother');

	objc1.innerHTML = "";
	objc2.innerHTML = "";

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	xmlhttp.open("GET", 'index.php?option=com_ajax&task=teamsubcat&id=' + s);

	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}

	xmlhttp.send(null);
}

function teamChildcategory(s) {
	var xmlhttp = false;
	var objState = 0;
	var obj = document.getElementById('teamchildcat');
	var objc1 = document.getElementById('teamother');

	objc1.innerHTML = "";

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	xmlhttp.open("GET", 'index.php?option=com_ajax&task=teamchildcat&id=' + s);

	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}

	xmlhttp.send(null);
}

function teamChildcategoryOther(s) {
	var xmlhttp = false;
	var objState = 0;
	var obj = document.getElementById('teamother');

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	xmlhttp.open("GET", 'index.php?option=com_ajax&task=teamchildcatother&id=' + s);

	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}

	xmlhttp.send(null);
}

function contentRating(r, e) {
	var str = "";
	var xmlhttp = getXmlHttp();

	str = "id=" + e;
	str += "&rating=" + r;

	xmlhttp.open("POST", "index2.php?option=com_ajax&task=thumbrating&" + str, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			// get the message from the server
			var xmlresponse = xmlhttp.responseXML;
			var xmlroot = xmlresponse.documentElement;
			var contentid = xmlroot.getElementsByTagName('contentid').item(0).firstChild.data;
			var rating = xmlroot.getElementsByTagName('rating').item(0).firstChild.data;
			var ratings = xmlroot.getElementsByTagName('ratings').item(0).firstChild.data;
			var percent = xmlroot.getElementsByTagName('percent').item(0).firstChild.data;
			var status = xmlroot.getElementsByTagName('status').item(0).firstChild.data;

			if (document.getElementById('rating')) {
				document.getElementById('rating').innerHTML = rating;
			}
			if (document.getElementById('ratings')) {
				document.getElementById('ratings').innerHTML = ratings;
			}
			if (document.getElementById('ul_' + e)) {
				document.getElementById('ul_' + e).style.width = percent;
			}
			if (document.getElementById('ul_thumb_' + e)) {
				document.getElementById('ul_thumb_' + e).style.width = percent;
			}
			if (document.getElementById('status')) {
				document.getElementById('status').innerHTML = status;
			}
			setTimeout('clearMessage()', 2000);
		}
	}
	xmlhttp.send(null);
}

function clearMessage() {
	document.getElementById('status').innerHTML = "";
	return;
}

function deleteComment(id) {
	var str = "";
	var xmlhttp = getXmlHttp();

	str = "id=" + id;
	setTimeout("doCommentRefresh()", 100);
	xmlhttp.open("POST", "index.php?option=com_ajax&task=deletecomment&" + str, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
	return;
}

function commentBoxMain(id, rater, rated) {
	var str = "";
	var xmlhttp = getXmlHttp();
	var obj = document.getElementById('commentbox');

	str = "id=" + id;
	str += "&rater=" + rater;
	str += "&rated=" + rated;

	xmlhttp.open("POST", "index2.php?option=com_ajax&task=commentboxmain&" + str, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
	return;
}

function commentBoxMainApply() {
	var str = "";
	var xmlhttp = getXmlHttp();
	var comment = document.getElementById('comment').value;
	var obj = document.getElementById('commentresult');
	var content = document.getElementById('contentid').value;
	var rater = document.getElementById('rater').value;
	var rated = document.getElementById('rated').value;

	str = "comment=" + comment;
	str += "&id=" + content;
	str += "&rater=" + rater
	str += "&rated=" + rated;

	setTimeout("doCommentRefresh()", 100);
	xmlhttp.open("POST", "index2.php?option=com_ajax&task=commentboxmainapply&" + str, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
	return;
}

function commentBoxReply(id) {
	var str = "";
	var xmlhttp = getXmlHttp();
	var obj = document.getElementById('rbox' + id);

	str = "id=" + id;

	xmlhttp.open("POST", "index2.php?option=com_ajax&task=commentboxreply&" + str, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
	return;
}

function commentBoxReplyApply() {
	var str = "";
	var xmlhttp = getXmlHttp();
	var comment = document.getElementById('commentreply').value;
	var replyid = document.getElementById('replyid').value;
	var obj = document.getElementById('commentresult');

	str = "id=" + replyid;
	str += "&comment=" + comment;

	setTimeout("refreshComments()", 100);
	xmlhttp.open("POST", "index2.php?option=com_ajax&task=commentboxreplyapply&" + str, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
	return;
}

function commentBoxMainGoAway() {
	if (document.getElementById('commentbox')) {
		obj = document.getElementById('commentbox');
		obj.innerHTML = "";
	}
	return;
}

function commentBoxReplyGoAway(id) {
	if (document.getElementById('rbox' + id)) {
		obj = document.getElementById('rbox' + id);
		obj.innerHTML = "";
	}
	return;
}

function doCommentRefresh() {
	refreshComments();
	commentBoxMainGoAway();
	return;
}

function refreshComments() {
	var str = "";
	var xmlhttp = getXmlHttp();
	var obj = document.getElementById('commentresult');
	var id = document.getElementById('contentid').value;

	str = "id=" + id;
	xmlhttp.open("POST", "index2.php?option=com_ajax&task=contentcomments&" + str, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
	return;
}

function commentsPage(p) {
	var str = "";
	var xmlhttp = getXmlHttp();
	var obj = document.getElementById('commentresult');
	var id = document.getElementById('contentid').value;

	str = "id=" + id;
	str += "&page=" + p;

	xmlhttp.open("POST", "index2.php?option=com_ajax&task=contentcomments&" + str, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
	return;
}

