
var GAMEAPI_GAME_TYPE_5ON5=0;
var GAMEAPI_GAME_TYPE_1ON1=1;

function GameAPI()
{
	this.gi = window.external.GameInterface ;
	this.gameType = GAMEAPI_GAME_TYPE_5ON5;
	this.userName = "";
	this.isHost=false;
	this.opponentIP = null;
}


GameAPI.prototype.getLanguage = function () 
{
	if(this.gi.GetLanguage() == this.gi.English)
	{
		return "en";
	}
	else if(this.gi.GetLanguage() == this.gi.German)
	{
		return "de";
	}
	else if(this.gi.GetLanguage() == this.gi.French)
	{
		return "fr";
	}
	else if(this.gi.GetLanguage() == this.gi.Spanish)
	{
		return "es";
	}
	else if(this.gi.GetLanguage() == this.gi.Italian)
	{
		return "it";
	}
	else if(this.gi.GetLanguage() == this.gi.Korean)
	{
		return "ko";
	}
}

GameAPI.prototype.getPlayerIP = function ()
{
	var myIp = this.gi.GetMyIp();
	return myIp ;
}

GameAPI.prototype.getMajorVersion = function ()
{
	return 1;
}

GameAPI.prototype.getUserDirectory = function ()
{
	return "c:\\" ;
}

GameAPI.prototype.setAudioCallback = function  ( ChironCallbackObj )
{
	this.gi.SetBrowserCallback(ChironCallbackObj);
}

GameAPI.prototype.setMyPlayerId = function (sValue) 
{
	window.external.GameInterface.SetMyPlayerId(sValue);
}

GameAPI.prototype.setOpponentPlayerId = function (sValue)
{
	this.gi.SetOpponentPlayerId(sValue) ;
}

GameAPI.prototype.setPeerIP = function (sIP)
{
	this.opponentIP=sIP;
}

GameAPI.prototype.setUserName = function ( sName )
{
	this.userName = sName;
	this.gi.SetUserName(this.userName);
}


GameAPI.prototype.setIsGameHost = function (bool)
{
	this.isHost = bool;
}

GameAPI.prototype.setIsProPlay = function (bool)
{
	this.gi.Multiplayer.ProPlay = bool;
}

GameAPI.prototype.play = function ( )
{
	if (this.gameType == GAMEAPI_GAME_TYPE_5ON5)
	{
		this.gi.Multiplayer.SetFiveOnFiveMode();
	}
	else
	{
		this.gi.Multiplayer.SetOneOnOneMode();
	}

	this.gi.SetUserName(this.userName);

	if (this.isHost)
	{
		this.gi.Multiplayer.HostPeerToPeerGame(this.opponentIP);
	}
	else
	{
		this.gi.Multiplayer.JoinPeerToPeerGame(this.opponentIP, 0);
	}
}


GameAPI.prototype.quit = function ()
{
	this.gi.Quit();
}

GameAPI.prototype.setGameType = function ( eType )
{
	this.gameType = eType;
}

GameAPI.prototype.setGameStyle = function ( nEnum )
{
	this.gi.Multiplayer.GameStyle =  nEnum;
}

GameAPI.prototype.setSkillLevel = function ( nEnum )
{
	this.gi.Multiplayer.SkillLevel = nEnum;
}

GameAPI.prototype.setPointsToWin = function ( shortInt )
{
	this.gi.Multiplayer.PointsToWin = shortInt;
}

GameAPI.prototype.setPossessionRule = function ( nEnum )
{
	this.gi.Multiplayer.PossessionRule = nEnum;
}

GameAPI.prototype.setCourt = function ( nEnum )
{
	this.gi.Multiplayer.Court = nEnum;
}

GameAPI.prototype.setCameraView = function ( nEnum )
{
	this.gi.Multiplayer.CameraView = nEnum;
}

GameAPI.prototype.setGameSpeed = function ( shortInt ) 
{
	this.gi.Multiplayer.GameSpeed = shortInt;
}

GameAPI.prototype.setCBFoulFrequency = function ( shortInt ) 
{
	this.gi.Multiplayer.CBFoulFrequency = shortInt;
}

GameAPI.prototype.setShootingFoulFrequency = function ( shortInt ) 
{
	this.gi.Multiplayer.ShootingFoulFrequency = shortInt;
}

GameAPI.prototype.setReachInFoulFrequency = function ( shortInt ) 
{
	this.gi.Multiplayer.ReachInFoulFrequency= shortInt;
}

GameAPI.prototype.setOutOfBounds = function (bool)
{
	this.gi.Multiplayer.OutOfBounds = bool;
}

GameAPI.prototype.setTravelling = function (bool)
{
	this.gi.Multiplayer.Traveling = bool;
}

GameAPI.prototype.setGoaltending = function ( bool )
{
	this.gi.Multiplayer.GoalTending = bool;

}

GameAPI.prototype.setQuarterLength = function (shortInt)
{
	this.gi.Multiplayer.QuarterLength = shortInt;
}

GameAPI.prototype.setInjuryFrequency = function (shortInt) 
{
	this.gi.Multiplayer.InjuryFrequency = shortInt;
}

GameAPI.prototype.setFatigueEffect = function ( shortInt ) 
{
	this.gi.Multiplayer.FatigueEffect = shortInt;
}

GameAPI.prototype.setBackcourtViolation = function ( bool )
{
	this.gi.Multiplayer.BackcourtViolation = bool;
}

GameAPI.prototype.setDef3Seconds = function ( bool )
{
	this.gi.Multiplayer.Def3Seconds = bool;
}

GameAPI.prototype.set3InTheKey = function ( bool )
{
	this.gi.Multiplayer.ThreeInTheKey = bool;
}

GameAPI.prototype.set5SecondInbounding = function ( bool )
{
	this.gi.Multiplayer.FiveSecondInbounding = bool;
}

GameAPI.prototype.set8SecondHalfCourt = function ( bool )
{
	this.gi.Multiplayer.EightSecondHalfCourt = bool;
}

GameAPI.prototype.setFoulOut = function ( shortInt ) 
{
	this.gi.Multiplayer.FoulOut = shortInt;
}

GameAPI.prototype.setEASOGameType = function (nType)
{
	this.gi.Multiplayer.EasoGameType = nType;
}

GameAPI.prototype.getSKU = function () 
{
	return "NA" ;
}

GameAPI.prototype.setOpponentName = function (sName)
{
	this.gi.SetOpponentName(sName);
}

GameAPI.prototype.setLKey = function (sLKey) 
{
	this.gi.SetLKey(sLKey);
}

GameAPI.prototype.setGameKey = function (sGKey) 
{
	this.gi.SetGKey(sGKey);
}
 
