﻿// WGN namespace
if (typeof (WGN) == "undefined") {
    var WGN = {
        currentSection: "",
        newSection: ""
    };
}


WGN.showSection = function() {

    //highlight correct sub nav
    $('.sub-nav li.li' + WGN.currentSection + 'Sel').attr('class', 'li' + WGN.currentSection);
    $('.sub-nav li.li' + WGN.newSection).attr('class', 'li' + WGN.newSection + 'Sel');

    //show/hide content sections
    $('.content-main').hide();
    $('#main' + WGN.newSection).show();

    //set height of left content section to match height of main section
    //    var mainHeight = $('#main' + WGN.newSection).height();
    //    $('div.content-left').height(mainHeight + 153);

    WGN.currentSection = WGN.newSection;

    //webtrends tracking
    var trackingURL = '/WGN/';
    var trackingTitle = "";
    switch (WGN.newSection) {
        case 'Benefits':
            trackingURL += 'benefits/5LifeChanges';
            trackingTitle = 'Whole Grain Benefits - 5 Life Changes';
            break;
        case 'Nutrients':
            trackingURL += 'benefits/8Nutrients';
            trackingTitle = 'Whole Grain Benefits - 8 Nutrients';
            break;
        case 'Fiber':
            trackingURL += 'benefits/MoreThanFiber';
            trackingTitle = 'Whole Grain Benefits - More Than Fiber';
            break;
        case 'Lifestyle':
            trackingURL += 'lifestyle/EveryMeal';
            trackingTitle = 'Whole Grain Lifestyle - Every Meal';
            break;
        case 'Picky':
            trackingURL += 'lifestyle/PickyEaters';
            trackingTitle = 'Whole Grain Lifestyle - Picky Eaters';
            break;
        case 'Find':
            trackingURL += 'lifestyle/FindWholeGrain';
            trackingTitle = 'Whole Grain Lifestyle - Find Whole Grain';
            break;
        case 'Cereals':
            trackingURL += 'biggcereals/Products';
            trackingTitle = 'Whole Grain Big G Cereals - Products';
            break;
        case 'Passion':
            trackingURL += 'biggcereals/NutritionPassion';
            trackingTitle = 'Whole Grain Big G Cereals - Nutrition Passion';
            break;
            
    }
    dcsMultiTrack('DCS.dcsuri', trackingURL, 'WT.ti', trackingTitle);
}


$(document).ready(function() {
    $('.sub-nav ul a').click(function() {
        WGN.newSection = $(this).attr('rel');
        WGN.showSection();
        return false;
    });

});

