function setup() {
	// OUTBOUND LINKS OPEN IN A NEW WINDOW UNLESS EXPLICITLY TOLD OTHERWISE
	// FORCE SAME WINDOW: rel="self" in anchor
	// FORCE EXTERNAL WINDOW: rel="external" in anchor 
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var URL = anchors[i].href;
		if ((URL.search('efilters')===-1 && URL.search('http')!==-1 && anchors[i].rel !== 'self') || anchors[i].rel === 'external') anchors[i].target = "_blank";
	}
}

function popup(file,wide,high) {
	window.open(file,'popup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=yes,copyhistory=no,width='+wide+',height='+high)
}


///////////////////////////
// SLIDING MENUS SCRIPTS //
///////////////////////////

function toggle(id,duration,step_duration){
	var el = document.getElementById(id);
	if (!el || !el.style) return;
	if (duration === undefined) duration = 500;
	if (!step_duration) step_duration = 10;
	var steps = Math.max(Math.ceil(duration/step_duration),1);
	if (el.offsetWidth == 0) { //show it
		morph_width(el,0,el.naturalWidth,duration,steps,0);
	}
}
function kill(id,duration,step_duration){
	var el = document.getElementById(id);
	if (!el || !el.style) return;
	if (duration === undefined) duration = 500;
	if (!step_duration) step_duration = 10;
	var steps = Math.max(Math.ceil(duration/step_duration),1);
	if (el.offsetWidth !== 0) {
		el.naturalWidth = el.naturalWidth || el.offsetWidth;
		el.style.overflow = 'hidden';
		morph_width(el,el.offsetWidth,0,duration,steps,0);
	}
}
function morph_width(el,from,to,duration,steps,step) {
	var x = step/steps;
	var y = Math.sin((x-0.5)*Math.PI);
	var z = (y+1)*0.5;
	var h = from + (to-from)*z;
	if (step == steps) h = to;
	el.style.width = h+'px';
	if (h == to) return;
	var t = duration/steps;
	if (el.style.width === '0px') el.style.marginTop = '-1px';
	setTimeout(function(){morph_width(el,from,to,duration,steps,step+1)},t);
}
function menus(foo) {
	var els = document.getElementsByTagName('*');
	for (var i=0;i<els.length;i++) {
		if (els[i].className == 'hidden' && els[i].id !== foo) { kill(els[i].id,200); }
	}
	menus2(foo);
}
function menus2(foo) {
	var els = document.getElementsByTagName('*');
	for (var i=0;i<els.length;i++) {
		if (els[i].className == 'hidden2' && els[i].id !== foo) { kill(els[i].id,200); }
	}
}

window.onload = setup;
