var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22499318-1']);
_gaq.push(['_setDomainName', '.obc.cat']);



$(function () {
    $('.trackEventCompraEntrades').bind('click', function() {
        _gaq.push(["_trackEvent", "Compra_entrades", $(this).attr("tipoentrada")]);
    });

    $('.trackEventMenuPrincipal').bind('click', function() {
        _gaq.push(["_trackEvent", "Menu_Principal", $(this).attr("trackEventValue")]);
    });

    $('.trackOutbounds').bind('click', function() {
        _gaq.push(["_trackPageview", $(this).attr('href') + "mxr=/url_virtual/PaginasVirtuales/Outbounds/" + $(this).attr("trackPagina") + "/" + $(this).attr("trackDescipcionDestino") + ""]);
    });


    $('.trackEvent').bind('click', function () {
        if (($(this).attr("trackEventValue2")) && ($(this).attr("trackEventValue2") != '')) {
            _gaq.push(["_trackEvent", $(this).attr("trackEventVar"), $(this).attr("trackEventValue"), $(this).attr("trackEventValue2")]);
        }
        else {
            _gaq.push(["_trackEvent", $(this).attr("trackEventVar"), $(this).attr("trackEventValue")]);
        }
    });
});

function doGoogleAnalytics(urlLogicaContenido) {

    var fisica = document.domain + location.pathname + location.search;
    if (fisica.match(/\?/))
       fisica += "&";
    else
        fisica +="?";
    var logica = '/url_logica/' + urlLogicaContenido;
    var contenido = fisica + 'mxr=' + logica;
    //_gaq.push(['_setCampaignCookieTimeOut', 2628000000]);
    _gaq.push(['_trackPageview', contenido]);
    _gaq.push(['_trackPageLoadTime']);
}


(function () {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
