﻿function InitializeHierarchyVariables(){
    /* Hierarchy Variables */
    s.hier1 = '';    
}

function OmnitureSetPromotionThankYouPageView() {
    var promoCode = getQuerystring('p');
    s.channel = 'offer'; 
    s.pageName = 'thank you '+ promoCode;
}

function OmnitureSetPromotionExpiredPageView() {
    var promoCode = getQuerystring('promo');
    s.channel = 'offer';
    s.pageName = 'expired ' + promoCode;
}

function OmnitureSetPromotionConfirmationPageView() {
    var promoCode = getQuerystring('promo');
    s.channel = 'offer';
    s.pageName = 'confirmation ' + promoCode;
}

/*This function can also be found in productFilter.js*/
function getQuerystring(key) {
    var defaultVal = "";
    key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
    var qs = regex.exec(window.location.href);
    if (qs == null) {
        return defaultVal;
    } else {
        return qs[1];
    }
}

function OmnitureProductTabClick(tab, product) {
    var linkName = 'product_'+tab+'_'+product;
    s.eVar3 = product;
    s.tl(this,'o',linkName);
}

function OmnitureProductDirectionsClick(step, product) {
    var linkName = 'product_directions_steps_'+product+','+step;
    s.eVar3= product;
    s.tl(this, 'o', linkName);
}

function OmnitureProductFilterClick(styles,surfaces,issues) {
    initialize();

    s.channel = 'home';
    s.eVar3 = styles + ',' + surfaces + ',' + issues;
    s.prop2 = styles + ',' + surfaces + ',' + issues;
    s.tl(this, 'o', 'solution_finder_' + styles + ',' + surfaces + ',' + issues); 
 }

function OmnitureProductBrowseClick(surfaces) {
    if (surfaces != 'All') {
        initialize();

        s.eVar3 = 'filter';
        s.tl(this, 'o', 'browse_products_' + surfaces);
    }
}

function OmnitureTipSurfaceClick(filter) {
    if (filter != 'Select') {
        s.tl(this, 'o', 'tips_filter_' + filter);
    }
}

function OmnitureTipSubmitSurfaceClick(filter) {
    s.tl(this, 'o', 'submit_tips_surface_' + filter);
}

function OmnitureSearchResultClick(keyword) {
    s.channel = 'home';
    s.tl(this, 'o', 'search_results _' + keyword);
}

function OmnitureEmailOpenForm(type, name) {
    s.events = 'event11';
    s.eVar6 = 'email ' + type + ' ' + name;
    s.prop6 = 'email ' + type + ' ' + name;
    s.tl(this, 'o', 'email_'+name+'_' + name);
}

function OmnitureEmailSend(type, name) {
    s.events = 'event12';
    s.eVar6 = 'email ' + type + 'send ' + name;
    s.prop6 = 'email ' + type + 'send ' + name;
    s.tl(this, 'o', 'email ' + type + 'send ' + name);
}

function OmnitureSocialNetworkingSend(service, type, name) {
    s.prop2 = 'share_'+service+'_' + name;
    s.tl(this, 'o', 'share_'+type+'_'+service+'_' + name);
}

function OmnitureWatchVideo(action, name) {
    if (action == 'play') {
        s.events = 'event1';
        s.eVar1 = name + '_' + action;
    }
    else if (action == 'stop') {
    s.events = 'event2';
    s.eVar1 = name + '_' + action;
    }
    else if (action == 'refresh') {
    s.events = 'event15';
    s.eVar12 = name + '_replay';
    }

    s.tl(this, 'o', name + '_' + action);
}

function OmniturePrintCoupon(promo) {
    s.events='event6';
    s.eVar4='print coupon ' + promo;
    s.tl(this, 'e', 'coupon print ' + promo);
}

function OmnitureSubmitCouponRequest(promo) {
    s.events='event12';
    s.eVar6='submit coupon ' + promo;
    s.prop6='submit coupon ' + promo;
    s.tl(this,'o','offer_submit ' + promo);            
}
