// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function getXmlHttp(){
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}

function rateAjax(movieId,rate)
{
  var xmlhttp = getXmlHttp();
  xmlhttp.open('GET', '/aj_ratevideo_na.php?flv_id='+movieId+'&rate='+rate, true);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4) {
       if(xmlhttp.status == 200) {
              if(xmlhttp.responseText != '')
              {
                Rated = 1;  
		var data = xmlhttp.responseText;
		document.getElementById('rateText').innerHTML = data;
              }
              else
	      {
		document.getElementById('rateText').innerHTML = '<font color=red>Error while rating.</font>';
	      }
         }
    }
  };
  xmlhttp.send(null);
}

function commentsAjax(movieId,isShow)
{
  var xmlhttp = getXmlHttp();
  xmlhttp.open('GET', '/aj_showcommnets.php?flv_id='+movieId+'&show='+isShow, true);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4) {
       if(xmlhttp.status == 200) {
              if(xmlhttp.responseText != '')
              {
                inProgress = 0;;  
		var data = xmlhttp.responseText;
		document.getElementById('commentsText').innerHTML = data;
              }
              else
	      {
//		document.getElementById('rateText').innerHTML = '<font color=red>Error while rating.</font>';
	      }
         }
    }
  };
  xmlhttp.send(null);
}
var showHideRepForm = 0;
function reportForm(movieId,memId)
{
  showHideRepForm = 1 - showHideRepForm;
  var xmlhttp = getXmlHttp();
  xmlhttp.open('GET', '/aj_showrep_form.php?flv_id='+movieId+'&show='+showHideRepForm+'&member_id='+memId, true);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4) {
       if(xmlhttp.status == 200) {
              if(xmlhttp.responseText != '')
              {
                inProgress = 0;;  
		var data = xmlhttp.responseText;
		document.getElementById('reporttext').innerHTML = data;
              }
              else
	      {
//		document.getElementById('rateText').innerHTML = '<font color=red>Error while rating.</font>';
	      }
         }
    }
  };
  xmlhttp.send(null);
}

function sendReport(movieId,memId,problem_id)
{
  showHideRepForm = 0;
  var xmlhttp = getXmlHttp();
  xmlhttp.open('GET', '/aj_showrep_form.php?flv_id='+movieId+'&show='+showHideRepForm+'&member_id='+memId+'&repid='+problem_id, true);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4) {
       if(xmlhttp.status == 200) {
              if(xmlhttp.responseText != '')
              {
                inProgress = 0;;  
		var data = xmlhttp.responseText;
		document.getElementById('reporttext').innerHTML = data;
              }
              else
	      {
//		document.getElementById('rateText').innerHTML = '<font color=red>Error while rating.</font>';
	      }
         }
    }
  };
  xmlhttp.send(null);
}

