var win = null;
function NewWindow(mypage,myname,w,h,scroll){
  LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
  TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
  settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition;
  settings = settings + 'toolbar=no,location=no,directories=no,status=no,';
  settings = settings + 'menubar=no,scrollbars=no,copyhistory=no,resizable=no'

  win = window.open(mypage,myname,settings);
  win.focus();
}

function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0) {
                  // alert('Value: '+c.substring(nameEQ.length,c.length));
                  return c.substring(nameEQ.length,c.length);
                }
        }
        return null;
}

function eraseCookie(name) {
        createCookie(name,"",-1);
}

function createCookie(name,value,days) {
        if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        document.cookie = name+"="+value+expires+"; path=/";
}

function upCount(e,c,m){
  var l = e.value;
  var n = m-l.length;
  c.value = n;
  if (n < 0) {
    c.style.fontWeight = "bold";
    c.style.color = "#900";
  } else {
    c.style.fontWeight = "normal";
    c.style.color = "#080";
  }
};

var session_id = readCookie('login');

