// $Id: scripts.js,v 1.4 2005/12/08 10:35:58 pmorrill Exp $
//
// Open Journal Systems 1.1
// (c) The Public Knowledge Project 2003
// http://www.pkp.ubc.ca
// 
// This file is part of Open Journal Systems.
// 
// Open Journal Systems is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// Open Journal Systems is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with Open Journal Systems; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// admin/include/scripts.js
// Contains various JavaScript scripts used in the site


// Opens a new window with the specified features
function openPopWin(url, width, height, features, left, top) {
	return openNamedWin(url, '', width, height, features, left, top);
}

//
// Opens a new named window with the specified features, and places focus on it
//
function openNamedWin(url, name, width, height, features, left, top) {
	var popup = window.open(
		url,
		name,
		"width=" + width
		+ ",height=" + height
		+ ",screenX=" + (left ? left : "30")
		+ ",screenY=" + (top ? top : "30")
		+ ",left=" + (left ? left : "30")
		+ ",top=" + (top ? top : "30")
		+ (features ? "," + features : "")
	);
	if ( popup ) popup.focus();
	else alert("The journal software has failed to open a critical window. Please adjust your popup-blocking software for this site.");
}

//
// reload the parent, with passed url, then close self if param set to 1
//
function reload_parent(url,close) {
	if ( opener ) {
		opener.document.location.href=url;
		opener.document.location.reload(1);
		if ( close == 1 ) self.close();
	}	
}

//
// open a full window onto the article
//
function popupArticle(url) {
	openNamedWin(url,'pArticle',850,600,'toolbar=yes,resizable=yes,scrollbars=yes',0,0);
}

//
// open a full window onto the article
//
function popupAttachment(url) {
	openNamedWin(url,'CEFigWin',850,600,'toolbar=yes,resizable=yes,scrollbars=yes',50,50);
}

// Opens a new window with editor's biography
function openBioWin(id, type) {
	var url = 'editors.php?op=bio&id='+id;
	if(type) {
		url += '&type=' + type;
	}
    window.open(url, 'Biography', 'height=400,width=500,screenX=150,screenY=100,left=150,top=100,scrollbars=yes,resizable=yes');
}

