var name = new Array();
	name[0]= "voting_images/star2.gif";
	if(document.images)
	{
		var ss = new Image();
		ss.src = name[0];		
	}			
 
////////////////////////
 function selstar(val)
      {



	for(var x=1;x<=val;x++)
	{
		document['i'+x].src="voting_images/star2.gif";;
	}
	
      }
      function remstar(val)
      {
	for(var x=1;x<=val;x++)
	{
		document['i'+x].src="voting_images/star1.gif";
	}
      }

     
 	function setrate(url,ip,video_id)
      {
 	frm=document.voting;
	for (var i=0; i<frm.vote.length; i++)
   	{

   		if (frm.vote[i].checked)
        	{
      			var val = frm.vote[i].value;
			
      	  	}
        }
	addRating(val,url,ip,video_id);
	
      }


////////////////////////////
function getVoting(str)
{

var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {

  document.getElementById("showContent").innerHTML=xmlhttp.responseText;
  }
}
var url="voting.php?video_id="+str;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}

function getComment(vid)
{

var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
var url="comment.php?video_id="+vid;
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {

  document.getElementById("showContent").innerHTML=xmlhttp.responseText;
  }
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}



function postComment(frm)
{
if(frm.comment.value=="")
{
alert("Please insert any comment");
}
else
{
var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

comment=frm.comment.value;
video_id=frm.video_id.value;
var url="comment_post.php?comment="+comment+"&video_id="+video_id;
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {

  document.getElementById("showContent").innerHTML=xmlhttp.responseText;
  }
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
}

function addRating(ratval,url,ip,video_id)
{

var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {

  document.getElementById("showContent").innerHTML=xmlhttp.responseText;
  }
}
var url="addrating.php?url="+url+"&rating="+ratval+"&ip="+ip+"&video_id="+video_id;

xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}


function checkLogin(frm)
{

if(frm.user_name.value=="")
{
	alert("Enter User Name");
}
else if(frm.password.value=="")
{
	alert("Enter password");
}
else
{
var xmlhttp=GetXmlHttpObject();
 if (xmlhttp==null)
  {
 alert ("Your browser does not support XMLHTTP!");
  return;
 }
var uname=frm.user_name.value;
var password=frm.password.value;
var video_id=frm.video_id.value;
str="?uname="+uname+"&psw="+password+"&video_id="+video_id;
var url="checkLogin.php";

url=url+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=function()
{

if(xmlhttp.readyState==4)
  {

  document.getElementById("showContent").innerHTML=xmlhttp.responseText;
  }
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}


function viewComments(vid)
{

var xmlhttp=GetXmlHttpObject();
 if (xmlhttp==null)
  {
 alert ("Your browser does not support XMLHTTP!");
  return;
 }
str="?video_id="+vid;
var url="view_comments.php";

url=url+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=function()
{

if(xmlhttp.readyState==4)
  {

  document.getElementById("showContent").innerHTML=xmlhttp.responseText;
  }
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}


function getCommentPage(vid,page)
{

var xmlhttp=GetXmlHttpObject();
 if (xmlhttp==null)
  {
 alert ("Your browser does not support XMLHTTP!");
  return;
 }

var url="view_comments.php";
str="?video_id="+vid+"&page="+page;
url=url+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=function()
{

if(xmlhttp.readyState==4)
  {

  document.getElementById("showContent").innerHTML=xmlhttp.responseText;
  }
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
			
}

function bookmarksite(title,url)
{
if (window.sidebar) // firefox
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all)// ie
window.external.AddFavorite(url, title);
}

