// JavaScript Document


/******************* iaforum Global Initialisation Parameter  *********************/


var mainObj = null;
animatedcollapse.addDiv('result', 'fade=1,speed=1000,group=pets')
animatedcollapse.init()


/************** iaforum  Server Side Validation For Home and Index Section ******************/

function createHTTPObj()
{
	var http = null;
		  if(window.XMLHttpRequest)
		  	http = new XMLHttpRequest();
		  else if (window.ActiveXObject)
		    http = new ActiveXObject("Microsoft.XMLHTTP");
			return http;
	}

function latestArticle()
		{

	 	  var http = createHTTPObj();
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
			    
				var response = http.responseText
				document.getElementById("newArticle").innerHTML=response;
					
				  
			  }
		   };
		   http.open('GET','latestArticle.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send(null);
		}
		
function addRegistrationDetails(emailid)
		{

	 	  var http = createHTTPObj();
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
			   	if((http.responseText).indexOf("True")>=0){ 
				document.getElementById("flag").innerHTML="<span class=RedLink>Email id Registered</span>";	
				 
				}else if((http.responseText).indexOf("False")>=0){
			document.getElementById("flag").innerHTML="<span class=RedLink>Sorry , Not Registered </span>";	
				}
				else if((http.responseText).indexOf("Duplicate")>=0){
			document.getElementById("flag").innerHTML="<span class=RedLink>Already Registered</span>";	
			
				}
			  }
		   };
		   http.open('POST','addRegistrationDetails.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send("emailid="+emailid);
		}		
		
function getArticlePages()
		{

	 	  var http = createHTTPObj();
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
				
				var response = http.responseText
				document.getElementById('view').innerHTML=response;
					
				  
			  }
		   };
		   http.open('POST','getArticleViewByYear.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send("year="+encodeURIComponent(document.getElementById("year").value)+"&lower="+encodeURIComponent(document.getElementById("firsttime").value)+"&upper="+encodeURIComponent(document.frm.count.value)+'&count='+encodeURIComponent(document.frm.count.value));
		}
		
		function viewArticlesDetails(year,lower,upper,count)
		{
		
	 	 var http = createHTTPObj();
		 
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
				document.getElementById('result').style.width='100%'; 
				document.getElementById('result').style.display='none';
				var response = http.responseText
				document.getElementById("result").innerHTML=response; 
				animatedcollapse.show('result');
			  }
		   };
		   http.open('POST','viewArticleDetails.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send("year="+year+"&lower="+lower+"&upper="+upper+'&count='+count);
		}
		
  function loadRecentArticles()
	{

	 getArticlePages();
	viewArticlesDetails(encodeURIComponent(document.getElementById("year").value),encodeURIComponent(document.getElementById("firsttime").value),encodeURIComponent(document.frm.count.value),encodeURIComponent(document.frm.count.value));
	 
	}	
	
	
	  function loadComments()
	{
 
	getCommentPages();
	viewDicussionDetails(encodeURIComponent(document.getElementById("year").value),encodeURIComponent(document.getElementById("firsttime").value),encodeURIComponent(document.frm.count.value),encodeURIComponent(document.frm.count.value));
	 
	}
	
	
	function getCommentPages()
		{

	 	  var http = createHTTPObj();
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
			    
				var response = http.responseText
				document.getElementById("view").innerHTML=response;
					
				  
			  }
		   };
		   http.open('POST','getCommentsViewByYear.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send("year="+encodeURIComponent(document.getElementById("year").value)+"&lower="+encodeURIComponent(document.getElementById("firsttime").value)+"&upper="+encodeURIComponent(document.frm.count.value)+'&count='+encodeURIComponent(document.frm.count.value));
		}
		
	function viewDicussionDetails(year,lower,upper,count)
		{

	 	  var http = createHTTPObj();
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
			
				document.getElementById('result').style.width='100%'; 
				document.getElementById('result').style.display='none';
				var response = http.responseText
				document.getElementById("result").innerHTML=response; 
				animatedcollapse.show('result');
					
				  
			  }
		   };
		   http.open('POST','getDiscussionBoardView.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send("year="+document.getElementById("year").value+"&lower="+lower+"&upper="+upper+'&count='+document.frm.count.value);
		}
		
	function openWindow(comments_id,year,lower,upper,count)
		{
		closeDiv();
	 	  var http = createHTTPObj();
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
			
				
				var response = http.responseText
				var x = 70;
			    var y = 500;
	 			document.getElementById('commentview').style.display='block';
	 			document.getElementById('commentview').style.left=x+'px';
	 			document.getElementById('commentview').style.top=y+'px';
	 			document.getElementById('commentview').innerHTML=response;	
				  
			  }
		   };
		   http.open('POST','viewComments.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send("comments_id="+comments_id+"&year="+year+"&lower="+lower+"&upper="+upper+"&count="+count);
		}
		
		
		function closeDiv()
		{
		document.getElementById('commentview').innerHTML='';
		 document.getElementById('commentview').style.display='none';
		}
	
		function replybtn(year,lower,upper,count)
		{
			 var http = createHTTPObj();
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
			
				var response = http.responseText
				document.getElementById("msg").innerHTML="";
				document.getElementById("pos").innerHTML=response; 
			  }
		   };
		   http.open('POST','postCommentForm.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send("year="+year+"&lower="+lower+"&upper="+upper+'&count='+count);
		}
			
			
			function cancelbtn(year,lower,upper,count)
			{
			 var http = createHTTPObj();
			  http.onreadystatechange = function()
			   {
				if(http.readyState == 4){
				
					var response = http.responseText
					document.getElementById("pos").innerHTML=response; 
				  }
			   };
			   http.open('POST','cancelCommentForm.jsp',true);
			   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			   http.send("year="+year+"&lower="+lower+"&upper="+upper+'&count='+count);
			}	
			
		function viewComments()
		{

	 	 var http = createHTTPObj();
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
			
				var response = http.responseText
				document.getElementById("report").innerHTML=response; 
			  }
		   };
		   http.open('POST','getCommentView.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send("comments_id="+encodeURIComponent(document.getElementById("comments_id").value));
		}
		
		
		
		function repliedComment(user_name,comments_id,reply,year,lower,upper,count)
		{

	 	  var http = createHTTPObj();
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
			
				if((http.responseText).indexOf("True")>=0){
					cancelbtn(year,lower,upper,count);
					document.getElementById("msg").innerHTML="Your reply has been posted successfully ";
					viewComments();
					parent.window.viewDicussionDetails(year,lower,upper,count);
					}
					else if((http.responseText).indexOf("False")>=0){
					document.getElementById("msg").innerHTML="Error encountered during posting your reply.";
					document.frm.user_name.focus();
				   }
				  
			  }
		   };
		   http.open('POST','replySubmitForComment.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send("user_name="+encodeURIComponent(user_name)+"&comments_id="+encodeURIComponent(comments_id)+"&reply="+encodeURIComponent(reply));
		}
		
		
		function submitQuestion()
		{

	 	  var http = null;
		  if(window.XMLHttpRequest)
		  	http = new XMLHttpRequest();
		  else if (window.ActiveXObject)
		    http = new ActiveXObject("Microsoft.XMLHTTP");
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
				 if((http.responseText).indexOf("DataFalse")>=0)
				 {
				 document.getElementById("view").innerHTML="Error occured during posting question - data false .";
				 document.frm.reset();
				 }
				 else if((http.responseText).indexOf("MailTrue")>=0)
				 {
				  document.getElementById("view").innerHTML="Your question has been posted successfully. <br>Please check your mail for acknowledgment .";
				
				 document.frm.reset();
				
				 }  
				 else if((http.responseText).indexOf("MailFalse")>=0)
				 {
				 document.getElementById("view").innerHTML="Your question has been posted successfully . ";
				document.frm.reset();
				 }
				 else
				 {
				  document.getElementById("view").innerHTML="Error occured during posting question .- normal";
				  document.frm.reset();
				 }  
			  }
		   };
		   http.open('POST','submitQuestion.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send("user_name="+encodeURIComponent(document.frm.user_name.value)+"&emailid="+encodeURIComponent(document.frm.emailid.value)+"&city="+encodeURIComponent(document.frm.city.value)+"&country="+encodeURIComponent(document.frm.country.value)+"&category="+encodeURIComponent(document.frm.category.value)+"&question="+encodeURIComponent(document.frm.question.value));
		}
		
		function getPageDetails()
		{

	 	  var http = null;
		  if(window.XMLHttpRequest)
		  	http = new XMLHttpRequest();
		  else if (window.ActiveXObject)
		    http = new ActiveXObject("Microsoft.XMLHTTP");
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
			
				var response = http.responseText
				document.getElementById("view").innerHTML=response;
					
				  
			  }
		   };
		   http.open('POST','getQuestionPageDetails.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send("categoryid="+encodeURIComponent(document.frm.category.value)+"&lower="+encodeURIComponent(document.getElementById("firsttime").value)+"&upper="+encodeURIComponent(document.frm.count.value)+'&count='+encodeURIComponent(document.frm.count.value));
		}
		
		function getQuestionAnswerDetails(categoryid,lower,upper,count)
		{
		
	 	  var http = null;
		  if(window.XMLHttpRequest)
		  	http = new XMLHttpRequest();
		  else if (window.ActiveXObject)
		    http = new ActiveXObject("Microsoft.XMLHTTP");
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
			
				document.getElementById('result').style.width='100%'; 
				document.getElementById('result').style.display='none';
				var response = http.responseText
				document.getElementById("result").innerHTML=response; 
				animatedcollapse.show('result');
					
				  
			  }
		   };
		   http.open('POST','QuestionAndAnswerDetails.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send("categoryid="+categoryid+"&lower="+lower+"&upper="+upper+'&count='+count);
		}	
		

	 function loadQuestionAnswer()
		{
		getPageDetails();
getQuestionAnswerDetails(encodeURIComponent(document.getElementById("category").value),encodeURIComponent(document.getElementById("firsttime").value),encodeURIComponent(document.frm.count.value),encodeURIComponent(document.frm.count.value));
		 
		}			
	
		function postComment(user_name,comments)
		{

	 	  var http = null;
		  if(window.XMLHttpRequest)
		  	http = new XMLHttpRequest();
		  else if (window.ActiveXObject)
		    http = new ActiveXObject("Microsoft.XMLHTTP");
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
			
				if((http.responseText).indexOf("True")>=0){
					document.getElementById("view").innerHTML="Your Comment have been Posted Successfully .";
					document.frm.reset();
					parent.window.loadComments();
					}
					else if((http.responseText).indexOf("False")>=0){
					document.getElementById("view").innerHTML="Error encounted during posting comments.";
					document.frm.reset();
					document.frm.user_name.focus();
				   }
				  
			  }
		   };
		   http.open('POST','submitComment.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send('user_name='+user_name+'&comments='+comments);
		}
		
		function postFeedback()
		{

	 	  var http = null;
		  if(window.XMLHttpRequest)
		  	http = new XMLHttpRequest();
		  else if (window.ActiveXObject)
		    http = new ActiveXObject("Microsoft.XMLHTTP");
		  http.onreadystatechange = function()
		   {
		    if(http.readyState == 4){
			
				if((http.responseText).indexOf("True")>=0){
					document.getElementById("msg").innerHTML="Your Feedback have been Posted Successfully .";
					document.frm.reset();
					}
					else if((http.responseText).indexOf("False")>=0){
					document.getElementById("msg").innerHTML="Error encounted during posting Feedback .";
					document.frm.reset();
					document.frm.name.focus();
				   }
				   else if((http.responseText).indexOf("Error")>=0){
					document.getElementById("msg").innerHTML="Exception has been encounted during posting comments.";
					document.frm.reset();
					document.frm.name.focus();
				   }
				  
			  }
		   };
		   http.open('POST','submitFeedBackDetails.jsp',true);
		   http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		   http.send('name='+encodeURIComponent(document.getElementById("name").value)+'&email='+encodeURIComponent(document.getElementById("email").value)+'&address='+encodeURIComponent(document.getElementById("address").value)+'&city='+encodeURIComponent(document.getElementById("city").value)+'&pincode='+encodeURIComponent(document.getElementById("pincode").value)+'&state='+encodeURIComponent(document.getElementById("state").value)+'&country='+encodeURIComponent(document.getElementById("country").value)+'&telno='+encodeURIComponent(document.getElementById("telno").value)+'&faxno='+encodeURIComponent(document.getElementById("faxno").value)+'&comments='+encodeURIComponent(document.getElementById("comments").value));
		}