/*
$(document).ready(function()	{

	$(".productdetail_img").bind('click', function() {

		var img = $(".productdetail_img img").attr("src");

		showPopupImage('info', getPopupImageContents(img));

	});

	$(".auctiondetail_img").bind('click', function() {

		var img = $(".auctiondetail_img img").attr("src");

		showPopupImage('info', getPopupImageContents(img));

	});


})
*/

/* maakt inhoud voor popup box */
function getPopupImageContents(img) {

	src = resizeImageLink(img);

	var contents = '<div id="popup"></div>'
	+ 	'<div id="popupcontents">'
	+ 	'<a class="button_popup" onclick="$.modal.close();" href="Javascript:void(0)">Close</a>'
	+ 		'<img src="' + src + '">'
	+ 	'</div>'

	return contents;

}

/* wijzigt de links met afmetingen voor de popup */
function resizeImageLink(img) {

	pos = img.lastIndexOf('/');
	src = '/media/480x360' + img.substring(pos);

	return src;

}

function showPopupImage(elementName,contents){

	var element = document.getElementById(elementName);

	$.modal(contents ,{

    	minHeight:17,
		containerCss:{backgroundColor:"#fff",height:360,padding:0,width:480},

		onOpen: function(dialog)
		{
			dialog.overlay.fadeIn('fast', function () {
				dialog.container.slideDown('normal', function () {
					dialog.data.fadeIn('normal');

					element.style.visibility = 'visible';


				});
			});
		},
		onClose: function(dialog)
		{
			dialog.overlay.fadeOut('fast', function () {
				dialog.container.fadeOut('fast', function () {
					dialog.data.fadeOut('fast', function () {

						$.modal.close(); // must call this!

						});
					});
				});

		}

	});
}

function showLoginError(elementName){


	var element = document.getElementById(elementName);

	$.modal($(element),{

    	minHeight:17,
		containerCss:{backgroundColor:"#fff",height:130,padding:0,width:322},

		onOpen: function(dialog)
		{
			dialog.overlay.fadeIn('fast', function () {
				dialog.container.slideDown('normal', function () {
					dialog.data.fadeIn('normal');

					element.style.visibility = 'visible';


				});
			});
		},
		onClose: function(dialog)
		{
			dialog.overlay.fadeOut('fast', function () {
				dialog.container.fadeOut('fast', function () {
					dialog.data.fadeOut('fast', function () {

						$.modal.close(); // must call this!
						$("#klantLoginFoutMeldingen").remove(); // and this too!

						});
					});
				});

		}

	});
}

