//LIB: functions.js
//VERSION: 0.4
//$jsfunctions_version = "0.4";

/*
    ------------------------------------------------------------------------------------------------
    PROJECT INFO
    
    project: ubiquity
    description: ubiquity.functions.js - javascript functions library for use by ubiquity.
    
    Copyright 2002 Jeremy Bell <jeremy.bell@acm.org>
    license: GPL

    ------------------------------------------------------------------------------------------------
    LICENSE
    
    This file is part of ubiquity.

    ubiquity 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.

    ubiquity 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 ubiquity; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    ------------------------------------------------------------------------------------------------
    CHANGELOG
    
    0.1:
    - initially extracted javascript functions from php functions library

    0.2:
    - added popFileWindow() for blogcomments, but is generic enough for other uses
    - added popWebWindow(): has menubar, toolbar, addressbar, statusbar, scrollbars, resizeable
    - changed popImageWindow() to look in lib/components/ for imagepopup.pop.php
    - changed popAlbumWindow() to name each window by album name; no winodw take-overs
    - added popWebWindow2(): pops windows with name as url so multiple popups are possible
      has no menubar, toolbar, addressbar, statusbar, scrollbars, nor is it resizeable
    
    0.3:
    - reorganized pop functions; added .focus() to each
    
    0.4:
    - added popImageWindowFrom() so path to popup component can be specified; required for
      blogimagelist.pop
    
    ------------------------------------------------------------------------------------------------
*/

//  ------------------------------------------------------------------------------------------------
//  FUNCTIONS
//  ------------------------------------------------------------------------------------------------

function popImageWindow(img,x,y) {
    // REQUIRES: lib/components/imagepopup.pop.php 0.1
    
    var popimage = window.open(
	'lib/components/imagepopup.pop.php?file='+img,
	'image',
	'width='+x+',height='+y+',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable'
    ).focus();
    
    void(0);
}

function popImageWindowFrom(from,img,x,y) {
    // REQUIRES: lib/components/imagepopup.pop.php 0.1
    
    var popimage = window.open(
	from+'/imagepopup.pop.php?file='+img,
	'image',
	'width='+x+',height='+y+',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable'
    ).focus();
    
    void(0);
}

function popAlbumWindow(album,x,y) {
    // pops a fixed size, non-decorated, non-resizeable window
    if (arguments.length < 3) { y = 480; }
    if (arguments.length < 2) { x = 640; }
    
    var popalbum = window.open(
	album,
	'',
	'width='+x+',height='+y+',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no'
    ).focus();

    void(0);
}

function popAlbumWindow2(album,x,y) {
    // pops a fixed size, non-decorated except for scrollbars, non-resizeable window
    if (arguments.length < 3) { y = 480; }
    if (arguments.length < 2) { x = 640; }
    
    var popalbum = window.open(
	album,
	'',
	'width='+x+',height='+y+',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no'
    ).focus();

    void(0);
}

function popFileWindow(file,x,y) {
    var popfile = window.open(
	file,
	'file',
	'width='+x+',height='+y+',menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable'
    ).focus();

    void(0);
}

function popWebWindow(url,x,y) {
    if (arguments.length < 3) { y = 600; }
    if (arguments.length < 2) { x = 800; }
    
    var popweb = window.open(
	url,
	'',
	'width='+x+',height='+y+',menubar=yes,toolbar=yes,location=yes,directories=no,status=yes,scrollbars=yes,resizable'
    ).focus();

    void(0);
}

function popWebWindow2(url,x,y) {
    // like popWebWindow but with no decorations except scrollbar
    if (arguments.length < 3) { y = 600; }
    if (arguments.length < 2) { x = 800; }
    
    var popweb2 = window.open(
	url,
	'',
	'width='+x+',height='+y+',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable'
    ).focus();

    void(0);
}
