	
	
	// Preloads
	
	pl1 = new Image();
	pl1.src = "images/menubg.png";
	
	//#5A5D75
	
	var cr = 90;
	var cg = 93;
	var cb = 117;
	
	// Blah
	
	fadeColour = new Array();
	
	fadeColour[0] = [  98, 12, 18 ]
	fadeColour[1] = [  98, 51, 16 ]
	fadeColour[2] = [ 102, 92,  4 ]
	fadeColour[3] = [  87, 91, 17 ]
	fadeColour[4] = [  64, 85, 33 ]
	fadeColour[5] = [  13, 73, 30 ]
	fadeColour[6] = [  14, 81,100 ]
	fadeColour[7] = [  10, 56,108 ]
	fadeColour[8] = [  45, 32, 94 ]
	fadeColour[9] = [ 121, 35,104 ]
	
	//
	
	var tr = 0;
	var tg = 0;
	var tb = 0;
	
	var rd = 0;
	var gd = 0;
	var bd = 0;
	
	var fc = 1;
	
	function fadeBgTo(r,g,b) {
		if (cr == tr && cb == tb && cg == tg) { fc = 1 }
		rd = (r - cr) / 15;
		gd = (g - cg) / 15;
		bd = (b - cb) / 15;
		tr = r;
		tg = g;
		tb = b;
		if (fc) { doBgFade() }
		fc = 0;
	}
	
	function doBgFade() {
		
		if (cr > tr) { cr = Math.max(tr,cr + rd) }
		if (cg > tg) { cg = Math.max(tg,cg + gd) }
		if (cb > tb) { cb = Math.max(tb,cb + bd) }
		if (cr < tr) { cr = Math.min(tr,cr + rd) }
		if (cg < tg) { cg = Math.min(tg,cg + gd) }
		if (cb < tb) { cb = Math.min(tb,cb + bd) }

		document.getElementById("content").style.backgroundColor = "RGB(" + Math.round(cr) + "," + Math.round(cg) + "," + Math.round(cb) + ")";
		
		if (cr != tr || cb != tb || cg != tg) {
			setTimeout("doBgFade()",40);		
		} else {
			fc = 1;
		}
		
	}
	
	sWelcome = true;
	
	function switchPanel(id) {
		fadeout(document.getElementById("welcometext"));
		fadeBgTo(fadeColour[id][0],fadeColour[id][1],fadeColour[id][2])
		fadein(document.getElementById('text'+id));
		sWelcome = false;
	}
	
	function hidePanel(id) {
		fadeout(document.getElementById('text'+id));
		sWelcome = true;
		setTimeout("showWelcome()",50)
	}
	
	function showWelcome() {
		if (sWelcome) { fadein(document.getElementById("welcometext")); }
	}
	function initP() {
		for (i=0;i<10;i++) {
			document.getElementById('text'+i).style.visibility="hidden";
		}
	}
	function fadein(obj) {
	
		if (!obj.getAttribute("curopacity")) { obj.setAttribute("curopacity",0); }
		newtimer = true
		
		if (diff(obj.getAttribute("curopacity"),obj.getAttribute("targopacity")) > 5) { newtimer = false }
		
		obj.setAttribute("targopacity",100)
		
		if (newtimer) { dofade(obj) }
		
	}	
	function fadeout(obj) {
		
		if (!obj.getAttribute("curopacity")) { obj.setAttribute("curopacity",0); }
		newtimer = true
		
		if (diff(obj.getAttribute("curopacity"),obj.getAttribute("targopacity")) > 5) { newtimer = false }
		
		
		obj.setAttribute("targopacity",0)
		if (newtimer) { dofade(obj) }
		
	}
	
	function dofade(obj) {
		if (parseInt(obj.getAttribute("curopacity")) < parseInt(obj.getAttribute("targopacity"))) {
			obj.setAttribute("curopacity",parseInt(obj.getAttribute("curopacity")) + 10)
		}
		if (parseInt(obj.getAttribute("curopacity")) > parseInt(obj.getAttribute("targopacity"))) {
			obj.setAttribute("curopacity",parseInt(obj.getAttribute("curopacity")) - 10)
		}	
		
		if (diff(obj.getAttribute("curopacity"),obj.getAttribute("targopacity")) > 0) {
			obj.style.visibility = "visible";
			setTimeout("dofade(document.getElementById('" + obj.getAttribute("id") + "'))",10);
		} else {
			if (obj.getAttribute("targopacity") == 0) {
				obj.style.visibility = "hidden";
			}
			
		}
		//alert(obj.getAttribute("curopacity"))
		obj.style.opacity = obj.getAttribute("curopacity") / 100
		try {
			obj.filters.alpha.opacity = obj.getAttribute("curopacity");
		} catch(e) { }
	}
	
	function diff(v1,v2) {
		return(Math.abs(parseInt(v1)-parseInt(v2)));
	}
	
	
	faderb = new Image();
	faderb.src = "images/fader.png";
	
	function faderPreloadShow() {
	  if (faderb.complete) { 
	  	for (i=0;i<250;i+=10) {
	  		setTimeout('document.getElementById("fader").style.height="' + i + 'px"',i*2);
	  	}
	  } else {
	  	setTimeout("faderPreloadShow()",10);
	  }
	}
	
	function hasFont(fontname) {
		document.write("<span id='font1' style='font-family: System; font-size: 18px; position: absolute; visibility: hidden'>ABCDEFGHIJKLMNOPQRSTUVWXYZ</span>")	
		document.write("<span id='font2' style='font-family: " + fontname + ", System; font-size: 18px; position: absolute; visibility: hidden'>ABCDEFGHIJKLMNOPQRSTUVWXYZ</span>")	
		var diff = document.getElementById("font1").offsetWidth - document.getElementById("font2").offsetWidth
		document.getElementById("font1").parentNode.removeChild(document.getElementById("font1"))
		document.getElementById("font2").parentNode.removeChild(document.getElementById("font2"))
		if (diff != 0) { return true } else { return false }
	}
	
	if (!hasFont("Calibri")) {
		for (s = 0; s < document.styleSheets.length; s++) {
			cssrul = (document.styleSheets[s].cssRules) ? document.styleSheets[s].cssRules : document.styleSheets[s].rules;
			for (r = 0; r < cssrul.length; r++ ) {
				if (parseInt(cssrul[r].style.fontSize)) {
					cssrul[r].style.fontSize = parseInt(cssrul[r].style.fontSize) / 1.05+ "px";
				}
			}
		}
	}

