function refreshplace(zip,city,county,id)
{ 
	if(zip.length==0 || zip.length==4 ){
		var opts = {
		   method: 'post',
	                // Send this lovely data
	       postBody: "zip="+zip+"&city="+city+"&county="+county,
	                // Handle successful response
	       onSuccess: function(t) {
	       				var place_array=t.responseText.split(";");
						document.getElementById("zip"+id).value=place_array[0];
						document.getElementById("city"+id).value=place_array[1];
						document.getElementById("county"+id).value=place_array[2];
	                },
	                // Handle 404
	                on404: function(t) {
	                        alert('Error 404: location "' + t.statusText + '" was not found.');
	                },
	                // Handle other errors
	                onFailure: function(t) {
	                        alert('Error ' + t.status + ' -- ' + t.statusText);
		
					}
		}
		var url=getAjaxIndexDir("_reg")+"genplace.php"
		new Ajax.Request(url, opts);
	}
}

//function addressmanager_add(name,zip,city,county,address,id)
function addressmanager_add(name,zip,city,county,address,addresstype1,addresstype2)
{ 		type="";
		if(addresstype1.checked) type+="&addresstype[]="+addresstype1.value;
		if(addresstype2.checked) type+="&addresstype[]="+addresstype2.value;
		if(name=='' || zip=='' || city=='' || county=='' || address=='')
		{
			alert('Mindent ki kell tölteni');
		}
		else{
		name=name.replace(/õ/g,'o=').replace(/û/g,'u=').replace(/Õ/g,'O=').replace(/Û/g,'U=');
		address=address.replace(/õ/g,'o=').replace(/û/g,'u=').replace(/Õ/g,'O=').replace(/Û/g,'U=');
			var opts = {
			   method: 'post',
		                // Send this lovely data
		       postBody: "method=add&name="+name+"&address="+address+"&city="+city+"&zip="+zip+type,
//		       			str,
		                // Handle successful response
		       onSuccess: refresh_selector,
//function(t) {
//		       alert(t.responseText);
	//				document.getElementById("address_page"+id).innerHTML=t.responseText;
//		                },
		                // Handle 404
		                on404: function(t) {
		                        alert('Error 404: location "' + t.statusText + '" was not found.');
		                },
		                // Handle other errors
		                onFailure: function(t) {
		                        alert('Error ' + t.status + ' -- ' + t.statusText);
			
						}
			}
			var url=getAjaxIndexDir("_reg")+"addressmanager.php?show=1"
//			new Ajax.Request(url, opts);
			new Ajax.Updater('editor',url, opts);
			
		refresh_selector();

		}
}

function addressmanager_del(id,typeid)
{ 
		var opts = {
		   method: 'post',
	                // Send this lovely data
	       postBody: "method=del&id="+id+"&type_id="+typeid,
	                // Handle successful response
	       onSuccess: refresh_selector,
	                on404: function(t) {
	                        alert('Error 404: location "' + t.statusText + '" was not found.');
	                },
	                // Handle other errors
	                onFailure: function(t) {
	                        alert('Error ' + t.status + ' -- ' + t.statusText);
		
					}
		}
		var url=getAjaxIndexDir("_reg")+"addressmanager.php?show=1"
//		new Ajax.Request(url, opts);
		new Ajax.Updater('editor',url, opts);
	

}


function refresh_selector(){
			var opts = {
		        method: 'post',
			postBody:'action=refresh_selector',
		        onSuccess: function(t) { 
//			alert(t.responseText);
			    },
		        on404: function(t) {
		                alert('Error 404: location "' + t.statusText + '" was not found.');
			    },
		        onFailure: function(t) {
		                alert('Error ' + t.status + ' -- ' + t.statusText);
    			    }
	    		}
			var url=getAjaxIndexDir()+'cart_checkout_ajax.php';
//			alert(url)
//			new Ajax.Request(url, opts);
		        new Ajax.Updater('selector', url, opts);

}


function clear_div_now(id){
		var opts = {
		   method: 'post',
	       postBody: "id="+id,
	       onSuccess: function(t) {
//						alert(t.responseText)
			document.getElementById("addr_mod"+id).innerHTML=t.responseText;
	                },
	                on404: function(t) {
	                        alert('Error 404: location "' + t.statusText + '" was not found.');
	                },
	                onFailure: function(t) {
	                        alert('Error ' + t.status + ' -- ' + t.statusText);
		
					}
		}
		var url=getAjaxIndexDir("_reg")+"addressmanager.php"
		new Ajax.Request(url, opts);


	
}

function addr_editor_show(divname){

//alert(document.getElementById('fifthrow').innerHTML)
	var opts = {
		   method: 'post',
	       onSuccess: function(t) {
//	       alert(t.responseText)
			document.getElementById(divname).innerHTML=t.responseText;

           },
           on404: function(t) {
                  alert('Error 404: location "' + t.statusText + '" was not found.');
           },
           onFailure: function(t) {
                  alert('Error ' + t.status + ' -- ' + t.statusText);
           }
		}
		var url=getAjaxIndexDir("_reg")+"addressmanager.php?show=1"
//		new Ajax.Updater(divname, url, opts);
		new Ajax.Request(url, opts);

}

function addr_editor_hide(divname){
		var opts = {
		   method: 'post',
	       onSuccess: function(t) {
	                },
           on404: function(t) {
           	alert('Error 404: location "' + t.statusText + '" was not found.');
           },
           onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		   }
		}
		var url=getAjaxIndexDir("_reg")+"addressmanager.php"
		new Ajax.Updater(divname, url, opts);
}


