﻿var structure = {
    /*
    * ------------------------------------------------------------------------------------------------
    * @alias init
    * ------------------------------------------------------------------------------------------------
    */
    init: function() {
        structure.tracking.init();
    },
    /*
    * ------------------------------------------------------------------------------------------------
    * @alias Tracking
    *
    * TRACKING
    * See too: 
    * Veja tambem: 
    * 
    * /App_Code/Tracking.cs
    * Line: 37
    * Method "Call"
    *
    * /App_code/MasteBase.cs
    * Line: 31
    * HiddenField TrackControlHidden
    * 
    * /Principal.master
    * Line: 42
    * <asp:hiddenfield id="hdnTrackControl" runat="server" />
    * 
    * All sections of code have the tag "here is tracking"
    * Todos os trechos de codigo possuem a tag "here is tracking"
    * 
    * ------------------------------------------------------------------------------------------------
    */
    tracking: {

        init: function() {
            var trackControl = $('span#track-control input');

            if (trackControl.val() != undefined && trackControl.val() != "") {
                this.call(trackControl.val())
            }
            else {
                //trace('nao chama...');
            }
        },

        call: function(key) {
            //trace('chama ' + key);
            dpc_pageview(key);
        },
        /*
        * Use the method 'hrefCall' in hyperlinks, so that 
        * tracking occurs before the page is unloaded
        */
        hrefCall: function(key, handler) {
            this.call(key);
			
            if ($(handler).attr('href') != undefined) {
                setTimeout(function() {
                    if ($(handler).attr('target') == '_blank') {
                        window.open($(handler).attr('href'));
                        void (0);
                    }
                    else {
                        location.href = $(handler).attr('href');
                    }
                }, 500);
            }
            return false;
        }
    }
}

/*
* ------------------------------------------------------------------------------------------------
* @shortcuts
* ------------------------------------------------------------------------------------------------
*/
var tracking = structure.tracking;
