var prozente = 0;
var preis = 0;
var uvp = 1;
    
$(document).ready(function()
{
    $("#lightbox").hide();
    $("#lightbox").css("visibility", "visible");

    var windowHoehe = $(window).height();
    var dokumentHoehe = $(document).height();
    var ContainerSpaltenHoehe = $("#container-spalten").height();
    
    if(windowHoehe-ContainerSpaltenHoehe-15 <= 259)
        var SollHoehe = 259;
    else
        var SollHoehe = windowHoehe-ContainerSpaltenHoehe-15;
    
    $("#fusszeile").css("height", SollHoehe);
    $("#lightbox").css("height", dokumentHoehe);

    if(uvp >= 1)
    {
        prozente = (preis * 100 / uvp)-100;
        prozente = prozente * -1;
    }

    if(prozente >= 1)
    {
        prozente = Math.round(prozente);
        $("#sparen").text("Sie sparen "+prozente+"%");
        $(".produktansicht-oben-block .Price").css("color","#C22020");
        $(".produktansicht-oben-block .waehrung").css("color","#C22020");
    }
});

$(document).ready(function()
{
    $(window).resize(function()
    {
        var windowHoehe = $(window).height();
        var dokumentHoehe = $(document).height();
        var ContainerSpaltenHoehe = $("#container-spalten").height();

        if(windowHoehe-ContainerSpaltenHoehe-15 <= 259)
            var SollHoehe = 259;
        else
            var SollHoehe = windowHoehe-ContainerSpaltenHoehe-15;

        $("#fusszeile").css("height", SollHoehe);
        $("#lightbox").css("height", dokumentHoehe);
    });
});

$(document).ready(function()
{	
    $("#slider").easySlider({
        auto: true, 
        continuous: true,
        numeric: true
    });
});

$(document).ready(function() {
    $(".scrollable").scrollable({circular: true, mousewheel: true}).navigator().autoscroll({interval: 3000});
});

$(document).ready(function()
{
    $(".suche").focus(function()
    {   
        if ($.browser.msie && $.browser.version.substr(0,1) <= 7)
        {
            return false;
        }
        else
        {
            var sucheHtml = $(".suche-div").html();
            $("#dyn-div").html(sucheHtml);
            $("#dyn-div").fadeIn(300);
            $("#dyn-div .suche").attr("value" , "");
            $("#dyn-div .suche").focus();
             
            $("#lightbox").css("opacity","0.5");
            $("#lightbox").fadeIn(300);
            $("#dyn-div").css('z-index','1005');
            $("#dyn-div").css('box-shadow','#FFFCEF 0px 0px 15px 3px');
            $("#dyn-div").css('-webkit-box-shadow','#FFFCEF 0px 0px 15px 3px');
            $("#dyn-div").css('-moz-box-shadow','#FFFCEF 0px 0px 15px 3px');
            
            return false;
        }
        
    });
	
    $('#lightbox').click(function() 
    {
        $("#lightbox").fadeOut(300);
        $("#dyn-div").css('display','none');
        $("#dyn-div").css('box-shadow','#FFFCEF 0px 0px 0px 0px');
        $("#dyn-div").css('-webkit-box-shadow','#FFFCEF 0px 0px 0px 0px');
        $("#dyn-div").css('-moz-box-shadow','#FFFCEF 0px 0px 0px 0px');
        
        $("#lightbox-inhalt").css('display','none');
        
        return false;
    });
});

function schliessen()
{
    $("#lightbox").fadeOut(300);
    $("#dyn-div").css('display','none');
    $("#dyn-div").css('box-shadow','#FFFCEF 0px 0px 0px 0px');
    $("#dyn-div").css('-webkit-box-shadow','#FFFCEF 0px 0px 0px 0px');
    $("#dyn-div").css('-moz-box-shadow','#FFFCEF 0px 0px 0px 0px');

    $("#lightbox-inhalt").css('display','none');

    return false;
}

function scrollHoch()
{
    $(document).ready(function()
    { 
        $('html, body').animate({scrollTop:0}, 'slow');
    });
}

$(document).ready(function()
{
    var projekt = $(".produkt-block-teil .beschreibung");
    projekt.each(function() 
    {
        var projtitel=$.trim($(this).html());
        $(this).html($.trim(projtitel.substring(0, 90))+'...');
    });
});





				
function vorschauLaden(obj, imageURL, bildGross)
{
    $(document).ready(function()
    {
        $('#bild').css("background-image", "url("+imageURL+")");
        $('#bild-link').attr('href', bildGross);
    });
}

function ladeErstesBild(imageURL,bildGross)
{
    $(document).ready(function()
    {
        $('#bild').css("background-image", "url("+imageURL+")");
        $('#bild-link').attr('href', bildGross);
    });
}

function shadowboxNeuLaden(imageURL)
{
    $(document).ready(function()
    {
        Shadowbox.open({ content: imageURL, player:'img', gallery: "produkt"}); 
        return false;
    });
}

function shadowboxIframeLaden(inhalt)
{
    $(document).ready(function()
    {
        $("#lightbox").css("opacity","0.5");
        $("#lightbox").fadeIn(300);
        $('#lightbox-inhalt').html('<a class="close-2" onclick="schliessen();"></a>'+inhalt);
        $('#lightbox-inhalt').css("display","block");
    });
}

$(document).ready(function()
{    
    jQuery(function($) {
        
    // if the function argument is given to overlay,
    // it is assumed to be the onBeforeLoad event listener
    $(".contentseite-include").overlay({
        effect: 'apple',
        onBeforeLoad: function()
        {
            // grab wrapper element inside content
            var wrap = this.getOverlay().find(".contentWrap");
            
            // load the page specified in the trigger
            wrap.load(this.getTrigger().attr("href"));
        },
        mask: 
        {
            color: '#000000',
            loadSpeed: 400,
            opacity: 0.5
        },
        closeOnClick: true
        });
    });
});

$(document).ready(function()
{
    $('.frage').click(function() {
        
        if ($(this).parent().next(".faq-antwort").is(":hidden"))
        {
            $(this).parent().next(".faq-antwort").slideDown("slow");
        } else
        {
            $(this).parent().next(".faq-antwort").slideUp("slow");
        }
    });
});

$(document).ready(function()
{
    $("#linke-spalte .left_menu .level1").last().css("border", "none");
    $(".kategorie-block .kategorie-block-teil").css("margin-right", "3px");
    $(".kategorie-block .kategorie-block-teil:last-child").css("margin-right", "0px");

    $(".produkt-block .produkt-block-teil").css("margin-right", "3px");
    $(".produkt-block .produkt-block-teil:last-child").css("margin-right", "0px");

    $(".kategorie-border").css("width", "694px");
    
    var kategorieBlockTeilCount = 0;
    $('.kategorie-block .kategorie-block-teil').each(function(index)
    {
        kategorieBlockTeilCount = index;
    });
    kategorieBlockTeilCount++;


    var topSellMinProduktBlockTeil = 0;
    $('#top-sell-min-3 .produkt-block-teil').each(function(index)
    {
        topSellMinProduktBlockTeil = index;
    });
    topSellMinProduktBlockTeil++;

    if(kategorieBlockTeilCount <= 3 && topSellMinProduktBlockTeil >= 3)
    {
        $('#top-sell-min-3').css('display', 'block');
    }

    if(window.location.href == "http://www.trendmoebel24.de/-AccountShowQQWatchlist/" || window.location.href == "https://www.trendmoebel24.de/-AccountShowQQWatchlist/"){
         $('#hinweis-merkliste').css('display', 'block');
    }

    if(window.location.href == "http://www.trendmoebel24.de/-AccountShowQQMyAccount/" || window.location.href == "https://www.trendmoebel24.de/-AccountShowQQMyAccount/"){
         $('#hinweis-mein-konto').css('display', 'block');
    }
});
