﻿// http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html

function getUrlVars() {
        var vars = [], hash;
        var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
        for (var i = 0; i < hashes.length; i++) {
            hash = hashes[i].split('=');
            vars.push(hash[0]);
            vars[hash[0]] = hash[1];
        }
        return vars;
    };
    
function getUrlVar (name) {
    return getUrlVars()[name];
};

// Kick off an autodownload for each element on the page marked autodownload
$(document).ready(function () {
    $('a.autoDownload').each(function () {
        setTimeout('navigateToDownload("' + $(this).attr('href') + '")', 4000);
    });

    $('a.track').click(function () {
        if (_gaq)
            _gaq.push(['_trackPageview', $(this).attr('href')]);
        document.location.href = $(this).attr('href');
    });

    // Check to see if this is a Confirmed page, and if so, report it to Google Analytics
    var confirmed = getUrlVar('confirmed');
    if (confirmed) {
        if (_gaq)
            _gaq.push(['_trackPageview', document.location.href+'/confirmed']);
    }

});

function navigateToDownload(href) {
    document.location.href = href;
};

