function addComments(user, user_id, song, song_id, comments, comment, type)
{
  var Ajax = new Object();
    
    var Page = new Object();
    
    Page.width;
    Page.height;
    Page.top;
    
    Page.loadOut = function ()
    {
    	document.getElementById('loading').innerHTML ='';	
    }
    
    Page.getPageCenterX = function ()
    {
    	var fWidth;
    	var fHeight;		
    	//For old IE browsers 
    	if(document.all) 
    	{ 
    		fWidth 	= document.body.clientWidth; 
    		fHeight = document.body.clientHeight; 
    	} 
    	//For DOM1 browsers 
    	else if(document.getElementById &&!document.all)
    	{ 
    		fWidth 	= innerWidth; 
    		fHeight = innerHeight; 
    	} 
    	else if(document.getElementById) 
    	{ 
    		fWidth 	= innerWidth; 
    		fHeight = innerHeight; 		
    	} 
    	//For Opera 
    	else if (is.op) 
    	{ 
    		fWidth 	= innerWidth; 
    		fHeight = innerHeight; 		
    	} 
    	//For old Netscape 
    	else if (document.layers) 
    	{ 
    		fWidth 	= window.innerWidth; 
    		fHeight = window.innerHeight; 		
    	}
    
    	Page.width 	= fWidth;
    	Page.height = fHeight;
    	Page.top 	= window.document.body.scrollTop;
    }
    
    Ajax.RequestComments = function(feedurl, user, user_id, song, song_id, comments, comment, callbackMethod)
    {
    	Page.getPageCenterX();
    	
    	if(user_id == 0)
    	{
    	    alert("please login before you comment");
    	    return false;
    	}

        newComment = escape(comment);
    	url = feedurl+user+user_id+song+song_id+comments+newComment;
    	Ajax.RequestComments = Ajax.createRequestObject();
    	Ajax.RequestComments.onreadystatechange = callbackMethod;
        Ajax.RequestComments.open("POST", url, true);
    	Ajax.RequestComments.send(url);
    }
    
    Ajax.ResponseComments = function ()
    {
    	if(Ajax.CheckReadyState(Ajax.RequestComments))
    	{	
    		document.getElementById("show_comments").innerHTML = Ajax.RequestComments.responseText;
    	}
    }

    Ajax.RequestActivity = function(feedurl, callbackMethod)
    {
    	Page.getPageCenterX();
    	
    	if(user_id == 0)
    	{
    	    alert("please login before you comment");
    	    return false;
    	}
    	
    	url = feedurl;
    	Ajax.RequestActivity = Ajax.createRequestObject();
    	Ajax.RequestActivity.onreadystatechange = callbackMethod;
        Ajax.RequestActivity.open("POST", url, true);
    	Ajax.RequestActivity.send(url);
    }
    
    Ajax.ResponseActivity = function ()
    {
    	if(Ajax.CheckReadyState(Ajax.RequestActivity))
    	{	
    		document.getElementById("show-activity").innerHTML = Ajax.RequestActivity.responseText;
    	}
    }
    
    Ajax.createRequestObject = function()
    {
    	var obj;
    	if(window.XMLHttpRequest)
    	{
    		obj = new XMLHttpRequest();
    	}
    	else if(window.ActiveXObject)
    	{
    		obj = new ActiveXObject("MSXML2.XMLHTTP");
    	}
    	return obj;
    }
    
    Ajax.CheckReadyState = function(obj)
    {
    	if(obj.readyState < 4) {		
    		
    		document.getElementById('loading').style.top = (Page.top + Page.height/2)+150;
    		document.getElementById('loading').style.left = Page.width/2-675;
    		document.getElementById('loading').style.position = "absolute";
    		
    		document.getElementById('loading').innerHTML = "<table align='center'><td class='columnHeader'>&nbsp;</td></table>";  
    	}
    	if(obj.readyState == 1) { document.getElementById('loading').innerHTML = " "; }
    	if(obj.readyState == 2) { document.getElementById('loading').innerHTML = " "; }
    	if(obj.readyState == 3) { document.getElementById('loading').innerHTML = " "; }	
    	if(obj.readyState == 4)
    	{
    		if(obj.status == 200)
    		{
    			document.getElementById('loading').innerHTML = "<div class='floaterText'> </div>";
    			//setTimeout('Page.loadOut()',2000);
    			return true;
    		}
    		else
    		{
    			document.getElementById('loading').innerHTML = "HTTP " + obj.status;
    		}
    	}
    }
    
    if(type == 'song') {
      	Ajax.RequestComments('content_ajax.php?method=getCommentsXML', user, user_id, song, song_id, comments, comment, Ajax.ResponseComments);
    } else {
      	var comm = $('textarea#comment').val();
     	Ajax.RequestComments('content_ajax.php?method=getUserCommentsXML', user, user_id, song, song_id, comments, comm, Ajax.ResponseComments);
    }
   // Ajax.RequestActivity('content_ajax.php?method=getActivityXML', Ajax.ResponseActivity);
}