//------------------------------------------------------------------------------------------
// Common pops (c) netAdapt Ltd.
//------------------------------------------------------------------------------------------

function PopPlayerInfo( ev, playerId, offSetXParam, offSetYParam )
{
	var offSetX = offSetXParam;
	var offSetY = offSetYParam;
	var popWinId = 'xgamesummary' +  Math.floor(Math.random()*99999)
	var popWin = new CPopWin( ev, popWinId, 490, true, offSetX, offSetY );	
	url =  '/xml/xmenu/playerinfo.php?id=' + playerId;	
	popWin.Launch( 'Player Details', url );
}

function PopUserProfile( ev, userId, offSetXParam, offSetYParam, isNewWindow )
{
    $("#dialog_ltplayerprofile").dialog( {autoOpen: false, width: 510, height: 560} ); 
    $("#dialog_ltplayerprofile").html
    (
        "<img src='/img/ajax/ajax-bar.gif' alt='loading...' />"  
    ).load
    (
        "/findplayer/dialog/dialog_playerprofile.php", {userid: userId}, OpenPlayerProfileDialog()
    ); 
}

function OpenPlayerProfileDialog()
{
    $('#dialog_ltplayerprofile').dialog('option', 'show', 'blind');
    $('#dialog_ltplayerprofile').dialog('option', 'hide', 'blind');
    $('#dialog_ltplayerprofile').dialog('option', 'title', 'Player Profile');
    $("#dialog_ltplayerprofile").dialog("open");
}

function PopUserProfile_Old( ev, userId, offSetXParam, offSetYParam, isNewWindow )
{
    var popX = document.getElementById('popx').value;
    var popY = document.getElementById('popy').value;
    var newPopX = offSetXParam + parseInt(popX);
    var newPopY = offSetYParam + parseInt(popY);
    var offSetX = newPopX;
    var offSetY = newPopY;
    var popWinId = 'xgamesummary' +  Math.floor(Math.random()*99999)
    var popWin = new CPopWin( ev, popWinId, 490, true, offSetX, offSetY );
    url =  '/xml/xmenu/userprofile.php?userid=' + userId + '&nw=' + isNewWindow;    
    popWin.Launch( 'Player Profile', url );
    if (newPopX > 50)
    {
        document.getElementById('popx').value = 0;
        document.getElementById('popy').value = 0;
    }
    else
    {
        document.getElementById('popx').value = newPopX + 15;
        document.getElementById('popy').value = newPopY + 15;
    }
}

function PopLeagueMatch( ev, player1Id, player2Id, leagueId, division, sexForLeague, offSetXParam, offSetYParam, isNewWindow )
{
    var popX = document.getElementById('popx').value;
    var popY = document.getElementById('popy').value;
    var newPopX = offSetXParam + parseInt(popX);
    var newPopY = offSetYParam + parseInt(popY);
    var offSetX = newPopX;
    var offSetY = newPopY;
    var popWinId = 'xgamesummary' +  Math.floor(Math.random()*99999)
    var popWin = new CPopWin( null, popWinId, 490, true, offSetX, offSetY );    
    url =  '/xml/xmenu/leaguematch.php?player1id=' + player1Id + '&player2id=' + player2Id + '&leagueid=' + leagueId + '&division=' + division + '&sexforleague=' + sexForLeague + '&nw=' + isNewWindow;
    popWin.Launch( 'League Match Details', url );
    if (newPopX > 50)
    {
        document.getElementById('popx').value = 0;
        document.getElementById('popy').value = 0;
    }
    else
    {
        document.getElementById('popx').value = newPopX + 15;
        document.getElementById('popy').value = newPopY + 15;
    }
}

function PopConjugation( ev, verbId, infinitive )
{
    var offSetX = 0;        
    var offSetY = 0;            
    var popWinId = 'xgamesummary' +  Math.floor(Math.random()*99999)
    var popWin = new CPopWin( ev, popWinId, 550, true, offSetX, offSetY );    
    url =  '/xml/xmenu/verbconjugation.php?verbid=' + verbId;    
    popWin.Launch( 'Verb Conjugation for ' + infinitive, url );
}

function PopProTourMatch( ev, playerId, opponentId, startDate, endDate, surfaceId, categoryId, tour, offSetXParam, offSetYParam, isNewWindow )
{
    var offSetX = offSetXParam || -348;        
    var offSetY = offSetYParam || -15;            
    offSetX = 0;
    offSetY = 0;    
    var popWinId = 'xgamesummary' +  Math.floor(Math.random()*99999)
    var popWin = new CPopWin( null, popWinId, 550, true, offSetX, offSetY );    
    //url =  '/xml/xmenu/playerinfo.php?id=' + userId;    
    url =  '/xml/xmenu/matches.php?pid=' + playerId + '&oid=' + opponentId + '&sd=' + startDate + '&ed=' + endDate + '&sid=' + surfaceId + '&cid=' + categoryId + '&t=' + tour;
    //alert(offSetX);
    popWin.Launch( 'Match List', url );
}