﻿var buttonSubmit = '';

// handler definition to personalize
function SetSubmitHandler(form) {
    // setting a pointer to the original submit function
    // to really post the form to the server
    form.orginalSubmit = form.submit;

    // function that replaces the normal post function
    form.newSubmit = function() {
        if (buttonSubmit = 'doIt') {
            if (pageTracker) {
                pageTracker._trackEvent("SERP Interactions", "Request", $j("input[schoolTrack]").attr("value"), $j("input[schoolCount]").attr("value"));
            }
        }


        form.orginalSubmit();
    }

    // replacing the standard handler (posting to the server)
    // with the new handler
    form.submit = form.newSubmit;
}

if (document.URL.indexOf("SearchResult") > 0) {

    $j("table[schoolid]").live("click", function() {
        if (pageTracker) {
            pageTracker._trackEvent("SERP Interactions", "Add", $j(this).attr("schoolid"), 1);
        }
        ntptEventTag('ev=Add to Cart');
    }
    );

    $j("table[removeid]").live("click", function() {
        ntptEventTag('ev=Remove from the Cart');
    }
    );

    // setting the handler of the main form:
    SetSubmitHandler(document.forms[0]);

}