﻿var hitboxMedia = "";
var hitboxMediaPlayer = "";

function HitBoxDownloadOnComplete(result, response, context) 
{
   hitboxMedia = result[2];
   
   var category = result[0];

   if (hbx.acct.indexOf(";") >= 0)
      category = category + ";" + "/PS" + category;
   else if (hbx.acct.indexOf("/PS/") != 0)
      category = "/PS" + category;

   HitBoxTrackView(result[1], category);
   HitBoxTrackDownload(hitboxMedia);
} 

function HitBoxViewMediaOnComplete(result, response, context) 
{
   hitboxMedia = result[2];

   var category = result[0];

   if (hbx.acct.indexOf(";") >= 0)
      category = category + ";" + "/PS" + category;
   else if (hbx.acct.indexOf("/PS/") != 0)
      category = "/PS" + category;

   HitBoxTrackView(result[1], category);
} 

function HitBoxDownloadOnError(objError)
{
   //confirm(objError.get_message()); 
}

function HitBoxDownload(url)
{
   try {
      if (!noAtlas)
         PageMethods.HitBoxDownload(url, HitBoxDownloadOnComplete, null, HitBoxDownloadOnError, null, null, 2000, 1);
   }
   catch (e) {}
}

function HitBoxViewMedia(url)
{
   try {
      if (!noAtlas)
         PageMethods.HitBoxViewMedia(url, HitBoxViewMediaOnComplete, null, HitBoxDownloadOnError, null, null, 2000, 1);
   }
   catch (e) {}
}

function HitBoxMedia(mode, current, end)
{
   //confirm(mode + " - " + current + " - " + end + " - " + hitboxMedia);
   _hbSet("m.f", hitboxMedia);
   _hbSet("m.cl", hitboxMediaPlayer);
   _hbSet("m.cv", "");
   _hbSet("m.s", mode);
   _hbSet("m.cp", current);
   _hbSet("m.ep", end);
   _hbSend();
}


function HitBoxPlay(current, end)
{
   HitBoxMedia("play", current, end);
}

function HitBoxPause(current, end)
{
   HitBoxMedia("pause", current, end);
}

function HitBoxStop(current, end)
{
   HitBoxMedia("stop", current, end);
}

function HitBoxProgress(current, end)
{
   //HitBoxMedia("playp", current, end);
}

function HitBoxMediaInit(media, player)
{
   hitboxMedia = media;
   hitboxMediaPlayer = player;
}
