var INARRAY		=	1;
var CAPARRAY		=	2;
var STICKY		=	3;
var BACKGROUND		=	4;
var NOCLOSE		=	5;
var CAPTION		=	6;
var LEFT		=	7;
var RIGHT		=	8;
var CENTER		=	9;
var OFFSETX		=	10;
var OFFSETY		=	11;
var FGCOLOR		=	12;
var BGCOLOR		=	13;
var TEXTCOLOR		=	14;
var CAPCOLOR		=	15;
var CLOSECOLOR		=	16;
var WIDTH		=	17;
var BORDER		=	18;
var STATUS		=	19;
var AUTOSTATUS		=	20;
var AUTOSTATUSCAP	=	21;
var HEIGHT		=	22;
var CLOSETEXT		=	23;
var SNAPX		=	24;
var SNAPY		=	25;
var FIXX		=	26;
var FIXY		=	27;
var FGBACKGROUND	=	28;
var BGBACKGROUND	=	29;
var PADX		=	30;
var PADY		=	31;
var PADX2		=	32;
var PADY2		=	33;
var FULLHTML		=	34;
var ABOVE		=	35;
var BELOW		=	36;
var CAPICON		=	37;
var TEXTFONT		=	38;
var CAPTIONFONT		=	39;
var CLOSEFONT		=	40;
var TEXTSIZE		=	41;
var CAPTIONSIZE		=	42;
var CLOSESIZE		=	43;
var FRAME		=	44;
var TIMEOUT		=	45;
var FUNCTION		=	46;
var DELAY		=	47;
var HAUTO		=	48;
var VAUTO		=	49;


var ol_capicon = ""; 
var ol_frame = self; 
var ol_delay = 0; 
var o3_cap = "";
var o3_frame = self;
var o3_timerid = 0;
var o3_allowmove = 0;
var o3_delay = 0;
var o3_delayid = 0;
var o3_x = 0;
var o3_y = 0;
var o3_allow = 0;
var o3_showingsticky = 0;
var o3_removecounter = 0;
var over = null;
var ns4 = (document.layers)? true:false;
var ns6 = (document.getElementById)? true:false;
var ie4 = (document.all)? true:false;
var ie5 = false;
if (ie4) {
	if (navigator.userAgent.indexOf('MSIE 5')>0) {
		ie5 = true;
	}
	if (ns6) {
		ns6 = false;
	}
}
if ( (ns4) || (ie4) || (ns6)) {
	document.onmousemove = mouseMove
	if (ns4) document.captureEvents(Event.MOUSEMOVE)
} else {
	overlib = no_overlib;
	nd = no_overlib;
	ver3fix = true;
}


// Fake function for 3.0 users.
function no_overlib() {
	return ver3fix;
}
function overlib() {
	
	// Load defaults to runtime.
	o3_text ="Default Text";
	o3_cap ="";
	o3_sticky =0;
	o3_background ="";
	o3_close ="Close";
	o3_hpos = RIGHT;
	o3_offsetx = 22;
	o3_offsety = 22;
	o3_fgcolor =  "#004080";
	o3_bgcolor =  "#004080";
	o3_textcolor = "#a5f999";
	o3_capcolor ="#FFFFFF";
	o3_closecolor ="#9999FF";
	o3_width ="244";
	o3_border = "2";
	o3_status = "";
	o3_autostatus = 0;
	o3_height = -1;
	o3_snapx = 10;
	o3_snapy = 0;
	o3_fixx = 10;
	o3_fixy = 13;
	o3_fgbackground ="";
	o3_bgbackground ="";
	o3_padxl = 0;
	o3_padxr = 0;
	o3_padyt = 0;
	o3_padyb = 0;
	o3_fullhtml = 0;
	o3_vpos = BELOW;
	o3_aboveheight = 0;
	o3_capicon = "";
	o3_textfont ="Tahoma";
	o3_captionfont ="Tahoma";
	o3_closefont = "Tahoma";
	o3_textsize ="2";
	o3_captionsize = "2";
	o3_closesize = "1";
	o3_timeout = 0;
	o3_function = Function();

	
	// Special for frame support, over must be reset...
	if ( (ns4) || (ie4) || (ns6) ) {
		o3_frame = ol_frame;
		if (ns4) over = o3_frame.document.overDiv
		if (ie4) over = o3_frame.overDiv.style
		if (ns6) over = o3_frame.document.getElementById("overDiv");
	}
	
	
	// What the next argument is expected to be.
	var parsemode = -1;

	for (i = 0; i < arguments.length; i++) {
		
		if (parsemode == 0) {
			// Arg is command
			if (arguments[i] == INARRAY) { parsemode = INARRAY; }
			if (arguments[i] == CAPARRAY) { parsemode = CAPARRAY; }
			if (arguments[i] == CAPTION) { parsemode = CAPTION; }
			if (arguments[i] == AUTOSTATUS) { parsemode = opt_AUTOSTATUS(arguments[i]); }
			if (arguments[i] == AUTOSTATUSCAP) { parsemode = opt_AUTOSTATUSCAP(arguments[i]); }
			if (arguments[i] == HEIGHT) { parsemode = HEIGHT; }
			if (arguments[i] == CLOSETEXT) { parsemode = CLOSETEXT; }
			if (arguments[i] == FUNCTION) { parsemode = FUNCTION; }
				

		} else {
			if (parsemode < 0) {
				// Arg is maintext, unless INARRAY
				if (arguments[i] == INARRAY) {
					parsemode = INARRAY;
				} else {
					o3_text = arguments[i];
					parsemode = 0;
				}
			} else {
				// Arg is option for command
				if (parsemode == INARRAY) { parsemode = opt_INARRAY(arguments[i]); }
				if (parsemode == CAPARRAY) { parsemode = opt_CAPARRAY(arguments[i]); }
							if (parsemode == CAPTION) { parsemode = opt_CAPTION(arguments[i]); }
							if (parsemode == FRAME) { parsemode = opt_FRAME(arguments[i]); }
			                        if (parsemode == FUNCTION) { parsemode = opt_FUNCTION(arguments[i]); }
				if (parsemode == DELAY) { parsemode = opt_DELAY(arguments[i]); }

			}
		}
	}

	if (o3_delay == 0) {
		return overlib330();
	} else {
		o3_delayid = setTimeout("overlib330()", o3_delay);
		return;
	}
}

function overlib330() {

	// Make layer content
	var layerhtml;

	{
		// They want a popup box.

		// Prepare popup background
		if (o3_fgbackground != "") {
			o3_fgbackground = "BACKGROUND=\""+o3_fgbackground+"\"";
		}
		if (o3_bgbackground != "") {
			o3_bgbackground = "BACKGROUND=\""+o3_bgbackground+"\"";
		}

		// Prepare popup colors
		if (o3_fgcolor != "") {
			o3_fgcolor = "BGCOLOR=\""+o3_fgcolor+"\"";
		}
		if (o3_bgcolor != "") {
			o3_bgcolor = "BGCOLOR=\""+o3_bgcolor+"\"";
		}

		// Prepare popup height
		if (o3_height > 0) {
			o3_height = "HEIGHT=" + o3_height;
		} else {
			o3_height = "";
		}

							// Show close text
				layerhtml = ol_content_caption(o3_text, o3_cap, o3_close);
				}
		// We want it to stick!
	if (o3_sticky) {
		o3_showingsticky = 1;
		o3_removecounter = 0;
	}
	
	// Write layer
	layerWrite(layerhtml);
	
	// Prepare status bar
	if (o3_autostatus > 0) {
		o3_status = o3_text;
		if (o3_autostatus > 1) {
			o3_status = o3_cap;
		}
	}

	// When placing the layer the first time, even stickies may be moved.
	o3_allowmove = 0;

		// Show layer
	disp(o3_status);

	// Stickies should stay where they are.	
	if (o3_sticky) {
		o3_allowmove = 0;
		return false;
	} else {
		return true;
	}
}

// Makes table with caption and optional close link
function ol_content_caption(text, title, close) {
	closing = "";
	if (close != "") {
		closing = "<TD ALIGN=RIGHT><A HREF=\"/\" onMouseOver=\"cClick();\"><FONT COLOR=\""+o3_closecolor+"\" FACE=\""+o3_closefont+"\" SIZE=\""+o3_closesize+"\">"+close+"</FONT></A></TD>";
		}
	txt = "<TABLE WIDTH="+o3_width+" BORDER=0 CELLPADDING="+o3_border+" CELLSPACING=0 "+o3_bgcolor+" "+o3_bgbackground+" "+o3_height+"><TR><TD><TABLE WIDTH=100% BORDER=2 CELLPADDING=1 CELLSPACING=0><TR><TD><B><FONT COLOR=\""+o3_capcolor+"\" FACE=\""+o3_captionfont+"\" SIZE=\""+o3_captionsize+"\">"+o3_capicon+title+"</FONT></B></TD>"+closing+"</TR></TABLE><TABLE WIDTH=100% BORDER=2 CELLPADDING=2 CELLSPACING=0 "+o3_fgcolor+" "+o3_fgbackground+" "+o3_height+"><TR><TD VALIGN=TOP><FONT COLOR=\""+o3_textcolor+"\" FACE=\""+o3_textfont+"\" SIZE=\""+o3_textsize+"\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>";
	return txt;
}
function disp(statustext) {
	if ( (ns4) || (ie4) || (ns6) ) {
		if (o3_allowmove == 0) 	{
			placeLayer();
			showObject(over);
			o3_allowmove = 1;
		}
	}

	if (statustext != "") {
		self.status = statustext;
	}
}

// Decides where we want the popup.
function placeLayer() {
	var placeX, placeY;
	
	// HORIZONTAL PLACEMENT
	if (o3_fixx > -1) {
		// Fixed position
		placeX = o3_fixx;
	} else {
		// If HAUTO, decide what to use.
		if (o3_hauto == 1) {
			if (ie4) iwidth = o3_frame.document.body.clientWidth;
			if (ns4) iwidth = o3_frame.innerWidth;
			if (ns6) iwidth = o3_frame.outerWidth;

			iwidth = (eval(iwidth)) / 2;
			if (o3_x > iwidth) {
				o3_hpos = LEFT;
			} else {
				o3_hpos = RIGHT;
			}
		}
		
			// Snapping!
		if (o3_snapx > 1) {
			var snapping = placeX % o3_snapx;
			if (o3_hpos == LEFT) {
				placeX = placeX - (o3_snapx + snapping);
			} else {
				// CENTER and RIGHT
				placeX = placeX + (o3_snapx - snapping);
			}
		}
	}
	
	// VERTICAL PLACEMENT
	if (o3_fixy > -1) {
		// Fixed position
		placeY = o3_fixy;
			}
	moveTo(over, placeX, placeY);
}

function cClick() {
	hideObject(over);
	o3_showingsticky = 0;
}


function compatibleframe(frameid) {        
	if (ns4) {
		if (typeof frameid.document.overDiv =='undefined') return false;
	} else if (ie4) {
		if (typeof frameid.document.all["overDiv"] =='undefined') return false;
	}

	return true;
}

function layerWrite(txt) {
        if (ns4) {
                var lyr = o3_frame.document.overDiv.document

                lyr.write(txt)
                lyr.close()
        } else if (ie4) {
		o3_frame.document.all["overDiv"].innerHTML = txt
	} else if (ns6) {
		range = o3_frame.document.createRange();
		range.setStartBefore(over);
		domfrag = range.createContextualFragment(txt);
		while (over.hasChildNodes()) {
			over.removeChild(over.lastChild);
		}
		over.appendChild(domfrag);
	}
}

function showObject(obj) {
        if (ns4) obj.visibility = "show"
        else if (ie4) obj.visibility = "visible"
	else if (ns6) obj.style.display = "block"
}

function hideObject(obj) {
        if (ns4) obj.visibility = "hide"
        else if (ie4) obj.visibility = "hidden"

      }

function moveTo(obj,xL,yL) {
	if ( (ns4) || (ie4) ) {
	        obj.left = xL;
	        obj.top = yL;
	} else if (ns6) {
		obj.style.left = xL;
		obj.style.top = yL;
	}		
}

function opt_CAPTION(text) {
	o3_cap = text;
	return 0;
}

function opt_HPOS(pos) {
	o3_hpos = pos;
	return 0;
}

function vpos_convert(d) {
	if (d == 0) {
		d = LEFT;
	} else {
		if (d == 1) {
			d = RIGHT;
		} else {
			d = CENTER;
		}
	}
	
	return d
}

function dtc(d,text, title) {
	o3_hpos = vpos_convert(d);
	overlib(text, CAPTION, title, o3_hpos);
}

function drc(text, title) {
	dtc(1,text,title);
}



