function deactivate(){
	var counter = 0;
	
	if($('HANDNESS_ID').value > 0)	counter++;
	if($('BIRTHRANK_ID').value > 0)	counter++;
	if($('BLOODGROUP_ID').value > 0)	counter++;
	if($('FATHER_HANDNESS_ID').value > 0)	counter++;
	if($('FATHER_BIRTHRANK_ID').value > 0)	counter++;
	if($('FATHER_BLOODGROUP_ID').value > 0)	counter++;
	if($('MOTHER_HANDNESS_ID').value > 0)	counter++;
	if($('MOTHER_BIRTHRANK_ID').value > 0)	counter++;
	if($('MOTHER_BLOODGROUP_ID').value > 0)	counter++;
	
	if(counter >= 3){
		if($('HANDNESS_ID').value == -1)	$('HANDNESS_ID').disable();
		if($('BIRTHRANK_ID').value == -1)	$('BIRTHRANK_ID').disable();
		if($('BLOODGROUP_ID').value == -1)	$('BLOODGROUP_ID').disable();
		if($('FATHER_HANDNESS_ID').value == -1)	$('FATHER_HANDNESS_ID').disable();
		if($('FATHER_BIRTHRANK_ID').value == -1)	$('FATHER_BIRTHRANK_ID').disable();
		if($('FATHER_BLOODGROUP_ID').value == -1)	$('FATHER_BLOODGROUP_ID').disable();
		if($('MOTHER_HANDNESS_ID').value == -1)	$('MOTHER_HANDNESS_ID').disable();
		if($('MOTHER_BIRTHRANK_ID').value == -1)	$('MOTHER_BIRTHRANK_ID').disable();
		if($('MOTHER_BLOODGROUP_ID').value == -1)	$('MOTHER_BLOODGROUP_ID').disable();
	}
	
	if (counter < 3) {
		$('HANDNESS_ID').enable();
		$('BIRTHRANK_ID').enable();
		$('BLOODGROUP_ID').enable();
		$('FATHER_HANDNESS_ID').enable();
		$('FATHER_BIRTHRANK_ID').enable();
		$('FATHER_BLOODGROUP_ID').enable();
		$('MOTHER_HANDNESS_ID').enable();
		$('MOTHER_BIRTHRANK_ID').enable();
		$('MOTHER_BLOODGROUP_ID').enable();
  }
}

function getStatistic(){
	var high = Element.getHeight(document.body);
	if(high < window.innerHeight) high = window.innerHeight;
	this.overlay = new Element("div", {id: "overlay",style: "height:"+ high });
	this.infobox = new Element("div", {id: "infobox",style: "display: none"})

	// Inserting into DOM. If parameter set and form element have been found will inject into it. 
	// Otherwise will inject into body as topmost element.
	// Be sure to set padding and marging to null via CSS for both body and (in case of asp.net) form elements. 
	var injectToEl = $(document.body);
	injectToEl.insert({'top':this.infobox});
	injectToEl.insert({'top':this.overlay});

	$(this.infobox).setStyle({left: Math.round((Element.getWidth(document.body) - Element.getWidth(this.infobox)) / 2 ) + "px"});
	$(this.infobox).setStyle({top: Math.round((document.body.clientHeight - Element.getHeight(this.infobox)) / 2 ) + "px"});
	$(this.infobox).update('Updating Data!<br><br><img src="images/loading_white.gif">');

	new Effect.Fade(this.overlay, {
		from: 0, 
		to: 0.65, 
		duration: 0.4,
		afterFinish: function(){
	  	$(this.infobox).show();
	  }.bind(this)
		});
		
	$('statistic').request({
		onComplete: function(oReq, oJSN){
			var response = oReq.responseText.evalJSON();
			if(response.sql[0] == 'FALSE'){
				$(this.infobox).update(response.sql[2]+'<br><br><input type="button" onclick="closeBox()" value="OK" />');
			}else{
				$(this.infobox).update(response.sql[1]+'% der Twinsearcher-User entsprechen Deiner Auswahl!<br><br><br><input type="button" onclick="closeBox()" value="OK" />');
			}
		},
		onFailure: function(){ $(this.infobox).update('Fehler bei Ajax Request') }		
	})
		
}

function closeBox(){
	$(this.infobox).hide();
	Effect.toggle(this.overlay, 'appear', {
		duration: 0.25,
		afterFinish: function(){
			// $(this.overlay).remove();
			// $(this.infobox).remove();
		}
	});
}

