var xmlHttpDownload;
var total_brId;
var total_fileName;
var total_downloadCost;

function createxmlHttpDownloadRequest() {
	if (window.ActiveXObject) {
		xmlHttpDownload = new ActiveXObject("Microsoft.xmlHttp");
	}
	else if (window.xmlHttpRequest) {
		xmlHttpDownload = new xmlHttpRequest();                
	}
}

function verifyCreditPoint(brId,fileName,downloadCost){
	var url = "resourceDownload/"+brId+"/"+fileName+"/"+downloadCost+"?_method=verifyCreditPoint";
	//var url = "resourceDownload/"+brId+"/"+escape(fileName)+"/"+downloadCost+"?_method=verifyCreditPoint&t="+(new Date().getTime());
	//var url = "resourceDownload?_method=verifyCreditPoint";
	total_brId = brId;
	total_fileName = fileName;
	total_downloadCost = downloadCost;
	createxmlHttpDownloadRequest();
	if(xmlHttpDownload){
		xmlHttpDownload.open("get",url,true);
		xmlHttpDownload.setRequestHeader("Accept","text/html");
		xmlHttpDownload.onreadystatechange = completeDownload;
		xmlHttpDownload.send(null);
	}	
}

function completeDownload(){
	if(xmlHttpDownload.readyState == 4){
		if(xmlHttpDownload.status == 200){
			returnMessageDownload();
		}else if(xmlHttpDownload.status == 204){
			alert("204");	
		}
	}
}

function returnMessageDownload(){
	alert(xmlHttpDownload.responseText);
	if(xmlHttpDownload.responseText == 0){
		alert("积分不足");
	}else if(xmlHttpDownload.responseText == 2){
		alert("未登录");
	}else if(xmlHttpDownload.responseText == 1){
		//var url = "resourceDownload/"+total_brId + "/" + total_fileName + "/" + total_downloadCost+"?_method=downFile";
		//window.location = url;
		alert("测试");
	}
}

