function popupEx(url, options)
{
	var defaultOptions = {
		"toolbar":		"no",
		"location":		"no",
		"directories":	"no",
		"status":		"no",
		"menubar":		"no",
		"scrollbars":	"no",
		"resizable":	"no"
	};

	
	for (var i in defaultOptions) {
		if (typeof(options[i]) == "undefined") {
			options[i] = defaultOptions[i];
		}
	}

	name = "popup";
	if (typeof options.name != "undefined") {
		var name = options.name;
		delete options["name"];
	}

	var pairs = [];
	for (var i in options) {
		pairs.push(i + "=" + options[i]);
	}
	
	var settings = pairs.join(",");

	//var oNewWin = window.open(url, name, settings);
	var oNewWin = window.open(url, name, settings);
}

function popupEx0(url, width, height, name)
{
	var settings = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + width + ",height=" + height;

	var oNewWin = window.open(url,name,settings);
}

function popup(url, width, height)
{
	var settings = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + width + ",height=" + height;

	var oNewWin=window.open(url,'view', settings);
}

function popup_image(url, width, height, name){
	var settings = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=100,top=100,width=" + width + ",height=" + height;

    var oNewWin = window.open('about:blank', null, settings);
    
    var sHTML = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
		+ "<HTML><HEAD>"
		+ "<TITLE>" + name + "</TITLE></HEAD>"
		+ "<BODY style='margin:0; background-color:#000000;' onload='self.focus()' onblur='self.close()'>"
		+ "<img src='" + url + "' width='" + width + "' height='" + height + "' alt='" + name + "' />"
		+ "</BODY></HTML>";
    oNewWin.document.writeln(sHTML);
    oNewWin.document.close();
}

function popupHelp(url)
{
	if ("undefinded" == typeof url) url = '/help/';
	return popupEx(url, {name: 'QuinturaHelp', width: 640, height: 480, 'scrollbars': 'yes', 'resizable': 'yes'});
}

function jump2url(url)
{
	window.location=url;
}

function checkAll(form, ch)
{
	for (i=0; i < form.elements.length; i++)
		if (form.elements[i].type=="checkbox" && form.elements[i].name=="checked[]") 
			form.elements[i].checked = ch;
}

function dump(d,l) {
    if (l == null) l = 1;
    var s = '';
    if (typeof(d) == "object") {
        s += typeof(d) + " {\n";
        for (var k in d) {
            for (var i=0; i<l; i++) s += "  ";
            s += k+": " + dump(d[k],l+1);
        }
        for (var i=0; i<l-1; i++) s += "  ";
        s += "}\n"
    } else {
        s += "" + d + "\n";
    }
    return s;
}
