﻿// Omniture code
$(document).ready(function() {
    $('div.job_tabs>ul>li>a').click(function() {
        var jobID = $(this).parents('.jobsSearchSleeve').attr("id");
        jobID = jobID.toLowerCase();
        jobID = jobID.replace("gold", "");
        jobID = jobID.replace("silver", "");

        var tabName;
        tabName = $(this).html();
        tabName = tabName.replace(/^\s+|\s+$/g, '');

        if (tabName == "School Information") {
            //If it is a school information tab
            var s = s_gi('tsltescouk');
            s.linkTrackVars = 'prop1,prop2,events';
            s.linkTrackEvents = 'event6';
            s.prop1 = jobID;
            s.events = 'event6';
            s.tl(this, 'o', 'School Information Disclosure');
        }
        else if (tabName == "Location and map") {
            //This is a locations and maps tab
            var s = s_gi('tsltescouk');
            s.linkTrackVars = 'prop1,prop2,events';
            s.linkTrackEvents = 'event6';
            s.prop1 = jobID;
            s.events = 'event6';
            s.tl(this, 'o', 'Location and Map Disclosure');
        }
    });

    $('#nav .secondary a[href*="talentbank.aspx"]').click(function(e) {
        var s = s_gi('tsltescouk');
        s.linkTrackVars = 'events';
        s.linkTrackEvents = 'event78';
        s.events = 'event78';
        s.tl(this, 'o', 'TalentBank');
    });

});


function OmnitureTrackingArticleDownload(storycode, type)
{
    var s = s_gi('tsltescouk');
    s.linkTrackVars='events,products';
    s.products=';resource_id' + storycode;
    if (type == "X") 
    {
        s.linkTrackEvents = 'event25';
        s.events = 'event25';
    }
    else if (type == "W") 
    {
        s.linkTrackEvents = 'event26';
        s.events = 'event26';
    }

    s.tl(this, 'o', 'ResourceDownload');
}



function OmnitureTrackingLocalProfile(jobid)
{
    var s=s_gi('tsltescouk');
    s.linkTrackVars='events,products';
    s.linkTrackEvents='event26';
    s.events='event26';
    s.products=';jobid' + jobid + '_jobid';
    s.tl(this,'o','LocalProfileClick');
}

function ResourceUploadSteps(Step)
{
   var s=s_gi('tsltescouk');
   s.linkTrackVars='events,products';
    
    // File Uplaoded
    //Resourcetypeselected
    //Phase selected
    //Subject Selected
    //Title selected.
    //Submit button for newResourceClicked
    //Submit button for editResourceClicked
    if (Step=='stepA')
    {
        s.linkTrackEvents='event29';
        s.events='event29';
        s.products=';ResourceID';
        s.tl(this,'o','FileUpload');
    }
    else if (Step=='stepB')
    {
        s.linkTrackEvents='event30';
        s.events='event30';
        s.products=';ResourceID';
        s.tl(this,'o','ResourceType');
    }
    else if (Step=='stepC')
    {
        s.linkTrackEvents='event31';
        s.events='event31';
        s.products=';ResourceID';
        s.tl(this,'o','KeyStage');
    }
    else if (Step=='stepD')
    {
        s.linkTrackEvents='event32';
        s.events='event32';
        s.products=';ResourceID';
        s.tl(this,'o','Subjects');
    }
    else if (Step=='stepE')
    {
        s.linkTrackEvents='event33';
        s.events='event33';
        s.products=';ResourceID';
        s.tl(this,'o','TitleAndDesc');
    }
    else if (Step=='stepF')
    {
        s.linkTrackEvents='event34';
        s.events='event34';
        s.products=';ResourceID';
        s.tl(this,'o','NewResourceSubmit');
    }
    else if (Step=='stepG')
    {
        s.linkTrackEvents='event35';
        s.events='event35';
        s.products=';ResourceID';
        s.tl(this,'o','EditResourceSubmit');
    }  
}

function FlashInstalled(isInstalled)
{
    s.linkTrackEvents='event38';
    s.events='event38';
    s.products=';ResourceID';
    if (isInstalled==true)
    {
        s.tl(this,'o','FlashInstalled');
    }
    else
    {
        s.tl(this,'o','FlashNotInstalled');
    }
}

function SetOmnitureForJobApplications(jobid,step)
{
    var s = s_gi('tsltescouk');
    s.linkTrackVars = 'events,products';
    
    switch(step)
    {
        case 'eligibility': s.linkTrackEvents='event50';
                            s.events='event50';
                            s.products=';jobid' + jobid + '_jobid';
                            s.tl(this,'o','EligibilitySubmit');
                            break;
                        
    case 'personalDetails': s.linkTrackEvents='event51';
                            s.events='event51';
                            s.products=';jobid' + jobid + '_jobid';
                            s.tl(this,'o','personalDetailsSubmit');
                            break;
                            
    case 'experience':      s.linkTrackEvents='event52';
                            s.events='event52';
                            s.products=';jobid' + jobid + '_jobid';
                            s.tl(this,'o','experienceSubmit');
                            break;
                            
    case 'qualifications':  s.linkTrackEvents='event53';
                            s.events='event53';
                            s.products=';jobid' + jobid + '_jobid';
                            s.tl(this,'o','qualificationsSubmit');
                            break;
                            
    case 'personalstatement': 
                            s.linkTrackEvents='event54';
                            s.events='event54';
                            s.products=';jobid' + jobid + '_jobid';
                            s.tl(this,'o','personalstatementSubmit');
                            break;
                            
    case 'reference':       s.linkTrackEvents='event55';
                            s.events='event55';
                            s.products=';jobid' + jobid + '_jobid';
                            s.tl(this,'o','referenceSubmit');
                            break;
                            
    case 'checks':          s.linkTrackEvents='event56';
                            s.events='event56';
                            s.products=';jobid' + jobid + '_jobid';
                            s.tl(this,'o','checksSubmit');
                            break;
                            
    case 'equalops':        s.linkTrackEvents='event57';
                            s.events='event57';
                            s.products=';jobid' + jobid + '_jobid';
                            s.tl(this,'o','equalopsSubmit');
                            break;
                            
     case 'review':         s.linkTrackEvents='event59';
                            s.events='event59';
                            s.products=';jobid' + jobid + '_jobid';
                            s.tl(this,'o','reviewSubmit');
                            break;
                            
    case 'upload':          s.linkTrackEvents='event98';
                            s.events='event98';
                            s.products=';jobid' + jobid + '_jobid';
                            s.tl(this,'o','applicationUpload');
                            break;
                            
    case 'download':        s.linkTrackEvents='event97';
                            s.events='event97';
                            s.products=';jobid' + jobid + '_jobid';
                            s.tl(this,'o','applicationDownload');
                            break;
    case 'apply':           s.linkTrackEvents='event91';
                            s.events='event91';
                            s.products=';jobid' + jobid + '_jobid';
                            s.tl(this,'o','NewApplicationApply');
                            break;
                            
    case 'applyProgress':   s.linkTrackEvents='event49';
                            s.events='event49';
                            s.products=';jobid' + jobid + '_jobid';
                            s.tl(this,'o','NewApplicationApply');
                            break;
                            
    case 'myALerts':        s.linkTrackEvents='event62';
                            s.events='event62';
                            s.products='0';
                            s.tl(this,'o','MyJobsClicked');
                            break;
                            
    case 'jobDetail':       s.linkTrackEvents='event65';
                            s.events='event65';
                            s.products=';jobid' + jobid + '_jobid';
                            s.tl(this,'o','jobDetailsClicked');
                            break;

    case 'uploadCV':        s.linkTrackEvents = 'event99';
                            s.events = 'event99';
                            s.products = ';jobid' + jobid + '_jobid';
                            s.tl(this, 'o', 'jobapplicationUpload');
                            break;

    }

}

function SetOmnitureForJobApplicationsHW(jobid, prop13, prop27, PackageType) 
   {

     var s = s_gi('tsltescouk');
     s.linkTrackVars = 'events,products,prop10,prop11,prop12,prop13,prop27,channel';
     s.channel = 'jobs';
     s.prop10 = 'jobs';
     s.prop11 = 'jobs';
     s.prop12 = 'jobs';
     s.linkTrackEvents = 'event91';
     s.events = 'event91';
     s.products = ';jobid' + jobid + '_' + PackageType;
     s.prop13 = prop13;
     s.prop27 = prop27;
     s.tl(this, 'o', 'jobapplicationHireWire');
   }

function SetOmnitureForFunnel(catNames, event) {

    var s = s_gi('tsltescouk');
    s.linkTrackVars = 'events,products';
    if (catNames != "") {
        var catName = catNames.toString();
        catName = catName.replace(/&/g, ":");
        catName = catName.replace(/_/g, " ");
        s.prop38 = catName;
    }
    if (event != "") {
        s.events = event;
    }
    s.tl(this, 'o', 'funnelResults');
}

function OmnitureTrackingAttachmentDownload() {
    var s = s_gi('tsltescouk');
    s.linkTrackVars='events,products';
    s.linkTrackEvents = 'event6';
    s.events = 'event6';

    s.tl(this, 'o', 'JobAttachmentDownload');
}

function SetOmnitureForSearchListing(jobid, jobsBreadCrumb , packageName) {
    var s = s_gi('tsltescouk');
    s.linkTrackVars = 'events,products,prop47';
    s.linkTrackEvents = 'event63';
    s.events = 'event63';
    s.products = ';job_id' + jobid + '_' + packageName + ';;;event63=1';
    s.prop47 = jobsBreadCrumb;
    s.tl(this, 'o', 'jobListingJobLinkClick');
}

