$(document).ready(function() {
    $(".images-list a").lightBox({
        imageLoading:			"/css/images/lightbox-ico-loading.gif",
        imageBtnPrev:			"/css/images/lightbox-btn-prev.gif",
        imageBtnNext:			"/css/images/lightbox-btn-next.gif",
        imageBtnClose:			"/css/images/lightbox-btn-close.gif",
        imageBlank:			"/css/images/lightbox-blank.gif"
    });
});

(function($){

    if(!document.defaultView || !document.defaultView.getComputedStyle){
        var oldCurCSS = jQuery.curCSS;
        jQuery.curCSS = function(elem, name, force){
            if(name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[ name ]){
                return oldCurCSS.apply(this, arguments);
            }
            var style = elem.style;
            if ( !force && style && style[ name ] ){
                return style[ name ];
            }
            return oldCurCSS(elem, 'backgroundPositionX', force) +' '+ oldCurCSS(elem, 'backgroundPositionY', force);
        };
    }
})(jQuery);

(function($) {

    function toArray(strg){
        strg = strg.replace(/left|top/g,'0px');
        strg = strg.replace(/right|bottom/g,'100%');
        strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
        var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
        return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
    }

    $.fx.step. backgroundPosition = function(fx) {
        if (!fx.bgPosReady) {

            var start = $.curCSS(fx.elem,'backgroundPosition');
            if(!start){//FF2 no inline-style fallback
                start = '0px 0px';
            }

            start = toArray(start);
            fx.start = [start[0],start[2]];

            var end = toArray(fx.options.curAnim.backgroundPosition);
            fx.end = [end[0],end[2]];

            fx.unit = [end[1],end[3]];
            fx.bgPosReady = true;
        }

        var nowPosX = [];
        nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
        nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
        fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

    };
})(jQuery);



////// 

var timerId = null;
function tryReflectImages()
{
    $("#menu-area img").each(function() {
        $(this).reflect({
            height: 1,
            opacity: 0.3
        } ); 
        var div  = $(this).parents('li').find('div')
        if (div) {
            $(div).css('visibility', 'visible');
            window.clearInterval(timerId);
        }
    });

}

$(document).ready(function() {

    $('#kotik').mouseover(function() {
        $(this).find('.simple').hide();
        $(this).find('.over').show();
    }).mouseout(function() {
        $(this).find('.simple').show();
        $(this).find('.over').hide();
    });

    var height = 0;
    
    $('.item').each(function() {
        var h = $(this).height();
        if (h > height)
            height = h;
    });
    //$('#items-height').height(height);
    $('#items-height').height('400px');

    $('.items a').mouseover(function() {
        var id = $(this).attr('class');
        $('.item').hide();
        $('#item' + id).show();
    });

    $('#menu-area a').click(function() {
        window.location = $(this).attr('href');
    });

    timerId = window.setInterval(tryReflectImages, 10);

    $('#menu-area li')
    .mouseleave(function(){
		$(this).find("p").stop().hide();
        $(this).stop().animate({
            backgroundPosition:"(-310px 1px)"
        }, {
            duration:400,
            complete: function() {
                $(this).find('.normal').show().css('visibility', 'visible');
                $(this).find('.hover').hide();
            }
        });
    })
    .mouseenter(function(){
		$(this).find("p").stop().show();
        $(this).stop().animate({
            backgroundPosition:"(-90px 1px)"
        }, {
            duration:400,
            complete:function(){
                $(this).css({
                    backgroundPosition: "-90px 1px"
                })
            }
        })
        $(this).find('.normal').hide();
        $(this).find('.hover').show().css('visibility', 'visible');
    });
});


function showP(id) {
    $('#' + id).toggle('show');
    return false;
}
