//--------------------------------------------------------------------
// Event Handling for After 20090730 JavaScript Files (PopCapGame Object)
//--------------------------------------------------------------------

//if(Event_Debug){
  Event_Debug = false;
//}

//--------------------------------------------------------------------
// Textarea manupilation
//--------------------------------------------------------------------
function textareaAddLine(id, text)
{
  if(document.getElementById(id)) {
    document.getElementById(id).value += text;
    document.getElementById(id).value += "\n";
  }
}

function textareaClear(id)
{
  if( document.getElementById(id) ) {
    document.getElementById(id).value = '';
  }
}

function textareaAddLog(id , text){
  /*
  var d = new Date();
  var dt = d.toLocaleString();
  var buf = dt + ' ' + text;
  */
  //textareaAddLine(id, buf);
  Logger.log(text);
}

function addEventLog(text){
  if(Event_Debug){
    Logger.log(text);
    //textareaAddLog('zooEventLog', text);
  }
}


//--------------------------------------------------------------------
// Override PopCapGame Object Event Handler
//--------------------------------------------------------------------
thePopCapGame.OnLoadBroadcast = function(params)
{
  addEventLog('OnLoadBroadcast : ' + params);
  //Zoo_receiveNotification('LoaadBroadcast', params);
}

thePopCapGame.OnSessionReady = function(params)
{
  addEventLog('OnSessionReady : ' + params);
  Zoo_receiveNotification('SessionReady', params);
  this.SessionStart();
}

thePopCapGame.OnGameReady = function(params)
{
  addEventLog('OnGameReady : ' + params);
  Zoo_receiveNotification('GameReady', params);
  this.GameStart();
}

thePopCapGame.OnScoreBroadcast = function(params)
{    
  addEventLog('OnScoreBroadcast : ' + params);
  Zoo_receiveNotification('ScoreBroadcast', params);
}

thePopCapGame.OnGameBreak = function(params)
{
  addEventLog('OnGameBreak : ' + params);
  Zoo_receiveNotification('GameBreak', params);
  this.GameContinue();

}

thePopCapGame.OnScoreSubmit = function(params)
{
  addEventLog('OnScoreSubmit : ' + params);
  Zoo_receiveNotification('ScoreSubmit', params);
}

thePopCapGame.OnGameEnd = function(params)
{
  addEventLog('OnGameEnd : ' + params);
  Zoo_receiveNotification('GameEnd', params);
  this.GameMenu();
}

thePopCapGame.OnCustomEvent = function(params)
{
  addEventLog('OnCustomEvent : ' + params);
  Zoo_receiveNotification('CustomEvent', params);
  if (Enable_Upsell) window.open(this.upsellUrl);
    this.CustomReturn(params);
}

//--------------------------------------------------------------------
// Event Log
//--------------------------------------------------------------------
/*
if(Event_Debug){
  document.write('<textarea id="zooEventLog" cols="100" rows="10" style="font-family:monospace; font-size:8pt;">');
  document.write('</textarea>');
  document.write('<input type="button" onClick="textareaClear(\'zooEventLog\')" value=" Clear ">');
  document.write('<br>');
}
*/

