/*
add_window_function.js
Don Havey: www.donhavey.com
use with permission, please
*/
function add_window_function(of,f){
	if(typeof of!='function'){ nf = f; }else{ nf = function(){ if(of){ of(); } f(); } }
	return nf;
}

/*
add_function.js
Don Havey: www.donhavey.com
use with permission, please
*/
var event_functions = new Object();
function add_function(n,function_string){
	if(!event_functions.n){
		event_functions[n] = [];
		var l = 0;
	}else{
		var l = event_functions[n].length;
	}
	event_functions[n][l] = { init:function(){ eval(function_string); }, instructions:function_string };
	return event_functions[n][l].init;
}	 

/*
cursor_xy.js
Don Havey: www.donhavey.com
use with permission, please
requires cursor_xy.css
*/
var cursor = {
	init:function(){
		document.onmousemove = cursor.track;
		if(document.captureEvents){
			ev = document.captureEvents(Event.MOUSEMOVE);
		}
		cursor.cx = 0;
		cursor.cy = 0;
	},
	track:function(ev){
		if(document.body){
			var ev = ev||window.event;
			if(ev.pageX&&ev.pageY){
				cursor.cx = ev.pageX;
				cursor.cy = ev.pageY;
			}else if(ev.clientX&&ev.clientY){
				cursor.cx = ev.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
				cursor.cy = ev.clientY+document.body.scrollTop+document.documentElement.scrollTop;
			}
			if(document.getElementById("cursor_xy")&&document.getElementById("cursor_xy").style.display!="none"){
				document.getElementById("cursor_xy").firstChild.nodeValue = cursor.cx+", "+cursor.cy;
			}
		}
	},
	x:function(){
		return cursor.cx;
	},
	y:function(){
		return cursor.cy;
	}
}
window.onload = add_window_function(window.onload,cursor.init);

/*
dom_element.js
Don Havey: www.donhavey.com
use with permission, please
*/
function dom_element(el,parent,cl,id){
	var e = document.createElement(el);
	if(cl){
		e.className = cl;
	}
	if(id){
		e.setAttribute("id",id);
		e.setAttribute("name",id);
	}
	if(parent){
		parent.appendChild(e);
	}
	return e;
}

/*
dom_image.js
Don Havey: www.donhavey.com
use with permission, please
requires icons/loader2.gif, dom_image.css
*/
function dom_image(w,h,src,parent,cl,id,functions){
	var e = dom_element("div",parent,"img_wrapper",id+"_wrapper");
	e.style.width = w+"px";
	e.style.height = h+"px";
	var pi = dom_element("img",e,"img_preloader",id+"_preloader");
	pi.src = "icons/loader2.gif";
	pi.style.top = (h/2-10)+"px";
	var i = dom_element("img",e,cl,id);
	i.style.width = w+"px";
	i.style.height = h+"px";
	i.style.visibility = "hidden";
	var ii = new Image();
	ii.onload = function(){
		i.src = ii.src;
		i.style.visibility = "visible";
		pi.parentNode.removeChild(pi);
		if(functions&&functions.onload){
			functions.onload();
		}
	}
	ii.src = src;
	return i;
}

/*
dom_text.js
Don Havey: www.donhavey.com
use with permission, please
*/
function dom_text(text,parent){
	var e = document.createTextNode(text);
	if(parent){
		parent.appendChild(e);
	}
	return e;
}

/*
drag.js
originally by Aaron Boodman: www.youngpup.net
modified by Don Havey: www.donhavey.com
use with permission, please
*/
var drag = {
	obj : null,
	init : function(o,oRoot,minX,maxX,minY,maxY){
		o.onmousedown = drag.dragOn;
		o.root = oRoot && oRoot !== null ? oRoot : o;
		o.minX	= typeof(minX) != 'undefined' ? minX : null;
		o.minY	= typeof(minY) != 'undefined' ? minY : null;
		o.maxX	= typeof(maxX) != 'undefined' ? maxX : null;
		o.maxY	= typeof(maxY) != 'undefined' ? maxY : null;
		o.root.onDragStart = new Function();
		o.root.onDragEnd = new Function();
		o.root.onDrag = new Function();
	},
	dragOn : function(e){
		var o = this;
		drag.obj = this;
		e = drag.ee(e);
		var y = parseInt(o.root.style.top);
		var x = parseInt(o.root.style.left);
		o.root.onDragStart(x,y);
		o.lastMouseX = e.clientX;
		o.lastMouseY = e.clientY;
		if (o.minX !== null) o.minMouseX = e.clientX-x+o.minX;
		if (o.maxX !== null) o.maxMouseX = o.minMouseX+o.maxX-o.minX;
		if (o.minY !== null) o.minMouseY = e.clientY-y+o.minY;
		if (o.maxY !== null) o.maxMouseY = o.minMouseY+o.maxY-o.minY;
		document.onmousemove = drag.dragMove;
		document.onmouseup = drag.dragOff;
		return false;
	},
	dragMove : function(e){
		e = drag.ee(e);
		var o = drag.obj;
		var ex	= e.clientX;
		var ey	= e.clientY;
		var x = parseInt(o.root.style.left);
		var y = parseInt(o.root.style.top);
		var nx,ny;
		if (o.minX!==null) ex = Math.max(ex,o.minMouseX);
		if (o.maxX!==null) ex = Math.min(ex,o.maxMouseX);
		if (o.minY!==null) ey = Math.max(ey,o.minMouseY);
		if (o.maxY!==null) ey = Math.min(ey,o.maxMouseY);
		nx = x+(ex-o.lastMouseX);
		ny = y+(ey-o.lastMouseY);
		drag.obj.root.style.left = nx+"px";
		drag.obj.root.style.top = ny+"px";
		drag.obj.lastMouseX	= ex;
		drag.obj.lastMouseY	= ey;
		drag.obj.root.onDrag(nx,ny);
		return false;
	},
	dragOff : function(){
		document.onmousemove = null;
		document.onmouseup = null;
		document.onmouseup = null;
		drag.obj.root.onDragEnd(parseInt(drag.obj.root.style.left),parseInt(drag.obj.root.style.top));
		drag.obj = null;
	},
	ee : function(e){
		if (typeof(e)=='undefined')	e = window.event;
		if (typeof(e.layerX)=='undefined') e.layerX = e.offsetX;
		if (typeof(e.layerY)=='undefined') e.layerY = e.offsetY;
		return e;
	}
}

/*
fade.js
Don Havey: www.donhavey.com
use with permission, please
requires set_opacity.js
*/
if(!timeouts){
	var timeouts = new Object();
}
timeouts.fade = new Object();
var fade_functions = new Object();
function fade(o,ta,speed,func){
	for(var i=0;i<o.length;i++){
		if(timeouts.fade[o[i]]!=0){
			clearTimeout(timeouts.fade[o[i]]);
			timeouts.fade[o[i]] = 0;
		}
		if(func){
			fade_functions[o[i]] = func;
		}
		var inc = 40;
		var e = document.getElementById(o[i]);
		if(e){
			var a = Math.round(1-ta);
			if(e.style.opacity){
				a = parseFloat(e.style.opacity);
			}else if(e.style.filter){
				a = parseFloat(e.style.filter.substring(e.style.filter.search(/=/)+1,e.style.filter.search(/\)/)))/100;
			}
			if(Math.abs(ta-a)<.005){
				set_opacity(e,ta);
				if(typeof(fade_functions[o[i]])=="function"){
					fade_functions[o[i]]();
					fade_functions[o[i]] = 0;
				}
			}else{
				set_opacity(e,a+(ta-a)*speed);
				timeouts.fade[o[i]] = setTimeout("fade(['"+o[i]+"'],"+ta+","+speed+")");
			}
		}else{
			fade_functions[o[i]] = 0;
		}
	}
	return false;
}

/*
highlight.js
Don Havey: www.donhavey.com
use with permission, please
*/
var oc = new Object;
function highlight(o,c){
	if(!c){
		for(var i=0;i<o.length;i++){
			var e = document.getElementById(o[i]);
			e.style.backgroundColor = oc[o[i]];
		}
	}else{
		for(var i=0;i<o.length;i++){
			var e = document.getElementById(o[i]);
			oc[o[i]] = e.style.backgroundColor;
			e.style.backgroundColor = c;
		}
	}
	return false;
}

/*
popin.js
Don Havey: www.donhavey.com
use with permission, please
requires dom_element.js, set_opacity.js, add_function.js, dom_text.js, and popin.css
*/
var popin = {
	padding:15,
	margin:0,
	alpha:.9,
	speed:.8,
	load_img:"icons/loader2.gif",
	close_img:"icons/close.gif",
	init:function(){
		this.clear();
		var body = document.getElementsByTagName("body")[0];
		var p = dom_element("div",body,"popin","popin");
		var pc = dom_element("div",body,"popin_cover","popin_cover");
		p.style.padding = this.padding+"px";
		p.style.margin = this.margin+"px";
		var closer = dom_element("div",body,"popin_closer","popin_closer");
		var closer_img = dom_element("img",closer,"popin_closer_img","popin_closer_img");
		var closer_text = dom_text("close ",closer);
		closer_img.src = this.close_img;
	},
	clear:function(){
		var body = document.getElementsByTagName("body")[0];
		var p = document.getElementById("popin");
		var pc = document.getElementById("popin_cover");
		var closer = document.getElementById("popin_closer");
		if(p){
			body.removeChild(p);
		}
		if(pc){
			body.removeChild(pc);
		}
		if(closer){
			body.removeChild(closer);
		}
	},
	pop:function(left,top,w,h,cover,filepath,filetype,content){
		this.init();
		this.left = left;	this.top = top;	this.w = w;	this.h = h;	this.filepath = filepath; this.filetype = filetype; this.content = content;
		var p = document.getElementById("popin");
		var pc = document.getElementById("popin_cover");
		var closer = document.getElementById("popin_closer");
		var win = window_size();
		//set popin attributes
		if(left=="center"){
			p.style.left = closer.style.left = (win.sx+(win.w-w)/2-this.padding-this.margin)+"px";
		}else{
			p.style.left = closer.style.left = (left-this.padding-this.margin-w/2)+"px";
		}
		if(top=="center"){
			p.style.top = (win.sy+(win.h-h)/2-this.padding-this.margin-50)+"px";
		}else{
			p.style.top = (top-this.padding-this.margin-h/2-50)+"px";
		}
		p.style.width = w+"px";	//p.style.height = h+"px";
		p.style.visibility = "hidden";
		set_opacity(p,.01);
		//set closer attributes
		closer.style.width = (w+this.padding*2+this.margin*2)+"px";
		set_opacity(closer,.01);
		closer.onclick = add_function("popin_out","document.getElementById('popin_closer').onclick = function(){}; document.getElementById('popin_cover').onclick = function(){}; fade(['popin_cover','popin','popin_closer'],0,"+this.speed+",popin.clear);");
		//set cover attributes
		pc.style.width = win.w+"px";
		pc.style.height = win.h+"px";
		set_opacity(pc,.01);
		if(cover){			
			fade(["popin_cover","popin","popin_closer"],this.alpha-.01,this.speed,this.show);
		}
		pc.onclick = add_function("popin_out","fade(['popin_cover','popin','popin_closer'],0,"+this.speed+",popin.clear);");
		//add image or other file
		if(filepath&&filetype){
			if(filetype!="img"){
				var o = dom_element(filetype,p,"popin_object","popin_object");
				o.style.width = (w-this.padding)+"px";
				o.style.height = (h-this.padding)+"px";
				o.src = filepath;
			}else{
				var o = dom_image(w-this.padding,h-this.padding,filepath,p,"popin_object","popin_object");
			}
		}
		//add text or node
		if(content){
			this.append(content);
		}
		//align closer
		closer.style.top = (y(p)+p.offsetHeight-2)+"px";
	},
	show:function(){
		var p = document.getElementById("popin");
		var pc = document.getElementById("popin_cover");
		var closer = document.getElementById("popin_closer");
		p.style.visibility = "visible";
		pc.style.visibility = "visible";
		closer.style.visibility = "visible";
		closer.style.top = (y(p)+p.offsetHeight-2)+"px";
	},
	append:function(content){
		var p = document.getElementById("popin");
		if(typeof(content)=="string"){
			var e = dom_element("div",p,"popin_text");
			e.style.width = (this.w-this.padding)+"px";
			dom_text(content,e);
		}else if(typeof(content)=="object"){
			p.appendChild(content);
		}
	}
}

/*
scale.js
Don Havey: www.donhavey.com
use with permission, please
*/
if(!timeouts){
	var timeouts = new Object();
}
timeouts.scale = new Object();
function scale(o,tl,speed,wh){
	for(var i=0;i<o.length;i++){
		var e = document.getElementById(o[i]);
		if(e){
			var l = (wh=="w") ? e.offsetWidth : e.offsetHeight;
			if(Math.abs(tl-l)<.01){
				if(wh=="w"){
					e.style.width = tl+"px";
				}else{
					e.style.height = tl+"px";
				}
			}else{
				if(wh=="w"){
					e.style.width = (l+(tl-l)*speed)+"px";
				}else{
					e.style.height = (l+(tl-l)*speed)+"px";
				}
				if(timeouts.scale[o[i]]!=0){
					clearTimeout(timeouts.scale[o[i]]);
					timeouts.scale[o[i]] = 0;
				}
				timeouts.scale[o[i]] = setTimeout("scale(['"+o[i]+"'],"+tl+","+speed+",'"+wh+"')",30);
			}
		}
	}
	return false;
}

/*
set_opacity.js
Don Havey: www.donhavey.com
use with permission, please
*/
function set_opacity(e,n){
	e.style.opacity = n;
	e.style.filter = "alpha(opacity="+Math.round(n*100)+")";
	if(n==0){
		e.style.visibility = "hidden";
	}else{
		e.style.visibility = "visible";
	}
	return false;
}

/*
slideshow.js
Don Havey: www.donhavey.com
use with permission, please
requires xml.js, dom_element.js, and slideshow.css
*/
if(!timeouts){
	var timeouts = new Object();
}
timeouts.slideshow = new Object();
var slideshows = new Object();
function slideshow(name,mw,mh,delay,urls,structure,parent,playing,internal_actions,external_actions){
	//passed var init
	this.name = name;
	this.mw = mw;
	this.mh = mh;
	this.urls = urls;
	this.structure = structure;
	this.delay = delay;
	this.parent = parent;
	this.internal_actions = internal_actions;
	this.external_actions = external_actions;
	//functions
	this.init = function(){
		//dom init
		this.e = dom_element("div",this.parent,"slideshow","slideshow-"+this.name);
		this.current_image = dom_element("div",this.e,"current_image","current_image-"+this.name);
		//var init
		this.images = [];
		this.playing = playing;
		this.preload = 2;
		this.i = 0;
		this.speed = .7;
		this.fade_delay = 0;
		var n = 1;
		while(n>.01){
			n -= n*this.speed;
			this.fade_delay++;
		}
		this.fade_delay *= 40;
		//load images
		if(this.structure){
			for(var j=0;j<this.urls.length;j++){
				setTimeout("xml.request('"+this.urls[j]+"',slideshows["+this.name+"].load,false,'"+this.name+"')",500*j);
			}
		}else{
			//if structure array is not passed, assume that the data has already been loaded and parsed
			for(var j=0;j<this.urls.length;j++){
				this.load(urls[j]);
			}
		}
	}
	this.play = function(){
		if(timeouts.slideshow.next!=0){
			clearTimeout(timeouts.slideshow.next);
			timeouts.slideshow.next = 0;
		}
		if(!this.playing){
			timeouts.slideshow.next = setTimeout("slideshows['"+this.name+"'].next();",this.delay);
			this.playing = true;
		}else{
			this.next();
		}
	}
	this.pause = function(){
		if(timeouts.slideshow.next!=0){
			clearTimeout(timeouts.slideshow.next);
			timeouts.slideshow.next = 0;
		}
		if(this.playing){
			this.playing = false;
		}
	}
	this.next = function(){
		if(timeouts.slideshow.next!=0){
			clearTimeout(timeouts.slideshow.next);
			timeouts.slideshow.next = 0;
		}
		fade(["current_image-"+this.name],.01,this.speed,add_function(this.name+"-fade","slideshows['"+this.name+"'].next_in();"));
		this.i = (this.i+1)%this.images.length;
		for(var j=1;j<this.preload;j++){
			this.images[(this.i+j)%this.images.length].o.src = this.images[(this.i+j)%this.images.length].filepath;
		}
		this.images[(this.images.length+this.i-1)%this.images.length].o.src = this.images[(this.images.length+this.i-1)%this.images.length].filepath;
	}
	this.next_in = function(){
		if(timeouts.slideshow.next!=0){
			clearTimeout(timeouts.slideshow.next);
			timeouts.slideshow.next = 0;
		}
		this.display_image(this.images[this.i],"current");
		fade(["current_image-"+this.name],.99,this.speed);
		if(this.playing){
			timeouts.slideshow.next = setTimeout("slideshows['"+this.name+"'].next();",this.delay);
		}
	}
	this.previous = function(){
		if(timeouts.slideshow.next!=0){
			clearTimeout(timeouts.slideshow.next);
			timeouts.slideshow.next = 0;
		}
		this.i = (this.i-1+this.images.length)%this.images.length;
		for(var j=1;j<this.preload;j++){
			this.images[(this.i+j)%this.images.length].o.src = this.images[(this.i+j)%this.images.length].filepath;
		}
		this.images[(this.images.length+this.i-1)%this.images.length].o.src = this.images[(this.images.length+this.i-1)%this.images.length].filepath;
		this.display_image(this.images[this.i],"current");
		this.playing = false;
	}
	this.load = function(data,o){
		if(o){
			o = slideshows[o];
			o.images[o.images.length] = xml.parse(data.responseXML.documentElement.getElementsByTagName("image")[0],o.structure);
		}else{
			o = this;
			o.images[o.images.length] = data;
		}
		o.images[o.images.length-1].o = new Image();
		if(o.preload==0){
			o.images[o.images.length-1].o.src = o.images[o.images.length-1].filepath;
		}
		if(o.images.length==1){
			o.display_image(o.images[0],"current");
			o.images[0].o.src = o.images[0].filepath;
		}else if(o.images.length<o.preload){
			o.images[o.images.length-1].o.src = o.images[o.images.length-1].filepath;
		}
		if(o.images.length==o.urls.length&&o.playing){
			o.play();
		}
	}
	this.display_image = function(image,type){
		this[type+"_image"].style.visibility = "hidden";
		if(!this.current_image_img){
			this.current_image_img = dom_element("img",this.current_image,"current_image_img","current_image_img"+this.name);
			this.current_image_img.setAttribute("vspace",0);
			this.current_image_img.setAttribute("hspace",0);
			var onclick = "";
			var onmouseover = "";
			var onmouseout = "";
			if(this.internal_actions){
				if(this.internal_actions.onclick){ onclick += "slideshows['"+this.name+"']."+this.internal_actions.onclick+"();"; }
				if(this.internal_actions.onmouseover){ onmouseover += "slideshows['"+this.name+"']."+this.internal_actions.onmouseover+"();"; }
				if(this.internal_actions.onmouseout){ onmouseout += "slideshows['"+this.name+"']."+this.internal_actions.onmouseot+"();"; }
			}
			if(this.external_actions){
				if(this.external_actions.onclick){ onclick += this.external_actions.onclick; }
				if(this.external_actions.onmouseover){ onmouseover += this.external_actions.onmouseover; }
				if(this.external_actions.onmouseout){ onmouseout += this.external_actions.onmouseout; }
			}
			if(onclick!=""){ this.current_image_img.onclick = add_function(this.name+"-click",onclick); }
			if(onmouseover!=""){ this.current_image_img.onmouseover = add_function(this.name+"-mouseover",onmouseover); }
			if(onmouseout!=""){ this.current_image_img.onmouseout = add_function(this.name+"-mouseout",onmouseout); }
		}
		var ratio = image.width/image.height;
		var w = image.width;
		var h = image.height;
		if(w<this.mw){ w = this.mw; h = this.mw/ratio; }
		if(w>this.mw){ w = this.mw; h = this.mw/ratio; }
		if(h>this.mh){ w = this.mh*ratio; h = this.mh; }
		this[type+"_image"].style.width = w+"px";
		this[type+"_image"].style.height = h+"px";
		this[type+"_image_img"].setAttribute("width",w);
		this[type+"_image_img"].setAttribute("height",h);
		this[type+"_image_img"].setAttribute("src",image.filepath);
		this[type+"_image"].style.visibility = "visible";
	}
}

/*
swap_thumbs.js
Don Havey: www.donhavey.com
use with permission, please
*/
if(!timeouts){
	var timeouts = new Object;
}
timeouts.swap_thumbs = new Object;
function swap_thumbs(o1,o2){
	var speed = .2;
	var delay = 0;
	var n = 1;
	while(n>.01){
		n -= n*speed;
		delay++;
	}
	delay *= 40;
	var e1 = document.getElementById(o1);
	var e2 = document.getElementById(o2);
	if(e1.src!=e2.src){
		fade(o1,.01,speed,true);
		clearTimeout(timeouts.swap_thumbs.swap);
		clearTimeout(timeouts.swap_thumbs.fade);
		timeouts.swap_thumbs.swap = setTimeout("document.getElementById('"+o1+"').src=document.getElementById('"+o2+"').src",delay);
		timeouts.swap_thumbs.fade = setTimeout("fade('"+o1+"',.99,.2,true)",delay+40);
	}
	return false;
}

/*
tooltip.js
Don Havey: www.donhavey.com
use with permission, please
requires cursor_xy.js and tooltip.css
*/
if(!timeouts){
	var timeouts = new Object();
}
timeouts.tooltip = new Object();
function tooltip(text,runonce,delay){
	if(document.getElementById("tooltip")){
		if(timeouts.tooltip.track!=0){
			clearTimeout(timeouts.tooltip.track);
			timeouts.tooltip.track = 0;
		}
		if(timeouts.tooltip.delay!=0){
			clearTimeout(timeouts.tooltip.delay);
			timeouts.tooltip.delay = 0;
		}
		if(text){
			if(runonce){
				if(!delay){
					fade(['tooltip'],.9,.2);
				}else{
					timeouts.tooltip.delay = setTimeout("fade(['tooltip'],.9,.2)",delay);
				}
			}
			var e = document.getElementById("tooltip");
			e.style.left = (cursor.x()+2)+"px";
			e.style.top = (cursor.y()-e.offsetHeight-3)+"px";
			e.firstChild.nodeValue = text;
			timeouts.tooltip.track = setTimeout("tooltip('"+text+"')",40);
		}else{
			if(document.getElementById("tooltip").style.visibility=="visible"){
				fade(['tooltip'],0,.2);
			}
		}
	}
}

/*
window_size.js
Don Havey: www.donhavey.com
use with permission, please
*/
function window_size(resize){
	var w = 0; var h = 0; var ow = 0; var oh = 0; var sx = 0; var sy = 0;
	w = iw();
	h = ih();
	if(resize){
		window.resizeTo(w+10,h+10);
		ow = (w+10)-iw();
		oh = (h+10)-ih();
		window.resizeTo(w+ow,h+oh);
	}
	sx = xscroll();
	sy = yscroll();
	return {w:w,h:h,ow:ow,oh:oh,sx:sx,sy:sy};
}
function xscroll(){
	if(self.pageXOffset) {
		return self.pageXOffset;
	}else if(document.documentElement&&document.documentElement.scrollLeft){
		return document.documentElement.scrollLeft;
	}else if(document.body){
		return document.body.scrollLeft;
	}
}
function yscroll(){
	if(self.pageYOffset) {
		return self.pageYOffset;
	}else if(document.documentElement&&document.documentElement.scrollTop){
		return document.documentElement.scrollTop;
	}else if(document.body){
		return document.body.scrollTop;
	}
}
function iw(){
	if(window.innerWidth){
		return window.innerWidth;
	}else if(document.documentElement&&document.documentElement.clientWidth){
		return document.documentElement.clientWidth;
	}else if(document.body){
		return document.body.clientWidth;
	}
}
function ih(){
	if(window.innerHeight){
		return window.innerHeight;
	}else if(document.documentElement&&document.documentElement.clientHeight){
		return document.documentElement.clientHeight;
	}else if(document.body){
		return document.body.clientHeight;
	}
}

/*
xml.js
request function originally by Peter-Paul Koch: www.quirksmode.org
modified by Don Havey: www.donhavey.com
use with permission, please
*/
var xmls = [];
function xml(url,func,param,post){
	this.n = xmls.length;
	xmls[this.n] = this;
	this.url = url;
	this.func = func;
	this.async = true;
	this.method = (post)?"POST":"GET";
	this.post = post;
	this.param = param;
	this.errors = 0;
	this.retries = 3;
	this.wait = 120000;
	this.debugging = true;
	this.req = null;
	this.request = function(n){
		var reqs = [function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}];
		for(var i=0;i<reqs.length;i++){
			try{ xmls[n].req = reqs[i](); }catch(e){ continue; }
			break;
		}
		if(!xmls[n].req){ xmls[n].error(n,xmls[n].req,"Could not create XHR object.") }
		xmls[n].req.open(xmls[n].method,xmls[n].url,xmls[n].async);
		xmls[n].timeout = setTimeout(function(){ xmls[n].error(n,xmls[n].req,"Request timed out."); },xmls[n].wait);
		xmls[n].req.setRequestHeader('User-Agent','XMLHTTP/1.0');
		if(xmls[n].post){
			xmls[n].req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
		}
		xmls[n].req.onreadystatechange = function(){
			if(xmls[n].req.readyState!=4){ return; }
			clearTimeout(xmls[n].timeout);
			xmls[n].timeout = null;
			if(xmls[n].req.status!=200){
				xmls[n].error(n,xmls[n].req,"Invalid result returned.");
			}else{
				if(xmls[n].param){ xmls[n].func(xmls[n].req,xmls[n].n,xmls[n].param); }else{ xmls[n].func(xmls[n].req,xmls[n].n); }
			}
		}
		if(xmls[n].req.readyState==4){ return };
		xmls[n].req.send(xmls[n].post);
	},
	this.parse = function(node,structure){
		var vars = new Object();
		for(var i=0;i<structure.length;i++){
			if(typeof(structure[i])=="string"){
				if(node.getElementsByTagName(structure[i]).length>0){
					vars[structure[i]] = node.getElementsByTagName(structure[i])[0].firstChild.nodeValue;
				}
			}else if(typeof(structure[i])=="object"){
				var subnodes = node.getElementsByTagName(structure[i][0]);
				if(subnodes.length>0){
					vars[structure[i][0]] = [];
					for(var j=0;j<subnodes.length;j++){
						vars[structure[i][0]][j] = this.parse(subnodes[j],structure[i][1]);
					}
				}
			}
		}
		return vars;
	}
	this.error = function(n,req,message){
		if(xmls[n].debugging){ alert("Error: "+message); }
		xmls[n].req.abort();
		if(xmls[n].errors<xmls[n].retries){
			if(xmls[n].debugging){ alert("Retrying request..."); }
			xmls[n].request();
		}
		xmls[n].errors++;
	}
	this.request(this.n);
}

/*
xy.js
Don Havey: www.donhavey.com
use with permission, please
*/
function x(e,_depth){
	var left = 0;
	var d = 0;
	if(e.offsetParent){
		while(e.offsetParent){
			left += e.offsetLeft;
			e = e.offsetParent;
			if(_depth!=null&&d==_depth){
				return left;
			}
			d++;
		}
	}else if(e.x){
		left += e.x;
	}
	return left;
}
function y(e,_depth){
	var top = 0;
	var d = 0;
	if(e.offsetParent){
		while(e.offsetParent){
			top += e.offsetTop;
			e = e.offsetParent;
			if(_depth!=null&&d==_depth){
				return top;
			}
			d++;
		}
	}else if(e.y){
		top += e.y;
	}
	return top;
}
/*
browser_detect.js
originally by Peter-Paul Koch: www.quirksmode.org
modified by Don Havey: www.donhavey.com		 
use with permission, please
*/
var browser_detect = {
	init:function(){
		browser_detect.browser = browser_detect.searchString(browser_detect.dataBrowser) || "Unknown browser";
		browser_detect.version = browser_detect.searchVersion(navigator.userAgent) || browser_detect.searchVersion(navigator.appVersion) || "Unknown version";
		browser_detect.OS = browser_detect.searchString(browser_detect.dataOS) || "Unknown OS";
	},
	searchString:function(data){
		for(var i=0;i<data.length;i++){
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			browser_detect.versionSearchString = data[i].versionSearch || data[i].identity;
			if(dataString){
				if(dataString.indexOf(data[i].subString)!=-1){ return data[i].identity;	}
			}else if(dataProp){	
				return data[i].identity;
			}
		}
	},
	searchVersion:function(dataString){
		var index = dataString.indexOf(browser_detect.versionSearchString);
		if(index == -1){ return false; }
		return parseFloat(dataString.substring(index+browser_detect.versionSearchString.length+1));
	},
	dataBrowser:[
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{	
			string: navigator.userAgent,
			subString: "webkit",
			identity: "webkit"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS:[
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]
};
window.onload = add_window_function(window.onload,browser_detect.init);