// JavaScript Document

$(function() {
    
    $("#submit_comment").click(function(){
    
        var name = $('input#name').val();
		var comment = $('textarea#comment').val();
		var spam = $('input#spam').val();
		var humantest1 = $('input#HumanTest1').val();
		var humantest = $('input#HumanTest').val();
		var BlogID = $('input#BlogID').val();

		
		if(spam.length >  1) {	
            alert("Go Away!!");
			$('input#spam').focus();
        	return false;
        }
		else if(name.length <  1) {	
            alert("You have not entered a name");
			$('input#name').focus();
        	return false;
        }
		else if(comment.length <  1) {	
            alert("You have not entered a comment");
			$('textarea#comment').focus();
        	return false;
        }
		else if(humantest.length <  1) {	
            alert("You have not entered a verification code");
			$('input#HumanTest').focus();
        	return false;
        }
		else if(humantest.length >  1) {	
			if (humantest1 != humantest) {
            alert("Your verification code is incorrect. Please try again");
			$('input#HumanTest').focus();
        	return false;
			}
        }

		
        $('<div class="overlay"></div>').appendTo('.makecomment_form');
        
        $.ajax({
            url: 'http://www.candeomedia.com/actions/submitcomment_process_ajax.asp',
            data: {blogID:BlogID,Name:name,Comment:comment,HumanTest:humantest},
            type: 'GET',
            
            success: function(results) {
                $('div.overlay').remove();
				$('textarea#comment').val("");
				$('input#name').val("");
				$('input#HumanTest').val("");
                
				
				if ($('#nocomments')) {
					$('#nocomments').fadeOut(600);
				}

				$('<div class="makecomment"><div class="makecomment_inner">'+results+'</div></div>').prependTo('div#comments').hide().slideDown(600);
	
				
            }
         });
		
        return false;
    }); //a sumbit
    
}); //document ready
