//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function ReloadWindow() {
    window.location.href = window.location.href;    
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function CloseWindow() {
    window.close();    
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function OpenWindow(url, name, width, height) {
    OpenWindow(url, name, height, width, false);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function OpenWindow(url, name, width, height, enableScrollbars) {
    OpenWindow(url, name, height, width, enableScrollbars, false);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function OpenWindow(url, name, width, height, enableScrollbars, resizable) {
	if(navigator.appName.indexOf("WebTV")!=-1)
		window.location.href=url;
	else
	{
		winhandle=window.open(url, name, "width=" + width + ",height=" + height + ",scrollbars=" + GetWindowBoolString(enableScrollbars) + ",resizable=" + GetWindowBoolString(enableScrollbars) + ",status=no,menubar=no");
		winhandle.focus();
	}
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function OpenCustomerSupport() {
	if (confirm("Before moving onto our customer service department, have you read the page-specific help located along the top of every Hardball Dynasty page or the FAQ page within the Admin Office's Help section?  They contain the answers to the most frequently asked questions. Are you sure you've taken the time to read through these readily available resources?"))
		OpenWindow("../../../help/router.asp", "customer_", 743, 550, true, true);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function GetWindowBoolString(value) {
    if(value) 
        return "yes";
    else
        return "no";   
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function OpenPlayerProfile(playerid, tabindex) {
    OpenWindow("../Popups/PlayerProfile.aspx?pid=" + playerid, "playerprofile_" + playerid, 743, 550);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function OpenProspectProfile(playerid, tabindex) {
    OpenWindow("../Popups/ProspectProfile.aspx?pid=" + playerid, "prospectprofile_" + playerid, 743, 550);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function OpenFranchiseProfile(franchiseid, tabindex) {
    OpenWindow("../Popups/FranchiseProfile.aspx?fid=" + franchiseid, "franchiseprofile_" + franchiseid, 743, 550);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function OpenCoachProfile(coachid, tabindex) {
    OpenWindow("../Popups/CoachProfile.aspx?cid=" + coachid, "coachprofile_" + coachid, 743, 550);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function OpenUserProfile(uid) 
{
    OpenWindow("../Popups/UserProfile.aspx?uid=" + uid, "userprofile_" + uid, 743, 550);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function OpenPositionAssignment(playerid, tabindex) {
    OpenWindow("../Popups/PositionAssignment.aspx?pid=" + playerid, "positionassignment_" + playerid, 643, 625);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function OpenBoxscore(GameID) 
{
    OpenWindow("../Popups/Boxscore.aspx?gid=" + GameID, "boxscore_" + GameID, 773, 550, true);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function OpenBoxscoreWithPlayByPlay(GameID, PlayByPlay) 
{
    OpenWindow("../Popups/Boxscore.aspx?gid=" + GameID + "&pbp=" + PlayByPlay, "boxscore_" + GameID, 773, 550, true);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function OpenTour() 
{
    OpenWindow("Tour.aspx",100 , 762, 488 );
}

function OpenFlash()
{
	window.open("http://www.adobe.com/products/flashplayer/");
}

function OpenSupport()
{
	window.open("http://www.whatifsports.com/knowledgebase/SubmitTicket.aspx");
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function OpenPrivateWorldMembership(WorldID)
{
	OpenWindow("../Popups/PrivateWorldMembership.aspx?wid=" + WorldID, "privateworldmembership_" + WorldID, 800, 670,true);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function ViewMessage(messageID, pageID) {
    OpenWindow("../Popups/InboxMessage.aspx?mid=" + messageID + "&id=" + pageID , "message_" + messageID, 400, 460);    
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function removeCommas(nStr)
{
	nStr=nStr.replace(/\s/g,"");
	nStr=nStr.replace(/,/g,"");
	
	return nStr;
}			
