

//
//
//	Windows-like Popup boxes
//	v0.1
//
//

// If you choose to copy this, please leave the following:
// Written S.Lee, 1999



// ******************** helpmsg constructor ******************** 

function helpmsg(header, hstyle, message, mstyle) {
	this.DEFAULTHSTYLE = "plain";
	this.DEFAULTMSTYLE = "plain";

	this.header = header;
	if (hstyle)
		this.hstyle = hstyle;
	else
		this.hstyle = this.DEFAULTHSTYLE;
	this.message = message;
	if (mstyle)
		this.mstyle = mstyle;
	else
		this.mstyle = this.DEFAULTMSTYLE;
	return this;
}

new helpmsg();
helpmsg.prototype.show = show;

	// ++++++++++++++++ Construct header ++++++++++++++++
function show() {
	var H = this.header;// removed "<FONT FACE='arial'>" + this.header + "</FONT>"
	if (this.hstyle == "header1")
		H = "<H1>" + H + "</H1>";
	else if (this.hstyle == "header2")
		H = "<H2>" + H + "</H2>";
	else if (this.hstyle == "header3")
		H = "<H3>" + H + "</H3>";
	else if (this.hstyle == "header4")
		H = "<H4>" + H + "</H4>";
	else if (this.hstyle == "fancyheader1")
		H = "<table width='75%'>" +
			"<tr><td bgcolor='#6060ff' align='center' valign='center'>" +
			"<H1><FONT COLOR='white'>" +
			H +
			"</FONT></H1>" +
			"</td></tr></table>";
	else if (this.hstyle == "TT-header")
		H = "<table width='100%'>" +
			"<tr align='center'><td bgcolor='#222222' align='center' valign='center'>" +
			"<FONT COLOR='#006699' size='+4'><strong><TT>" +
			H +
			"</TT></strong></FONT>" +
			"</td></tr></table>";
	else if (this.hstyle == "jTT-header")
		H = "<table width='100%'>" +
			"<tr align='center'><td bgcolor='#333333' align='center' valign='center'>" +
			"<DIV style='font:800 20;color:#CC0000;'><TT>" +
			H +
			"</TT></DIV>" +
			"</td></tr></table>";
	else if (this.hstyle == "BgHdr")
		H = "<table align='center' width='80%'>" +
			"<tr align='center'><td bgcolor='#333333' align='center' valign='center'>" +
			"<span style='font:600 15;color:#999999;'>" +
			H +
			"</span>" +
			"</td></tr></table>";
	else if (this.hstyle == "italics")
		H = "<I>" + H + "</I>";
	else if (this.hstyle == "")
		H = H;
	else if (this.hstyle == "noheader")
		H = H;

	// +++++++++++++++++ Construct message +++++++++++++++++++
	var M = this.message;
	if (this.mstyle == "plain") {
	}
	else if (this.mstyle == "bold")
		M = M.bold();
	else if (this.mstyle == "NGblurb")
		M = "<div style='text-align:justify;margin: -20 0 0 ; color:#0099AA;'>"+M+"</div>";
	else if (this.mstyle == "BgHx")
		M = "<div style='margin:-5 10;'><table width='195' style='font: 600 12; text-indent:10; text-align:justify; color:#0099AA;'><tr><td valign='middle'>"+M+"</td></tr></table></div>";
	else if (this.mstyle == "justify")
		M = "<div style='text-align:justify;margin: 0 0 10; color:#0099AA;'>"+M+"</div>";
	else if (this.mstyle == "jJustify")
		M = "<table width='100%' height='170'><tr valign='middle'><td valign='middle'><div style='color:#FFCC99; border:solid #FF0000; border-width:1 2; padding:7 10; background-color:#000000; font:800 14 verdana, tahoma, arial; text-align:justify; margin: 0 35 0 35;'>" +M+ "</div></td></tr></table>";

	var htmlpage = "";
	if (this.hstyle=="")
		htmlpage = M;
        else if (this.hstyle.indexOf("header")>=0)
		htmlpage = H + M;
	else
		htmlpage = H + "<BR>" + M;
	return htmlpage;
}


// ******************** helpbox constructor  ********************

function helpbox(name, hm, width, height, bgcolor, loc) {

	this.name = name;
	this.helpmessage = hm;		// hm is an array of helpmsg
//X(	this.helpmessage.length = hmSz;		
//X(    var popHeight = (this.helpmessage.length*.5)+50;		
//X(    var popHeight = (this.message.length*.5)+50;		
//X(    var popHeight = (M.length*.5)+50;		
//X(    var popHeight = (message.length*.5)+50;		
//X(    var popHeight = (hm.length*.5)+50;		

	// Implementation attributes

	this.timerHandle = null;
	this.windowHandle = null;

	this.DEFAULTWIDTH = 250;
	this.DEFAULTHEIGHT = 50;
	this.DEFAULTBGCOLOR = "#000000";
	this.DEFAULTLOC = "left";
	this.POPUPDELAY = 200;

	if (width)
		this.width = width;
	else
		this.width = this.DEFAULTWIDTH;
	if (height)
		this.height = height;
	else
		this.height = this.DEFAULTHEIGHT;
	if (bgcolor)
		this.bgcolor = bgcolor;
	else
		this.bgcolor = this.DEFAULTBGCOLOR;
	if (loc)
		this.loc = loc;
	else
		this.loc = this.DEFAULTLOC;

	return this;
}


// ******************** define methods ******************** 

function startHelp(msgindex) {
	    var cmdstr="self." + this.name + ".showHelp('" + msgindex + "')";
	    this.timerHandle = setTimeout(cmdstr, this.POPUPDELAY);
}

function showHelp(msgindex) {
	var leftPos = "";
	if (this.loc == "left")
		leftPos = 0;
	else 
		leftPos = (screen.availWidth-this.width)-10;
	if (!this.windowHandle || !this.windowHandle.name || this.windowHandle.name=="")
		this.windowHandle = window.open(
			"", +
			"subWindow", +
			"toolbar=no," +
			"location=no," +
			"directories=no," +
			"status=no," +
			"menubar=no," +
			"scrollbars=no," +
			"left=" + leftPos + "," +
			"top='0'," +
			"resizable=no," +
			"width=" + this.width + "," +
			"height=" + ((hmsg[msgindex].message.length*.60)+25)
			);
	else
		this.windowHandle.focus();

	this.windowHandle.document.open();
	var to_page =
		"<HTML>\n" +
		"<BODY STYLE='margin:0;' BGCOLOR='" + this.bgcolor + "'>" +
		this.helpmessage[msgindex].show() +
		"</BODY></HTML>\n";
	this.windowHandle.document.write(to_page);
	this.windowHandle.document.close();
}

function clearHelp() {
	clearTimeout(this.timerHandle);
	if (this.windowHandle && this.windowHandle.name) {
		this.windowHandle.close();
		this.windowHandle=null;
	}
}

new helpbox();
helpbox.prototype.startHelp = startHelp;
helpbox.prototype.showHelp = showHelp;
helpbox.prototype.clearHelp = clearHelp;


//******************** end ******************** 

// and if you really get frustrated, go to the origin: 
// http://www.geocities.com/SiliconValley/Bay/4000/popup.html
// or locate helpopupORIGINAL.js on your harddrive (e:\JS\helpopupORIGINAL.js)

