/***************************************************************************
      jesus/modules/popup.js  -  Javascript popup windows and profiles
                             -------------------
    begin                : Fri Jun 09 2006
    copyright            : (C) 2006 by Filios Konstantinos
    licence              : GNU GPL 2 (or later)
    email                : drcypher@mail.ntua.gr
    last modified        : Fri Jun 09 2006
    module version       : 1.0
 ***************************************************************************/

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

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

popup_profiles[POPUP_ACTION] = new Array('action', '800','500','yes','center');
popup_profiles[POPUP_HELP] = new Array('help', '600','400','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';

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

function loadwindow(url,width,height)
{
	if (!ie5 && !ns6) {
		window.open(url,"","width=width,height=height,scrollbars=1");
	} else {
		document.getElementById("dwindow").style.display = '';
		document.getElementById("dwindow").style.width = initialwidth=width+"px";
		document.getElementById("dwindow").style.height = initialheight=height+"px";
		document.getElementById("dwindow").style.left = "30px";
		document.getElementById("dwindow").style.top = ns6 ?
			window.pageYOffset * 1 + 30 + "px" :
			doc().scrollTop * 1 + 30 + "px";
		document.getElementById("cframe").src = url;
	}
}

function maximize()
{
	if (minrestore == 0) {
		minrestore = 1; //maximize window
		document.getElementById("maxname").setAttribute("src", "restore.gif");
		document.getElementById("dwindow").style.width = ns6 ?
			(window.innerWidth - 20) + "px" :
			doc().clientWidth + "px";
		document.getElementById("dwindow").style.height = ns6 ?
			(window.innerHeight - 20) + "px" :
			doc().clientHeight + "px";
	} else {
		minrestore = 0; //restore window
		document.getElementById("maxname").setAttribute("src", "max.gif");
		document.getElementById("dwindow").style.width = initialwidth;
		document.getElementById("dwindow").style.height = initialheight;
	}
	document.getElementById("dwindow").style.left = ns6 ?
		window.pageXOffset + "px" :
		doc().scrollLeft + "px";
	document.getElementById("dwindow").style.top = ns6 ?
		window.pageYOffset + "px" :
		doc().scrollTop + "px";
}

function closeit()
{
	document.getElementById("dwindow").style.display = "none";
}


