﻿// CHECK CLIENT BROWSER & PLATFORM
// Works: IE4+, NS4+, Opera

	var its;
	var browserName = '';
	var browserNameLong = '';
	var browserNew = '';
	var preloadFlag = false;
	var Macintosh = navigator.userAgent.indexOf('Mac')>0;

	function its() {
		var n = navigator;
		var ua = ' ' + n.userAgent.toLowerCase();
		var pl = n.platform.toLowerCase();
		var an = n.appName.toLowerCase();

		// browser version
		this.version = n.appVersion;
		this.nn = ua.indexOf('mozilla') > 0;

		// 'compatible' versions of mozilla aren't navigator
		if(ua.indexOf('compatible') > 0) {
			this.nn = false;
		}
		
		this.opera = ua.indexOf('opera') > 0;
		this.ie = ua.indexOf('msie') > 0;
		this.major = parseInt( this.version );
		this.minor = parseFloat( this.version );

		// platform
		this.mac = ua.indexOf('mac') > 0;
		this.win = ua.indexOf('win') > 0;

		// workaround for IE5 which reports itself as version 4.0
		if(this.ie) {
			if(ua.indexOf("msie 5") > 1) {
			var msieIndex = navigator.appVersion.indexOf("MSIE") + 5;
			this.major = parseFloat(navigator.appVersion.substr(msieIndex,3));
			}
		}

		return this;
	}

	function browserNaming() {
		its = new its();
		
		// DOM-enabled browser?
		if (!document.getElementById) {
			browserNew = false;
		} else {
			browserNew = true;
		}

		// browser name
		if (its.opera) {
			browserName = "Opera";
		} else if (its.ie) {
			browserName = "IE";
		} else {
			browserName = "NS";
		}

		// browser number
		browserNameLong = browserName + its.major;
	}
	

// PRELOADING THE MOUSEOVER IMAGES
// Works: IE4+, NS4+, Opera

	function createObject(imgName,imgSrc) {
		if (loadingFlag) {
			eval(imgName + ' = new Image()');
			eval(imgName + '.src = "' + imgSrc + '"');
			return imgName;
		}
	}


// MOUSEOVER IMAGE SWITCHING
// Works: IE4+, NS4+, Opera
// Notes: NS4 needs the DIV-name in there if image is in a DIV

	function changeImage(layer,imgName,imgObj) {
		if (preloadFlag) {
			if (browserNew) {
				document.getElementById(imgName).src = eval(imgObj+'.src');
			}
			if ((!browserNew) && (browserName == "NS") && (layer!=null)) {
				eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src');
			} else {
				document.images[imgName].src = eval(imgObj+'.src');
			}
		}
	}


// IFRAME RESIZING / HEIGHT ONLY
// Works: IE4+, NS4+
// Notes: Not supported in Opera

	function resizeFrame(id,newSize) {
		if (browserNew) {
			resizeLayer = document.getElementById(id);
			resizeLayer.style.height = newSize;
		} else if (browserName == "NS") {
			resizeLayer = document.layers[id];
			resizeLayer.clip.bottom = newSize;
		} else if (browserName == "Opera") {
			// does absolutely nothing
			resizeLayer = document.getElementById(id);
			resizeLayer.style.height = newSize;
		} else {
			resizeLayer = document.all[id];
			resizeLayer.style.height = newSize;
		}
	}


// LOAD IFRAME/LAYER
// Works: IE4+, NS4+, Opera
// Notes: In NS4 use layers instead of DIVs

	function load(targetWindow, page) {
		if ((!browserNew) && (browserName == "NS")) {
			document.layers[targetWindow].src = page;
		} else {
			eval('window.'+targetWindow+'.location.href = page');
		}
	}


// POPUP WINDOW
// Works: IE4+, NS4+, Opera
// Notes: IE4/IE4.5 for the mac spawns windows 17px too short

	function spawn(desktopURL,windowName,width,height) {
		if ((Macintosh) && ((browserNameLong == "IE4") || (browserNameLong == "IE4.5"))) {
 			var newheight = parseInt(height + 17);
		} else {
			var newheight = height;
		}
		window.open(desktopURL,windowName,'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,width='+width+',height='+newheight+',resizable=0');
	}


	function spawnEvil(desktopURL,windowName,width,height) {
 		window.open(desktopURL,windowName,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width='+width+',height='+height+',resizable=0');
	}
	

	
// REMOVES THE LINK BORDER IN IE4+, NS6
// Works: IE4+, NS6+
// Notes: In NS6 the select tags are not blurred

	function unblur() {
		this.blur();
	}

	function getLinksToBlur() {
		if ((browserNew) || (browserName == "IE")) {
			if (browserNew) {
				links = document.getElementsByTagName("a");
			} else {
				links = document.all.tags("a");
			}
			for(i=0; i<links.length; i++) {
				links[i].onfocus = unblur
			}
		}
	}


// SWITCHES BUTTON CLASS
// Works: IE4+, NS6+, Opera
	function bSwitcher(thisId,param) {
		if (browserNew) {
			d = document.getElementById(thisId);
			if (param == "off") {
				d.style.backgroundColor='#7EC700';
			} else if (param == "coff") {
				d.style.backgroundColor='#EC8C8C';
			} else if (param == "tgoff") {
				d.style.backgroundColor='#a2c35a';
			} else if (param == "troff") {
				d.style.backgroundColor='#cca251';
			} else {
				d.style.backgroundColor='#FFA800';
			}
		} else {
			d = document.all[thisId];
			d.className = 'btn'+param;
		}
	}


// SWITCHES BUTTON TEXT CLASS
// Works: IE4+, NS6+
	function buttonTxtSwitcher(thisId,param) {
		if (browserNew) {
			d = document.getElementById(thisId);
			if (param == "off") {
				d.style.backgroundColor='#BCCF9D';
			} else {
				d.style.backgroundColor='#FFD82B';
			}
		} else {
			d = document.all[thisId];
			d.className = 'txtbtn'+param;
		}
	}


// GENERIC CLASS SWITCHER
// Works: IE4+, NS6+
	function cSwitcher(thisId,newClass) {
	    if (browserNew) {
			d = document.getElementById(thisId);
            d.className = newClass;
		} else {
			d = document.all[thisId];
			d.className = newClass;
		}
	}


// DOM / GET PROPERTY
// Works: IE5+, NS6+, Opera

	function getIdProperty(id,property) {
		var styleObject = document.getElementById( id );
		if (styleObject != null) {
			styleObject = styleObject.style;
				if (styleObject[property]) {
					return styleObject[ property ];
				}
			}
		return (styleObject != null) ?
		styleObject[property] :
		null;
	}


// DOM / SET PROPERTY
// Works: IE5+, NS6+, Opera

	function setIdProperty(id,property,value) {
		var styleObject = document.getElementById( id );
		if (styleObject != null) {
			styleObject = styleObject.style;
			styleObject[ property ] = value;
		}
	}


// DOM / MASTER MOVE FUNCTION
// Works: IE5+, NS6+, Opera

	function generic_move(id,xValue,yValue,additive ) {
		var left = parseInt(getIdProperty(id, "left"));
		var top = parseInt(getIdProperty(id, "top"));
		if (additive) {
			setIdProperty(id,"left",left + xValue);
			setIdProperty(id,"top",top + yValue);
		} else {
			setIdProperty(id,"left",xValue);
			setIdProperty(id,"top",yValue);
		}
	}


// NON-DOM / MASTER MOVE FUNCTION
// Works: IE4, NS4

	function generic_move_nondom(id,xValue,yValue,additive) {
		if (browserName == "NS") {
			var thisLayer = document.layers[id];
		} else {
			var thisLayer = document.all[id].style;
		}
		thisLayer.xpos = parseInt(thisLayer.left);
		thisLayer.ypos = parseInt(thisLayer.top);
		if (additive) {
			thisLayer.xpos += xValue;
			thisLayer.ypos += yValue;
			thisLayer.left = thisLayer.xpos;
			thisLayer.top = thisLayer.ypos;
		} else {
			thisLayer.left = xValue;
			thisLayer.top = yValue;
		}
	}


// MOVE TO - SHORTHAND
// Works: IE4+, NS4+, Opera
	
	function move(id,x,y,addit) {
		if (browserNew) {
			generic_move(id,x,y,addit);
		} else {
			generic_move_nondom(id,x,y,addit);
		}
	}
	

// DOM / MASTER MOVE FUNCTION (ONLY Y POS)
// Works: IE5+, NS6+, Opera

	function generic_moveY(id,yValue,additive ) {
		var top = parseInt(getIdProperty(id, "top"));
		if (additive) {
			setIdProperty(id,"top",top + yValue +"px");
		}
		else {
			setIdProperty(id,"top",yValue+"px");
		}
	}


// NON-DOM / MASTER MOVE FUNCTION (ONLY Y POS)
// Works: IE4, NS4

	function generic_move_nondomY(id,yValue,additive) {
		if (browserName == "NS") {
			var thisLayer = document.layers[id];
		}
		else {
			var thisLayer = document.all[id].style;
		}
		thisLayer.ypos = parseInt(thisLayer.top);
		if (additive) {
			thisLayer.ypos += yValue;
			thisLayer.top = thisLayer.ypos+"px";
		}
		else {
			thisLayer.top = yValue+"px";
		}
	}


// MOVE TO - SHORTHAND (ONLY Y POS)
// Works: IE4+, NS4+, Opera
	
	function moveY(id,y,addit) {
		if (browserNew) {
			generic_moveY(id,y,addit);
		}
		else {
			generic_move_nondomY(id,y,addit);
		}
	}


// DOM / MASTER MOVE FUNCTION (ONLY X POS)
// Works: IE5+, NS6+, Opera

	function generic_moveX(id,xValue,additive ) {
		var left = parseInt(getIdProperty(id, "left"));
		if (additive) {
			setIdProperty(id,"left",left + xValue+"px");
		}
		else {
			setIdProperty(id,"left",xValue+"px");
		}
	}


// NON-DOM / MASTER MOVE FUNCTION (ONLY X POS)
// Works: IE4, NS4

	function generic_move_nondomX(id,xValue,additive) {
		if (browserName == "NS") {
			var thisLayer = document.layers[id];
		}
		else {
			var thisLayer = document.all[id].style;
		}
		thisLayer.xpos = parseInt(thisLayer.left);
		if (additive) {
			thisLayer.xpos += xValue;
			thisLayer.left = thisLayer.xpos+"px";
		}
		else {
			thisLayer.left = xValue+"px";
		}
	}


// MOVE TO - SHORTHAND (ONLY X POS)
// Works: IE4+, NS4+, Opera
	
	function moveX(id,x,addit) {
		if (browserNew) {
			generic_moveX(id,x,addit);
		}
		else {
			generic_move_nondomX(id,x,addit);
		}
	}


// HIDE AND SHOW LAYERS
// Works: IE4+, NS4+, Opera

	function hide(id) {
		if (browserNew) {
			setIdProperty(id,"visibility","hidden");
		} else {
			if (browserName == "NS") { document.layers[id].visibility = "hide"; }
			else { document.all[id].style.visibility = "hidden"; }
		}
	}

	function show(id) {
		if (browserNew) {
			setIdProperty(id,"visibility","visible");
		} else {
			if (browserName == "NS") { document.layers[id].visibility = "show"; }
			else { document.all[id].style.visibility = "visible"; }
		}
	}


// CHANGE DISPLAY VALUE FOR LAYERS
// Works: IE4+, NS4+, Opera

	function switchDisplay(id,value) {
		if (browserNew) {
			setIdProperty(id,"display",value);
		} else {
			if (browserName == "NS") {
				document.layers[id].display = value;
			} else {
				document.all[id].style.display = value;
			}
		}
	}
	

// STYLESHEET LINK WRITER
// Works: IE4+, NS4+, Opera

	function writeLinkSettings(linkSettings) {

		// set generic settings
		lColor = '#A50000';
		aColor = '#A50000';
		vColor = '#CC7701';
		thisDec = 'none';
		thisWeight = 'normal';

		// cookie values
		if (linkSettings == 'underline') {
			thisDec = 'underline';
		} else if (linkSettings == 'bold') {
			thisWeight = 'bold';
		} else if (linkSettings == 'jakob') {
			lColor = '#0000FF';
			aColor = '#FF0000';
			vColor = '#800080';
			thisDec = 'underline';
			thisWeight = 'normal';
		}

		// write out styles
		document.write("<style type='text/css'><!-- ");
		document.write("A:link { color: "+lColor+"; text-decoration: "+thisDec+"; font-weight: "+thisWeight+"; }");
		document.write("A:visited { color: "+vColor+"; text-decoration: "+thisDec+"; font-weight: "+thisWeight+"; }");
		document.write("A:active { color: "+aColor+"; text-decoration: "+thisDec+"; font-weight: "+thisWeight+"; }");
		document.write("A.sml:link { color: "+lColor+"; text-decoration: "+thisDec+"; font-weight: "+thisWeight+"; }");
		document.write("A.sml:visited { color: "+vColor+"; text-decoration: "+thisDec+"; font-weight: "+thisWeight+"; }");
		document.write("A.sml:active { color: "+aColor+"; text-decoration: "+thisDec+"; font-weight: "+thisWeight+"; }");
		if (linkSettings != 'jakob') {
			document.write("A:hover { color: #AE6500; text-decoration: underline; font-weight: "+thisWeight+"; }");
			document.write("A.sml:hover { color: #AE6500; text-decoration: underline; font-weight: "+thisWeight+"; }");
		} else {
			document.write("A:hover { text-decoration: underline; font-weight: normal;  }");
			document.write("A.sml:hover { text-decoration: underline; font-weight: normal; }");
		}
		document.write(" --></style>");
	}


// RANDOM NUMBER GENERATOR
// Works: IE4+, NS4+, Opera

	function randNum (num) {
		var now = new Date();
		var rand = Math.round(num * Math.cos(now.getTime()));
		if (rand < 0) rand = - rand; 
		if (rand == 0) rand++;
		return rand;
	}


// FIXES THE OS X IFRAME DISPLAY PROBLEMS
// Notes: Only needed for IE5/mac under OS X

	function fix_OSX_IE_DisplayBug() {
		if ((Macintosh) && (browserName == 'IE') && (browserNew)) {
			try {
				objBody = document.getElementsByTagName("body");
				for (i=0; i < objBody.length; i++) {
					objBody[i].style.visibility = "hidden";
					objBody[i].style.visibility = "visible";
				}
			}
			catch(error) {
				// ignore error
			}
		}
	}


// RESIZE WINDOW FUNCTION
// Works: IE4+, NS6+, Opera

	function resizeBrowser(width,height) {
		thisTargetWidth = width;
		thisTargetHeight = height;
		
		// NS6 HAS DECENT SUPPORT FOR THIS
		if (self.innerWidth) {
			frameWidth = parent.innerWidth;
			frameHeight = parent.innerHeight;
			realWidth = self.outerWidth;
			realHeight = self.outerHeight;
			widthMod = (realWidth - frameWidth);
			heightMod = (realHeight - frameHeight);
			parent.window.resizeTo(thisTargetWidth+widthMod,thisTargetHeight+heightMod);
		}
		// WHEREAS THE IE SUPPORT SUCKS ASSCOCK
		else {
			// ie4-ie4.5 mac
			if ((Macintosh) && (navigator.appVersion.indexOf("MSIE 4.") > 1)) {
				parent.window.resizeTo(thisTargetWidth,thisTargetHeight+101);
			}
			// ie5+ mac
			else if (Macintosh) {
				if (self.screen.width > 1024) {
					parent.window.moveTo(20,5);
				}
				else {
					parent.window.moveTo(0,5);
				}
				parent.window.resizeTo(thisTargetWidth,thisTargetHeight+107);
			}
			// ie pc
			else {
				frameWidth = parent.document.body.offsetWidth;
				frameHeight = parent.document.body.offsetHeight;
				calcWidth = thisTargetWidth - frameWidth;
				calcHeight = thisTargetHeight - frameHeight + 3;
				parent.window.resizeBy(calcWidth,calcHeight);
			}
		}
	}


// ANTI-SPAM
// Works: IE4+, NS6+, Opera

	function antispam(name,domain) {
    	document.location = "mailto:" + name + "@" + domain;
	}


// STATUS
// Works: IE4+, NS6+, Opera

	function s(txt) {
		self.status = txt;
	}
	

// REWRITE TEXT LAYER

	function rwt(txt, id) {
	    txt += "\n";
	    // NS6
	    if (browserNew && browserName == "NS") {
	        botOver = document.getElementById(id);
	        range = document.createRange();
	        range.setStartBefore(botOver);
	        domfrag = range.createContextualFragment(txt);
	        while (botOver.hasChildNodes()) {
	            botOver.removeChild(botOver.lastChild);
	        }
	        botOver.appendChild(domfrag);
	    }
	    // IE 4+
	    else {
	        document.all[id].innerHTML = txt;
	    }
	}
	
// FAKE DROPDOWN FUNCTIONS

	function foldDrop(id) {
		if (!inPeel) {
			inPeel = true;
			if (sShown == true) {
				// dropdown shown - hide it again
				dropperUp(id); 
				sShown = false;
			} else {
				// dropdown not shown - show it
				dropperDown(id);
				sShown = true;
			}
		}
	}
        
	function dropperDown(id) {
		curTop = parseInt(getIdProperty(id,'top'));
		if ((curTop == minTop) || (curTop < maxTop)) {
			// on its way down
			moveY(id,2,true);
			setTimeout("dropperDown('" + id + "')",delay);
		} else {
			// all done
			moveY(id,maxTop,false);
			inPeel = false;
		}
	}
        
	function dropperUp(id) {
		curTop = parseInt(getIdProperty(id,'top'));
		if (curTop > (minTop + 2)) {
			// on its way up
			moveY(id,-2,true);
			setTimeout("dropperUp('" + id + "')",delay);
		} else {
			// finished
			moveY(id,minTop,false);
			inPeel = false;
		}
	}
	
	function resetDrop(id) {
	    moveY(id,minTop,false);
		inPeel = false;
		sShown = false;
	}
	
	function notop() {
	
	}
