<!--
// dhtml_base.js
// updated : 2000.12.12
// 
// supports Mozilla M17 / Netscape 6 / Gecko
// supports IE 4, 5 and 5.5 on windows
// supports IE 4.5 and IE 5 on macOS
// supports NN 4.5, 4.7 on windows and macOS
// partial support of Opera 4.01
//
// all code is copyright sebastien chevrel, cooked from scratch
// feel free to reuse, just let me know if you do something nice with it
// seb@sebchevrel.com
//
// startMouseCapture()
// popUp(URL,width,height,additional)
// getscrollX(window)
// getscrollY(window)
// Showlayer(id,visibility)
// Movelayer(id,x,y)
// Writelayer(id,htmlcode)
// Resizelayer(id,w,h)
// setZindex(id,z)
// getwindowWidth()
// getwindowHeight()
// getlayerX(id)
// getlayerY(id)
// getlayerWidth(id)
// getlayerHeight(id)


isNav=false;
isW3C=false;
isExp=false;
isOpera=false;
isNOT=false;
var nestedLayer='clipper';

mouseX=0;
mouseY=0;

// Detect browser and define pre/suf-fixes
browser=navigator.appName;
version=navigator.appVersion;
Vmajor=parseInt(navigator.appVersion);
Vminor=parseFloat(navigator.appVersion);

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 if (browser=="Opera") {
	if (Vmajor==4) isOpera=true;
	else isNOT=true;
}

window.onresize=resizeH;

// Cross Browser DHTML Functions

// Pop-up Window
function popUp(theURL,width,height,more)
{
		var popup=window.open(theURL,'popup','width='+width+',height='+height+','+more);
		popup.focus();
}

// This function writes HTML code in a layer
function Writelayer(layer,code) {
	if (isNav) {
		eval('document.'+layer+'.document.open()');
		eval('document.'+layer+'.document.write(code)');
		eval('document.'+layer+'.document.close()');
		}
	else if (isExp) {
		eval('document.all.'+layer+'.innerHTML=code');
	}
	else if (isW3C) {
		obj=document.getElementById(layer);
		// 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(layer);
		obj.style.innerHTML=code;
	}
}

function getscrollX(window) {
	if (isNav || isW3C) {
		return eval(window+'.pageXOffset');
	}
	else if (isExp) {
		return eval(window+'.document.body.scrollLeft');
	}
}

function getscrollY(window) {
	if (isNav || isW3C) {
		return eval(window+'.pageYOffset');
	}
	else if (isExp) {
		return eval(window+'.document.body.scrollTop');
	}
}

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;
	}
}

function startMouseCapture(handler) {
	if (isNav) document.captureEvents(Event.MOUSEMOVE);
	if (handler) document.onmousemove=handler;
	else document.onmousemove=mousemoveH;
//	if (isW3C) document.addEventListener(Event.MOUSEMOVE,mousemoveH,true);
}


function resizeH()
{
	location.reload();
	return false;
}


function setZindex(which,how) {
	if (isNav || isExp) {
		eval ('document.'+pre+which+suf+'.zIndex="'+how+'"');
		return;
	}
	else if (isW3C || isOpera) {
		obj=document.getElementById(which);
		obj.style.zIndex=how;
	}
}

function Showlayer(which,how) {
	if (isNav || isExp) {
		eval ('document.'+pre+which+suf+'.visibility="'+how+'"');
		return;
	}
	else if (isW3C || isOpera) {
		obj=document.getElementById(which);
		obj.style.visibility=how;
	}
}

function Movelayer(which,x,y) {
	if (isExp)	{
		eval ('document.'+pre+which+suf+'.pixelLeft='+x);
		eval ('document.'+pre+which+suf+'.pixelTop='+y);
		return;
	}
	else if (isNav) {
		eval ('document.'+pre+which+suf+'.moveTo('+x+','+y+')');
		return;
	}
	else if (isW3C) {
		obj=document.getElementById(which);
		obj.style.left=x+'px';
		obj.style.top=y+'px';	
		return;
	}
	else if (isOpera) {
		obj=document.getElementById(which);
		obj.style.left=x;
		obj.style.top=y;	
	}
}

function MoveClippedLayer(which,x,y) {
	if (isExp)	{
		eval ('document.'+pre+which+suf+'.pixelLeft='+x);
		eval ('document.'+pre+which+suf+'.pixelTop='+y);
		return;
	}
	else if (isNav) {
		eval ('document.'+nestedLayer+'.document.'+pre+which+suf+'.moveTo('+x+','+y+')');
		return;
	}
	else if (isW3C) {
		obj=document.getElementById(which);
		obj.style.left=x+'px';
		obj.style.top=y+'px';	
		return;
	}
	else if (isOpera) {
		obj=document.getElementById(which);
		obj.style.left=x;
		obj.style.top=y;	
	}
}

function getwindowWidth() {
	if (isExp) {
		return document.body.clientWidth;
	}
	else if (isNav || isW3C || isOpera) {
		return window.innerWidth;
	}
}

function getwindowHeight() {
	if (isExp) {
		return document.body.clientHeight;
	}
	else if (isNav || isW3C || isOpera) {
		return window.innerHeight;
	}
}

function getlayerX(which) {
	if (isExp) {
		return eval ('document.'+pre+which+suf+'.pixelLeft');
	}
	else if (isNav) {
		return eval ('document.'+pre+which+suf+'.left');
	}
	else if (isW3C) {
		obj=document.getElementById(which);
		style=getComputedStyle(obj,null); // computed style vs. style definition
		return parseInt(style.getPropertyValue('left')); // we need to parse 'px' out
	}
	else if (isOpera) { // broken
		obj=document.getElementById(which);
		
	}
}

function getlayerY(which) {
	if (isExp) {
		return eval ('document.'+pre+which+suf+'.pixelTop');
	}
	else if (isNav) {
		return eval ('document.'+pre+which+suf+'.top');
	}
	else if (isW3C) {
		obj=document.getElementById(which);
		style=getComputedStyle(obj,null); // computed style vs. style definition
		return parseInt(style.getPropertyValue('top')); // we need to parse 'px' out
	}
	else if (isOpera) { // broken
		obj=document.getElementById(which);
		return (obj.style.top);
	}


}

function Resizelayer(which,w,h) {
	if (isExp) {
		eval ('document.'+pre+which+'.pixelWidth='+w);
		eval ('document.'+pre+which+'.pixelHeight='+h);
	}
	else if (isNav) {
		eval ('document.'+pre+which+'.resizeTo('+w+','+h+')');
	}
}

function getlayerWidth(which) {
	if (isExp) {
		return eval ('document.'+pre+which+'.clientWidth');
	}
	else if (isNav) {
		return eval ('document.'+pre+which+'.clip.width');
	}
	else if (isW3C) {
		obj=document.getElementById(which);
		style=getComputedStyle(obj,null);
		return parseInt(style.getPropertyValue('width'));
	}
	else if (isOpera) { // broken
		obj=document.getElementById(which);
		return (obj.style.width);
	}

}

function getlayerHeight(which) {
	if (isExp) {
		return eval ('document.'+pre+which+'.clientHeight');
	}
	else if (isNav) {
		return eval ('document.'+pre+which+'.clip.height');
	}
	else if (isW3C) {
		obj=document.getElementById(which);
		style=getComputedStyle(obj,null);
		return parseInt(style.getPropertyValue('height'));
	}
	else if (isOpera) {	// broken
		obj=document.getElementById(which);
		return (obj.style.height);
	}

}


// -->
