/*
$Id: js_functions.inc.js 1629 2005-12-21 20:54:40Z miggles $
*/
function popup_image(image_url, title) {
	var winl = (screen.width - 200)/2;
	var wint = (screen.height - 300)/2;
	var settings ='top='+wint+',';
	settings +='left='+winl+',';
	settings +='width=200, ';
	settings +='height=300, ';
	settings +='scrollbars=no,';
	settings +='resizable=yes';

	title = title.replace(/\s/g, '%20');

	win=window.open('/image_popup.php?image_url='+image_url+'&title='+title, 'image',settings);

	if(parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}

function popup_gallery_image(g, i, w, h) {
	var winl = (screen.width - 700)/2;
	var wint = (screen.height - 500)/2;
	var settings ='top='+wint+',';
		settings +='left='+winl+',';
		settings +='width=700, ';
		settings +='height=500, ';
		settings +='scrollbars=no,';
		settings +='resizable=yes';

	win=window.open('/popup.php?comp_gallery_id='+g+'&comp_gallery_image_id='+i+'&w='+w+'&h='+h, 'image',settings);

	if(parseInt(navigator.appVersion) >= 4) {
	   win.window.focus();
	}
}

function popup_gallery(g, i, w, h) {
	var winl = (screen.width - 700)/2;
	var wint = (screen.height - 500)/2;
	var settings ='top='+wint+',';
		settings +='left='+winl+',';
		settings +='width=700, ';
		settings +='height=500, ';
		settings +='scrollbars=no,';
		settings +='resizable=yes';

	win=window.open('/gallery_popup.php?g='+g+'&i='+i+'&w='+w+'&h='+h, 'image',settings);

	if(parseInt(navigator.appVersion) >= 4) {
	   win.window.focus();
	}
}
var href = location.href;
function refreshPage(page) {
	if (typeof page == "undefined") page = href;
	window.location.replace(page);
}
var win=null;
function PopupPage(w, h, page, resize, name) {
	if (typeof resize == "undefined") resize = 0;
	if (typeof name == "undefined") name = 'editor_popup';

	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var settings  ='height='+h+',';
		settings +='width='+w+',';
		settings +='top='+wint+',';
		settings +='left='+winl+',';
		settings +='resizable='+resize+',';
		settings +='scrollbars=0';

	win = window.open(page, name, settings);
	win.window.focus();

	return false;
}
/* preload images */
if (document.images) {
	var spacerOn = new Image();
	spacerOn.src = "images/spacer.gif";
}
var $ = function() {
	var elements = new Array();
	for (var i=0; i < arguments.length; i++) {
		var element = arguments[i];

		if (typeof(element) === 'string') {
			element = document.getElementById(element);
		}

		if (arguments.length == 1) {
			return element;
		}

		elements.push(element);
	}

	return elements;
};