var eform="";
var eadresse1="";
var eadresse2="";
var eadresse3="";
var ecode_postal="";
var eville="";
function checkAdresse(form,pays,adresse1,adresse2,adresse3,code_postal,ville){

	eform = form;
	eadresse1 = adresse1;
	eadresse2 = adresse2;
	eadresse3 = adresse3;
	ecode_postal = code_postal;
	eville = ville;
	

	var tsElementsHTML = $$('html');
	
	//for(var i=0,x=tsElementsHTML.length;i<x;i++){tsElementsHTML[i].setStyle('overflow', 'hidden');}

	$ShowFilter();
	if( !$('popup') ){$CreatePopup();}else{$HidePopup();}
	
	url = "/index2.php?option=com_qas&no_html=1&task=search&country="+pays;
	argsGet = new Array();

	url +="&asUserInput[]="+adresse3.value;
	url +="&asUserInput[]="+adresse2.value;
	url +="&asUserInput[]="+adresse1.value;
	url +="&asUserInput[]="+code_postal.value;
	url +="&asUserInput[]="+ville.value;
	
	$CreateLoader();
	var myAjax = new Ajax(url, {
			method: 'get',
		
			onFailure:$HideAll,
			onComplete:function(text,html){

				if(text!="")
					Message(text);
				else{
					$HideAll;					
					form.submit();
				}
			}
		}
	);
	myAjax.request();
	$HideAll();

}

function changeSelectAdresse(selectname){
	elinpts = $$("select").filterByAttribute("name","=",selectname);
	if(elinpts.length==1){
		moniker = elinpts[0].options[elinpts[0].selectedIndex].value;
		url = "/index2.php?option=com_qas&no_html=1&task=getformatadress&moniker="+moniker;
		var myAjax = new Ajax(url, {
			method: 'get',
			onComplete:function(text,html){
					val = text;
					if($chk(val) && val !=""){
						tabval = val.split("|");
						changeAdresse(tabval);

						eform.submit();
					}
				}
			}
		);
		myAjax.request();
	}
}

function changeInputAdresse(inputname){
	elinpts = $$("input").filterByAttribute("name","=",inputname);
	if(elinpts.length==1){
		val = elinpts[0].value;
		if($chk(val) && val !=""){
			tabval = val.split("|");
			changeAdresse(tabval);
		}
	}
}
			
function changeAdresse(tabval){
	if(tabval.length >5){
		eadresse3.value = tabval[0];
		eadresse2.value = tabval[1];
		eadresse1.value = tabval[2];							
		ecode_postal.value = tabval[3];
		eville.value = tabval[4];
	}
}
