// JavaScript Document
 $.noConflict();
jQuery(document).ready(function($) {


    // add pl-classes in subNav
    $('.subNavProd span.target').each(function(i) {
        var id = $(this).attr('id');
        $(this).parent().addClass(id);
    })

    // $('.page').append('<div class="devgrid"></div>');
    // $('.devgrid').css('opacity', 0.5).click(function() {
    //         $(this).toggleClass("short");
    //     });
    $('table.jbEdtOverview td').filter(':contains(ja)').wrapInner('<span />').addClass('yes');
    $('table.jbEdtOverview td').filter(':contains(nein)').wrapInner('<span />').addClass('no');

    //===================================================
    // expand content col
    // $('#col3_content .ssl').addClass('clearfix');
    // $('#col3_content .ssr').addClass('clearfix');
    // $('#col3_content .ceHg2').addClass('clearfix');
    // $('#col3_content .ceHg1').addClass('clearfix');
    //===================================================
    // adjust iFrame height
    // var calcH = 0;
    // var hasH = 0;
    // var tarH = 0;
    // if ($("#myIframe")) {
    //
    //     // find current website language
    //     var lngMarker = $('#lngMarker').text();
    //     if (lngMarker == 'EN') {
    //         // german
    //         var myHint = "<p id='myHint'><strong>Please wait, while the shopping cart is loading ...</strong></p>";
    //     } else {
    //         // english
    //         var myHint = "<p id='myHint'><strong>Bitte warten, der Warenkorb wird geladen ...</strong></p>";
    //     }
    //     // hide iFrame
    //     $("#myIframe").hide();
    //     // display loading-hint
    //     $("#myIframe").before(myHint);
    //
    //     var window_height = $(window).height() - 20;
    //     var page_height = $('.page').height();
    //     var addHeight = window_height - page_height;
    //     var ceHg1_height = $('.ceHg1').height();
    //
    //     if (window_height > page_height) {
    //         var ceHg1_height_new = ceHg1_height + addHeight;
    //         $('.ceHg1').height(ceHg1_height_new);
    //     }
    //
    //     $("#myIframe").load(function() {
    //         $("#myHint").hide();
    //         $('#col3_content .subcolumns').each(function(i) {
    //             calcH += $(this).height();
    //         })
    //         hasH = $('#col3_content .ceHg1').height();
    //         tarH = hasH - calcH;
    //         $('#col3_content iframe').attr('height', tarH).show();
    //     });
    // }
    //remove empty subNav
    var snChildren = $('#subNav .subNavStd ul li').length;
    if (snChildren == 0) {
        $('#subNav .subNavStd_st').hide()
        $('#subNav .subNavStd').hide()
        $('#subNav .subNavStd_sb').hide()
    }
    
    // hide emtpy rows which have sub
    $('#col3_content .subcolumns .sub').each(function(i){
        var snChildrenRow1 = $(this).children().length;
        if (snChildrenRow1 == 0) {
            $(this).parent().hide();
        }
    })
    
    // hide emtpy subcolumns in subcolumns
    $('#col3_content .subcolumns .subcolumns').each(function(i){
        var snChildrenRow1 = $(this).children().length;
        if (snChildrenRow1 == 0) {
            $(this).hide();
        }
    })
    
    
    // same height for cols in corp
    // var cslh = $('.lay3 .subcolumns .subcl').height();
    //  var csrh = $('.lay3 .subcolumns .subcr').height();
    //  if (cslh > csrh) {
    //      $('.lay3 .subcolumns .subcr').height(cslh);
    //  }
    // same height for cols in corp
    // var cslhx = $('.lay2 .subcolumns .subcolumns .subcl').height();
    //     var csrhx = $('.lay2 .subcolumns .subcolumns .subcr').height();
    //     if (cslhx > csrhx) {
    //         $('.lay2 .subcolumns .subcolumns .subcr').height(cslhx);
    //     }
    // same height for cols in corp
    var cslhy = $('.subcl.bordered').height();
    var csrhy = $('.subcr.bordered').height();
    if (cslhy > csrhy) {
        $('.subcr.bordered').height(cslhy);
    }

    //--- featureTour overview
    var h = 0;
    var h1 = 0;
    var h2 = 0;
    var s = true;
    var j;
    var k;
    $('.tx-jppageteaser-pi1 .itm').each(function(i) {

        //console.info(i)

        if (s) {
            h1 = $(this).height();
            //console.info(h1);
            h2 = $(this).next().height();
            //console.info(h2);
            if (h1 > h2) {
                h = h1;
            } else {
                h = h2;
            }
            $(this).height(h).addClass('even');
            $(this).next().height(h);
            h = 0;
            h1 = 0;
            h2 = 0;
            s = false;
            j = i
        } else {
            s = true;
        }
        k=i;
    })

    $('.tx-jppageteaser-pi1 .itm').eq(j).addClass('lastRow');
    $('.tx-jppageteaser-pi1 .itm').eq(k).addClass('lastRow');
})
jQuery(document).ready(function($) {

    /*------------------------------------------------------------------------------------------------------*/
    /* browser detection */
    var client = parseInt(jQuery.browser.version);

    if ($.browser.msie && client <= 6) {
        // nothing
        } else {

        // layout helper + click hide on a
        $('#mainNav a').wrapInner('<span />').click(function() {
            $('#mainNav ul.l1').hide();
        })
        // layout exceptions
        $('#mainNav li.sT').next().children('a').css('padding-top', 0);
        $('#mainNav li.sT').next().children('ul').css('top', -3);
        $('#mainNav li.sB').prev().css('border', 'none').children('a').css('padding-bottom', 0);

        // ie7 layout helper (ie7 stack bug)
        if ($.browser.msie && client == 7) {
            $("#mainNav li").filter(":not('.sT')").filter(":not('.sB')").mouseenter(function() {
                $(this).css('position', 'relative').css('z-index', 3000);
            }).mouseleave(function() {
                $(this).css('position', '').css('z-index', '');
            })
        }

        /*------------------------------------------------------------------------------------------------------*/
        /* honor viewport */
        var slotX1 = 0;
        var slotX2 = 0;
        var ulLeftNew = -1;
        var ulRightNew = -1;
        var ulLeft;
        var ulRight;        

        $('#mainNav li').mouseenter(function() {

            // reset honor viewport position
            $(this).children('ul').css('left', '');

            // only remove class flyUnder if parent has not moved over
            if (!$(this).parent().hasClass('movedOver')) {
                $('#mainNav ul.l1.flyUnder').removeClass('flyUnder');
            }

            // reset parent movedOver switch
            $(this).children('ul.movedUnder').removeClass('movedOver');

            // reset honor viewport position
            ulLeftNew = 0;

            ulRightNew = 0;
            var tar = $(this).children('ul').eq(0);

            // need show() for ie to calculate layout-position, ie calculate fix
            tar.show();
            var offTar = tar.offset();
            var ulLeft = offTar.left;
            var ulRight = ulLeft + tar.width();
            // console.info(ulLeft, '-----------------');
            // remember slot on l1
            if ($(this).parent().hasClass('l0')) {
                slotX1 = ulLeft - 2;
                slotX2 = ulRight + 2;
            }
            // console.info(slotX1, ' x1');
            // console.info(slotX2, ' x2');
            // remove ie calculate fix
            tar.css('display', '');

            var vpw = $(window).width() + 10;
            // honor shadowBox, we have more space
            // console.info(vpw, ' vpw');
            // if viewport is to small and we are not on first level
            if (ulRight > vpw && !$(this).children('ul').hasClass('l1')) {
                tar.css('left', -210);
                // -208
            }
            // dimm underlayed
            var tarNew = $(this).children('ul').eq(0);

            tarNew.show();
            var offTarNew = tarNew.offset();
            var ulLeftNew = offTarNew.left;
            // console.info(ulLeftNew, '   ulLeftNew');
            var ulRightNew = ulLeftNew + tarNew.width();
            // console.info(ulRightNew, '   ulRightNew');
            tarNew.css('display', '');
            if (ulLeftNew >= slotX1 && ulRightNew <= slotX2 && !$(this).parent().hasClass('l0')) {
                $('#mainNav ul.l1').addClass('flyUnder');
                tar.addClass('movedOver');
            }
        });

        /*------------------------------------------------------------------------------------------------------*/
        /* dimm content */


        $('.page').append('<div id="flyoutDimm"></div>');
        $('#flyoutDimm').hide();

        $('#mainNav > ul.l0 > li.hasSub').mouseenter(function() {
            // dimm
            var h = $('.page').height();
            // var off = $('.page').offset();
            // var top = off.top;
            // var diff = top - 155;
            // var vph = $(window).height();
            h = h - 182;
            // if (h < vph) {
            //                 h = vph - 155;
            //             }
            $('#flyoutDimm').height(h);
            $('#flyoutDimm').stop().fadeTo(500, 0.7);
            $('#mainNav').addClass('doFly');
            // ie hack for swf-stack-bug
            //if ($.browser.msie) {
                $('object').css('visibility', 'hidden');
                $('object').parent().css('background', '#eee');
            //}
        })

        $('#mainNav').mouseleave(function() {
            // unDimm
            $('#flyoutDimm').stop().fadeOut(500,
            function() {
                // ie un-hack for swf-stack-bug
                //if ($.browser.msie) {
                    $('object').css('visibility', '');
                //}
            });

            $('#mainNav').removeClass('doFly');
        })

        $('#mainNav li.home').mouseenter(function() {
            // unDimm
            $('#flyoutDimm').stop().fadeOut(500,
            function() {
                // ie un-hack for swf-stack-bug
                //if ($.browser.msie) {
                    $('object').css('visibility', '');
                //}
            });

        })
    }

})
jQuery(document).ready(function($) {

    // button wrapping/unwrapping and classes
    $('#col3 p.csc-frame-frame1 a').wrapInner('<span />');
    $('#col3 p.csc-frame-frame2 a').wrapInner('<span />');
    $('#col3 p.csc-frame-frame1').wrap('<div class="buttonRow buttonBig" />').wrap('<div class="buttonRowInner " />').children().unwrap()
    $('#col3 p.csc-frame-frame2').wrap('<div class="buttonRow buttonSmall" />').wrap('<div class="buttonRowInner " />').children().unwrap()

    // insert clearing
    $('<div class="cf" />').insertAfter('.buttonRow');

    // remove unwanted non breaking white spaces
    var t = new Array();
    var z = new Array();
    $('.buttonRowInner').each(function(i) {
        t[i] = $(this).html();
        z[i] = t[i].replace("&nbsp;", ' ');
        $(this).html(z[i]);
    })

    // add button classes
    $('#col3 div.buttonRow a').filter(':contains(aufen)').wrapInner('<span />').addClass('buyDe');
    $('#col3 div.buttonRow a').filter(':contains(penden)').wrapInner('<span />').addClass('donateDe');
    $('#col3 div.buttonRow a').filter(':contains(ownload)').wrapInner('<span />').addClass('download');
    $('#col3 div.buttonRow a').filter(':contains(eatures)').wrapInner('<span />').addClass('features');
    $('#col3 div.buttonRow a').filter(':contains(uy)').wrapInner('<span />').addClass('buyEn');
    $('#col3 div.buttonRow a').filter(':contains(onate)').wrapInner('<span />').addClass('donateEn');
    $('#col3 div.buttonRow a').filter(':contains(etail)').wrapInner('<span />').addClass('details');

})
