function TableBorderStyle(color,width)
{
        // return ("border-bottom: 2px solid ");
        return ("border-bottom: "+width+" solid "+color+"; border-top: "+width+" solid "+color+"; border-left: "+width+" solid "+color+"; border-right: "+width+" solid "+color+";");
}

function TableOnOver(name)
{
         document.getElementById(name).style.cssText=TableBorderStyle(BoxBorderColorActive,'1px');
}
function TableOnOut(name)
{
         document.getElementById(name).style.cssText=TableBorderStyle(BoxBorderColor,'1px');
}
function BoxOnOver(name)
{
         document.getElementById(name).style.border='1px solid #003366';//#808080';
}
function BoxOnOut(name)
{
         document.getElementById(name).style.border='1px solid #E0E0E0';
}

function getPar(name)
{
        paramStr = window.location.search;
        begin = paramStr.indexOf(name) + name.length + 1;
        end = paramStr.indexOf('&', begin);
        if(end == -1) end = paramStr.length;
        return unescape(paramStr.substring(begin, end));
}
function getLocation()
{
        paramStr = window.location.href;
        end = paramStr.indexOf('?', 1);
        if(end == -1) end = paramStr.length;
        return unescape(paramStr.substring(1, end));
}
function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function WindowResize()
{
        if (getClientWidth()<=1024)
                MainWindowStyleMarginleft=0;
        else
                MainWindowStyleMarginleft=(getClientWidth()-1024)/2;
        BIG.style.marginLeft=MainWindowStyleMarginleft;
        
        PMLeft=document.getElementById("PMLeft");
        if (PMLeft)
            PMLeft.style.marginLeft=MainWindowStyleMarginleft;
            
}

function setcookie2(name,value,expire){
  var exp=new Date();
  var cookieexpire=exp.getTime()+expire;
  exp.setTime(cookieexpire);
  document.cookie=name+"="+value+";expires="+exp.toGMTString();
}

// name - имя cookie
// value - значение cookie
// [expires] - дата окончания действия cookie (по умолчанию - до конца сессии)
// [path] - путь, для которого cookie действительно (по умолчанию - документ, в котором значение было установлено)
// [domain] - домен, для которого cookie действительно (по умолчанию - домен, в котором значение было установлено)
// [secure] - логическое значение, показывающее требуется ли защищенная передача значения cookie
function setCookie(name, value, expires, path, domain, secure) {
                document.cookie = name + "=" + escape(value)
                return
        var curCookie = name + "=" + escape(value) +
                ((expires) ? "; expires=" + expires.toGMTString() : "") +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                ((secure) ? "; secure" : "")
        if (!caution || (name + "=" + escape(value)).length <= 4000)
                document.cookie = curCookie
        else
                if (confirm("Cookie превышает 4KB и будет вырезан !"))
                        document.cookie = curCookie
}

// name - имя считываемого cookie
function getCookie(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))
}
function rand(x,y)
{
        return x+Math.round((y-x)*Math.random());
}
function Write(x)
{
        document.write(x);
}

function ChemAnim(name)
{
var newWindow;
newWindow=open(name,"","target=_blank, width=400px,height=300px");
}
function ChemX(name,LX,LY)
{
var newWindow;
newWindow=open(name,"","toolbar=no,menubar=no,scrollbars=yes,width="+LX+",height="+LY+", resizable=yes");
}
function ChgImg(st1,st2)
{
    document.getElementById(st1).src=st2;
}
function ChgImg2(st1,st2,st3,st4)
{
    document.getElementById(st1).src=st2;
    document.getElementById(st3).src=st4;
}
function ChgImg2Thread(st1,st2,st3,st4)
{
        setTimeout("ChgImg2('"+st1+"','"+st2+"','"+st3+"','"+st4+"')",10);
}
function NewWindow(adress,width,height)
{
        open(adress,"","toolbar=no,menubar=no,scrollbars=yes,width="+(width+42)+",height="+(height+52)+", resizable=yes");
}

function email2(user,domain)
{
st = domain + ">" +user+"@"+domain+"</a>";
return st;
}

function email1(user, domain)
{
st = "<a href=mailto:"+user+"@";
return st;
}

function email(user,domain)
{
return email1(user,domain)+email2(user,domain);
}

function ChgStyle(id,st)
{
       document.getElementById(id).style.cssText=st;
}
function OnImageOver(ImageNum)
{
//       ChgImg("Image"+ImageNum,"images/MakeBig_Over.jpg");
       document.getElementById("TDImage"+ImageNum).style.border="2px dashed #003366";
//       ChgStyle("TDImage"+ImageNum,"border: 2px dashed #003366");
}
function OnImageOut(ImageNum)
{
       document.getElementById("TDImage"+ImageNum).style.border="2px dashed gray";
//       ChgImg("Image"+ImageNum,"images/MakeBig.jpg");
//       ChgStyle("TDImage"+ImageNum,"border: 2px dashed gray");
}