﻿/* Custom Yahoo! Web Analytics Action Tracking */
var debugTracking = false;

var strYWA = 'Yahoo! Web Analytics Tracking:\n';
function lebsea_tracking(debugMode) { if (debugMode == true) { this.debug = true; alert("Yahoo! Web Analytics custom action tracking \ndebug mode is enabled."); } else { this.debug = false; } }

/* Preen.com */
//captureWeedPopup
lebsea_tracking.prototype.WeedPopup = function(weedName) { if (this.debug) { alert(strYWA + 'Weed Popup: '+weedName); }; YWATracker.setAction('17'); YWATracker.setCF(17, weedName); YWATracker.submit_action(); };
//captureQuickSignup
//lebsea_tracking.prototype.QuickSignup = function() { if (this.debug) { alert(strYWA + 'Calculate Bags'); }; YWATracker.setAction('18'); YWATracker.submit_action(); };
//captureQuickEmailSignup
lebsea_tracking.prototype.QuickEmailSignup = function() { if (this.debug) { alert(strYWA + 'Quick Email Signup'); }; YWATracker.setAction('18'); YWATracker.submit_action(); };
//captureSweepsSignup
//lebsea_tracking.prototype.SweepsSignup = function() { if (this.debug) { alert(strYWA + 'Sweeps Signup'); }; YWATracker.setAction('18'); YWATracker.submit_action(); };
lebsea_tracking.prototype.FacebookClick = function() { if (this.debug) { alert(strYWA + 'Facebook Click'); }; YWATracker.setAction('10'); YWATracker.submit_action(); };
lebsea_tracking.prototype.TwitterClick = function() { if (this.debug) { alert(strYWA + 'Twitter Click'); }; YWATracker.setAction('11'); YWATracker.submit_action(); };

/* Preen Sweeps */
lebsea_tracking.prototype.trackSweepsOptinStatus = function(optinControl) {
    var optin = $(optinControl).attr('checked');
    if (this.debug) { alert(strYWA + 'Track Sweeps OptIn Status: ' + optin); };
    if (optin == true) {
        YWATracker.setAction('20'); YWATracker.submit_action();
    } else {
        YWATracker.setAction('21'); YWATracker.submit_action();
    }
    return true;
};

/*
The lebsea_tracking prototype functions are exposed through the jsTracker instance for tracking custom actions
within the Greenview web site. Some of these functions are referenced from code-behind scripts in the 
Lawn Plan checkout process.
*/
jsTracker = new lebsea_tracking(debugTracking);
