/**
 * javascript to add binaries to google analytics
 */
google.load("jquery", "1.3.2");

var hold_init = false;
/*
    script.js

* */

function trackMe(me) {
    try {
        me = $(me);
        link = me.attr('href');
        me = me.attr('href');
        me = me.replace('http://', '');
        var splitAt = me.indexOf('/');
        var path = me.substring(splitAt, me.length);
        //alert('tracking: ' + path)
        _gaq.push(['_trackPageview', path]);
        //alert('done?')   
        if ($.browser.msie && $.browser.version == "8.0") {
            setTimeout('window.open("' + link + '", "_self")', 100);
        } else {
            setTimeout('window.open("' + link + '")', 100)
        }
    } catch(e) {
    }

}

google.setOnLoadCallback(
    function() {
        // internal links should open in the same window for IE8:
        if ($.browser.msie && $.browser.version == "8.0") {
            $("a[href^=/]").attr("target", "_self");
            // open internal links written as external links within self
            $("a[href^='http://www.tui.nl']").attr('target', '_self');
            // open external links within self
            $("a[href^='http://']").attr('target', '_self');
        }
        
        // all binary links start in a new window, but call to trackMe to include google analytics:
        $("a[href*=.pdf], a[href*=.doc], a[href*=.ppt]").attr("target", "_self").attr("onClick", "trackMe(this); return false;");
   
        if (hold_init) {
            tui.init();
        }
    }
);

