﻿function setupGA() {
    
    // Priority Analytics
    _gaq = [];
    _gaq.push(['_setAccount', 'UA-4274186-5']);
    _gaq.push(['_trackPageview']);

    // Business Section Specific Analytics
    var _gaq1 = _gaq || [];
    _gaq1.push(['_setAccount', 'UA-4274186-46']); // Subdirectory profile tracking ID
    _gaq1.push(['_trackPageview']);

    (function () {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        //ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/u/ga_debug.js';  //turn on for debugging if required
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();

    // Top Offers
    $('#aTopOffers').click(function () {
        _gaq.push(['_trackEvent', 'navigation', 'Top Offers', ]);
        //debug("GA call >> category: navigation, action: Top Offers");
    });

    // Office Equipment
    $('#aOfficeEquipment').click(function () {
        _gaq.push(['_trackEvent', 'navigation', 'Office Equipment', ]);
        //debug("GA call >> category: navigation, action: Office Equipment");
    });

    // Travel
    $('#aTravel').click(function () {
        _gaq.push(['_trackEvent', 'navigation', 'Travel', ]);
        //debug("GA call >> category: navigation, action: Travel");
    });

    // Protect Your Business
    $('#aProtectYourBusiness').click(function () {
        _gaq.push(['_trackEvent', 'navigation', 'Protect Your Business', ]);
        //debug("GA call >> category: navigation, action: Protect Your Business");
    });

    // Staff
    $('#aStaff').click(function () {
        _gaq.push(['_trackEvent', 'navigation', 'Staff', ]);
        //debug("GA call >> category: navigation, action: Staff");
    });

    // Lifestyle Benefits
    $('#aLifestyleBenefits').click(function () {
        _gaq.push(['_trackEvent', 'navigation', 'Lifestyle Benefits', ]);
        //debug("GA call >> category: navigation, action: Lifestyle Benefits");
    });

    // Other
    $('#aOther').click(function () {
        _gaq.push(['_trackEvent', 'navigation', 'Other', ]);
        //debug("GA call >> category: navigation, action: Other");
    });

    // Top Offer Links
    $('a.aCompanyName').click(function (e) {
        //e.preventDefault();
        
        var companyName = $(this).attr('title');

        if (companyName == 'Annodata Business Communications') {
            _gaq.push(['_trackEvent', 'business offer', 'Annodata Business Communications', ]);
            //debug("GA call >> category: business offer, action: Annodata Business Communications");            
        }
        else if (companyName == 'MoCo Communications Ltd') {
            _gaq.push(['_trackEvent', 'business offer', 'MoCo Communications Ltd', ]);
            //debug("GA call >> category: business offer, action: MoCo Communications Ltd");            
        }
        else if (companyName == 'Yell Limited') {
            _gaq.push(['_trackEvent', 'business offer', 'Yell Limited', ]);
            //debug("GA call >> category: business offer, action: Yell Limited");            
        }
        else if (companyName == 'Shine Business Centre') {
            _gaq.push(['_trackEvent', 'business offer', 'Shine Business Centre', ]);
            //debug("GA call >> category: business offer, action: Shine Business Centre");            
        }
        else if (companyName == 'APH Airport Parking') {
            _gaq.push(['_trackEvent', 'business offer', 'APH Airport Parking', ]);
            //debug("GA call >> category: business offer, action: APH Airport Parking");            
        }
        else if (companyName == 'Parcelforce Worldwide') {
            _gaq.push(['_trackEvent', 'business offer', 'Parcelforce Worldwide', ]);
            //debug("GA call >> category: business offer, action: APH Airport Parking");            
        }
        else if (companyName == 'thomsonlocal.com') {
            _gaq.push(['_trackEvent', 'business offer', 'thomsonlocal.com', ]);
            //debug("GA call >> category: business offer, action: thomsonlocal.com");            
        }
        else if (companyName == 'printing.com') {
            _gaq.push(['_trackEvent', 'business offer', 'printing.com', ]);
            //debug("GA call >> category: business offer, action: printing.com");            
        }
        else if (companyName == 'The Activity People') {
            _gaq.push(['_trackEvent', 'business offer', 'The Activity People', ]);
            //debug("GA call >> category: business offer, action: The Activity People");            
        }
        else if (companyName == 'The Team Building Company') {
            _gaq.push(['_trackEvent', 'business offer', 'The Team Building Company', ]);
            //debug("GA call >> category: business offer, action: The Team Building Company");            
        }
        else if (companyName == 'Team Tactics Ltd') {
            _gaq.push(['_trackEvent', 'business offer', 'Team Tactics Ltd', ]);
            //debug("GA call >> category: business offer, action: Team Tactics Ltd");            
        }
        else if (companyName == 'Hamper.com') {
            _gaq.push(['_trackEvent', 'business offer', 'Hamper.com', ]);
            //debug("GA call >> category: business offer, action: Hamper.com");            
        }
        else if (companyName == 'Virtual PA Co') {
            _gaq.push(['_trackEvent', 'business offer', 'Virtual PA Co', ]);
            //debug("GA call >> category: business offer, action: Virtual PA Co");            
        }

    });

    // Offer Links - Right Column
    // If signed in add click event with google analytics to links
    if ($('.divSignedIn').length) {
        $('.divSignedIn p a').click(function () {

            var offerClicked = $(this).attr('title');

            if (offerClicked == 'Get 10% off Yellsites') {
                _gaq.push(['_trackEvent', 'business offer', 'Get 10% off Yellsites', ]);
                //debug("GA call >> category: business offer, action: Get 10% off Yellsites");            
            }
            else if (offerClicked == 'For this offer, call sales on 0113 388 0000 and quote: SHINE/O2') {
                _gaq.push(['_trackEvent', 'business offer', 'For this offer, call sales on 0113 388 0000 and quote: SHINE/O2', ]);
                //debug("GA call >> category: business offer, action: For this offer, call sales on 0113 388 0000 and quote: SHINE/O2s");            
            }
            else if (offerClicked == 'Pre-book your APH airport parking now') {
                _gaq.push(['_trackEvent', 'business offer', 'Pre-book your APH airport parking now', ]);
                //debug("GA call >> category: business offer, action: Pre-book your APH airport parking now");            
            }
            else if (offerClicked == 'Book your delivery now (use code: VHPJ)') {
                _gaq.push(['_trackEvent', 'business offer', 'Book your delivery now (use code: VHPJ)', ]);
                //debug("GA call >> category: business offer, action: Book your delivery now (use code: VHPJ)");            
            }
            else if (offerClicked == 'Search now and quote O240 at checkout.') {
                _gaq.push(['_trackEvent', 'business offer', 'Search now and quote O240 at checkout.', ]);
                //debug("GA call >> category: business offer, action: Search now and quote O240 at checkout.");            
            }
            else if (offerClicked == 'Open an account with Parcelforce here') {
                _gaq.push(['_trackEvent', 'business offer', 'Open an account with Parcelforce here', ]);
                //debug("GA call >> category: business offer, action: Open an account with Parcelforce here");            
            }
            else if (offerClicked == 'Call 0844 745 3082 and quote ‘O2 Business customer’') {
                _gaq.push(['_trackEvent', 'business offer', 'Call 0844 745 3082 and quote ‘O2 Business customer’', ]);
                //debug("GA call >> category: business offer, action: Call 0844 745 3082 and quote ‘O2 Business customer’");            
            }
            else if (offerClicked == 'Call 01590 676599 and quote ‘O2’. ') {
                _gaq.push(['_trackEvent', 'business offer', 'Call 01590 676599 and quote ‘O2’.', ]);
                //debug("GA call >> category: business offer, action: Call 01590 676599 and quote ‘O2’.");            
            }
            else if (offerClicked == 'Call 01227 738280 quoting 10TH02 to start investigating') {
                _gaq.push(['_trackEvent', 'business offer', 'Call 01227 738280 quoting 10TH02 to start investigating', ]);
                //debug("GA call >> category: business offer, action: Call 01227 738280 quoting 10TH02 to start investigating");            
            }
            else if (offerClicked == 'Visit www.hamper.com and enter CW-BR2B at the checkout') {
                _gaq.push(['_trackEvent', 'business offer', 'Visit www.hamper.com and enter CW-BR2B at the checkout', ]);
                //debug("GA call >> category: business offer, action: Visit www.hamper.com and enter CW-BR2B at the checkout");            
            }
            else if (offerClicked == 'Get £50 towards your own virtual PA ') {
                _gaq.push(['_trackEvent', 'business offer', 'Get £50 towards your own virtual PA', ]);
                //debug("GA call >> category: business offer, action: Get £50 towards your own virtual PA");            
            }


        });
    }

}

$(document).ready(function () {
    setupGA();
});
