function checkData(cData, cType, el){
		var myRequest = new Request({
			method: 'post',
			url: '/global/registrieren/' + cType,
			onRequest: function() {
				$(cType + '_reg-load').setStyle('display', 'inline');				
			},
			onSuccess: function(res){
				if($(cType + '_message')) $(cType + '_message').hide();
				if($(cType + '_warn')) $(cType + '_warn').hide();
				$(cType + '_reg-load').hide();
				el.removeClass('ipt-error');
				
				if (res == 1) {
					// ok
					el.setStyle('background-color', '#D1EFC2');
				}
				else if(res == 2) {
					// nur WARNING
					el.setStyle('background-color', '#D1EFC2');
					if($(cType + '_warn')) {
						$(cType + '_warn').show();
					}					
				}
				else if(res == 3) {
					if(!$('inp_email_re')) {
						return;
					}
					// email wiederholen
					el.setStyle('background-color', '#D1EFC2');
					$('inp_email_re').show();
					try {
						// ie kann das nicht...
						$('email_re').focus.delay(100, $('email_re'));
					}
					catch(e) {
						$('email_re').focus();
					}
					$('force_email_re').set('value', 1);
				}
				else {
					// FEHLER
					$('info_name').hide();
					if($(cType + '_message')) {
						if(res != '') {
							$(cType + '_message').show();
						}
						$(cType + '_message').set('html', res);
					}
					el.addClass('ipt-error');
					el.setStyle('background-color', '#F7E5E5');
				}				
			}
		}).send(cType + '=' + encodeURIComponent(cData));	
}

function searchRegionByZip(code) {
	if(code.length < 3) {
		return false;
	}
	var request = new Request.JSON({
		'url': '/global/zipcodes/code,' + code,
		'onSuccess': function(regions) {
			if(regions.length > 0) {
				var node = $('register_city');
				node.empty();
			}
			$('register_city').getChildren().dispose();
			$('region_info').hide();
			for(var i=0; i<regions.length; i++) {
				
				/*if(regions.length == 1) {
					var p = new Element('p', {
						'text': regions[i].city
					});
					node.getParent().appendChild(p);
				}*/
				//else { 
					var option = new Element('option', {
						'text': regions[i].city
					});
					node.appendChild(option);
				//}
				if(!regions[i].region_name || regions[i].region_id == 3 || regions[i].region_id == 30 || regions[i].region_id == 47) {
					$('region_info').hide();
					$('region_manual_info').show();
				}
				else {
					$('region_manual_info').hide();
					$('region_manual').selectedIndex = 0;
					$('region_info').show();
				}
				$('register_region').set('text', regions[i].region_name);
				$('tou').href = '/global/nutzungsbedingungen/mandant,'+regions[i].mandator_id;
				$('secure').href = '/global/nutzungsbedingungen/mandant,'+regions[i].mandator_id+'#datenschutz';
			}
			
			if(regions.length == 0) {
				var node = $('register_city');
				var option = new Element('option', {
					'text': 'PLZ ist nicht hinterlegt'
				});
				node.appendChild(option);
				$('tou').href = '/global/nutzungsbedingungen/mandant,'+globalMandator;
				$('secure').href = '/global/nutzungsbedingungen/mandant,'+globalMandator+'#datenschutz';
			}
		}
	}).get(null);
}

function updateText(text, el, offset) {
	if(el.value.length > 0) {
		return;
	}
	if(!offset) {
		offset = 33;
	}
	$('info_name_text').set('html', text);
	$('info_name').show();
	$('info_name').setStyle('top', el.offsetTop.toInt() + offset + 'px');
	$('info_name').setStyle('left', el.offsetLeft);
	$(el).addEvent('blur', function(){ $('info_name').hide(); });
}

function showCaptcha() {
	if($('captcha_cont').displayed()) {
		return;
	}
	/*$$('.strengthMeter ').hide();
	$('global_registration').getElements('input[type=text]').tween('width', '145px').getParent('div').tween('width', '170px');
	$('global_registration').getElements('input[type=password]').tween('width', '145px').getParent('div').tween('width', '170px');
	$$('.reg-load').setStyle('width', '25px'); 
	$('global_registration').getElements('p.error').tween('width', '139px'); 
	$('info_name').setStyle('width', '145px');
	$('info_name_text').setStyle('width', '125px');*/
	
	$('captcha_cont').show();
	$('captcha_cont').tween('height', '130px');
}

function checkReEmail(or, re) {
	m = $('email_re_message');
	if(or.value == re.value) {
		re.getParent('div').dispose();
		m.hide();
	}
	else if(re.value.length == or.value.length) {
		m.show();
		m.set('text', 'Die E-Mail Adressen stimmen nicht überein!');
		re.setStyle('background-color', '#F7E5E5');
	}	
}

function checkPwd(input1, input2) {

	if(input1.value == '') {
		return false;
	}

	if(input1.value.length < 4) {
		return false;
	}

	if(input1.value.length < 6) {
		input1.setStyle('background-color', '#F7E5E5');
		$('pwd1_message').show();
		$('pwd1_message').set('html', 'Das Passwort muss mind. 6 Zeichen lang sein');
		return false;
	}

	$('pwd1_message').hide();
	input1.setStyle('background-color', '#D1EFC2');
	
	if(input2.value.length < 1) {
		return false;
	}
	
	if(input1.value != input2.value) {
		input2.setStyle('background-color', '#F7E5E5');
		if(input2.value.length >= input1.value.length) {
			$('pwd2_message').show();
			$('pwd2_message').set('html', 'Die Passw&ouml;rter stimmen nicht &uuml;berein');
		}
		return false;
	}
	
	if(input2.value.length == input1.value.length) {
		showCaptcha();
	}
	
	$('pwd1_message').hide();
	$('pwd2_message').hide();	
	input2.setStyle('background-color', '#D1EFC2');

}

window.addEvent('domready', function() {
	/*var myTips = new Tips('.tooltip', {
		className: 'eToolTip',
		hideDelay: 300
	});*/
});
