(function(){
    var getQueryParam = function(name) {
        var results, expression = "[\\?&]"+name+"=([^&#]*)";
        if (results = window.location.href.match(expression)) {
            return results[1];
        }
        return false;
    }

    var uri = "", utm_medium, q, params = {rand : Math.random()};

    if (document.location)
        params.location = document.location;
    if (document.referrer)
        params.referer = document.referrer;
    if (utm_medium = getQueryParam('utm_medium'))
        params.utm_medium = utm_medium;
    if ((typeof vertical != "undefined") && vertical)
        params.vertical = vertical;
    if (q = getQueryParam('q'))
        params.q = q;
        
    if (window.post && post) {
        params.post_id = post.id;
        params.post_author = (post.author instanceof Array) ? 
            post.author.join('|') : post.author;
        params.post_author_ids = post.author_ids;
    }

	if (typeof _bi_domain != "undefined") {
		uri = document.location.protocol + "//" + _bi_domain;
	}
	
	uri += '/track.gif?';
	
    for (var k in params) {
        uri += '&' + k + '=' + encodeURIComponent(params[k]);
    }
	
	var i = new Image(1, 1);
		i.src = uri;
}());

