	function modalpopup(popuptype, fileorcontent, title, width, height, scrollable, onloadfunction, buttons) {
		if (!width) { width=300; }
		if (!height) { height=200; }
		if (popuptype=="") { popuptype="string"; }

		if (popuptype=="loginwarning") { title="Please Log In"; }
		if (document.getElementById('modalbox')) {
			/*e = document.getElementById('modalbox').parentNode;
			e.removeChild(document.getElementById('modalbox'));*/
			$('.modalbox').remove();
			$('#modalbox').remove();
		}
		
		var cssObj = {
		  'overflow' : 'hidden',
		  'overflowX' : 'hidden'
		}
		/*var a = document.createElement("div");
		a.setAttribute("title", title);
		a.setAttribute("id", "modalbox");
		a.style.overflow='hidden';*/
		/*a.style.height = '100px';
		a.style.width = '100px';
		a.style.left = '0px';
		a.style.position = 'absolute';
		a.style.top = '0px';
		a.style.backgroundColor = 'green';*/
		//a.className = "modalbox";
		var html = "<div id='modalbox_loadarea'";
		if (scrollable != 'no') {
			html += " style='height:"+(height-40)+"px;width:"+(width-20)+"px;overflow-y:auto;overflow-x:hidden;'";
		}
		html += "><div style='position:relative; left:"+((width/2)-50)+"px; top:"+((height/2)-60)+"px;'><img src='/img/loading.gif'><br><span style='font-size:13.5px; font-weight:bold;'>Loading...</span></div></div>";
		
		$('<div></div>').appendTo('body').html(html).attr('class', 'modalbox').attr('title', title).attr('id', 'modalbox').css(cssObj);
		//a.innerHTML = html;
		/*a.style.overflowX = 'hidden';
		if (scrollable == 'no') {
			a.style.overflow='hidden';
		}*/

		//document.body.appendChild(a);
		//$('#bodytag').add("<div id='modalbox' class='modalbox' title='"+title+"'></div>");
		
		if (popuptype=="loginwarning") {
			InjectIntoDiv("modalbox_loadarea", "You must log in to use that feature<br><br><a href=# onclick=\"FB.Connect.requireSession(fblogin); $('#modalbox').dialog('close'); return false;\">LOGIN</a>");
			$("#modalbox").dialog({
				height: height,
				width: width,
				modal: true
			});
			$('#modalbox').dialog('open');
		} else if (popuptype=="string") {
			InjectIntoDiv("modalbox_loadarea", fileorcontent);
			$("#modalbox").dialog({
				height: height,
				width: width,
				modal: true,
				buttons: buttons
			});
			$('#modalbox').dialog('open');
		} else if (popuptype=="file") {
			$("#modalbox").dialog({
				height: height,
				width: width,
				modal: true,
				autoOpen: true
			});
			$("#modalbox_loadarea").load(fileorcontent, function() {
				if (scrollable != 'no') {
					$('#modalbox_loadarea').jScrollPane({
						showArrows:true, 
						scrollbarWidth: 15,
						arrowSize: 20,
						reinitialiseOnImageLoad: true
					});
				}
				if (onloadfunction=="yes") ondialogload();
			});
		} else if (popuptype=="url") {
			InjectIntoDiv("modalbox_loadarea", "<iframe name='externalpage' id='externalpage' frameborder='0' width='"+(width-25)+"' height='"+(height-50)+"' src='"+fileorcontent+"'></iframe>");
			$("#modalbox").dialog({
				height: height,
				width: width,
				modal: true
			});
			$('#modalbox').dialog('open');
		}
	}

	function generatenickimg(bg, font) {
		loadscript("/js.php", "jscript=generatenickimg%2Ephp&bg="+bg+"&font="+font);
	}
