centered_popup_window="";

function centered_popup(name, url, width, height) {
	var left = 0, top = 0;
	if (screen.width > width) {
		left = (screen.width - width) / 2;
	}
	if (screen.height > height) {
		top = (screen.height - height) / 2;
	}
	opts="toolbar=no,directories=no,menubar=no,resizable=no,scrollbars=no,width=" +width+ ",height=" +height+ ",left=" +left+ ",top=" +top;
	if (centered_popup_window.closed == false) {
		centered_popup_window.close();
	}
	centered_popup_window=window.open(url, name, opts);
	centered_popup_window.focus();
}

function printer_popup(url) {
	var opts = 'left=40, top=10, width=620, height=530, fullscreen=0, locationbar=0, menubar=0, personalbar=0, statusbar=0, toolbar=0';
	window.open(url, 'printer', opts);
}

function recommend_popup(lang) {
	var opts = 'left=20, top=20, width=480, height=300, fullscreen=0, locationbar=0, menubar=0, personalbar=0, scrollbars=0, statusbar=0, toolbar=0';
	window.open('recommend.php?lang=' + lang, 'recommend', opts);
}

function gallery_popup(name, x, y) {
	centered_popup('gallery_popup', 'gallery_fullsize.php?i=' + name, x, y);
}

function show_popup(n, w, h) {
	var left = 0, top = 0;
	if (screen.width > w) {
		left = (screen.width - w) / 2;
	}
	if (screen.height > h) {
		top = (screen.height - h) / 2;
	}
	var opts = 'left=' + left + ', top=' + top + ', width=' + w + ', height=' + h +', fullscreen=0, locationbar=0, menubar=0, personalbar=0, scrollbars=0, statusbar=0, toolbar=0'
	window.open('/popup.php?n=' + n, 'popup', opts)
}

function show_popunder(n, w, h) {
	var left = 0, top = 0;
	if (screen.width > w) {
		left = (screen.width - w) / 2;
	}
	if (screen.height > h) {
		top = (screen.height - h) / 2;
	}
	var opts = 'left=' + left + ', top=' + top + ', width=' + w + ', height=' + h +', fullscreen=0, locationbar=0, menubar=0, personalbar=0, scrollbars=0, statusbar=0, toolbar=0'
	popunder_window = window.open('/popup.php?n=' + n, 'popunder', opts)
	popunder_window.blur()
	window.focus()
}

function Gallery(image) {
	ImageWindow = window.open('/' + image, '', 'width=680px, height=300px, resizable');

	if(!ImageWindow.closed)
	 ImageWindow.focus();
}


function changeValue(elem) {
	passwordInput = document.getElementById(elem);
	passwordInput.value = "";
}

