var xmlHttp;

function addtag(id)
 { 
document.getElementById("bottomarea").innerHTML="<br /><strong>Adding Tag</strong><br /><br /><form action=\"javascript:addtagsave('" + id + "');\">Tags: <input type=\"text\" id=\"tagsform\" name=\"tagsform\" /><input type=\"submit\" name=\"submit\" value=\"Submit\"></form><br />Tags don't appear immediately because they require verification. ";
 }

function addtagsave(id)
 { 
 xmlHttp=GetXmlHttpObject();
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  } 
var tags=document.getElementById("tagsform").value;
 var url="http://www.runetower.com/Runescape-Videos.php?id=" + id + "&tags=" + tags + "&submittags=yes";
document.getElementById("response").innerHTML="Sending...";
 xmlHttp.onreadystatechange=stateChangedaddtag;
 xmlHttp.open("GET",url,true);
 xmlHttp.send(null);
 }

function rateVideo(id,rating)
 { 
 xmlHttp=GetXmlHttpObject();
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  } 
 var url="http://www.runetower.com/Runescape-Videos.php?id=" + id + "&rating=" + rating + "&addrating=yes";
document.getElementById("response").innerHTML="Sending...";
 xmlHttp.onreadystatechange=stateChangedrate;
 xmlHttp.open("GET",url,true);
 xmlHttp.send(null);
 }

function addcomment(id)
 { 
document.getElementById("response").innerHTML="Verifying request...";
nameform=document.getElementById("name_form").value;
comment=document.getElementById("comment_form").value;
if(nameform!="" && comment!="")
{
 xmlHttp=GetXmlHttpObject();
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  } 
 var url="http://www.runetower.com/Runescape-Videos.php?id=" + id + "&name_form=" + nameform + "&comment_form=" + comment + "&addcomment=yes";
document.getElementById("response").innerHTML="Sending...";
 xmlHttp.onreadystatechange=stateChangedaddcomment;
 xmlHttp.open("GET",url,true);
 xmlHttp.send(null);
}
else
{
document.getElementById("response").innerHTML="You forgot to fill in a field.";
	if(nameform=="")
	{
		document.getElementById("nameinfo").innerHTML="Please fill in a name!<br />";
	}
	else
	{
		document.getElementById("nameinfo").innerHTML="";
	}
	if(comment=="")
	{
		document.getElementById("cominfo").innerHTML="Please fill in a comment!<br />";
	}
	else
	{
		document.getElementById("cominfo").innerHTML="";
	}
}
 }

function stateChangedaddtag() 
{ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 	xmlDoc=xmlHttp.responseText;
 	if(xmlDoc=="1E")
 	{
 		document.getElementById("response").innerHTML="Flood control.";
 	}
 	else if(xmlDoc=="2E")
 	{
 		document.getElementById("response").innerHTML="";
 	}
	else
	{
		document.getElementById("response").innerHTML=xmlDoc;
	}
 }
} 

function stateChangedaddcomment() 
{ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 	xmlDoc=xmlHttp.responseText;
 	if(xmlDoc=="1E")
 	{
 		document.getElementById("response").innerHTML="Flood control.";
 	}
 	else if(xmlDoc=="2E")
 	{
 		document.getElementById("response").innerHTML="";
 	}
	else
	{
		document.getElementById("response").innerHTML=xmlDoc;
	}
 }
} 

function stateChangedrate() 
{ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 	xmlDoc=xmlHttp.responseText;
	document.getElementById("rating").innerHTML=xmlDoc;
	document.getElementById("response").innerHTML="";
 }
} 

function GetXmlHttpObject()
 { 
 var objXMLHttp=null;
 if (window.XMLHttpRequest)
  {
  objXMLHttp=new XMLHttpRequest();
  }
 else if (window.ActiveXObject)
  {
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
 return objXMLHttp;
 }