function addPost() {
	xajax_addPost();
}
function showPost() {
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	Element.setHeight('overlay', arrayPageSize[1]);
	new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.8 });
	
	var createPostTop = arrayPageScroll[1] + (arrayPageSize[3] / 15) + 40;
	Element.setTop('post_div', createPostTop);
	document.getElementById("post_div").style.display = "block";
	
	document.getElementById("overlay").onclick = function() { hidePost(); myLightbox.end(); return false; }
}

function hidePost() {
	new Effect.Fade('overlay', { duration: 0.2});
	
	document.getElementById("post_div").style.display = "none";
}

function addComment(post_id) {
	var current_id = document.getElementById("post_id").value;
	if(current_id != post_id) {
		xajax_addComment(post_id);
	} else {
		showComment();
	}
}
function showComment() {
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	Element.setHeight('overlay', arrayPageSize[1]);
	new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.8 });
	
	var createCommentTop = arrayPageScroll[1] + (arrayPageSize[3] / 15) + 40;
	Element.setTop('comment_div', createCommentTop);
	document.getElementById("comment_div").style.display = "block";
	
	document.getElementById("overlay").onclick = function() { hideComment(); myLightbox.end(); return false; }	
}

function hideComment() {
	new Effect.Fade('overlay', { duration: 0.2});
	
	document.getElementById("comment_div").style.display = "none";
}

function addEmailFriend(post_id) {
	var current_id = document.getElementById("friendpost_id").value;
	if(current_id != post_id) {
		xajax_addEmailFriend(post_id);
	} else {
		showEmailFriend();
	}
}
function showEmailFriend() {
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	Element.setHeight('overlay', arrayPageSize[1]);
	new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.8 });
	
	var createCommentTop = arrayPageScroll[1] + (arrayPageSize[3] / 15) + 40;
	Element.setTop('emailFriend_div', createCommentTop);
	document.getElementById("emailFriend_div").style.display = "block";
	
	document.getElementById("overlay").onclick = function() { hideEmailFriend(); myLightbox.end(); return false; }	
}

function hideEmailFriend() {
	new Effect.Fade('overlay', { duration: 0.2});
	
	document.getElementById("emailFriend_div").style.display = "none";
}

function addAlert(type) {
	xajax_addAlert(type);
}

function showRedAlert() {
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	Element.setHeight('overlay', arrayPageSize[1]);
	new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.8 });
	
	var createCommentTop = arrayPageScroll[1] + (arrayPageSize[3] / 15) + 40;
	Element.setTop('alert_div', createCommentTop);
	document.getElementById("alert_div").style.display = "block";
	document.getElementById("alert_div").style.background = "#E36F70";
	
	document.getElementById("overlay").onclick = function() { hideAlert(); myLightbox.end(); return false; }	
}

function showGreenAlert() {
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	Element.setHeight('overlay', arrayPageSize[1]);
	new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.8 });
	
	var createCommentTop = arrayPageScroll[1] + (arrayPageSize[3] / 15) + 40;
	Element.setTop('alert_div', createCommentTop);
	document.getElementById("alert_div").style.display = "block";
	document.getElementById("alert_div").style.background = "#6FE3A0";
	
	document.getElementById("overlay").onclick = function() { hideAlert(); myLightbox.end(); return false; }	
}

function hideAlert() {
	new Effect.Fade('overlay', { duration: 0.2});
	document.getElementById("alert_div").style.display = "none";
}

function checkExtension(filename) {
	xajax_checkExtension(filename);
}

function checkForBadwords($text) {
	xajax_checkForBadwords($text);
}

function toggleComments(id) {
	var commentsDiv = document.getElementById("comments_container"+id);
	commentsDiv.style.display = commentsDiv.style.display=="block"?"none":"block";
}

function validateEmailFriend() {
	$email_address = document.getElementById("friendEmail").value;
	if(validate_email($email_address))
		return true;
	else {
		alert("Invalid email address");
		return false;
	}
	
}

function validate_email(str) {
	var regexp =/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (regexp.test(str))
		return true;
	else 
		return false;
}