// JavaScript Document
//XMLHttpRequest????????
//createHttpRequest()
//
// @returns XMLHttpRequest?????? ???null
//
function createHttpRequest()
{
	if(window.ActiveXObject)
	{
		try 
		{
			return new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				return new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e2) 
			{
				return null;
			}
		 }
	} 
	else if(window.XMLHttpRequest)
	{
		return new XMLHttpRequest();
	} 
	else 
	{
		return null;
	}
}

// requestFile( callback , data , method , fileURL , async )
//
// @param callback ???????????
// @param data	 ???????
// @param method "POST" or "GET"
// @param fileURL????????????URL
// @param async	Async??true Sync??false
// --@param user A username for authentication if necessary.
// --@param password A password for authentication if necessary.
// ??????????????
//
function requestFile( callback , data , method , fileURL , async )
{
	//XMLHttpRequest????????
	var oj = createHttpRequest()
	if( oj == null ) return null

	//??????-->???????????????
	var ua = navigator.userAgent
	var safari	= ua.indexOf("Safari")!=-1
	var konqueror = ua.indexOf("Konqueror")!=-1
	var mozes	 = ((a=navigator.userAgent.split("Gecko/")[1] )?a.split(" ")[0]:0) >= 20011128 
	
	//Konqueror?onload????http://jsgt.org/ajax/ref/test/response/responsetext/try1.php
	if(window.opera || safari || mozes)
	{
	oj.onload = function () { callback(oj) }
	}
	else
	{
		oj.onreadystatechange =function () 
		{
			if ( oj.readyState == 4 )
			{
				callback(oj)
			}
		}
	}

	//open ????
	oj.open( method , fileURL , async )

	
	if(method == 'POST')
	{
		//???????Win Opera8??????????????????2005.5.20
		if(!window.opera)
			oj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
	}

	//send ????
	oj.send(data)

}

