/*  compat.js  -  Implements some platform-compatibility code.
 *  (C) Copyright 2003  Kars Meyboom <kars@kde.nl>
 *
 *  LICENSE:
 * 
 *  This code is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 * 
 *  This code is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 *  DESCRIPTION:
 * 
 *  This file contains several functions and variables in an attempt
 *  to hide incompatibility issues between browsers.
 * 
 */

// --
// -- GLOBALS
// --

var isIE = (navigator.appName.indexOf('Explorer') >= 0);
var isBrokenMoz = (!isIE)
	&& (navigator.product.indexOf('Gecko') >= 0)
	&& (   (navigator.userAgent.indexOf('rv:1.3)') >= 0)
	    || (navigator.userAgent.match(/rv:1\.(\d+)/)[1] >= 4)
	   );

// --
// -- FUNCTIONS
// --

function getTarget (event) {
	return (isIE) ? event.srcElement : event.target;
}

function imgX (image) {
	if (isIE) {
		return image.offsetLeft;
	} else {
		return image.x;
	}
}

function imgY (image) {
	if (isIE) {
		return image.offsetTop;
	} else {
		return image.y;
	}
}

// -- IE 5.0's array implementation doesn't support the Javascript 1.2
// -- push and pop methods; this is a work-around.

// pushes element e onto the end of array a.
function push (a, e) {
	a[a.length] = e;
}

// pops the last element of the array from the stack and returns it.
function pop (a) {
	if (a.length == 0) {
		return null;
	}
	var e = a[a.length - 1];
	a.length--;
	return e;
}

// returns 1 if the specified element appears in the given array,
// or 0 otherwise.
function in_list(list, element) {
	for (var i = 0; i < list.length; i++) {
		if (list[i] == element) {
			return 1;
		}
	}
	return 0;
}


