knsp = {}

knsp.like = {}

knsp.like.like = function(postId) {
	if(jQuery('#like-button-' + postId + ' img').attr('src') == '/wp-content/themes/flirt/images/like-grey.png') {
		return;
	}
	
	nameCnf = '#like-confirmation-' + postId;
	posBtn = jQuery('#like-button-' + postId).position();
	
	// ajax machen
	 jQuery.post('/wp-content/plugins/knspr-like/knspr-like.php', {
		'postId': postId
	}, function(data) {
		jQuery('#like-count-' + postId).html(data);
	});
	
	
	jQuery(nameCnf).css('position', 'absolute');
	jQuery(nameCnf).css('top', posBtn.top);
	jQuery(nameCnf).css('left', posBtn.left);
	jQuery(nameCnf).css('display', 'block');
	jQuery(nameCnf).css('opacity', '0');
	jQuery(nameCnf).animate({'opacity': 1, 'top': posBtn.top - 50}, 500).fadeOut();
	
	jQuery('#like-button-' + postId + ' img').attr('src', '/wp-content/themes/flirt/images/like-grey.png');
}

knsp.flickr = {}
knsp.flickr.show = function(elem, url) {
	jQuery('#flickr-image-popup').stop(true, true);
	jQuery('#flickr-image-popup img').attr('src', '/wp-content/themes/knspr/images/ajax-loader.gif');
	jQuery('#flickr-image-popup img').attr('src', url);
	
	thumbpos = jQuery(elem).position();
	
	_top = thumbpos.top + 80;
	_left = thumbpos.left - (jQuery('#flickr-image-popup').width()/2);
	
	jQuery('#flickr-image-popup').css('position', 'absolute').css('top', _top).css('left', _left);
	jQuery('#flickr-image-popup').fadeIn();
	
}

knsp.flickr.hide = function() {
	jQuery('#flickr-image-popup').stop(true, true).fadeOut();
}

knsp.reviews = {}
knsp.reviews.loadCategory = function(categoryId) {
	jQuery('#review-list').html('<img src="/wp-content/themes/knspr/images/ajax-loader.gif" style="display: block; margin: auto;"/>');

	 $.post('/wp-content/plugins/knspr-reviews/reviews-ajax.php', {
		'categoryId': categoryId
	}, function(data) {
		jQuery('#review-list').html(data);
	});
}

