var httpObj = false;



		try {



			  httpObj = new XMLHttpRequest();



		} catch (trymicrosoft) {



		  try {



				httpObj = new ActiveXObject("Msxml2.XMLHTTP");



		  } catch (othermicrosoft) {



			try {



			  httpObj = new ActiveXObject("Microsoft.XMLHTTP");



			} catch (failed) {



			  httpObj = false;



			}



	  }



	}







	function SendExistRequest(Url,FieldName,Title){



		var SendUrl = Url+"&r="+Math.random(); 



		httpObj.open("GET", SendUrl, true);



		httpObj.onreadystatechange = function RecieveExistRequest(){



			if (httpObj.readyState == 4) {



				if(httpObj.responseText==1) {



					alert(Title+" already exists in database. Please enter another !");



					document.getElementById(FieldName).select();



					return false;



				} else if(httpObj.responseText==0) {	 



					document.forms[0].submit();



				}else {



					alert("Error : " + httpObj.responseText);



					return false;



				}



			}



		};



		httpObj.send(null);



	}







	function SendAbuseExistRequest(Url,FieldName,Title,FieldName2,Title2){



		var SendUrl = Url+"&r="+Math.random(); 



		httpObj.open("GET", SendUrl, true);



		httpObj.onreadystatechange = function AbuseExistRequest(){



			if (httpObj.readyState == 4) {



				//alert(httpObj.responseText);



				if(httpObj.responseText==1) {



					alert(Title+" already exists in database. Please enter another !");



					document.getElementById(FieldName).select();



					return false;



				}else if(httpObj.responseText==2) {



					alert(Title+" has abuse words in it. Please remove them !");



					document.getElementById(FieldName).select();



					return false;



				}else if(httpObj.responseText==3) {



					alert(Title2+" has abuse words in it. Please remove them !");



					document.getElementById(FieldName2).select();



					return false;



				}else if(httpObj.responseText==0) {	 



					document.forms[0].submit();



				}else {



					alert("Error : " + httpObj.responseText);



					return false;



				}



			}



		};



		httpObj.send(null);



	}







///////////----------- Forum Section--------------- ////////////



///////////--------------------------------------- ////////////















	function LoadForum(reset){



		Loading("ForumDiv");







		if(reset==1){



			document.getElementById("CurrentAction").value = 'view';



			document.getElementById("CommentID").value = 0;



		}











		if(document.getElementById("CurrentAction").value == 'post'){



			PostComment(document.getElementById("CommentID").value);



		}else if(document.getElementById("CurrentAction").value == 'reply'){



			ReplyComment(document.getElementById("CommentID").value);



		}else{



			var SendUrl = "forum.php?action=view&MemberID="+document.getElementById("ForumMemberID").value+"&ProductID="+document.getElementById("ForumProductID").value+"&r="+Math.random(); 



			httpObj.open("GET", SendUrl, true);



			httpObj.onreadystatechange = function RecieveForumRequest(){



				if (httpObj.readyState == 4) {



					if(httpObj.responseText != '') {



						document.getElementById("ForumDiv").innerHTML = httpObj.responseText;



					}else {



						alert("Error Occur : " + httpObj.responseText);



					}



				}



			};



			httpObj.send(null);







		}



	}







	function Loading(p_Div){



		document.getElementById(p_Div).innerHTML = '<Div  class="red-txt" align="center"><br><br><img src="images/loading.gif" /> Loading .....</Div>';







	}











	///////////----------- Post Comment Section--------------- ////////////



	function PostComment(CommentID){



		if(document.getElementById("ForumMemberID").value > 0){



			Loading("ForumDiv");



			var SendUrl = "forum.php?action=post&CommentID="+CommentID+"&MemberID="+document.getElementById("ForumMemberID").value+"&ProductID="+document.getElementById("ForumProductID").value+"&r="+Math.random(); 



			



			document.getElementById("CommentType").value = 'new';



			



			httpObj.open("GET", SendUrl, true);



			httpObj.onreadystatechange = function RecieveForumRequest(){



				if (httpObj.readyState == 4) { 



						



					if(httpObj.responseText != '') {



						document.getElementById("ForumDiv").innerHTML = httpObj.responseText;



					}else {



						alert("Error Occur : " + httpObj.responseText);



					}



				}



			};



			httpObj.send(null);



		}else{	



			alert('You are not logged in. Redirecting to login area.....');



			location.href = "myAccount.php?cont=products.php?id="+document.getElementById("ForumProductID").value+',action=post,CommentID='+CommentID;



		}



	}	







	///////////----------- Validate Comment --------------- ////////////



	function validateForm(frm){



		if( ValidateForBlank(frm.Comment, "Topic")



			&& ValidateMandRange(frm.Comment, "Topic", 5, 100)



			&& ValidateForTextarea(frm.CommentDetail, "Topic Detail", 10, 800)



		){







			if(CheckAbuseCharacters(frm.Comment, "Topic")){



				return false;



			}







			var SendUrl = "forum.php?action=validate&edit="+document.getElementById("edit").value+"&Comment="+escape(document.getElementById("Comment").value)+"&CommentType="+escape(document.getElementById("CommentType").value)+"&CommentDetail="+escape(document.getElementById("CommentDetail").value)+"&MemberID="+document.getElementById("ForumMemberID").value+"&PostedByID="+document.getElementById("PostedByID").value+"&ProductID="+document.getElementById("ForumProductID").value+"&r="+Math.random(); 



			



			httpObj.open("GET", SendUrl, true);



			httpObj.onreadystatechange = function ForumRequestRcv(){



				if (httpObj.readyState == 4) {



					if(httpObj.responseText==1) {



						alert("Topic already exists in database for this product. Please enter another topic.");



						document.getElementById("Comment").select();



						return false;



					}else if(httpObj.responseText==2) {



						alert("Topic has abuse words in it. Please remove them !");



						document.getElementById("Comment").select();



						return false;



					}else if(httpObj.responseText==3) {



						alert("Topic Detail has abuse words in it. Please remove them !");



						document.getElementById("CommentDetail").select();



						return false;



					}else {



						SubmitComment();



						return false;



					}







					return false;







				}



			};



			httpObj.send(null);







			return false;



		}else{



			return false;	



		}



	}











	///////////----------- Submit after Validation --------------- ////////////







	function SubmitComment(){







		var SendUrl = "forum.php?action=submit&edit="+document.getElementById("edit").value+"&Comment="+escape(document.getElementById("Comment").value)+"&CommentType="+escape(document.getElementById("CommentType").value)+"&CommentDetail="+escape(document.getElementById("CommentDetail").value)+"&PostedByID="+document.getElementById("PostedByID").value+"&MemberID="+document.getElementById("ForumMemberID").value+"&ProductID="+document.getElementById("ForumProductID").value+"&r="+Math.random(); 



		httpObj.open("GET", SendUrl, true);



		httpObj.onreadystatechange = function SubmitForumRequest(){



			if (httpObj.readyState == 4) {



				if(httpObj.responseText != '') {



					document.getElementById("ForumDiv").innerHTML = httpObj.responseText;



				}else {



					alert("Error Occur : " + httpObj.responseText);



				}



				return false;



			}



		};



		httpObj.send(null);







	}







	



	///////////----------- View single comment --------------- ////////////







	 function ViewComment(CommentID){



		var SendUrl = "forum.php?action=view&CommentID="+CommentID+"&MemberID="+document.getElementById("ForumMemberID").value+"&ProductID="+document.getElementById("ForumProductID").value+"&r="+Math.random(); 



		Loading("ForumDiv");



		httpObj.open("GET", SendUrl, true);



		httpObj.onreadystatechange = function RecieveForumRequest(){



			if (httpObj.readyState == 4) {



				if(httpObj.responseText != '') {



					document.getElementById("ForumDiv").innerHTML = httpObj.responseText;



				}else {



					alert("Error Occur : " + httpObj.responseText);



				}



			}



		};



		httpObj.send(null);







	}











	///////////----------- Reply Comment Section--------------- ////////////



	function ReplyComment(CommentID){



		if(document.getElementById("ForumMemberID").value > 0){



			Loading("ForumDiv");



			var SendUrl = "forum.php?action=reply&CommentID="+CommentID+"&MemberID="+document.getElementById("ForumMemberID").value+"&ProductID="+document.getElementById("ForumProductID").value+"&r="+Math.random(); 



			



			document.getElementById("CommentType").value = 'reply';



			



			httpObj.open("GET", SendUrl, true);



			httpObj.onreadystatechange = function RecieveReplyRequest(){



				if (httpObj.readyState == 4) { 



						



					if(httpObj.responseText != '') {



						document.getElementById("ForumDiv").innerHTML = httpObj.responseText;



					}else {



						alert("Error Occur : " + httpObj.responseText);



					}



				}



			};



			httpObj.send(null);



		}else{	



			alert('You are not logged in. Redirecting to login area.....');



			location.href = "myAccount.php?cont=products.php?id="+document.getElementById("ForumProductID").value+',action=reply,CommentID='+CommentID;



		}



	}	











	///////////----------- Submit Reply Comment Section--------------- ////////////







	function SubmitReplyComment(){



		if( ValidateForTextarea(document.getElementById("ReplyComment"), "Comment", 10, 800)



		){







			var SendUrl = "forum.php?action=submit_reply&CommentID="+document.getElementById("ReplyCommentID").value+"&CommentType="+escape(document.getElementById("CommentType").value)+"&ReplyComment="+escape(document.getElementById("ReplyComment").value)+"&MemberID="+document.getElementById("ForumMemberID").value+"&ProductID="+document.getElementById("ForumProductID").value+"&r="+Math.random(); 



			



			



			if(document.getElementById("OwnerEmailID") != null){



				SendUrl += "&OwnerEmailID="+document.getElementById("OwnerEmailID").value+"&OwnerName="+document.getElementById("OwnerName").value;



			}



			



			



			



			httpObj.open("GET", SendUrl, true);



			httpObj.onreadystatechange = function SubmitReplyForumRequest(){



				if (httpObj.readyState == 4) {



					if(httpObj.responseText==3) {



						alert("Comment has abuse words in it. Please remove them !");



						document.getElementById("ReplyComment").select();



						return false;



					}else if(httpObj.responseText != '') {



						//alert("Error Occur : " + httpObj.responseText);



						document.getElementById("ForumDiv").innerHTML = httpObj.responseText;



					}else {



						alert("Error Occur : " + httpObj.responseText);



					}



					return false;



				}



			};



			httpObj.send(null);



		}



		



	}











	///////////----------- Submit Reply Comment Section--------------- ////////////







	function RemoveTopic(CommentID){







		if(confirm("Are you sure, you want to delete this topic ?")){



			



			var SendUrl = "forum.php?action=view&del_id="+CommentID+"&MemberID="+document.getElementById("ForumMemberID").value+"&ProductID="+document.getElementById("ForumProductID").value+"&r="+Math.random(); 



			Loading("ForumDiv");



			httpObj.open("GET", SendUrl, true);



			httpObj.onreadystatechange = function RemoveForumRequest(){



				if (httpObj.readyState == 4) {



					if(httpObj.responseText != '') {



						document.getElementById("ForumDiv").innerHTML = httpObj.responseText;



					}else {



						alert("Error Occur : " + httpObj.responseText);



					}



					return false;



				}



			};



			httpObj.send(null);



					



		}



	











	}



	
