function initPostComment(objectid,objecttypid){
	$('comment_type').value=objecttypid;
	$('comment_objectid').value=objectid;
}

function displayPostComment(cssid){
	$(cssid).show();
	//[cssid].each(Element.show);
}

function showPostComment(cssid,objectid,objecttypid){
	$('comment_type').value=objecttypid;
	$('comment_objectid').value=objectid;
	Effect.SlideDown(cssid, { duration: 1.0 });
}

function addComment(form){
	if($('comment').value == $('comment').readAttribute('title'))
		return;
	var formparameters = Form.serialize($(form));
	var ajaxurl = '/postcomment';

	$('mod_comment').hide();
	$('mod_comment').insert({'after' :'<img src="/gui/images/ajax/ajax-loader.gif" id="ajaxloader" />'});
    $('ajaxloader').show();

	var myAjax = new Ajax.Request(
		ajaxurl,
		{ method: 'post', 
		  parameters: formparameters, 
		  onSuccess: handleComment, 
		  onFailure: handleCommentFail 
		});
	
    // Following two lines must be added in callback function handling addComment responses to display 
	// comment form and remove ajax loader
	/*$('mod_comment').show(); 
	$('ajaxloader').remove(); */

}


/*function processCommentForm(e) {
	//alert ('processCommentForm');
 	// get the form that got submited ( the first parrent element of the element that trigger the event)
    var aform = Event.findElement(e, 'form');
	// where to submit the form
    //var ajaxurl = aform.action;
    var ajaxurl = '/postcomment';
	var formparameters = aform.serialize(true); // take the form field values before you disable it
	//alert(formparameters);
    //disable the form elements while beeing processed
   	aform.disable();

    // get the submit button of the form and show an ajax-loader instead
    var submitbutton = aform.getInputs('submit')[0];
    new Insertion.Before(submitbutton, '<img src="/gui/images/ajax/ajax-loader.gif" id="ajaxloader" />');
    submitbutton.hide();

        var myAjax = new Ajax.Request(
        ajaxurl,
        { method: 'post', 
          parameters: formparameters, 
          onSuccess: handlereq, 
          onFailure: function() {alert('Refresh the Page, something happend to the server');} // what to do if the server return something else than 2xx status.
        });

    function handlereq(req) {
		//alert(req.responseText);
		//$('error_misc').update(req.responseText);
        aform.enable(); // enable the form
        $('ajaxloader').remove(); // remove the ajax-loader
        submitbutton.show(); // return the submit button
    }
   

    // don't trigger the actual html submit form
    Event.stop(e);
	
}*/
