function open_pix(obj)
{
        open_img(obj);
        //open_screen(obj);
        //window.open(obj.href,obj.target,'width='+this.width+',height='+this.height);
        return false;
}

function open_img(obj)
{
        var im=new Image;
        im.src=obj.href;
        if (!im.width)
        {
        im.onload=function()
        {
                w=this.width+30<screen.width ? this.width+30 : screen.width;
                h=this.height+30<screen.height ? this.height+30 : screen.height;
                win=window.open(this.src,'_blank','width='+w+', height='+h+',scrollbars=yes,resizable=yes');
                //var bd=win.document.body;
                //bd.style.padding='0px';
                //bd.style.margin='0px';
        }
        }
        else
        {
        w=im.width+30<screen.width ? im.width+30 : screen.width;
        h=im.height+30<screen.height ? im.height+30 : screen.height;
        win=window.open(im.src,'_blank','width='+w+', height='+h+',scrollbars=yes,resizable=yes');
        }
        return false;
}


function open_screen(obj)
{
        if (typeof window.img_window=='undefined')
        {
                window.img_window=document.createElement('div');
                window.img_window.style.position='absolute';
                window.img_window.style.left='0px';
                window.img_window.style.top='0px';
                window.img_window.style.width='100%';
                window.img_window.style.height=document.body.offsetHeight+'px';
                window.img_window.style.backgroundColor='#000000';
                document.body.appendChild(window.img_window);
                window.img_image=new Image;
                document.body.appendChild(window.img_image);
                set_opacity(window.img_window,70);
                window.img_window.onclick=close_screen;
                window.img_image.onclick=close_screen;
                window.img_image.onload=function ()
                {
                        //this.style.width=this.offsetWidth+'px';
                        //this.style.height=this.offsetHeight+'px';

                        //window.img_image.style.width=this.width+'px';
                        var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
                        window.img_image.style.left=((document.body.offsetWidth-this.width)/2)+'px';
                        var y=scrollTop+(document.body.clientHeight-scrollTop)/2-this.height/2;
                        window.img_image.style.top=y+'px';
                        window.img_image.style.display='block';
                        //alert (this.width);
                }
        }
        window.img_window.style.display='block';
        window.img_image.src=obj.href;
        window.img_image.style.position='absolute';
}



function close_screen()
{
        window.img_window.style.display='none';
        window.img_image.style.display='none';
}

function set_opacity(obj,opacity)
{
        var o=opacity/100;
        obj.style.opacity=o;
        obj.style.filter='alpha(opacity='+opacity+')';
        obj.style.display=(opacity>0) ? 'block' : 'none';
}

function update_skin()
{
        set_cookie('skin','update');
}

function show_submenu(obj)
{
        var p=obj.parentNode;
        var o_ul=p.getElementsByTagName('ul')[0];
        var o_t_li=o_ul.parentNode;
        var o_t_ul=o_t_li.parentNode;
        var lis=o_t_ul.getElementsByTagName('ul');
        for (var i=0;i<lis.length;i++)
        {
                lis[i].style.display='none';
        }
        o_ul.style.display=o_ul.style.display!='block' ? 'block' : 'none';
        return false;
}



function set_cookie(name, value) {
        var valueEscaped = escape(value);
        var expiresDate = new Date();
        expiresDate.setTime(expiresDate.getTime() + 365 * 24 * 60 * 60 * 1000); // срок - 1 год, но его можно изменить
        var expires = expiresDate.toGMTString();
        var newCookie = name + "=" + valueEscaped + "; path=/; expires=" + expires;
        if (valueEscaped.length <= 4000) document.cookie = newCookie + ";";
}

function get_cookie(name) {
        var prefix = name + "=";
        var cookieStartIndex = document.cookie.indexOf(prefix);
        if (cookieStartIndex == -1) return null;
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
        if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length;
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

