/***************************************************************************
        panel/popup.js  -  Javascript popup windows and profiles
                             -------------------
    begin                : Fri Jun 09 2006
    copyright            : (C) 2006 by Filios Konstantinos
    email                : drcypher@mail.ntua.gr
    last modified        : Fri Jun 09 2006
    module version       : 1.0
 ***************************************************************************/

/***************************************************************************
 *  This program 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.
 ***************************************************************************/

var win = null;

//
// Define built-in popup profiles
//
var POPUP_ACTION = 0;
var POPUP_LOGIN = 1;

//
// Define array of profile properties
//
var popup_profiles = new Array(2);

popup_profiles[POPUP_ACTION] = new Array('action', '700','500','yes','center');
popup_profiles[POPUP_LOGIN] = new Array('help', '250','150','yes','center');

function popup(str_page, var_name, int_width, int_height, str_scroll, str_pos)
{
	//
	// Use a built-in profile
	//
	if (typeof(var_name) == "number") {
		// Set profile name
		str_name = popup_profiles[var_name][0];

		// Set profile width
		if (int_width == null) {
			int_width = popup_profiles[var_name][1];
		}

		// Set profile height
		if (int_height == null) {
			int_height = popup_profiles[var_name][2];
		}

		// Set profile scrolling
		if (str_scroll == null) {
			str_scroll = popup_profiles[var_name][3];
		}

		// Set profile scrolling
		if (str_scroll == null) {
			str_pos = popup_profiles[var_name][4];
		}

	//
	// Use passed arguments
	//
	} else {
		str_name = var_name;
	}

	// Calculate left/top
	switch (str_pos) {
	case "random":
		int_left = (screen.width) ? Math.floor(Math.random()*(screen.width-int_width)):100;
		int_top = (screen.height)?Math.floor(Math.random()*((screen.height-int_height)-75)):100;
		break;

	case "center":
		int_left = (screen.width)?(screen.width-int_width)/2:100;
		int_top = (screen.height)?(screen.height-int_height)/2:100;
		break;

	default:
		int_left = 0;
		int_top = 20;
		break;
	}

	str_settings = 'width='+int_width+',height='+int_height+',top='+int_top+',left='+int_left+
		',scrollbars='+str_scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';

	win = window.open(str_page, str_name, str_settings);
}

function to_old_win(url) {
	opener.location.href = url;
}
