var tOut = null;
var changed = '#f0bf92';
var rand = Math.round(Math.random() * 100000);

function hider () {
    $('#alert').empty().hide();
    clearTimeout(tOut);
}

function boat_position () {
    var boatPosX = parseInt($('#total-holder').width()) - 358;
    var boatPosY = parseInt($('#total-holder').height()) - 128;
    $('#main-boat').css('position', 'absolute').css('top', boatPosY + 'px').css('left', boatPosX + 'px');
}

function mail_position () {
    var mailPosY = parseInt($('#total-holder').height()) - 120;
    $('#main-mail').css('position', 'absolute').css('top', mailPosY + 'px').css('left', '282px');
}

$(document).ready( function () {

    tOut = window.setTimeout('hider()', 8000);

	//if (location.pathname.indexOf('admin') == -1) $(function() { $('.gallery a').lightBox(); });

    $('.t_1, .t_2').hover( function () {
        changed = $(this).css('background-color');
        $(this).css('background-color', '#f0bf92');
    }, function () {
        $(this).css('background-color', changed);
    });

    $('#captcha').attr('src', '/inc/captcha.php?r=' + rand);
    $('#reset-btn').click( function () {
        rand = Math.round(Math.random() * 100000);
        $('#captcha').attr('src', '/inc/captcha.php?r=' + rand);
        return false;
    });

});

$(window).resize( function () {
    mail_position();
    boat_position();
});

/* Add boat's swf */
$(document).ready( function () {
    var boat_flashvars = {};
    var boat_params = {
    	menu: "false",
    	scale: "noScale",
    	wmode: "transparent",
    	quality: "high"
    };
    var boat_attributes = {};
    swfobject.embedSWF(
        "/img/BoatOnWave.swf?rand=" + rand,
        "main-boat",
        "358",
        "128",
        "9.0.0",
        "/img/expressInstall.swf",
        boat_flashvars,
        boat_params,
        boat_attributes
    );
    mail_position();
    boat_position();
});
