
var ns4 = (document.layers)? true:false;
var ns6 = (document.getElementById)? true:false;
var ie4 = (document.all)? true:false;
var ie5 = false;
var ie6 = (navigator.userAgent.indexOf("MSIE 6") > 0) ? true : false;

if (ie6) { ie6 = true; }

if (ie4) {
	if (navigator.userAgent.indexOf('MSIE 5')>0) {
		ie5 = true;
	}
	if (ns6) {
		ns6 = false;
	}
}


var x = 0;
var y = 0;
var snow = 0;
var sw = 0;
var cnt = 0;
var dir = 1;

if(typeof ol_frame=='undefined'){var ol_frame=self;}

if ( (ns4) || (ie4) || (ns6)) {
	oframe=ol_frame;
	if (ns4) over = oframe.document.overDiv
	if (ie4) over = oframe.overDiv.style
	if (ns6) over = oframe.document.getElementById("overDiv");
	oframe.document.onmousemove = mouseMove
	if (ns4) oframe.document.captureEvents(Event.MOUSEMOVE)
} 


// Simple popup right
function drs(text) {
	dts(1,text);
}

// Caption popup right
function drc(text, title) {
	dtc(1,text,title);
}

// Sticky caption right
function src(text,title) {
	stc(1,text,title);
}

// Simple popup left
function dls(text) {
	dts(0,text);
}

// Caption popup left
function dlc(text, title) {
	dtc(0,text,title);
}

// Sticky caption left
function slc(text,title) {
	stc(0,text,title);
}

// Simple popup center
function dcs(text) {
	dts(2,text);
}

// Caption popup center
function dcc(text, title) {
	dtc(2,text,title);
}

// Sticky caption center
function scc(text,title) {
	stc(2,text,title);
}


// Clears popups if appropriate
function nd() {
	if ( cnt >= 1 ) { sw = 0 };
	if ( (ns4) || (ie4)  || (ns6) ) {
		if ( sw == 0 ) {
			snow = 0;
			hideObject(over);
		} else {
			cnt++;
		}
	}
}

// Non public functions. These are called by other functions etc.

// Simple popup
function dts(d,text) {
	txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><FONT FACE=\"Verdana, Arial\" COLOR=\""+textcolor+"\" SIZE=\"1\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>"
	layerWrite(txt);
	dir = d;
	disp();
}

// Caption popup
function dtc(d,text, title) {
	txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><SPAN ID=\"PTT\"><B><FONT COLOR=\""+capcolor+"\">"+title+"</FONT></B></SPAN></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><SPAN ID=\"PST\"><FONT COLOR=\""+textcolor+"\">"+text+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"
	layerWrite(txt);
	dir = d;
	disp();
}

// Sticky
function stc(d,text, title) {
	sw = 1;
	cnt = 0;
	txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD align=center><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN=LEFT><A HREF=\"/\" onMouseOver=\"cClick();\" ID=\"PCL\"><FONT COLOR=\""+closecolor+"\">Close this subwindow</FONT></A> &nbsp;&nbsp;</TD><TD><SPAN ID=\"PTT\"><B><FONT COLOR=\""+capcolor+"\">"+title+"</FONT></B></SPAN></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><SPAN ID=\"PST\"><FONT COLOR=\""+textcolor+"\">"+text+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"
	layerWrite(txt);
	dir = d;
	disp();
	snow = 0;
}

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");
}

function disp() {
	if ( (ns4) || (ie4) || (ns6) ) {
		if (snow == 0) 	{

			winoffsetx = (ie4) ? o3_frame.document.body.scrollLeft : o3_frame.pageXOffset;
			if (ie4) iwidth = o3_frame.document.body.clientWidth;
			if (ns4) iwidth = o3_frame.innerWidth; 
			if (ns6) iwidth = o3_frame.outerWidth;

			scrolloffsety = (ie4) ? o3_frame.document.body.scrollTop : o3_frame.pageYOffset;
			if (ie4) iheight = o3_frame.document.body.clientHeight;
			if (ns4) iheight = o3_frame.innerHeight;
			if (ns6) iheight = o3_frame.outerHeight;


			if (dir == 2) { // Center
				if (ie6) {
					moveTo(over,x+winoffsetx+offsetx-(width/2),y+scrolloffsety+offsety);
				}
				else {
					moveTo(over,x+offsetx-(width/2),y+offsety);
				}
			}
			if (dir == 1) { // Right
				if (ie6) {
					moveTo(over,x+winoffsetx+offsetx,y+scrolloffsety+offsety);
				}
				else {
					moveTo(over,x+offsetx,y+offsety);
				}	
			}
			if (dir == 0) { // Left
				if (ie6) {
					moveTo(over,x+winoffsetx-offsetx-width,y+scrolloffsety+offsety);
				}
				else {
					moveTo(over,x-offsetx-width,y+offsety);
				}
			}
			showObject(over);
			snow = 1;
		}
	}
}

if ( (ns4) || (ie4) || (ns6) ) {
	o4_frame = ol_frame;
	if (ns4) over = o4_frame.document.overDiv
	if (ie4) over = o4_frame.overDiv.style
	if (ns6) over = o4_frame.document.getElementById("overDiv");
}


// Moves the layer
function mouseMove(e) {

	winoffsetx = (ie4) ? o4_frame.document.body.scrollLeft : o4_frame.pageXOffset;
	if (ie4) iwidth = o4_frame.document.body.clientWidth;
	if (ns6) iwidth = o4_frame.outerWidth;
	if (ns4) iwidth = o4_frame.outerWidth;

	scrolloffsety = (ie4) ? o4_frame.document.body.scrollTop : o4_frame.pageYOffset;
	if (ie4) iheight = o4_frame.document.body.clientHeight;
	if (ns6) iheight = o4_frame.outerHeight;
	if (ns4) iheight = o4_frame.outerHeight;
	

	if ((ns4)||(ns6)) {x=e.pageX; y=e.pageY;}
	if (ie4) {x=event.x; y=event.y;}
	if (ie5) {x=event.x+o4_frame.document.body.scrollLeft; y=event.y+o4_frame.document.body.scrollTop;}
	if (ie6) {x=event.x; y=event.y;}

	if (snow) {
		if (dir == 2) { // Center
			if (ie6) {
				moveTo(over,x+winoffsetx+offsetx-(width/2),y+scrolloffsety+offsety);
			}
			else {
				moveTo(over,x+offsetx-(width/2),y+offsety);
			}
		}
		if (dir == 1) { // Right
			if (ie6) {
				moveTo(over,x+winoffsetx+offsetx,y+scrolloffsety+offsety);
			}
			else {
				moveTo(over,x+offsetx,y+offsety);
			}		
		}
		if (dir == 0) { // Left	
			if (ie6) {
				moveTo(over,x+winoffsetx-offsetx-width,y+scrolloffsety+offsety);
			}
			else {
				moveTo(over,x-offsetx-width,y+offsety);
			}
		}
	}
}

// The Close onMouseOver function for Sticky
function cClick() {
	hideObject(over);
	sw=0;
}

// Writes to a layer
function layerWrite(txt) {
	if(ns4){
		var lyr=oframe.document.overDiv.document
		lyr.write(txt)
		lyr.close()
	}else if(ie4){
		oframe.document.all["overDiv"].innerHTML=txt
	}else if(ns6){
		range=oframe.document.createRange();
		range.setStartBefore(over);
		domfrag=range.createContextualFragment(txt);
		while(over.hasChildNodes()){
			over.removeChild(over.lastChild);
		}
		over.appendChild(domfrag);
	}
}


// Make an object visible
function showObject(obj) {
	if(ns4)obj.visibility="show";
	else if(ie4)obj.visibility="visible";
	else if(ns6)obj.style.visibility="visible";
}

// Hides an object
function hideObject(obj) {
	if(ns4)obj.visibility="hide";
	else if(ie4)obj.visibility="hidden";
	else if(ns6)obj.style.visibility="hidden";
}

// Move a layer
function moveTo(obj,xL,yL) {
if((ns4)||(ie4)){
	obj.left=xL;
	obj.top=yL;
}else if(ns6){
	obj.style.left=xL + "px";
	obj.style.top=yL+ "px";
}
}

