$(function(){
    $('#ico-new-shop').mouseover(function(){
        $(this).attr('src', $(this).attr('src').replace('normal', 'hover'));
    }).mouseout(function(){
        $(this).attr('src', $(this).attr('src').replace('hover', 'normal'));
    });    
    
    $('#logo').mouseover(function(){
        $(this).attr('src', $(this).attr('src').replace('normal', 'hover'));
    }).mouseout(function(){
        $(this).attr('src', $(this).attr('src').replace('hover', 'normal'));
    });
    
    $('.maincat').mouseover(function(){
        $(this).find('h2').css('color', '#ff5400');
    }).mouseout(function(){
       $(this).find('h2').css('color', '#ffffff');
    });
    
    $('.subcat').mouseover(function(){
        var pid = $(this).parent().attr('id');
        $(this).stop().animate({
            width: '450px'
        }, 200, 'linear', function(){
            $('#' + pid + '-ico').attr('src', URL_MROOT + 'media/img/files/fp-cat-' + $(this).attr('title') + '.png').show();
        }).find('h2').css('color', '#ff5400');
    }).mouseout(function(){
       $(this).stop().animate({
            width: '300px'
        }).find('h2').css('color', '#ffffff');
    });
    
    $('#fp-categories-left, #fp-categories-right').mouseleave(function(){
        $('#fp-categories-left-ico').hide();
        $('#fp-categories-right-ico').hide();
    });
    
    $('.details-icon').click(function(){
        var db = $(this).parent().parent().find('.details-bottom');
        if(db.is(':visible')){
            $(this).attr('src', $(this).attr('src').replace('open', 'close'));
            db.slideUp();
        }else{
            $(this).attr('src', $(this).attr('src').replace('close', 'open'));
            db.slideDown();
        }
    });
    
    $('.group-icon').click(function(){
        var db = $(this).parent().parent().find('.group-bottom');
        if(db.is(':visible')){
            $(this).attr('src', $(this).attr('src').replace('open', 'close'));
            db.slideUp(200);
        }else{
            $(this).attr('src', $(this).attr('src').replace('close', 'open'));
            db.slideDown(200);
        }
    });
    
    $('#article-list-c-left').click(function(){
        $('#article-slide-list-w ul').animate({
            marginLeft: '+=200px'
        }, 1000);
    });
    
    $('#article-list-c-right').click(function(){
        $('#article-slide-list-w ul').animate({
            marginLeft: '-=200px'
        }, 1000);
    });
    
    $('#notification-close').mouseover(function(){
        $(this).css('background-position', '0 26px');
        closeNotification();
    }).mouseleave(function(){
        $(this).css('background-position', '0 0');
    });
    
});

function closeNotification(){
    $('#notification-text').hide();
    $('#notification').animate({
        bottom: '-65px'
    }, 300, 'linear', function(){
        $('#notification-close').fadeOut(300, function(){
            $('#notification').fadeOut();
        });
    });
}

function showNotification(text){
    $('#notification-text').html(text).show();
    $('#notification').animate({
        bottom: '0px'
    }, 300, 'linear', function(){
        $('#notification-close').fadeIn(300, function(){
            $('#notification').fadeIn();
        });
    });
}

function popup(url, w, h){
    if(w==null){
        w = 800;
    }
    if(h==null){
        h = 600;
    }
    window.open(url, 'popup','resizable,scrollbars,screenX=300,screenY=200,width=' + w + ',height=' + h);
}

