
function gamePageWrite( objB )
{
    document.writeln( objB );
}

function gotoInParent(url,stayOpen)
{
    if (window.opener == null) {
        window.location = url;
    } else {
        window.opener.location = url;
        window.opener.focus();
        if (!stayOpen)
        {
            window.close();
        }
    }
}

// on all calls where the response is under 512 bytes, expect IE to cache the
// request and not call it twice.  append this to requests as needed
function ie_cache_breaker()
{
    x=Math.floor(Math.random()*1000);
    y=Math.floor(Math.random()*1000);
    z=Math.floor(Math.random()*1000);

    return 'green=' + x + '&red=' + y  + '&blue=' + z;
}

// KEEP-ALIVE CODE FOR DAUGHTER WINDOWS. THIS LOOP WILL PING THE SERVER EVERY [PINGER_DELAY] MILLISECONDS
var PINGER_DELAY = 5 * 60 * 1000; // once every 5 minutes
var PINGER_START = false;

function pingServer()
{
    // don't ping first time this function is called
    if ( PINGER_START )
	{
        // The gameKeyword variable should be set in the landing page
        var keepAliveUrl = '/contentPlay/keepAlive.jsp' + '?keyword=' + gameKeyword + '&' + ie_cache_breaker();

        $.get( keepAliveUrl );
    }

	PINGER_START = true;

	setTimeout('pingServer()', PINGER_DELAY);
}

// Call an MTVN Reporting function to track a "link event".  We use this for arbitrary tracking of text strings.
// This function is dependent on reporting_shockwave.js.
function trackGamePlayEvent()
{
    var eventText = gameID + " - GamePlayEvent"
    sendLinkEvent( eventText );
}

//***************************
// get started

pingServer();
