//This is native Java script Library of utility functions not available through GWT

/*
 * Fetches Buy Link for DOM Model mpp_buyLink and returns the URL
 */

function fetchBuyLink() {
	var buyLink = document.getElementById('mpp_buyLink')
	if (buyLink == null || buyLink == undefined)
	{
		return "http://www.mpowerplayer.com";
	}
	return buyLink.href;
}

/*
 * Opens a new Window with specified URL
 */
function openNewWindow(url)
{
	openWindow( url, "_blank" );
}

/*
 * Opens a Window with specified URL for the given target.
 */
function openWindow(url, target)
{
	window.open(url,target,"");
}

/*
 * Resets the Widget
 */
function resetWidget()
{
	resetAppOnGameOver();
}

function reloadPageWithStartApp()
{
    //parent.location.reload();
    var currentHREF = parent.location.href;
    var lowerHREF = currentHREF.toLowerCase();
    if ( lowerHREF.indexOf( "startapp" ) < 0 )
    {
    	if ( currentHREF.indexOf( "?" ) < 0 )
    	{
    		currentHREF = currentHREF + "?startApp=true";
    	}
    	else
    	{
    		currentHREF = currentHREF + "&startApp=true";
    	}
    }

	parent.location.href = currentHREF;
}

/*
 * Resets the Widget
 */
function showAppletPlayer()
{
	showAppletDiv();
}

function recommendFriends()
{
    recommendToFriends();
}

function shareSelected()
{
	shareSelectedGame();
}

function becomeFan()
{
	becomeAFan();
}

function selectGame( gameID )
{
	selectNewGame( gameID );
}

function openBuyPage()
{
	openBuyLink();
}

function loginEnsured( uid )
{
	facebookLoginEnsured( uid );
}

function fetchedUserInfo( result )
{
	fetchedFacebookUserInfo( result );
}

function switchMode( mode )
{
	switchToRequestedMode( mode );
}
