var objComment = {
	init: function() {},
	
	
	textCounter: function(field,cntfield,maxlimit){
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	
	else
		cntfield.value = maxlimit - field.value.length;
	},
	
	//Calling function for Ajax object
	saveComment: function(formID, contentWrapper, ajaxURL){
		//var ajaxURL = '/library/components/Comment/commentService.cfc?method=SaveComment';
		var ajaxString = ajaxURL;
	
		document.getElementById(contentWrapper).style.display = "";
 		objAjax.filterDataSet(formID, ajaxString , contentWrapper);
	},
	
	//Calling function for Ajax object
	approveComment: function(formID, contentWrapper, ajaxURL){
		var ajaxString = ajaxURL + "&commentStatusID=2";
	
		document.getElementById(contentWrapper).style.display = "";
 		objAjax.filterDataSet(formID, ajaxString , contentWrapper);
	},
	
	//Calling function for Ajax object
	rejectComment: function(formID, contentWrapper, ajaxURL){
		var ajaxString = ajaxURL + "&commentStatusID=3";
	
		document.getElementById(contentWrapper).style.display = "";
 		objAjax.filterDataSet(formID, ajaxString , contentWrapper);
	},
	
	validate: function(formID, contentWrapper, ajaxURL){
		//document.getElementById('disclaimer').style.display='inline';
		
		if ( confirm('Click OK if you have read and understood our disclaimer, otherwise click cancel.') ) 
		{
			var success= 	true;
			var message= 	'Please enter: \n'
							
			this.value= 	'Posting comment...'; 
			this.disabled=	true; 
							
			if ( document.getElementById('user_comment').value == '' ) {
				success = false;
				message = message + ' - a comment before posting.\n'
			}
			if ( document.getElementById('user_comment_name').value == '' ) {
				success = false;
				message = message + ' - your name before posting.\n'
			}
			if ( document.getElementById('user_comment_email').value == '' ) {
				success = false;
				message = message + ' - your email before posting.\n'
			}
			/*if ( !validEmailAddress(document.getElementById('user_comment_email').value)  ) {
				success = false;
				message = message + ' - a valid email address.\n'
			}*/				
			if ( success ) {
							 
				//post comment here using ajax and then clear the form
				//a=1;
				objComment.saveComment(formID, contentWrapper, ajaxURL);
				document.getElementById('user_comment').value = '';
				document.getElementById('user_comment_name').value = '';
				document.getElementById('user_comment_email').value = '';
				document.getElementById('remaining').value = '500';
			} 
			else {
				alert( message );
				this.disabled = false; 
				this.value = 'Post comment'; 
			}
		}	
	},
	
	openform : function(){
		document.getElementById('commentButton').style.display=	'none';
		document.getElementById('commentTbl').style.display=	'inline';
		document.getElementById('user_comment').focus();
	}

}

addLoadEvent(objComment.init);