function getObject(id) {
	var d = document;
	var ret = false;
	if (arguments.length > 0 && typeof(is) != "undefined") {
		if (is.ns4) {
			if (typeof(d.all) == "undefined") {
				d.all = [];
				findAllObjects();
			}	
			//ret = findObject(id);
			ret = d.all[id];
		}
		else if (is.msd) {
			ret = d.all[id];
		}
		else if (is.w3d) {
			ret = d.getElementById(id);
			if (ret==null) ret = d.getElementsByName(id)[0];
		}
	}
	return ret;
}

function findObject(id, obj) {
	var ret = false;
	if (arguments.length == 1) {
		var obj = document;
	}
	if (arguments.length > 0) {
		for (var i=0; i<obj.images.length; i++) {
			if (obj.images[i].name == id) {
				return obj.images[i];
			}
		}
		for (var i=0; i<obj.forms.length; i++) {
			if (obj.forms[i].name == id) {
				return obj.forms[i];
			}
			for (var j=0;j<obj.forms[i].elements.length; j++) {
				if (obj.forms[i].elements[j].name == id) {
					return obj.forms[i].elements[j];
				}
			}
		}
		for (var i=0; i<obj.layers.length; i++) {
			if (obj.layers[i].name == id) {
				return obj.layers[i];
			}
			ret = findObject(id, obj.layers[i].document);
			if (ret != false) {
				return ret;
			}
		}
	}
	return ret;
}

function findAllObjects(obj) {
	if (is.ns4) {
		if (arguments.length == 0) {
			var obj = document;
		}
		for (var i=0; i<obj.images.length; i++) {
			if (typeof(obj.images[i].name) != "undefined" && obj.images[i].name != "") {
				addObject(obj.images[i].name,obj.images[i]);
			}
		}
		for (var i=0; i<obj.forms.length; i++) {
			if (typeof(obj.forms[i].name) != "undefined" && obj.forms[i].name != "") {
				addObject(obj.forms[i].name,obj.forms[i]);
			}
			for (var j=0;j<obj.forms[i].elements.length; j++) {
				if (typeof(obj.forms[i].elements[j].name) != "undefined" && obj.forms[i].elements[j].name != "") {
					addObject(i+obj.forms[i].elements[j].name,obj.forms[i].elements[j]);
				}
			}
		}
		for (var i=0; i<obj.layers.length; i++) {
			if (typeof(obj.layers[i].name) != "undefined" && obj.layers[i].name != "") {
				addObject(obj.layers[i].name,obj.layers[i]);
			}
			findAllObjects(obj.layers[i].document);
		}
	}
	return false;
}

function addObject(id,obj) {
	var d = document;
	if (arguments.length > 1 && is.ns4) {
		if (typeof(d.all) == "undefined") {
			d.all = [];
		}
		d.all[id] = obj;
	}
}

function preloadImages() {
	var d = document;
	var tempImage;
	for (var i=0; i<arguments.length; i++) {
		tempImage = new Image();
		tempImage.src = d.imagePath + arguments[i];
	}
}

function swapImage(id,val) {
	var d = document;
	var obj = getObject(id);
	if (obj) {
		obj.src = document.imagePath + val;
	}
}

function moveLayerTo(id,x,y) {
	if (arguments.length > 2 && typeof(is)!= "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				obj.moveTo(x,y);
			}
			else if (is.ie4) {
				obj.style.pixelLeft = x;
				obj.style.pixelTop = y;
			}
			else if (is.w3d) {
		      obj.style.left = x + "px";
		      obj.style.top = y + "px";
			}
		}
	}
}

function moveLayerBy(id,x,y) {
	if (arguments.length > 2 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				obj.moveBy(x,y);
			}
			else if (is.ie4) {
				obj.style.pixelLeft += x;
				obj.style.pixelTop += y;
			}
			else if (is.w3d) {
		      obj.style.left = (parseInt(obj.style.left)+x) + "px";
		      obj.style.top = (parseInt(obj.style.top)+y) + "px";
			}
		}
	}
}

function moveLayerClipTo(id,x,y) {
	if (arguments.length > 2 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				obj.clip.left = x;
				obj.clip.right = obj.clip.width + x;
				obj.clip.top = y;
				obj.clip.bottom = obj.clip.height + y;
			}
			else if (is.ie4 || is.w3d) {
				val = getLayerClipRect(id);
				val[1] = (val[3]-val[1])+x;
				val[2] = (val[0]-val[2])+y;
		      obj.style.clip = "rect("+(val[0]+y)+"px "+val[1]+"px "+val[2]+"px "+(val[3]+x)+"px)";
			}
		}
	}
}

function moveLayerClipBy(id,x,y) {
	if (arguments.length > 2 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				if (y > 0) {
					obj.clip.rigth += x;
					obj.clip.left += x;
					obj.clip.bottom += y;
					obj.clip.top += y;
				}
				else {
					obj.clip.left += x;
					obj.clip.rigth += x;
					obj.clip.top += y;
					obj.clip.bottom += y;
				}
			}
			else if (is.ie4 || is.w3d) {
				val = getLayerClipRect(id);
		      obj.style.clip = "rect("+(val[0]+y)+"px "+(val[1]+x)+"px "+(val[2]+y)+"px "+(val[3]+x)+"px)";
			}
		}
	}
}


function getLayerRect(id) {
	var ret = false;
	if (arguments.length > 0 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				ret = [obj.top,obj.document.width,obj.document.height,obj.left];
			}
			else if (is.ie4 || is.w3d) {
				ret = [obj.offsetTop,obj.scrollWidth,obj.scrollHeight,obj.offsetLeft];
			}
		}
	}
	if (ret) {
		for (var i=0; i<ret.length; i++) {;
			ret[i] = parseInt(ret[i]);
		}
	}
	return ret;
}

function setLayerRect(id,val) {
	if (arguments.length > 1 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				obj.top = val[0];
				obj.document.width = val[1];
				obj.document.height = val[2];
				obj.left = val[3];
			}
			else if (is.ie4 || is.w3d) {
				obj.offsetTop = val[0];
				obj.offsetWidth = val[1];
				obj.offsetHeight = val[2];
				obj.offsetLeft = val[3];
			}
		}
	}
}

function getLayerClipRect(id) {
	var ret = false;
	if (arguments.length > 0 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				ret = [obj.clip.top,obj.clip.right,obj.clip.bottom,obj.clip.left];
			}
			else if (is.ie4 || is.w3d) {
				ret = obj.style.clip.split("rect(")[1].split(")")[0];
				if (obj.style.clip.indexOf("px")>0) {
					ret = ret.split("px");
				}
				else {
					ret = ret.split(" ");
				}
			}
		}
	}
	if (ret) {
		for (var i=0; i<ret.length; i++) {
			ret[i] = parseInt(ret[i]);
		}
	}
	return ret;
}

function setLayerClipRect(id,val) {
	if (arguments.length > 4 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				 obj.clip.top = val[0];
				 obj.clip.right = val[1];
				 obj.clip.bottom = val[2];
				 obj.clip.left = val[3];
			}
			else if (is.ie4 || is.w3d) {
				obj.style.clip = "rect("+val[0]+"px "+val[1]+"px "+val[2]+"px "+val[3]+"px)";
			}
		}
	}
}

function showLayer(id) {
	if (arguments.length > 0 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				obj.visibility = 'show';
			}
			else if (is.ie4 || is.w3d) {
				obj.style.visibility = 'visible';
			}
		}
	}
}

function hideLayer(id) {
	if (arguments.length > 0 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				obj.visibility = 'hide';
			}
			else if (is.ie4 || is.w3d) {
				obj.style.visibility = 'hidden';

			}
		}
	}
}


function startScroll(id,y,interval,steps) {
	if (arguments.length > 2 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				obj = obj.document;
			}
			obj.scrolly = y;
			obj.scrollinterval = interval;
			obj.scrollsteps = steps;
			obj.scrollcount = 0;
			scrollLayer(id);
		}
	}
}

function scrollLayer(id) {
	if (arguments.length > 0 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				obj = obj.document;
			}
			valc = getLayerRect(id);
			//valsc = getLayerClipRect(id+"c");
			valsc = getLayerClipRect(id);
			if ((obj.scrolly<0 && valsc[0]>0) || (obj.scrolly>0 && valsc[2]<=valc[2])) {
				moveLayerClipBy(id,0,obj.scrolly);
				moveLayerBy(id,0,-obj.scrolly);
				obj.scrollcount++;
				if (typeof(obj.scrollsteps) == "undefined" ||obj.scrollcount < obj.scrollsteps) {
					obj.scroll = window.setTimeout("scrollLayer('"+id+"')",obj.scrollinterval);
				}
			}
		}
	}
}

function gotoScrollTop(id) {
	if (arguments.length > 0 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				obj = obj.document;
			}
			moveLayerTo(id,0,0);
		}
	}
}

function gotoScrollBottom(id) {
	if (arguments.length > 0 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				obj = obj.document;
			}
			valc = getLayerRect(id);
			valsc = getLayerClipRect(id+"c");
			moveLayerTo(id,0,(valsc[2]-valc[2]));
		}
	}
}

function stopScroll(id) {
	if (arguments.length > 0 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			if (is.ns4) {
				obj = obj.document;
			}
			if (typeof(obj.scroll) != "undefined") {
				window.clearTimeout(obj.scroll);
				obj.scrolly = null;
				obj.scrollinterval = null;
				obj.scrollsteps = null;
				obj.scrollcount = null;
			}
		}
	}
}

function showMenu(id) {
	var d = document;
	if (arguments.length > 0 && typeof(is) != "undefined") {
		if (typeof(d.activeMenu) == "undefined") {
			d.activeMenu = id;
		}
		if (d.activeMenu != id) {
			hideLayer(d.activeMenu+"h");
			hideLayer(d.activeMenu);
			hideLayer(d.activeMenu+"v");
			d.activeMenu = id;
		}
		showLayer(id+"h");
		showLayer(id);
		showLayer(id+"v");
		setTab('nglobal',id.substr(id.length-1,1));
	}
	if (is.ie) {
		//window.event.cancelBubble = true;
	}	
}

function hideMenu(id) {
	var d = document;
	if (is.ie4) {
		var val = getLayerRect(id);
		var x = window.event.clientX-1;
		var y = window.event.clientY-1;
		if (val) {
			if (val[0] < y && (val[2]+val[0]) > y && val[3] < x && (val[3]+val[1]) > x) {
				return false;
			}
		}
	}
	if (arguments.length > 0 && typeof(is) != "undefined") {
		if (is.ns4) {
			id = id.target.name;
		}
		if (typeof(d.activeMenu) != "undefined" && d.activeMenu == id) {
			hideLayer(id+"h");
			hideLayer(id);
			hideLayer(id+"v");
			//track("hidemenu() - id : "+id);
			setTab('nglobal',0);
		}
	}
	if (is.ie) {
		//window.event.cancelBubble = true;
	}
	return true;	
}

function countTab(id) {
	var ret = 0;
	if (arguments.length > 0) {
		var obj = true;
		while (obj) {
			obj=getObject(id+ret)
			ret++;
		}
	}
	return ret;
}

function showTab(id,val) {
	if (arguments.length > 1 && typeof(is) != "undefined") {
		var valct = countTab(id);
		if (valct > val) {
			showLayer(id+val);
			showLayer(id+val+"s");
			//showLayer(id+val+"sc");
			for(var i=0; i<valct; i++) {
				if (val != i) {
					hideLayer(id+i);
					hideLayer(id+i+"s");
					//hideLayer(id+i+"sc");
				}
			}
		}
	}
}

function setTab(id,val) {
	var d = document;
	if (arguments.length > 0) {
		var obj = getObject(id);
		if (obj) {
			tmp = obj.src.split("/");
			var src = tmp[tmp.length-1];
			src = src.substr(0,src.length-5);
			if (typeof(val) != "undefined") {
				src += val+'.gif';
			}
			else {
				src += src.substr(src.length-2,1)+'.gif';
			}
			swapImage(id,src);
		}
	}
}

function alertError(val) {
	alert("\n"+val+"\n");
}

function setBgcolor(obj,color) {
	if (arguments.length > 1 && typeof(is) != "undefined" && is.w3d && typeof(obj) != "undefined") {
		obj.style.background=color;
	}
}

function gotoLocation(obj) {
	if (arguments.length > 0) {
		val = obj.options[obj.selectedIndex].value;
		if (val != "") {
			document.location = val;
		}
	}
}


function openSat(src,id,val,h,w,x,y,lm,tm) {
	var ret = false;
	for (i=9; i > arguments.length; i--) arguments[i-1]= "no";
	if (arguments.length > 1) {
		val =  val + "";
		var p = [];
		if (val=="0") val="00000000";
		for (i=0; i<val.length; i++) {
			if (val.substr(i,1) == "0") {
				p[i] = "no";
			}
			else {
				p[i] = "yes";
			}
		}		
		ret = window.open(arguments[0],arguments[1],"height="+arguments[3]+",width="+arguments[4]+",screenx="+arguments[6]+",screeny="+arguments[5]+",leftmargin="+arguments[7]+",topmargin="+arguments[8]+",directories="+p[0]+",toolbar="+p[1]+",scrollbars="+p[2]+",resizable="+p[3]+",location="+p[4]+",menubar="+p[5]+",personalbar="+p[6]+",status="+p[7]);
	}
	return ret;
}

function openSatOpener(src) {
	if (arguments.length > 0) {
		if (typeof(window.opener) != "undefined" && window.opener != null && window.opener.closed == false) {	
				window.opener.document.location = src;
				window.opener.focus();
		}
		else {
			window.opener = openSat(src,"_blank",255);
		}
	}
}

function submitForm(id) {
	if (arguments.length > 0 && typeof(is) != "undefined") {
		var obj = getObject(id);
		if (obj) {
			obj.submit();
		}
	}
}

function startTicker(id,val,interval) {
	var d = document;
	if (arguments.length > 0) {
		if (typeof(d.tickerval) == "undefined") {
			if (val.length < 2) {
				d.tickerval = "--";
			}
			else {
				d.tickerval = val;
			}
		}
		if (typeof(d.tickerinterval) == "undefined") {
			d.tickerinterval = interval;
		}
		//track("startTicker() - id,val,interval : "+id+" , "+val+" , "+interval);
		scrollTicker(id);
	}
}

function scrollTicker(id) {
	var d = document;
	if (arguments.length > 0) {
		obj = getObject(id);
		if (obj) {
			d.tickerval = d.tickerval.substr(1,d.tickerval.length-1)+d.tickerval.substr(0,1);
			obj.value = d.tickerval;
		}
		d.ticker = window.setTimeout("scrollTicker('"+id+"')",d.tickerinterval);
	}
}

function pauseTicker(id) {
	var d = document;
	if (arguments.length > 0) {
		if (typeof(d.ticker) != "undefined") {
			window.clearTimeout(d.ticker);
		}
	}
}

function stopTicker(id) {
	var d = document;
	if (arguments.length > 0) {
		if (typeof(d.ticker) != "undefined") {
			window.clearTimeout(d.ticker);
			d.ticker = null;
			d.tickerval = null;
			d.tickerinterval = null;
		}
	}
}

function track(str) {
	var d = document;
	if (d.trackOn) {
		if (typeof(d.tracknr) == "undefined") {
			d.tracknr = 1;
		}
		if (typeof(d.trackstr) == "undefined") {
			d.trackstr = "";
		}
		if (typeof(d.trackwinh) == "undefined") {
			d.trackwinh = openSat('','errorwin',12,600,200,0,0,0,0);
		}
		d.trackwinh.document.open();
		d.trackwinh.document.write('<h2>track-report</h2><font size="2" color="#ff0000">'+d.tracknr+' : '+str+'</font><br><font size="2">'+d.trackstr+'</font>');
		d.trackwinh.document.close();
		d.trackstr = d.tracknr+" : "+str+"<br>"+d.trackstr;
		d.tracknr++;
	}
}

function errorHandler(message, url, line)
{
	alert(url + "\n\n" + line + " : " + message);
   return true;
}


var jumpPerformed = false;
function jumpHash(hash){
	if (is.op || (is.ie && !is.ie5)) return false;
	
	if ((document.location)&&(!jumpPerformed)&&(hash!='')){
		document.location.hash=hash;
		jumpPerformed = true;
	}
	return true;
	
}


domLoaded = true;