jQuery(document).ready(function()
{
    jQuery('.external-link-new-window').click(function(){
        theExtenalLink = jQuery(this).attr('href');
        confirmation(theExtenalLink);
        return false;
    });

    jQuery('iframe').attr({
        marginheight:'0',
        marginwidth:'0'
    });

    jQuery('.searchInput').Watermark('Suchen');

    jQuery('a').click(function() {
        jQuery(this).blur();
    });

    $("#mainnavi a").hover(
        function () {
            theRelVal = $(this).attr("rel");
            var tmp = new Array();
            jQuery(".megamenu-"+theRelVal).each(function(c){
                tmp[c] = '<div class="activ-megamenu">'+jQuery(this).html()+'</div>';
                c++;
            });
            if(tmp.length < 1) {
                jQuery(".menuSub").html('');
                jQuery("#"+theRelVal).removeAttr('class');
                jQuery(this).addClass('mnLink');
                jQuery(this).removeClass('mm-item-link');
            } else {
                jQuery(".menuSub").html('');
                jQuery(".menuSub").append(tmp.join(''));
            }
        },
        function () {
            // ...
        }
    );

    jQuery(".megamenu").megamenu();

    if(!isIE6 && !isIE7) {
        $('#fontsizer').jfontsizer({
            applyTo: '#contentArea',
            changesmall: '2',
            changelarge: '2',
            expire: 30
        });
    }

    if($("a[rel='group1']").length)
    {
        $(".grouped_elements").click(function()
        {
            $("a[rel='group1']").colorbox({
                slideshow:true,
                slideshowSpeed:4000,
                current:"Bild {current} von {total}",
                previous:"zurück",
                next:"vor",
                close:"schließen"
            });
        });
    }

    $('#loginInit').click(function()
    {
        $.colorbox({
            innerWidth:'600px',
            innerHeight:'400px',
            iframe:true,
            href:"http://www.frankgruppe.de/login/?type=55",
            close:"schließen"
        });
    });

    $("#spalte3 a[class='internal-link']").css({
        border:"0px solid #FF0000"
    });

    $("#spalte3 a[class='internal-link']").wrap("<div class=\"moreLinkWrap\"></div>");

    if(!isIE6 && !isIE7) {
        $('.section_frame_20 a img').each(function(i){
            thisImgHref = $(this).parent('a').attr('href');
            thisParentObj = $(this).parent('a');
            $(thisParentObj).addClass('suscImgLayer');
            $(thisParentObj).attr('href','javascript:void(0);');
            $(thisParentObj).attr('rel',thisImgHref);
        });
    } else {
    $('.section_frame_20 a img').click(function()
    {
            thisImgHref = $(this).parent('a').attr('href');
            thisParentObj = $(this).parent('a');
            $(thisParentObj).addClass('suscImgLayer');
            $(thisParentObj).attr('href','javascript:void(0);');
            $(thisParentObj).attr('rel',thisImgHref);
        openGWindow(thisImgHref,'gwin',630,420,'no');
    });
    }

    if($(".sc-auto-gallery").length)
    {
        if(isIE6 || isIE7) {
            $('img.sc-auto-gallery').click(function()
            {
                thisImgHref = $(this).parent('a').attr('href');
                thisParentObj = $(this).parent('a');
                //$(thisParentObj).addClass('suscImgLayer');
                $(thisParentObj).attr('href','javascript:void(0);');
                $(thisParentObj).attr('rel',thisImgHref);
            openGWindow(thisImgHref,'gwin',630,420,'no');
            });
        }
    }

    $('.suscImgLayer').click(function()
    {
        var imgUrlToGet = $(this).attr('rel');
        $.colorbox({
            href:imgUrlToGet,
            close:"schließen"
        });
    });
});
