var isMinNS4 = (document.layers) ? 1 : 0;
var isMinIE4 = (document.all)    ? 1 : 0;


//var video_no;
function rating(popt)
{
	
  if (isMinNS4) 
  {
	bt="ns";
  }
  else if (isMinIE4) 
  {
	bt="ie";
  }
  else
  {
	bt="ot";
  }

	document.getElementById("div1").innerHTML = "";
/*	box1="<table width=\"165\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" ><tr><td height=11 width=11><img src=../images/ltop.gif></td><td bgcolor=\"#944212\" ></td><td height=11 width=11><img src=../images/rtop.gif></td></tr><tr><td bgcolor=\"#944212\"></td><td bgcolor=\"#944212\">";
	box2="</td><td bgcolor=\"#944212\">&nbsp;</td></tr><tr><td height=11 width=11><img src=../images/lbottom.gif></td><td bgcolor=\"#944212\"></td><td height=11 width=11><img src=../images/rbottom.gif></td></tr></table>";
	box11="<table width=\"165\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" ><tr><td height=11 width=11><img src=../images/ltop.gif></td><td bgcolor=\"#944212\" ></td><td height=11 width=11><img src=../images/rtop.gif></td></tr><tr><td bgcolor=\"#944212\"></td><td bgcolor=\"#944212\" align=\"right\">";
	box12="</td><td bgcolor=\"#944212\">&nbsp;</td></tr><tr><td height=11 width=11><img src=../images/lbottom.gif></td><td bgcolor=\"#944212\"></td><td height=11 width=11><img src=../images/rbottom.gif></td></tr></table>";
*/
	box1="<table width=\"200\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFFF\"><tr><td>";
	box2="</td></tr></table>";
	if(popt=="1")
	{//alert("hi");
		
		if(bt=="ie")
		{
			document.getElementById("div1").style.top =571; 
			document.getElementById("div1").style.left =603;  
		}
		else
		{
			document.getElementById("div1").style.top =571+"px"; 
			document.getElementById("div1").style.left =601+"px";  
		}
		vid_value=" Poor ";
		document.getElementById("div1").innerHTML = box1+vid_value+box2;
	}
	else if(popt=="2")
	{
		if(bt=="ie")
		{
			document.getElementById("div1").style.top =571;  
			document.getElementById("div1").style.left =603;  
		}
		else
		{
			document.getElementById("div1").style.top =571+"px";  
			document.getElementById("div1").style.left =601+"px";  
		}
		vid_value="Nothing Special";
		document.getElementById("div1").innerHTML = box1+vid_value+box2;
	}
	else if(popt=="3")
	{
		if(bt=="ie")
		{
			document.getElementById("div1").style.top =571;  
			document.getElementById("div1").style.left =603; 
		}
		else
		{
			document.getElementById("div1").style.top =571+"px";  
			document.getElementById("div1").style.left =601+"px"; 
		}
		vid_value="Worth Watching";
		
		document.getElementById("div1").innerHTML = box1+vid_value+box2;
	}
	else if(popt=="4")
	{
		if(bt=="ie")
		{
			document.getElementById("div1").style.top =571;  
			document.getElementById("div1").style.left =603;  
		}
		else
		{
			document.getElementById("div1").style.top =571+"px";  
			document.getElementById("div1").style.left = 601+"px";  
		}
		vid_value="Pretty Cool";
		
		document.getElementById("div1").innerHTML = box1+vid_value+box2;
	}
	else if(popt=="5")
	{
		if(bt=="ie")
		{
			document.getElementById("div1").style.top =571;  
			document.getElementById("div1").style.left =603; 
		}
		else
		{
			document.getElementById("div1").style.top =571+"px";  
			document.getElementById("div1").style.left =601+"px"; 
		}
		vid_value="Awesome !";
		
		
		document.getElementById("div1").innerHTML = box1+vid_value+box2;
	}
	
}	

function outdiv()
{
		document.getElementById("div1").innerHTML = "";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function handleHttpResponse2_1_4() {
 if (http.readyState == 4) {
    results = http.responseText;
	 results = http.responseText.split("*");
 	//alert(results[0]);
	//alert(results[0]);
	if(results[0]==0)
	{
		alert("your comment not posted");
		//document.getElementById('but').style.visibility="hidden";
	}
	else if(results[0]==2)
	{
		document.location=results[1]+"/login.php";
	}
	else if(results[0]==3)
	{
		alert("you can't add comment b'coz this is your video");
		document.getElementById('text1').value="";
	}
	else if(results[0]==4)
	{
		alert("You must enter comment!");
		document.getElementById('text1').value="";
	}
	else if(results[0]==5)
	{
		alert("You have no permission to add a comments for this video.");
		document.getElementById('text1').value="";
	}
	else
	{
		
		//document.getElementById("view_comment").innerHTML = results[0];
		/**/
		
		view_profile_comment.innerHTML = "";
		view_profile_comment.innerHTML = results[0];
		/*
		document.getElementById('view_comment').innerHTML=results[0];
		*/
		document.getElementById('but').style.visibility="hidden";
		hidecomment();
		document.form1.text1.value="";
	}
	/**/
  }
}
function handleHttpResponse3() {
 if (http.readyState == 4) {
    results = http.responseText;
	 results = http.responseText.split("*");
 	
	if(results[0]==0)
	{
		alert("your comment not posted");
		//document.getElementById('but').style.visibility="hidden";
	}
	else if(results[0]==2)
	{
		document.location=results[1]+"/login.php";
	}
	else if(results[0]==3)
	{
		alert("you can't add comment b'coz this is your Photo");
		document.getElementById('text1').value="";
	}
	else if(results[0]==4)
	{
		alert("You must enter comment!");
		document.getElementById('text1').value="";
	}
	else if(results[0]==5)
	{
		alert("You have no permission to add a comments for this Photo.");
		document.getElementById('text1').value="";
	}
	else
	{
		view_user_comment.innerHTML = "";
		view_user_comment.innerHTML = results[0];
		
		document.getElementById('but').style.visibility="hidden";
		hidecomment();
		document.form1.text1.value="";
		
	}
  }
}

function insertcom_user(uid,cip,postedby)
{
	/*alert(uid);
	alert(cip);
	alert(postedby);
	alert(document.getElementById('text1').value);
	alert(document.getElementById('title').value);
	alert(document.getElementById('pid').value);
	*/
	//http.open("GET", "user_insert_comment.php?user=" + escape(postedby)+"&ownerid="+escape(uid)+"&cip="+escape(cip)+"&descr="+escape(document.getElementById('text1').value)+"&title="+escape(document.getElementById('title').value)+"&pid="+escape(document.getElementById('pid').value), true);
	
	var url = "user_insert_comment.php";
	var params = "user=" + escape(postedby)+"&ownerid="+escape(uid)+"&cip="+escape(cip)+"&descr="+escape(document.getElementById('text1').value)+"&title="+escape(document.getElementById('title').value)+"&pid="+escape(document.getElementById('pid').value);
	http.open("POST", url, true);
	
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");


	
	/*
	http.open("GET", "user_insert_comment.php?, true);	 
	*/
	http.onreadystatechange = handleHttpResponse2_1_4;
	http.send(params); 
	 
}
function insertcom_user1(uid,cip,postedby)
{
	/*alert(uid);
	alert(cip);
	alert(postedby);
	alert(document.getElementById('text1').value);
	alert(document.getElementById('title').value);
	alert(document.getElementById('pid').value);
	*/
	//http.open("GET", "user_insert_comment.php?user=" + escape(postedby)+"&ownerid="+escape(uid)+"&cip="+escape(cip)+"&descr="+escape(document.getElementById('text1').value)+"&title="+escape(document.getElementById('title').value)+"&pid="+escape(document.getElementById('pid').value), true);
	
	var url = "user_insert_comment1.php";
	var params = "user=" + escape(postedby)+"&ownerid="+escape(uid)+"&cip="+escape(cip)+"&descr="+escape(document.getElementById('text1').value)+"&title="+escape(document.getElementById('title1').value)+"&pid="+escape(document.getElementById('pid').value);
	http.open("POST", url, true);
	
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");


	
	/*
	http.open("GET", "user_insert_comment.php?, true);	 
	*/
	http.onreadystatechange = handleHttpResponse2_1_4;
	http.send(params); 
	 
}
function insertcom_photo(pid,cip,postedby)
{
	
	http.open("GET", "insert_comment_photo.php?user=" + escape(postedby)+"&vid="+escape(pid)+"&cip="+escape(cip)+"&descr="+escape(document.getElementById('text1').value)+"&title="+escape(document.getElementById('title').value)+"&pid="+escape(document.getElementById('pid').value), true);
	 http.onreadystatechange = handleHttpResponse3;
	 http.send(null);
}
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;
}
var http = getHTTPObject(); // We create the HTTP Object
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ThreadedCommentHandler(comment_form)
{
        var comment = comment_form.comment;
        var comment_button = comment_form.comment_button;

        if (comment.value.length == 0 || comment.value == null)
        {
                alert("You must enter a comment!");
                comment.focus();
                return false;
        }

        if (comment.value.length > 500)
        {
                alert("Your comment must be shorter than 500 characters!");
                comment.focus();
                return false;
        }

		postForm(comment_form.name, true, commentResponse);
        return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
function handleHttpResponse1() {
  if (http.readyState == 4) {
    results = http.responseText;
	 //results = http.responseText.split("$");
	// alert(results);
		alert("This is all comments");
		document.getElementById('id1').innerHTML="";
		document.getElementById('id1').innerHTML=results;
  }
}
function load_all_comments_old(video_id)
{
	//alert("allcoments.php?v=" + video_id);
	//alert(video_id);
	 http.open("GET", "all_comments.php?v=" + video_id, true);
	 http.onreadystatechange = handleHttpResponse1;
	 http.send(null);
}
function load_all_comments_old_photo(video_id)
{
	//alert("allcoments.php?v=" + video_id);
	 //alert(video_id);
	 http.open("GET", "all_comments_photo.php?v=" + video_id, true);
	 http.onreadystatechange = handleHttpResponse1;
	 http.send(null);
}

