
/**
 * @author Rigre G. Garciandia Sonora
 * 
 */
function ajaxShowMoreFromThisContributorListings(listingId, extraParameters) {
    populateAJAXPlaceholder(getContextName() + "search-more-from-this-contributor-listings.do?lid=" + listingId + "&" + extraParameters, "related-listings-content");
}
function ajaxAddListingToMyChannel(listingId) {
    executeAJAXCommand(getContextName() + "member-ajax-command.do?command=addToMyChannel&pfid=-1&lid=" + listingId);
}
function ajaxMarkAsInapropiate(listingId) {
    executeAJAXCommand(getContextName() + "member-ajax-command.do?command=markAsInapropiate&lid=" + listingId);
}
function ajaxSubscribe(prsid) {
    executeAJAXCommand(getContextName() + "member-ajax-command.do?command=subscribe&prsid=" + prsid);
}
/*
function ajaxVoteForListing(listingId, rating) {
    if (ratingComponent.isEnableEvents()) {
        executeAJAXCommand(getContextName() + "member-ajax-command.do?command=voteForListing&lid=" + listingId + "&rating=" + rating);
    }
}
*/
function ajaxVoteForListing(listingId, rating) {
    if (ratingComponent.isEnableEvents()) {
        executeAJAXCommand(getContextName() + "anonymous-ajax-command.do?command=voteForListing&lid=" + listingId + "&rating=" + rating);
    }
}

function ajaxSubmitValidationEmail(email,fullName,returnURL){
 executeAJAXCommand(getContextName() + "anonymous-ajax-command.do?command=validateEmail&email=" + email + "&fullName=" + fullName+ "&returnURL=" + returnURL);
 }

function ajaxShowComments(listingId, returnUrl) {
    populateAJAXPlaceholder(getContextName() + "listing-comments.do?lid=" + listingId + "&returnurl=" + Url.encode(returnUrl), "commentForm");
}

function ajaxFilterComment(formVar) {
	
	var result = encodeURIComponent(formVar);
result = result.replace(/%20/g,"+");
for ( var p = result.indexOf("%u"); p != -1; p = result.indexOf("%u")  ) {
   var code = result.substr(p,6);
   var rep = '%' + code.substr(2,2) + '%' + code.substr(4,2);
   result = result.replace(code,rep);
}
var p = -1;
for ( p = result.indexOf("%",p+1); p != -1; p = result.indexOf("%",p+1)  ) {
   var code = result.substr(p,3);
   var rep = code.toUpperCase();
   result = result.replace(code,rep);
}
return result;
}
function ajaxSubmitCommentListingForm(listingId) {
	  populateAJAXFormPlaceholder(getContextName() + "listing-comments.do?lid=" + listingId, createFormParameters("commentForm", new Array("text", "action", "pageNumber")), "commentForm");
}
function ajaxMarkCommentAsSPAM(commentId) {
    executeAJAXCommand(getContextName() + "member-ajax-command.do?command=markCommentAsSPAM&comment=" + commentId);
}
function ajaxSelectPortfolio() {
    if (!isVisible("add-listing-to-my-channel-select-portfolio-content")) {
        populateAJAXPlaceholderWithPostAction(getContextName() + "search-select-portfolio.do", "add-listing-to-my-channel-select-portfolio-content", function (ajaxContext) {
            setVisible("add-listing-to-my-channel-select-portfolio-content", true);
        });
    } else {
        closeSelectPortfolio();
    }
}
function closeSelectPortfolio() {
    cleanDiv("add-listing-to-my-channel-select-portfolio-content");
    setVisible("add-listing-to-my-channel-select-portfolio-content", false);
}
function analyzePortfolioSelection(selectPortfolio) {
    if (selectPortfolio.options[selectPortfolio.selectedIndex].value == -2) {
        populateAJAXPlaceholderWithPostAction(getContextName() + "search-add-portfolio.do", "add-listing-to-my-channel-select-portfolio-content", function (ajaxContext) {
            setVisible("add-listing-to-my-channel-select-portfolio-content", true);
        });
    } else {
        changeFormProperty("searchResultForm", "destinationPortfolioId", selectPortfolio.options[selectPortfolio.selectedIndex].value);
    }
}
function ajaxSubmitAddPortfolioForm() {
    populateAJAXFormPlaceholder(getContextName() + "search-add-portfolio.do", createFormParameters("addPortfolio", new Array("name")), "add-listing-to-my-channel-select-portfolio-content");
}
function ajaxImportRSS(url, rssurl, rssindex) {
    executeAJAXCommand(getContextName() + "admin-ajax-command.do?command=importRSS&url=" + encode(url) + "&rssurl=" + Url.encode(rssurl) + "&rssindex=" + rssindex);
}
function ajaxShowSearchComponent(url, divName) {
    populateAJAXPlaceholder(url, divName);
}
function ajaxSubmitSearchComponentForm(formName, action, url, divName) {
    changeFormProperty(formName, "action", action);
    populateAJAXFormPlaceholder(url, createFormParameters(formName, new Array("newVideoState", "catalogListingState", "catalogListingId", "videoState", "action", "pageNumber", "selectedCategoryListing", "destinationPortfolioId", "viewState", "genericData", "state")), divName);
}
function ajaxNominate(listingId, nomid) {
    if (nomid != "-1") {
        executeAJAXCommand(getContextName() + "member-ajax-command.do?command=nominate&lid=" + listingId + "&nomid=" + nomid);
    }
}
//Admin site
function ajaxAdminListingChangeContextFilter() {
    var contextValue = document.adminResultForm.selectContextFilter.options[document.adminResultForm.selectContextFilter.selectedIndex].value;
    if (contextValue != "") {
        populateAJAXPlaceholder(contextValue, "admin-listings-content");
    }
}
function ajaxRecoverListingField() {
    executeAJAXCommand(getContextName() + "admin-ajax-command.do?command=recoverListingField");
}
//Registration
function ajaxChangePassword(form, login) {
    executeAJAXPostCommand(getContextName() + "member-ajax-command.do?command=changePassword&login=" + login, createFormParameters(form, new Array("oldPassword", "newPassword", "confirmNewPassword", "ctx")));
}
function ajaxResetPassword(login) {
    executeAJAXPostCommand(getContextName() + "admin-ajax-command.do?command=resetPassword&login=" + login);
}

