	if (top.location != self.location){ top.location = self.location.href }
	
	function createRequestObject() { 

       var req; 
    
       if(window.XMLHttpRequest){ 
          // Firefox, Safari, Opera... 
          req = new XMLHttpRequest(); 
       } else if(window.ActiveXObject) { 
          // Internet Explorer 5+ 
          req = new ActiveXObject("Microsoft.XMLHTTP"); 
       } else { 
          // There is an error creating the object, 
          // just as an old browser is being used. 
          alert('Problem creating the XMLHttpRequest object'); 
       } 
    
       return req; 
    
    } 
	
	// Make the XMLHttpRequest object 
    var http = createRequestObject(); 

	//Query database to get username
    function sendRequest(words, id) { 
    
       // Open PHP script for requests 
       http.open('get', 'http://www.campusbreak.com/js/comment.php?id=' + id + '&comment='+words); 
       http.onreadystatechange = handleResponse; 
       http.send(null); 
    
    }
	

	function handleResponse() { 
    
       if(http.readyState == 4 && http.status == 200){ 
    
          // Text returned FROM the PHP script 
          var response = http.responseText; 
    
          if(response) { 
             // UPDATE ajaxTest content 
			 document.getElementById("no_comment").style.display = 'none';
             document.getElementById("newcomment").innerHTML = '<div class="comment">' + response + '</div>'; 
          } 
    
       } 
    
    } 

function CharCount (max, f, ft, fc) {
		var d = document[f];
		var len = max - d[ft].value.length;
		if (len < 0) {
			d[ft].value = d[ft].value.substring(0,max);
			d[fc].value = 0;
		} else {
			d[fc].value = len;
		}
		if(len > 50){
			document.getElementById('limit').style.color='green';
		} else {
			document.getElementById('limit').style.color='red';
		}
	}