var xmlHttpComment

function loadcomment(content_id,comment_type_id,adr_page,bid,server_adr)
{ 
xmlHttpComment=GetXmlHttpObjectComment()
if (xmlHttpComment==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url= server_adr+"include/comment.php"
url=url+"?content_id="+content_id
url=url+"&comment_type_id="+comment_type_id
url=url+"&adr_page="+adr_page
url=url+"&bid="+bid
url=url+"&sid="+Math.random()
xmlHttpComment.onreadystatechange=stateChangedComment
xmlHttpComment.open("GET",url,true)
xmlHttpComment.send(null)
}

function stateChangedComment() 
{ 
 if (xmlHttpComment.readyState==4 || xmlHttpComment.readyState=="complete")
 { 
 	document.getElementById("comments").innerHTML=xmlHttpComment.responseText;
 }
 else
 {
	document.getElementById("comments").innerHTML="<table border='0' width='100%' height='100%'><tr><td style='vertical-align:middle;text-align:center;'><img src='http://www.riikriey.com/blog/include/ajax/ajax-loader.gif'><br>Loading...</td></tr></table>";
 }
}

function GetXmlHttpObjectComment()
{
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 add comment
// -----------------------

function addcomment(i,main_comment_id,text,keycode,sessioncodename){
	//alert(i+"-"+main_comment_id+"-"+text+"-"+keycode+"-"+sessioncodename)
	if (main_comment_id=="0"){
		
		if (document.getElementById('txtPostComment').value!=""){
			document.getElementById('setValue').value = text;
			document.getElementById('CommType').value = "0"
			document.getElementById('SecureCode').value = keycode
			document.getElementById('SessionCodeName').value = sessioncodename
//			if (document.getElementById('txtCommentBy').value!=""){
//				document.getElementById('CommBy').value = document.getElementById('txtCommentBy').value
//			}
			
			//alert(i+"-"+main_comment_id+"-"+text+"-"+keycode+"-"+sessioncodename)
			
			document.frmmainpost.method ="post";
			document.frmmainpost.submit();
		}else
		{
			alert("Please type your comment!");
			//return false
		}
	} else {
		if (document.getElementById('txtPostComment' + i).value!="") {
			document.getElementById('setValue').value = text;
			document.getElementById('CommType').value = main_comment_id
			document.getElementById('SecureCode').value = keycode
			document.getElementById('SessionCodeName').value = sessioncodename
			//document.getElementById('CommBy').value = document.getElementById('txtCommentBy'+i).value
			document.frmmainpost.method ="post";
			document.frmmainpost.submit();
		}else
		{
			alert("Please type your comment!");
			//return false
		}
	}
	
}

function deleteComment(commentID) {
	if (confirm("Do you want to delete comment?")){
		document.getElementById('deleteID').value =commentID
		document.getElementById('CommType').value = "delete"
		document.frmmainpost.method ="post";;
		document.frmmainpost.submit();
	}
}

// -----------------------
// function show sub category
// -----------------------

var xmlHttpSubCategory

function loadSubCategory(cat_id,selvalue,adr)
{ 

xmlHttpSubCategory=GetXmlHttpObjectSubCategory()
if (xmlHttpSubCategory==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url=adr+"include/sub_category.php"
url=url+"?cat_id="+cat_id
url=url+"&selvalue="+selvalue
url=url+"&sid="+Math.random()

xmlHttpSubCategory.onreadystatechange=stateChangedSubCategory
xmlHttpSubCategory.open("GET",url,true)
xmlHttpSubCategory.send(null)
}

function stateChangedSubCategory() 
{ 
 if (xmlHttpSubCategory.readyState==4 || xmlHttpSubCategory.readyState=="complete")
 { 
 	document.getElementById("SubCategorys").innerHTML=xmlHttpSubCategory.responseText;
 }
 else
 {
	document.getElementById("SubCategorys").innerHTML="<table border='0' width='100%' height='100%'><tr><td style='vertical-align:middle;text-align:center;'><img src='http://www.riikriey.com/blog/include/ajax/ajax-loader.gif'></td></tr></table>";
 }
}

function GetXmlHttpObjectSubCategory()
{
var xmlHttpSubCategory=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttpSubCategory=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttpSubCategory=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttpSubCategory=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttpSubCategory;
}
