function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);

if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}

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 SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=.uregina.ca" : "") +
    ((secure) ? "; secure" : "");
}

function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=.uregina.ca" : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function hideAd(divId) 
{ if (document.layers) document.layers[divId].visibility = 'hide';
  else if (document.all) document.all[divId].style.visibility = 'hidden';
  else if (document.getElementById) document.getElementById(divId).style.visibility = 'hidden';
}

function hideforever(divID) { 
	/*if (document.layers) document.layers[divId].visibility = 'hide';
  	else if (document.all) document.all[divId].style.visibility = 'hidden';
  	else if (document.getElementById) document.getElementById(divId).style.visibility = 'hidden';*/
  	hideAd(divID);
	
	// set cookie so it won't 'slide' up for 1 year
	var expirydate = new Date();
	FixCookieDate (expirydate);
	expirydate.setTime (expirydate.getTime() + ((24 * 60 * 60 * 1000)*365)); // 24 hrs from now 
	SetCookie("showslidedown",1,expirydate,'/');
}

function adDown(divId) { 
	var slideme = true;
	var showslidedown = GetCookie("showslidedown");
	if (showslidedown) slideme = false;
	if (slideme) {
		state=typeof topPos;
		if(state=='undefined') topPos=-300;
		if(topPos < 150) { 
			topPos+=40;
			if (document.layers) document.layers[divId].top = topPos+"px";
			else if (document.all) document.all[divId].style.top = topPos+"px";
			else if (document.getElementById) document.getElementById(divId).style.top = topPos+"px";
			setTimeout("adDown('pop')",20);
		} else {
		// set cookie so it won't 'slide' up for the rest of the session
		var exp = new Date();
		FixCookieDate (exp);
		exp.setTime (exp.getTime() + (24 * 60 * 60 * 1000)); // 24 hrs from now 
		SetCookie("showslidedown",1,exp,'/');
		}
	}
}