$(function() {	
	
	var galleries = $('.ad-gallery').adGallery();
	
	$('#switch-effect').change(
		function() {
			galleries[0].settings.effect = $(this).val();
			return false;
		}
	);
	
	$('#toggle-slideshow').click(
		function() {
			galleries[0].slideshow.toggle();
			return false;
		}
	);
	
	$('#toggle-description').click(
		function() {
			if(!galleries[0].settings.description_wrapper)
			{
				galleries[0].settings.description_wrapper = $('#descriptions');
			} 
			else 
			{
				galleries[0].settings.description_wrapper = false;
			}
			return false;
		}
	);
});
		
$(document).ready(function() {

	/* show loginVenster when #showPopup is clicked */
	$('#showPopup').live('click', function(){
		showLoginVenster();
		return false;
	});
	
	/* show popup when .specs_button is clicked */
	$(".specs_button").click(function() {
		showPopup(this);
		return false;
	});
});

var visibility = false;

/* showLoginVenster() */
function showLoginVenster(){
	if(visibility != true){
		$('#loginVenster').show("slide", { direction: "up" }, 800);
		visibility = true;
	}
};

/* hideLoginVenster()*/
function hideLoginVenster() {
	if(visibility != false){
		$('#loginVenster').hide("slide", { direction: "up" }, 300);
		visibility = false;
	}
};

function showPopup(currentA) 
{
	/*create popup dynamically*/
	$("body").append("<div class='popupBackground' onclick='closePopup();'></div>");
	$("body").append("<div class='popupWindow' style='display:none'>" +
						"<img alt='' src='" + $(currentA).children("img").attr("src") +"' />" +
						"<h5>" + $(currentA).children("h5").html() + "</h5>" +
						"<p>" + $(currentA).children("p").html() + "</p>" +
						"<div class='popup_Knoppen' onClick='closePopup()'></div>" +
					"</div>");	
	/*disable scrollbars*/
	$("body").css("overflow", "hidden");
	/*fade in the popupWindow*/
	$('.popupWindow').fadeIn('500');
}

function closePopup() 
{
	/* remove the popup */
	$(".popupBackground").fadeOut('1000');
	$('.popupWindow').fadeOut('1000');
	
	/*enable the scrollbars*/
	$("body").css("overflow", "visible");
}
