var data;
var block;
function Ajax_xml(url, cmd)
{
	if(url.length<=0 || cmd.length<=0){
		return false;
	}
	this.url = url;
	this.cmd = cmd;
	this.result = "";
    this.req = null;
	 if (window.XMLHttpRequest) {
			var req = new XMLHttpRequest();
			 if (req.overrideMimeType) {
					 req.overrideMimeType('text/html');
			 }
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
    this.req = req;
	return true;
}

function Ajax_post_xml(url,cmd, fieldValues){
this.output = "NoRecords";
	var x = new Ajax_xml(url,cmd);
	x.popen();	
	try{
	x.req.onreadystatechange = function(){
		if (x.req.readyState==4){
			if(x.req.status==200){
				if(x.req.responseText){
					x.result = escape(x.req.responseText);
					x.getOp();
				}
			}
		}		
	}
	}
	catch(e){}
	x.psend(Ajax_getURI(fieldValues));
	return true;
}

function Ajax(url,cmd){
this.output = "NoRecords";
	var x = new Ajax_xml(url,cmd);
	x.opens();	
	try{
	x.req.onreadystatechange = function(){
		if (x.req.readyState==4){
			if(x.req.status==200){
				if(x.req.responseText){
					x.result = escape(x.req.responseText);
					x.getOp();
				}
			}
		}		
	}
	}
	catch(e){}
	x.sends();

}

Ajax_xml.prototype.opens = function(){
	this.req.open("GET", this.url, true);
}

Ajax_xml.prototype.sends = function(){
	this.req.send(null);
}

Ajax_xml.prototype.popen = function(){
	this.req.open("POST", this.url, true);
}

Ajax_xml.prototype.psend = function(p){
	this.req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	this.req.setRequestHeader("Content-length",p.length); 
	this.req.send(unescape(p));
}

Ajax_xml.prototype.getOp=function(){
	if(arguments.length>1){
		this.cmd = arguments[0];
		alert(this.cmd+"(\""+this.result+"\")");
	}
	eval(this.cmd+"(\""+this.result+"\")");
}


function populatePassword(url, id, field,blk)
	{
		var path = url+'?id='+id + '&field='+ field;	
		//alert(path);
		block=blk;
		Ajax(path,'getPassword');	
	}

function getPassword(data)
	{
		data = unescape(data);	
		//alert(data);
		var obj = document.getElementById(block);
		obj.innerHTML=data;
	}
