/***********************************************************
*  xhttp module [visualstory] : do not edit this function  *
***********************************************************/
function setXHR(method, url, async, uid, pwd, docType,isJson, params, callback){
	//method:(GET,POST), url:address, async:(true,false), uid:user id, pwd:user pwd, params : parameter, isJason : (true,false), callback : process function
	var resType = "responseText";
	if(docType == "xml") resType = "responseXML";
	if(params == "") params = null;
	if(async == "") async = true;
	//alert(params);
	var xObj = {
		xhttp:null,
		create:function(){
			try{
				if (window.XMLHttpRequest){
					xObj.xhttp = new XMLHttpRequest();
					if(docType == 'xml' && xObj.xhttp.overrideMimeType) {
						xObj.xhttp.overrideMimeType('text/xml');
					}
				}else if(window.ActiveXObject){
					xObj.xhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
			}catch(e){
				alert(e);
			}
			/** set handler **/
			xObj.baseCallBack = function(arg){//base handler
				alert("[has no callback function]\r\n" + arg);
			}			
			if(callback){
				xObj.setResult = callback;
			}else{
				xObj.setResult = xObj.baseCallBack;	
			}
		},
		//force to abort
		timer:window.setTimeout(function(){xObj.xhttp.abort();}, 10000)
	}
	xObj.create();

	try{xObj.xhttp.open(method,url,async);} catch(err){alert(err);return;}
	
	if(xObj.xhttp != null){
		xObj.xhttp.onreadystatechange = function(){
			
			if(xObj.xhttp.readyState == 4) {
				clearTimeout(xObj.timer);
				if(xObj.xhttp.status == 200) {					
					
					if(docType == 'xml'){
						if(window.ActiveXObject) xObj.xhttp[resType].loadXML(xObj.xhttp.responseText);
					}
					//alert(xObj.xhttp[resType]);
					if(isJson){ 
						try {
							xObj.setResult( eval("("+xObj.xhttp[resType]+")") );
						}catch(err){alert(err);return;}
					}
					else xObj.setResult(xObj.xhttp[resType]);
				}else{
					var isErrCode = xObj.xhttp.status;
					if(isErrCode == 403) {
						alert("access denied.  ");
						xObj.setResult(null);
					}
					else if(isErrCode == 404) {
						alert("file is not found  ");
						xObj.setResult(null);
					}					
					else {//aboart
						//alert("Error while loading : [code : "+ isErrCode +"]");
						xObj.setResult(null);
					}
				}
			}
		}
	}else{
		alert('XMLHTTP Object is null');
		return;
	}

	//if(method == "POST") xObj.xhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	if(method == "POST") xObj.xhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
	try {xObj.xhttp.send(params);} catch(err){alert(err);}
}