﻿Ajax.Commands.GetReviewToPostToFaceBook = function(elementId, ajaxCommand, cmdCounter) {
    this.priority = net.CommandQueue.PRIORITY_IMMEDIATE;
    this.type = net.CommandQueue.TYPE_SINGLEPROCESS;
    this.id = cmdCounter;
    this.elementId = elementId;
    this.ajaxCommand = ajaxCommand;
    this.vendorLocationId = document.getElementById('vendorLocationToPostToFacadebook').value;
    this.remember = 'N'
    if (document.getElementById('remember').checked) {
        this.remember = 'Y'
    }
    this.allwaysPostReviewToFacadebook = document.getElementById('allwaysPostReviewToFacadebook').value;
}

Ajax.Commands.GetReviewToPostToFaceBook.prototype.QueryStringVariables = function() {
    var commandVariables = new Hashtable();
    commandVariables.put("vendorLocationId", this.vendorLocationId);
    commandVariables.put("remember", this.remember);
    commandVariables.put("allwaysPostReviewToFacadebook", this.allwaysPostReviewToFacadebook);
    return commandVariables;
}

Ajax.Commands.GetReviewToPostToFaceBook.prototype.ParseResponse = function(docEl) {
    var attrs = docEl.attributes;
    var status = attrs.getNamedItem('status').value;
    var message = attrs.getNamedItem("message").value;

    if (message == "DoNotPost") {
        return;
    }

    var vendorName = attrs.getNamedItem("vendorName").value;
    var vendorLogoImagePath = attrs.getNamedItem("vendorLogoImagePath").value;
    var reviewText = attrs.getNamedItem("reviewText").value;
    var reviewText2 = reviewText.replace("&#39;", "'");
    var vendorRatingImagePath = attrs.getNamedItem("vendorRatingImagePath").value;
    var friendlyUrl = attrs.getNamedItem("friendlyUrl").value;
    var consumerHomePageUrl = attrs.getNamedItem("consumerHomePageUrl").value;
    ShareVendorRatingAndReviews(vendorName, vendorLogoImagePath, reviewText2, vendorRatingImagePath, friendlyUrl, consumerHomePageUrl);
}

