/**
 * Полезные функции для работы сайта krepika.ru
 */

$(document).ready(function(){

    $("<img>").attr('id', "popupFoto").hide().appendTo("body");

    $("table.text3 tr.t1").each(function(){
        $(this).mouseover(function(){
            $(this).css({
                "background-color": "#EDF1F3"
            });
        })
        .mouseout(function(){
            $(this).css({
                "background-color": "#fff"
            });
        });
    })

    $("a.itemFoto").each(function(){
        var rel = $(this).attr("rel");
        var id = $(this).attr("id");
        id = id.replace(/tid-/, '');

        if (rel != '') {
            var pos = $(this).find("img").position();
                $(this).mouseover(function(){
                    $("#popupFoto").attr('src', rel)
                        .css(
                        {
                            "position":"absolute",
                            "z-index": 1000,
                            "top": parseInt(pos.top) +"px",
                            "right": ($("body").width() - parseInt(pos.left)+10) +"px",
                            "border": "1px solid #000"
                        })
                    .show();

                    })
                    .mouseout(function(){
                        $("#popupFoto").hide();
                    })
                    .click(function(){
                        $(this).attr('target', 'w'+id);
                        window.open('/view-foto-'+id+'.html', 'w'+id,
                            'width=400,height=350,status=no,copyhistory=no,directories=no,menubar=no,location=no,resizable=yes,scrollbars=yes');
                    })

        }
    })
});

function emailLink()
{
    infoWind = window.open("/email/",
                       "email",
                       "width=300,height=280,toolbar=no,status=no,scrollbars=no,menubar=no,resizable=yes");
    infoWind.focus();
    return;
}

