// --- Product Reviews ---

var productReviewsPanel = null;
function showProductReviewsPanel(isDynamicPage, wsWebsiteEndpoint, userId, productId, additionalParams) {
    showLoadingWindow("Loading, Please Wait...");

    // construct the web service request
    var wsRequest = "action=getProductReviewsContent&wsParams[multipart_result]=isDynamicPage=" + isDynamicPage;
    wsRequest += ",clientWidth=" + YAHOO.util.Dom.getViewportWidth() + ",clientHeight=" + YAHOO.util.Dom.getViewportHeight();
    wsRequest += ",uid=" + userId + ",pid=" + productId;
    if (additionalParams != null && additionalParams != "") { wsRequest += "," + additionalParams.replace("&", ","); }

    // construct the callback
    var asyncResponseCallback_showProductReviewsPanel = {
        success: function(o) {
            var resultContent = getMultipartResultById(o.responseText, "multipart_result");
            if (resultContent == "") { resultContent = geWsErrorDescription(o.responseText, true); }
            hideLoadingWindow();

            // construct and show the dynamic panel
            if (productReviewsPanel == null) { productReviewsPanel = new YAHOO.widget.Panel("productReviewsPanel", { zindex:1001, visible:false, fixedcenter:true, draggable:true, close:true, modal:true, constraintoviewport:true } ); }
            productReviewsPanel.setHeader("Product Reviews");
            productReviewsPanel.setBody(resultContent);
            productReviewsPanel.render(document.body);
            productReviewsPanel.show();

            // execute response JavaScript after the response text is shown
            launchJavascript(o.responseText);
        },
        failure: function(o) { hideLoadingWindow(); alert("Failed showProductReviewsPanel (" + o.status + " " + o.statusText + ")"); }
    }

    // make the AJAX call
    var transaction = YAHOO.util.Connect.asyncRequest('POST', wsWebsiteEndpoint, asyncResponseCallback_showProductReviewsPanel, wsRequest);
    if (transaction == null) { hideLoadingWindow(); }
}

var productReviewHelpful = null;
function reportProductReviewHelpful(isDynamicPage, wsWebsiteEndpoint, userId, productReviewId, helpful, additionalParams) {
    showLoadingWindow("Loading, Please Wait...");

    // construct the web service request
    var wsRequest = "action=addProductReviewHelpful&wsParams[multipart_result]=isDynamicPage=" + isDynamicPage;
    if (helpful) { wsRequest += ",helpful=yes"; } else { wsRequest += ",helpful=no"; }
    wsRequest += ",clientWidth=" + YAHOO.util.Dom.getViewportWidth() + ",clientHeight=" + YAHOO.util.Dom.getViewportHeight();
    wsRequest += ",uid=" + userId + ",prodReviewId=" + productReviewId;
    if (additionalParams != null && additionalParams != "") { wsRequest += "," + additionalParams.replace("&", ","); }

    // construct the callback
    var asyncResponseCallback_showProductReviewHelpful = {
        success: function(o) {
            var resultContent = getMultipartResultById(o.responseText, "multipart_result");
            if (resultContent == "") { resultContent = geWsErrorDescription(o.responseText, true); }
            launchJavascript(o.responseText);
            hideLoadingWindow();
            alert(resultContent);
        },
        failure: function(o) { hideLoadingWindow(); alert("Failed reportProductReviewHelpful (" + o.status + " " + o.statusText + ")"); }
    }

    // make the AJAX call
    var transaction = YAHOO.util.Connect.asyncRequest('POST', wsWebsiteEndpoint, asyncResponseCallback_showProductReviewHelpful, wsRequest);
    if (transaction == null) { hideLoadingWindow(); }
}

var productReviewAbuse = null;
function reportProductReviewAbuse(isDynamicPage, wsWebsiteEndpoint, userId, productReviewId, additionalParams) {
    showLoadingWindow("Loading, Please Wait...");

    // construct the web service request
    var wsRequest = "action=addProductReviewAbuse&wsParams[multipart_result]=isDynamicPage=" + isDynamicPage;
    wsRequest += ",clientWidth=" + YAHOO.util.Dom.getViewportWidth() + ",clientHeight=" + YAHOO.util.Dom.getViewportHeight();
    wsRequest += ",uid=" + userId + ",prodReviewId=" + productReviewId;
    if (additionalParams != null && additionalParams != "") { wsRequest += "," + additionalParams.replace("&", ","); }

    // construct the callback
    var asyncResponseCallback_showProductReviewAbuse = {
        success: function(o) {
            var resultContent = getMultipartResultById(o.responseText, "multipart_result");
            if (resultContent == "") { resultContent = geWsErrorDescription(o.responseText, true); }
            launchJavascript(o.responseText);
            hideLoadingWindow();
            alert(resultContent);
        },
        failure: function(o) { hideLoadingWindow(); alert("Failed reportProductReviewAbuse (" + o.status + " " + o.statusText + ")"); }
    }

    // make the AJAX call
    var transaction = YAHOO.util.Connect.asyncRequest('POST', wsWebsiteEndpoint, asyncResponseCallback_showProductReviewAbuse, wsRequest);
    if (transaction == null) { hideLoadingWindow(); }
}

var viewReviewCommentsPanel = null;
function showViewProductReviewComments(isDynamicPage, wsWebsiteEndpoint, userId, productId, reviewId, additionalParams) {
    showLoadingWindow("Loading, Please Wait...");

    // construct the web service request
    var wsRequest = "action=getProductReviewCommentsContent&wsParams[multipart_result]=isDynamicPage=" + isDynamicPage;
    wsRequest += ",clientWidth=" + YAHOO.util.Dom.getViewportWidth() + ",clientHeight=" + YAHOO.util.Dom.getViewportHeight();
    wsRequest += ",uid=" + userId + ",pid=" + productId + ",rid=" + reviewId;
    if (additionalParams != null && additionalParams != "") { wsRequest += "," + additionalParams.replace("&", ","); }

    // construct the callback
    var asyncResponseCallback_showViewProductReviewComments = {
        success: function(o) {
            var resultContent = getMultipartResultById(o.responseText, "multipart_result");
            if (resultContent == "") { resultContent = geWsErrorDescription(o.responseText, true); }
            hideLoadingWindow();

            // construct and show the dynamic panel
            if (viewReviewCommentsPanel == null) { viewReviewCommentsPanel = new YAHOO.widget.Panel("viewReviewCommentsPanel", { zindex:1001, visible:false, fixedcenter:true, draggable:true, close:true, modal:true, constraintoviewport:true } ); }
            viewReviewCommentsPanel.setHeader("Product Review Comments");
            viewReviewCommentsPanel.setBody(resultContent);
            viewReviewCommentsPanel.render(document.body);
            viewReviewCommentsPanel.show();

            // execute response JavaScript after the response text is shown
            launchJavascript(o.responseText);
        },
        failure: function(o) { hideLoadingWindow(); alert("Failed showViewProductReviewComments (" + o.status + " " + o.statusText + ")"); }
    }

    // make the AJAX call
    var transaction = YAHOO.util.Connect.asyncRequest('POST', wsWebsiteEndpoint, asyncResponseCallback_showViewProductReviewComments, wsRequest);
    if (transaction == null) { hideLoadingWindow(); }
}

var productReviewCommentHelpful = null;
function reportProductReviewCommentHelpful(isDynamicPage, wsWebsiteEndpoint, userId, productReviewCommentId, helpful, additionalParams) {
    showLoadingWindow("Loading, Please Wait...");

    // construct the web service request
    var wsRequest = "action=addProductReviewCommentHelpful&wsParams[multipart_result]=isDynamicPage=" + isDynamicPage;
    if (helpful) { wsRequest += ",helpful=yes"; } else { wsRequest += ",helpful=no"; }
    wsRequest += ",clientWidth=" + YAHOO.util.Dom.getViewportWidth() + ",clientHeight=" + YAHOO.util.Dom.getViewportHeight();
    wsRequest += ",uid=" + userId + ",prodReviewCommentId=" + productReviewCommentId;
    if (additionalParams != null && additionalParams != "") { wsRequest += "," + additionalParams.replace("&", ","); }

    // construct the callback
    var asyncResponseCallback_showProductReviewCommentHelpful = {
        success: function(o) {
            var resultContent = getMultipartResultById(o.responseText, "multipart_result");
            if (resultContent == "") { resultContent = geWsErrorDescription(o.responseText, true); }
            launchJavascript(o.responseText);
            hideLoadingWindow();
            alert(resultContent);
        },
        failure: function(o) { hideLoadingWindow(); alert("Failed reportProductReviewCommentHelpful (" + o.status + " " + o.statusText + ")"); }
    }

    // make the AJAX call
    var transaction = YAHOO.util.Connect.asyncRequest('POST', wsWebsiteEndpoint, asyncResponseCallback_showProductReviewCommentHelpful, wsRequest);
    if (transaction == null) { hideLoadingWindow(); }
}

var productReviewCommentAbuse = null;
function reportProductReviewCommentAbuse(isDynamicPage, wsWebsiteEndpoint, userId, productReviewCommentId, additionalParams) {
    showLoadingWindow("Loading, Please Wait...");

    // construct the web service request
    var wsRequest = "action=addProductReviewCommentAbuse&wsParams[multipart_result]=isDynamicPage=" + isDynamicPage;
    wsRequest += ",clientWidth=" + YAHOO.util.Dom.getViewportWidth() + ",clientHeight=" + YAHOO.util.Dom.getViewportHeight();
    wsRequest += ",uid=" + userId + ",prodReviewCommentId=" + productReviewCommentId;
    if (additionalParams != null && additionalParams != "") { wsRequest += "," + additionalParams.replace("&", ","); }

    // construct the callback
    var asyncResponseCallback_showProductReviewCommentAbuse = {
        success: function(o) {
            var resultContent = getMultipartResultById(o.responseText, "multipart_result");
            if (resultContent == "") { resultContent = geWsErrorDescription(o.responseText, true); }
            launchJavascript(o.responseText);
            hideLoadingWindow();
            alert(resultContent);
        },
        failure: function(o) { hideLoadingWindow(); alert("Failed reportProductReviewCommentAbuse (" + o.status + " " + o.statusText + ")"); }
    }

    // make the AJAX call
    var transaction = YAHOO.util.Connect.asyncRequest('POST', wsWebsiteEndpoint, asyncResponseCallback_showProductReviewCommentAbuse, wsRequest);
    if (transaction == null) { hideLoadingWindow(); }
}