﻿var lastEl;
function s(elID)
{
    var offsetBuffer = 20;
    if (lastEl) lastEl.style.backgroundColor = 'White';
    var el = document.getElementById(elID);
    if (el)
    {
        window.scrollTo(el.offsetLeft - offsetBuffer, el.offsetTop - offsetBuffer);
        //el.scrollIntoView(true);
        el.style.backgroundColor = 'Yellow';
        lastEl = el;
    }
    return false;
}
function scrollHome()
{
    var offsetBuffer = 20;
    var defaultMatch = "W1-1";
    var defaultMatch2 = "W2-1";
    var el = document.getElementById(defaultMatch);
    if (!el)
    {
        //el = document.getElementById(defaultMatch2);
    }
    if (lastEl) lastEl.style.backgroundColor = 'White';
    var el = document.getElementById(defaultMatch);
    if (el)
    {
        window.scrollTo(el.offsetLeft - offsetBuffer, el.offsetTop - offsetBuffer);
    }
    return false;
}
function sm(entrantID)
{
    window.open("EntrantMatches.aspx?EntrantID="+entrantID
    , "EntrantMatches", "location=0,address=0,status=0,toolbar=0,resizable=1,width=650,height=600"); 

}
function sb(bracketID, matchLabel, closeThis)
{
    var navWin;
    // need to detect if window.opener is really parent from playbca.com
    if (window.opener && closeThis)
    {
        navWin = window.opener;
    }
    else
    {
        navWin = window;
    }
    var newURL = "BracketViewer.aspx?BracketID="+bracketID;
    
    if (matchLabel.length > 0)
    {
        newURL = newURL + "&MatchLabel="+matchLabel;
    }
    
    navWin.location.href = newURL;
    if (window.opener && closeThis)
    {
        if (window.opener) this.close();
    }
}
function st(tournamentID)
{
    window.location.href = "BracketViewer.aspx?TournamentID="+tournamentID;
}
function se(eventID)
{
    window.location.href = "BracketViewer.aspx?EventID="+eventID;
}

function getParam( name )
{  
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";  
    var regex = new RegExp( regexS );  
    var results = regex.exec( window.location.href );  
    if( results == null )
    {
        return "";  
    }
    else
    {
        return results[1];
    }
}

