var flowPlayer = null;

$(window).load(function(){
    $("td.menu li").bind("mouseover", function(){
        this.className = this.className == "" ? "cur" : "cur2";
    });
    $("td.menu li").bind("mouseout", function(){
        this.className = this.className == "cur2" ? "cur" : "";
    });
    goMozaika();
});

function goMozaika()
{
    $("#mozaika").css("width", document.body.clientWidth + "px");
    $("#mozaika").css("height", (document.body.clientHeight + 10 )+ "px");
    var x = Math.round(document.body.clientWidth / 170 + 0.5);
    var y = Math.round(document.body.clientHeight / 102 + 0.5);
    $("#mozaika2").css("width", (x * 170) + "px");
    $("#mozaika2").css("height", (y * 102) + "px");
    var k = 0;
    for (j = 0; j < y; j++)
    {
        for (i = 0; i < x; i++)
        {
            $("#mozaika2").append("<a href='/@images/" + mozaika[k].i + "' rel='lightbox' target='_blank'><img src='/@images/" + mozaika[k].p + "'></a>");
            k++;
            if (k == mozaika.length)
            {
                k = 0;
            }
        }
    }
    $("#mozaika2").find("img").bind("mouseover", function(){
        $(this).fadeTo("fast", 1);
    });
    $("#mozaika2").find("img").bind("mouseout", function(){
        $(this).fadeTo("fast", 0.3);
    });
}

$(window).bind("resize", goMozaika);

function feedbackFormLinkClick(a)
{
    $('#feedback-form').find('img')[0].src = "/guestbook/check/?" + Math.random();
    $('#guestbook-form').hide('fast');
    $('#feedback-form').find('form')[0].reset();
    $('#feedback-form').toggle('slow');
    if ($(a).html() == 'Анкета посетителя')
    {
        $(this).html('Скрыть форму');
    }
    else
    {
        $(this).html('Анкета посетителя');
    }
}

function guestbookFormLinkClick(a)
{
    $('#guestbook-form').find('img')[0].src = "/guestbook/check/?" + Math.random();
    $('#feedback-form').hide('fast');
    $('#guestbook-form').find('form')[0].reset();
    $('#guestbook-form').toggle('slow');
    if ($(this).html() == 'Написать сообщение')
    {
        $(this).html('Скрыть форму');
    }
    else
    {
        $(this).html('Написать сообщение');
    }
}

function showVideo()
{
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	
	var objOverlay = document.getElementById('overlay');
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';
	$("#loadingImage").hide();
	$("#player").show();
	$("#player").css("top", 120 + arrayPageScroll[1]);
	$("#player").css("left", document.body.offsetWidth / 2 - 240);
	flowPlayer.play();
}