
function initPager() {
	$('.tx_iofotostrecke_pi1_single a.next, .tx_iofotostrecke_pi1_single a.prev').click(function() {
		var ajaxUrl = $(this).attr('href');
		$.getJSON(
			ajaxUrl,
			{
				'tx_iofotostrecke_pi1[ajax]': 1
			},
			function(data) {
				showPic(data);
			}
		);
		return false;
	});
	$('.tx_iofotostrecke_pi1_single .itemImage img').click(function() {
		$('.tx_iofotostrecke_pi1_single a.next').click();
	});
}

function initTeaser() {
	if ($('.tx_iofotostrecke_pi1_teaser').length > 0) {
		window.setTimeout('showNextPic()', 3000);
	}
	$('.tx_iofotostrecke_pi1_teaser a.next, .tx_iofotostrecke_pi1_teaser a.prev').click(function() {
		location.href = $('.tx_iofotostrecke_pi1_teaser .itemImage a').attr('href');
		return false;
	});
}

function tx_ratings_submit(id, rating, ajaxData, check) {
	$('#tx-ratings-display-' + id).hide();
	$('#tx-ratings-wait-' + id).show();
	$('#tx-ratings-' + id).load(
		'index.php?eID=tx_ratings_ajax',
		{
			'ref': id,
			'rating': rating,
			'data': ajaxData,
			'check': check
		}
	);
}

function showNextPic() {
	var ajaxUrl = $('.tx_iofotostrecke_pi1_teaser a.next').attr('href');
	if (ajaxUrl == 'undefined') {
		ajaxUrl = $('.tx_iofotostrecke_pi1_teaser a.prev').attr('href');
	}
	if (ajaxUrl != 'undefined') {
		$.getJSON(
			ajaxUrl,
			{
				'tx_iofotostrecke_pi1[ajax]': 1,
				'tx_iofotostrecke_pi1[action]': 'teaser'
			},
			function(data) {
				$('.tx_iofotostrecke_pi1_teaser .itemImage a').empty().append(data.item_image);
				$('.tx_iofotostrecke_pi1_teaser .itemContent').empty().append('<p>'+data.item_title+'</p>');
				$('.tx_iofotostrecke_pi1_teaser .pager').empty().append(data.pager);
				initTeaser();
			}
		);
	}
}

function showPic(data) {
	$('.tx_iofotostrecke_pi1_single .itemImage').empty().append(data.item_image);
	$('.tx_iofotostrecke_pi1_single .itemContent').empty().append('<p>'+data.item_title+'<br/>'+data.item_description+'</p>');
	$('.tx_iofotostrecke_pi1_single .pager').empty().append(data.pager);
	initPager();
}

$(document).ready(function() {
	initPager();
	initTeaser();
});



