$(document).ready(function() {
    $(".mouseWheelButtons .jCarouselLite").jCarouselLite({
      visible:4,
      btnNext: ".mouseWheelButtons .next",
      btnPrev: ".mouseWheelButtons .prev",
      mouseWheel: true,
	  circular: false
    });
});

function update_div(ajaxUrl,destId){
	var XMLresponse = '';
	XMLresponse = $.ajax({
		type: "POST",
		url: ajaxUrl,
		async: false
		}).responseText;
	
	if (!handleAjaxResponse(XMLresponse)) return false;
	
	$('#'+destId).html(XMLresponse);
}

function changeBlogListFilter(url,jsonParameters) {
	var response = '';
	$('#blog-listing').hide();
	$('#ajax-loader').fadeIn('slow');
	response = $.ajax({
		type: "GET",
		url: url,
		data: {arguments: jsonParameters},
		dataType :'json',
		async: false
		});

	var text = response.responseText;
	this.text = response.responseText;
	

	$('#blog-listing').html(text);
	$('#ajax-loader').fadeOut('slow');
	setTimeout ("$('#blog-listing').fadeIn('slow')",1000);
	
	
	//setTimeout ("displayFilteredBlogEntries(response.responseText)", 2000);
}

function displayFilteredBlogEntries(text) {
	$('#blog-listing').html(text);
	$('#blog-listing').fadeIn('slow');
	$('#ajax-loader').fadeOut('slow');
}

function showComments() {
	$('.comment-container').fadeIn('slow');
	$('.comments').attr({ 
          onClick: "hideComments(); return false;"
        });
	return false;
}

function hideComments() {
	$('.comment-container').slideUp('slow');
	$('.comments').attr({ 
          onClick: "showComments(); return false;"
        });
	return false;
}

function changePreview(image){
	$('#image-preview').html('<img src="'+image+'">');
}

function validate_comment_form(form) {
	var errortext = '';

	if ($('#name').val() == null || $('#name').val() == '') {
		errortext = errortext + 'You have left out your name.<br />';
	}

	if ($('#title').val() == null || $('#title').val() == '') {
		errortext = errortext + 'You have not entered a title for your comment.<br />';
	}

	if ($('#comment').val() == null || $('#comment').val() == '') {
		errortext = errortext + 'You have not entered anything in the comment section.<br />';
	}

	if (errortext != '')
	{
		$('.comment-error-box').html(errortext);
		$('.comment-error-box').show();
		return false;
	}

	ajaxCommentFormSubmit();
	return true;
}

function ajaxCommentFormSubmit() {
	$('#comment-form-wrapper').hide();
	$('.comment-loader').show();

	response = $.ajax({
		type: "POST",
		url: 'ajax.php',
		//data: {arguments: jsonParameters},
		//dataType :'json',
		async: false
	});
}

/*$(".comments").click(function () {
   $('.comment-container').fadeIn('slow');
   return false;
}); */
