// COOKIE FUNCTIONS
function cookies_browser_compatible(){
	if(navigator.cookieEnabled)
		return true;
	else
		return false;
}

function cookies_reldate(days) {
	var d;
	d = new Date();
	
	/* We need to add a relative amount of time to
	the current date. The basic unit of JavaScript
	time is milliseconds, so we need to convert the
	days value to ms. Thus we have
	ms/day
	= 1000 ms/sec *  60 sec/min * 60 min/hr * 24 hrs/day
	= 86,400,000. */
	
	d.setTime(d.getTime() + days*86400000);
	return d.toGMTString();
}

function cookies_read(name) {
	var s = document.cookie, i;
	if (s)
	for (i=0, s=s.split('; '); i<s.length; i++) {
	s[i] = s[i].split('=', 2);
	if (unescape(s[i][0]) == name)
	return unescape(s[i][1]);
	}
	return null;
}

function cookies_make(name, value, p) {
	var s, k;
	s = escape(name) + '=' + escape(value);
	if (p) for (k in p) {
	
	/* convert a numeric expires value to a relative date */
	
	if (k == 'expires')
	p[k] = isNaN(p[k]) ? p[k] : cookies_reldate(p[k]);
	
	/* The secure property is the only special case
	here, and it causes two problems. Rather than
	being '; protocol=secure' like all other
	properties, the secure property is set by
	appending '; secure', so we have to use a
	ternary statement to format the string.
	
	The second problem is that secure doesn't have
	any value associated with it, so whatever value
	people use doesn't matter. However, we don't
	want to surprise people who set { secure: false }.
	For this reason, we actually do have to check
	the value of the secure property so that someone
	won't end up with a secure cookie when
	they didn't want one. */
	
	if (p[k])
	s += '; ' + (k != 'secure' ? k + '=' + p[k] : k);
	}
	document.cookie = s;
	return cookies_read(name) == value;
}

function cookies_rm(name) {
	return !cookies_make(name, '', { expires: -1 });
}

function cookies_set(name, value, p) {
	cookies_rm(name);
	cookies_make(name, value, p);
}

// OTHER FUNCTZ

function getkey(e)
{
if (window.event)
	return window.event.keyCode;
else if (e)
	return e.which;
else
	return null;
}

function addslashes(str) {
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\0/g,'\\0');
return str;
}

function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}

function array_randomize(array) {
	array_elements = array.length;
	for(i=0; i<array_elements; i++) {
		rnd = Math.floor(Math.random()*array_elements);
		rnd2 = Math.floor(Math.random()*array_elements);
		tmp = array[rnd]; array[rnd] = array[rnd2]; array[rnd2] = tmp;
	}
	return array;
}

function w(txt) {
	document.write(txt);
}