/* Last updated: 10/16/2009 */
function bn_isNotEmpty(name) {
    return (name != null) && (name != "");
}
function bn_getOrderInfo() {
    if (typeof (bnOrderId) != "undefined" && bn_isNotEmpty(bnOrderId))
        baynote_tag.attrs.purchaseId = bnOrderId;
    if (typeof (bnOrderTotal) != "undefined" && bn_isNotEmpty(bnOrderTotal))
        baynote_tag.attrs.totalPurchases = parseFloat(bnOrderTotal);
    if (typeof (bnOrderDetails) != "undefined" && bn_isNotEmpty(bnOrderDetails))
        baynote_tag.attrs.purchaseDetails = bnOrderDetails;
}
function bn_getMediaInfo() {
    if (typeof (bnMediaDuration) != "undefined" && bn_isNotEmpty(bnMediaDuration)) {
        baynote_tag.attrs.expectedDuration = bnMediaDuration;
    }
}
function bn_showObserver() {
    /* 1. set customer id */
    bn_customerId = "tablespoon";
    /* 2. set customer code */
    bn_code = "www";
    var bn_locHref = window.location.href;
    if (bn_locHref.indexOf("https://") == 0) {
        baynote_tag.server = "https://" + bn_customerId + "-" + bn_code + ".baynote.net";
    } else {
        baynote_tag.server = "http://" + bn_customerId + "-" + bn_code + ".baynote.net";
    }
    baynote_tag.customerId = bn_customerId;
    baynote_tag.code = bn_code;
    baynote_tag.type = "baynoteObserver";
    /* 3. set customer domain (optional) */
    baynote_globals.cookieDomain = "tablespoon.com";
    /* 4. collect purchase info (optional) */
    bn_getOrderInfo();
    bn_getMediaInfo();
    baynote_tag.exitConfirmation = bn_onClickHandler;
    baynote_tag.show();
}

function bn_onClickHandler(clickedElement, exitInfo) {
    if (typeof (bnObserver) != 'undefined' && typeof (bnObserver.defaultExitConfirmation) != 'undefined') {
        exitResult = bnObserver.defaultExitConfirmation(clickedElement, exitInfo);
    }


    if (clickedElement) {
        if (exitInfo != null && typeof (exitInfo.attrs) == "undefined") {
            exitInfo.attrs = new Object();
        }
        if (bn_isNotEmpty(clickedElement.tagName)) {
            var idName = clickedElement.id + "";
            var pidName = clickedElement.parentNode.id + "";
            var ppidName = clickedElement.parentNode.parentNode.id + "";
            var className = clickedElement.className + "";
            var pclassName = clickedElement.parentNode.className + "";
            if (pidName == 'add' || idName == 'ctl04_ctl05_ctlRecipeDetails_calloutSave') {
                exitInfo.attrs.recipeBoxPage = '1';
            } else if (pidName == 'send') {
                exitInfo.attrs.sendToFriend = '1';
            } else if (pidName == 'print') {
                exitInfo.attrs.printRecipe = '1';
            } else if (pidName == 'ctl04_ctl04_lnkCreateVariation') {
                exitInfo.attrs.createAVersion = '1';
            } else if (className == 'addRecipe open-connect-login open-connect-login' || className == 'addRecipe') {
                exitInfo.attrs.recipeBoxSearch = '1';
            } else if (ppidName == 'ctl03_ctlLogin_logged_out') {
                exitInfo.attrs.registerUser = '1';
            } else if (className == 'call_comments odd' || className == 'call_comments even') {
                exitInfo.attrs.commentRecipe = '1';
            } else if (pclassName == 'mainrating') {
                exitInfo.attrs.rateRecipe = '1';
            }
        }
    }
    return exitResult;
}
if (typeof (baynote_tag) != "undefined") {
    bn_showObserver();
}

