/**
* The YAHOO module provides utilities to be used on Yahoo! stores.
*
* @module yahoo
* @title Yahoo!
* @namespace MUI
* @requires util, ga
*/
if(typeof(MUI) != "undefined") {
if(typeof(MUI.yahoo) == "undefined") {
/**
* The YAHOO module provides utilities to be used on Yahoo! stores.
*
* @class yahoo
* @namespace MUI
* @static
*/
MUI.yahoo = {
_tracking_objects: new Array(),
/**
* Get a broad enough domain to be used for cookies on a Yahoo! store.
*
* @method cookie_domain
*
* @param {string} pDomain the domain OR null OR "auto". If not null, this simply returns the passed domain.
*
* @return {string} a domain broad enough to be used for store cookies.
*
* @static
*/
cookie_domain: function(pDomain) {
if(!pDomain || (pDomain == "auto")) {
pDomain = null;
if(location.hostname.match(/stores\.yahoo\.net$/i)) pDomain = 'stores.yahoo.net';
else if(location.hostname.match(/yahoo\.net$/i)) pDomain = 'store.yahoo.net';
else if(location.hostname.match(/(search|lib)\.store\.yahoo\.com$/i)) pDomain = 'store.yahoo.com';
else pDomain = location.hostname.replace(/(?:^|.+\.)([^\.]+\.[^\.]+)$/i, "$1");
}
return pDomain;
},
/**
* Save the current referrer in a cookie, so it can be read later.
* Particularely useful for javascript redirects: use this before you do the redirect, and then
* use MUI.util.cookie_value("_mrrf", null); on the new landing page to grab the initial referrer.
* <strong>Note: </strong> since this mechanism uses cookies, it will only work if the redirect happens on the same root domain.
*
* @method save_referrer_for_redirect
*
* @static
*/
save_referrer_for_redirect: function() {
MUI.util.set_cookie_value("_mrrf", ".", "/", MUI.yahoo.cookie_domain(), document.referrer);
},
/**
* Clear the saved referrer from the cookies; should be called as soon as you have used the referrer info.
*
* @method clear_referrer_for_redirect
*
* @static
*/
clear_referrer_for_redirect: function() {
MUI.util.set_cookie_value("_mrrf", "x", "/", MUI.yahoo.cookie_domain(), "");
},
/**
* Create a Monitus-compatible tracking object for Google Analytics. This ensures that your tracking object
* does not interfere with the Monitus one, or pollute the cookie space, etc...
*
* <p>This call will also automatically grab and use the saved referrer, if set.</p>
* <p>If the Facebook or Twitter javascript objects exists when the object is created, Social NEtowrk tracking will happen automatically.</p>
*
* @method create_ga_tracking_object
*
* @param {string} pProfileID the GA profile ID (UA-xxxxxx-x)
* @param {array} pIgnoredReferers list of ignored referrers; maps to GA's "_addIgnoredRef" function. Optional.
* @param {number} pMaxVars maximum number of custom variables allowed on the page; maps to GA's "_setMaxCustomVariables" function. Optional.
* @param {number} pSessionTimeout session timeout value; maps to GA's "_setSessionCookieTimeout" function. Optional.
*
* @return {object} a GA tracker object.
*
* @static
*/
create_ga_tracking_object: function(pProfileID, pIgnoredReferers, pMaxVars, pSessionTimeout, pTrackerName) {
var gaq = [];
pTrackerName = pTrackerName || "";
if(typeof(_gat) != "undefined") {
var tracker = _gat._getTrackerByName(pTrackerName);
if(tracker && (typeof(tracker._getAccount) == "function")) {
tracker = tracker._getAccount();
if((typeof(tracker) == "string") && (!tracker.match(/^[ua\-x]+$/i)) && (tracker != pProfileID)) pTrackerName += pProfileID.replace(/[^UA\d]+/g, '');
}
}
var prefix = pTrackerName + ((pTrackerName && (pTrackerName != "")) ? "." : "");
gaq.push([prefix + '_setAccount', pProfileID]);
gaq.push([prefix + '_setAllowHash', false]);
if(pSessionTimeout) gaq.push([prefix + '_setSessionCookieTimeout', pSessionTimeout]);
var vDomain = document.location.host;
var vTokens = vDomain.match(/(store\.yahoo\.(com|net))/i);
if(vTokens) vDomain = vTokens[1];
else {
vTokens = document.location.host.match(/.*\.([^\.]+\.[^\.]+)\/?$/i);
if(vTokens) vDomain = vTokens[1];
}
gaq.push([prefix + '_setDomainName', vDomain]);
gaq.push([prefix + '_setAllowLinker', true]);
if(typeof(monitus_ref_analyzer) != "undefined") monitus_ref_analyzer.setup_ga(prefix, gaq);
if(MUI.yahoo.current_page_id().match(/ysco\./)) gaq.push([prefix + '_setSiteSpeedSampleRate', 20]);
var vIgnoredReferers = [vDomain, "paypal.com", "edit.store.yahoo.net", "stores.yahoo.net", "order.store.yahoo.net", "search.store.yahoo.com", "search.store.yahoo.net"];
if(pIgnoredReferers) vIgnoredReferers = vIgnoredReferers.concat(pIgnoredReferers);
for(var vLoop = 0; vLoop < vIgnoredReferers.length; vLoop++) gaq.push([prefix + '_addIgnoredRef', vIgnoredReferers[vLoop]]);
if(pMaxVars && (pMaxVars != 5)) gaq.push([prefix + '_setMaxCustomVariables', pMaxVars]);
var vOverridenReferrer = MUI.util.cookie_value("_mrrf", null);
if(vOverridenReferrer) gaq.push([prefix + '_setReferrerOverride', vOverridenReferrer]);
if((typeof(FB) != "undefined") && (typeof(FB.Event) != "undefined")) {
FB.Event.subscribe('edge.create', function(pTargetURL) { window._gaq.push(['_trackSocial', 'facebook', 'like', pTargetURL]); });
FB.Event.subscribe('edge.remove', function(pTargetURL) { window._gaq.push(['_trackSocial', 'facebook', 'unlike', pTargetURL]); });
FB.Event.subscribe('message.send', function(pTargetURL) { window._gaq.push(['_trackSocial', 'facebook', 'send', pTargetURL]); });
}
if((typeof(twttr) != "undefined") && (typeof(twttr.events) != "undefined")) {
twttr.events.bind('tweet', function(pEvent) {
if(pEvent) {
var vTargetURL;
if(pEvent.target && pEvent.target.nodeName.match(/iframe/i)) vTargetURL = MUI.util.url_parameter(pEvent.target.src, 'url', null);
window._gaq.push(['_trackSocial', 'twitter', 'tweet', vTargetURL]);
}
});
}
if(typeof(addthis) != "undefined") {
addthis.addEventListener('addthis.menu.share', function(pEvent) {
window._gaq.push(['_trackSocial', pEvent.data.service, 'addthis', null]);
});
}
// add anything that was queued before our init...
window._gaq = window._gaq || [];
if((typeof(console) != "undefined") && document.location.search.match(/MDEBUG/)) console.log(window._gaq);
if(typeof(monitus_gaq) == "undefined") monitus_gaq = [];
monitus_gaq = gaq.concat(monitus_gaq);
if((typeof(console) != "undefined") && document.location.search.match(/MDEBUG/)) console.log(monitus_gaq);
if(Object.prototype.toString.call(window._gaq) == "[object Object]") {
if(window._gaq.monitus_push) {
window._gaq.push = window._gaq.monitus_push;
window._gaq.monitus_push = null;
}
for(var loop = 0; loop < monitus_gaq.length; loop++) window._gaq.push(monitus_gaq[loop]);
} else window._gaq = monitus_gaq; // it's ok to loose the "push" override here - the tracker is initialized and when ga loads, it will slurp the whole _gaq array
monitus_gaq = null;
if(typeof(_gat) != "undefined") {
if((typeof(_gat._getTrackerByName) != "function") && (typeof(monitus_error_trap) == "function")) monitus_error_trap(0, "error_ga", "_gat._getTrackerByName undefined! (" + _gat + ")");
return _gat._getTrackerByName(pTrackerName);
} else {
if(typeof(monitus_error_trap) == "function") monitus_error_trap(0, "error_ga", "_gat undefined!");
var fc = function(){};
return {_dud:true, _setCustomVar:fc, _trackPageview:fc, _trackEvent:fc, _addTrans:fc, _addItem:fc, _trackTrans:fc};
}
/*
var fc = function(){};
MUI.yahoo._tracking_objects[pProfileID] = {_dud:true, _setCustomVar:fc, _trackPageview:fc, _trackEvent:fc, _addTrans:fc, _addItem:fc, _trackTrans:fc};
if(MUI.yahoo._tracking_objects[pProfileID]._dud && (typeof(_gat) != "undefined") && ((typeof(_gat._createTracker) == "function") || (typeof(_gat._getTracker) == "function"))) {
MUI.yahoo._tracking_objects[pProfileID] = ((typeof(_gat._createTracker) == "function") ? _gat._createTracker(pProfileID) : _gat._getTracker(pProfileID));
if(typeof(MUI.yahoo._tracking_objects[pProfileID]._setAllowHash) == "function") MUI.yahoo._tracking_objects[pProfileID]._setAllowHash(false); // deprecated but still required to cross domains!
if(pSessionTimeout && (typeof(MUI.yahoo._tracking_objects[pProfileID]._setSessionCookieTimeout) == "function")) MUI.yahoo._tracking_objects[pProfileID]._setSessionCookieTimeout(pSessionTimeout);
var vDomain = document.location.host;
var vTokens = vDomain.match(/(store\.yahoo\.(com|net))/i);
if(vTokens) vDomain = vTokens[1];
else {
vTokens = document.location.host.match(/.*\.([^\.]+\.[^\.]+)\/?$/i);
if(vTokens) vDomain = vTokens[1];
}
if(typeof(MUI.yahoo._tracking_objects[pProfileID]._setDomainName) == "function") MUI.yahoo._tracking_objects[pProfileID]._setDomainName(vDomain);
if(typeof(MUI.yahoo._tracking_objects[pProfileID]._setAllowLinker) == "function") MUI.yahoo._tracking_objects[pProfileID]._setAllowLinker(true);
if(typeof(monitus_ref_analyzer) != "undefined") monitus_ref_analyzer.setup_ga(MUI.yahoo._tracking_objects[pProfileID]);
if(typeof(MUI.yahoo._tracking_objects[pProfileID]._addIgnoredRef) == "function") {
var vIgnoredReferers = [vDomain, "paypal.com", "edit.store.yahoo.net", "stores.yahoo.net", "order.store.yahoo.net", "search.store.yahoo.com", "search.store.yahoo.net"];
if(pIgnoredReferers) vIgnoredReferers = vIgnoredReferers.concat(pIgnoredReferers);
for(var vLoop = 0; vLoop < vIgnoredReferers.length; vLoop++) MUI.yahoo._tracking_objects[pProfileID]._addIgnoredRef(vIgnoredReferers[vLoop]);
}
if(pMaxVars && (pMaxVars != 5) && (typeof(MUI.yahoo._tracking_objects[pProfileID]._setMaxCustomVariables) == "function")) MUI.yahoo._tracking_objects[pProfileID]._setMaxCustomVariables(pMaxVars);
var vOverridenReferrer = MUI.util.cookie_value("_mrrf", null);
if(vOverridenReferrer && (typeof(MUI.yahoo._tracking_objects[pProfileID]._setReferrerOverride) == "function")) MUI.yahoo._tracking_objects[pProfileID]._setReferrerOverride(vOverridenReferrer);
var vTracker = MUI.yahoo._tracking_objects[pProfileID];
if((typeof(FB) != "undefined") && (typeof(FB.Event) != "undefined")) {
FB.Event.subscribe('edge.create', function(pTargetURL) { vTracker._trackSocial('facebook', 'like', pTargetURL); });
FB.Event.subscribe('edge.remove', function(pTargetURL) { vTracker._trackSocial('facebook', 'unlike', pTargetURL); });
FB.Event.subscribe('message.send', function(pTargetURL) { vTracker._trackSocial('facebook', 'send', pTargetURL); });
}
if((typeof(twttr) != "undefined") && (typeof(twttr.events) != "undefined")) {
twttr.events.bind('tweet', function(pEvent) {
if(pEvent) {
var vTargetURL;
if(pEvent.target && pEvent.target.nodeName.match(/iframe/i)) vTargetURL = MUI.util.url_parameter(pEvent.target.src, 'url', null);
vTracker._trackSocial('twitter', 'tweet', vTargetURL);
}
});
}
if(typeof(addthis) != "undefined") {
addthis.addEventListener('addthis.menu.share', function(pEvent) {
vTracker._trackSocial(pEvent.data.service, 'addthis', null);
});
}
} else if((pProfileID == "UA-296592-3") && (typeof(monitus_error_trap) == "function")) monitus_error_trap(242, "debug", MUI.yahoo._tracking_objects[pProfileID]._dud+", "+typeof(_gat)+", "+((typeof(_gat) != "undefined") ? typeof(_gat._createTracker) : "-")+", "+((typeof(_gat) != "undefined") ? typeof(_gat._getTracker) : "-"));
return MUI.yahoo._tracking_objects[pProfileID];
*/
},
/**
* Grab the current page's ID; on the store domain, will be the product ID.
* On the checkout side, it will be the "sectionId" value. (ysco.cart, ysco.ship-bill, ...)
*
* @method current_page_id
*
* @return {object} the current page's ID.
*
* @static
*/
current_page_id: function() {
var vTokens = window.location.search.match(/sectionId\=([^&]*)/);
if(window.location.search && (vTokens || window.location.pathname.match(/\/wg\-order/))) {
if(vTokens) return vTokens[1];
else return "ysco.cart";
} else {
vTokens = window.location.pathname.match(/([^\/\.]+)\..+?$/);
if(vTokens) return vTokens[1];
else return "homepage";
}
},
/**
* Builds new order variables that are cleaned-up. On the confirmation page, Yahoo! gives javascript developers
* a series of variables that hold the items ordered, quantity ordered, etc... Except that it does not create a list of unique product IDs.
* So if a customer orders a product, but with different options, for instance, this creates 2 lines in Yahoo!'s arrays,
* even though we do not have the actual options that could differentiate the ordered items... So this function
* makes sure that this product will only show once in the list of ordered products, and adjusts the quantity accordingly.
*
* <strong>Note: </strong> This also considered the price of the items. So if certain options cost more, then the product will
* be kept on two lines.
*
* The new arrays to use are: mon_order_ids, mon_order_items, mon_order_codes, mon_order_price, mon_order_qtys
*
* @method cleanup_order_data
*
* @static
*/
cleanup_order_data: function() {
if(typeof(window.ids) != "undefined") {
var vMerged = new Array();
for(var vLoop = 0; vLoop < window.ids.length; vLoop++) {
var vIndex = "item_" + window.ids[vLoop] + ";" + window.price[vLoop];
if(typeof(vMerged[vIndex]) != "undefined") {
vMerged[vIndex].qty += parseInt(window.qtys[vLoop]);
} else {
vMerged[vIndex] = {id: window.ids[vLoop], item: window.items[vLoop], code: window.codes[vLoop], price: window.price[vLoop], qty: parseInt(window.qtys[vLoop])};
}
}
window.mon_order_ids = new Array();
window.mon_order_items = new Array();
window.mon_order_codes = new Array();
window.mon_order_price = new Array();
window.mon_order_qtys = new Array();
for(var vLoop in vMerged) {
if((typeof(vLoop) == "string") && vLoop.match(/^item_/)) {
var vRecord = vMerged[vLoop];
window.mon_order_ids[window.mon_order_ids.length] = vRecord.id;
window.mon_order_items[window.mon_order_items.length] = vRecord.item;
window.mon_order_codes[window.mon_order_codes.length] = vRecord.code;
window.mon_order_price[window.mon_order_price.length] = vRecord.price;
window.mon_order_qtys[window.mon_order_qtys.length] = vRecord.qty;
}
}
}
},
/**
* Attaches an onclick event handler to the "Update" button on the cart page, so the click can be tracked as an event
* in Google Analytics.
*
* @method install_track_cart_update
*
* @param {string|object} pTrackerObject the name of the tracker object variabl, or the actual tracker object.
* @param {number} pVariableSlot the variable's slot number. (1-5)
* @param {string} pOptionalVariableName the vairable's name. Default: "Crt"
* @param {number} pOptionalVariableScope the variable's scope. One of: MUI.ga.kvariable_scope_visitor, MUI.ga.kvariable_scope_session or MUI.ga.kvariable_scope_page. Default: MUI.ga.kvariable_scope_session
*
* @static
*/
track_cart_content: function(pTrackerObject, pVariableSlot, pOptionalVariableName, pOptionalVariableScope) {
if(typeof(ids) == "undefined") return;
if(typeof(pOptionalVariableName) == "undefined") pOptionalVariableName = "Crt";
if(typeof(pOptionalVariableScope) == "undefined") pOptionalVariableScope = MUI.ga.kvariable_scope_session;
var vValue ="";
var vMyIDs = ids.slice();
do{
vValue = vMyIDs.join("|");
vMyIDs.pop();
} while((vMyIDs.length > 0) && (vValue.length > 125));
var vTracker = null;
if(typeof(pTrackerObject) == "string") {
try{
vTracker = eval(pTrackerObject);
} catch(e){}
} else vTracker = pTrackerObject;
if(!vTracker || (typeof(vTracker) == "undefined") || (typeof(vTracker._setCustomVar) != "function")) MUI.ga.queue_custom_variable(pVariableSlot, pOptionalVariableName, vValue, pOptionalVariableScope);
else vTracker._setCustomVar(pVariableSlot, pOptionalVariableName, vValue, pOptionalVariableScope);
},
/**
* Attaches an onclick event handler to the "Update" button on the cart page, so the click can be tracked as an event
* in Google Analytics.
*
* @method install_track_cart_update
*
* @param {string|object} pTrackerObject the name of the tracker object variabl, or the actual tracker object.
* @param {string} pOptionalEventCategory the category for this event; can be an inflatable template. Default: "Update Cart"
* @param {string} pOptionalEventAction the action for this event; can be an inflatable template. Default: ""
* @param {string} pOptionalEventLabel the label for this event; can be an inflatable template. Default: "Checkout Button Clicked"
* @param {bool} pNonInteraction when false, event has an impact on bounce rate. When true, the event will not be used in bounce rate calculations. Default: "true"
*
* @static
*/
install_track_cart_update: function(pTrackerObject, pOptionalEventAction, pOptionalEventLabel, pOptionalEventCategory, pNonInteraction) {
if(typeof(pNonInteraction) == "undefined") pNonInteraction = true;
var vPage = MUI.yahoo.current_page_id();
if(vPage.match(/ysco\./)) {
var vButton = MUI.util.dom.object_by_name_attribute("input", "eventName.updateEvent");
if(!vButton) setTimeout("MUI.yahoo.install_track_cart_update('" + pTrackerObject + "', '" + MUI.util.string.non_null_string(pOptionalEventAction, "Update Cart") + "', '" + MUI.util.string.non_null_string(pOptionalEventLabel) + "', '" + MUI.util.string.non_null_string(pOptionalEventCategory, "Checkout Button Clicked") + "', " + (pNonInteraction ? "true" : "false") + ");", 10);
else {
MUI.ga.attach_tracking_info(vButton, pTrackerObject, MUI.util.string.non_null_string(pOptionalEventCategory, "Checkout Button Clicked"), MUI.util.string.non_null_string(pOptionalEventAction, "Update Cart"), MUI.util.string.non_null_string(pOptionalEventLabel), undefined, pNonInteraction);
vButton.onclick = function() { return MUI.ga.track_event_attached_to_object(this); };
}
}
},
/**
* Attaches an onclick event handler to the Shipping Calculator button on the checkout, so the click can be tracked as an event
* in Google Analytics.
*
* @method install_track_ship_update
*
* @param {string|object} pTrackerObject the name of the tracker object variabl, or the actual tracker object.
* @param {string} pOptionalEventCategory the category for this event; can be an inflatable template. Default: "Update Shipping - [page ID] page'"
* @param {string} pOptionalEventAction the action for this event; can be an inflatable template. Default: "[zip code] - [state] - [shipping method]"
* @param {string} pOptionalEventLabel the label for this event; can be an inflatable template. Default: "Checkout Button Clicked"
* @param {bool} pNonInteraction when false, event has an impact on bounce rate. When true, the event will not be used in bounce rate calculations. Default: "true"
*
* @static
*/
install_track_ship_update: function(pTrackerObject, pOptionalEventAction, pOptionalEventLabel, pOptionalEventCategory, pNonInteraction) {
if(typeof(pNonInteraction) == "undefined") pNonInteraction = true;
var vPage = MUI.yahoo.current_page_id();
if(vPage.match(/ysco\./)) {
vPage = vPage.replace(/ysco\./, '');
var vDefaultLabel = "%shipping-zip% - %shipping-state";
if(vPage == "cart") vDefaultLabel += "-for-shipping-calculator";
vDefaultLabel += "% - %merchant-selected-shipping-methods%";
var vButton = MUI.util.dom.object_by_name_attribute("input", "eventName.updateShippingMethodEvent");
if(!vButton) setTimeout("MUI.yahoo.install_track_ship_update('" + pTrackerObject + "', '" + MUI.util.string.non_null_string(pOptionalEventAction, "Update Shipping - " + vPage + " page") + "', '" + MUI.util.string.non_null_string(pOptionalEventLabel, vDefaultLabel) + "', '" + MUI.util.string.non_null_string(pOptionalEventCategory, "Checkout Button Clicked") + "', " + (pNonInteraction ? "true" : "false") + ");", 10);
else {
MUI.ga.attach_tracking_info(vButton, pTrackerObject, MUI.util.string.non_null_string(pOptionalEventCategory, "Checkout Button Clicked"), MUI.util.string.non_null_string(pOptionalEventAction, "Update Shipping - " + vPage + " page"), MUI.util.string.non_null_string(pOptionalEventLabel, vDefaultLabel), undefined, pNonInteraction);
vButton.onclick = function() { return MUI.ga.track_event_attached_to_object(this); };
}
}
},
/**
* Track an event when the user clicks the "Add to cart" button. To be used in an "onclick" function.
*
* @method track_add_to_cart
*
* @param {string|object} pTrackerObject the name of the tracker object variabl, or the actual tracker object.
* @param {string} pOptionalEventCategory the category for this event; can be an inflatable template. Default: "[page ID]'"
* @param {string} pOptionalEventAction the action for this event; can be an inflatable template. Default: ""
* @param {string} pOptionalEventLabel the label for this event; can be an inflatable template. Default: "Add to Cart"
* @param {bool} pNonInteraction when false, event has an impact on bounce rate. When true, the event will not be used in bounce rate calculations. Default: "true"
*
* @return {true} returns TRUE so it can easily be used in an onclick or onsubmit handler.
*
* @static
*/
track_add_to_cart: function(pTrackerObject, pOptionalEventAction, pOptionalEventLabel, pOptionalEventCategory, pNonInteraction) {
if(typeof(pNonInteraction) == "undefined") pNonInteraction = true;
MUI.ga.track_event(pTrackerObject, MUI.util.string.non_null_string(pOptionalEventCategory, "Add to Cart"), MUI.util.string.non_null_string(pOptionalEventAction, MUI.yahoo.current_page_id()), MUI.util.string.non_null_string(pOptionalEventLabel), undefined, pNonInteraction);
return true;
},
/**
* Track an event when the user clicks a "Click to enlarge" button. To be used in the "onclick" function.
*
* @method track_click_to_enlarge
*
* @param {string|object} pTrackerObject the name of the tracker object variabl, or the actual tracker object.
* @param {string} pOptionalEventCategory the category for this event; can be an inflatable template. Default: "[page ID]'"
* @param {string} pOptionalEventAction the action for this event; can be an inflatable template. Default: "clicked"
* @param {string} pOptionalEventLabel the label for this event; can be an inflatable template. Default: "Click to enlarge"
* @param {bool} pNonInteraction when false, event has an impact on bounce rate. When true, the event will not be used in bounce rate calculations. Default: "true"
*
* @return {true} returns TRUE so it can easily be used in an onclick or onsubmit handler.
*
* @static
*/
track_click_to_enlarge: function(pTrackerObject, pOptionalEventAction, pOptionalEventLabel, pOptionalEventCategory, pNonInteraction) {
if(typeof(pNonInteraction) == "undefined") pNonInteraction = true;
MUI.ga.track_event(pTrackerObject, MUI.util.string.non_null_string(pOptionalEventCategory, "Click to enlarge"), MUI.util.string.non_null_string(pOptionalEventAction, "clicked"), MUI.util.string.non_null_string(pOptionalEventLabel, MUI.yahoo.current_page_id()), undefined, pNonInteraction);
return true;
},
/**
* Changes the image of a checkout button.
*
* @method checkout_button_image_swap
*
* @param {string} pImageName the name of the image that will be swapped. (input of type "button")
* @param {url} pNewImageURL the url of the image to load instead.
*
* @static
*/
checkout_button_image_swap: function(pImageName, pNewImageURL) {
var vButton = MUI.util.dom.object_by_name_attribute("input", pImageName);
if(!vButton) setTimeout("MUI.yahoo.checkout_button_image_swap('" + pImageName + "', '" + pNewImageURL + "');", 10);
else {
try {
if(vButton.type.match(/image/i)) vButton.src = pNewImageURL;
} catch(e) { }
}
},
/**
* Changes a checkout button's caption.
*
* @method checkout_button_caption_swap
*
* @param {string} pButtonName the name of the button that will be targeted. (input of type "submit")
* @param {url} pNewCaption the new caption for the button.
*
* @static
*/
checkout_button_caption_swap: function(pButtonName, pNewCaption) {
var vButton = MUI.util.dom.object_by_name_attribute("input", pButtonName);
if(!vButton) setTimeout("MUI.yahoo.checkout_button_caption_swap('" + pButtonName + "', '" + pNewCaption + "');", 10);
else {
try {
if(vButton.type.match(/submit/i)) vButton.value = pNewCaption;
} catch(e) { }
}
},
/**
* Move a subsection to another section on the checkout page.
* The subsection will be added before the subsection at position "position".
*
* @method checkout_move_subsection
*
* @param {string} pSubSectionID the ID of the section to move.
* @param {string} pNewSectionID the ID of the new section to move it to.
* @param {number} pPosition the position of the moved subsection in the new section; zero-based.
*
* @static
*/
checkout_move_subsection: function(pSubSectionID, pNewSectionID, pPosition) {
var vSubSection = document.getElementById(pSubSectionID);
var vNewSection = document.getElementById(pNewSectionID);
if(!vSubSection || !vNewSection) setTimeout("MUI.yahoo.checkout_move_subsection('" + pSubSectionID + "', '" + pNewSectionID + "', " + pPosition + ")", 10);
else {
try {
var vSibling = vSubSection;
var vSubSectionHeader = null;
do {
var vSibling = vSibling.previousSibling;
if(vSibling && (typeof(vSibling.className) != "undefined") && vSibling.className.match(/ys_subSectionHeader/i)) vSubSectionHeader = vSibling;
} while(vSibling && !vSubSectionHeader);
if(vSubSectionHeader) {
var vHeaders = vNewSection.getElementsByTagName("h4");
if(vHeaders) {
if((vHeaders.length == 0) || (pPosition >= vHeaders.length)) {
vNewSection.appendChild(vSubSectionHeader);
vNewSection.appendChild(vSubSection);
} else {
vNewSection.insertBefore(vSubSection, vHeaders[pPosition]);
vNewSection.insertBefore(vSubSectionHeader, vSubSection);
}
}
}
} catch(e) { }
}
},
/**
* Create a new section on the checkout page. The new section will be added before the placeholder section.
*
* @method checkout_create_new_section
*
* @param {string} pBeforeSectionID the ID of the section to use a a placeholder.
* @param {string} pNewSectionID the ID of the new section.
* @param {string} pTitle the title of the new section.
* @param {string} pSubTitle the title of the new section's first sub-section.
*
* @static
*/
checkout_create_new_section: function(pBeforeSectionID, pNewSectionID, pTitle, pSubTitle) {
var vPlaceholder = document.getElementById(pBeforeSectionID);
if(!vPlaceholder) setTimeout("MUI.yahoo.checkout_create_new_section('" + pBeforeSectionID + "', '" + pNewSectionID + "', '" + pTitle + "', " + (pSubTitle ? ("'" + pSubTitle + "'") : "null") + ")", 10);
else {
try {
var vNewDiv = document.createElement("div");
vNewDiv.id = pNewSectionID;
vNewDiv.className = "ys_majorSection";
vPlaceholder.parentNode.insertBefore(vNewDiv, vPlaceholder);
var vObject = document.createElement("h3");
vObject.className = "ys_sectionHeader";
vNewDiv.appendChild(vObject);
vObject.appendChild(document.createTextNode(pTitle));
if(pSubTitle) {
vObject = document.createElement("h4");
vObject.className = "ys_subSectionHeader";
vNewDiv.appendChild(vObject);
vObject.appendChild(document.createTextNode(pSubTitle));
}
var vSubSection = document.createElement("div");
vSubSection.id = pNewSectionID+"_subsection";
vSubSection.className = "ys_subSection";
vNewDiv.appendChild(vSubSection);
var vFieldSet = document.createElement("fieldset");
vSubSection.appendChild(vFieldSet);
vObject = document.createElement("span");
vObject.id = pNewSectionID+"_placeholder";
vFieldSet.appendChild(vObject);
return vNewDiv;
} catch(e) { }
}
},
/**
* Creates 3 fields (MM / DD / YYYY) to enter dates, and will update the original field's value accordingly.
* The original field is usually a hidden field.
*
* @method checkout_create_date_fields_for_field
*
* @param {string} pFieldID the ID of the parent field, normally a hidden field.
*
* @static
*/
checkout_create_date_fields_for_field: function(pFieldID) {
var vPlaceholder = document.getElementById(pFieldID);
if(!vPlaceholder) setTimeout("MUI.yahoo.checkout_create_date_fields_for_field('" + pFieldID + "');", 10);
else {
vPlaceholder.style.display = "none";
vPlaceholder.value = "";
vPlaceholder.update_value = function() {
vPlaceholder.value = "";
try {
var vYear = Number.NaN;
var vMonth = Number.NaN;
var vDay = Number.NaN;
var vObject = document.getElementById("m-" + vPlaceholder.id);
if(vObject) vMonth = parseInt(vObject.value);
vObject = document.getElementById("d-" + vPlaceholder.id);
if(vObject) vDay = parseInt(vObject.value);
vObject = document.getElementById("y-" + vPlaceholder.id);
if(vObject) vYear = parseInt(vObject.value);
if(!isNaN(vYear) && !isNaN(vMonth) && !isNaN(vDay)) {
vMonth = vMonth - 1;
if(vYear < 100) vYear += 2000;
var vDate = new Date(vYear, vMonth, vDay, 0, 0, 0, 0);
if((vDate.getFullYear() == vYear) && (vDate.getMonth() == vMonth) && (vDate.getDate() == vDay)) {
vPlaceholder.value = (vDate.getMonth() + 1) + "/" + vDate.getDate() + "/" + vDate.getFullYear();
}
}
} catch (e) { }
};
var vTable = document.createElement("table");
vPlaceholder.parentNode.parentNode.insertBefore(vTable, vPlaceholder.parentNode.nextSibling);
var vRow = vTable.insertRow(vTable.rows.length);
var vCell = vRow.insertCell(vRow.cells.length);
var vField = document.createElement("input");
vField.id = "m-" + pFieldID;
vField.type = "text";
vField.maxLength = 2;
vField.size = 2;
vField.date_field = vPlaceholder;
vField.onchange = function() { this.date_field.update_value(); };
vCell.appendChild(vField);
vCell = vRow.insertCell(vRow.cells.length);
vCell.appendChild(document.createTextNode(" / "));
vCell = vRow.insertCell(vRow.cells.length);
vField = document.createElement("input");
vField.id = "d-" + pFieldID;
vField.type = "text";
vField.maxLength = 2;
vField.size = 2;
vField.date_field = vPlaceholder;
vField.onchange = function() { this.date_field.update_value(); };
vCell.appendChild(vField);
vCell = vRow.insertCell(vRow.cells.length);
vCell.appendChild(document.createTextNode(" / "));
vCell = vRow.insertCell(vRow.cells.length);
vField = document.createElement("input");
vField.id = "y-" + pFieldID;
vField.type = "text";
vField.maxLength = 4;
vField.size = 4;
vField.date_field = vPlaceholder;
vField.onchange = function() { this.date_field.update_value(); };
vCell.appendChild(vField);
vRow = vTable.insertRow(vTable.rows.length);
vCell = vRow.insertCell(vRow.cells.length);
vCell.style.textAlign = "center";
var vSpan = document.createElement("span");
vSpan.style.color = "#cccccc";
vSpan.appendChild(document.createTextNode("MM"));
vCell.appendChild(vSpan);
vCell = vRow.insertCell(vRow.cells.length);
vCell.appendChild(document.createTextNode(" "));
vCell = vRow.insertCell(vRow.cells.length);
vCell.style.textAlign = "center";
var vSpan = document.createElement("span");
vSpan.style.color = "#cccccc";
vSpan.appendChild(document.createTextNode("DD"));
vCell.appendChild(vSpan);
vCell = vRow.insertCell(vRow.cells.length);
vCell.appendChild(document.createTextNode(" "));
vCell = vRow.insertCell(vRow.cells.length);
vCell.style.textAlign = "center";
var vSpan = document.createElement("span");
vSpan.style.color = "#cccccc";
vSpan.appendChild(document.createTextNode("YYYY"));
vCell.appendChild(vSpan);
}
},
/**
* Duplicate a button on the checkout page. The new button will be added before or after the placeholder element.
*
* @method checkout_duplicate_button
*
* @param {string} pNewNextSiblingID the ID of the placeholder.
* @param {string} pTargetName the NAME of the button to duplicate.
* @param {bool} pAppend place the copied button before (false, default) or after (true) the placeholder.
*
* @static
*/
checkout_duplicate_button: function(pNewNextSiblingID, pTargetName, pAppend) {
var vNewSibling = document.getElementById(pNewNextSiblingID);
if(!vNewSibling) setTimeout("MUI.yahoo.checkout_duplicate_button('" + pNewNextSiblingID + "', '" + pTargetName + "', " + (pAppend?"true":"false") + ");", 10);
else {
var vTarget = document.getElementByIdFromName("input", pTargetName);
try {
var vNewNode = vTarget.cloneNode(true);
if(vTarget.onclick) vNewNode.onclick = vTarget.onclick;
if(pAppend) vNewSibling.appendChild(vNewNode);
else vNewSibling.parentNode.insertBefore(vNewNode, vNewSibling);
if(typeof(MUI.yahoo.node_duplicated) == "function") MUI.yahoo.node_duplicated(vNewNode);
} catch(e) { }
}
},
/**
* Make a Yahoo!-mandatory field optional, like the Phone field on the checkout...
*
* @method checkout_mandatory_to_optional_field
*
* @param {string} pTargetID the ID of the targeted element.
* @param {string} pActiveLinkID the ID of the *field* element.
* @param {string} pEmptyValue the value to place int he field so Y! thinks it is not empty.
*
* @static
*/
checkout_mandatory_to_optional_field: function(pTargetID, pActiveLinkID, pEmptyValue) {
var vTarget = document.getElementById(pTargetID);
if(!vTarget) setTimeout("MUI.yahoo.checkout_mandatory_to_optional_field('" + pTargetID + "', '" + pActiveLinkID + "', '" + pEmptyValue + "');", 10);
else {
try {
var vNewNode = vTarget.cloneNode(true);
vTarget.parentNode.insertBefore(vNewNode, vTarget);
MUI.util.dom.rename_element(vNewNode, "_monitus", true);
var vActiveLink1 = document.getElementById(pActiveLinkID);
var vActiveLink2 = document.getElementById(pActiveLinkID + "_monitus");
if(vActiveLink1 && vActiveLink2 && (vActiveLink1 != vActiveLink2)) {
vActiveLink2.empty_value = pEmptyValue;
if(vActiveLink1.value == "") vActiveLink1.value = pEmptyValue;
else if(vActiveLink1.value == pEmptyValue) vActiveLink2.value = "";
var vBaseID = pActiveLinkID;
vFc = function(event) {
var f = document.getElementById(vBaseID + "_monitus");
document.getElementById(vBaseID).value=(f.value != "") ? f.value : f.empty_value;
if(document.createEvent) {
var _Mv_event = document.createEvent("HTMLEvents");
_Mv_event.initEvent("blur", true, true);
document.getElementById(vBaseID).dispatchEvent(_Mv_event);
} else if(document.createEventObject) document.getElementById(vBaseID).fireEvent("onblur");
};
MUI.util.dom.add_event(vActiveLink2, "change", vFc, true);
MUI.util.dom.add_event(vActiveLink2, "blur", vFc, true);
MUI.util.dom.add_event(document.forms["CheckoutForm"], "submit", function(event) {
var f = document.getElementById(vBaseID + "_monitus");
document.getElementById(vBaseID).value=(f.value != "") ? f.value : f.empty_value;
}, true);
vTarget.style.display = "none";
vActiveLink1.style.display = "none";
}
} catch(e) { }
}
},
/**
* Duplicate a field on a checkout page.
*
* @method checkout_duplicate_field
*
* @param {string} pNewNextSiblingID the ID of the placeholder element.
* @param {string} pTargetID the ID of the targeted element.
* @param {string} pActiveLinkID the ID of the *field* element.
* @param {bool} pFocus should the new field have focus?
* @param {bool} pHideOriginal should the original copy be hidden?
*
* @static
*/
checkout_duplicate_field: function(pNewNextSiblingID, pTargetID, pActiveLinkID, pFocus, pHideOriginal) {
var vNewSibling = document.getElementById(pNewNextSiblingID);
var vTarget = document.getElementById(pTargetID);
if(!vNewSibling || !vTarget) setTimeout("MUI.yahoo.checkout_duplicate_field('" + pNewNextSiblingID + "', '" + pTargetID + "', '" + pActiveLinkID + "', " + (pFocus?"true":"false") + ", " + (pHideOriginal?"true":"false") + ");", 10);
else {
try {
var vNewNode = vTarget.cloneNode(true);
vNewSibling.parentNode.insertBefore(vNewNode, vNewSibling);
MUI.util.dom.rename_element(vNewNode, "_monitus", true);
var vActiveLink1 = document.getElementById(pActiveLinkID); // link active links
var vActiveLink2 = document.getElementById(pActiveLinkID + "_monitus");
if(vActiveLink1 && vActiveLink2 && (vActiveLink1 != vActiveLink2)) {
var vBaseID = pActiveLinkID;
if(vActiveLink1.type == "checkbox") {
MUI.util.dom.add_event(vActiveLink1, "click", function(event) { document.getElementById(vBaseID + "_monitus").checked=document.getElementById(vBaseID).checked; }, true);
MUI.util.dom.add_event(vActiveLink2, "click", function(event) {
document.getElementById(vBaseID).checked=document.getElementById(vBaseID + "_monitus").checked;
if(document.createEvent) {
var _Mv_event = document.createEvent("HTMLEvents");
_Mv_event.initEvent("click", true, true);
document.getElementById(vBaseID).dispatchEvent(_Mv_event);
} else if(document.createEventObject) document.getElementById(vBaseID).fireEvent("onclick");
}, true);
} else {
var vFc = function(event) { document.getElementById(vBaseID + "_monitus").value=document.getElementById(vBaseID).value; };
MUI.util.dom.add_event(vActiveLink1, "change", vFc, true);
MUI.util.dom.add_event(vActiveLink1, "blur", vFc, true);
vFc = function(event) {
document.getElementById(vBaseID).value=document.getElementById(vBaseID + "_monitus").value;
if(document.createEvent) {
var _Mv_event = document.createEvent("HTMLEvents");
_Mv_event.initEvent("blur", true, true);
document.getElementById(vBaseID).dispatchEvent(_Mv_event);
} else if(document.createEventObject) document.getElementById(vBaseID).fireEvent("onblur");
};
MUI.util.dom.add_event(vActiveLink2, "change", vFc, true);
MUI.util.dom.add_event(vActiveLink2, "blur", vFc, true);
MUI.util.dom.add_event(document.forms["CheckoutForm"], "submit", function(event) {
document.getElementById(vBaseID).value=document.getElementById(vBaseID + "_monitus").value;
}, true);
}
if(pFocus) vActiveLink2.focus();
if(pHideOriginal) {
vTarget.style.display = "none";
vActiveLink1.style.display = "none";
}
if(typeof(MUI.yahoo.node_duplicated) == "function") MUI.yahoo.node_duplicated(vNewNode);
}
} catch(e) { }
}
},
checkout_validation: function(pMarkerCallback, pValidationCallback, pValidationFailedCallback, pIgnoredFields) {
try {
var vForm = document.forms['CheckoutForm'];
if(vForm) {
var vRequiredFields = new Array();
var vBillingFields = new Array();
var vBillingInputsDiv = document.getElementById("ys_billingInputs");
if(!pMarkerCallback) {
var vImage = new Image(1,1);
vImage.src=document.location.protocol+"//bive.monitus.net/images/bullet_star.png";
pMarkerCallback = function(pRequiredField, pShowMarker) {
var vID = pRequiredField.name + "_req";
var vMarker = document.getElementById(vID);
if(pShowMarker && !vMarker) {
vMarker = document.createElement("img");
pRequiredField.parentNode.insertBefore(vMarker, pRequiredField);
vMarker.id = vID;
vMarker.src = document.location.protocol+"//bive.monitus.net/images/bullet_star.png";
vMarker.style.marginRight = "3px";
} else if(!pShowMarker && vMarker) {
vMarker.parentNode.removeChild(vMarker);
}
};
}
if(!pValidationCallback) {
var vImage = new Image(1,1);
vImage.src=document.location.protocol+"//bive.monitus.net/images/bullet_error.png";
pValidationCallback = function(pRequiredField, pValid) {
var vMarker = document.getElementById(pRequiredField.name + "_req");
if(vMarker) {
vMarker.src = document.location.protocol+"//bive.monitus.net/images/bullet_" + (pValid ? "star" : "error") + ".png";
vMarker.style.display = (pValid ? "none" : "inline");
}
};
}
if(!pValidationFailedCallback) {
pValidationFailedCallback = function validationFailed() {
alert("Some required fields were not filled-out correctly. Please complete all fields before proceeding.");
};
}
if(!pIgnoredFields) pIgnoredFields = new Array();
for(var vLoop = 0; vLoop < vForm.elements.length; vLoop++) {
var vElement = vForm.elements[vLoop];
if(vElement && vElement.name && (MUI.util.indexOfInArray(vElement.name, pIgnoredFields) < 0) && (!vElement.tagName.match(/input/i) || (vElement.type != "hidden"))) {
var vValueElement = MUI.util.dom.object_by_name_attribute("input", vElement.name + "_ymixval");
if(!vValueElement) vValueElement = MUI.util.dom.object_by_name_attribute("input", vElement.name.replace(/_monitus/i, "_ymixval_monitus"));
if(vValueElement && vValueElement.value && vValueElement.value.match(/(^|,)req(,|$)/i)) {
vRequiredFields.push(vElement);
MUI.util.dom.add_event(vElement, "blur", function(pEvent){ var vObject = ((typeof(event) != "undefined") ? event.srcElement : pEvent.target); pValidationCallback(vObject, (vObject.disabled || (vObject.value != ""))); }, true);
if(vBillingInputsDiv && (MUI.util.dom.object_by_name_attribute("input", vElement.name, vBillingInputsDiv) || MUI.util.dom.object_by_name_attribute("select", vElement.name, vBillingInputsDiv) || MUI.util.dom.object_by_name_attribute("textarea", vElement.name, vBillingInputsDiv))) vBillingFields.push(vElement);
}
}
}
for(var vLoop = 0; vLoop < vRequiredFields.length; vLoop++) {
pMarkerCallback(vRequiredFields[vLoop], true);
}
if(vBillingInputsDiv) {
var vShipBillToggle = function() {
var vBillingRadio = document.getElementById("useBillingRadio");
if(vBillingRadio) {
for(var vLoop = 0; vLoop < vBillingFields.length; vLoop++) pMarkerCallback(vBillingFields[vLoop], vBillingRadio.checked);
}
};
vShipBillToggle();
MUI.util.dom.add_event(document.getElementById("useShippingRadio"), "click", vShipBillToggle, true);
MUI.util.dom.add_event(document.getElementById("useBillingRadio"), "click", vShipBillToggle, true);
}
var vOriginalOnSubmit = vForm.onsubmit;
vForm.onsubmit = function(pEvent) {
var vResult = true;
if(vOriginalOnSubmit) vResult = vOriginalOnSubmit(pEvent);
if(vResult) {
for(var vLoop = 0; vLoop < vRequiredFields.length; vLoop++) {
if(!pValidationCallback(vRequiredFields[vLoop], (vRequiredFields[vLoop].disabled || (vRequiredFields[vLoop].value != "")))) vResult = false;
}
}
if(!vResult) pValidationFailedCallback();
return vResult;
};
}
} catch(e) { }
},
/**
* Create a pop-up div; these pop-ups are not blocked by pop-up blockers, as they are not in a separate window. This version (as opposed to MUI.util.create_popup) will center the popup on the screen by default.
*
* @method create_pop_up
*
* @param {string} pText title of the button to show the pop-up.
* @param {url} pImage url of the image used on the button. Optional.
* @param {string} pPlaceholderID id of the element into which the button shoudl be placed.
* @param {string} pPopUpID id of the div to show as the pop-up content. If the div does not exist, one will be created.
* @param {function} pPopUpFc function to be called when the button is clicked. Optional; by default, this function centers the popup on the screen. <em>Note: </em> For the automatic popUp function to work, make sure the YAHOO.util.Dom library is loaded on the page.
*
* @return {button} a reference to the created button; the button will have a "popup" property, for quick access to the popup div.
*
* @static
*/
create_pop_up: function(pText, pImage, pPlaceholderID, pPopUpID, pPopUpFc) {
if(!pPopUpFc && (typeof(YAHOO) != "undefined") && (typeof(YAHOO.util) != "undefined") && (typeof(YAHOO.util.Dom) != "undefined")) {
pPopUpFc = function() {
YAHOO.util.Dom.setStyle(this.popup, "zIndex", "100000");
YAHOO.util.Dom.setStyle(this.popup, "display", "block");
var vRegion = YAHOO.util.Dom.getRegion(this.popup);
var vElementWidth = vRegion.right - vRegion.left;
var vElementHeight = vRegion.bottom - vRegion.top;
var vViewportWidth = YAHOO.util.Dom.getViewportWidth();
var vViewportHeight = YAHOO.util.Dom.getViewportHeight();
var vX = vRegion.left;
if(vElementWidth < vViewportWidth) vX = (vViewportWidth / 2) - (vElementWidth / 2);
var vY = vRegion.top;
if(vElementHeight < vViewportHeight) vY = (vViewportHeight / 2) - (vElementHeight / 2);
YAHOO.util.Dom.setXY(this.popup, [parseInt(vX, 10), parseInt(vY, 10)]);
};
}
var vButton = MUI.util.ui.create_pop_up(pText, pImage, pPlaceholderID, pPopUpID, pPopUpFc);
if(vButton) {
vButton.popup.style.position = "absolute";
}
},
/**
* Push coupon(s) through a non-blocking pop-up. The button will be added right after the coupon field on the checkout.
*
* @method coupon_pusher
*
* @param {string} pText title of the button to show the coupon(s) pop-up.
* @param {url} pImage url of the image used on the button. Optional.
* @param {string} pPopUpID id of the div to show as the pop-up content. If the div does not exist, one will be created.
* @param {function} pPopUpFc function to be called when the button is clicked.
*
* @static
*/
coupon_pusher: function(pText, pImage, pPopUpID, pPopUpFc) {
var vButton = MUI.yahoo.create_pop_up(pText, pImage, "gc-redemption-code", pPopUpID, pPopUpFc);
if(vButton) {
vButton.popup.style.position = "absolute";
}
},
/**
* Automatically apply a coupon code to the current cart; useful to use as links on coupon codes. This will not only set the coupon code in the right field, it will also hit the "Apply" button for the user, so the coupon is actually applied.
*
* @method coupon_apply
*
* @param {string} pCoupon the coupon code to apply.
*
* @static
*/
coupon_apply: function(pCoupon) {
try {
var vObject = document.getElementById("gc-redemption-code");
if(vObject) {
vObject.value = pCoupon;
vObject = document.createElement("input");
vObject.name = "eventName.updateGiftCertDataEvent";
vObject.type = "hidden";
vObject.value = "Apply";
document.forms['CheckoutForm'].appendChild(vObject);
document.forms['CheckoutForm'].submit();
}
} catch(e) {}
},
/**
* "Keep Shopping" Handler: for one-page carts, make sure the "Keep Shopping" link works and takes the customer back to the last store page they saw before coming ot the checkout.
*
* @method keep_shopping_handler
*
* @param {string|object} pOptionalTrackerObject the name of the tracker object variabl, or the actual tracker object. Default: null (no event tracking);
* @param {string} pOptionalEventCategory the category for this event; can be an inflatable template. Default: "[page ID]'"
* @param {string} pOptionalEventAction the action for this event; can be an inflatable template. Default: ""
* @param {string} pOptionalEventLabel the label for this event; can be an inflatable template. Default: "Add to Cart"
* @param {bool} pNonInteraction when false, event has an impact on bounce rate. When true, the event will not be used in bounce rate calculations. Default: "true"
*
* @static
*/
keep_shopping_handler: function(pOptionalTrackerObject, pOptionalEventCategory, pOptionalEventAction, pOptionalEventLabel, pNonInteraction) {
if(typeof(pNonInteraction) == "undefined") pNonInteraction = true;
var vCurrentDomain = MUI.yahoo.cookie_domain();
if(vCurrentDomain.match(/\.yahoo\./i)) {
if(!document.referrer.match(/https?\:\/\/[^\/]*?\.yahoo\.(com|net)/i)) MUI.util.set_cookie_value("_mkpshpg", ".", "/", vCurrentDomain, document.referrer);
var vElements = document.getElementsByTagName("li");
for(var vLoop = 0; vLoop < vElements.length; vLoop++) {
if(vElements[vLoop].className == "ys_first") {
var vElements2 = vElements[vLoop].getElementsByTagName("a");
for(var vLoop2 = 0; vLoop2 < vElements2.length; vLoop2++) {
if(vElements2[vLoop2].href.match(/eventName\.cancelEvent/i)) {
var vCookieValue = MUI.util.cookie_value("_mkpshpg", null);
if(vCookieValue) {
if(pOptionalTrackerObject) {
MUI.ga.attach_tracking_info(vElements2[vLoop2], pOptionalTrackerObject, pOptionalEventAction, pOptionalEventLabel, pOptionalEventCategory, undefined, pNonInteraction);
vElements2[vLoop2].onclick = function() { MUI.ga.track_event_attached_to_object(this); setTimeout('window.location="' + this.href + '";', 250); return false; };
}
vElements2[vLoop2].href = vCookieValue;
vElements2[vLoop2].style.display = "inline";
}
return vElements2[vLoop2];
}
}
}
}
}
return null;
},
/**
* Badge images by product ID: adds an image (badge) over another image (target); target images are identified by product IDs.
*
* @method badge_products
*
* @param {string|array} pProductIDs string of comma-separated product IDs, OR an array of product IDs (strings).
* @param {url} pBadgeURL url of the badge image; the image should be a file with a transparent background.
* @param {string} pPosition one of: MUI.util.ktop_right (default), MUI.util.ktop_center, MUI.util.ktop_left, MUI.util.kbottom_right, MUI.util.kbottom_center or MUI.util.kbottom_left
*
* @static
*/
badge_products: function(pProductIDs, pBadgeURL, pPosition) {
if(!pPosition) pPosition = "tr";
if(!MUI.util.kdom_is_ready) {
if(typeof(pProductIDs) != "string") pProductIDs = pProductIDs.join(",");
setTimeout("MUI.yahoo.badge_products(\"" + pProductIDs + "\", \"" + pBadgeURL + "\", \"" + pPosition + "\");", 10);
} else {
if(typeof(pProductIDs) == "string") pProductIDs = pProductIDs.split(",");
for(var vLoop = 0; vLoop < pProductIDs.length; vLoop++) {
var vLinks = MUI.util.dom.get_objects("a", "{href=##(^|\\\/)" + pProductIDs[vLoop] + "\\\.(htm|php)##}");
if(vLinks) {
for(var vLoop2 = 0; vLoop2 < vLinks.length; vLoop2++) {
var vLink = vLinks[vLoop2];
var vImages = vLink.getElementsByTagName("img");
if(vImages && (vImages.length > 0)) MUI.util.ui.badge_image(pBadgeURL, vImages[0], pPosition);
}
}
}
}
}
};
}
}