var page = 1;

$(document).ready(function()	{
	$('#page_number').html('1');

	$('#left img.page-up').mouseover(function(){
		if ($(this).attr('alt') == "up")	{
			$(this).attr({ src: "/templates/images/left-uparrow_on.png" });
		}
	});
	$('#left img.page-up').mouseout(function(){
		$(this).attr({ src: "/templates/images/left-uparrow_off.png" });
		if ($(this).attr('alt') == "up")	{
			$(this).attr({ src: "/templates/images/left-uparrow.png" });
		}
	});
	$('#left img.page-down').mouseover(function(){
		if ($(this).attr('alt') == "down")	{
			$(this).attr({ src: "/templates/images/left-downarrow_on.png" });
		}
	});
	$('#left img.page-down').mouseout(function(){
		$(this).attr({ src: "/templates/images/left-downarrow_off.png" });
		if ($(this).attr('alt') == "down")	{
			$(this).attr({ src: "/templates/images/left-downarrow.png" });
		}
	});

	/* Move to the previous page */
	$('#left img.page-up').click(function(){
		prev_page = page - 1; /* get previous page number */
		if (prev_page > 1) {	/* if prev_page is higher then 1 (first page) */
			$('#page_'+page).slideUp();	/* hide active page */
			page = page - 1; /* decrease page */
			$('#page_'+page).slideDown();	/* show previous page */
			$(this).attr({ src: "/templates/images/left-uparrow.png" }); /* show ACTIVE image */
			$(this).attr({ alt: "up" }); /* turn on paging this way */
			$('#page_number').html(page); /* show page number */
		}
		else	{	/* if next_page is 1 or less */
			if ( $(this).attr('alt') == 'up' )
			{
				$('#page_'+page).slideUp();	/* hide active page */
				page = 1; /* set page 1 */
				$('#page_'+page).slideDown();	/* show previous page */
			}
			$(this).attr({ src: "/templates/images/left-uparrow_off.png" }); /* show OFF image */
			$(this).attr({ alt: "" }); /* turn off paging this way */
			$('#page_number').html('1'); /* show page number as 1 */
		}

		$('#left img.page-down').attr({ src: "/templates/images/left-downarrow.png" });
		$('#left img.page-down').attr({ alt: "down" });
	});

	/* Move to the next page */
	$('#left img.page-down').click(function()	{
		next_page = page + 1; /* get next page number */
		if (next_page < pages)	{ /* if next_page is lower then total pages amount */
			$('#page_'+page).slideUp(); /* hide active page */
			page = page + 1; /* increase page */
			$('#page_'+page).slideDown(); /* show next page */
			$(this).attr({ src: "/templates/images/left-downarrow.png" }); /* show ACTIVE image */
			$(this).attr({ alt: "down" }); /* turn on paging this way */
			$('#page_number').html(page); /* show page number */
		}
		else	{ /* if next page is equal or higher then total pages amount */
			if ( $(this).attr('alt') == 'down' )
			{
				$('#page_'+page).slideUp(); /* hide active page */
				page = pages; /* set page as a last */
				$('#page_'+page).slideDown(); /* show next page */
			}
			$(this).attr({ src: "/templates/images/left-downarrow_off.png" }); /* show OFF image */
			$(this).attr({ alt: "" }); /* turn off paging this way */
			$('#page_number').html(page); /* show page number */
		}

		$('#left img.page-up').attr({ src: "/templates/images/left-uparrow.png" });
		$('#left img.page-up').attr({ alt: "up" });
	});

	/* Lista hover */
	$('#aktualniinterpreti').mouseover(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-aktualniinterpreti_hover.png" });
		}
	});
	$('#aktualniinterpreti').mouseout(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-aktualniinterpreti.png" });
		}
	});
	$('#novinky').mouseover(function(){
		$(this).attr({ src: "/templates/images/button-novinky_hover.png" });
	});
	$('#novinky').mouseout(function(){
		$(this).attr({ src: "/templates/images/button-novinky.png" });
	});
	$('#katalog').mouseover(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-katalog_hover.png" });
		}
	});
	$('#katalog').mouseout(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-katalog.png" });
		}
	});
	$('#zadejkod').mouseover(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-zadejkod_hover.png" });
		}
	});
	$('#zadejkod').mouseout(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-zadejkod.png" });
		}
	});
	$('#domaci').mouseover(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-domaci_hover.png" });
		}
	});
	$('#domaci').mouseout(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-domaci.png" });
		}
	});
	$('#zahranicni').mouseover(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-zahranicni_hover.png" });
		}
	});
	$('#zahranicni').mouseout(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-zahranicni.png" });
		}
	});
	$('#kompilace').mouseover(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-kompilace_hover.png" });
		}
	});
	$('#kompilace').mouseout(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-kompilace.png" });
		}
	});
	$('#ozahranicni').mouseover(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-ostatnizahranicni_hover.png" });
		}
	});
	$('#ozahranicni').mouseout(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-ostatnizahranicni.png" });
		}
	});
	$('#dvdzahranicni').mouseover(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-dvdzahranicni_hover.png" });
		}
	});
	$('#dvdzahranicni').mouseout(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-dvdzahranicni.png" });
		}
	});
	$('#jazz').mouseover(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-jazz_hover.png" });
		}
	});
	$('#jazz').mouseout(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-jazz.png" });
		}
	});
	$('#klasika').mouseover(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-klasika_hover.png" });
		}
	});
	$('#klasika').mouseout(function(){
		if ($(this).attr('class') != "active")	{
			$(this).attr({ src: "/templates/images/button-klasika.png" });
		}
	});

});