	function show_photo_xl(photo_src) {
		//photo_src = photo_src.replace(/Photos/, "PhotosXL");
		photo_src = photo_src.replace(/Icons/, "PhotosXL");
		prepare_modal_layout('<div style="position: relative; margin: 10px; overflow: hidden;"><table id="photos_xl_nav" style="position: absolute; top: 0; left: 0; z-index: 99999; width: 100%; height: 100%; background-color: none;"><tr><td style="width: 33%; vertical-align: middle; text-align: center;" id="photos-prev"><img src="/graphics/spacer.gif" style="height: 100%; width: 100%; background: url(/graphics/prev.png) center center no-repeat;" alt="" /></td><td style="width: 33%; vertical-align: middle; text-align: center;" id="photos-play"><img src="/graphics/spacer.gif" style="height: 100%; width: 100%; background: url(/graphics/play.png) center center no-repeat;" alt="" /></td><td style="width: 33%; vertical-align: middle; text-align: center;" id="photos-next"><img src="/graphics/spacer.gif" style="height: 100%; width: 100%; background: url(/graphics/next.png) center center no-repeat;" alt="" /></td></tr></table><img src="/graphics/spacer.gif" alt="" style="position: absolute; top: 0px; left: 0px; z-index: 99998; width: 60px; height: 60px; opacity: 0.0;" id="photo_xl_prev" /><img src="/graphics/spacer.gif" alt="" id="photo_xl" style="width: 60px; height: 60px; opacity: 0.0;" /></div>');
		$("#photos_xl_nav td").css({'opacity' : '0.0'});
		$("#photos_xl_nav td").mouseenter(function () { $(this).css({opacity: "1.0"}); $(this).css({cursor: 'pointer'}); });
		$("#photos_xl_nav td").mouseleave(function () { $(this).css({opacity: "0.0"}); });
		$("#photos_xl_nav td").eq(0).unbind('click');
		$("#photos_xl_nav td").eq(1).unbind('click');
		$("#photos_xl_nav td").eq(2).unbind('click');
		$("#photos_xl_nav td").eq(0).click(function () {stop_slideshow_xl(); prev_photo_xl()});
		$("#photos_xl_nav td").eq(1).click(function () {start_slideshow_xl()});
		$("#photos_xl_nav td").eq(2).click(function () {stop_slideshow_xl(); next_photo_xl()});
		$("#photo_xl_prev").css({'opacity' : '0.0', 'width' : '60px', 'height' : '60px'});
		$("#photo_xl").css({'opacity' : '0.0', 'width' : '60px', 'height' : '60px'});
		setTimeout(function() {set_photo(photo_src)}, 500);
    };
	
	function next_photo_xl() {
		photo_src = $("#photo_xl").attr('src');
		//alert(photo_src);
		photo_src = photo_src.replace(/PhotosXL/, "Icons");
		var i = 1;
		for (i = 1; i < $("#photos-list a img").length; i++) {
			if ($("#photos-list a img").eq(i-1).attr('src') == photo_src) {
				set_photo($("#photos-list a img").eq(i).attr('src').replace(/Icons/, "PhotosXL"));
			}
		}
	}
	
	function prev_photo_xl() {
		photo_src = $("#photo_xl").attr('src');
		photo_src = photo_src.replace(/PhotosXL/, "Icons");
		var i = 0;
		for (i = 0; i < ($("#photos-list a img").length - 1); i++) {
			if ($("#photos-list a img").eq(i+1).attr('src') == photo_src) {
				set_photo($("#photos-list a img").eq(i).attr('src').replace(/Icons/, "PhotosXL"));
			}
		}
	}
	
	function set_photo(photo_src) {
		var photo_file = new Image;
		$(photo_file).unbind('load');
		$(photo_file).bind('load', function () {
			$("#photo_xl_prev").attr('src', $("#photo_xl").attr('src'));
			$("#photo_xl_prev").css({'opacity' : '1.0'});
			$("#photo_xl").attr('src', photo_src);
			$("#photo_xl").css({'opacity' : '0.0'});
			$("#photos_xl_nav").css({'width' : photo_file.width + 'px', 'height' : photo_file.height + 'px'});
			$("#photos_xl_nav td").css({'height' : photo_file.height + 'px'});
			$("#photo_xl").animate({'width' : photo_file.width + 'px', 'height' : photo_file.height + 'px', 'opacity' : '1.0'}, 500);
			$("#photo_xl_prev").animate({'width' : photo_file.width + 'px', 'height' : photo_file.height + 'px', 'opacity' : '0.0'}, 500);
			$("#modal_window").animate({'width' : (photo_file.width + 20) + 'px', 'height' : (photo_file.height + 20) + 'px', 'marginLeft' : '-' + Math.floor((photo_file.width + 20) / 2) + 'px'}, 500);
		});
		photo_file.src = photo_src;
	}

	var intval_xl = "";

	function start_slideshow_xl() {
		if (intval_xl == "") {
			$("#photos_xl_nav td").eq(1).children("img").css("background", "url(/graphics/pause.png) center center no-repeat");
			intval_xl = setInterval("next_photo_xl()", 3000);
		} else {
			stop_slideshow_xl();
		}
	}

	function stop_slideshow_xl () {
		if (intval_xl != "") {
			$("#photos_xl_nav td").eq(1).children("img").css("background", "url(/graphics/play.png) center center no-repeat");
			clearInterval(intval_xl);
			intval_xl = "";
		}
	}

    function prepare_modal_back () {
		var modal = document.createElement('div');
        modal.id = 'modal';
        modal.style.zIndex = '9999';
        modal.style.position = 'absolute';
		modal.style.zoom = '1';
        modal.style.left = '0px';
        modal.style.top = '0px';
        modal.style.width = $(window).width() + 'px';
        modal.style.height = $(window).height() + 'px';
        modal.style.height = $(document).height() + 'px';
        modal.style.opacity = '0.85';
        modal.style.filter = 'alpha(opacity = 85)';
        modal.style.backgroundColor = '#000000';
        modal.style.display = 'none';
		
		return modal;
	}

    function prepare_modal_window (inner_html) {
		var modal_window = document.createElement('div');

        modal_window.id = 'modal_window';
        modal_window.style.zIndex = '99999';
        modal_window.style.position = 'absolute';
        modal_window.style.left = '50%';
        modal_window.style.marginLeft = '-40px';
//        modal_window.style.top = Math.floor((parseInt($(window).scrollTop())+665*2+100)) + 'px';
        modal_window.style.top = 50 + 'px';
        modal_window.style.width = '80px';
        modal_window.style.height = '80px';
        modal_window.style.backgroundColor = '#222222';
        modal_window.style.webkitBoxShadow = '0px 0px 40px #000000';
        modal_window.style.webkitBorderRadius = '10px';
        modal_window.style.MozBoxShadow = '0px 0px 40px #000000';
        modal_window.style.MozBorderRadius = '10px';
        modal_window.style.boxShadow = '0px 0px 40px #000000';
        modal_window.style.borderRadius = '10px';
		if (navigator.userAgent.toLowerCase().indexOf('msie') > -1) {
        	modal_window.style.border = '2px solid #333333';
		}
        modal_window.style.display = 'none';

        modal_window.innerHTML = inner_html;

		return modal_window;
    }

    function prepare_modal_layout (inner_html) {
		var _body;
	
		var modal;
		var modal_window;
	
		_body = document.getElementsByTagName('body')[0];
		
		modal = prepare_modal_back();
		modal_window = prepare_modal_window(inner_html);

        _body.appendChild(modal_window);
        _body.appendChild(modal);
		
        $(modal).click(function(){
			stop_slideshow_xl();
			var photo_src = $("#photo_xl").attr('src').replace(/PhotosXL/, 'Icons');
			var i = 0;
			for (i = 0; i < $("#photos-list a").length; i++) {
				if ($("#photos-list a").eq(i).children("img").attr('src') == photo_src) {
					choosePhoto($("#photos-list a").eq(i).children("img"));
				}
			};
            $(modal).remove();
            $(modal_window).remove();
        });
		
/*        $(modal_window).click(function(){
            $(modal).remove();
            $(modal_window).remove();
        });*/
		
		$(modal).show();
		$(modal).css({'opacity': '0.0'});
		$(modal).animate({'opacity': '0.85'});
		$(modal_window).show();
		$(modal_window).css({'opacity': '0.0', 'top': '30px'});
		$(modal_window).animate({'opacity': '1.0', 'top': '50px'});
    }

