//*******************************************************************************************
/*Object.prototype.dump = function() {
	var s = '';
	for(k in this) {
		s += k + '=' + this[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();