/******************** DayPortPopupPlayer Class ********************/
var DayPortPopupPlayer = new Object();

DayPortPopupPlayer.autoLaunchCheck = function(playerID)
{
  //document.getElementById("debugTA").value += "\nDayPortPopupPlayer.autoLaunchCheck() called.";
  //document.getElementById("debugTA").value += "\n playerID="+playerID;
 
  var artID = DayPortPopupPlayer.getURLVar("artID");
  if (artID == "")
  {
    // There are no articles to automatically play, so just return.
    return;
  }

  var catID = DayPortPopupPlayer.getURLVar("catID");

  playerID = parseInt(playerID, 10);
  if (isNaN(playerID))
  {
    playerID = DayPortPopupPlayer.getURLVar("playerID");
  }
  
  DayPortPopupPlayer.launchPlayer(artID, catID, playerID);
};

DayPortPopupPlayer.domain = "www.versus.com";

DayPortPopupPlayer.getURLVar = function(varName)
{
  //document.getElementById("debugTA").value += "\nDayPortPopupPlayer.getURLVar() called.";
  //document.getElementById("debugTA").value += "\n varName="+varName;

  // Strip off the URL parameters
  var url_params = window.location.search.substr(1);

  var retn = "";
  if (url_params != "")
  {
    var url_param_array = url_params.split("&");
    var url_param_count = url_param_array.length;
    var temp;

    for (var count = 0; count < url_param_count; count++)
    {
      temp = url_param_array[count].split("=");
      if (temp[0] == varName)
      {
        retn = temp[1];
      }
    }
  }

  return retn;
};

DayPortPopupPlayer.launchPlayer = function(articleID, categoryID, playerID)
{
  //document.getElementById("debugTA").value += "\nDayPortPopupPlayer.launchPlayer() called.";
  //document.getElementById("debugTA").value += "\n articleID="+articleID+", categoryID="+categoryID+", playerID="+playerID;

  // Player window settings
  var winURL = "http://" + DayPortPopupPlayer.domain;

  categoryID = parseInt(categoryID, 10);
  if (isNaN(categoryID) || (categoryID == 0))  
  {
    categoryID = "";
  }

  // Pass in a 0 for article or category if the launchPlayer is not for a specific category and article;
  if (articleID == 0)
  {
    articleID = "";
  }
  playerID = parseInt(playerID, 10);
  switch (playerID)
  {
    case 1:
    default:
     {
      // OLN Broadband Player
      winURL += "/videoPlayer/";
      break;
     }
    case 2:
     { 
      // PBR Player
      winURL += "/videoPlayer/";
      break;
     }
  }

  winURL += "?artID=" + articleID + "&catID=" + categoryID;

  // Open the player window
  window.location = winURL;
};

DayPortPopupPlayer.playerWindowPrefix = "OLN";
/******************** End of DayPortPopupPlayer Class ********************/