$(document).ready(function () {
    setup_ezfancy();
});

function setup_ezfancy() {
	
	$("a.lightbox_640").fancybox({
        titlePosition: "inside",
        showCloseButton: true,
		width: 640,
		height: 480,
        zoomOpacity: true,
        zoomSpeedIn: 300,
        zoomSpeedOut: 300,
        overlayShow: true,
        easingIn: "easeOutBack",
        easingOut: "easeInBack",
        type: 'iframe',
		scrolling: "no",
		autoScale: false,
		autoDimensions: false
    });
	
    $("a[data-ezq-type=fancy]").fancybox({
        titlePosition: "inside",
        showCloseButton: false,
        zoomOpacity: true,
        zoomSpeedIn: 300,
        zoomSpeedOut: 300,
        overlayShow: true,
        easingIn: "easeOutBack",
        easingOut: "easeInBack",
        titleFormat: fancyFormatTitleMultiLine
    });

    $('a.fancy-youtube').fancybox({
        titlePosition: "inside",
        showCloseButton: false,
        zoomOpacity: true,
        zoomSpeedIn: 300,
        zoomSpeedOut: 300,
        overlayShow: true,
        easingIn: "easeOutBack",
        easingOut: "easeInBack",
        titleFormat: fancyFormatTitleMultiLine,
        width: 853,
        height: 505,
        autoScale: false,
        type: 'swf',
        'swf': {
            'wmode': 'transparent',
            'allowfullscreen': true
        }
    });

	// Configurator
	$("a.stationconfig").fancybox({
        width: 908,
        height: 586,
        autoScale: false,
        showCloseButton: true,
        zoomOpacity: true,
        zoomSpeedIn: 300,
        zoomSpeedOut: 300,
        overlayShow: true,
        easingIn: "easeOutBack",
        easingOut: "easeInBack",
        type: "iframe",
		scrolling: "no"
	});

    $("a.directions").fancybox({
        width: 852,
        height: 480,
        autoScale: false,
        showCloseButton: true,
        zoomOpacity: true,
        zoomSpeedIn: 300,
        zoomSpeedOut: 300,
        overlayShow: true,
        easingIn: "easeOutBack",
        easingOut: "easeInBack",
        type: "iframe"
    });
    $("#news_alert div").fancybox({
        titlePosition: "inside",
        showCloseButton: false,
        zoomOpacity: true,
        zoomSpeedIn: 300,
        zoomSpeedOut: 300,
        overlayShow: true,
        easingIn: "easeOutBack",
        easingOut: "easeInBack",
        type: "html",
        autoDimensions: false,
        width: 700,
        height: "auto",
        content: $("#lgbxCnt p#content").html(),
        title: $("#lgbxCnt p#title").html(),
        titleFormat: fancyFormatTitleMultiLine
    });
}
function fancyFormatTitle(d, c, a, b) {
    return '<div id="fancybox-title-classic"><span><a href="javascript:;" onclick="$.fancybox.close();"><img src="/extension/hwleitner/design/hwleitner/stylesheets/fancybox/close.png" /></a></span>' + (d && d.length ? "<b>" + d + "</b>" : "") + "Bild " + (a + 1) + " von " + c.length + "</div>";
}
function fancyFormatTitleMultiLine(d, c, a, b) {
    d = d.replace(/\[title\]/g, "<strong>");
    d = d.replace(/\[\/title\]/g, "</strong><br />");
    d = d.replace(/\[div\]/g, "<div class='break'>");
    d = d.replace(/\[\/div\]/g, "</div>");
    d = d.replace(/\[br\/\]/g, "<br/>");
    d = d.replace(/\[strong\]/g, "<strong>");
    d = d.replace(/\[\/strong\]/g, "</strong>");
    d = d.replace(/\[img\](.*?)\[\/img\]/gi, '<img src="$1" />');
    return '<div id="fancybox-title-classic" class="referenceLightbox"><span><a href="javascript:;" onclick="$.fancybox.close();"><img src="/extension/hwleitner/design/hwleitner/stylesheets/fancybox/close.png" /></a></span>' + (d && d.length ? d : "") + "</div>";
}
