function getHTTPObject()
{
	var xmlhttp;
	/*@cc_on
	@if(@_jscript_version >=5)
	try
	{
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E)
		{
			xmlhttp=false;
		}
	}
	@else
		xmlhttp=false;
	@end @*/
	if(!xmlhttp && typeof XMLHttpRequest != 'undefined')
	{
		try
		{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)
		{
			xmlhttp=false;
		}
	}
	return xmlhttp;
}
function handleResponse()
{
	var viddiv=eval(document.getElementById("vidplayer"));
	if(http.readyState == 4)
	{
		// set up video
		//alert(http.responseText);
		viddiv.innerHTML=http.responseText;
	}	
}
function goVideo(uniqueid)
{
	var addiv=eval(document.getElementById("addiv"));
	var url="getembed.php?id=" + uniqueid;
	
	addiv.style.visibility='visible';
	http.open("GET",url, true);
	http.onreadystatechange=handleResponse;
	http.send(null);
}
function handleFavResponse()
{
	var favdiv=eval(document.getElementById("favdiv"));
	if(http.readyState == 4)
	{
		//alert(http.responseText);
		favdiv.innerHTML="<span><strong>Favourite Video</strong></span>";
	}	
}
function goFavourite(vidid,user)
{
	var url="addfav.php?id=" + vidid + "&user=" + user;
	
	http.open("GET",url, true);
	http.onreadystatechange=handleFavResponse;
	http.send(null);
}
function handleSubCatResponse()
{
	var tagdiv=eval(document.getElementById("primtag"));
	if(http.readyState == 4)
	{
		// print subcat options
		//alert(http.responseText);
		tagdiv.innerHTML=http.responseText;
	}	
}
function fillSubCat()
{
	var myindex=eval(document.getElementById("catsel").selectedIndex);
	if(myindex==0) return;
	var chanid=document.uplform.catsel[myindex].value;
	var url="getsubcats.php?channel=" + chanid;
	http.open("GET",url, true);
	http.onreadystatechange=handleSubCatResponse;
	http.send(null);
}
function showCommentForm(vidid,user)
{
	var comdiv=eval(document.getElementById("commentformdiv"));
	
	comdiv.style.visibility='visible';
	var urldata = '<form name="commentform" method="post" action="addcomment.php">';
	urldata += '<textarea cols="40" rows="5" name="comment">';
	urldata += '</textarea>';
	urldata += '<input class="red_button" type="submit" value="Post Comment" />';
	urldata += '<input type="hidden" name="user" value="' + user + '" />';
	urldata += '<input type="hidden" name="postid" value="' + vidid + '" />';
	urldata += '</form>';

	comdiv.innerHTML = urldata;
}
function handleUserCheckResponse()
{
	var userdiv=eval(document.getElementById("checkuserdiv"));
	var respMsg;
	if(http.readyState == 4)
	{
		if(http.responseText == 'OK')
			respMsg = '<span style="color:green;">(User Name Valid)</span>';
		else
		{
			respMsg = '<span style="color:red;">(Username Taken)</span>'; 	
			document.regform.user.value="";
			document.regform.user.focus();
		}
		userdiv.innerHTML= respMsg;
	}
}
function checkUserName()
{
	var enteredname = document.regform.user.value;
	var url="checkuser.php?user=" + enteredname;
	http.open("GET",url, true);
	http.onreadystatechange=handleUserCheckResponse;
	http.send(null);
}
function handleIncResp()
{
}
function doIncrementAndShow(vidid,vidurl)
{
	var url="doincrement.php?vidid=" + vidid;
	http.open("GET",url, true);
	http.onreadystatechange=handleIncResp;
	http.send(null);
	window.open(vidurl,'newwin');
	return false;
}
