if (is.ns4) {
var domRef="document.layers.";
var domClose = ""
var styleRef=""; }
 else if ((is.ie) && (!is.dom) && (!is.ie55)) {
 var domRef="document.all.";
 var domClose = ""
 var styleRef=".style";
 leftPos = 'left'; }
 else if ((is.dom)||(is.ie55)) {
 var domRef="document.getElementById(\""
 var domClose = "\")"
 var styleRef=".style"
 var leftPos = 'left'; }

var timerid
//* create object reference
function getRef(obj) {
 if (typeof(obj) == 'string') {
 theObj = eval(domRef+obj+domClose);
 } else {
 theObj = obj
 }
 return theObj
}

function getClipFormat(top,right,bottom,left) {
 if (is.dom) {
 var clipRect =
 "rect("
 + top + "px "
 + right + "px "
 + bottom + "px "
 + left + "px"
 + ")";
 return clipRect;
 } else {
 return "rect(" + top + " " + right + " " + bottom + " " + left + ")";
 }
}
function init() {
 var mask = getRef('hmaskClip'), nav = getRef('nav');
 if (mask == null) return;
 var top = 0;
 var right = 940;
 var bottom = 460;
 var left = 0;

 mask.style.clip = getClipFormat(top,right,bottom,left);
 menuW = document.forms["myForm"].elements["tablewidth"].value;
 getRef('hmenu').maxScrollPos = right - menuW;
 getRef('hmenu').minScrollPos = 0;
 getRef('hmenu').speed = 7.5;
 getRef('hmenu').timerSpeed = 10;
 getRef('hmenu').OyPos = mask.offsetTop;
 // test
 mask_r = clipValues(mask,'r')
 // reveal the navigation...
}

onresize = init;

function shiftHort(div, x, y) {
 if (is.dom) {
 div.style.left = x + "px";
 } else if (is.ns4) {
 div.moveTo(x,y);
 } else if ((is.ie) && (!is.dom)) {
 div.style.pixelLeft = x;
 }
}

function scrollLef() {
 hmenuObj = getRef('hmenu');
 OxPos = hmenuObj.style.left.split("px")[0];
 if (OxPos < hmenuObj.minScrollPos) {
 OxPos = Number(OxPos) + Number(hmenuObj.speed);
 if (OxPos > hmenuObj.minScrollPos) { OxPos = hmenuObj.minScrollPos; }
 shiftHort(hmenuObj, OxPos, hmenuObj.OyPos);
 timerid = setTimeout("scrollLef()", hmenuObj.timerSpeed);
 } else {
 OxPos = hmenuObj.minScrollPos;
 shiftHort(hmenuObj, OxPos, hmenuObj.OyPos);
 clearTimeout(timerid);
 }
 //updateScrollContent(OxPos);
 clearContent();
}

function scrollRight() {
	
 hmenuObj = getRef('hmenu');
 OxPos = hmenuObj.style.left.split("px")[0];
 
 
 if (OxPos > hmenuObj.maxScrollPos) {
 OxPos = OxPos - hmenuObj.speed;
 if (OxPos < hmenuObj.maxScrollPos) {OxPos = hmenuObj.maxScrollPos;}
 shiftHort(hmenuObj, OxPos, hmenuObj.OyPos);
 timerid = setTimeout("scrollRight()",hmenuObj.timerSpeed);
 } else {
 OxPos = hmenuObj.maxScrollPos;
 shiftHort(hmenuObj, OxPos, hmenuObj.OyPos);
 clearTimeout(timerid);
 }
 //updateScrollContent(OxPos);
 clearContent();
}

var _textID = null;
function updateScrollContent(posX){
	_id = getTextId(-posX);
	if (_id == _textID) {
	
	//debug
		//document.getElementById("top").innerHTML =  "" +(-posX);
	
	} else {
		//document.getElementById("top").innerHTML = _id ;//+ "" +(-posX);
		changeContentOnly(_id);
		_textID = _id;
	}
}



function stopScroll() {
 clearTimeout(timerid);
}



// for changing clip widths
function clipValues(obj,which) {
 if (is.ns4) {
 if (which=="t") return obj.clip.top
 if (which=="r") return obj.clip.right
 if (which=="b") return obj.clip.bottom
 if (which=="l") return obj.clip.left
 }
 else if ((is.ie) || (is.dom)) {
 var clips = obj.style.clip
 var regexp = /pt/
 var rpl = clips.replace(regexp,"px")
 rpl = rpl.replace(regexp,"px")
 var clipv = rpl.split("rect(")[1].split(")")[0].split("px")
 if (which=="t") return Number(clipv[0])
 if (which=="r") return Number(clipv[1])
 if (which=="b") return Number(clipv[2])
 if (which=="l") return Number(clipv[3])
 }
}




function clipBy(obj,t,r,b,l) {
 if (is.ns4) {
 obj.clip.top = clipValues(obj,'t') + t
 obj.clip.right = clipValues(obj,'r') + r
 obj.clip.bottom = clipValues(obj,'b') + b
 obj.clip.left = clipValues(obj,'l') + l
 }
 else if ((is.ie) || (is.dom)) {
 obj.style.clip = "rect("+(this.clipValues(obj,'t')+t)+"px "+(this.clipValues(obj,'r')+r)+"px "+Number(this.clipValues(obj,'b')+b)+"px "+Number(this.clipValues(obj,'l')+l)+"px)"

 }
}