var StagingFolder;
var ProdID;
var PgTitle;
var BVisLoaded = false;
var ReviewsCount;
var AverageRating;
var RatingsOnlyCount;
var BuyAgainPercent;
var ThrowTag = false;

document.domain = "levenger.com"

function ratingsDisplayed(totalReviewsCount, avgRating, ratingsOnlyReviewCount, buyAgainPercentage)
{
  var obj = document.getElementById("hideBV")
  if (obj)
  {
    if (totalReviewsCount <= 0)
    {
      obj.innerHTML = "Be the first to <a href='http://reviews.levenger.com/" + 
                       StagingFolder + "2450/" + ProdID +
                       "/submission.htm?bvpage=reviews.htm&action=AddReview&format=embedded&user=__ALLOWANONYMOUS__&return=" +
                       escape(document.getElementById("BVReturnURL").innerHTML) +
                       "&loginparams=__BVLOGINPARAMETERS__&submissionparams=__BVSUBMISSIONPARAMETERS__" +
                       "&submissionurl=" + escape(document.getElementById("BVContainerPageURL").innerHTML) +
                       "'>write a review</a>. Your feedback aids other customers who are considering purchasing these products, and helps us improve future designs. Your opinion matters to us.<BR><BR>Thank you.<BR>";
    }
    obj.style.display = "block";
  }

  ReviewsCount = totalReviewsCount;
  AverageRating = avgRating;
  RatingsOnlyCount = ratingsOnlyReviewCount;
  BuyAgainPercent = buyAgainPercentage;
  ThrowTag = true;
} //ratingsDisplayed

function CheckSubmissionLoadState()
{
  if (BVisLoaded)
  {
    document.title = PgTitle;
  }
  else
  {
    //the content was not pushed, show a friendly message
    document.getElementById('BVSubmissionFrame').src="";
    document.getElementById('BVSubmissionContainer').innerHTML = 'Reviews are currently unavailable, please try again';
  }
  
  ThrowTag = true;
} //CheckSubmissionLoadState
                
function CheckLoadState(BazaarVoiceStagingFolder)
{
  if(!BVisLoaded)
  {
    var page = document.getElementById('BVFrame').src;
    document.getElementById('BVFrame').src='http://reviews.levenger.com/' + BazaarVoiceStagingFolder + 'logging?page=' + escape(page);
    document.getElementById('BVReviewsContainer').innerHTML = 'Reviews are currently unavailable, please try again';
  }

  ThrowTag = true;
}

function pageChanged(pageName, pageStatus)
{
  cmCreatePageviewTag(pageName, 'ReviewSubmissionProcess');
}