// JavaScript Document

var SITE_ANALYTICS = false;

HERSHEYS.Analytics = (function () {

    var areDebugging = false;
    var showAllEvents = false;

    /* GLOBAL DROPDOWN AND FOOTER TRACKING */

    var GLOBAL_CAMPAIGN_TRACKING = {
        globalShareCodes: {
            /* ALL ON CLICK */
			'mixx-link' 	: 'HER1399',
			'del-link'      : 'HER1400',
			'reddit-link' 	: 'HER1401',
			'stumble-link' 	: 'HER1402',
			'myspace-link' 	: 'HER1403',
			'twitter-link'  : 'HER1404',
			'digg-link' 	: 'HER1405',
			'facebook-link' : 'HER1406'
        }
    };
    var callTracking = function (msg) {
        if (showAllEvents) console.log('Analytics: ' + msg);
    };
    $(HERSHEYS.Carousel).bind('AllItemsSeen', function (e, data) {
        callTracking('Carousel AllItemsSeen Being Called');
    });
    $(HERSHEYS.Carousel).bind('SlideStart', function (e, data) {
        callTracking('Carousel SlideStart Being Called - "' + $(data).attr('alt') + '"');
    });
    $(HERSHEYS.TabbedBrowsing).bind('NewItemShowing', function (e, data) {
        callTracking('TabbedBrowsing NewItemShowing Being Called - "' + $(data).attr('title') + '"');
    });
    $(HERSHEYS.TabbedBrowsing).bind('AllItemsSeen', function () {
        callTracking('TabbedBrowsing AllItemsSeen Being Called');
    });
    var trackInternalCampaign = function (pTrackCode) {

        var s = s_gi(s_account);
        s.templtv = s.linkTrackVars;          /*Saving the original state of the variables*/
        s.templte = s.linkTrackEvents;         /*Saving the original state of the variables*/
        s.linkTrackVars = "events,eVar2";      /*Defining the list of variables that will be sent in the server call*/
        s.eVar2 = pTrackCode + ":" + s.pageName; // Tracking code will be provided by Kendra
        s.linkTrackEvents = "event9";
        s.events = "event9";              //Passing in the value into s.events

        s.tl(true, 'o', 'internal campaign clicks');   //Server call

        if (s.templtv) {
            s.linkTrackVars = s.templtv;    //reassigning the variables to the original state
        }

        if (s.templte) {
            s.linkTrackEvents = s.templte;   //reassigning the variables to the original state
        }
    };

    var shareTracking = function (pTrackCode) {
	
        var s = s_gi(s_account);
        s.templtv = s.linkTrackVars; /*Saving the original state of the variables*/
        s.templte = s.linkTrackEvents; /*Saving the original state of the variables*/
        s.linkTrackVars = "events,eVar2"; /*Defining the list of variables that will be sent in the server call*/
        s.eVar2 = pTrackCode + ":" + s.pageName;
        s.linkTrackEvents = "event7,event9";
        s.events = "event7,event9"; 	//Passing the value into s.events

        s.tl(true, 'o', 'clicks to share widget');   //Server call	

        if (s.templtv) {
            s.linkTrackVars = s.templtv;     //reassigning the variables to the original state
        }
        if (s.templte) {
            s.linkTrackEvents = s.templte;   //reassigning the variables to the original state
        }

    };
    var addToURL = function (href, code) {
		
	 	if (href.indexOf('?') == -1) {
			if (href.indexOf('#') != -1) {
				return href.replace('#', '?' + code + '#');
			}else{
            	return href + '?' + code;
			}
        } else {
			if (href.indexOf('#') != -1) {
				return href.replace('#', '&' + code + '#');
			}else{
            	return href + '&' + code;
			}
        }
        return;
    };
    var CONFIG = false;

    return {
        debug: function () { areDebugging = true; console.log('Debugging enabled.'); },
        showAllEvents: function () {
            $.cookie('HERSHEYS_showAllEvents', 1);
            showAllEvents = true;
            console.log('Now showing everything that can be bound to.');
        },
        
        init: function (config) {

            CONFIG = config;

            $(document).ready(function () {
                $.each(CONFIG.clickCampaignCodes, function (code, selector) {
	
                    var link = $(selector);

                    if (link) {
                        link.bind('click', function () {
                            trackInternalCampaign(code);
                        });
                    }
                });

                $.each(CONFIG.appendCampaignCodes, function (i, v) {
                    var link = $(v);

                    if (link.length) {
                        link.each(function($i, $item){
                            var curlink = $($item);
                            var href = curlink.attr("href");

                            if (!href) {
                                if (showAllEvents) console.log('Analytics: Bad campaign code request: ' + v);
                            } else {
                                curlink.attr('href', addToURL(href, i));
                            }
                        })
                        
                    }

                });

				$('.share-links').bind('click', function(){
					switch($(this).attr('id')){				                                                                               
						case 'mixx-link'        :  HERSHEYS.Analytics.doShareTracking('HER1399');break;
						case 'del-link'     	:  HERSHEYS.Analytics.doShareTracking('HER1400');break;
						case 'reddit-link'		:  HERSHEYS.Analytics.doShareTracking('HER1401');break;
						case 'stumble-link' 	:  HERSHEYS.Analytics.doShareTracking('HER1402');break;
						case 'myspace-link' 	:  HERSHEYS.Analytics.doShareTracking('HER1403');break;
						case 'twitterk-link' 	:  HERSHEYS.Analytics.doShareTracking('HER1404');break;
						case 'digg-link' 		:  HERSHEYS.Analytics.doShareTracking('HER1405');break;
						case 'facebook-link' 	:  HERSHEYS.Analytics.doShareTracking('HER1406');break;
					}	
				});
				
				/* To Track Recipe Prints */     
				    $('a.print_recipe').live('click', function () {
					
						if ($(this).attr('recipeID')){
							var OMNITURE_RECIPE_ID = $(this).attr('recipeID');
						}
						
						if (typeof OMNITURE_RECIPE_ID == 'undefined') return true;
						
							s.templtv = s.linkTrackVars; /*Saving the original state of the variables*/
							s.templte = s.linkTrackEvents; /*Saving the original state of the variables*/
							s.linkTrackVars = "events,eVar10,products,prop30";
							s.linkTrackEvents = "event5";
							s.events = "event5";
							s.eVar10 = OMNITURE_RECIPE_ID;
							s.prop30 = OMNITURE_RECIPE_ID;
							s.products = ";" + OMNITURE_RECIPE_ID;
							s.tl(this, 'o', 'recipe print clicks');
				        if (s.templtv) {
			                s.linkTrackVars = s.templtv;     //reassigning the variables to the original state
                        }
                        if (s.templte) {
                            s.linkTrackEvents = s.templte;   //reassigning the variables to the original state
                        }
				    });
								

                $('.gh a, .gf a').bind('click', function () {
                    var code = $(this).attr('omni');
                    if (code) {
                       
                       trackInternalCampaign(code);
                       /*
                       var wholeCode = 'ICID=' + code;
                        var href = $(this).attr('href');

                        $(this).attr('href', addToURL(href, wholeCode));
                        */
                    }
                });

                $("a#estore_header").bind('click', function () {
                    trackInternalCampaign('HER1361');
                });
		$("a#gh_retailer_dropdown").bind('click', function () {
                    trackInternalCampaign('HER1344');
                });
		$("a#gh_hersheypa").bind('click', function () {
                    trackInternalCampaign('HER1343');
                });


                $(HERSHEYS.Video).bind('Milestone', function (e, data) {

                    switch (data.percent) {

						case 0:
                            HERSHEYS.Analytics.trackVideo(data.title, 'start');
                            break;

						case 100:
                            HERSHEYS.Analytics.trackVideo(data.title, 'complete');
                            break;
                    }

                });

            });

            return this;

        },
		doShareTracking : function(code){
			shareTracking(code);
		},
        getAccount: function () {
			
            if (href.indexOf("www.hersheys.com") != -1 || href.indexOf("www.thehersheycompany.com") != -1 || href.indexOf("m.hersheys.com") != -1 || href.indexOf("m.thehersheycompany.com") != -1 || href.indexOf("-hersheys.icims.com") != -1 || href.indexOf("hersheystrackandfield.com") != -1 || href.indexOf("eatthinksmile.com") != -1){
                return CONFIG.liveAccount;
            } 
            else {
                return CONFIG.devAccount;
            }

        },
        getBusinessUnit: function () {

            return CONFIG.businessUnit;

        },
        getDomain: function () {

            return CONFIG.domain;

        },
        getTempLinkInternalFilters: function () {

            return CONFIG.tempLinkInternalFilters;
        },
        doProductView: function (productNameIn) {
			
			if (window.location.href.indexOf('/seasonal/products.aspx') != -1 && this.getBusinessUnit() == 'Reeses'){
            s.pageName = s.prop3 = s.prop4 = s.prop1 = 'hersheys:reeses:recipes and ideas:seasonal:products:home';
            s.products = ';' + productNameIn.replace(/-/g, ' ');
            s.events = "event3,prodView";
            s.prop2 = 'hersheys:reeses:recipes and ideas';
            s.t();
			} else{
		    s.pageName = s.prop3 = s.prop4 = s.prop1 = this.getDomain().toLowerCase() + ':' + this.getBusinessUnit().toLowerCase() + ':products:product detail';
            s.products = ';' + productNameIn.replace(/-/g, ' ');
            s.events = "event3,prodView";
            s.prop2 = this.getDomain().toLowerCase() + ':' + this.getBusinessUnit().toLowerCase() + ':products';
            s.channel = 'hersheys:' + this.getBusinessUnit().toLowerCase() + ':products';
            s.t();
			}
        },
        doPageView: function (channel, pageName) {
                if (SITE_ANALYTICS.getBusinessUnit() == 'Hersheys'){
                    s.pageName = this.getBusinessUnit().toLowerCase() + ':' + channel.toLowerCase().replace(/-/g, ' ') + ':' + pageName.toLowerCase().replace(/-/g, ' ');
                    s.channel = s.prop2 = this.getDomain().toLowerCase() + ':' + this.getBusinessUnit().toLowerCase() + ':' + channel.toLowerCase().replace(/-/g, ' ');
                    s.prop3 = s.prop4 = s.prop1 = s.pageName.toLowerCase().replace(/-/g, ' ');
            } else {
                    s.pageName = this.getDomain().toLowerCase() + ':' + this.getBusinessUnit().toLowerCase() + ':' + channel.toLowerCase().replace(/-/g, ' ') + ':' + pageName.toLowerCase().replace(/-/g, ' ');
                    s.channel = s.prop2 = this.getDomain().toLowerCase() + ':' + this.getBusinessUnit().toLowerCase() + ':' + channel.toLowerCase().replace(/-/g, ' ');
                    s.prop3 = s.prop4 = s.prop1 = s.pageName.toLowerCase().replace(/-/g, ' ');
            }
            
            s.t();

        },
		doDownload: function(pDownloadType,pCategory){
			var s = s_gi(s_account);
						s.templtv = s.linkTrackVars; /*Saving the original state of the variables*/
				        s.templte = s.linkTrackEvents; /*Saving the original state of the variables*/
						s.linkTrackVars = "events,eVar6"; //Defining the list of variables that will be sent in the server call	
						s.linkTrackEvents = "event21";
						s.events = "event21";  
						s.eVar6 = s.prop17 = pDownloadType + ":" + pCategory;		
	    						
						
			s.tl(true,'o', 'asset download');
			if (s.templtv) {
			    s.linkTrackVars = s.templtv;     //reassigning the variables to the original state
            }
            if (s.templte) {
                s.linkTrackEvents = s.templte;   //reassigning the variables to the original state
            }
			
			
		},
		
		doAssetInteraction: function(assettype, assetname){
				
				/* types: PDF, AUDIO */
				if (typeof OMNITURE_RECIPE_ID != 'undefined' && OMNITURE_RECIPE_ID != null){
						
					s.templtv = s.linkTrackVars; /*Saving the original state of the variables*/
				    s.templte = s.linkTrackEvents; /*Saving the original state of the variables*/
					s.linkTrackVars = "events,eVar10,products,prop30";
				    s.linkTrackEvents = "event5";
					s.events = "event5";
				    s.eVar10 = OMNITURE_RECIPE_ID;
					s.prop30 = OMNITURE_RECIPE_ID;
				    s.products = ";" + OMNITURE_RECIPE_ID;
				    s.tl(this, 'o', 'recipe print clicks');
				    if (s.templtv) {
			        	s.linkTrackVars = s.templtv;     //reassigning the variables to the original state
                     }
                    if (s.templte) {
                        s.linkTrackEvents = s.templte;   //reassigning the variables to the original state
                    }
                                        
				                                      
                }else{
                    s.templtv = s.linkTrackVars; /*Saving the original state of the variables*/
					s.templte = s.linkTrackEvents; /*Saving the original state of the variables*/
					s.linkTrackVars = "events,eVar6,prop17";
					s.linkTrackEvents = "event21";
					s.events = "event21";
					s.eVar6  = assettype + ":" + assetname;
					s.prop17 = assettype + ":" + assetname;
					s.tl(this, 'o', 'download');
					if (s.templtv) {
						s.linkTrackVars = s.templtv;     //reassigning the variables to the original state
					}
					if (s.templte) {
						s.linkTrackEvents = s.templte;   //reassigning the variables to the original state
					}
                }
                                
		},
		doPureSmoresView: function (section, pageName) {

			/*
				section will be "occasion" , "timeless traditions" or "recipes and prep methods"
				pageName will be name that appears below the thumbnail
				
			*/
						
            s.pageName = this.getBusinessUnit().toLowerCase() + ':promotions:pure smores:' + section + ':' + pageName.toLowerCase().replace(/-/g, ' ').replace(/\'/, '');
            s.prop2 = this.getDomain().toLowerCase() + ':' + this.getBusinessUnit().toLowerCase() + ':promotions'
            s.prop3 = this.getDomain().toLowerCase() + ':' + this.getBusinessUnit().toLowerCase() + ':promotions:pure smores'
            s.prop4 = s.prop1 = this.getBusinessUnit().toLowerCase() + ':' + s.pageName.toLowerCase().replace(/-/g, ' ');
            s.events = 'event18'
            s.prop26 = s.eVar36 = 'hersheys:Interaction:pure smores';
            s.prop29 = s.eVar38 = 'hersheys:Interaction:pure smores:' + section + ':' + pageName;
            s.t();

        },
        doPrintAdView: function (channel, pageName) {
            s.linkTrackEvents = 'event15,event16';
            s.linkTrackVars   = 'prop26,eVar36';
            s.prop26 = s.eVar36 = this.getBusinessUnit().toLowerCase() + ':PrintAdView:' + pageName.toLowerCase().replace(/-/g, ' ');
            s.events = 'event15,event16';
            s.tl(true,'o', pageName + 'view');

        },
        trackVideo: function (videoID, action) {
			
			if (typeof s_gi != 'function') return false;
			
            /* We must split the video id by an underscore - the first half should be the type, the second half should be the video name */

            var videoSplit = videoID.split('_');

            var videoCategory = videoSplit.length == 2 ? videoSplit[0].replace(/-/g, ' ') : 'Unclassified';
            var videoName = videoSplit.length == 2 ? videoSplit[1].replace(/-/g, ' ') : videoID;

            var s = s_gi(s_account);
            s.templtv = s.linkTrackVars; /*Saving the original state of the variables*/
            s.templte = s.linkTrackEvents; /*Saving the original state of the variables*/
            s.linkTrackVars = "events,eVar36,prop26"; /*Defining the list of variables that will be sent in the server call*/
            s.eVar36 = s.prop26 = this.getBusinessUnit().toLowerCase() + ':' + videoCategory + ':' + videoName;

            switch (action) {
                case "start":
                    s.linkTrackEvents = "event15,event30";
                    s.events = "event15,event30"; 	//Passing the value into s.events
                    break;
                case 'complete':
                    s.linkTrackEvents = "event16,event31";
                    s.events = "event16,event31"; 	//Passing the value into s.events
                    break;
            }

            s.tl(true, 'o', s.eVar36 + ' ' + action);   //Server call	

            if (s.templtv) {
                s.linkTrackVars = s.templtv;     //reassigning the variables to the original state
            }
            if (s.templte) {
                s.linkTrackEvents = s.templte;   //reassigning the variables to the original state
            }
        },
		trackRecipeView : function(opts){
			
			var contextType = "Category not found";
			var contextValue = "Category not found";
			
			if (window.location.href.indexOf('/recipes-by-type/') != -1){		
				contextType = 'Type';
				var split = window.location.href.split('/');
				contextValue = split[split.length - 1].split('.aspx')[0];			
			}else if (window.location.href.indexOf('/recipes-by-occasion/') != -1){
				contextType = 'Occasion';
				var split = window.location.href.split('/');
				contextValue = split[split.length - 1].split('.aspx')[0];
			}else if (window.location.href.indexOf('searchresults.aspx') != -1){
					contextType = 'Search';				
					var split = window.location.href.split('KW=');
					if (split.length > 1)
						contextValue = split[1];
			}else if (window.location.href.indexOf('/promotions/') != -1){
                                contextType = 'Promotions';
                                if(typeof CURRENT_PROMOTION_NAME != 'undefined'){
                                contextValue = CURRENT_PROMOTION_NAME;
                                }else{
                                        contextValue = "Category not found";
                                }
                        }else if (window.location.href.indexOf('/my-kitchen/') != -1){
                                contextType = 'My Kitchen';
                                
                                if(window.location.href.indexOf('/my-recipe-box.aspx') != -1){
                                contextValue = 'My Recipe Box';
                                }else if(window.location.href.indexOf('/my-grocery-list.aspx') != -1){
                                        contextValue = 'My Grocery List';
                                }else if (window.location.href.indexOf('/my-recipes-and-tips.aspx') != -1){
                                        contextValue = 'My Recipes and Tips';
                                }
                        }else if (window.location.href.indexOf('/holiday-ideas/') != -1){
                                contextType = 'Holiday Ideas';
                                if(window.location.href.indexOf('/valentines-day.aspx') != -1){
                                        contextValue = 'Valentines Day';
                                }
                        }else if (window.location.href.indexOf('/recipes.aspx') != -1){
							contextValue = 'Homepage';
							
							if (window.location.href.indexOf('ds=lg') != -1){
								contextType = 'View By Large'
							}else if (window.location.href.indexOf('ds=ls') != -1){
								contextType = 'View By List';
							}else {
							contextType  = 'View By Grid';
							}
						}else if (window.location.href.indexOf('/how-to/') != -1){
                                contextType = 'How To';
                                if(window.location.href.indexOf('/cookie-exchange.aspx') != -1){
                                        contextValue = 'Cookie Exchange Home';
                                }else if(window.location.href.indexOf('/cookie-exchange-hosting.aspx') != -1){
                                        contextValue = 'Cookie Exchange Hosting';
                                }else if(window.location.href.indexOf('/bake-sale.aspx') != -1){
                                        contextValue = 'Bake Sale Home';
                                }else if(window.location.href.indexOf('/bake-sale-organize.aspx') != -1){
                                        contextValue = 'Bake Sale Organize';
                                }
                        }else if (window.location.href.indexOf('/recipes-by-product/') != -1){
                                contextValue = 'Product';
                                if(window.location.href.indexOf('/hersheys-milk-chocolate-chips.aspx') != -1){
                                        contextValue = 'Hersheys Milk Chocolate Chips';
                                }else if(window.location.href.indexOf('/mounds-sweetened-coconut-flakes.aspx') != -1){
                                        contextValue = 'Mounds Sweetened Coconut Flakes';
                                }else if(window.location.href.indexOf('/hersheys-cocoa.aspx') != -1){
                                        contextValue = 'Hersheys Cocoa';
                                }
                        }
				
			
			s.pageName = this.getDomain().replace(/ /g,'').toLowerCase() + ':' + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ':recipes:detail';
		  	s.products = " ;" + opts['recipeID'] + ";;;event22=1;eVar9=" + contextType + "|eVar4=" + contextValue + ",;" + opts['associatedProducts'].replace(/,/g,";;;event22=1,;")
		  	s.events   = "event4,event22";
		    s.channel  = s.prop2 = this.getDomain().replace(/ /g,'').toLowerCase() + ':' + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ':recipes';
			s.prop3 = this.getDomain().replace(/ /g,'').toLowerCase() + ':' + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ':recipes:' + contextType.toLowerCase();
			s.prop4 = s.prop1 = this.getDomain().replace(/ /g,'').toLowerCase() + ':' + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + 'recipes:'+ contextType.toLowerCase() + ':' + contextValue.toLowerCase();
			s.prop30 = s.eVar10 = opts['recipeID'];
        	s.t();
			
		},
		trackPromotionEvent : function(keyword, elementSource){
			
			if (typeof CURRENT_PROMOTION_NAME == 'undefined'){
		//		var CURRENT_PROMOTION_NAME = "unknown";
			}
			CURRENT_PROMOTION_NAME = CURRENT_PROMOTION_NAME.toLowerCase();
			
			switch(keyword){                              
				
				case 'tell_a_friend_submit_button' : 

					s.templtv = s.linkTrackVars; /*Saving the original state of the variables*/
					s.templte = s.linkTrackEvents; /*Saving the original state of the variables*/

					s.linkTrackVars   = "events,eVar36,eVar38,eVar42,prop26,prop29,prop35";
					s.linkTrackEvents = "event16,event18";
					s.events          = "event16,event18";
					s.prop26          = s.eVar36 = SITE_ANALYTICS.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME + ":tell a friend";
					s.prop29          = s.eVar38 = SITE_ANALYTICS.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME + ":share:tell a friend";
					s.prop35          = s.eVar42 = SITE_ANALYTICS.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME;
					s.tl(true, 'o', 'share on tell a friend');
					if (s.templtv) {
						s.linkTrackVars = s.templtv;     //reassigning the variables to the original state
					}
					if (s.templte) {
						s.linkTrackEvents = s.templte;   //reassigning the variables to the original state
					}
					break;
				
				case 'share_it_links' :
				
					s.templtv = s.linkTrackVars; /*Saving the original state of the variables*/
					s.templte = s.linkTrackEvents; /*Saving the original state of the variables*/
					var socialchannel = elementSource.attr('id');
					s.linkTrackVars   = "events,eVar36,eVar38,eVar42,prop26,prop29,prop35";
					s.linkTrackEvents = "event7,event16,event18";
					s.events          = "event7,event16,event18";
					s.prop26          = s.eVar36 = SITE_ANALYTICS.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME + ":share";
					s.prop29          = s.eVar38 = SITE_ANALYTICS.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME + ":share:" + socialchannel.replace(/-link/g,' ').toLowerCase();
					s.prop35          = s.eVar42 = SITE_ANALYTICS.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME;
					s.tl(true, 'o', 'share on ' + socialchannel.toLowerCase().replace(/-link/g,''));
					if (s.templtv) {
						s.linkTrackVars = s.templtv;     //reassigning the variables to the original state
					}
					if (s.templte) {
						s.linkTrackEvents = s.templte;   //reassigning the variables to the original state
					}				
				break;
				
				default: 
					
					$.error('Calling a bad trackPromotionEvent: ' + keyword);
					       
					break;
			}
			
			s.t();
			
		},
		trackPromotionPage : function(keyword){

			if (typeof CURRENT_PROMOTION_NAME == 'undefined'){
			//	var CURRENT_PROMOTION_NAME = "unknown";
			}

			CURRENT_PROMOTION_NAME = CURRENT_PROMOTION_NAME.toLowerCase();			
            
			/* prevents hersheys.com from sending hersheys:hersheys:hersheys */
			var prefix = SITE_ANALYTICS.getBusinessUnit() == 'Hersheys' ? '' : SITE_ANALYTICS.getDomain().replace(/ /g,'').toLowerCase() + ':';

   
			switch(keyword){                              
				case 'register' :
					return true;
					/* The first step of the registration process actually determines WHICH step to show. We don't want to track this. Kind of messy. but makes the promo engine cleaner.*/
					break;
				case 'dob' : 
                                
					s.events   = "event15";
					s.pageName = 	prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME + ":dob";
					s.channel  =	prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop2    = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop3    = s.prop4  = s.prop1 = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME;
					s.prop26   = s.eVar36 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME + ":promotionentry";
					s.prop35   = s.eVar42 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME;  

					break;

				case 'form_initiation' :

					s.events   = "event18";
					s.pageName = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME + ":form initiation";
					s.channel  = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop2    = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop3    = s.prop4  = s.prop1 = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME;
					s.prop26   = s.eVar36 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME + ":promotionentry";
					s.prop35   = s.eVar42 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME;      

					break;				

				case 'entry_confirmation' :

					s.events   = "event14,event16";
					s.pageName = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME + ":entry confirmation";
					s.channel  = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop2    = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop3    = s.prop4  = s.prop1 = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME;
					s.prop26   = s.eVar36 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME + ":promotionentry";
					s.prop35   = s.eVar42 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME;  
					s.eVar33   = "New registration";

					break;

				case 'instant_win' :

					s.events   = "event14,event16";
					s.pageName = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME + ":entry confirmation";
					s.channel  = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop2    = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop3    = s.prop4  = s.prop1 = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME;
					s.prop26   = s.eVar36 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME + ":promotionentry";
					s.prop35   = s.eVar42 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME;  
					s.eVar33   = "Instant Win";

					break;
					
				case 'instant_win_existing' :

					s.events   = "event14,event16";
					s.pageName = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME + ":entry confirmation";
					s.channel  = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop2    = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop3    = s.prop4  = s.prop1 = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME;
					s.prop26   = s.eVar36 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME + ":promotionentry";
					s.prop35   = s.eVar42 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME;  
					s.eVar33   = "Instant Win";

					break;

				case 'repeat_entry_confirmation' :

					s.events   = "event14,event16";
					s.pageName = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME + ":repeat entry confirmation";
					s.channel  = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop2    = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop3    = s.prop4  = s.prop1 = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME;
					s.prop26   = s.eVar36 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME + ":promotionentry";
					s.prop35   = s.eVar42 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME;  
					s.eVar33   = "RepeatRegistered"; 

					break;

				case 'tell_a_friend' :

					s.events   = "event15";
					s.pageName = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME + ":tell a friend";
					s.channel  = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop2    = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop3    = s.prop4  = s.prop1 = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME;
					s.prop26   = s.eVar36 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME + ":tell a friend";
					s.prop35   = s.eVar42 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":" + CURRENT_PROMOTION_NAME;   

					break;
                                        
				default : 

					s.pageName = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions:" + CURRENT_PROMOTION_NAME + ":" + keyword.toLowerCase();
					s.channel  = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions";
					s.prop2    = s.prop3  = s.prop4 = s.prop1 = prefix + this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ":promotions" ;  
					s.prop35   = s.eVar42 = this.getBusinessUnit().replace(/ /g,'').toLowerCase() + ':' + CURRENT_PROMOTION_NAME;

					break;
			}
			
			s.t();
	
		},
		IsLoggedIn : function(){
			return HERSHEYS.IsLoggedIn;
		}

    };

})();

