function gotoURL(url){
  if(url != ""){
    document.location = url;
  }
}

function read_cookie(name)
{
var allcookies = document.cookie;
var start = allcookies.indexOf(name+"=");

if (start == -1) return "";

start += name.length + 1;
var end = allcookies.indexOf(';', start);
if (end == -1) end = allcookies.length;

var value = allcookies.substring(start, end);
return value;
}

function SetCookie ()
{
var d = new Date();
d.setDate(d.getDate()+365)
d.setHours(5);
d.setMinutes(1);

document.cookie = "BCOU0302Cd=yes; expires=" + d.toGMTString() + "; path=/";
return true;
}

function survey()
{
  var donebefore = read_cookie("BCOU0302Cd");

  if (donebefore == "") {
    SetCookie();
    windowOpen('http://survey.bcou.ca/BCOU0001_0305/bcou0001_0305.htm');
  } 

}

/*function popup()
{
  var donebefore = read_cookie("BCOU0302Cd");

  if (donebefore == "") {
    windowOpen('http://www.bcou.ca/survey/begin.html');
  }
}*/

function Is() {
        var agent   = navigator.userAgent.toLowerCase();
        this.major  = parseInt(navigator.appVersion);
        this.minor  = parseFloat(navigator.appVersion);
        this.ns     = ((agent.indexOf('mozilla') != -1) && (agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1) && (agent.indexOf('opera') == -1) && (agent.indexOf('webtv') == -1));
        this.ns2    = (this.ns && (this.major == 2));
        this.ns3    = (this.ns && (this.major == 3));
        this.ns4    = (this.ns && (this.major == 4));
        this.ns6    = (this.ns && (this.major >= 5));
        this.ie     = (agent.indexOf("msie")!= -1);
        this.ie3    = (this.ie && (this.major < 4));
        this.ie4    = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") == -1));
        this.ie5    = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") != -1));
        this.ieX    = (this.ie && !this.ie3 && !this.ie4);
}

function windowOpen(window_url) {

  var is = new Is();    
  var win_width = 640;
  var win_height = 400;

  //the above function detects the browser
  var available_width;
  var available_height;

  if(is.ns4 || is.ns6) 
  {
   available_width=screen.width;
   available_height=screen.height;
  } 
  else if(is.ie4 ||is.ie5) 
  {
   available_width=screen.width;
   available_height=screen.height;           
  }

   var winprop = "width="+win_width+",height="+win_height+",top=" + Math.round(available_height/2-win_height/2) + ",left=" + Math.round(available_width/2-win_width/2);  
   newWin = window.open(window_url,'','toolbar=no,status=no,scrollbars=yes,menubar=no,resizable=no,directories=no,location=no,' + winprop);
   if (document.images) { 
       if (newWin) newWin.focus()
   }
}

