function Request(url,vars,output,disel,enc,method)
{
	if(!enc) enc = false;
	if(!method) method = "POST";
	if(!disel) disel = false;
	this.dooutputfunction=false;
	if(output=='createone')
	{
		var name,a,i,c,div;
		c = 0;
		a = document.getElementsByTagName('div');
		for(i=0;i<a.length;i++)
		{
			if(a[i].id=="output")
				c++;
		}
		
		if(c==0)
			name = "output";
		else
			name = "output_" + c;	
		div = document.createElement("div");
		div.id=name;
		div.innerHTML='';
		document.body.appendChild(div);	
		
		this.output = document.getElementById(name);
		
	} else if(output.substr(0,9)=="function:") 
	{
		fname = output.substr(9,output.length);
		this.outputfunction = fname;
		this.dooutputfunction=true;
	} else {
		this.output = output;
	}
	this.disel = disel;
	this.url = url;
	this.enc = enc;
	this.method = method;
	this.vars = vars;
	
	//precache
}


function setfakevars(vars,name)
{
	var inp = document.createElement("input");
	inp.type = "hidden";
	inp.style.display = "none";
	inp.name = name;
	inp.id = "inp_fake_var_"+Math.floor(Math.random()*5);
	inp.className="inpfakevar";
	inp.value = escape(vars);
	document.body.appendChild(inp);
}

function getfakevars(name)
{
	var ids = document.getElementsByClassName("inpfakevar");
	for(i=0;i<ids.length;i++)
	{
		var n = ids[i].name;
		if(n==name)
		{
			return unescape(ids[i].value);
		}
	}
	return false;
}

function trashfakevars()
{
	var ids = document.getElementsByClassName("inpfakevar");
	for(i=0;i<ids.length;i++)
	{
		document.body.removeChild(ids[i]);
	}
}


Request.prototype.init = function(obj) 
{
	var headers,xml,response,errorid,status,outer;
	if(obj)
		this.obj = obj;
	this.loading();
	xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();   
	this.xmlHttpRequest = xml;
	var doOutputFunction = this.dooutputfunction;
	var outputFunction = this.outputfunction;
	var output = this.output;
	xml.onreadystatechange = function()
	{
		if (xml.readyState == 4)
		{
			if(doOutputFunction=="false")
			{
				var outer = document.getElementById(output);
			}
			response = xml.responseText;
			errorid = xml.status;
			status = xml.statusText;
			if (errorid == 200)
			{
				if(doOutputFunction=="false")
				{
					outer.innerHTML=response;
				} else {
					eval(outputFunction+"('"+escape(response)+"')");
				}
			} else {
				alert("ERROR: '"+status+"', code: '"+errorid+"'");
			}
		}
	}
	xml.open(this.method, this.d(), true);
	xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xml.send(this.vars);
}

/*
Request.prototype.init = function(obj) 
{
	var headers,xml,response,errorid,status,outer;
	if(obj)
		this.obj = obj;
	this.loading();
	xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();   
	this.xmlHttpRequest = xml;
	setfakevars(this.output,"outerid");
	setfakevars(this.outputfunction,"outputfunction");
	setfakevars(this.dooutputfunction+'',"outerfunctionq");
	xml.onreadystatechange = function()
	{
		if (xml.readyState == 4)
		{
			if(getfakevars("outerfunctionq")=="false")
			{
			var outer = document.getElementById(getfakevars("outerid"));
			trashfakevars();
			}
			response = xml.responseText;
			errorid = xml.status;
			status = xml.statusText;
			if (errorid == 200)
			{
				if(getfakevars("outerfunctionq")=="false")
				{
					outer.innerHTML=response;
				} else {
					eval(getfakevars("outputfunction")+"('"+escape(response)+"')");
				}
			} else {
				outer.innerHTML="ERROR: '"+status+"', code: '"+errorid+"'";
			}
		}
	}
	xml.open(this.method, this.d(), true);
	xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xml.send(this.vars);
}
*/



Request.prototype.d = function()
{
	return this.url;
	
	// encrpytion later
	var url;
	url = this.url;
	if(!this.enc) return url;
}


Request.prototype.loading = function()
{
	var div,output;
	if(!this.dooutputfunction)
	{
		output = document.getElementById(this.output);
		if(this.disel&&this.obj) this.obj.style.display = "none";
		this.outputidorig = output.id;
		//output.id = "outputid___";
		//this.outputid = "outputid___";
		output.innerHTML = "";
		div = document.createElement("div");
		div.id = "fakeloader_";
		div.name = "fakeloader_";
		div.innerHTML='Loading...';
		this.fakeloader = output.appendChild(div);
	}
}




function precache(array,type,swfsecs)
{
	if(!type)
		type = "url";
	this.type = type;
	this.url = array;
	this.swfsecs = swfsecs;
	if(!swfsecs) this.swfsecs=3;
}

precache.prototype.cache_url = function()
{
	var url,xml,iframe;
	ar = this.url;
	for(i=0;i<ar.length;i++)
	{
		url = ar[i];
		iframe = document.createElement("iframe");
		iframe.src = url;
		iframe.style.display="none";
		iframe.id = "url_"+Math.floor(Math.round()*12)+"_"+i;
		iframe.onload=function(){precache.prototype.remove(this);}
		document.body.appendChild(iframe);
	}
}

precache.prototype.remove = function(e)
{
	if(e)
	{
		setTimeout("document.body.removeChild(document.getElementById('"+e.id+"'));",1);
	}
}

precache.prototype.cache_img = function()
{
	var url,img;
	ar = this.url;
	for(i=0;i<ar.length;i++)
	{
		url = ar[i];
		img = new Image();
		img.src = url;
		img.style.display="none";
		img.id = "img_"+Math.floor(Math.round()*12)+"_"+i;
		img.onload=function(){precache.prototype.remove(this);}
		document.body.appendChild(img);
	}
}

precache.prototype.cache_swf = function()
{
	var url,swf,obj;
	ar = this.url;
	for(i=0;i<ar.length;i++)
	{
		url = ar[i];
		swf = document.createElement("embed");
		obj = document.createElement("object");
		obj.id = "obj_"+""+"_"+i;
		p1 = document.createElement("param");
		p1.name="movie";
		p1.value=url;
		swf.src = url;
		swf.style.display="none";
		swf.id = "swf_"+""+"_"+i;
		obj.appendChild(swf);
		document.body.appendChild(obj);
		setTimeout("precache.prototype.remove(document.getElementById('"+obj.id+"'));",this.swfsecs*1000);
	}
}

precache.prototype.init = function()
{
	switch(this.type)
	{
		case "url": this.cache_url(); break;
		case "img": this.cache_img(); break;
		case "swf": this.cache_swf(); break;
		default: return false; break;
	}
}