//////////////////////////////////////////////////////////////////////////
// Открывает/закрывает все сообщение
// todo: 1 - expand, 0 - collapse;
function openAll( todo) {
    if( todo) {
        $("div .C").show();
    } else {
        $("div .C").hide();
    }
}

function E(el) { 
    if($("#"+el+"C").is(":hidden")) {
        $("#"+el+"C").show();
    } else {
        $("#"+el+"C").hide();
    }
}
//////////////////////////////////////////////////////////////////////////

with (document) 
{
        var version = 0;
        if (navigator.userAgent.indexOf("MSIE 4") != -1)  version = 5;
        else if
        (navigator.userAgent.indexOf("MSIE 3") != -1)  version = 1;
        else if
        (navigator.userAgent.indexOf("Mozilla/4") != -1)  version = 4;
        else if
        (navigator.userAgent.indexOf("Mozilla/4.5") != -1)  version = 7;
        else if
        (navigator.userAgent.indexOf("Mozilla/3") != -1)  version = 3;
        else if
        (navigator.userAgent.indexOf("Mozilla/2") != -1)  version = 2;
        else if
        (navigator.userAgent.indexOf("MSIE 4.5") != -1)  version = 6;
        else version = 8;

        var hide = version >=4 ? true : false;
        write("<STYLE TYPE='text/css'>");
        if (hide)
        {   
                write(".P {text-decoration: none; position: relative;}");
                write(".C {text-decoration: none; display: none;}");
        }
        write("</STYLE>");
}


/**
 * Get cookie value
 * @param sName Cookie name
 * @retun Cookie value
 */   
function getForumCookieValue(sName) {
  // Cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++) {
    // A name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) return unescape(aCrumb[1]);
  }

  // A cookie with the requested name does not exist
  return null;
}

/**
 * Set cookie for Cookie.days days 
 * @param sName Cookie name
 * @param sValue Cookie value
 * @param days Expire time in days
 */
function setForumCookie(sName, sValue, days) {
  if (days == null) days = 365; // 1 Year expire date
  var today = new Date();
  var expire = new Date(today.getTime() + days * 86400000);
  document.cookie = sName + "=" + unescape(sValue) + ";expires=" + expire.toUTCString() + ";path=/";
}

function setForumBrowserCookie(sName, sValue) {
  var today = new Date();
  var expire = new Date(today.getTime() + 1800000);
  document.cookie = sName + "=" + unescape(sValue) + ";expires=" + expire.toUTCString() + ";path=/";
}

function disableFormButtons(formName){
  var col = document.forms[formName].elements;
  for (i = 0; i < col.length; i++)  {
    var e = col.item(i);
    if (e.type == 'button' || e.type == 'submit' || e.type == 'reset') {
      e.disabled = true;
    }
  }                     
}       

