petzl.controllers.processComment = function (lang,animId,visitorIp,sourceURL)
{		
		var index=0;
		var containerHeight = $('.commentsContentContainer').height();
		if(containerHeight < 267){
			$('#readMoreButton').hide();
			$('.commentsContentContainer').css("cssText", "height: auto !important;");
		}
		
		$('.formSubmit').click(function() {
				$(this).unbind('click');
				var self = $(this);
				var name = $(this).parent().find('.authoerName').val();
				var email = $(this).parent().find('.authoerEmail').val();				
				var comment = $(this).parent().find('.commentText').val();
				var posted = $(this).parent().find('.keepMePosted').prop('checked');
				
				if ( typeof posted == 'undefined'){
					posted = false;
				}
				
				var parentId = '';
				if ($(this).attr('data-id') !== undefined) {
					parentId = $(this).attr('data-id');	
				}
				
				Web_AnimationDetail.processComment(name, email,posted, comment, lang, animId, parentId, visitorIp ,navigator.userAgent, sourceURL, function(result){ 
					
					if(result){
						(self.parent().find('.commentForm')).after($('#successMsg').clone().attr('id','successMsg'+(++index)));
						self.parent().find('#successMsg'+index).show();
						self.parent().find('.commentForm').hide();
						if (self.parent().find('.respondButton').length){
								self.parent().find('.respondButton').removeClass("respondOpen");
								self.parent().find('.respondButton').hide();
						}
						self.hide();
					}				
				});
		});	
		
		$('.respondButton').click(function() {
				$(this).parent().find('.formSubmit').toggle();
				if (!$('#readMoreButton').is(':hidden')){
					$('#readMoreButton').click();
					$('.commentsContentContainer').css("cssText", "height: auto !important;");
					var Variables = {};
					Variables.$obj = $(this);
					Variables.ResizeTimer =	setTimeout(function(){ 
					setRespondBox(Variables.$obj);	
					}, 500);
					return;
				}
				
				setRespondBox($(this));
				
		});	
		
		function setRespondBox(elem){
			$('.commentsContentContainer').css("cssText", "height: auto !important;");
			if ( elem.hasClass( "respondOpen")){
					elem.removeClass("respondOpen");
			}
			else{
					elem.addClass("respondOpen");
			}
			elem.next().toggle();			
		}
}
