// pre set variables to prevent errors
// first for the browser type
isNav=false;
isW3C=false;
isExp=false;
isOpera=false;
isNOT=false;
isMac=false;
// capture the height & width of the viewers screen
screenWidth = screen.width;
screenHeight = screen.height;

// now begin
// browser detection
browser=navigator.appName;
version=navigator.appVersion;
useragent=navigator.userAgent;
Vmajor=parseInt(navigator.appVersion);
Vminor=parseFloat(navigator.appVersion);

if (useragent.indexOf('Opera') != -1) {
	isOpera=true;
	pre='all';
	suff='.style';
}
else if (browser=="Netscape") {
	if (Vmajor==4)
	{
		isNav=true; pre='layers.'; suf='';
		window.captureEvents(Event.RESIZE);	// handle the resize bug on NN
	}
	else if (Vmajor>=5)	isW3C=true;
	else isNOT=true;
}
else if (browser=="Microsoft Internet Explorer") {
	if ( version.indexOf('MSIE 5.0; Macintosh;') != -1 )  {
		isExp=true;
		pre='all.';
		suf='.style';
	}
	// IE 4 to 5.5 return 4 as the version
	else if ( (Vmajor==4) ) {
		isExp=true;
		pre='all.';
		suf='.style';
	}
	else isNOT=true;
} else {
	isW3C=true;
}

if (version.indexOf('Mac') != -1) isMac=true;

if (isNav) {
	document.captureEvents(Event.RESIZE);
	window.onresize=resizeH;
	window.onresize=document.reload;
}
//---------------------------------------------------------------------------------
//show/hide Layer - layerVis(name,visi)
function layerVis(name,visi) {
	if (isNav || isExp) {
		eval ('document.'+pre+name+suf+'.visibility="'+visi+'"');
		return;
	}
	else if (isW3C || isOpera) {
		obj=document.getElementById(name);
		obj.style.visibility=visi;
	}
}
//---------------------------------------------------------------------------------
//  moveLayer
function moveLayer(name,x,y) {
	if (isExp)	{
		eval ('document.'+pre+name+suf+'.pixelLeft='+x);
		eval ('document.'+pre+name+suf+'.pixelTop='+y);
		return;
	}
	else if (isNav) {
		eval ('document.'+name+'.moveTo('+x+','+y+')');
		return;
	}
	else if (isW3C) {
		obj=document.getElementById(name);
		obj.style.left=x+'px';
		obj.style.top=y+'px';	
		return;
	}
	else if (isOpera) {
		obj=document.getElementById(name);
		obj.style.left=x;
		obj.style.top=y;	
	}
}
//---------------------------------------------------------------------------------
// write html to layer
function writeLayer(name,code) {
	if (isNav) {
		eval('document.'+name+'.document.open()');
		eval('document.'+name+'.document.write(code)');
		eval('document.'+name+'.document.close()');
		}
	else if (isExp) {
		eval('document.all.'+name+'.innerHTML=code');
	}
	else if (isW3C) {
		obj=document.getElementById(name);
		// this is a non-compliant netscape hack supported by Gecko/Mozilla,
		// necessary to allow writing markup in a layer
		obj.innerHTML=code;
		/* this is the DOM way, but only support TextNodes in Mozilla
		while (obj.firstChild) obj.removeChild(obj.firstChild);
		node=document.createTextNode(code);
		obj.appendChild(node);*/
	}
	else if (isOpera) {
		obj=document.getElementById(name);
		obj.style.innerHTML=code;
	}
}
//---------------------------------------------------------------------------------
// mouse pointer 
mouseX=0;
mouseY=0;
//
function mousemoveH(evt) {
	if (isNav) {
		mouseX=evt.pageX;
		mouseY=evt.pageY;
	} 
	else if (isExp) {
		mouseX=window.event.clientX;
		mouseY=window.event.clientY;
	}
	else if (isW3C) {
		mouseX=evt.clientX;	
		mouseY=evt.clientY;
	}
	else if (isOpera) {
		mouseX=window.event.clientX;
		mouseY=window.event.clientY;
	}
	return true;
}
//
function startMC(handler) {
	if (isNav) document.captureEvents(Event.MOUSEMOVE);
	if (handler) document.onmousemove=handler;
	else document.onmousemove=mousemoveH;
//	if (isW3C) document.addEventListener(Event.MOUSEMOVE,mousemoveH,true);
}