$(document).ready(function(){
    var reffer = document.referrer;
    if (reffer == "") {
        $(".wrapper").css("display", "none");
        $(".contain").css("display", "none");
        $(".services-opacity").css("display", "none");
        $(".footer").css("display", "none");
        $(".right-main").css("display", "none");
        $("#header").css("display", "none");
        $(".wrapper").fadeIn(1800, function(){
            $("#header").fadeIn(3100, function(){
                $(".right-main").fadeIn(1500, function(){
                    $(".footer").fadeIn(1850, function(){
                        $(".services-opacity").fadeIn(1600, function(){
                            $(".contain").fadeIn(2400);
                        })
                    })
                });
            });
        });
    }
    $(document).click(function(){
        jQuery.fx.off = true;
    })

    $(".services li").hover(
        function(){$(this).css("background-color", "rgb(130,220,255)");/*$(this).before('<img class="img-little" src="/img/littlelogo.gif"/>')*/},
        function(){$(this).css("background-color", "");
        }
    )
        $("a[rel^='prettyPhoto']").prettyPhoto();  

        $(".services li").click(function(){
            var folder = $(this).attr("id");
            
            $("#1").html('<a rel="prettyPhoto" href="/img/'+folder+'/1.jpg" class="lightbox-enabled"><img class="photo" src="/img/'+folder+'/1.jpg" /></a>'); //attr("src", "/img/"+folder+"/1.jpg");
            $("#2").html('<a rel="prettyPhoto" href="/img/'+folder+'/2.jpg"><img class="photo" src="/img/'+folder+'/2.jpg" /></a>');
            $("#3").html('<a rel="prettyPhoto" href="/img/'+folder+'/3.jpg"><img class="photo" src="/img/'+folder+'/3.jpg" /></a>');
            $("#4").html('<a rel="prettyPhoto" href="/img/'+folder+'/4.jpg"><img class="photo" src="/img/'+folder+'/4.jpg" /></a>');
           $("a[rel^='prettyPhoto']").prettyPhoto();
            
        });
        $(".gallery-ul li").hover(
            function(){$(this).css("background-color", "rgb(130,220,255)");/*$(this).before('<img class="img-little" src="/img/littlelogo.gif"/>')*/},
            function(){$(this).css("background-color", "");
            }
        )
        $(".gallery-ul li").click(function(){
            var Folder = $(this).attr("id");
            $(".thumbs").css("display","none")
            $("[class=thumbs][id="+Folder+"]").css("display","block")
            $(".thumbs li").css("display","block");

           //var yy = ' <ul  class="thumbs noscript" id="9-f" style="display: none"><li><a class="thumb" style="line-height: 0px !important" name="leaf" href="/img/9-f/1.jpg" title="Title #0"><img style="width: 75px; height: 75px" src="/img/9-f/1.jpg" alt="Title #0" /></a></li><li><a class="thumb" style="line-height: 0px !important" name="leaf" href="/img/8-f/2.jpg" title="Title #0"><img style="width: 75px; height: 75px" src="/img/9-f/2.jpg" alt="Title #0" /></a></li><li><a class="thumb" style="line-height: 0px !important" name="leaf" href="/img/9-f/3.jpg" title="Title #0"><img style="width: 75px; height: 75px" src="/img/9-f/3.jpg" alt="Title #0" /></a></li><li><a class="thumb" style="line-height: 0px !important" name="leaf" href="/img/9-f/4.jpg" title="Title #0"><img style="width: 75px; height: 75px" src="/img/9-f/4.jpg" alt="Title #0" /></a></li></ul> ' ;
           //$("#thumbs").append(yy);
            //$(this).parent().addClass('exception');
            //$(this).parent().find('li:not(.exception)').css("display", "none")
            //$(".ff").css('display','block');
        })

        $(".yy").click(function(){
            var $dialog = $("<div><form class='mail-form' action='/em.php/' method='post'>\n\
                                <h2 style='background : #87CEFA; font-size: 16px'>Please input text</h2>    \n\
                                <textarea name='message'></textarea>\n\
                                <input class='submit' type='button' value='Send message' style='float:left'/>\n\
                                <input type='button' value='Cancel' class='cancel' />\n\
                            </form></div>")
                .dialog({
                    title: "",
                    width: 455,
                    height: 300,
                    resizable: false,
                    draggable: false,
                    position: "center"
                })
                $(".cancel").click(function(){
                    $dialog.dialog('close');
                    $dialog.remove();   
                })

                $(".mail-form").submit(function(){
                    var action = $(this).attr('action');
                    var data = $(this);
                     $.ajax({
                         type: 'POST',
                         url: '/em.php/',
                         success: function(data){
                             alert(data);
                             
                         }

                     })

                        //console.log(response);
                        
                        //if(response)
                        //    aletr(response);
                        // обратно вешаю обработчик
                        /*$('.submit').click(function(){
                            $('.card').submit();
                            $('.submit').attr('disabled', true);
                            $('.submit').unbind();
                                return false;
                            });
                            stopWait();
                            */
                    });
       
                //$(".submit").click(function(){
                //    $('.mail-form').submit();
                //})
                
        })

        $(".sub-email").click(function(){
            alert("Thank you. Your message has been sent");
        })
});



