/**
Javascript adapted from http://www.phpMyAdmin.net/
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object   the table row
 * @param   string   the action calling this script (over, out or click)
 * @param   string   the default background color
 * @param   string   the color to use for mouseover
 * @param   string   the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()) {
        if (theAction == 'out') {
            newColor = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor = (thePointerColor != '')
                     ? thePointerColor
                     : theDefaultColor;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function



//\//////////////////////////////////////////////////////////////////////////////////
//\  overLIB 3.50  --  This notice must remain untouched at all times.
//\  Copyright Erik Bosrup 1998-2001. All rights reserved.
//\
//\  By Erik Bosrup (erik@bosrup.com).  Last modified 2001-08-28.
//\  Portions by Dan Steinman (dansteinman.com). Additions by other people are
//\  listed on the overLIB homepage.
//\
//\  Get the latest version at http://www.bosrup.com/web/overlib/
//\
//\  This script is published under an open source license. Please read the license
//\  agreement online at: http://www.bosrup.com/web/overlib/license.html
//\  If you have questions regarding the license please contact erik@bosrup.com.
//\
//\  This script library was originally created for personal use. By request it has
//\  later been made public. This is free software. Do not sell this as your own
//\  work, or remove this copyright notice. For full details on copying or changing
//\  this script please read the license agreement at the link above.
//\
//\  Please give credit on sites that use overLIB and submit changes of the script
//\  so other people can use them as well. This script is free to use, don't abuse.
//\//////////////////////////////////////////////////////////////////////////////////

//\  THIS IS A *VERY* MODIFIED VERSION (by eco Ltd). DO NOT EDIT OR PUBLISH. GET THE ORIGINAL!

var LEFT		=	7;
var CENTER		=	9;
var RIGHT		=	8;
var BELOW		=	36;
var ABOVE		=	35;
var o3_sticky = 1;
var o3_close = "Close";
var o3_offsetx = 2;
var o3_offsety = 2;
var o3_vpos = BELOW;
var o3_function = Function();
var o3_closeclick = 1;
var o3_allowmove = 0;
var o3_width = 200;
var o3_hpos = RIGHT;
var o3_aboveheight = 0;
var o3_hauto = 1;
var o3_vauto = 1;
var o3_x = 0;
var o3_y = 0;
var o3_allow = 0;
var o3_showingsticky = 0;
var o3_removecounter = 0;
var over = null;

// Decide browser version
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) || (navigator.userAgent.indexOf('MSIE 6') > 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;
}

function overlib() {
if (ns4) over = self.document.overDiv
if (ie4) over = self.overDiv.style
if (ns6) over = self.document.getElementById("overDiv");
var ar = arguments;
o3_text = ar[0];
o3_cap = ar[1];
return overlib350();
}
function nd() {
	if ( o3_removecounter >= 1 ) { o3_showingsticky = 0 };
	if ( (ns4) || (ie4) || (ns6) ) {
		if ( o3_showingsticky == 0 ) {
			o3_allowmove = 0;
			if (over != null) hideObject(over);
		} else {
			o3_removecounter++;
		}
	}
	
	return true;
}

function overlib350() {
	var layerhtml;
	layerhtml = ol_content_caption(o3_text, o3_cap, o3_close);
	if (o3_sticky) {
		o3_showingsticky = 1;
		o3_removecounter = 0;
	}
	layerWrite(layerhtml);
	o3_allowmove = 0;
	disp();
	if (o3_sticky) {
		o3_allowmove = 0;
		return false;
	} else {
		return true;
	}
}

function ol_content_caption(text, title, close) {
	closing = "<TD ALIGN=RIGHT><A HREF=\"/\" onMouseOver=\"return cClick();\"><FONT SIZE=1 COLOR=\"white\">"+close+"</FONT></A></TD>";
	txt = "<TABLE WIDTH="+o3_width+" BORDER=0 CELLPADDING=1 CELLSPACING=0 BGCOLOR=\"#333399\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><B><FONT SIZE=1 COLOR=\"#FFFFFF\">"+title+"</FONT></B></TD>"+closing+"</TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\"#CCCCFF\"><TR><TD VALIGN=TOP><FONT SIZE=1 COLOR=\"#000000\">"+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;
	}
}

function placeLayer() {
	var placeX, placeY;
	
		winoffset = (ie4) ? self.document.body.scrollLeft : self.pageXOffset;
		if (ie4) iwidth = self.document.body.clientWidth;
		if (ns4) iwidth = self.innerWidth; // was screwed in mozilla, fixed now?
		if (ns6) iwidth = self.outerWidth;
		
		if (o3_hauto == 1) {
			if ( (o3_x - winoffset) > ((eval(iwidth)) / 2)) {
				o3_hpos = LEFT;
			} else {
				o3_hpos = RIGHT;
			}
		}
		
		if (o3_hpos == CENTER) { // Center
			placeX = o3_x+o3_offsetx-(o3_width/2);
		}
		if (o3_hpos == RIGHT) { // Right
			placeX = o3_x+o3_offsetx;
			if ( (eval(placeX) + eval(o3_width)) > (winoffset + iwidth) ) {
				placeX = iwidth + winoffset - o3_width;
				if (placeX < 0) placeX = 0;
			}
		}
		if (o3_hpos == LEFT) { // Left
			placeX = o3_x-o3_offsetx-o3_width;
			if (placeX < winoffset) placeX = winoffset;
		}

		scrolloffset = (ie4) ? self.document.body.scrollTop : self.pageYOffset;

		if (o3_vauto == 1) {
			if (ie4) iheight = self.document.body.clientHeight;
			if (ns4) iheight = self.innerHeight;
			if (ns6) iheight = self.outerHeight;

			iheight = (eval(iheight)) / 2;
			if ( (o3_y - scrolloffset) > iheight) {
				o3_vpos = ABOVE;
			} else {
				o3_vpos = BELOW;
			}
		}

		if (o3_vpos == ABOVE) {
			if (o3_aboveheight == 0) {
				var divref = (ie4) ? self.document.all['overDiv'] : over;
				o3_aboveheight = (ns4) ? divref.clip.height : divref.offsetHeight;
			}

			placeY = o3_y - (o3_aboveheight + o3_offsety);
			if (placeY < scrolloffset) placeY = scrolloffset;
		} else {
			placeY = o3_y + o3_offsety;
		}
	repositionTo(over, placeX, placeY);
}

function mouseMove(e) {
	if ( (ns4) || (ns6) ) {o3_x=e.pageX; o3_y=e.pageY;}
	if (ie4) {o3_x=event.x; o3_y=event.y;}
	if (ie5) {o3_x=event.x+self.document.body.scrollLeft; o3_y=event.y+self.document.body.scrollTop;}
	
	if (o3_allowmove == 1) {
		placeLayer();
	}
}

function cClick() {
	hideObject(over);
	o3_showingsticky = 0;
	
	return false;
}

function layerWrite(txt) {
	txt += "\n";
	
        if (ns4) {
                var lyr = self.document.overDiv.document

                lyr.write(txt)
                lyr.close()
        } else if (ie4) {
		self.document.all["overDiv"].innerHTML = txt
	} else if (ns6) {
		range = self.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.visibility = "visible";
}

function hideObject(obj) {
        if (ns4) obj.visibility = "hide";
        else if (ie4) obj.visibility = "hidden";
	else if (ns6) obj.style.visibility = "hidden";
        
 self.status = "";
}

function repositionTo(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";
	}
}
