// NAVIGATION SCRIPT BY JON ARNE JØRGENSEN
//************************************************
//**		DECLARE BROWSER			**
//************************************************
//navigator.appCodeName
//navigator.appName
//navigator.appVersion
//navigator.UserAgent
//navigator.language
//navigator.platform
function init(start) {
	browser = false;
	if (start == true) with (navigator) {
		if ((appName == "Netscape") && (parseInt(appVersion)==4)) {
			browser = 'NN4';
		}
		if ((appName == "Netscape") && (parseInt(appVersion)==5)) {
			browser = 'NN6';
		}
		if (appName == "Microsoft Internet Explorer") {
			browser = 'IE';
		}
	}
}
init(true);

//****************************************************************
//**			HELPER FUNCTIONS			**
//****************************************************************


function setCookie(name, value, expire) {
	if (!expire) { 
		document.cookie = name + "=" + escape(value) + "; path=/";
	} else {
		document.cookie = name + "=" + escape(value) + "; expires=" + expire.toGMTString() + "; path=/";
	}
}

function getCookie (name) {
	var dcookie = document.cookie; 
	var cname = name + "=";
	var clen = dcookie.length;
	var cbegin = 0;
	while (cbegin < clen) {
		var vbegin = cbegin + cname.length;
		if (dcookie.substring(cbegin, vbegin) == cname) { 
			var vend = dcookie.indexOf (";", vbegin);
			if (vend == -1) vend = clen;
			return unescape(dcookie.substring(vbegin, vend));
		}
		cbegin = dcookie.indexOf(" ", cbegin) + 1;
		if (cbegin == 0) break;
	}
	return null;
}

function delCookie (name) {
	cookieV = getCookie(name);
	document.cookie = name + "=" + cookieV + "; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
}

function swapem(iname, gname) {
	iname.src = gname.src;
}

//********************************************************
//**			DEFINE VARIBLES			**
//********************************************************

scrollup = new Image;
scrollup.src = "pil_opp_scroll.jpg";
scrollup_over = new Image;
scrollup_over.src = "pil_opp_scroll.jpg";
scrollup_stroked = new Image;
scrollup_stroked.src = "pil_opp_scroll.jpg";

scrolldown = new Image;
scrolldown.src = "pil_ned_scroll.jpg";
scrolldown_over = new Image;
scrolldown_over.src = "pil_ned_scroll.jpg";
scrolldown_stroked = new Image;
scrolldown_stroked.src = "pil_ned_scroll.jpg";

placeLeft = 701;
placeTop = 500;
//placeTop = 340;
frameWidth = 19;
frameHeight= 20;
pfx = ".jpg";
pageScroll = true;
var ScrollTimer;
Friction=0.3;
scrollDist = (scrollLength-4) * 150;
place = 0;
scrollnow = false;
up = true;
down = true;
o = 'over';
u = 'out';

if (typeof(scrollLayerName) == "undefined") {
	scrollLayerName = "proj";
} 

if (typeof(scrollLength) == "undefined" || scrollLength <= 4) {
	scrollLength = 0;
	pageScroll = false;
	pfx = ".jpg";
}

//********************************************************
//**			BEGIN HTML			**
//********************************************************
if ((browser == 'IE') || (browser == 'NN6')) { 				//InternetExplorer
	tag = "DIV";
} else {					//NetscapeNavigator
	tag = "LAYER";
}

if ((browser == 'IE') || (browser == 'NN6')) {
	this.document.write("<"+tag+" id='nav'" + 
		"style='position: absolute; z-index: 20;" +
		"left:" + placeLeft+"px;" +
		"top:" + placeTop+"px;" +
		"width:" + frameWidth+"px;" +
		"height:" + frameHeight+"px" +
		"'>");
} else {
	this.document.write("<"+tag+" id='nav'" +
		" left='"+placeLeft+"'" +
		" top='"+placeTop+"'" +
		" widtht='"+frameWidth+"'" +
		" height='"+frameHeight+"'" +
		" z-index='20'" +
		">");
		
}
this.document.write("<TABLE width='10' border='0' cellpadding='0' cellspacing='0'>" +
		"<TR><TD>");
if (pageScroll) {
	this.document.write("<A href='javascript:void(0);'" +
		"onClick='ScrollLayerUp();'>")
		//"onMouseOver='upMouse(o)'" +
		//"onMouseOut='upMouse(u)'>");
}
this.document.write("<IMG src='pil_opp_scroll"+pfx+"' border='0' width='15' height='15' id='scrollu' alt='   [ oppover ]   '>");
if (pageScroll) {
	this.document.write("</A>");
}
this.document.write("</TD></TR><TR><TD>&nbsp;</TD></TR><TR><TD>");
if (pageScroll) {
	this.document.write("<A href='javascript:void(0);'" +
		"onClick='ScrollLayerDown();'>")
		//"onMouseOver='downMouse(o)'" +
		//"onMouseOut='downMouse(u)'>");
}
this.document.write("<IMG src='pil_ned_scroll"+pfx+"' border='0'  width='15' height='15' id='scrolld' alt='   [ nedover ]   '>");
if (pageScroll) {
	this.document.write("</A>");
}
this.document.write("</TABLE></"+tag+">");

//********************************************************
//**			FUNCTIONS			**
//********************************************************

function getPlace(pageName) {
	place = getCookie(pageName);
	if (pageName == 'notset' || !place) {place = 0;}
	if (browser == 'IE') {				//IE
		document.all[scrollLayerName].style.top = place;
	}
	if (browser == 'NN4') {				//NN4
		document.layers[scrollLayerName].top = place;
	}
	if (browser == 'NN6') {				//NN6
		document.getElementById(scrollLayerName).style.top = place;
	}	
	if (browser == 'IE') {
		if (place == 0) { 
			swapem(scrollu, scrollup_stroked);
			up  = false;
		}
		if (place == -scrollDist) {
			swapem(scrolld, scrolldown_stroked);
			down = false;
		}
	}
}

function ScrollLayerUp() {
	if (browser == 'IE') {				//IE
		if (parseInt(document.all[scrollLayerName].style.top) < 0) {
			if (scrollnow == false) {
	      			place = parseInt(document.all[scrollLayerName].style.top);
				scrollnow = true;
			}
		}
	}
	if (browser == 'NN4') {				//NN4
		if (parseInt(document.layers[scrollLayerName].top) < 0) {
			if (scrollnow == false) {
				place = parseInt(document.layers[scrollLayerName].top);
				scrollnow = true;
			}
		}
	}
	if (browser == 'NN6') {				//NN6
		if (parseInt(document.getElementById(scrollLayerName).style.top) < 0) {
			if (scrollnow == false) {
				place = parseInt(document.getElementById(scrollLayerName).style.top);
				scrollnow = true;
			}
		}
	}
	if (scrollnow) {
		scrollnow = false;
		destination = place + (85*3);
		if (destination > 0) {destination = 0;}
		if (browser == 'IE') {
			if (destination == 0) { 
				swapem(scrollu, scrollup_stroked);
				up = false;
			}
			if (destination != -scrollDist) { 
				swapem(scrolld, scrolldown);
				down = true;
			}
		}
		doScroll();
	}
}

function ScrollLayerDown() {
	if (browser == 'IE') {				//IE
		if (parseInt(document.all[scrollLayerName].style.top) >= -scrollDist) {
			if (scrollnow == false) {
	      			place = parseInt(document.all[scrollLayerName].style.top);
				scrollnow = true;
			}
		}
	}
	if (browser == 'NN4') {				//NN4
		if (parseInt(document.layers[scrollLayerName].top) >= -scrollDist) {
			if (scrollnow == false) {
				place = parseInt(document.layers[scrollLayerName].top);
				scrollnow = true;
			}
		}
	}
	if (browser == 'NN6') {				//NN6
		if (parseInt(document.getElementById(scrollLayerName).style.top) >= -scrollDist) {
			if (scrollnow == false) {
				place = parseInt(document.getElementById(scrollLayerName).style.top);
				scrollnow = true;
			}
		}
	}
	if (scrollnow) {
		scrollnow = false;
		destination = place - (85*3);
		if (destination < -scrollDist) {destination = -scrollDist;}
		if (browser == 'IE') {
			if (destination != 0) { 
				swapem(scrollu, scrollup); 
				up = true;
			}
			if (destination == -scrollDist) { 
				swapem(scrolld, scrolldown_stroked);
				down = false;
			}
		}
		doScroll();
	}
}

function doScroll() {
	if (browser == 'IE') {				//IE
		dist = parseInt(document.all[scrollLayerName].style.top) - destination;
		document.all[scrollLayerName].style.top = parseInt(document.all[scrollLayerName].style.top) - dist*Friction;
		if (dist <= 3 && dist >= 3) {
			document.all[scrollLayerName].style.top = destination;
		}
	}
	if (browser == 'NN4') {				//NN4
		dist = parseInt(document.layers[scrollLayerName].top) - destination;
		document.layers[scrollLayerName].top = parseInt(document.layers[scrollLayerName].top) - dist*Friction;
		if (dist <= 3 && dist >= 3) {
			document.layers[scrollLayerName].top = destination;
		}
	}
	if (browser == 'NN6') {				//NN6
		dist = parseInt(document.getElementById(scrollLayerName).style.top) - destination;
		document.getElementById(scrollLayerName).style.top = parseInt(document.getElementById(scrollLayerName).style.top) - dist*Friction;
		if (dist <= 3 && dist >= 3) {
			document.getElementById(scrollLayerName).style.top = destination;
		}
	}
	if (dist != 0) {
		ScrollTimer = window.setTimeout('doScroll()', 80);
	} else {
		window.clearTimeout(ScrollTimer);
		if (browser == 'IE') {
			if (destination == 0) { 
				swapem(scrollu, scrollup_stroked);
				up  = false;
			}
			if (destination == -scrollDist) {
				swapem(scrolld, scrolldown_stroked);
				down = false;
			}
		}
	}
}

function downMouse(dir) {
	if (browser == 'IE') {
		if (down == true && dir == 'over') {
			swapem(scrolld, scrolldown_over);
		}
		if (down == true && dir == 'out') {
			swapem(scrolld, scrolldown);
		}	
	}
}

function upMouse(dir) {
	if (browser == 'IE') {
		if (up == true && dir == 'over') {
			swapem(scrollu, scrollup_over);
		}
		if (up == true && dir == 'out') {
			swapem(scrollu, scrollup);
		}
	}
}

function JumpScroll(jmpTo)
	{
	if (jmpTo != 0 && jmpTo != -scrollDist)
		{
		swapem(scrollu, scrollup);
		swapem(scrolld, scrolldown);
		up = true;
		down = true;
		}
	else if (jmpTo == 0)
		{
		swapem(scrollu, scrollup_stroked);
		swapem(scrolld, scrolldown);
		up  = false;
		down = true;
		}
	else
		{
		swapem(scrolld, scrolldown_stroked);
		swapem(scrollu, scrollup);
		down = false;
		up = true;
		}

	if (browser == 'IE')
		{				//IE
		document.all[scrollLayerName].style.top = jmpTo;
		}
	if (browser == 'NN4')
		{				//NN4
		document.layers[scrollLayerName].top = jmpTo;
		}
	if (browser == 'NN6')
		{				//NN6
		document.getElementById(scrollLayerName).style.top = jmpTo;
		}
	}

function setPlace(pageName) {
	if (browser == 'IE') {				//IE
		place = parseInt(document.all[scrollLayerName].style.top);
	}
	if (browser == 'NN4') {				//NN4
		place = parseInt(document.layers[scrollLayerName].top);
	}
	if (browser == 'NN6') {				//NN6
		place = parseInt(document.getElementById(scrollLayerName).style.top);
	}
        var expdate = new Date ();
        expdate.setTime (expdate.getTime() + (1000 * 60 * 15));
	setCookie(pageName, place, expdate);
}

