var RegistrationByICO = {
	find: function(ico) {
		var l = document.getElementById('RegistrationByICO_loading');
		if (l) l.style.display = 'block';
		var captcha = document.getElementById('RegistrationByICO_captcha').value;
		if(window.XMLHttpRequest) this.response = new XMLHttpRequest();
		else if(window.ActiveXObject) {
			try { this.response = new ActiveXObject("Msxml2.XMLHTTP"); } 
			catch(e) { this.response = new ActiveXObject("Microsoft.XMLHTTP"); }
		}
		this.response.onreadystatechange = function() { RegistrationByICO.receive(); };		
		this.response.open('GET', '/_Actions/RegistrationByICO/?ico='+ico+'&captcha-ico='+captcha, true);
		this.response.send(null);
	},
	receive: function () {
		var response=RegistrationByICO.response;
		if(response.readyState == 4) {
			if(response.status == 200) {
				var rs = eval('(' + response.responseText + ')');
				if (rs.actionResultStatus==1) {
					Registration.customerType(1);
					document.getElementById('company').value = rs.result.company;
					document.getElementById('name').value = rs.result.name;
					document.getElementById('ICO').value = rs.result.ICO;
					document.getElementById('street').value = rs.result.street;
					document.getElementById('city').value = rs.result.city;
					document.getElementById('zip').value = rs.result.zip;
				}
				alert(rs.actionResultString);
				var l = document.getElementById('RegistrationByICO_loading');
				if (l) l.style.display = 'none';
			} else {
				alert('Omlouváme se, ale bohužel došlo k chybe pri vykonávání akce.');
			}
		}
	}	
};