function trak(pluginName,value){TRAKTR=window.TRAKTR||{};TRAKTR.plugins=(TRAKTR.plugins||"");var getObjType=function(obj){var type=typeof(obj);if(type=='undefined'||obj===null){return false;}
if(type=='object'){if(obj.push){return'array';}}
return type;};var pList=TRAKTR.plugins.split('+');var addPlugin=true;for(var i=0;i<pList.length;i++){if(pList[i]==pluginName){addPlugin=false;}}
if(addPlugin){TRAKTR.plugins+=((TRAKTR.plugins==="")?"":"+")+pluginName;}
if(TRAKTR[pluginName]!==undefined&&TRAKTR[pluginName]!==null){var valueType=getObjType(TRAKTR[pluginName]);if(valueType=='array'){for(var v=0;v<value.length;v++){TRAKTR[pluginName].push(value[v]);}}else if(valueType=='object'){for(var x in value){if(value.hasOwnProperty(x)){TRAKTR[pluginName][x]=value[x];}}}else{TRAKTR[pluginName]=value;}}else{TRAKTR[pluginName]=value;}}

function CG_getCheckState(formLoc){
    var newsChecked = $("#CG_"+formLoc+"_searchtype_news").is(":checked"),
        carsChecked = $("#CG_"+formLoc+"_searchtype_sale").is(":checked");

    if(newsChecked && carsChecked){
        return "Both";
    }else if(!newsChecked && !carsChecked){
        return "None";
    }else if(newsChecked){
        return "NR";
    }else{
        return "CFS";
    }
}

trak('events', [
    {   'element': $('#CG_search_global input.CG_button').get(0),
        'event': 'click',
        'eventTypeDescription':'globalkeywordbutton',
        'data': {
            'kw_checkboxes': function() { return CG_getCheckState('global'); }
        }
    },
    {   'element': $('#CG_search_main input.CG_button').get(0),
        'event': 'click',
        'eventTypeDescription':'northkeywordbutton',
        'data': {
            'kw_checkboxes':  function() { return CG_getCheckState('main'); }
        }
    },
    {   'element': $('#CG_search_details input.CG_button').get(0),
        'event': 'click',
        'eventTypeDescription':'cardetailskeywordbutton',
        'data': {
            'kw_checkboxes':  'NR'
        }
    },
    {   'element': $('#CG_search_footer input.CG_button').not('body.mlp #CG_search_footer input.CG_button').get(0),
        'event': 'click',
        'eventTypeDescription':'southkeywordbutton',
        'data': {
            'kw_checkboxes':  function() { return CG_getCheckState('footer'); }
        }
    },
    {   'element': $('body.mlp #CG_search_footer input.CG_button').get(0),
        'event': 'click',
        'eventTypeDescription':'landingkeywordbutton',
        'data': {
            'kw_checkboxes':  function() { return CG_getCheckState('footer'); }
        }
    },
    {   'element': $('body.story #player').get(0),
        'event': 'click',
        'eventTypeDescription':'podcastcontrols',
        'data': {
            'click':'podcastcontrols'
        }
    },
    {   'element': $('body.story #CG_audio_download_link').get(0),
        'event': 'click',
        'eventTypeDescription':'podcastdownloadlink',
        'data': {
            'click':'podcastdownloadlink'
        }
    },
    {   'element': $('#contact-form input.send-email-button').get(0),
        'event': 'click',
        'eventTypeDescription':'dealercontactsendemailbutton',
        'data': {
            'click':'dealercontactsendemailbutton'
        }
    },
    {   'element': $('#CG_form_button_enquire').get(0),
        'event': 'click',
        'eventTypeDescription':'southdetailsleadbutton',
        'data': {
            'click':'southdetailsleadbutton'
        }
    },
    {   'element': $('#CG_form_button_enquire_rhs').get(0),
        'event': 'click',
        'eventTypeDescription':'northdetailsleadbutton',
        'data': {
            'click':'northdetailsleadbutton'
        }
    },
    {   'element': $('#CG_form_button_enquire_gallery').get(0),
        'event': 'click',
        'eventTypeDescription':'galleryleadbutton',
        'data': {
            'click':'galleryleadbutton'
        }
    },
    {   'element': $(".content-2 .CG_loancalculator .CG_form_button_calc").get(0),
        'event': 'click',
        'eventTypeDescription':'calculatorRHC',
        'data': {
            'click':'calculatorRHC'
        }
    },
    {   'element': $("#content-1 .CG_loancalculator .CG_form_button_calc").get(0),
        'event': 'click',
        'eventTypeDescription':'calculatorTAB',
        'data': {
            'click':'calculatorTAB'
        }
    },
    {   'element': $("#CG_playslideshow_link").get(0),
        'event': 'click',
        'eventTypeDescription':'galleryslideshowbutton',
        'data': {
            'click':'galleryslideshowbutton'
        }
    },
    {   'element': $("ul.CG_thumb_scroller_controls li.count").get(0),
        'event': 'click',
        'eventTypeDescription':'gallerypaginationbutton',
        'data': {
            'click':'gallerypaginationbutton'
        }
    }
]);