function HTTPRequest(){
	var http;
	try{
		http = new XMLHttpRequest();
	}catch(e){
		try{
			http = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				http = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				alert('JavaScript error');
				return false;
			}
		}
	}
	return http;
}
function RequestComments(contentId, pageId){
	var http = HTTPRequest();
	var element = document.getElementById(contentId);
	var listing = element.getElementsByTagName('DIV')[0];
	var mask = document.createElement('DIV');
	mask.className = 'mask';
	listing.appendChild(mask);
	mask.style.display = 'block';
	http.onreadystatechange = function(){
		if(http.readyState == 4){
			if(http.status == 200){
				if(http.responseText){
					mask.style.display = 'none';
					element.innerHTML = http.responseText;
				}
			}
		}
	};
	http.open('POST', 'AJAX/ArticleComments.asp', true);
	http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
	http.setRequestHeader("Connection", "Close");
	http.send("ContentId=" + contentId + "&PageId=" + pageId);
}
function RequestHoroscopeFans(contentId, pageId){
	var http = HTTPRequest();
	var element = document.getElementById(contentId);
	http.onreadystatechange = function(){
		if(http.readyState == 4){
			if(http.status == 200){
				if(http.responseText){
					element.innerHTML = http.responseText;
				}
			}
		}
	};
	http.open('POST', 'AJAX/HoroscopeFans.asp', true);
	http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
	http.setRequestHeader("Connection", "Close");
	http.send("ContentId=" + contentId + "&PageId=" + pageId);
}
function GalleryImage(articleId, pageId){
	var http = HTTPRequest();
	http.onreadystatechange = function(){
		if(http.readyState == 4){
			if(http.status == 200){
				if(http.responseText){
					if(http.responseText){
						var element = document.getElementById('gallery');
						element.innerHTML = http.responseText;
						if(window.initLightbox){
							initLightbox();
						}
					}
				}
			}
		}
	};
	http.open('POST', 'AJAX/GalleryImage.asp', true);
	http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
	http.setRequestHeader("Connection", "Close");
	http.send("ArticleId=" + articleId + "&PageId=" + pageId);
}
function PersonImage(ImageId){
	var http = HTTPRequest();
	http.onreadystatechange = function(){
		if(http.readyState == 4){
			if(http.status == 200){
				if(http.responseText){
					if(http.responseText != 'false'){
						document.getElementById('gallery').innerHTML = http.responseText;
						if(window.initLightbox){
							initLightbox();
						}
					}
				}
			}
			return;
		}
	};
	http.open('POST', 'AJAX/PersonImages.asp', true);
	http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
	http.setRequestHeader("Connection", "Close");
	http.send("ImageId=" + ImageId);
}
function UserImage(ImageId){
	var http = HTTPRequest();
	http.onreadystatechange = function(){
		if(http.readyState == 4){
			if(http.status == 200){
				if(http.responseText){
					if(http.responseText != 'false'){
						document.getElementById('image').innerHTML = http.responseText;
						if(window.initLightbox){
							initLightbox();
						}
					}
				}
			}
			return;
		}
	};
	http.open('POST', 'AJAX/UserImage.asp', true);
	http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
	http.setRequestHeader("Connection", "Close");
	http.send("ImageId=" + ImageId);
}
function UserImagePage(UserId, PageId){
	var http = HTTPRequest();
	http.onreadystatechange = function(){
		if(http.readyState == 4){
			if(http.status == 200){
				if(http.responseText){
					if(http.responseText != 'false'){
						document.getElementById('page').innerHTML = http.responseText;
						if(window.initLightbox){
							initLightbox();
						}
					}
				}
			}
			return;
		}
	};
	http.open('POST', 'AJAX/UserImagePage.asp', true);
	http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
	http.setRequestHeader("Connection", "Close");
	http.send("UserId=" + UserId + "&PageId=" + PageId);
}
function UserImagePage2(UserId, PageId){
	var http = HTTPRequest();
	http.onreadystatechange = function(){
		if(http.readyState == 4){
			if(http.status == 200){
				if(http.responseText){
					if(http.responseText != 'false'){
						document.getElementById('page').innerHTML = http.responseText;
						if(window.initLightbox){
							initLightbox();
						}
					}
				}
			}
			return;
		}
	};
	http.open('POST', 'AJAX/UserImagePage2.asp', true);
	http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
	http.setRequestHeader("Connection", "Close");
	http.send("UserId=" + UserId + "&PageId=" + PageId);
}
function UserVote(UserId, UserVote){
	if(cookieRead("Voted") == "True"){
		alert("Не можеш да гласуваш през следващия 1 час!");
	}else{
		var http = HTTPRequest();
		http.onreadystatechange = function(){
			if(http.readyState == 4){
				if(http.status == 200){
					if(http.responseText){
						if(http.responseText != 'false'){
							var expires = new Date();
							expires.setMinutes(expires.getMinutes() + 60);
							cookieWrite("Voted", "True", expires.toGMTString());
							document.getElementById('rating').innerHTML = http.responseText;
						}
					}
				}
				return;
			}
		};
		http.open('POST', 'AJAX/UserVote.asp', true);
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
		http.setRequestHeader("Connection", "Close");
		http.send("UserId=" + UserId + "&UserVote=" + UserVote);
	}
}
function ReportAbusive(commentId){
	if(confirm('Сигурен ли си, че искаш да информираш администратор?')){
		var http = HTTPRequest();
		http.onreadystatechange = function(){
			if(http.readyState == 4){
				if(http.status == 200){
					if(http.responseText == 'true'){
						var href = document.getElementById(commentId);
						href.parentNode.removeChild(href);
					}
				}
			}
		};
		http.open('POST', 'AJAX/ReportAbusive.asp', true);
		http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
		http.setRequestHeader("Connection", "Close");
		http.send("CommentId=" + commentId);
	}
}
function ShowClubs(UserId, PageId){
	var http = HTTPRequest();
	http.onreadystatechange = function(){
		if(http.readyState == 4){
			if(http.status == 200){
				if(http.responseText != 'false'){
					document.getElementById('membership').innerHTML = http.responseText;
				}
			}
		}
	}
	http.open('POST', 'AJAX/ShowClubs.asp', true);
	http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
	http.setRequestHeader("Connection", "Close");
	http.send("UserId=" + UserId + "&PageId=" + PageId);
}
function ShowFans(ClubId, PageId){
	var http = HTTPRequest();
	http.onreadystatechange = function(){
		if(http.readyState == 4){
			if(http.status == 200){
				if(http.responseText != 'false'){
					document.getElementById('membership').innerHTML = http.responseText;
				}
			}
		}
	}
	http.open('POST', 'AJAX/ShowFans.asp', true);
	http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
	http.setRequestHeader("Connection", "Close");
	http.send("ClubId=" + ClubId + "&PageId=" + PageId);
}
