function paddToggle(classname,value) {
	jQuery(classname).focus(function() {
		if (value == jQuery(classname).val()) {
			jQuery(this).val('');
		}
	});
	jQuery(classname).blur(function() {
		if ('' == jQuery(classname).val()) {
			jQuery(this).val(value);
		}
	});
}

function paddCarouselInit(carousel) {
	// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});

	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});

	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(
		function() {
			carousel.stopAuto();
		},
		function() {
			carousel.startAuto();
		}
	);
}

function paddPlaceCommentCount() {
	jQuery('div.padd-middle-list div.post').each(function() {
		id = jQuery(this).attr('id');
		th = jQuery('div.padd-middle-list div#' + id + ' div.post-title').height();
		eh = jQuery('div.padd-middle-list div#' + id + ' div.post-entry').height();
		eh = (th + eh  < 210) ? (210 - th) : eh;
		jQuery('div.padd-middle-list div#' + id + ' div.post-entry').height(eh);

		height = jQuery(this).height();
		jQuery('div.padd-middle-list div#' + id + ' div.post-comment-count').css('margin-top', -height + 30);
	});
}

function paddPlaceGoToTop() {
	w = jQuery('div.footer-about').width();
	t = jQuery('div.footer-about').position();
	jQuery('div.footer-about div.link-top').css({
		'margin-left': (w - 145),
		'top': (t.top - 29)
	});
}

jQuery(document).ready(function() {
	paddToggle('input#s','Search website');
	paddPlaceCommentCount();
	paddPlaceGoToTop();
	jQuery('div.search form').click(function () {
		jQuery('input#s').focus();
	});
	jQuery('div.menu ul li:last a > span > span').css('background','transparent none');
	jQuery('div.categories ul li:first').css('margin','0');
	jQuery('ul#carousel').jcarousel({
		auto: 6,
		wrap: 'last',
		initCallback: paddCarouselInit
	});
	paddToggle('input#comment-author','Name');
	paddToggle('input#comment-email','Email');
	paddToggle('input#comment-url','Website');
	paddToggle('textarea#comment-comment','Message');
	paddPlaceGoToTop();
});

