function ajaxFunction(source,destination){
	var ajaxRequest;  // The variable that makes Ajax possible!

	if(document.getElementById(destination)) {
		document.getElementById(destination).innerHTML = '<div align=\"center\" style=\"padding:30px;\"><img src="/images/icons/loaderB32.gif" border="0" width="32" height="32"></div>';
	}

	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4) {
			if(document.getElementById(destination)) {
				//alert(ajaxRequest.responseText);
				document.getElementById(destination).innerHTML = ajaxRequest.responseText;
			}
			else {
				alert('invalid target!');
			}
		}
	}
	ajaxRequest.open("GET", source, true);
	ajaxRequest.send(null); 
}

function submitForm(x) {
	if(x.title.value == '') {
		alert("Please enter your Comment Title!");
		return false;
	}
	if(x.comment.value == '') {
		alert("Please enter your Comment!");
		return false;
	}
	if(x.author.value == '') {
		alert("Who are you!");
		return false;
	}
	var elem = x.elements;
	var params = ''; 
	for(var i = 0; i < elem.length; i++) {
		params += '&' + elem[i].name + "=" + escape(elem[i].value); 
	}
	var url = '/includes/2010/ajax/user-comments.php?action=submit-comment' + params;
	var COMMENT_TYPE = x.TopicType.value;
	var COMMENT_ITEM_ID = x.TopicID.value;
	var TARGET = 'user_comment_post_' + COMMENT_TYPE + '_' + COMMENT_ITEM_ID;
	var TARGET2 = 'user_comment_results_' + COMMENT_TYPE + '_' + COMMENT_ITEM_ID;
	//alert("ajaxFunction('/includes/2010/ajax/user-comments.php?action=submit-comment'" + params +",'user_comment_post');");
	ajaxFunction(url,TARGET);	
	var url2 = '/includes/2010/ajax/user-comments.php?action=list-comments&COMMENT_TYPE=' + escape(COMMENT_TYPE) + '&COMMENT_ITEM_ID=' + escape(COMMENT_ITEM_ID);
	ajaxFunction(url2,TARGET2);
}


