var timeoutVar;

	function clsTimeout(){
		clearTimeout(timeoutVar);
	}

function doDownload(id){
	$.post(
		'/js.func.php', 
		{ getdl:id }, 
		function(data){ 
			switch(data){
				case "errid":
					$("#btn").html("File ID error.");
					break;
				case "errnotfile":
					$("#btn").html("File does not exist.");
					break;
				default:
					var url;
					url = "/get/"+id+"/"+data+"/";
					$("#btn").html("Starting in 5 seconds... or <a href='"+url+"' onclick='location.href=\""+url+"\"; clsTimeout(); return false;'>Click here.</a>");
					timedRefresh(url, 5000);
					break;
			}
		}
	);



	function timedRefresh(url, timeoutPeriod) {
		timeoutVar = setTimeout("location.href='"+url+"';",timeoutPeriod);
	}
}

