// expand more info block
function watch_moreInfo(){
  document.getElementById('moreinfo').innerHTML='[ <a href="#" onclick="watch_lessInfo(); return false;">less info</a> ]';
  document.getElementById('lessinfo').style.display="none";
  document.getElementById('fullinfo').style.display="block";
}
function watch_lessInfo(){
  document.getElementById('moreinfo').innerHTML='[ <a href="#" onclick="watch_moreInfo(); return false;">more info</a> ]';
  document.getElementById('fullinfo').style.display="none";
  document.getElementById('lessinfo').style.display="block";
}

function watch_hideAdultWarn(){
  document.getElementById('adlt-warn').style.display="none";
  return false;
}

function watchShowRateStars(){
  document.getElementById('rate-stars-over').style.display="block";
}
function watchHideRateStars(){
  document.getElementById('rate-stars-over').style.display="none";
  $("#stars-cap").text("");
}

function watchReportContent(video){
  if (video=='') return;
  $.post("/ls_post/report.php", "act=rep&thr="+video,
  function(data){
  }, "script");
}
function watchReportContentOk(video){  
  if (video=='') return;
  var rtype=escape(document.getElementById('rep-type').value);
  var rtext=escape(document.getElementById('rep-text').value);
  var remail=escape($('#remail').val());
  //alert(rtype);
  if ($('#rep-type').val()!="Wrong Category" && $('#rep-type').val()!="Bug Report" && $('#remail').val()==""){
    alert("Error: Please enter your email address so we could contact you back.");
    return;
  }
  $.post("/ls_post/report.php", "act=rep&subact=ok&thr="+video+"&rtype="+rtype+"&rtext="+rtext+"&remail="+remail,
  function(data){
  }, "script");
}

function watchSendComment(video){  
  if (video=='') return;
  var ctext=document.getElementById('comsg').value;
  if (ctext=='') {
    alert("Comment text can not be empty");
    return;
  }
  $.post("/ls_post/comment.php", "thr="+video+"&ctext="+ctext,
  function(data){
  }, "script");
}





var preroll=0;
function playerReady(obj) {
    if (obj['id']=='player_go') {
      player = document.getElementById(obj['id']);
      if ($("#aidpl").val()>=0){
        player.sendEvent('LOAD', '/'+ $("#vidnamez").val() +'.flv');
        if ($("#anamepreroll").val()!="") player.addViewListener('PLAY','firePreRoll');
      }
   }
    if (obj['id']=='playera') {
      player2 = document.getElementById(obj['id']);
    }
};

function amovieCompleted(a) {
  if (a.newstate=='COMPLETED'){
    $.post("/ls_post/a-manage.php", "act=exp&a="+$("#aidpl").val(),
    function(data){ }, "script");
    $("#adblock").css('height','1px');
    $("#adblock").css('width','1px');
    $("#vidcont").css('height','340px');
    $("#vidcont").css('width','560px');
    $("#urlblock").hide();
    player.sendEvent('LOAD', '/'+ $("#vidnamez").val() +'.flv');
    player.sendEvent('PLAY', 'true');
    player.removeModelListener('STATE', 'amovieCompleted');
  }
}

function firePreRoll() {
  if (preroll==0) {
    preroll=1;
    $("#adblock").css('height','340px');
    $("#adblock").css('width','560px');
    $("#vidcont").css('height','1px');
    $("#vidcont").css('width','1px');
    player.sendEvent('PLAY', 'true');
    
    if ($("#aurlpl").val()!="0"){
      $("#urlblock").show();
      $("#aurl").attr("href", $("#aurlpl").val());
      $("#aurl").attr("onclick", "checkClickState("+$("#aidpl").val()+")");
    }

    player2.removeViewListener('PLAY','firePreRoll');   
    player2.sendEvent('LOAD', '/ls_content/ar/'+ $("#anamepreroll").val());
    player2.sendEvent('PLAY', 'true');
    player2.addModelListener('STATE', 'amovieCompleted');
  }
  preroll=1;
}

function checkClickState(aid){
  $.post("/ls_post/a-manage.php", "act=clc&a="+aid,
  function(data){ }, "script");
}