/*
document.observe("dom:loaded", function() {
	Event.observe(window, 'load', function() {
*/

		if ($('Rechtsform')){
	  		Event.observe('Rechtsform', 'change', function(event){
				var rechtsform = $('Rechtsform').getValue();
				var url = '/konto_und_depot/kundewerden/getbranchen';
				var pars = 'rechtsform=' + rechtsform;
				var myAjax = new Ajax.Request(
					url,
					{
						method:'post',
						parameters: pars,
						onSuccess: function(transport){
							var json = transport.responseText.evalJSON(true);
							CleanBranchen();
							for(var i=0; i<json.branchen.length;i++) {
								var label = json.branchen[i].label;
								var value = json.branchen[i].value;
								AddBranche(value, label);
							}
					}
				});
	  		});
  		}

		$A(document.getElementsByTagName("a")).each(function(link) {
		        if((window.location.hostname+window.location.pathname).replace(/\//g,"") != (link.hostname+link.pathname).replace(/\//g,"")
		           && $(link).rel ==''
		           && $(link).target!='_blank'
		           && link.href.indexOf('javascript')
		           )
		        {   $(link).observe('mouseover', function(event){
		                if ($("abort_button")){
		                	$("abort_button").href=link.href;
		                }
		                if ($("abortOverlay")){
			                Event.element(event).onclick = new Function(
			                    '$("abortOverlay").setStyle({display:"block"});$("abortWindow").setStyle({display:"block"});return false;'
			                );
		                }
		            });
		        }
		  });

		$A(document.getElementsByTagName("input")).each(function(link) {
			$(link).observe('mouseover', function(event){
				Event.element(event).onclick = new Function(
					'window.onbeforeunload = null;'
				);
			});
		});

/*
  	});
});
*/



function CleanBranchen()
{
	$('Branche')
		.update()
			.insert(
				new Element('option', {selected:'selected', value:'', label:'---------------- Bitte wählen ----------------'})
					.insert('---------------- Bitte wählen ----------------')
				);
}

function AddBranche(value, label)
{
	$('Branche')
			.insert(
				new Element('option', {value:value, label:label})
					.insert(label)
				);
}
if (null != $('tabs_example_one')){
	new Control.Tabs('tabs_example_one');
}


if (null != $('Geburtsdatum')){
	Event.observe('Geburtsdatum', 'blur', function(event) {
	    var geburtsdatum = $('Geburtsdatum').value;
		geburtsdatum = geburtsdatum.replace(/[-,\/]/g, ".");
		$('Geburtsdatum').setValue(geburtsdatum);
	});
	Event.observe('Wohnhaft', 'blur', function(event) {
	    var wohnhaft = $('Wohnhaft').value;
		wohnhaft = wohnhaft.replace(/[-,\/]/g, ".");
		$('Wohnhaft').setValue(wohnhaft);
	});
}


