// JavaScript Document
function GetComments(article_id,page,hash) {
	            
				var http_request = false;
		
				if (window.XMLHttpRequest) { 
					http_request = new XMLHttpRequest();
					if (http_request.overrideMimeType) {
						http_request.overrideMimeType('text/xml');
					}
				}else if (window.ActiveXObject) { // IE
					try {
						http_request = new ActiveXObject("Msxml2.XMLHTTP");
					} catch (e) {
						try {
							http_request = new ActiveXObject("Microsoft.XMLHTTP");
						}catch (e) {}
					}
				}
		
				if (http_request) {
					http_request.onreadystatechange = function(){ GetResult(http_request,'comments_div'); };
					http_request.open('GET', "class/ajax/exec_comment.php?article_id="+article_id+"&page="+page+"&hash="+hash, true);
					http_request.send(null);
				}
								
}

function GetCommentRating(comment_id,i,action) {
	            
				var http_request = false;
		
				if (window.XMLHttpRequest) { 
					http_request = new XMLHttpRequest();
					if (http_request.overrideMimeType) {
						http_request.overrideMimeType('text/xml');
					}
				}else if (window.ActiveXObject) { // IE
					try {
						http_request = new ActiveXObject("Msxml2.XMLHTTP");
					} catch (e) {
						try {
							http_request = new ActiveXObject("Microsoft.XMLHTTP");
						}catch (e) {}
					}
				}
		
				if (http_request) {
					http_request.onreadystatechange = function(){ GetResult(http_request,'comment_rating'+i); };
					http_request.open('GET', "class/ajax/exec_comment_rating.php?comment_id="+comment_id+"&div="+i+"&action="+action, true);
					http_request.send(null);
				}
								
}
function CommentRatingPlus(comment_id) {
	            
				var http_request = false;
		
				if (window.XMLHttpRequest) { 
					http_request = new XMLHttpRequest();
					if (http_request.overrideMimeType) {
						http_request.overrideMimeType('text/xml');
					}
				}else if (window.ActiveXObject) { // IE
					try {
						http_request = new ActiveXObject("Msxml2.XMLHTTP");
					} catch (e) {
						try {
							http_request = new ActiveXObject("Microsoft.XMLHTTP");
						}catch (e) {}
					}
				}
		
				if (http_request) {
					http_request.onreadystatechange = function(){ GetResult(http_request,'comment_rating_plus'); };
					http_request.open('GET', "exec_comment_rating_plus.php?comment_id="+comment_id, true);
					http_request.send(null);
				}
								
}


function CheckComment(name,comment,code,bin_code,article_id) {
				var http_request = false;
		
				if (window.XMLHttpRequest) { 
					http_request = new XMLHttpRequest();
					if (http_request.overrideMimeType) {
						http_request.overrideMimeType('text/xml');
					}
				}else if (window.ActiveXObject) { // IE
					try {
						http_request = new ActiveXObject("Msxml2.XMLHTTP");
					} catch (e) {
						try {
							http_request = new ActiveXObject("Microsoft.XMLHTTP");
						}catch (e) {}
					}
				}
		
				if (http_request) {
					http_request.onreadystatechange = function(){ GetCommnetResult(http_request,'comment_error_div',article_id); };
					http_request.open('GET', "class/ajax/exec_comment_form.php?name="+name+"&comment="+comment+"&code="+code+"&scode="+bin_code+"&article_id="+article_id,true);
					http_request.send(null);
				}
			}


function RightTabMenu(article_id,tab_id,cat_id,type,sort,hash,navPage) {
				var http_request = false;
		
				if (window.XMLHttpRequest) { 
					http_request = new XMLHttpRequest();
					if (http_request.overrideMimeType) {
						http_request.overrideMimeType('text/xml');
					}
				}else if (window.ActiveXObject) { // IE
					try {
						http_request = new ActiveXObject("Msxml2.XMLHTTP");
					} catch (e) {
						try {
							http_request = new ActiveXObject("Microsoft.XMLHTTP");
						}catch (e) {}
					}
				}
		
				if (http_request) {
				    
					http_request.onreadystatechange = function(){ GetResult(http_request,'right_tab_menu_div'); };
					http_request.open('GET', "class/ajax/exec_tabmenu.php?article_id="+article_id+"&tab_id="+tab_id+"&cat_id="+cat_id+"&type="+type+"&sort="+sort+"&navPage="+navPage+"&hash="+hash,true);
					http_request.send(null);
				}
			}


			
function GetCommnetResult(http_request,div_id,article_id) {
				oText = document.getElementById(div_id);								
				oText.innerHTML = '';
				var arrText= new Array();
				var sText='';
				
				if (http_request.readyState == 4){
					if (http_request.status == 200){
						//oText.innerHTML = http_request.responseText;
						
						if(http_request.responseText == 1) {
						     
						     document.comment_form.name.style.border='1px solid red';
						     document.comment_form.comment.style.border='1px solid red';
						     document.comment_form.code.style.border='1px solid red';
						     oName = document.getElementById("name_div");
						     oComment = document.getElementById("comment_div");
						     oCode = document.getElementById("code_div")
						     oNameSpan = document.getElementById("name_span");
						     oCommentSpan = document.getElementById("comment_span");						     
						     oCodeSpan = document.getElementById("code_span")
						     oNameSpan.style.display = 'none';						     
						     oCommentSpan.style.display = 'none';
						     oCodeSpan.style.display = 'none';
						     oName.style.display = '';						     
						     oComment.style.display = '';
						     oCode.style.display = '';
						     oName.innerHTML = 'Полето Име е задължително.';
						     oComment.innerHTML = 'Полето Коментар е задължително.';
						     oCode.innerHTML = 'Полето Ключ е задължително.';
						     
						     
						
						} else if (http_request.responseText == 2) {
						     oName = document.getElementById("name_div");
						     oComment = document.getElementById("comment_div");
						     oCode = document.getElementById("code_div")
						     oNameSpan = document.getElementById("name_span");
						     oCommentSpan = document.getElementById("comment_span");						     
						     oCodeSpan = document.getElementById("code_span")
						     oNameSpan.style.display = 'block';						     
						     oCommentSpan.style.display = 'block';
						     oName.style.display = 'none';	
						     oComment.style.display = 'none';
						     oCodeSpan.style.display = 'none';
						     document.comment_form.name.style.border='1px solid #e6e6e6';
						     document.comment_form.comment.style.border='1px solid #e6e6e6';
						     document.comment_form.code.style.border='1px solid red';
						     oCode.innerHTML = 'Препишете правилно ключа.'; 
						
						} else {						
						oForm = document.getElementById("comment_form");				        
						oForm.style.display = 'none';
						oSuccess = document.getElementById("success_div");
						oSuccess.style.display = 'block';
						GetComments(article_id,1);
						
						}
						
					             
					}
				}
}							
					function ResetCommentForm() {
					
					document.comment_form.reset();
					oForm = document.getElementById("comment_form");
					oSuccess = document.getElementById("success_div");
					oNameSpan = document.getElementById("name_span");
					oCommentSpan = document.getElementById("comment_span");
					document.getElementById('cnt-descr').innerHTML = 1000;
					oForm.style.display = 'block';
					oSuccess.style.display = 'none';
					document.comment_form.name.style.border='1px solid #e6e6e6';
					document.comment_form.comment.style.border='1px solid #e6e6e6';
					document.comment_form.code.style.border='1px solid #e6e6e6';
					oName = document.getElementById("name_div");
					oComment = document.getElementById("comment_div");
					
					oNameSpan.style.display = 'block';						     
					oCommentSpan.style.display = 'block';
					oName.style.display = 'none';	
					oComment.style.display = 'none';
					oCodeSpan = document.getElementById("code_span");
					oCode = document.getElementById("code_div");
					oCode.style.display = 'none';
					oCodeSpan.style.display = '';
					
					}



function GetResult(http_request,div_id) {
				oText = document.getElementById(div_id);								
				oText.innerHTML = '';
				var arrText= new Array();
				var sText='';
				
				if (http_request.readyState == 4){
					if (http_request.status == 200){
					   
						oText.innerHTML = http_request.responseText;
						oText.style.display = 'block';
						oText.focus();
					}
				}
}


function SubscriptionForm(article_id,author_id,cat_id,email,type) {
				var http_request = false;
		
				if (window.XMLHttpRequest) { 
					http_request = new XMLHttpRequest();
					if (http_request.overrideMimeType) {
						http_request.overrideMimeType('text/xml');
					}
				}else if (window.ActiveXObject) { // IE
					try {
						http_request = new ActiveXObject("Msxml2.XMLHTTP");
					} catch (e) {
						try {
							http_request = new ActiveXObject("Microsoft.XMLHTTP");
						}catch (e) {}
					}
				}
		
				if (http_request) {
					http_request.onreadystatechange = function(){ GetSubscriptionResult(http_request,'subscription_div'); };
					http_request.open('GET', "class/ajax/exec_subscription_form.php?article_id="+article_id+"&author_id="+author_id+"&cat_id="+cat_id+"&type="+type+"&email="+email,true);
					http_request.send(null);
				}
			}

function SubscribeAuthor(author_id,type1,email) {
				var http_request = false;
		
				if (window.XMLHttpRequest) { 
					http_request = new XMLHttpRequest();
					if (http_request.overrideMimeType) {
						http_request.overrideMimeType('text/xml');
					}
				}else if (window.ActiveXObject) { // IE
					try {
						http_request = new ActiveXObject("Msxml2.XMLHTTP");
					} catch (e) {
						try {
							http_request = new ActiveXObject("Microsoft.XMLHTTP");
						}catch (e) {}
					}
				}
		
				if (http_request) {
					http_request.onreadystatechange = function(){ GetSubscribeAuthorResult(http_request,'subscribe_author_div'); };
					http_request.open('GET', "class/ajax/exec_subscribe_author.php?author_id="+author_id+"&type1="+type1+"&email="+email,true);
					http_request.send(null);
				}
			}

function GetSubscribeAuthorResult(http_request,div_id) {
				oText = document.getElementById(div_id);								
				oText.innerHTML = '';
				var arrText= new Array();
				var sText='';
				
				if (http_request.readyState == 4){
					if (http_request.status == 200){
						oText.innerHTML = http_request.responseText;						

						
					             
					}
				}
}
						
function GetSubscriptionResult(http_request,div_id) {
				oText = document.getElementById(div_id);								
				oText.innerHTML = '';
				var arrText= new Array();
				var sText='';
				
				if (http_request.readyState == 4){
					if (http_request.status == 200){
						oText.innerHTML = http_request.responseText;
					}
				}
}			
function wait(msecs)
{
var start = new Date().getTime();
var cur = start
while(cur - start < msecs)
{								
cur = new Date().getTime();
}
} 		



function Vote(article_id, action,hash) {
	var http_request = false;

	if (window.XMLHttpRequest) { 
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	}else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e) {}
		}
	}

	if (http_request) {
	    
		http_request.onreadystatechange = function(){ VoteResult(http_request,'recommend_form'); };
		http_request.open('GET', "class/ajax/exec_vote.php?article_id="+article_id+"&action="+action+"&hash="+hash,true);
		http_request.send(null);
	}
}	

function VoteResult(http_request,div_id) {
				oText = document.getElementById(div_id);								
				oText.innerHTML = '';
				var arrText= new Array();
				var sText='';
				
				if (http_request.readyState == 4){
					if (http_request.status == 200){
					   
						oText.innerHTML = http_request.responseText;
						oText.style.display = 'block';
						oText.focus();
					}
				}
}
