﻿function showAddLinkPopup() {
    dialogAddLink.showDialog();
}
function addLinkToFavorites(uid) {
    rpc.startRequest(addLinkToFavoritesComplete, "There was an unexpected problem trying to add this link to your favorites.  Please try again.  This problem has been logged for evaluation by our support team.", "/links/addfavoritelink.ashx", "uid=" + uid);
}
function addLinkToFavoritesComplete(response) {
    if (response == "1") {
        alert("The link has been successfully added to your favorites, check out your public profile page to see it.");
    }
    else {
        alert(response);
    }
}
var dialogAddLink = function() {
    var dialog;
    return {
        init: function() {
        },
        hide: function() {
            dialog.hide();
        },
        showDialog: function() {
            if (!dialog) {
                document.getElementById("divAddLink").style.display = "";
                dialog = new YAHOO.widget.Dialog("divAddLink", { width: "485px", fixedcenter: true, draggable: true, visible: false, modal: true, constraintoviewport: true, zindex: 9001, postmethod: '', buttons: [{ text: "Add Link", handler: addLink, isDefault: true}] });
                dialog.cfg.queueProperty("postmethod", "form");
                dialog.render(document.body);
            }
            dialog.show();
        }
    };
} ();
function addLink() {
    genericSaveChanges(['Name', 'URL', 'LocationAddress', 'LocationCity', 'LocationStateProvince', 'LocationPostalCode', 'Description'], ['LinkTypeID'], [], "/links/addlink.ashx", addLinkComplete);
    /*
    var newlink = {};
    newlink.Name = document.getElementById("txtLinkName").value;
    newlink.Url = document.getElementById("txtLinkURL").value;
    newlink.LocationAddress = document.getElementById("txtAddress").value;
    newlink.LocationCity = document.getElementById("txtCity").value;
    newlink.LocationStateProvince = document.getElementById("txtStateProvince").value;
    newlink.LocationPostalCode = document.getElementById("txtPostalCode").value;
    newlink.Description = document.getElementById("txtDescription").value;
    newlink.LinkTypeID = document.getElementById("drpLinkType").options[document.getElementById("drpLinkType").selectedIndex].value;
    rpc.startRequest(addLinkComplete, "There was an unexpected problem trying to create your link.  Please try again.  This problem has been logged for evaluation by our support team.", "/links/addlink.ashx", "link=" + escape(YAHOO.lang.JSON.stringify(newlink)));
    */
}
function addLink2() {
    genericSaveChanges({ TextFields: ['Name', 'URL', 'Description'], DropDownFields: [], CheckFields: [], TextCollFields: [{ FieldName: 'Keywords', Fields: ['Keyword1', 'Keyword2', 'Keyword3']}]}, "/links/addlink.ashx", addLinkComplete);
}
function addLinkComplete(response) {
    document.getElementById("Name").value = "";
    document.getElementById("URL").value = "";
    document.getElementById("Description").value = "";
    document.getElementById("Keyword1").value = "";
    document.getElementById("Keyword2").value = "";
    document.getElementById("Keyword3").value = "";
}
function addVideoToFavorites(vid) {
    rpc.startRequest(addVideoToFavoritesComplete, "There was an unexpected problem trying to add this video to your favorites.  Please try again.  This problem has been logged for evaluation by our support team.", "/videos/addfavoritevideo.ashx", "vid=" + vid);
}
function addVideoToFavoritesComplete(response) {
    if (response == "1") {
        alert("The video has been successfully added to your favorites, check out your public profile page to see it.");
    }
    else {
        alert(response);
    }
}

