/**
 * @author NeTRaY
 */


/**
 * 
 * @param {Node} element
 */
var currentMenu = $('menu-1');

function menuToggle(element) {
	if (element != currentMenu) {
		
		
		if (currentMenu != '') {
			//new Effect.BlindUp(currentMenu, {queue: {position: 'end', scope: 'menuScope', limit: 4}, duration: 0.3});
			currentMenu.style.display = 'none';
		}
		element.style.display = '';
		//new Effect.BlindDown(element, {queue: {position: 'end', scope: 'menuScope', limit: 4}, duration: 0.5});
		
		currentMenu = element;
		
	}
}

function toggle(el) {
	if (el.style.display == '') {
		el.style.display = 'block';
	} else {
		el.style.display = '';
	}
}

function toggleComments() {
	$('sendContents').style.display = '';
	toggle($('addComment'));
	return false;
}

function toggleSend() {
	$('addComment').style.display = '';
	toggle($('sendContents'));
	return false;
}

function submitComment(contentId, commentLink) {
	var _name = encodeURIComponent($F('name').strip());
	var _comment = encodeURIComponent($F('comment').strip());
	
	if ($('sendName') != null) {
		$('sendName').value =  _name;
	}
	
	var pars = 'action=addComment&id=' + contentId + '&name=' + _name + '&comment=' + _comment;
	
	if (_name == '' || _comment == '') {
		return false;
	} else {
		//$('commentButton').disabled = true;
		$('commentLoad').style.display = 'block';
		
		var ajax = new Ajax.Updater('newComment', commentLink, {
  		parameters: pars,
		onSuccess: function() {
			$('commentLoad').style.display = 'none';
			$('addComment').style.display = '';
			
			var noComments = $('no-comments');
			if (noComments != null) {
				noComments.hide();
			}
		}
		});
		
		return false;	
	}
}

function submitSend(contentId, sendLink) {
	var _name = $F('sendName').strip();
	var _address = $F('email').strip();
	
	$('name').value =  _name;
	
	var pars = 'action=sendEmail&id=' + contentId + '&name=' + _name + '&address=' + _address;
	
	if (_name == '' || _address== '') {
		return false;
	} else {
		$('sendButton').disabled = true;
		$('sendLoad').style.display = 'block';
		
		var ajax = new Ajax.Updater('newComment', sendLink, {
  		parameters: pars,
		onSuccess: function() {
			$('sendButton').disabled = false;
			$('sendLoad').style.display = 'none';
		}
		});
		
		return false;	
	}
}