function creazaXmlHttp(){
	var xmlHttp;
	if(window.ActiveXObject){
		try{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e){
			xmlHttp = false;
		}
	}
	else{
		try{
			xmlHttp = new XMLHttpRequest();
		}
		catch (e){
			xmlHttp = false;
		}
	}
	if (!xmlHttp) alert("Nu s-a putut crea obiectul XMLHttpRequest .");
	else return xmlHttp;
}

function $id(a){
	var rez;
	try{
		rez=document.getElementById(a);
		return rez;
	}
	catch(e){
		alert('Elementul '+a+' nu poate fi gasit reporniti browserul si incercati din nou');
		return false;
	}
}

var xmainpath='http://www.ugc.ro/ro/images/';
var xmlHttp=creazaXmlHttp();
function Ejax(phpfile,params,divelem){
	if(divelem!=''){
		var xdiv=$id(divelem);
		var dispwait=true;
	}
	else {
		var xdiv='';
		var dispwait=false;
	}
	this.phppath=phpfile;
	var xphp=this.phppath;
	if(params!=''){
		var xparam='?'+params+"&sid="+Math.random();
	}
	else{
		var xparam="?sid="+Math.random();
	}
	this.cerere=function(){
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
			xmlHttp.open("GET", xphp+xparam, true);
				xmlHttp.onreadystatechange = xrez;
				xmlHttp.send(null);
				if(dispwait){
					xdiv.innerHTML= '<img src="'+xmainpath+'wait.gif'+'" width=16 height=16>';
				}
		}
		else{
			if(dispwait){
				xdiv.innerHTML= '<img src="'+xmainpath+'wait.gif'+'" width=16 height=16>';
			}
			
		}
	};
	var xcer=this.cerere;
	this.rezultat=function(){
		if (xmlHttp.readyState == 4){
			if (xmlHttp.status == 200){
				var raspuns = xmlHttp.responseText;
				if(xdiv==''){
					alert(raspuns);
				}
				else{
					xdiv.innerHTML =  raspuns;
				}
			}
			else{
				alert("Problema la accesare: " +xmlHttp.statusText);
			}
		}
		else{
			if(dispwait){
				//xdiv.innerHTML= '<img src="'+xmainpath+'wait.gif'+'" width=16 height=16>';
			}
			
		}
	};
	var xrez=this.rezultat;
	xcer();
	
}

function eurl(v) {
	return encodeURIComponent(v);
}

function verDateReg(t,v,d) {
	var trim='';
	trim+='tip='+t;
	trim+='&val='+eurl(v);
	Ejax('ajax_php/ver_date_formular.php',trim,d);
}
