

function startTime()
{
	t=setTimeout("loadTopVideos()",5000);
}
function loadTopVideos()
{ 
//while(true)
//{
  t=setTimeout("loadVideoOne()",50);
  t=setTimeout("loadVideoTwo()",100);
   t=setTimeout("loadVideoThree()",150);
  t=setTimeout("loadVideoFour()",200);
  t=setTimeout("loadVideoFive()",250);
  
}
// loadVideo2();
  //loadVideo3();
 //loadVideo4();
 //loadVideo5();
//}

function GetXmlHttpObjectLoadComment()
{
var xmlHttpComment=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpComment=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpComment=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpComment=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpComment;
}

function stateChangedComment() 
{ 
if (xmlHttpComment.readyState==4)
{ 
document.getElementById("comment").innerHTML=xmlHttpComment.responseText;
}
//xmlHttp=null;
}

function loadComment(operation,id,i)
{
	if(operation=="ShowPost")
	{
		document.getElementById("feedback").innerHTML="Post Comment Here";
	}
	else
	{
		document.getElementById("feedback").innerHTML="";
	}
	xmlHttpComment=GetXmlHttpObjectLoadComment();
if (xmlHttpComment==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
 } 
var url="getComment.php";
url=url+"?operation="+operation;
url=url+"&id="+id;
url=url+"&c="+i;
xmlHttpComment.onreadystatechange=stateChangedComment;
xmlHttpComment.open("GET",url,true);
xmlHttpComment.send(null);
}

function hidePost()
{
	xmlHttpComment=GetXmlHttpObjectLoadComment();
if (xmlHttpComment==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
 } 
var url="getComment.php";
url=url+"?operation=HidePost";
url=url+"&id="+id;
url=url+"&c="+i;
xmlHttpComment.onreadystatechange=stateChangedComment;
xmlHttpComment.open("GET",url,true);
xmlHttpComment.send(null);
}

function GetXmlHttpObjectLoadPost()
{
var xmlHttpPost=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpPost=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpPost=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpPost=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpPost;
}

function stateChangedPost() 
{ 
if (xmlHttpPost.readyState==4)
{ 
var reply  = xmlHttpPost.responseText;
document.getElementById("feedback").innerHTML=reply;
	
	
	
	
}
//xmlHttp=null;
}

function loadFooter(id,i)
{
	xmlHttpFooter=GetXmlHttpObjectLoadFooter();
if (xmlHttpFooter==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
 } 
var url="getFooter.php";
url=url+"?id="+id;
url=url+"&c="+i;
xmlHttpFooter.onreadystatechange=stateChangedFooter;
xmlHttpFooter.open("GET",url,true);
xmlHttpFooter.send(null);
}

function initialize(view,id,counter,username)
{
	if(view=="display")
	{
		loadComment('HidePost',id,counter);
		getRating(id,username);
	}
	else if(view=="init")
	{
		//loadVideoOne();
		//loadVideoTwo();
		//loadVideoThree();
		//loadVideoFour();
		//loadVideoFive();
		loadTopVideos()
	}
	else if(view=="")
	{
		//loadVideoOne();
		//loadVideoTwo();
		//loadVideoThree();
		//loadVideoFour();
		//loadVideoFive();
		loadTopVideos()
	}
}

function postComment(id,username)
{
	var comment = document.form1.comment.value;
	if(comment.length==0)
	{
		document.getElementById("feedback").innerHTML="Comment can't be empty!!";
		return;
	}
	xmlHttpPost=GetXmlHttpObjectLoadPost();
	if (xmlHttpPost==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	 } 
	var url="comment_post.php";
	url=url+"?id="+id;
	url=url+"&comment="+comment;
	url=url+"&username="+username;
	xmlHttpPost.onreadystatechange=stateChangedPost;
	xmlHttpPost.open("GET",url,true);
	xmlHttpPost.send(null);
	loadComment('HidePost',id,1);
}
function updateCount()
{
	var comment = document.form1.comment.value;
	var length= comment.length;
	
	if(length==0)
	{
		length=1;
	}
	var rem= 500 - length;
	document.getElementById("character").innerHTML=rem + " characters remaining";

}

function stateChangedRate() 
{ 
if (xmlHttpRate.readyState==4)
{ 
var reply  = xmlHttpRate.responseText;
document.getElementById("rating").innerHTML=reply;
	
	
	
	
}
//xmlHttp=null;
}

function GetXmlHttpObjectLoadRate()
{
var xmlHttpRate=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpRate=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpRate=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpRate=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpRate;
}

function getRating(id,username)
{
	xmlHttpRate=GetXmlHttpObjectLoadRate();
if (xmlHttpRate==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
 } 
var url="getRating.php";
url=url+"?id="+id;
url=url+"&username="+username;
xmlHttpRate.onreadystatechange=stateChangedRate;
xmlHttpRate.open("GET",url,true);
xmlHttpRate.send(null);
}

function rating_description(i)
{
	var desc;
	if(i==1)
	{
		desc='Poor';
	}
	else if(i==2)
	{
		desc='Fair';
	}
	else if(i==3)
	{
		desc='Good';
	}
	else if(i==4)
	{
		desc='Very Good';
	}
	else if(i==5)
	{
		desc='Excellent';
	}
	document.getElementById("rate_desc").innerHTML=desc;
}





function stateChangedPRate() 
{ 
if (xmlHttpPRate.readyState==4)
{ 
var reply  = xmlHttpPRate.responseText;

document.getElementById("rate_desc").innerHTML=reply;
	
	
	
	
}
//xmlHttp=null;
}

function GetXmlHttpObjectLoadPRate()
{
var xmlHttpPRate=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpPRate=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpPRate=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpPRate=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpPRate;
}

function postRating(id,c,username)
{
	xmlHttpPRate=GetXmlHttpObjectLoadPRate();
if (xmlHttpPRate==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
 } 
var url="rating_post.php";
url=url+"?id="+id;
url=url+"&c="+c;
url=url+"&username="+username;
xmlHttpPRate.onreadystatechange=stateChangedPRate;
xmlHttpPRate.open("GET",url,true);
xmlHttpPRate.send(null);
//getRating(id,username);
}


function stateChangedPRate1() 
{ 
if (xmlHttpPRate1.readyState==4)
{ 
var reply  = xmlHttpPRate1.responseText;

document.getElementById("rate_desc").innerHTML=reply + " points";
	
	
	
	
}
//xmlHttp=null;
}

function GetXmlHttpObjectLoadPRate1()
{
var xmlHttpPRate1=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpPRate1=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpPRate1=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpPRate1=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpPRate1;
}

function getInRate(id,username)
{
	
	xmlHttpPRate1=GetXmlHttpObjectLoadPRate1();
if (xmlHttpPRate1==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
 } 
var url="getRatingValue.php";
url=url+"?id="+id;
xmlHttpPRate1.onreadystatechange=stateChangedPRate1;
xmlHttpPRate1.open("GET",url,true);
xmlHttpPRate1.send(null);
getRating(id,username)
}



function loadStatistics(id)
{
	
	xmlHttpStat=GetXmlHttpObjectLoadStat();
if (xmlHttpStat==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
 } 
var url="getStat.php";
url=url+"?id="+id;
xmlHttpStat.onreadystatechange=stateChangedStat;
xmlHttpStat.open("GET",url,true);
xmlHttpStat.send(null);
}

function stateChangedStat() 
{ 
if (xmlHttpStat.readyState==4)
{ 
var reply  = xmlHttpStat.responseText;

document.getElementById("comment").innerHTML=reply;
	
	
	
	
}
//xmlHttp=null;
}

function GetXmlHttpObjectLoadStat()
{
var xmlHttpStat=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpStat=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpStat=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpStat=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpStat;
}



function showEmailForm(id)
{
	
	xmlHttpEmail=GetXmlHttpObjectLoadEmail();
if (xmlHttpEmail==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
 } 
var url="show_email.php";
url=url+"?id="+id;
xmlHttpEmail.onreadystatechange=stateChangedEmail;
xmlHttpEmail.open("GET",url,true);
xmlHttpEmail.send(null);
}

function stateChangedEmail() 
{ 
if (xmlHttpEmail.readyState==4)
{ 
var reply  = xmlHttpEmail.responseText;

document.getElementById("email").innerHTML=reply;
	
	
	
	
}
//xmlHttp=null;
}

function GetXmlHttpObjectLoadEmail()
{
var xmlHttpEmail=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpEmail=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpEmail=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpEmail=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpEmail;
}

function hideEmailForm()
{
	document.getElementById("email").innerHTML="";
}

function sendMail(id)
{
	var emai = document.frmemail.email.value;
	if(emai.length==0)
	{
		document.getElementById("ef").innerHTML="Email can't be empty!!";
		return;
	}
	xmlHttpSend=GetXmlHttpObjectLoadSend();
	if (xmlHttpSend==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	 } 
	var url="send_mail.php";
	url=url+"?email="+emai;
	url=url+"&id="+id;
	xmlHttpSend.onreadystatechange=stateChangedSend;
	xmlHttpSend.open("GET",url,true);
	xmlHttpSend.send(null);
}



function stateChangedSend() 
{ 
if (xmlHttpSend.readyState==4)
{ 
var reply  = xmlHttpSend.responseText;

document.getElementById("email").innerHTML=reply;
	
	
	
	
}
//xmlHttp=null;
}

function GetXmlHttpObjectLoadSend()
{
var xmlHttpSend=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpSend=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpSend=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpSend=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpSend;
}









function loadVideoOne()
{
	
	xmlHttpVideoOne=GetXmlHttpObjectLoadVideoOne();
	if (xmlHttpVideoOne==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	 } 
	var url="getHot1.php";
	xmlHttpVideoOne.onreadystatechange=stateChangedVideoOne;
	xmlHttpVideoOne.open("GET",url,true);
	xmlHttpVideoOne.send(null);
}



function stateChangedVideoOne() 
{ 
if (xmlHttpVideoOne.readyState==4)
{ 
var reply  = xmlHttpVideoOne.responseText;

document.getElementById("top1").innerHTML=reply;
	
	
	
	
}
//xmlHttp=null;
}

function GetXmlHttpObjectLoadVideoOne()
{
var xmlHttpVideoOne=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpVideoOne=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpVideoOne=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpVideoOne=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpVideoOne;
}




function loadVideoTwo()
{
	
	xmlHttpVideoTwo=GetXmlHttpObjectLoadVideoTwo();
	if (xmlHttpVideoTwo==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	 } 
	var url="getHot2.php";
	xmlHttpVideoTwo.onreadystatechange=stateChangedVideoTwo;
	xmlHttpVideoTwo.open("GET",url,true);
	xmlHttpVideoTwo.send(null);
}



function stateChangedVideoTwo() 
{ 
if (xmlHttpVideoTwo.readyState==4)
{ 
var reply  = xmlHttpVideoTwo.responseText;

document.getElementById("top2").innerHTML=reply;
	
	
	
	
}
//xmlHttp=null;
}

function GetXmlHttpObjectLoadVideoTwo()
{
var xmlHttpVideoTwo=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpVideoTwo=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpVideoTwo=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpVideoTwo=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpVideoTwo;
}



function loadVideoThree()
{
	
	xmlHttpVideoThree=GetXmlHttpObjectLoadVideoThree();
	if (xmlHttpVideoThree==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	 } 
	var url="getHot3.php";
	xmlHttpVideoThree.onreadystatechange=stateChangedVideoThree;
	xmlHttpVideoThree.open("GET",url,true);
	xmlHttpVideoThree.send(null);
}



function stateChangedVideoThree() 
{ 
if (xmlHttpVideoThree.readyState==4)
{ 
var reply  = xmlHttpVideoThree.responseText;

document.getElementById("top3").innerHTML=reply;
	
	
	
	
}
//xmlHttp=null;
}

function GetXmlHttpObjectLoadVideoThree()
{
var xmlHttpVideoThree=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpVideoThree=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpVideoThree=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpVideoThree=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpVideoThree;
}



function loadVideoFour()
{
	
	xmlHttpVideoFour=GetXmlHttpObjectLoadVideoFour();
	if (xmlHttpVideoFour==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	 } 
	var url="getHot4.php";
	xmlHttpVideoFour.onreadystatechange=stateChangedVideoFour;
	xmlHttpVideoFour.open("GET",url,true);
	xmlHttpVideoFour.send(null);
}



function stateChangedVideoFour() 
{ 
if (xmlHttpVideoFour.readyState==4)
{ 
var reply  = xmlHttpVideoFour.responseText;

document.getElementById("top4").innerHTML=reply;
	
	
	
	
}
//xmlHttp=null;
}

function GetXmlHttpObjectLoadVideoFour()
{
var xmlHttpVideoFour=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpVideoFour=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpVideoFour=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpVideoFour=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpVideoFour;
}


function loadVideoFive()
{
	
	xmlHttpVideoFive=GetXmlHttpObjectLoadVideoFive();
	if (xmlHttpVideoFive==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	 } 
	var url="getHot5.php";
	xmlHttpVideoFive.onreadystatechange=stateChangedVideoFive;
	xmlHttpVideoFive.open("GET",url,true);
	xmlHttpVideoFive.send(null);
}



function stateChangedVideoFive() 
{ 
if (xmlHttpVideoFive.readyState==4)
{ 
var reply  = xmlHttpVideoFive.responseText;

document.getElementById("top5").innerHTML=reply;
	
	
	
	
}
//xmlHttp=null;
}

function GetXmlHttpObjectLoadVideoFive()
{
var xmlHttpVideoFive=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpVideoFive=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpVideoFive=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpVideoFive=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpVideoFive;
}

