function open_window(url,name,obj){
	if(url){
		var arr_param = new Array();
		var obj_default = {
			url:"",
			name:"win",
			left:0,
			top:0,
			width:500,
			height:500,
			titlebar:"no",
			menubar:"no",
			scrollbars:"no",
			location:"no",
			directories:"no",
			resizable:"no",
			statusbar:"no",
			favoritebar:"no",
			toolbar:"no"
		};
		// Centering functionality
		w = (obj.width)? obj.width : obj_default.width;
		h = (obj.height)? obj.height : obj_default.height;
		if(obj.left=="center") obj.left = parseInt((screen.availWidth-w)/2);
		if(obj.top=="center") obj.top = parseInt((screen.availHeight-h)/2);
		
		// Gathering window features
		for(var i in obj_default){
			if(i != "url" && i != "name") arr_param[arr_param.length] = (new String(obj[i])!="undefined")? i+"="+obj[i] : i+"="+obj_default[i];
		}
		
		winname = (new String(obj.name)!="undefined")? name : obj_default.name;
		return window.open(url,winname,new String(arr_param));
	} else {
		return new String("you must specify an URL");
	}
}

function popup(url){
	win = open_window(url,"popup",{width:700,height:420,left:"center",top:"center",scrollbars:"no"});
	win.focus();
}

function popup_quiz(strURL){
	win = open_window(strURL,"popup",{width:605,height:410,left:"center",top:"center",scrollbars:"yes"});
	win.focus();
}

function htmlpopup(url,w,h){
    width = w;
    height = h;
    if( !w ) { width = "700"; }
    if( !h ) {
        height = "500";
    } else {
        if( h == "full") {
            height = window.screen.height-100;
        } else {
            height = h;
        }
    }
    attr = "statusbar=no,favoritebar=no,toolbar=no,scrollbars=yes,resizable=yes,titlebar=no,menubar=no";
	win = window.open(url,"htmlpopup","width="+width+",height="+height+",top=0,"+attr);
	win.focus();
}

function popup_resize(url){
	win = open_window(url,"popup",{width:700,height:410,left:"center",top:"center",scrollbars:"yes",resizable:"yes"});
	win.focus();
}

