﻿/* layer */
function bl_send_contactform() {
    if ( $('#Name').val() == "" && $("#mail").val() == "" && $("#privacy").val() == "") {
        return false;
    } else {
        document.contactform.submit();
    }
}
$.fn.serializeObject = function() {
    var o = {};
    var a = this.serializeArray();
    $.each(a, function() {
        if (o[this.name]) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    for (var prop in o) {
        alert(prop + ": " + o[prop]);
    }
    return o;
};

$(document).ready(
    function(){
        //$('body').supersleight();
        $('.tabs').tabs(
            {
                fx: {
                    opacity: 'toggle',
                    duration:'normal'
                }
            }
        );
        //alle absoluten URIs im extra Fenster öffnen
        $("a[href^='http'],area[href^='http']").click(
            function () {
                this.target = "_blank";
            }
        );
        $('.closeLayer').click($.unblockUI);
        // contactlayer
        $('.ServiceCenter .SiteTools .Contact A').click(
            function() {
                $.blockUI(
                    {
                        message: $('#contactlayer'),
                        fadeIn: 700, 
                        fadeOut: 700,
                        css: {
                            border: 'none',
                            backgroundColor: '',
                            cursor: 'auto',
                            top: '80px',
                            left: ($(window).width() - $('#contactlayer').width()) / 2 + 'px',
                            position: 'absolute'
                        }
                    }
                );
                $('.blockOverlay').css("cursor", "default").click($.unblockUI);
                return false;
            }
        );
        // orderlayer
        $('.ServiceCenter .SiteTools .Order A').click(
            function() {
                $.blockUI(
                    {
                        message: $('#orderlayer'),
                        fadeIn: 700, 
                        fadeOut: 700,
                        css: {
                            border: 'none',
                            backgroundColor: '',
                            cursor: 'auto',
                            top: '80px',
                            left: ($(window).width() - $('#orderlayer').width()) / 2 + 'px',
                            position: 'absolute'
                        }
                    }
                );
                $('.blockOverlay').css("cursor", "default").click($.unblockUI);
                return false;
            }
        );

        $('.ServiceCenter .SiteTools .Print A').click(
            function () {
                window.print();
            }
        );
        $("DIV.shadowboxLoupe").click(
            function () {
                $("A[rel^=shadowbox]", $(this).parent()).click();
            }
        );
        

    }
);
$(window).load(
    function(){
        // ContentImages in Content with caption / legend needs a width fix
        // found @http://www.blogrammierer.de/jquery-bildbreite-ermitteln-um-bildunterschriften-korrekt-darzustellen/
        $(".BoxImage").each(
            function(){
                var width = $(this).children("IMG").width() || $(this).children("A").children("IMG").width();
                $(this).css("width", width);
                $(this).children("SPAN").css("width", width - $(this).children("DIV.fancybox").width() - 1);
            }
        );
        $(".ContentImage,").each(
            function(){
                if (!$(this).hasClass("FullWidth")) {
                    var width = $(this).children(".ContentImageWrapper").children("IMG").width() || $(this).children(".ContentImageWrapper").children("A").children("IMG").width();
                    $(this).css("width", width);
                    $(this).children("SPAN").css("width", width - $(this).children("DIV.shadowboxLoupe").width() - 1);
                } else {
                    $(this).css("width", "100%");
                    var width = $(this).children(".ContentImageWrapper").children("IMG").width() || $(this).children(".ContentImageWrapper").children("A").children("IMG").width();
                    $(this).children("SPAN").css("width", width - $(this).children("DIV.shadowboxLoupe").width() - 1);
                }
            }
        );
        $(".BoxImage").each(
            function () {
                var width = $(this).width();
                $(this).children("SPAN").css("width", width - $(this).children("DIV.shadowboxLoupe").width() - 1);                
            }
        );
    }
);
