var browser = new Browser();

// Global variable for tracking the currently active tab button.
var activeTab = null;

//DETERMINE BROWSER
function Browser() {
  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

//FUNCTIONS
function popup2(url, win, hgt, wdt, sta, dep, scr, res, tol, mnb, loc){popup(url, hgt, wdt, sta, dep, scr, res, tol, mnb, loc, win)}
function popup(url, hgt, wdt, sta, dep, scr, res, tol, mnb, loc, win){	
	var u=undefined,pop;
	alert(url);
	if(hgt==u)hgt=400;
	if(wdt==u)wdt=666;
	if(sta==u)sta='no';
	if(dep==u)dep='no';
	if(scr==u)scr='yes';
	if(res==u)res='yes';
	if(tol==u)tol='no';
	if(mnb==u)mnb='no';
	if(loc==u)loc='no';
	if(win==u)win='Popup';
	pop=window.open(url, win, 'height='+hgt+',width='+wdt+',status='+sta+',dependent='+dep+',scrollbars='+scr+',resizable='+res+',toolbar='+tol+',menubar='+mnb+',location='+loc);
	if(win != 0) pop.focus();
}

function returnTo(val)
{
  window.close();
  if (val != '') { window.opener.location=val; }
}

function Back(num)
{
  if (typeof(num) != 'int') { num=-1 };
  history.go(num);
}

function goTo(loc, pop)
{
  if (pop==true) {
    window.opener.location=loc;
    window.opener.focus();
    window.close(); }
  else {
    window.location=loc;
  }
}

function closeWindow(){window.close();}

function isDefined(obj) {
  if (typeof(obj) != 'undefined') {
		if (obj != null) return true
	}
  return false;
}

function checkAll(chk,name){
	var form = chk.form;
	var check = chk.checked;
	var i,e;
	for(i=0;i<form.elements.length;i++){
		e=form.elements[i];
		if((e.name==name)&&(e.type=='checkbox')){
			if(!e.disabled)e.checked=check;
		}
	}
}

function findInArray(arr, val) {
  var j,id;
  if (isDefined(arr)) {
    for(j=0; j<arr.length; j++) {
      id=arr[j];
      if (isDefined(id)) {
        if (id==val) return true;
      }
    }
  }
  return false;
}
function buildDate(date) {
	return (date.getMonth()+1)+'/'+date.getDate()+'/'+date.getYear()+' '+date.getHours()+':'+date.getMinutes()+':'+date.getSeconds();
}

