﻿///<reference path="jquery-1.4.2-vsdoc.js"/>
$(function () {
    // Submenu
    $('#subMenu span').click(function () {
        //$(this).next('ul.level2').children('li:first-child').css('border-top', 'none');
        $(this).next('ul.level2').toggle();
        if ($(this).parent().hasClass('active')) {
            $(this).parent().removeClass('active');
            $(this).parent().children('ul:first').removeClass('active');
            $(this).removeClass('active');

        }
        else {
            $(this).parent().addClass('active');
            $(this).parent().children('ul:first').addClass('active');

            $(this).addClass('active');
        }
    });
    //    $('#subMenu span.level2').click(function () {
    //        $(this).next('ul.level3').toggle();
    //        if ($(this).parent().hasClass('active')) {
    //            $(this).parent().removeClass('active');
    //        }
    //        else {
    //            $(this).parent().addClass('active');
    //        }
    //    });
    if ($('#box').hasClass('3Columns')) {
        // BOXLIST PRODUCTPAGE - 3 COLUMNS
        $('#box div.box160Wrap:nth-child(3n)').addClass('lastBox');
    }
    else {
        // BOXLIST OTHER PAGES - 4 COLUMNS
        $('#box div.box160Wrap:nth-child(4n+4)').addClass('lastBox');
    }

    // fancybox on product page
    $("a.fancy-product").fancybox({
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'speedIn': 500,
        'speedOut': 300,
        'overlayShow': true,
        'hideOnContentClick': true,
        'titleShow': false,
        'overlayOpacity': 0,
        'padding': 37
    });

    $("#showMore").click(function () {
        $this = $(this);
        $this.parent().find(".description").hide();
        $this.parent().find(".moreText").show();
        $this.hide();
    });

    // placeholder attribute fix for old browsers

    $('[placeholder]').focus(function () {
        var input = $(this);
        if (input.val() == input.attr('placeholder')) {
            input.val('');
            input.removeClass('placeholder');
        }
    }).blur(function () {
        var input = $(this);
        if (input.val() == '' || input.val() == input.attr('placeholder')) {
            input.addClass('placeholder');
            input.val(input.attr('placeholder'));
        }
    }).blur().parents('form').submit(function () {
        $(this).find('[placeholder]').each(function () {
            var input = $(this);
            if (input.val() == input.attr('placeholder')) {
                input.val('');
            }
        })
    });


    // searchbox text disappearing onclick
    $("input.#SearchTextBox").focus(function () {
        if (this.value == this.defaultValue)
            this.value = '';
    }).blur(function () {
        if (this.value.trim() == '')
            this.value = this.defaultValue;
    });


    // show/hide the mini login form
    /*
    $('#loginbutton').click(function () {
    $('.loginContainer').show();
    });
    $('#closeLoginWindowButton').click(function () {
    $('.loginContainer').hide();
    });
    */
});
