function browser(n,v) {
	//	***	Browser object, with name and version. ***	
	this.bn = n;
	this.bv = v;
}

function getBrowser() {
	// ***	Return object of type <broswer> with name and version.	
	var bwsr = navigator;
	var bver = new String(bwsr.appVersion);	
	return new browser(bwsr.appName, parseInt(bver.substr(0,3)));	
}

/* cri object */
function cri(id,des) {
	this.id = id;
	this.des = des;	
	this.ch = new Array();
	this.pa = null;
	this.add = add;
	this.toString = toString;
	this.find = find; 
	this.findchild = findchild;
}

var root = new cri(0,'SPORTS CRITERIA');	

function add(ch) {	
	this.ch[this.ch.length] = ch;
	ch.pa = this;
}

function toString() {		
	var s = "(" + this.id + "," + this.des + ")";	
	for (c in this.ch) {
		if (this.ch[c] != null)
			s = s + this.ch[c].toString();
	}	
	return s;
}

function find(id) {
	if (this.id != id) {
		for (c in this.ch) {
			if (this.ch[c] != null)
				return (this.ch[c].find(id));
		}
		return null;
	}
	return this;			
}	
		

function findchild(id) {
	for (c in this.ch) {
		if (this.ch[c].id == id) return this.ch[c];
	}
	return null;
}
		
		
/* web user functions */

function updstat(o,host) {
	var i = o.options[o.selectedIndex].value;	
	var s;
	if (i == 996) 
		s = "visible"
	else
		s = "hidden";
	var objs = document.getElementsByName("obj");
	var obj = objs[host];
	obj.style.visibility = s;	
}


function refresh(root,lvl) {
	
	// retrieve all form combos
	var objs = document.getElementsByName("obj");	
	var v, obj;
	var bwsr = getBrowser();
	
	if (lvl == objs.length) return;	
	
	obj = objs[lvl];	// get combo to update	
	if (bwsr.bn == "Microsoft Internet Explorer") {
		for (c in obj) obj.options.remove(c)
	} else {	
		for (c in obj) obj.options[c] = null;
	}
	var i = 0;
	for (c in root.ch) 
		obj.options[i++] = new Option(root.ch[c].des,root.ch[c].id);
	obj.selectedIndex = 0;
	if (obj.length > 0) {
		v = obj.options[obj.selectedIndex].value;
		refresh(root.findchild(v),lvl+1);
	}
}


function update(root,source) {
	var objs = document.getElementsByName("obj");
	// var objs = frm.all.namedItem("obj");	
	var v, obj;

	if (source == objs.length) return;

	// locate appropriate root 
	for (var i = 0; i <= source; i++) {
		v = objs[i].options[objs[i].selectedIndex].value;
		root = root.findchild(v);		
		if (root == null) return;
	}			
	// update combos
	refresh(root,source+1);
}

// custom for scorestats page - msk 22/8/03
function update2(root,source) {
	var objs = document.getElementsByName("obj");
	// var objs = frm.all.namedItem("obj");	
	var v, obj;

	if (source == objs.length) return;

	// locate appropriate root 
	for (var i = 0; i <= source; i++) {
		v = objs[i].options[objs[i].selectedIndex].value;
		root = root.findchild(v);		
		if (root == null) return;
	}			
	// update combos
	refresh(root,source+1);
	
	// check if group combo has any values and enabled it
	if (objs[3].length == 0) {
		objs[3].disabled = true;
	}
	else {
		objs[3].disabled = false;
	}

}

