$(document).ready(function () {
    jQuery("a[href^=http]").not('a[href*="deceuninck.be"]').click(function () {
        var Argument = window.location.href.replace("http://", "").replace("https://", "") + "vp?" + $(this).attr("href").replace("http://", "").replace("https://", "")
        _gaq.push(['_trackPageview', Argument.replace("#vp?", "vp?").replace(".aspx?vp?", ".aspxvp?")]);
        if (!this.target == "_blank") {
            setTimeout('document.location = "' + $(this).attr("href") + '"', 100);
        }
    });

    var url = location.pathname;

    if (url.indexOf("contact.aspx") == -1) {
        jQuery("a[href^='mailto:benelux@deceuninck.com']").click(function () {
            _gaq.push(['_trackPageview', '/footer/mailto']);
            setTimeout('document.location = "' + $(this).attr("href") + '"', 100);
        });
    }
    else {
        jQuery("a[href^='mailto:benelux@deceuninck.com']").click(function () {
            _gaq.push(['_trackPageview', '/contact/mailto']);
            setTimeout('document.location = "' + $(this).attr("href") + '"', 100);
        });
    }

    // The slashes are to ensure the period is in the url, the $ is to make sure it is the end of the url, the i is to make it case insensitive.
    filetypes = /\.doc$|\.docx$|\.ai$|\.bmp$|\.dgn$|\.dwg$|\.dxf$|\.emf$|\.eps$|\.fci$|\.htm$|\.igs$|\.jpg$|\.pld$|\.png$|\.rmk$|\.stl$|\.stp$|\.tbn$|\.tif$|\.w10$|\.x10$|\.xls$|\.xlsx$|\.exe$|\.zip$|\.pdf$|\.psd$/i;
    $("a").not('a[href^=http]').each(function () {
        if ($(this).attr("href").match(filetypes)) {
            $(this).click(function () {
                var Argument = window.location.href.replace("http://", "").replace("https://", "") + "_downloads?" + $(this).attr("href").replace("../", "").replace("http://", "").replace("https://", "")
                _gaq.push(['_trackPageview', Argument.replace("#downloads?", "downloads?").replace(".aspx?downloads?", ".aspxdownloads?")]);
                if (!this.target == "_blank") {
                    setTimeout('document.location = "' + $(this).attr("href") + '"', 100);
                }
            });
        }
    })
});

function GATakeOverExistingPathTrackEventLink(string) {
    var returnstring = window.location.href.replace("http://", "").replace("https://", "") + string; 
    return returnstring;
}


