//*******************************************************************************************
function dump(o) {
	var s = '';
	for(k in o) {
		s += k + '=' + o[k] + '\n';
		if(s.length>500) {
			alert(s);
			s = '';
		}
	}
	alert(s);
}

///
///	MyArray
///
function MyArray() {}

//*******************************************************************************************
MyArray.inArray = function(array, value) {
	for(var i=0;i<array.length;i++) {
		if(array[i] == value) {
			return i;
		}	
	}

	return -1;
}

//*******************************************************************************************
MyArray.pop = function(array, value) {
	var newArray = new Array();
	var t = 0;
	for(var i=0;i<array.length;i++) {
		if(array[i] != value) {
			newArray[t] = array[i];
			t++;
		}
	}

	return newArray;
}

//*******************************************************************************************
MyArray.popIdx = function(array, idx) {
	var newArray = new Array();
	var t = 0;
	for(var i=0;i<array.length;i++) {
		if(i != idx) {
			newArray[t] = array[i];
			t++;
		}
	}
	return newArray;
}

//*******************************************************************************************
MyArray.push = function(array, value) {
	array[array.length] = value;
	return array;
}

//*******************************************************************************************
function getExpires(days) {
	oneday = 1000*3600*24;
	s = 'expires=';
	d = new Date();
	expires = new Date(d.valueOf() + oneday*days);
	s += expires.toUTCString();
	return(s);
}

//*******************************************************************************************
function setCookie(name, value, days) {
	document.cookie = name + "=" + value + ";" + getExpires(days) + ";path=/;";
}

///
///	Cookies
///
function Cookies(name) {
	return Cookies.collection[name];
}

Cookies.collection = new Object();
Cookies.init = function() {
	var cookie = document.cookie;
	var cookiesList = cookie.split(';');
	for(var i=0;i<cookiesList.length;i++) {
		var cookieItem = cookiesList[i].split('=');
		if(cookieItem.length==2) {
			var name = cookieItem[0];
			name = name.replace(/^\s+/, '');
			var value = cookieItem[1]; 
			Cookies.collection[name] = value;
		}
	}
}

Cookies.init();

function getElementById(layerID) {
	if (is_ie4) {
		return document.all(layerID);
	
	} else if (document.getElementById(layerID)) {
		return document.getElementById(layerID);
	
	} else if (document.all(layerID)) {
		return document.all(layerID);
	}
}

// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();

// *** BROWSER VERSION ***
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

// Note: Opera and WebTV spoof Navigator.  We do strict client detection.
// If you want to allow spoofing, take out the tests for opera and webtv.
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
			&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
			&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav6up = (is_nav && (is_major >= 5));
var is_gecko = (agt.indexOf('gecko') != -1);


var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
	
var is_opera  = (agt.indexOf("opera") != -1);
var is_opera7 = is_opera && (agt.indexOf("opera 7") != -1);
