// FULLSIZE WINDOW

function fullsize_window() {
	window.moveTo(0,0);
	window.resizeTo(window.screen.availWidth, window.screen.availHeight);
}

// RANDOM BACKGROUND IMAGES

var backgrounds = [];

function random_background() {
	if (backgrounds.length) {
		document.body.background = backgrounds[Math.floor(backgrounds.length * Math.random())];
	}
}

// CONVERT HREFS INTO JAVASCRIPT

/*
function make_popups() {
	if (!document.links.length) return;
	var a = 0;
	while (a < document.links.length) {
		var id = document.links[a].id;
		if (popups[id] != null) {
			var href = document.links[a].href;
			document.links[a].href = "javascript:popup('"+id+"', '"+href+"')";
			document.links[a].target = "_self";
		}
		a++;
	}
}

// OPEN AND POSITION CHILD WINDOW

var popups = new Object;
var child = false;

function popup(id, url) {
	var features;
	if (popups != null) features = popups[id];
	if (features != null) {
		var name = features[0];
		var x = features[1];
		var y = features[2];
		var w = features[3];
		var h = features[4];
		if (window.screenX != null) {
			x += window.screenX;
			y += window.screenY;
		}
		if (x < 0) x = (window.screen.availWidth - w) / 2;
		if (y < 0) y = (window.screen.availHeight - h) / 2;
		features = features[5];
		if (features != "") features += ",";
		features += "left="+x+",top="+y;
		features += ",screenX="+x+",screenY="+y;
		features += ",width="+w+",height="+h;
	}
	if (!!child) child.close();
	child = window.open(url,name,features);
}
*/

// POPUP SUPPORT

var popups = new Object;
var popups_child;

function make_popups() {
	popups_initialise();
}

function popups_initialise() {
	if (!document.links.length) return;
	var a = 0;
	while (a < document.links.length) {
		var id = document.links[a].id;
		if (!popups[id]) id = document.links[a].id;
		if (!popups[id] && id.substring(0, 5) == 'popup') id = 'popup';
		if (popups[id] != null || id == 'popup') {
			var href = document.links[a].href;
			document.links[a].href = "javascript:popup('"+id+"','"+href+"')";
			document.links[a].target = "_self";
		}
		a++;
	}
}

function popup(id, url) {
	var name, features;
	if (popups != null) features = popups[id];
	if (features != null) {
		name = features[0];
		var x = features[1];
		var y = features[2];
		var w = features[3];
		var h = features[4];
		if (x < 0) x = Math.floor((window.screen.availWidth - w) / 2);
		else if (window.screenX != null) x += window.screenX;
		if (y < 0) y = Math.floor((window.screen.availHeight - h) / 2);
		else if (window.screenY != null) y += window.screenY;
		features = features[5];
		if (features != "") features += ",";
		features += "width="+w+",height="+h;
		features += ",screenX="+x+",screenY="+y;
		features += ",left="+x+",top="+y;
	}
//	if (popups_child != null) {
//		if (popups_child.close != null) popups_child.close();
//		else name = '';
//	}
	popups_child = window.open(url, '', features);
	if (popups_child != null && popups_child.focus != null) popups_child.focus();
}