// The tabs in the sidabar for Navigation
function tab_navigate(whichtab, whichcontent) {
	document.getElementById('nav_content_1').style.display = 'none';
	document.getElementById('nav_content_2').style.display = 'none';
	document.getElementById('nav_content_3').style.display = 'none';
	document.getElementById(whichcontent).style.display = 'block';		

	document.getElementById('nav_tab1').className = 'off';
	document.getElementById('nav_tab2').className = 'off';
	document.getElementById('nav_tab3').className = 'off';
	document.getElementById(whichtab).className = 'on';		
}

function tab_recent(whichtab, whichcontent) {
	document.getElementById('rec_content_1').style.display = 'none';
	document.getElementById('rec_content_2').style.display = 'none';
	document.getElementById(whichcontent).style.display = 'block';		

	document.getElementById('rec_tab1').className = 'off';
	document.getElementById('rec_tab2').className = 'off';
	document.getElementById(whichtab).className = 'on';		
}


// Handling of the comment form
$(document).ready(function () {
	var default_values = new Array();
	default_values['author'] = "Name";
	default_values['email'] = "Email";
	default_values['url'] = "URL (Optional)";
	default_values['comment'] = "Your Message...";

	$('#comment_form input, #comment_form textarea').each(function () {
		if ($(this).val() == '') {
			$(this).val(default_values[$(this).attr('name')]);
		}
	}).focus(function () {
		$(this).removeClass('inputerror');
		if ($(this).val() == default_values[$(this).attr('name')]) {
			$(this).val('');
		}
	}).blur(function () {
		if ($(this).val() == '') {
			$(this).val(default_values[$(this).attr('name')]);
		}
	});

	$('#comment_form').submit(function () {
		$('#submiterror').remove();
		var errors = 0;
		$(this).find('textarea, input').each(function () {
			if ($(this).val() == default_values[$(this).attr('name')]) {
				if ($(this).attr('name') != 'comment_post_ID') {
					$(this).val('');
				}
			}
			if ($(this).hasClass('required') && $(this).val() == '') {
				$(this).addClass('inputerror');
				errors++;
			}
		});

		if (errors > 0) {
			$(this).find('textarea, input').each(function () {
				if ($(this).val() == '') {
					$(this).val(default_values[$(this).attr('name')]);
				}
			});
			$(this).prepend('<div id="submiterror">Please complete the highlighted fields.</div>');
			return false;
		}
		return true;
	});
});