function trackevent(category, action, title) {
    /*alert(category);
    alert(action);
    alert(title);*/
    _gaq.push(['_trackEvent', category, action, title]);
}

function trackevent2(url, category, action, title) {
    /*alert(url);
    alert(category);
    alert(action);
    alert(title);*/
    _gaq.push(['_trackEvent', category, action, title]);
    window.open(url);
}


$(document).ready(function () {

    $("a.jqtrackevent1, a.jqtrackevent2").click(function () {

        //var url = $(this).attr("href");
        var action = "Download";
        //var title = $(this).html();   // don't use the <a>html text</a>, but use "title" attribute,
        //because html sometimes isn't just plain text but stuff like spans etc: <a><span...>title</span></a>
        var title = $(this).attr("title");
        var category;

        switch ($(this).attr("class").toString()) {

            case "track_about-us_about-us":
                category = "ABOUT US";
                break;
            case "track_about-us_staff":
                category = "ABOUT US >> Staff";
                break;
            case "track_about-us_trustees":
                category = "ABOUT US >> Trustees";
                break;
            case "track_about-us_patrons":
                category = "ABOUT US >> Patrons";
                break;
            case "track_about-us_annual_reports":
                category = "ABOUT US >> Annual Reports";
                break;

            case "track_library_library":
                category = "LIBRARY";
                break;
            case "track_library_project-reports":
                category = "LIBRARY >> Project Reports ";
                break;
            case "track_library_dissemination-series":
                category = "LIBRARY >> Dissemination Series";
                break;
            case "track_library_publications":
                category = "LIBRARY >> Publications";
                break;
            case "track_library_reference_lists":
                category = "LIBRARY >> Reference Lists";
                break;
            case "track_library_evaluations":
                category = "LIBRARY >> Evaluations";
                break;
            case "track_library_project_archive":
                category = "LIBRARY >> Project Archive";
                break;
            case "track_library_awards_archive":
                category = "LIBRARY >> Awards Archive";
                break;
            case "track_library_journal":
                category = "LIBRARY >> Journal";
                break;

            case "track_programmes_programmes":
                category = "PROGRAMMES";
                break;
            case "track_programmes_patients-first":
                category = "PROGRAMMES >> Patients First";
                break;
            case "track_programmes_development-research":
                category = "PROGRAMMES >> Development and Research";
                break;
            case "track_programmes_small-projects":
                category = "PROGRAMMES >> Small Projects";
                break;

            case "track_learning-zone_learning-zone":
                category = "LEARNING ZONE";
                break;
            case "track_learning-zone_tools-and-resources":
                category = "LEARNING ZONE >> Tools and Resources";
                break;
            case "track_learning-zone_podcasts":
                category = "LEARNING ZONE >> Podcasts";
                break;
            case "track_learning-zone_teleconferences":
                category = "LEARNING ZONE >> Teleconferences";
                break;
            case "track_learning-zone_consultancy-facilitation":
                category = "LEARNING ZONE >> Consultancy And Facilitation ";
                break;
            // they will need to do these ones themselves -> custom2 field     
            case "track_learning-zone_report-details":
                category = "LEARNING ZONE >> Tools and Resources";
                break;

            case "track_supporting-fons_supporting-fons":
                category = "SUPPORTING FONS";
                break;
            case "track_supporting-fons_donations":
                category = "SUPPORTING FONS >> Donations";
                break;
            case "track_supporting-fons_legacies":
                category = "SUPPORTING FONS >> Legacies";
                break;
            case "track_supporting-fons_shopping":
                category = "SUPPORTING FONS >> Shopping";
                break;
            case "track_supporting-fons_fundraising-events":
                category = "SUPPORTING FONS >> Fundraising Events";
                break;
        }

        trackevent(category, action, title);
        //trackevent2(url, category, action, title);
        //return (false);     // this will void the original "href" action

    });

});

