$(document).ready(Init);
$(window).resize(function() {LocateButton();});

function Init()
{
    var begin = 'lto:info'

	$(".button").click( function()
    {
        var url = ($(this).children().attr('href'));
        if (url != null)
            document.location = url;
    } );

    $('.email').attr('href', 'mai' + begin + '@' + '66bit.ru');
    $.PreloadImages('/web/img/active.gif');
    LocateButton();

    if ($('#content .form').length == 0)
        $('#button-form').show();

    $('#contact').dialog({width: 443, resizable: false, modal: true, position: "center", show: 'blind', hide: 'blind', autoOpen: false});

    $('#button-form').click(function(){
        $.fx.speeds._default = 800;
        $('#contact').dialog("open");
    });

    $('.portfolio .item').mouseenter(function() {
        $('.goto', this).animate({ opacity : 1 }, 'fast');
    }).mouseleave(function() {
        $('.goto', this).animate({ opacity : 0 }, 'fast');
    });
}

function LocateButton()
{
    $('#button-form').css('top', $(window).height()/2  - 211/2+'px');
}

jQuery.PreloadImages = function()
{
    jQuery.each (arguments,function (e)
    {
        jQuery("<img>").attr("src", this);
    });
}

