function openWin(file, width, height) {
	if(!width)	width = 100;
	if(!height)	height = 100;
        x = (screen.width / 2) - (width / 2) - 150;
        y = (screen.height / 2) - (height / 2) - 150;
        var i = Math.round(100*Math.random());
        return window.open(file, i,'close=no,width='+width+',height='+height+',top='+y+',left='+x+',top=1,resizable=yes,status=no,scrollbars=yes');
}
var dropped = false;
function over(obj) {
	if(dropped)	out($(dropped).parentNode);
	var header = obj.firstChild;
	var drop = obj.lastChild;
	drop.style.visibility='visible';
	drop.style.left=Left(header)+'px';
	header.className='hover'; 
}
function out(obj) {
	dropped = false;
	obj.firstChild.className = obj.firstChild.className.replace('hover','');
	obj.lastChild.style.visibility='hidden';
}







var drop_stepper = 1;
var roll_dir = false;
function rolldown(i, h, post) {
	if(roll_dir != 'up') {
		roll_dir = 'down';
		var w = $(i);
		if(parseInt(w.offsetHeight) < h) {
			w.style.height = parseInt(w.offsetHeight) + drop_stepper+'px';
			setTimeout('rolldown("'+i+'",'+h+',\''+post+'\');', 10);
			return;
		} else {
			roll_dir = false;
			w.style.height = h;
			setTimeout(replace(post, '`', '\\\''),1);
		}
	}
}
function rollup(i) {
	if(roll_dir != 'down') {
		roll_dir = 'up';
		var w = $(i);
		if(parseInt(w.style.height) > drop_stepper) {
			w.style.height = parseInt(w.offsetHeight) - drop_stepper;
			setTimeout('rollup("'+i+'");', 10);
			return;
		} else {
			roll_dir = false;
			w.style.height = 0;
			w.style.dispaly='none';
		}
	}
}
function $(i) {
	return document.getElementById(i);
}
function replace(string,text,by) {
	if(!string)	return '';
	var strLength = string.length, txtLength = text.length;
	if ((strLength == 0) || (txtLength == 0)) return string;
	if(string.indexOf) {
		var i = string.indexOf(text);
		if ((!i) && (text != string.substring(0,txtLength))) return string;
		if (i == -1) return string;
		var newstr = string.substring(0,i) + by;
		if (i+txtLength < strLength)	newstr += replace(string.substring(i+txtLength,strLength),text,by);
		return newstr;
	}
}

function Left(obj) {
	if(obj) {
		var x = eval(obj).offsetLeft;
		elem = eval(obj).offsetParent;
		while (elem != null) {
			x += elem.offsetLeft;
			elem = elem.offsetParent;
		}
		return x;
	}
}
function Top(obj) {
	y = eval(obj).offsetTop;
	elem = eval(obj).offsetParent;
	while (elem != null) {
		y += parseFloat(elem.offsetTop);
		elem = elem.offsetParent;
	}
	return y;
}




function debug(elem) {
	var properties = "<HEAD><link href='/styles/sections.css' rel='stylesheet' type='text/css'></HEAD><BODY><TABLE WIDTH='100%'><TR><TH>Element<TH>Document<TH>Window</TR><TD VALIGn=TOP>";
	for(var e in elem) 
		properties += '<LI>'+e + ": " + elem[e]+"</LI>\n";
	properties += "<TD VALIGn=TOP>";
	for(var e in document) 
		properties += '<LI>'+e+(document.e ? ' = '+document.e : '')+"</LI>\n";
	properties += "<TD VALIGn=TOP>";
	for(e in window) 
		properties += '<LI>'+e;
	properties += "</TR></TABLE></BODY>";

	var newwindow=window.open('','name','height=700,width=750,scrollbars=yes,scroll=yes');
	var tmp = newwindow.document;
	tmp.write(properties);
}

