isNS4 = (document.layers) ? 1 : 0;
function popupwin(page, poptitle, popwidth, popheight)
{
   var controls = "status=0,scrollbars=no,personalbar=0,addressbar=0,title=0";
   controls += ",width=" + popwidth + ",height=" + popheight;
   if (isNS4)
   {
      controls += ",screenX=" + window.screenX + ",screenY=" + window.screenY;
   }
   controls += "\"";
   popwin = window.open(page, poptitle, controls);
   popwin.focus();
   popwin.opener.name = "opener";
}
function GetCookie (name) 
{
   var arg = name + "=";  
   var alen = arg.length;  
   var clen = document.cookie.length;  
   var i = 0;  
   while (i < clen) {
      var j = i + alen;    
      if (document.cookie.substring(i, j) == arg)      
      return getCookieVal (j);    
      i = document.cookie.indexOf(" ", i) + 1;    
      if (i == 0) break;   
   }  
   return null;
}
function getUserName()
{
   var vname = GetCookie('dcol_user')
   if(vname == null) 
   {
      return vname;
   }
   var dcol_user = vname.split("|");
   return dcol_user[1];
}
function getCookieVal(offset) 
{
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}
function frmSubmit(frmName)
{
   var userid = getUserName();
   if (userid != null)
   {
      document[frmName].username.value=userid;
      document[frmName].submit();
   }
   else
   {
      alert("You need to be a member of Custom Classroom and logged into your account to use this feature");
   }
   return;
}
function frmCCSubmit()
{
   var userid = getUserName();
      window.location.href = "http://my.school.discovery.com/MyDiscovery/login.html?joinsource=21&dest=http://school.discovery.com/jsp/customclass.jsp%3faction%3dlogin%26userid%3d<login>%26fname%3d<firstname>%26email%3d<email>%26someparm%3d<features-31>";
   return;
}

