function openPrintWin( news_id )
{
    window.open( "/news_print.php?news="+news_id, news_id, "height=500,width=740,top=50,left=50,toolbar=yes,location=no,status=no,menubar=yes,scrollbars=yes,resizable=no");
};


function checkCommentsForm( news_id )
{
    cookie_name = "news_" + news_id;

    if ( getCookie( cookie_name ) )
    {
        alert("Добавление невозможно. Попробуйте повторить операцию через 10 секунд");
        return false;
    }
    author_name     = ( document.getElementById('author_name') ) ? document.getElementById('author_name').value : false;
    author_email    = ( document.getElementById('author_email') ) ? document.getElementById('author_email').value : false;
    comment_text    = ( document.getElementById('comment_text') ) ? document.getElementById('comment_text').value : false;

    var re = /.+/;

    if( !author_name.match(re) ) 
    {
        alert("Введите имя");
        return false;
    } 

    if( !comment_text.match(re) ) 
    {
        alert("Введите комментарий.");
        return false;
    } 

    re1 = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    
    if ( author_email.match(re) && ! author_email.match(re1)) 
    {
        alert('Вы ввели неправильный Email');
        return false;
    }
    
    var today = new Date();
    var expires = new Date();
    expires.setTime(today.getTime() + 1000*10*1);
    setCookie( cookie_name, 1, expires );

    return true;
};


function setCookie(name, value, expire) 
{   
    document.cookie = name + "=" + escape(value)   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}

function getCookie(Name) 
{   
    var search = Name + "=";
    if (document.cookie.length > 0) 
    { 
        // if there are any cookies      
        offset = document.cookie.indexOf(search);       
        if (offset != -1) 
        { 
            // if cookie exists          
            offset += search.length;          
            // set index of beginning of value         
            end = document.cookie.indexOf(";", offset);          
            // set index of end of cookie value         
            if (end == -1)
            {
                end = document.cookie.length;
            }
            return unescape(document.cookie.substring(offset, end));
        }    
    }

    return false;
}

// Вкл/выкл DIV'а по ID
function vis(id) {
if (document.getElementById(id).style.display == "none") {document.getElementById(id).style.display = "block"} else {document.getElementById(id).style.display = "none"}
}
