﻿﻿$(document).ready(function(){

	$('#s').focus(function() {
		var value = $(this).val();
		$(this).val('');
		$(this).attr('data-value', value);
	});
	
	$('#s').blur(function() {
		if ($(this).val() == '') {
			var value = $(this).attr('data-value');
			$(this).val(value);
		}
	});

	$('.showMore').click( function() {
		$(this).css('display', 'none');
		$(this).parent().parent().find('.hidden').fadeIn('fast');
		return false;
	});
	
	$('#see_more').click(function() {
		var page = parseInt($(this).attr('data-page'));
		var year = parseInt($(this).attr('data-year'));
		var month = parseInt($(this).attr('data-month'));
		var tag = parseInt($(this).attr('data-tag'));

		$.ajax({
			type: 'POST',
			url: 'http://' + window.location.host + '/getAjaxPosts',
			data: 'page=' + page + '&year=' + year + '&month=' + month + '&tag=' + tag,
			success: function(html){
				$(html).appendTo('#posts');
				$('#see_more').attr('data-page', page + 1);
				if (html.search('xxxxxx') != -1) {
					$('#see_more').css('display', 'none');
				}
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){
				alert("Error: " +textStatus);
			}
		});
		return false;
	});
	

	
	$('.reportAbuse').click(function() {
		$(this).css('display', 'none');
	});
	
});

