function incarcaMulte (raspuns, multe) {
	a=multe.split('.');
	for (i=0;i<=a.length-2;i=i+2) {
		el=$(a[i]);
		if (el==null) el=$('foo');
		if (el!=null) { 
			if (typeof(el)=='string') el=$(el);
		}
		switch (a[i+1]) {
			case 's':	
				el.options[index].selected=true;
				break;
			case 'v':
				el.value=raspuns;
				break;
			case 'src' :
				el.src=raspuns;
				break;
			case 't':
				el.innerText=raspuns;
				break;
			case 'h':
				el.innerHTML=raspuns;
				break;
			case 'a':
				el.action=raspuns;
				break;	
			default:
				el.innerHTML=responseTxt;	
		}								
	}
}

function incarca (url, el,multe,asinc,ev) {
	var aj= new ajaxObject(url,incarca,asinc);
	if (el==null) el=$('foo');
	if (el!=null) { 
		if (typeof(el)=='string') el=$(el);
	}
	aj.callback=function (responseTxt, responseStat) { 
		if (multe!=null) {
			incarcaMulte (responseTxt, multe)
		}
		else {
			if (el!=null) {			
    			switch (el.tagName) {
    				case 'FORM':
    					el.action=responseTxt;
    					break;
    				case 'INPUT':
    					el.value=responseTxt;
    					break;
    				case 'DIV':
    					el.innerHTML=responseTxt;
    					break;
    				case 'SPAN':
    					el.innerHTML=responseTxt;
    					break;
    				case 'TEXTAREA ':
    					el.innerHTML=responseTxt;
    					break;
    				case 'n':
    					break;
    				default:
    					el.innerHTML=responseTxt;
    					break;
    			}
        
			}
		}
	}     
	aj.update(''); 
} 

function incarcaval (url, el,asinc) {
	var aj= new ajaxObject(url,incarca,asinc);
	if (el!=null) { 
		if (typeof(el)=='string') el=$(el);
	}
	aj.callback=function (responseTxt, responseStat) { 
		el.value=responseTxt;
	}     
	aj.update(''); 
} 

function incarcavarPost (form,url,variabila) {
	var aj= new ajaxObject(url,incarcavarPost,false);
	aj.callback=function (responseTxt, responseStat) { 
		variabila.value=responseTxt;
	}
	param='';
	if (typeof(arguments[4])!='undefined') param=arguments[4];  
	aj.update($f(form)+param,'POST'); 
} 

function incarcavar (url,variabila) {
	var aj= new ajaxObject(url,incarcavar,false);
	aj.callback=function (responseTxt, responseStat) { 
		variabila.value=responseTxt;
	}     
	aj.update(''); 
} 

function navConfirm (url,confirmare,el,asinc) {
	var raspuns=confirm(confirmare);
	if (raspuns) {
		var aj= new ajaxObject(url,navConfirm,asinc);
		aj.callback=function (responseTxt, responseStat) { 
			if (responseTxt.indexOf('eroare')>=0) alert(responseTxt);
			if (el!=null && el!='n') { 
				if (typeof(el)=='string') el=$(el);
				el.innerHTML=responseTxt;
			}
		}     
		aj.update(''); 
	}
} 

function trimitePost (form,url,el,asinc) {
	var aj= new ajaxObject(url,trimitePost,asinc);
	aj.callback=function (responseTxt, responseStat) { 
		if (responseTxt.indexOf('eroare')>=0) alert(responseTxt);
		if (el==null && el!='n') el=$('foo');
		if (el!=null && el!='n') { 
			if (typeof(el)=='string') el=$(el);
		}					
		if (el!=null && el!='n') { 
			switch (el.tagName) {
				case 'FORM':
					el.action=responseTxt;
					break;
				case 'INPUT':
					el.value=responseTxt;
					break;
				case 'DIV':
					el.innerHTML=responseTxt;
					break;
				case 'SPAN':
					el.innerHTML=responseTxt;
					break
				case 'TEXTAREA ':
					el.innerHTML=responseTxt;
					break;
				case 'IFRAME':
					el.contentWindow.document.body.innerHTML='';
					el.contentWindow.document.write(responseTxt);
					break;
				default:
					el.innerHTML=responseTxt;
					break;
			}
      
		}
      
	}
	param='';
	if (typeof(arguments[4])!='undefined') param=arguments[4];  
	aj.update($f(form)+param,'POST'); 
} 

//if ("onhashchange" in window) window.onhashchange= function (){navigare();}



function navigare(){
	if(window.location.hash.length > 1 && window.location.toString().indexOf('admin')>0)
		incarca(window.location.hash.replace('#',''));	
	else {  
      //window.location='index.php';
  }  
}


