
FontPicker_targetInput = null;
function FontPicker_writeDiv() {
	document.writeln("<DIV ID=\"fontPickerDiv\" STYLE=\"position:absolute;visibility:hidden;\"> </DIV>");
	}

function FontPicker_show(anchorname) {
	this.showPopup(anchorname);
	}

function FontPicker_pickFont(font,win) {
	win.close();
	pickFont(font);
	}

// A Default "pickFont" function to accept the font passed back from popup.
// User can over-ride this with their own function.
function pickFont(font) {
	if (FontPicker_targetInput==null) {
		alert("Target Input is null, which means you either didn't use the 'select' function or you have no defined your own 'pickFont' function to handle the picked font!");
		return;
		}
	FontPicker_targetInput.value = font;
	}

// This function is the easiest way to popup the window, select a font, and
// have the value populate a form field, which is what most people want to do.
function FontPicker_select(inputobj,linkname) {
	if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") { 
		alert("fontpicker.select: Input object passed is not a valid form input object"); 
		window.FontPicker_targetInput=null;
		return;
		}
	window.FontPicker_targetInput = inputobj;
	this.show(linkname);
	}
	
// This function runs when you move your mouse over a font block, if you have a newer browser
function FontPicker_highlightColor(c) {
	var thedoc = (arguments.length>1)?arguments[1]:window.document;
	var d = thedoc.getElementById("fontPickerSelectedColor");
	d.style.backgroundColor = c;
	d = thedoc.getElementById("fontPickerSelectedColorValue");
	d.innerHTML = c;
	}

function FontPicker() {
	var windowMode = false;
	// Create a new PopupWindow object
	if (arguments.length==0) {
		var divname = "fontPickerDiv";
		}
	else if (arguments[0] == "window") {
		var divname = '';
		windowMode = true;
		}
	else {
		var divname = arguments[0];
		}
	
	if (divname != "") {
		var fp = new PopupWindow(divname);
		}
	else {
		var fp = new PopupWindow();
		fp.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars,resizable,alwaysRaised,dependent,titlebar=no";
		//fp.setSize(500,500);
		}

	// Object variables
	fp.currentValue = "#FFFFFF";
	
	// Method Mappings
	fp.writeDiv = FontPicker_writeDiv;
	fp.highlightColor = FontPicker_highlightColor;
	fp.show = FontPicker_show;
	fp.select = FontPicker_select;

	fp.setUrl("/fonts.html");
	fp.offsetY = 25;
	fp.autoHide();
	return fp;
	}

