var fl = new Object();
function flashIsReady(object_id)
{
  fl.o = document.getElementsByName(object_id)[0];
  flash_vars._session_id = getCookie('_c1r-2008_ar');
  return flash_vars;
}
fl.call = function(method, id)
{
  if(this.o != null)
  {
    if(this.o[method] != null)
      this.o[method](id);
    else
      alert('This operation is not recognized by the Flash Player');
  }
  else
    alert('The Flash Player is taking longer than usual to load. Please be patient');
}

getFlash = function(nameOfObject)
{
  	var isIE = navigator.appName.indexOf("Microsoft") != -1;
  	return (isIE) ? window[nameOfObject] : document[nameOfObject];
}

resizeFlash = function(width, height)
{
  if(fl.o != null)
  {
    fl.o.width = width;
    fl.o.height = height;
  }
  else
    alert('The Flash Player is taking longer than usual to load. Please be patient');
}
function getCookie(c_name)
{
  if (document.cookie.length>0)
  {
    c_start=document.cookie.indexOf(c_name + "=");
    if (c_start!=-1)
    { 
      c_start=c_start + c_name.length + 1; 
      c_end=document.cookie.indexOf(";", c_start);
      if (c_end==-1) c_end = document.cookie.length;
      return unescape(document.cookie.substring(c_start, c_end));
    } 
  }
  return "";
}
function getURLQuery(q_name)
{
  if (window.location.href.length>0)
  {
    q_start=window.location.href.indexOf(q_name + "=");
    if (q_start!=-1)
    { 
      q_start=q_start + q_name.length + 1; 
      q_end=window.location.href.indexOf("&", q_start);
      if (q_end==-1) q_end = window.location.href.length;
      return unescape(window.location.href.substring(q_start, q_end));
    } 
  }
  return null;
}
function videosPresent()
{
  var videos_present = new Array();
  if(($("view-trailer") != null) || ($('free-movie') != null))
    videos_present.push('trailer');
  if(($$(".purchase-options .watch").length) || ($('free-movie') != null))
    videos_present.push('feature');
  return videos_present;
}
function forceLogin()
{
	$$('#login-popup .inner-container form')[0].insert({top: '<p class="error">Please login to watch this video.</p>'});
	$('top').scrollTo();
	C1R.displayLoginPopup();
}
function buyMinutes()
{
  window.location.href = '/account/buy_minutes?return_to=' + window.location.pathname;
}
