﻿
//Contact Me Methods

function ProcessSendEmail(name, email, website, comment) {
        $("#divContactForm").hide();
        $("#divThrobber").show();
        var strName = escape($("#"+name).val());
        var strEmail = escape($("#"+email).val());
        var strWebsite = escape($("#" + website).val());
        var strComment = escape($("#" + comment).val());
		$.ajax({
    		type: "POST",
    		url: "/WebServices/ContactMe.asmx/SendMeAnEmail",
    		contentType: "application/json; charset=utf-8",
    		data: "{'name': '" + strName + "','email':'" + strEmail + "','webaddress':'" + strWebsite + "','comment':'" + strComment + "'}",
    		dataType: "json",
    		success: function(msg) {
    		var results = (typeof msg.d) == 'string' ? eval('(' + msg.d + ')') : eval(msg);

    		if (results = "true") {
    			$("#divThrobber").hide();
    				$("#divThankyou").animate({ top: "show", opacity: "show" }, 500);
    			}
    			else {
    				$("#divThrobber").hide();
    				$("#divContactForm").show();
    				alert("There was an error while attempting to post your comment, \n\nPlease try again - if this is a continuing trend, please let me know by email: doug[at]diaryofaninja.com");
    			}
    		},
    		error: function() {
    			alert("There was an error while attempting to post your comment, \n\nPlease try again - if this is a continuing trend, please let me know by email: doug[at]diaryofaninja.com\n");
    		}
			});
	return false;
}

//Blog Page Methods

function ProcessCommentAddition(name, email, website, comment, subscribeToUpdates, blogID) {

	var strName = escape($("#" + name).val());
	var strEmail = escape($("#" + email).val());
	var strWebsite = escape($("#" + website).val());
	var strComment = escape($("#" + comment).val());
	var boolSubscribe = escape($("#" + subscribeToUpdates).is(':checked'));
	var strBlogID = escape(blogID);
	
    $("#newpostcomment").animate({ top: "hide", opacity: "hide" }, 500, function(){
		$("#divThrobber").show();

		$.ajax({
    		type: "POST",
    		url: "/WebServices/BlogComments.asmx/SubmitComment",
    		contentType: "application/json; charset=utf-8",
    		data: "{'name': '" + strName + "','email':'" + strEmail + "','webaddress':'" + strWebsite + "','comment':'" + strComment + "','subscribeToUpdates':'"+boolSubscribe+"','blogID':'" + strBlogID + "'}",
    		dataType: "json",
    		success: function(msg) {
    		var results = (typeof msg.d) == 'string' ? eval('(' + msg.d + ')') : eval(msg);

    		if (results="true") {
    				$("#divThrobber").hide();
    				$("#divThankyou").animate({ top: "show", opacity: "show" }, 500);
    			}
    			else {
    				$("#divThrobber").hide();
    				$("#newpostcomment").show();
    				alert("There was an error while trying to send your comment, \nplease try again\nafter");
    			}
    		},
    		error: function() {
    			alert("There was an error while attempting to post your comment, \nplease try again\nbefore");
    		}
		});
   });

           	
        //add google event tracking
}

window.scrollTo = function() { }


