/* JavaScript Document

--------------------------------
Animal Music
(c) Adam Kudrna 2010
Last edited: 2011-09-01 22:30
--------------------------------

*/



// Initialize
$(document).ready(function () {



/*---------------------------------------------------------------
GENERIC EFFECTS
---------------------------------------------------------------*/

	// External Links & Files
	$('a[href^="http://"], a.file').click(function() {
		this.target="_blank";
	});

	// Animated On-Page Scrolling
	$('a[href^="#"]').not(".slide-toggle-next, .show-toggle-next").click(function() {
		$.scrollTo(this.hash, "slow");
		return false;
	});

	// Fancybox Gallery
	$("a.gallery").fancybox({
		"centerOnScroll": true,
		"hideOnContentClick": true,
		"titleShow": false
	});

	// Custom Title
	/*$("a.play").addClass("popup").append('<span class="title"><span></span></span>');
	$("a.play.popup span.title span").text(this.parents().eq(2).attr("title"));*/

	// Popups
	$(".popup span.title").hide();
	$(".popup").removeClass("css-fx").mouseenter(function() {
		$("span.title", this).fadeIn("fast");
		//$("span.title", this).show("drop"); // rozbity
	}).mouseleave(function() {
		$("span.title", this).fadeOut(500);
		//$("span.title", this).hide("drop");
	});

	// Show Effect
	$('.show-toggle-next').next().hide();
	$('.show-toggle-next').click(function() {
		$(this).toggleClass('selected');
		$(this).next().animate(
			{'height': 'toggle', 'opacity': 'toggle'},
			{duration: 200, queue: true}
		);
		return false;
	});

	// Slide Down Effect
	$(".slide-toggle-next").next().hide();
	$(".slide-toggle-next").toggle(
		function() {
			$(this).addClass("selected").next().show("slide", {direction: "up"}, "normal");
			return false;
		},
		function() {
			$(this).removeClass("selected").next().hide("slide", {direction: "up"}, "slow");
			return false;
		}
	);
		
	// Hide Flash Message
	var delay = 3000;
	setTimeout(function() {
		$('div.flash').hide(2000);
	}, delay);



/*---------------------------------------------------------------
CONTENT-SPECIFIC EFFECTS
---------------------------------------------------------------*/

	// Top Link
	$topLinkMarginRight = parseInt($("#top-link a").css("marginRight"));
	$topLinkBackgroundColor = $("#top-link a").css("backgroundColor");
	$("#top-link a").mouseenter(function() {
		$(this).animate({
			marginRight: "0",
			backgroundColor: "#999"
		}, {queue: false, duration: "fast"});
	}).mouseleave(function() {
		$(this).animate({
			marginRight: $topLinkMarginRight,
			backgroundColor: $topLinkBackgroundColor
		}, {queue: false, duration: 500});
	});

	// Album Previews
	$("a.album-preview span.info").hide();
	$("a.album-preview").removeClass("css-fx").mouseenter(function() {
		$("span.info", this).fadeIn(100); // queue: false to rozbiji
	}).mouseleave(function() {
		$("span.info", this).fadeOut(333);
	});

	// E-shop: Drop-All Confirm
	$('#eshop-drop-all').click(function() {
		if (window.confirm('Opravdu si přejete vysypat celý košík?')) {
			return true;
		} else {
			return false;
		}
	});
	$('#eshop-drop-all-2').click(function() {
		if (window.confirm('Do you really wish to remove all items?')) {
			return true;
		} else {
			return false;
		}
	});

	// Mailing List Subscribe Conditions
	$('.dialog-message').dialog({
		width: 400,
		autoOpen: false,
		//show: 'fade',
		modal: true,
		resizable: false,
		buttons: {
			OK: function() {
				$( this ).dialog('close');
			}
		}
	});
	
	$('#subscribe-conditions-handle').click(function() {
		$('#subscribe-conditions').dialog('open');
		return false;
	});

});

