/**
 *
 * @access public
 * @return void
 **/
function DownloadManager(name){
	this.name            = name;
	this.xmlHttp         = null;

	this.init=function(){
		this.xmlHttp=this.getXmlHttpObject();
	}

	this.download=function(tbl,id){
		var psw=prompt('Adja meg a fájlhoz tartozó jelszót!','');
		if(psw){
			var url='inc/download.php?tbl='+tbl+'&id='+id+'&psw='+psw+'&rnd='+Math.random();

			this.xmlHttp.onreadystatechange=function(){
				if(this.readyState==4){
					if(this.responseText!='0') window.location.href=this.responseText;
					else alert('A kiszolgáló nem fogadta el a jelszót!');
				}
			}
			this.xmlHttp.open("GET",url,true);
			this.xmlHttp.send(null);
		}
	}

	this.getXmlHttpObject=function(){
		var xmlHttp=null;
		try { xmlHttp=new XMLHttpRequest(); }
		catch (e) {
			try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
		}
		return xmlHttp;
	}

	this.isIE=function(){
		return (this.strpos(navigator.userAgent.toLowerCase(),"msie",0)>0);
	}

	this.strpos=function( haystack, needle, offset){
	    var i = haystack.indexOf( needle, offset ); // returns -1
	    return i >= 0 ? i : false;
	}

	this.addInit=function(name) {
	    var oldQueue = window.onload? window.onload: function() {};
	    window.onload = function() {
	    	eval(name+".init()");
	        oldQueue();
	    }
	}

	this.addInit(this.name);
}