var isDOM=document.getElementById;
var isIE=document.all && document.all.item;
var isMZ=isDOM && (navigator.appName=="Netscape");
var isO=window.opera && isDOM;

function init() //инициализация всяких штук, которые требуют инициализации
{
}

function putprint(text) {
  var txtarea = document.sendcomment.comment;
  if (txtarea.createTextRange && txtarea.caretPos) {
    var caretPos = txtarea.caretPos;
    caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
    txtarea.focus();
  } else {
    txtarea.value  += text;
    txtarea.focus();
  }
}

function storeCaret(textarea) {
  if (textarea.createTextRange) textarea.caretPos = document.selection.createRange().duplicate();
}

function enablebtn() {
  var send = document.sendcomment.send;
  var jopa = document.sendcomment.jopa;

  if (jopa.value.length>=4) {
    send.disabled = false;
  } else {
    send.disabled = true;
  }
}

/* CHAT */
var host = 'se7en.ru';

function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function rememberChatInfo() {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    setCookie('chat_name', document.all['name'].value, now, '', host, '');
    setCookie('chat_color', document.info.color.value, now, '', host, '');
    setCookie('chat_style', document.info.style.value, now, '', host, '');
    setCookie('chat_msgs', document.info.msgs.value, now, '', host, '');
    setCookie('chat_refr', document.info.refr.value, now, '', host, '');
}
/* EOF CHAT */

function loadpopunder() {
  if (getCookie('popunder')=='') {
    document.write('<scr' + 'ipt type="text/javascript" language="javascript" src="http://se7en.ru/popunder.js"></scr' + 'ipt>');
    document.cookie="popunder=yes"
  }
}
