// JavaScript Document

// JavaScript Document

		function toggleComments(){
			Effect.toggle('addCommentBox', 'appear');
		}
		
		function deleteComment(iCommentId){
			
			if(confirm('Are you sure you want to delete this comment?')){
				var postBody = "COMMENT_ID=" + iCommentId;
				
				new Ajax.Request(fullurl + '/inc_comments.asp?action=delete', {
					method: 'post',	
					postBody: postBody ,
					onComplete: resetComments
				});	
			}
		}
		
		function loadComments(itemid, itemtype){
			
			var postBody = "itemid=" + itemid ;
			postBody += "&itemtype=" + itemtype ;
			
			new Ajax.Request(fullurl + '/inc_comments.asp', {
				method: 'post',	
				postBody: postBody ,
				onComplete: showResponse
			});
		}
	
		function resetComments(itemid, itemtype){
			Effect.Fade('addCommentBox');
			loadComments(itemid, itemtype);
		}
		
		function showResponse(originalRequest){
			
			var previewContainer = document.getElementById('comments');
			previewContainer.innerHTML = originalRequest.responseText;
		}	
		
		function debugResponse(originalRequest){
			alert(originalRequest.responseText);
		}
		
		function addComment(itemid, itemtype){
			
			if( $('comment_name').value !='' && $('comment_email').value != '' && $('comment_content').value != ''){
			
			var postBody = $('commentform').serialize() ;			
			new Ajax.Request(fullurl + '/inc_comments.asp?action=insert', {
												method: 'post',	
												postBody: postBody ,
												onComplete: function(xmlobject){
													Effect.Appear('comment_added') ;
													resetComments(itemid, itemtype);	
												}
												});
			
			}else{
				
				Effect.Appear('missedfields') ;
				
			}
		}
