var isNav4, isNav6, isIE;
var coll = "";
var styleObj = "";
var preloadFlag = false;
var layFlag, currentLayer;

// browser detection
if (parseInt(navigator.appVersion) >= 4) {
	if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 4) {
		isNav4 = true;
	} else {
		if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) > 4) {
			isNav6 = true;
			styleObj = ".style";
		} else { 
			isIE = true;
			coll = "all.";
			styleObj = ".style";
		}
	}	
}

function hideStatus() {
	window.status = '';
	return true;
}

// returns valid object reference
function getObject(obj) {
	var theObj;
	if (isNav4) {
		theObj = eval("document." + obj);
	} else {
		if (isNav6) {
			theObj = eval("document.getElementById(" + "\"" + obj + "\"" + ")" + styleObj);
		} else {
			theObj = eval("document." + coll + obj + styleObj);
		}
	}
	return theObj;
}

// show layer
function layerOn(obj) {
	var theObj = getObject(obj);
	theObj.visibility = "visible";
	window.status='';
}

// hide layer
function layerOff(obj) {
	var theObj = getObject(obj);
	theObj.visibility = "hidden";
	window.status='';
}

// positions layer
function shiftTo(obj, x, y) {
	if (isNav4) {
		var theObj = getObject(obj)
		theObj.moveTo(x, y)
	}
	if (isNav6) {
		var theObj = eval("document.getElementById(" + "\"" + obj + "\"" + ")" + styleObj)
		theObj.left = x
		theObj.top = y
	}
	if (isIE) {
		var theObj = getObject(obj)
		theObj.pixelLeft = x
		theObj.pixelTop = y
	}
}

var time = 0;
var duration = 10;
var begin;
var finish = 0;
var setScrollStart = true;
var scrll = "";

function goTop() {
	scrll = setTimeout("goTop()", 10);
	if (setScrollStart) {
		if (isNav4) {
			begin = top.pageYOffset;
		} else {
			if (isNav6) {
				begin = top.scrollY;
			} else {
				begin = top.document.body.scrollTop;
			}
		}
		setScrollStart = false;
	}
	// calculate the new position
	if (time < duration) {
		change = finish - begin;
		daScrollPos = scrollPos(time++, begin, change, duration);		
	} else {
		// call the function to end the scroll
		endScroll();
		daScrollPos = 0;
	}
	// scroll the page
	if (isNav4) {
		top.scrollTo(0, daScrollPos);
	} else {
		if (isNav6) {
			top.scrollTo(0, daScrollPos);
		} else {
			top.document.body.scrollTop = daScrollPos;
		}
	}
}

// ends the scroll and resets the variables to their starting positions
function endScroll() {
	clearTimeout(scrll);
	time = 0;
	setScrollStart = true;
}
// generates scroll coordinate
function scrollPos(t, b, c, d) {
	return -c*t*t/(d*d) + 2*c*t/d + b;
}

function openBioWin() {
	biowin=window.open("bio_kuaska.htm","bio","toolbar=0,status=0,directories=0,scrollbars=0,location=0,resizable=0 menubar=0,width=460,height=550")
}

function credOn() {
	win=window.open("0703/cred/credit.htm","credit","toolbar=0,status=0,directories=0,scrollbars=0,location=0,resizable=0 menubar=0,width=300,height=150")
}

var gallSubOff = true
function gallSub() {
	if (gallSubOff) {
		layerOn('btn4sub')
	} else {
		layerOff('btn4sub')
	}
	gallSubOff = !gallSubOff
}


/******************************************/
var c = 0
			var rollOut = true
			var pauseFlag = true
			var incrementFlag = false
			//
			function initScroll(itemCount) {
				var x1 = new Tween(getObject(newsList[0]),'left',Tween.strongEaseOut,200,0,2,'px');
				x1.start();
				x1.onMotionFinished = function() {
					pauseScroll()
				}
			}
			//
			function shiftBoxes() {
				if (rollOut) {
					var inXStart = 0
					var inXEnd = -200
					var outXStart = 200
					var outXEnd = 0
				} else {
					var inXStart = 200
					var inXEnd = 0
					var outXStart = 0
					var outXEnd = -200
				}
				rollOut = !rollOut
				var t1 = new Tween(getObject(newsList[c]),'left',Tween.strongEaseOut,0,-200,2.5,'px');
				t1.start();
				t1.onMotionFinished = function() {
					incrementFlag = true
					pauseScroll()
				}
				if (c+1 > newsList.length - 1) {
					var ind = 0
				} else {
					var ind = c+1
				}
				var t2 = new Tween(getObject(newsList[ind]),'left',Tween.strongEaseOut,200,0,2.5,'px');
				t2.start();
			}
			//
			function pauseScroll() {
				var pause1 = new Tween(getObject(newsList[c]),'alpha',Tween.regularEaseIn, 0, 0, 3);
				pause1.start();
				pause1.onMotionFinished = function() {
					if (incrementFlag) {
						if (c == newsList.length - 1) {
							incrementFlag = false
							c = 0
						} else {
							c = c+1
						}
					}
					shiftBoxes()
				}
			}