﻿var origVals = new Dictionary();

$(document).ready(function() {
    origVals = new Dictionary();
    $("a[id*=editLink]").siblings().filter(":first").children().each(function() {
        origVals.Add($(this).attr("id"), $(this).attr("value"));
    });
});

jQuery(function($) {
    $("a[id*=editLink]").click(function() {
        if ($(this).html() == 'edit') {
            editClicked($(this));
        } else {
            cancelClicked($(this));
        }
    });
});

function editClicked(lnk) {
    lnk.html('cancel');
    lnk.siblings().show();
}

function cancelClicked(lnk) {
    lnk.html('edit');
    lnk.siblings().hide();
    lnk.siblings().filter(":first").children().each(function(elem) {
        $(this).attr("value", origVals.Lookup($(this).attr("id")));
    });   
}

