// JavaScript Document<style>

	function xmlhttpPost(strURL, Flagged_Counter, Media_Id, i, note) {
		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {
			if (self.xmlHttpReq.readyState == 4) {
				updatepage(self.xmlHttpReq.responseText, i);
			}
		}
		self.xmlHttpReq.send('count=' + Flagged_Counter + '&media_id=' + Media_Id + '&note=' + escape(note));
	}
	
	function xmlhttpPostDisable(strURL, Media_Id, GFW) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
    self.xmlHttpReq.send('GFW=' + GFW + '&media_id=' + Media_Id);
}
	
	
	function updatepage(str, i){
		document.getElementById("report" + i).innerHTML = str;
	}
	
	
	function CheckForSwears(strURL, phrase, pobjForm) {
	   
		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {
			if (self.xmlHttpReq.readyState == 4) {
				CheckForSwearsUpdatepage(self.xmlHttpReq.responseText, pobjForm);
			}
		}
		self.xmlHttpReq.send('phrase=' + phrase);
	}
	
	function CheckForSwearsUpdatepage(str, pobjForm){
		document.getElementById("error").innerHTML = str;
        
		if (str.length == 0) 
	    {
	        pobjForm.action = pobjForm.action;
		    pobjForm.submit();
		}
	}
	
	
	function ReportPost(strURL, params, i) {
	  
		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {
			if (self.xmlHttpReq.readyState == 4) {
				ReportPostUpdate(self.xmlHttpReq.responseText, i);
			}
		}
		self.xmlHttpReq.send('params=' + params);
	}
	
	function ReportPostUpdate(str, i){
	
		document.getElementById("report" + i).innerHTML = str;
	}
	
	function TogglePost(strURL, postid, status) {
	  
		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {
			if (self.xmlHttpReq.readyState == 4) {
				TogglePostUpdate(self.xmlHttpReq.responseText, i);
			}
		}
		self.xmlHttpReq.send('postid=' + postid + "&status=" + status);
	}
	
	function TogglePostUpdate(str){
	
		document.getElementById("toggle").innerHTML = str;
	}
	
	function ToggleWarn(strURL, userid, status) {
	  
		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {
			if (self.xmlHttpReq.readyState == 4) {
				ToggleWarnUpdate(self.xmlHttpReq.responseText, i);
			}
		}
		self.xmlHttpReq.send('userid=' + userid + "&status=" + status);
	}
	
	function ToggleWarnUpdate(str){
	
		document.getElementById("warn").innerHTML = str;
	}
	
	function ToggleBan(strURL, userid, status) {
	  
		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {
			if (self.xmlHttpReq.readyState == 4) {
				ToggleBanUpdate(self.xmlHttpReq.responseText);
			}
		}
		self.xmlHttpReq.send('userid=' + userid + "&status=" + status);
	}
	
	function ToggleBanUpdate(str){
	
		document.getElementById("ban").innerHTML = str;
	}
	
	function ToggleLockBanTopic(strURL, topicid, status) {
	  
		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {
			if (self.xmlHttpReq.readyState == 4) {
			    alert(status)
			    if (status == "lock" || status == "unlock" )
			        ToggleLockTopicUpdate(self.xmlHttpReq.responseText, "lock");
			    else
			        ToggleLockTopicUpdate(self.xmlHttpReq.responseText, "disable");
			}
		}
		self.xmlHttpReq.send('topicid=' + topicid + "&status=" + status);
	}
	
	function ToggleLockTopicUpdate(str, div){
	
		document.getElementById(div).innerHTML = str;
	}
	
	function SubmitWallComment(strURL, memberid, mediaid, comment, createdby, controls) {

		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {
			if (self.xmlHttpReq.readyState == 4) {
			    SubmitWallCommentUpdate(self.xmlHttpReq.responseXML.documentElement);
			}
		}
		
		self.xmlHttpReq.send('memberid=' + memberid + "&mediaid=" + encodeURI(mediaid) + "&comment=" + encodeURI(comment) + "&createdby=" + createdby + "&controls=" + controls);
	}
	
	function SubmitWallCommentUpdate(str){
        
        var temp = document.createElement("div");
        temp.id = "comment" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue;
        temp.style.fontSize = "12";
        temp.style.borderBottom = "solid 1px #cccccc";
        temp.style.padding = "10";
        temp.onmouseover = new Function("if (document.getElementById('remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "') != null) {document.getElementById('remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "').style.visibility = 'visible';}");
        temp.onmouseout  = new Function("if (document.getElementById('remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "') != null) {document.getElementById('remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "').style.visibility = 'hidden';}");
        temp.innerHTML += "<div id='remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "' style='float:right; visibility:hidden; font-size:10px; position:relative; top:-8px;'><a href='#' onClick=\"document.getElementById('loadinggif" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "').style.visibility = 'visible'; ToggleWallComment('../utility/ajax_mini_pages/ToggleWallComment.asp','" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "', 'off','" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "');return false;\">[Remove]</a><img id='loadinggif" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "' border='0' src='i/loading.GIF' style='position:relative; top:5px; left: 10px; visibility:hidden;' /><br><br><a href='convo.asp?to=" + str.getElementsByTagName('createdby')[0].firstChild.nodeValue + "&from=" + str.getElementsByTagName('memberid')[0].firstChild.nodeValue + "' >[Conversation]</a></div>";
        temp.innerHTML += "<div style='color:#666666; '><a href='profile.asp?member=" + str.getElementsByTagName('createdby')[0].firstChild.nodeValue + "'>" + str.getElementsByTagName('createdbyname')[0].firstChild.nodeValue + "</a> on " + str.getElementsByTagName('time')[0].firstChild.nodeValue + "</div>";
        temp.innerHTML += "<div style='margin: 0 0 0 4;'>" + str.getElementsByTagName('commenttext')[0].firstChild.nodeValue + "</div>";
        
		document.getElementById('wall').insertBefore(temp, document.getElementById('wall').firstChild);
		document.getElementById('newcomment').value = "";
		document.getElementById('loadinggif2').style.visibility ='hidden';
	}
	
	function ToggleWallComment(strURL, commentid, onoff, loadingif) {

		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {
			if (self.xmlHttpReq.readyState == 4) {
			    if (onoff == "off") 
			        ToggleWallCommentUpdate(commentid, loadingif)
			    else
			        window.location.reload()
			}
		}
		self.xmlHttpReq.send("commentid=" + commentid + "&onoff=" + onoff);
	}
	
	function ToggleWallCommentUpdate(str, loadingif){
	    
        if (document.getElementById('feeditem' + str) != null)
		    document.getElementById('feeditem' + str).innerHTML = "<div style='float:right; font-size:11px; '><a href='#' onClick=\"ToggleWallComment('../utility/ajax_mini_pages/ToggleWallComment.asp'," + str + ", 'on'); return false;\" >[Undo]</a></div><br>";
	    else
	        document.getElementById('comment' + str).innerHTML = "<div style='float:right; font-size:11px; '><a href='#' onClick=\"ToggleWallComment('../utility/ajax_mini_pages/ToggleWallComment.asp'," + str + ", 'on'); return false;\" >[Undo]</a></div><br>";
	    if (document.getElementById('loadinggif' + loadingif) != null)
	        document.getElementById('loadinggif' + loadingif).style.visibility ='hidden';
	}
	
	function PostStatus(strURL, memberid, status) {
	    
		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('GET', strURL + "?memberid=" + encodeURIComponent(memberid) + "&status=" + encodeURIComponent(status), true);
		//self.xmlHttpReq.setRequestHeader('Content-Type', 'text/xml');
		//self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {
			if (self.xmlHttpReq.readyState == 4) {
			    PostStatusUpdate(self.xmlHttpReq.responseXML.documentElement);
			   //PostStatusUpdate(self.xmlHttpReq.responseText);
			}
		}
		self.xmlHttpReq.send(null);
	}
	
	function PostStatusUpdate(str){
        
        var temp = document.createElement("div");
        temp.id = "feeditem" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue;
        temp.className = "StatusItem bloopAnimation";
        temp.onmouseover = new Function("if (document.getElementById('remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "') != null) {document.getElementById('remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "').style.visibility = 'visible';}");
        temp.onmouseout  = new Function("if (document.getElementById('remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "') != null) {document.getElementById('remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "').style.visibility = 'hidden';}");
        temp.innerHTML += "<div id='remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "' style='float:right; visibility:hidden; font-size:10px; position:relative; top:0px;'><a href='#' onClick=\"document.getElementById('loadinggif" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "').style.visibility = 'visible'; ToggleWallComment('../utility/ajax_mini_pages/ToggleWallComment.asp','" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "', 'off','" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "');return false;\">[Remove]</a></div>";
        temp.innerHTML += "<div style='color:#666666; margin: 0 0 0 0;'><a href='profile.asp?member=" + str.getElementsByTagName('createdby')[0].firstChild.nodeValue + "'>" + str.getElementsByTagName('createdbyname')[0].firstChild.nodeValue + "</a> (" + str.getElementsByTagName('commenttype')[0].firstChild.nodeValue +  ") on " + str.getElementsByTagName('time')[0].firstChild.nodeValue + "</div>";
        temp.innerHTML += "<div style='margin: 0 0 0 4;'>" + str.getElementsByTagName('commenttext')[0].firstChild.nodeValue + "</div>";
        temp.innerHTML += "<div id='feeditemsubcomments" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "'>";
        temp.innerHTML += "</div>";
        temp.innerHTML += "<div>";
        temp.innerHTML += "    <input id='statuscommentfield" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "' name='statuscommentfield" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "'  style='height:17px; width: 200px; margin:3 10 2 10;' />";
        temp.innerHTML += "    <a href='#' onClick=\"if (document.getElementById('statuscommentfield" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "').value != ''){document.getElementById('loadinggif" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "').style.visibility = 'visible'; PostStatusComment('../utility/ajax_mini_pages/PostStatusComment.asp','" + str.getElementsByTagName('createdby')[0].firstChild.nodeValue + "','0',document.getElementById('statuscommentfield" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "').value,'" + str.getElementsByTagName('loginid')[0].firstChild.nodeValue + "','" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "');} return false;\"><span style='background-color:#ffffff; color:#000000; padding:3 5 3 5px; position:relative; top:-3px; border:solid 1px #aaaaaa; font-weight:bold; font-size:10px;'>Comment</span></a>"; 
        temp.innerHTML += "    <img id='loadinggif" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "' border='1' src='i/loading.GIF' style='margin:0 0 0 10; visibility:hidden;' />";
        temp.innerHTML += "</div>";
          
        //alert(temp.innerHTML);
	    document.getElementById('feed').insertBefore(temp, document.getElementById('feed').firstChild);
		document.getElementById('newstatus').value = "";
		document.getElementById('loadinggif2').style.visibility ='hidden';
		
		document.getElementById('norecentactivity').style.display ='none';
	}
	
	function PostStatusComment(strURL, memberid, mediaid, comment, createdby, parentid) {
	    
	   
		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {
			if (self.xmlHttpReq.readyState == 4) {
			   PostStatusCommentUpdate(self.xmlHttpReq.responseXML.documentElement);
			   //PostStatusCommentUpdate(self.xmlHttpReq.responseText);
			}
		}
		self.xmlHttpReq.send("memberid=" + encodeURI(memberid) + "&mediaid=" + encodeURI(mediaid) + "&comment=" + encodeURI(comment) + "&createdby=" + encodeURI(createdby) +  "&parentid=" + encodeURI(parentid));
	}
	
	function PostStatusCommentUpdate(str){
	
		var temp = document.createElement("div");
        temp.id = "feeditem" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue;
        temp.className = "StatusItemComment bloopAnimation"
        temp.onmouseover = new Function("if (document.getElementById('remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "') != null) {document.getElementById('remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "').style.visibility = 'visible';}");
        temp.onmouseout  = new Function("if (document.getElementById('remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "') != null) {document.getElementById('remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "').style.visibility = 'hidden';}");
        temp.innerHTML += "<div id='remove" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "' style='float:right; visibility:hidden; font-size:10px; position:relative; top:0px;'><a href='#' onClick=\"document.getElementById('loadinggif" + str.getElementsByTagName('parentid')[0].firstChild.nodeValue + "').style.visibility = 'visible'; ToggleWallComment('../utility/ajax_mini_pages/ToggleWallComment.asp','" + str.getElementsByTagName('commentid')[0].firstChild.nodeValue + "', 'off','" + str.getElementsByTagName('parentid')[0].firstChild.nodeValue + "');return false;\">[Remove]</a></div>";
        temp.innerHTML += "<div style='margin: 0 0 0 0;'>" + str.getElementsByTagName('commenttext')[0].firstChild.nodeValue + "</div>";
        temp.innerHTML += "<div style='float:right; clear:both; color:#666666; '><a href='profile.asp?member=" + str.getElementsByTagName('createdby')[0].firstChild.nodeValue + "'>" + str.getElementsByTagName('createdbyname')[0].firstChild.nodeValue + "</a> on " + str.getElementsByTagName('time')[0].firstChild.nodeValue + "</div><br>";
       //alert('feeditemsubcomments' + str.getElementsByTagName('parentid')[0].firstChild.nodeValue);
        document.getElementById('feeditemsubcomments' + str.getElementsByTagName('parentid')[0].firstChild.nodeValue).appendChild(temp);
		document.getElementById('statuscommentfield' + str.getElementsByTagName('parentid')[0].firstChild.nodeValue).value = "";
		document.getElementById('loadinggif' + str.getElementsByTagName('parentid')[0].firstChild.nodeValue).style.visibility ='hidden';
	}
	
	function RemoveFriend(strURL, you, friend) {

		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {
			if (self.xmlHttpReq.readyState == 4) {
			    RemoveFriendUpdate(self.xmlHttpReq.responseText)
			}
		}
		self.xmlHttpReq.send("you=" + encodeURI(you) + "&friend=" + encodeURI(friend));
	}
	
	function RemoveFriendUpdate(str){
		document.getElementById('status').innerHTML = str;
		setTimeout("parent.parent.location='http://www.roadscholar.org/social/MyProfile.asp'",2000);
	}
	
	
	
	

	
	
	
	function showToolTip(show) 
	{
		var helpToolTip = document.getElementById('help');
		
		helpToolTip.style.top = window.event.clientY - 200 + document.body.scrollTop;
		helpToolTip.style.left = window.event.clientX - 420;
		
		if (show) 
			helpToolTip.style.display = 'block';
		else
			helpToolTip.style.display = 'none';
	
	return true;
	}
	
	function showSharePopUp(params) 
	{
		var showSharePopUp = document.getElementById('shareBox');
		document.getElementById('shareBoxContents').innerText = "http://www.roadscholar.org/social/GroupTopic.asp?" + params;
		showSharePopUp.style.top = window.event.clientY - 143 + document.body.scrollTop;
		showSharePopUp.style.left = window.event.clientX - 520;
        
		showSharePopUp.style.display = 'block';
	
	return true;
	}
	
