function js_go(ul)
{
    self.location.href = ul;
}

function js_rate(id, stars)
{
    //alert(document.getElementById('starbox').innerHTML);
    document.getElementById('starbox').innerHTML= "......";

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

    xmlhttp.onreadystatechange=function()
    {
    if(xmlhttp.readyState==4)
      {
        xres = xmlhttp.responseText;
        //alert(xres);
        document.getElementById('starbox').innerHTML= xres;
      }
    }
    xmlhttp.open("GET","ajax_rank.php?id=" + id + "&stars=" + stars + "&nocache=" + Math.floor(Math.random() * 99999)  , true);
    xmlhttp.send(null);

}

function js_sort(id)
{
    
    newcat = document.forms['sform'].ssel.value;
    document.getElementById('uns').innerHTML= "......";

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

    xmlhttp.onreadystatechange=function()
    {
    if(xmlhttp.readyState==4)
      {
        xres = xmlhttp.responseText;
        document.getElementById('uns').innerHTML= xres;
      }
    }
    xmlhttp.open("GET","ajax_usort.php?id=" + id + "&cat=" + newcat + "&nocache=" + Math.floor(Math.random() * 99999)  , true);
    xmlhttp.send(null);

}

function js_prob(id)
{
    
    newcat = document.forms['pform'].ssel.value;
    msg = document.forms['pform'].smsg.value;
    document.getElementById('prob').innerHTML= "......";

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

    xmlhttp.onreadystatechange=function()
    {
    if(xmlhttp.readyState==4)
      {
        xres = xmlhttp.responseText;
        document.getElementById('prob').innerHTML= xres;
      }
    }
    xmlhttp.open("GET","ajax_problem.php?id=" + id + "&cat=" + newcat + "&msg=" + msg + "&nocache=" + Math.floor(Math.random() * 99999)  , true);
    xmlhttp.send(null);
}

function js_tag(id)
{
    newtag = document.forms['tform'].tag.value;
    document.getElementById('tdiv').innerHTML= "......";

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

    xmlhttp.onreadystatechange=function()
    {
    if(xmlhttp.readyState==4)
      {
        xres = xmlhttp.responseText;
        document.getElementById('tdiv').innerHTML= xres;
      }
    }
    xmlhttp.open("GET","ajax_addtag.php?id=" + id + "&tag=" + newtag + "&nocache=" + Math.floor(Math.random() * 99999)  , true);
    xmlhttp.send(null);
}

function js_retag(id)
{
    document.getElementById('tdiv').innerHTML="<form style='padding:0px; margin:0px' id='tform' name='tform'><input name='tag'  onkeydown='testForEnter();' id='tag' size=12><input type='button' value='Add Tag!' onclick='js_tag(" + id + ");'></form>";
}

function js_react(id, video_id, parent_id)
{
    // load a form in place of the button    
    document.getElementById('com_' + id).innerHTML= "<form id='cform_" + id + "'><table class='txt'><tr><td>Subject:</td><td><input name='csub' id='csub' size=25></td></tr>" +
    "<tr><td valign='top'>Comment:</td><td><textarea cols=40 rows=5 name='cmsg'></textarea></td></tr><tr><td></td><td><input type='button' onclick='js_doreact(" + id + "," + video_id + "," + parent_id + ");' value='Add comment'></td></tr></table></form>";
}

function js_doreact(id, video_id, parent_id)
{
    csub = document.forms['cform_' + id].csub.value;
    cmsg = document.forms['cform_' + id].cmsg.value;
    document.getElementById('com_' + id).innerHTML="......";
    //alert(csub + cmsg);

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

    xmlhttp.onreadystatechange=function()
    {
    if(xmlhttp.readyState==4)
      {
        xres = xmlhttp.responseText;
        document.getElementById('com_' + id).innerHTML= xres;
      }
    }
    xmlhttp.open("GET","ajax_comment.php?id=" + video_id + "&parent_id=" + parent_id + "&csub=" + csub + "&cmsg=" + cmsg + "&nocache=" + Math.floor(Math.random() * 99999)  , true);
    xmlhttp.send(null);
}

function js_ed(id)
{
    
    newcat = document.forms['edf'].edcat.value;
    newtitle = document.forms['edf'].edtitle.value;
    newtags = document.forms['edf'].edtags.value;
    remove = document.forms['edf'].eddel.checked;
    //alert(newcat + newtitle + newtags + remove)
    document.getElementById('ed').innerHTML= "......";

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

    xmlhttp.onreadystatechange=function()
    {
    if(xmlhttp.readyState==4)
      {
        xres = xmlhttp.responseText;
        document.getElementById('ed').innerHTML= xres;
      }
    }
    xmlhttp.open("GET","ajax_ed.php?id=" + id + "&cat=" + newcat + "&title=" + newtitle + "&tags=" + newtags + "&remove=" + remove + "&nocache=" + Math.floor(Math.random() * 99999)  , true);
    xmlhttp.send(null);

}

function testForEnter() 
{    
	if (event.keyCode == 13) 
	{        
		event.cancelBubble = true;
		event.returnValue = false;
         }
}        
