function Is(){ 
  this.ver=navigator.appVersion;
  this.agent=navigator.userAgent;
  this.dom=document.getElementById?1:0;
  this.opera5=this.agent.indexOf("Opera 5")>-1;
  this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
  this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
  this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
  this.ie=this.ie4||this.ie5||this.ie6;
  this.mac=this.agent.indexOf("Mac")>-1;
  this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
  this.ns4=(document.layers && !this.dom)?1:0;
  this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);
  return this;
	}

function wh() {
	pw = (is.ns6) ? innerWidth : (is.ie) ? ((document.compatMode=='CSS1Compat') ? document.documentElement : document.body).clientWidth: 0;
	ph = (is.ns6) ? innerHeight : (is.ie) ? ((document.compatMode=='CSS1Compat') ? document.documentElement : document.body).clientHeight: 0;
	}

var is = new Is();
var d = document;

function g(o) {
	return d.getElementById(o);
	}

function max(a, b) {
	return (a>b)?a:b;
	}

function loader() {
	window.onresize = rejib;
	setTimeout("fadeto('backhome',247)",500);
	setTimeout("fadeto('backhome',200)",700);
	setTimeout("fadeto('backhome',247)",770);
	}

function rejib() {
	if(!is.dom) return;
	wh();
	g('descback').style.top = parseInt(g('present').offsetHeight) + 100 + 'px';
	var contentheight = max(parseInt(g('desctitle').offsetHeight), parseInt(g('description').offsetHeight));
	g('descback').style.height = max(contentheight+50, ph - (parseInt(g('present').offsetHeight) + 101)) + 'px';
	g('descback').style.width = ((is.mac && is.ie) ? (pw-40) : pw)+'px';
	g('descback').style.visibility = 'visible';
	}

function dec2hex(n) {
	var t = ''+n.toString(16);
	return (t.length == 1) ? '0'+t : t;
	}

function hex2dec(n) {
	var t = ''+parseInt(n, 16);
  return (t.length == 1) ? '0'+t : t;
	}
	
function csplit(c, p) {
  return hex2dec(c.substring(0+ (p* 2), 2+(p*2)));
	}

var rgbPattern = /\brgb\(\s*([\d]{1,3})(%)?\s*\,\s*([\d]{1,3})(%)?\s*\,\s*([\d]{1,3})(%)?\s*\)/i;

function rgb2hex(inp){
	var hex = '#';
	for(var rgb; (rgb = inp.match(rgbPattern)) != null;){	
		for(var j = 1; j < rgb.length; j++) {
			if(!isNaN(parseInt(rgb[j]))) {
				hex += ''+dec2hex(parseInt(rgb[j]));
			  }
			}
		inp = inp.replace(rgb[0], hex);
		}
	return inp;
	}

function fader(obj) {
	var o = g(obj);
	o.backa = o.backa + (o.targ-o.backa)/6;
	hexval = dec2hex(Math.round(o.backa));
	if(o.backa < o.targ + 2 && o.backa > o.targ - 2) {
		o.backa = o.targ;
		o.fading = 0;
		}
	o.style.background = '#'+hexval+hexval+hexval;
	
	if(o.fading == 1) {
		setTimeout("fader('"+obj+"')",20);
		}
	}

function fadeto(o, a) {
	var bg = g(o).style.backgroundColor;
	if(is.ns6) bg = rgb2hex(bg);

	g(o).backa = parseInt(csplit(bg.substring(1,7),1));
	g(o).targ = a;
	if(!g(o).fading) {
		g(o).fading = 1;
		setTimeout("fader('"+o+"')",20);
		}
	}
