$(function(){
    /* (c) Kamil Wasilewski 2010 < tempb(at)prokonto(dot)pl > */
    var fadeFn = {
        evt:function(elem){
            $(elem).fadeTo(400,0.6);
            $(elem).hover(function(){
                $(this).stop(true,false).fadeTo(400,1);
            },function(){
                $(this).stop(true,false).fadeTo(200,0.6);
            },400);
        }
    };
    fadeFn.evt('.contact-send');
    fadeFn.evt('.mini');
    
    var gfxFn = {
        bodyShadow:function(){
            var height = $(document).height();
            var width = $(document).width();
            $('#body-shadow').css({'width':width,'height':height,'opacity':0.7});
            $('#body-shadow').fadeIn(300);
        },
        bodyMsg:function(msg){
            var pos = $('.contact-send').offset();
            var bMsg = '<div class="bMsg"style="display:none;position:absolute;z-index:1000;background-color:#cccccc;font-size:12px;padding:10px;text-align:justify;">';
            $(bMsg).appendTo('body');
            $('.bMsg').html(msg).css({'left':pos.left-400,'top':pos.top-100}).show();
            
        }
    };
    
    var mininav = {
        init:function(){
            $("#det-mini-nav").hover(function(){$(this).stop(true,false).animate({left:"0"},700);},function(){$(this).stop(true,false).animate({left:"-112"},500);},300);
        }
    };
    mininav.init();

    var clickFn = {
        hideShadow:function(){
            $('#body-shadow').click(function(){
                $('.bMsg').fadeOut().remove();
                $(this).fadeOut(300);
            });
        }
    };
    clickFn.hideShadow();
    
    var smallContactFn = {
      init:function(){
        $('#det-s-contact').submit(function(evt){
        //console.log('scform!');
            var strData = $(this).serialize();
            evt.preventDefault();
            $.ajax({
                type: "POST",
                url: 'scsend.php',
                data: strData,
                    success: function(msg){
                        gfxFn.bodyShadow();
                        gfxFn.bodyMsg(msg);
                }
            });
        });
      }  
    };
    smallContactFn.init();
});
