jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

$(document).ready(function() {
    $('div.hidden').hide();
    //~ preloadImages();
    $('#promo').hover(function() {
        $(this).css('background-position', '100% 0');
        $('#promo-text').fadeIn();
    }, function() {
        $(this).css('background-position', '0 0');
        $('#promo-text').hide();
    });
    $('#break').hover(function() {
        $(this).css('background-position', '100% 0');
        $('#break-text').fadeIn();
    }, function() {
        $(this).css('background-position', '0 0');
        $('#break-text').hide();
    });
    $('.block a.active').hover(function() {
        $('.content', $(this).parent()).fadeIn();
    }, function() {
        $('.content', $(this).parent()).hide();
    });
    $('.block a.active').click(function() { return false; });
    $('a._blank').click(function() {
        var win = window.open($(this).attr('href'), '_blank');
        win.focus();
        return false;

    });
    $('div.mini-nav a.promo').hover(function() {
        $(this).append('<address>' + $('#promo-address').html() + '</address>');
        $('address', $(this)).fadeIn();
    }, function() {
        $('address', $(this)).remove();
    });
    $('div.mini-nav a.break').hover(function() {
        $(this).append('<address>' + $('#break-address').html() + '</address>');
        $('address', $(this)).fadeIn();
    }, function() {
        $('address', $(this)).remove();
    });
    $('div.mini-nav a.promo, div.mini-nav a.break').click(function() { return false; });
    $('#sendemail').click(function() {
        var parent = $(this).parent();
        var data = parent.serializeArray();
        $.ajax({url:'./send.php', type: 'post', data: data, complete: function(request) {
            response = request.responseText;
            if(response.substr(0, 2) == 'OK')
            {
                $('input[@name=name]', parent).val('');
                $('input[@name=email]', parent).val('');
                $('textarea', parent).val('');
                alert(response.substr(2));
            }
            else
            {
                alert(response);
            }
        }});
        return false;
    });
});
