﻿/*
NAME: lookupCategory
AUTHOR: Patrick Scott (WP)
DATE: 11/02/2010
INPUTS (strings): categoryName text from RTP analyticsLineItem.CategoryName and productID number from RTP analyticsLineItem.ProductId
OUTPUT (string): standard category for site catalyst reporting
DESCRIPTION: Lookup all eStore products and report their category to site catalyst.

Allowable standard categories:
1. Lodging
2. Lift Tickets
3. Equipment Rentals
4. Ski & Snowboard School
5. Season Passes
6. Cards
7. Activities
8. Air Travel
9. Car Rentals
10. Transportation
11. Travel Insurance
12. Other
*/

function lookupCategory(categoryName, productID)
{
    var category = '';

    switch (categoryName)
    {
        /* Season Passes */
        case 'New Passes': // Season passes and 4 by 40 tickets
            category = productLookup(productID);
            break;
        case 'Summer Passes':
            category = 'Season Passes';
            break;
        case 'Undefined': // Reload Products
            category = productLookup(productID);
            break;
        case 'Renewal Passes - Winter 11-12': // Reload Products
            category = productLookup(productID);
            break;

        /* 4 by 40 */
        case '4 by 40':
            category = 'Lift Tickets';
            break;

        /* Colorado Triple Play */
        case 'Colorado Triple Play':
            category = 'Lift Tickets';
            break;

        /* Tickets */
        case 'Adult Lift Tickets':
            category = 'Lift Tickets';
            break;
        case 'Child Lift Tickets':
            category = 'Lift Tickets';
            break;
        case 'Senior Lift Tickets':
            category = 'Lift Tickets';
            break;
        case '70+ Lift Tickets':
            category = 'Lift Tickets';
            break;
        case 'Summer Tickets':
            category = 'Lift Tickets';
            break;
        case 'Winter Adult Lift Tickets':
            category = 'Lift Tickets';
            break;
        case 'Winter Child Lift Tickets':
            category = 'Lift Tickets';
            break;
        case 'Winter Senior Lift Tickets':
            category = 'Lift Tickets';
            break;
        case 'Winter 70+ Lift Tickets':
            category = 'Lift Tickets';
            break;

        /* Equipment */
        case 'World Cup Bikes':
            category = 'Equipment Rentals';
            break;
        case 'Demo Bikes':
            category = 'Equipment Rentals';
            break;
        case 'Downhill Bikes':
            category = 'Equipment Rentals';
            break;
        case 'JR Downhill Bikes':
            category = 'Equipment Rentals';
            break;
        case 'Cross Country Bikes':
            category = 'Equipment Rentals';
            break;
        case 'Demo Ski':
            category = 'Equipment Rentals';
            break;
        case 'Demo Snowboard':
            category = 'Equipment Rentals';
            break;
        case 'High Performance Ski':
            category = 'Equipment Rentals';
            break;
        case 'High Performance Snowboard':
            category = 'Equipment Rentals';
            break;
        case 'Performance Ski':
            category = 'Equipment Rentals';
            break;
        case 'Performance Snowboard':
            category = 'Equipment Rentals';
            break;
        case 'Sport Ski':
            category = 'Equipment Rentals';
            break;
        case 'Sport Snowboard':
            category = 'Equipment Rentals';
            break;
        case 'Junior Ski':
            category = 'Equipment Rentals';
            break;
        case 'Junior Snowboard':
            category = 'Equipment Rentals';
            break;
        case 'Helmets':
            category = 'Equipment Rentals';
            break;
        case 'Delivery Service':
            category = 'Equipment Rentals';
            break;
        case 'Season Long Rentals':
            category = 'Equipment Rentals';
            break;            

        /* Lessons */
        case 'Lesson Passes':
            category = 'Ski & Snowboard School';
            break;
        case 'Bike Lessons':
            category = 'Ski & Snowboard School';
            break;
        case 'Bike Camps':
            category = 'Ski & Snowboard School';
            break;
        case 'Winter Lesson Passes':
            category = 'Ski & Snowboard School';
            break;
        case 'Wednesday - Guppies (3-5yr)':
            category = 'Ski & Snowboard School';
            break;
        case 'Friday - Barracudas (4-14yr)':
            category = 'Ski & Snowboard School';
            break;
        case 'Friday - Piranhas (4-14yr)':
            category = 'Ski & Snowboard School';
            break;
        case 'Weekend - Minnows (4-5yr)':
            category = 'Ski & Snowboard School';
            break;
        case 'Weekend - Barracudas (6-14yr)':
            category = 'Ski & Snowboard School';
            break;
        case 'Weekend - Piranhas (6-14yr)':
            category = 'Ski & Snowboard School';
            break;
        case 'Just Because I’m 3':
            category = 'Ski & Snowboard School';
            break;
        case 'Kids’ Ski (4-6yr)':
            category = 'Ski & Snowboard School';
            break;
        case 'Kids’ Ski (7-14yr)':
            category = 'Ski & Snowboard School';
            break;
        case 'Kids’ Snowboard (4-6yr)':
            category = 'Ski & Snowboard School';
            break;
        case 'Kids’ Snowboard (7-14yr)':
            category = 'Ski & Snowboard School';
            break;
        case 'Kids’ Snowboard (6-14yr)':
            category = 'Ski & Snowboard School';
            break;
        case 'Teen Freeride Camps (14-17yr)':
            category = 'Ski & Snowboard School';
            break;
        case 'Adult Group Lessons':
            category = 'Ski & Snowboard School';
            break;
        case 'Private Lessons':
            category = 'Ski & Snowboard School';
            break;
        case 'Specialty Camps':
            category = 'Ski & Snowboard School';
            break;
        case 'Women’s Camps':
            category = 'Ski & Snowboard School';
            break;
        case 'Childcare':
            category = 'Ski & Snowboard School';
            break;
        case 'Night Bikes':
            category = 'Ski & Snowboard School';
            break;
        case 'Ski Bikes':
            category = 'Ski & Snowboard School';
            break;

        /* Competition Center \ Bike Races */ 
        case 'WP Snowboard Team Camp':
            category = 'Activities';
            break;
        case 'King of the Grommets':
            category = 'Activities';
            break;
        case 'VANS King of the Grommets':
            category = 'Activities';
            break;
        case 'Winter Park Freeskiing Open':
            category = 'Activities';
            break;
        case 'Epic Singletrack Series - Beginner':
            category = 'Activities';
            break;
        case 'Epic Singletrack Series - Sport':
            category = 'Activities';
            break;
        case 'Epic Singletrack Series - Expert':
            category = 'Activities';
            break;
        case 'Epic Singletrack Series - Pro or Semi-Pro':
            category = 'Activities';
            break;
        case 'Epic Singletrack Series - Single Speed':
            category = 'Activities';
            break;
        case 'Epic Singletrack Series - Clydesdale':
            category = 'Activities';
            break;
        case 'Epic Singletrack Series - Open':
            category = 'Activities';
            break;
        case 'Crankworx Colorado':
            category = 'Activities';
            break;
        case 'Trestle All-Mountain Enduro':
            category = 'Activities';
            break;
        case 'Trestle Downhill Series':
            category = 'Activities';
            break;

        /* Lodging */
        case 'Lodging Passes':
            category = 'Lodging';
            break;

         /* Hidden pages */ 
        case 'AMEX Triple Points':
            category = 'Lift Tickets';
            break;
        case 'Home James Ski Rentals':
            category = 'Equipment Rentals';
            break;
        case 'Home James Snowboard Rentals':
            category = 'Equipment Rentals';
            break;
        case 'Home James Custom Delivery Service':
            category = 'Equipment Rentals';
            break;
        case 'DU Winter Carnival Ski Rentals':
            category = 'Equipment Rentals';
            break;
        case 'DU Winter Carnival Snowboard Rentals':
            category = 'Equipment Rentals';
            break;
        case 'Winter Park Lodging Company Ski Rentals':
            category = 'Equipment Rentals';
            break;
        case 'Winter Park Lodging Company Snowboard Rentals':
            category = 'Equipment Rentals';
            break;
        case 'Winter Park Lodging Company Bike Rentals':
            category = 'Equipment Rentals';
            break;
        case 'Winter Park Lodging Company Custom Delivery Service':
            category = 'Equipment Rentals';
            break;
        case 'Winter Park Management Ski Rentals':
            category = 'Equipment Rentals';
            break;
        case 'Winter Park Management Snowboard Rentals':
            category = 'Equipment Rentals';
            break;
        case 'Winter Park Management Custom Delivery Service':
            category = 'Equipment Rentals';
            break;
        case 'Ski Exchange Rentals':
            category = 'Equipment Rentals';
            break;
        case 'NASTAR Race Clinics':
            category = 'Ski & Snowboard School';
            break;
        case 'NASTAR Lift Tickets':
            category = 'Lift Tickets';
            break;
        case 'Hike For Spencer':
            category = 'Other';
            break;

        /* Stored Value */
        case 'PayProd-SV':
            category = 'Other';
            break;
            
        default:
            category = 'Other';
            break;
    }

    return category;
}

function productLookup(productID)
{    
    switch (productID) {
        // Winter Season Passes Renewal Passes
        case '29041': // WP Four Pass w/media
            category = 'Cards';
            break;
        case '38722': // WP Four Pass R
            category = 'Cards';
            break;
        case '38056': // 4 by 40 Pass w/Media
            category = 'Lift Tickets';
            break;
        case '39465': // 4 BY 40 Pass R
            category = 'Lift Tickets';
            break;

        default:
            category = 'Season Passes';
    }

    return category;
}


function WriteFile(text) {
    var xmlHttp;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                //alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }

    //first parameter is to specify Method either GET or POST
    //second parameter is URL of server, where you want to send request
    //Third parameter would define either communication pattern is synchornous(false) or asynchornous(true)
    xmlHttp.open("GET", "/writeFile.aspx?text=" + text.replace(/&/gi, ""), false);

    //send request to server according to parameters
    xmlHttp.send(null);
}
