// JavaScript Document
var httpRequest;
var theData;

function request(url, data) {
	if (typeof data == "undefined") { data=""; }
	if (data == null) { data=""; }
	if (data!="") {
		url+="?data="+encodeURI(data);
	}
	
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		httpRequest = new XMLHttpRequest();
		if (httpRequest.overrideMimeType) {
			httpRequest.overrideMimeType('text/xml');
		}
	} 
	else if (window.ActiveXObject) { // IE
		try {
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) {
			try {
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
		catch (e) {}
		}
	}
	
	if (!httpRequest) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	
	httpRequest.onreadystatechange = function() {
		//response();
	};
	httpRequest.open('GET', url, true);
	httpRequest.send('');
	
}
	
function getCookie(cookie_name) {
	var x = readCookie(cookie_name);
	if (x) {
		process(x);
	}
}
	
_constantPollTimer=null;
_constantPollURL="";
_constantPollInterval=1000;
function constantPoll(cookie_name) {
	_constantPollURL=cookie_name;
	getCookie(cookie_name);
	setTimeout("constantPoll('"+cookie_name+"')", _constantPollInterval);
	
}

function createCookie(thename,thevalue,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = thename+"="+thevalue+expires+"; path=/";
}

function readCookie(thename) {
	var nameEQ = thename + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(thename) {
	createCookie(thename,"",-1);
}