﻿
function LeaderboardLink(controlID) {
    //get selected leaderboardID 
    var leaderboardID = $(controlID).val()
    
    //get url to redirect to:
    // get the url of the page
    var url = document.location + "";

    // get the index of the querystring or anchor name hash
    var index = url.indexOf("?");
    var index2 = url.indexOf("#");

    // if there is an anchor hash, and either there is no querystring or the hash is before the querystring
    if ((index2 >= 0)
        &&
        (
            (index < 0) ||
            (index2 < index)
        ))
    {
        // use the hash index instead
        index = index2;
    }

    // if we have an anchor or querystring, strip it off
    if (index >= 0)
        url = url.substring(0, index);

    //redirect
    document.location = url + "?LeaderboardID=" + leaderboardID
}



