//
//
//
//


var countryAustria = '17360';
var countryAustriaDupl = '101';
var countrySwiss = '17420';
var countrySwissDupl = '102';
var countryGermany = '17110';
var countryGermanyDupl = '100';
var countrySpain = '17450';
var countrySpainDupl = '110';
var countryItaly = '17220';
var countryItalyDupl = '120';
var countryNetherlands = '17340';
var countryNetherlandsDupl = '140';
var countryBelgium = '17030';
var countryBelgiumDupl = '150';
var countryFrance = '17140';
var countryFranceDupl = '130';

function isNumber(str) {
  for(var position=0; position<str.length; position++){
	var chr = str.charAt(position);
    if  ( (chr < "0") || (chr > "9") ) {
    	return false;
    }
  }      
  return true;
}

var myOnDomReady=[];
function doOnDomReady(){
	try{
		for(aa in myOnDomReady){
			var a = myOnDomReady[aa] || "";
			eval(aa+"("+a+")");
		}
	}catch(error){
		//alert('error in function doOnDomReady(): '+error);
	}
}


var myOnload=[];
function doOnloads(e){
	if(!e)e=window.event;
	if(typeof tmpOnload == 'function'){
		var windowOnloadRegExp=/^function ([^\(]*)/i;
		if(windowOnloadRegExp.test(tmpOnload.toString())){
			var regExpResult=windowOnloadRegExp.exec(tmpOnload.toString());
			if(regExpResult.length > 1){
				if(regExpResult[1]=='anonymous' || regExpResult[1]==''){
					tmpOnload(e);
				}else myOnload[''+regExpResult[1]]=null;
			}
		}
	}
	try{
		for(aa in myOnload){
			var a = myOnload[aa] || "";
			eval(aa+"("+a+")");
		}
	}catch(error){
		//alert('error in function doOnloads(): '+error);
	}
}

var myOnunload=[];
function doOnunloads(e){
	if(!e)e=window.event;
	if(typeof tmpOnunload == 'function'){
		var windowOnunloadRegExp=/^function ([^\(]*)/i;
		if(windowOnunloadRegExp.test(tmpOnunload.toString())){
			var regExpResult=windowOnunloadRegExp.exec(tmpOnunload.toString());
			if(regExpResult.length > 1){
				if(regExpResult[1]=='anonymous' || regExpResult[1]==''){
					tmpOnunload(e);
				}else myOnunload[''+regExpResult[1]]=null;
			}
		}
	}
	try{
		for(aa in myOnunload){
			var a = myOnunload[aa] || "";
			eval(aa+"("+a+")");
		}
	}catch(error){
		//alert('error in function doOnunloads('+myOnunload.toString()+'): '+error);
	}
}

function getStyle(_e, _style){
	var e = typeof _e == "string"?document.getElementById(_e):_e;var value = e.style[_style];
    if (!value){
		if (document.defaultView && document.defaultView.getComputedStyle){var css = document.defaultView.getComputedStyle(e, null);value = css ? css[_style] : null;
		}else if (e.currentStyle){value = e.currentStyle[_style];}
	}return value;
}

function getDimensions(_e) {
    var e=typeof _e=="string"?document.getElementById(_e):_e;var d = getStyle(e, 'display');
    if (d != 'none' && d != null)return {width: e.offsetWidth, height: e.offsetHeight};
    var _style = e.style;
    var oVisibility = _style.visibility;var oPosition = _style.position;var oDisplay = _style.display;
    _style.visibility = 'hidden';_style.position = 'absolute';_style.display = 'block';
    var oWidth = e.clientWidth;var oHeight = e.clientHeight;
    _style.display = oDisplay;_style.position = oPosition;_style.visibility = oVisibility;
    return {width: oWidth, height: oHeight};
}

function returnCuttedText(_txt, _testContainerId, _width, _cutted){
	if(_txt !== ""){
		_cutted = _cutted || false;
		document.getElementById(_testContainerId).style.width='auto';
		document.getElementById(_testContainerId).innerHTML=_txt;
		if(parseInt(getDimensions(_testContainerId).width) >= _width){
			return (_txt.length > 1)?returnCuttedText(_txt.substring(0,_txt.length-1), _testContainerId, _width, true):"";
		}else{
			if(_cutted){
				document.getElementById(_testContainerId).innerHTML+="...";
				return (parseInt(getDimensions(_testContainerId).width,10) >= _width)?((_txt.length > 1)?returnCuttedText(_txt.substring(0,_txt.length-1), _testContainerId, _width, true):""):_txt+'...';
			}else return _txt;
		}
	}
	return "";
}

function appendClassName(obj, cName){
	obj.className=obj.className.replace(eval('/'+cName+'/'),'');
	obj.className+=' '+cName;
	obj.className=obj.className.replace(/[ ]{2}/,' ');
	obj.className=obj.className.replace(/^[ ]?/,'');
}

function sliceClassName(obj, cName){
	if(obj.className.indexOf(' '+cName)!=-1 || obj.className.indexOf(cName+' ')!=-1 || obj.className==cName)
	{
		obj.className=obj.className.replace(eval('/'+cName+'/'),'');
		obj.className=obj.className.replace(/[ ]{2}/,' ');
		obj.className=obj.className.replace(/^[ ]?/,'');
	}
}

function replaceClassName(obj, cName1, cName2){
	obj.className=obj.className.replace(eval('/'+cName1+'/'),cName2);
}

function trim(s){
	while(s.substring(0,1) == ' '){s = s.substring(1,s.length);}
	while(s.substring(s.length-1,s.length) == ' '){s = s.substring(0,s.length-1);}
	return s;
}

var p;
var pcount=0;
function popup4(_href){
	var winWidth=480;
	p=window.open(_href,'popup'+pcount,'resizable=no,scrollbars=yes,menubar=no,toolbar=no,width='+winWidth+',height=50,top=50,left=50')
	p.opener=self;
	p.focus();
	pcount++;
}
function popup5(_href){
	var winWidth=316;
	p=window.open(_href,'popup'+pcount,'resizable=no,scrollbars=yes,menubar=no,toolbar=no,width='+winWidth+',height=50,top=50,left=50')
	p.opener=self;
	p.focus();
	pcount++;
}

function overlay1(_href){
	overlayLoad(_href);
}

function agbprintpopup(_href){
	var winWidth=583+5+5+20;
	var p=window.open(_href,'popup'+pcount,'resizable=yes,scrollbars=yes,menubar=no,toolbar=no,width='+winWidth+',height=250,top=0,left=0')
	p.focus();
	pcount++;
}

function agbPDFPopup(){
var _href='http://i.friendscout24.de/datingr5/img/rps/1/9/5/5/1.pdf';
	var winWidth=583+5+5+20;
	var p=window.open(_href,null)
	p.focus();
}

function goToAGB(){
	document.location.href='/agb.html';
}
function goToAboutUs(){
	document.location.href='/aboutus.html';
}

function zipHelperPopUp(){
	var p=window.open("/searchZipHelperPopUp",'popup'+pcount,'resizable=yes,scrollbars=yes,menubar=no,toolbar=no,width=430,height=300,top=50,left=50')
	p.focus();
	pcount++;
}

function popupInfotour(){
	var p=window.open('/infotour.html','infotourpopup','width=710,height=630,resizable=no');
	p.window.focus();
}

function popupRedirect(){
	//
	//
		document.location.href='/registration.html';
	//
}
 
function sizeWin()
{
	if(arguments.length>0){/* hier noch beim Call von StdOverlayPage das sizeWin mit einem Parameter versehen! */
		var innerContentHeight = getDimensions(document.body).height;
		var innerContentWidth = parseInt(getDimensions(document.getElementById('content2')).width);

		var newHeight = (innerContentHeight<=590)?innerContentHeight:590;
		var newWidth = innerContentWidth;

		if(innerContentHeight > 590){
			parent.overlayResize(newWidth+17, newHeight, newWidth);
		}else{
			parent.overlayResize(newWidth, newHeight+2);
		}
	}else{
		try{
			var maxHeight = document.getElementById("content2").className=="popupcontentwrapper45"?400:500;
		}catch(e){var maxHeight=500;}
	
		var innerContentHeight = document.body.scrollHeight;
		var innerContentWidth = document.body.scrollWidth;
		var initialWindowHeight = self.innerHeight;
		
		if(!self.innerHeight || self.innerHeight == 'undefined'){ 
			initialWindowHeight = (1*document.documentElement.clientHeight > 0)?document.documentElement.clientHeight:document.body.clientHeight;
		}
		var newHeight=(innerContentHeight-initialWindowHeight < maxHeight)?innerContentHeight-initialWindowHeight:maxHeight;
		
		var oWidth=document.body.scrollWidth-10;
		if(typeof document.getElementById('content2') != 'undefined'){
			var oElement = document.getElementById('content2');
			if( window.getComputedStyle ) {
			  oWidth = window.getComputedStyle(oElement,null).width.replace(/px/,'')*1;
			} else if( oElement.currentStyle ) {
			  oWidth = oElement.currentStyle.width.replace(/px/,'')*1;
			}
		}
	
		if(navigator.appVersion.indexOf("MSIE")==-1){
			if(innerContentHeight-initialWindowHeight>maxHeight || initialWindowHeight > innerContentHeight){
				innerContentWidth-=15;
			}
			var widthFixPx=navigator.userAgent.indexOf("Safari")!=-1?15:0;
			window.resizeBy(oWidth+widthFixPx-innerContentWidth-15, newHeight+3);
		}else{
			window.resizeBy(oWidth+18-innerContentWidth, newHeight-15);
		}
	}
}

/* change boxtablayercontents (explorative search) */
var tabBoxes=[];

function changetab(){
	var obj = arguments[0];
	var func = arguments[1];
	var tabBoxName = arguments[2] || "a";
	var selectedTab = arguments[3] || "0";
	var e = document.getElementById(obj);
	if(e != null) {
		eval('tabBoxes.'+tabBoxName+'=selectedTab');
		for(i=0; i< e.parentNode.childNodes.length; i++){
			e.parentNode.childNodes[i].className='';
		}
		e.className='active';
	}
	if(func != null) {
		eval(func);
	}
	window.focus();
}

function checkAll(f, n, c) {
	for (var i=0; i<f.elements.length;i++) {
		var e=f.elements[i];
		if((e.name==n)&&(e.type=='checkbox')) {
			e.checked=c;
		}
	}
	return false;
}

//
//

function openProfilewin(_id, _mainPageId, _subPageId, _ignoreCount, _sourcePage, _sourceElement, _linkType){top.datacenter.openPrfWin(_id, _mainPageId, _subPageId,_ignoreCount, _sourcePage, _sourceElement, _linkType);}
function openPresswin(){top.datacenter.openPresswin();}
function openHelpwin(){top.datacenter.openHelpwin();}

function openGuestPresswin(){
	var rand=Math.round(Math.random()*9999999999999999);
	var x=window.open('/press.html?rand='+rand, 'press', 'resizable=no,scrollbars=yes,menubar=no,toolbar=no,width=720,height=480,top=0,left=0');
	x.window.focus();
}

/*Link Tracking*/

function globalClick(e) {

	e = e || window.event || null;
	// target return the HTML element the event took place on.
	var target = e.target || e.srcElement || null;

	if(target.nodeName=="IMG" && target.parentNode.nodeName=="A") {
		target=target.parentNode;
	}
	
	/* if an event takes place on an element that contains text, this text node, and not the element
	becomes the target of the event(nodeType is 3 is a text node, if it is we move to its parent node, 
	the HTML element) 	*/
	if(target.nodeType==3){
		target=target.parentNode;
	}
       if(typeof target.rel=="string"){
		if(target.rel.indexOf('trackLink:')!=-1){
			alert("GlobalClick: " + target.rel.substring(10,target.rel.length));
			//linkCode(target,target.ref);
		}
	}

}

/*Link Tracking - Remember to change the linkName!!!!*/
function linkCode(obj,linkId) {

	s.linkTrackVars='prop20';
	s.linkTrackEvents='None';
	s.prop20=linkId;
	s.linkType='o';
	s.linkName='My Test Link';
	var lt=obj.href!=null?s.lt(obj.href):"";
	if (lt=="") { s.tl(obj,s.linkType,s.linkName); }

}


function resizeFE(FEid, EROWid){
/* 
	Due to the boxmodel a width of 100% is wider than the parent node width 
	(boxModel: real element width = margins+border+width+paddings)
	Because of that we must not use a width of 100% but a px-width which is 
	adusted by this function. Just throw in the FEelementId and the erowId.
	
	Only makes sense for inputs like text or textarea
*/
	try{
		var BORDER_MINUS=4;
		var r=document.getElementById(EROWid);
		var paddingMarginMinus=parseInt(getStyle(r,'paddingLeft'))+parseInt(getStyle(r,'paddingRight'))+parseInt(getStyle(r,'marginLeft'))+parseInt(getStyle(r,'marginRight'));
		document.getElementById(FEid).style.width=(parseInt(getStyle(document.getElementById(FEid),'width'))-(BORDER_MINUS+paddingMarginMinus))+"px";
	}catch(e){}
}

function showError(formName, fieldName, errorTxt){
	try{
		appendClassName(document.forms[formName].elements[fieldName],"error");
		appendClassName(document.getElementById(formName+fieldName+"Label"),"error");
		document.getElementById(formName+fieldName+"Error").innerHTML=errorTxt;
		document.getElementById(formName+fieldName+"Error").className="errorvisible";
	}catch(e){}
	if(typeof isoverlaypage != 'undefined'){
		sizeWin("true");
	}
}
function hideError(formName, fieldName){
	try{
		document.getElementById(formName+fieldName+"Error").className="hidden";
		document.getElementById(formName+fieldName+"Error").innerHTML="";
	}catch(e){}
	try{
		sliceClassName(document.forms[formName].elements[fieldName],"error");
		sliceClassName(document.getElementById(formName+fieldName+"Label"),"error");
	}catch(e){}
	if(typeof isoverlaypage != 'undefined'){
		sizeWin("true");
	}
}
function hideErrors(formName){
	//alert(formName);
	var theForm = document.forms[formName];
	for (e=0;e<theForm.elements.length;e++) {
		var fe=theForm.elements[e];
		if(fe.type!='submit' && fe.type!='button' && fe.type!='file') {
			hideError(formName, theForm.elements[e].name);
		}
	}
}
	
function hideFormrow(_formName, _elementName){
	if(document.forms[_formName]){
		var elem = document.forms[_formName].elements[_elementName];
		if(elem){
			while(typeof(elem)=="object" && typeof(elem.tagName)!="undefined"){
				tagname=elem.tagName.toUpperCase();
				if(tagname=="BODY" || tagname=="HTML")break;
				if(elem.className=="formrow"){
					elem.style.display="none";
					break;
				}
				if(typeof elem=="object")elem=elem.parentNode;
			}
		}
	}
}
function showFormrow(_formName, _elementName){
	if(document.forms[_formName]){
		var elem = document.forms[_formName].elements[_elementName];
		if(elem){
			while(typeof(elem)=="object" && typeof(elem.tagName)!="undefined"){
				tagname=elem.tagName.toUpperCase();
				if(tagname=="BODY" || tagname=="HTML")break;
				if(elem.className=="formrow"){
					elem.style.display="block";
					break;
				}
				if(typeof elem=="object")elem=elem.parentNode;
			}
		}
	}
}
function hideFormcolumn(_formName, _elementName){
	if(document.forms[_formName]){
		var elem = document.forms[_formName].elements[_elementName];
		if(elem){
			while(typeof(elem)=="object" && typeof(elem.tagName)!="undefined"){
				tagname=elem.tagName.toUpperCase();
				if(tagname=="BODY" || tagname=="HTML")break;
				if(elem.className.indexOf("formcolumn")!=-1){
					elem.style.visibility="hidden";
					break;
				}
				if(typeof elem=="object")elem=elem.parentNode;
			}
		}
	}
}
function showFormcolumn(_formName, _elementName){
	if(document.forms[_formName]){
		var elem = document.forms[_formName].elements[_elementName];
		if(elem){
			while(typeof(elem)=="object" && typeof(elem.tagName)!="undefined"){
				tagname=elem.tagName.toUpperCase();
				if(tagname=="BODY" || tagname=="HTML")break;
				if(elem.className.indexOf("formcolumn")!=-1){
					elem.style.visibility="visible";
					break;
				}
				if(typeof elem=="object")elem=elem.parentNode;
			}
		}
	}
}

function Validator() {

	var quotes={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};
	
	var quote=function(whs) {
		t=whs+'';r="";
		for(i=0;i<t.length;i++){
			c=t.charAt(i);
			if(quotes[c]){r+=quotes[c];}else{r+=c;}
		}
		return r;	  
	}
	
	var createRequest=function(theForm) {
		var qs = '{'
		for (e=0;e<theForm.elements.length;e++) {
			var fe=theForm.elements[e];
			if(fe.type!='submit' && fe.type!='button' && fe.type!='file') {
				fieldValue = getFieldValue(fe);
				if(fieldValue != null) {
					qs+='"'+theForm.elements[e].name+'":"'+quote(getFieldValue(theForm.elements[e]))+'",';
				}
			}
		}
		if(qs.length>1){qs=qs.substr(0,qs.length-1);}
		qs+='}';
		return qs
	}
	
	var getFieldValue=function(obj) {
		switch(obj.type){
			case 'radio': case 'checkbox': return obj.checked?obj.value:null;
			case 'text': case 'hidden': case 'textarea': return obj.value;
			case 'password': return obj.value;
			case 'select-one':
				if(obj.options==null || obj.selectedIndex<0 || obj.options.length<=0) {
					return null;
				}
				if(obj.options[obj.selectedIndex].value != null && obj.options[obj.selectedIndex].value != '') {
					return obj.options[obj.selectedIndex].value;
				} else {
					return obj.options[obj.selectedIndex].text;
				}
			case 'select-multiple': 
				if (obj.options==null) { return null; }
				var values=new Array();
				for(var i=0;i<obj.options.length;i++) {
					if(obj.options[i].selected) {
						if(obj.options[i].value != null && obj.options[i].value != '') {
							values[values.length]=obj.options[i].value;
						} else {
							values[values.length]=obj.options[i].text;
						}
					}
				}
				return values;
		}
		return null;
	}
	
	this.validate=function(fn) {
		var df = document.forms[fn];
		var w = eval(fn);
		var err = w.validateForm(createRequest(df));
		hideErrors(fn);
		this.showErrors(fn,err);
		return err.length==0;
	}
	
	this.showErrors=function(fn,err) {
		for(var i=0;i<err.length;i++) {
			showError(fn, err[i].field, err[i].error);
		}
	}
	
	this.showFieldErrors=function(fn,err,fieldName) {
		for(var i=0;i<err.length;i++) {
			if(fieldName == err[i].field){
				showError(fn, err[i].field, err[i].error);
			}
		}
	}
}
var validator=new Validator();

function returnExtendedFunction(_functionName, _argString, _toExtendString){
	var funcStr=""
	try{
		if(typeof _functionName == "string"){
			funcStr+=eval(_functionName);
		}else if(typeof _functionName == "function"){
			funcStr+=_functionName;
		}else if(_functionName == null){
			_functionName = new Function();
			funcStr+=_functionName;
		}
	}catch(e){}
	var regex = new RegExp('function[^{]*{((.|\r|\n)*)}$', 'i');
	if(regex.test(funcStr)){
		var res=regex.exec(funcStr);
		return new Function(_argString, res[1]+_toExtendString);
	}else{
		return null;
	}
}

function setTabIndex(){
	var forms = document.forms;
	var tabIndex=1;
	var allLinks = document.getElementsByTagName("a");
	var submitButtons = [];
	for(var act in allLinks){
		if(allLinks[act].className && allLinks[act].className.indexOf("formsubmit")!=-1){
			submitButtons[submitButtons.length]=allLinks[act];
		}
	}
	//var aStr="";
	for(var i=0; i<forms.length; i++){
		try{
			var fName=forms[i].name;
			//aStr+=fName+":\n";
			if(fName!="login"){
				for(var j=0; j<forms[i].elements.length; j++){
					if(forms[i].elements[j].type!="hidden"){
						forms[i].elements[j].tabIndex=""+tabIndex;
						//aStr+=forms[i].elements[j].name+"("+tabIndex+")\n";
						tabIndex++;
					}
				}
			}else{
				for(var j=forms[i].elements.length-1; j>=0; j--){
					if(forms[i].elements[j].type!="hidden"){
						forms[i].elements[j].tabIndex=""+tabIndex;
						//aStr+=forms[i].elements[j].name+"("+tabIndex+")\n";
						tabIndex++;
					}
				}
			}
			for(var j=0; j<submitButtons.length;j++){
				if(submitButtons[j].className.indexOf("formsubmit"+fName!=-1)){
					submitButtons[j].tabIndex=""+tabIndex;
					//aStr+=submitButtons[j].className+"("+tabIndex+")\n\n";
					tabIndex++;
				}
			}
		}catch(e){}
	}
	//alert(aStr);
}
	function scroller(_scrollWrapperId){
		var that = {};
		that.members = [];
		that.isScrolling=false;
		that.endScrolling=false;
		that.nowScrollPos=0;
		that.endScrollPos=0;

		that.addMember = function(_id){
			that.members[_id]=that.endScrollPos;
			that.endScrollPos+=getDimensions(_id).width;
		}

		that.getMovingCheckpoints = function(start, end){
			var percent = .1;var startPos=start;var endPos=end;var nowPos=startPos;var posArray=new Array();
			while(percent!=0){percent = .1 * (endPos - 1*nowPos);if(percent > 0){percent = Math.ceil(percent);}else{percent = Math.floor(percent);}nowPos+=percent;posArray[posArray.length]=nowPos;}
			return posArray.reverse();
		}
		
		that.scrollToMember = function(_id){
			that.endScrolling=that.isScrolling?true:false;
			var steps=that.getMovingCheckpoints(parseInt(document.getElementById(_scrollWrapperId).scrollLeft), that.members[_id]);
			var step = function(){
				that.isScrolling=true;
				if(that.endScrolling){
					that.isScrolling=false;
					that.endScrolling=false;
					return;
				}
				if(steps.length > 0){
					document.getElementById(_scrollWrapperId).scrollLeft=steps[steps.length-1];
					that.nowScrollPos=steps[steps.length-1];
					steps.length-=1;
					setTimeout(step,0);
				}else{
					that.isScrolling=false;
				}
			}
			setTimeout(step,20);
		}
		
		that.switchToMember = function(_id) {
			if (!that.isScrolling) {
				that.isScrolling=true;
				document.getElementById(_scrollWrapperId).scrollLeft=that.members[_id];
				that.nowScrollPos=that.members[_id];
				that.isScrolling=false;
			}
		}
			
		that.bindScrollAuthorityChecker=function(){
			document.getElementById(_scrollWrapperId).onscroll=function(){
				return function(){
					if(!that.isScrolling){this.scrollLeft=that.nowScrollPos;}
				}
			}();
		}
		
		that.bindScrollAuthorityChecker();
		return that;
	}
	
	function addEvent(node,evt,fn,bubbling){
		var mapEvents = {
	        "change":"onchange",
	        "focus":"onfocus",
			"keypress":"onkeypress",
			"blur":"onblur",
	        "keyup":"onkeyup"	
		};
	    bubbling = bubbling || false;
	    if(window.addEventListener){
	        node.addEventListener(evt, fn, bubbling);
	    }else if(window.attachEvent){
	        node.attachEvent(mapEvents[evt], fn);
	    }
	}
	
var foldingContent2Clicks = function(_clickContainerId, _closeClickContainerId, _contentContainerId, _foldingContainerId, _componentName, _isOpen){
	var that = {};
	_closeClickContainerId = _closeClickContainerId || null;
	that.contentref = function(){return document.getElementById(_contentContainerId);};
	that.foldref =  function(){return document.getElementById(_foldingContainerId);};
	that.clickref =  function(){return document.getElementById(_clickContainerId);};
	that.lockButtons=false;
	that.doShowContent=false;
	that.fastFadeIn=false;

	that.clickOpen=function(){
		if(!that.lockButtons){
			that.lockButtons=true;
			that.clickref().style.display="none";
			that.clickref().onclick=that.clickClose;
			that.showContent();
		}
	}
	
	that.clickClose=function(){
		if(!that.lockButtons){
			that.lockButtons=true;
			that.clickref().style.display="block";
			that.clickref().onclick=that.clickOpen;
			that.hideContent();
		}
	}
	
	that.openContent=function(){
		that.doShowContent=true;
		var beforeAnimationHeight = that.getCurrentHeight(that.foldref());
		var endHeight = that.getCurrentHeight(that.contentref());
		that.smoothMove([endHeight+beforeAnimationHeight, beforeAnimationHeight]);
	}
	
	that.showContent=function(){
		that.doShowContent=true;
		that.animateContentHeight();
	}
	
	that.hideContent=function(){
		that.doShowContent=false;
		that.fadeOutContent();
	}
	
	that.animateContentHeight=function(){
		var beforeAnimationHeight = that.getCurrentHeight(this.foldref());
		that.smoothMove(that.getMovingCheckpoints(beforeAnimationHeight, beforeAnimationHeight+(that.getCurrentHeight(that.contentref())*(that.doShowContent?1:-1))));
	}
	
	that.getCurrentHeight = function(ref) {
		var retVal=null;
		var toRedoDisplay=getStyle(ref,'display');
		if(toRedoDisplay == "none"){
			ref.style.display="block";
		}
		if(window.getComputedStyle){retVal = parseInt(window.getComputedStyle(ref,'').getPropertyValue('height'));
		}else if(ref.currentStyle) {retVal = parseInt(ref.offsetHeight);}
		ref.style.display=toRedoDisplay;
		return retVal;
	}
	
	that.setOpacity=function(_node, _level){
		_node.style.opacity = (_level / 10);
	    _node.style.MozOpacity = (_level / 10);
	    _node.style.KhtmlOpacity = (_level / 10);
	    _node.style.filter = "alpha(opacity=" + (_level*10) + ")";
	}
	
	that.fadeInContent=function(){
		var level = 1;
		var _node = that.contentref();
		if(that.fastFadeIn){
			that.fastFadeIn=false;
			level=9;
		}
		var step = function(){
			that.setOpacity(_node, level+=(level==9?1:2));
			_node.style.display="block";
			if(level < 10){
				window.setTimeout(step,0);
			}else{
				that.foldref().style.overflow="visible";
				window.setTimeout(function(){that.lockButtons=false;},30);
			}
		}
		setTimeout(step,0);
	}

	that.fadeOutContent=function(){
		var level = 10;
		var _node = that.contentref();
		var step = function(){
			that.setOpacity(_node, level-=(level==1?1:2));
			if(level > 0){
				window.setTimeout(step,0);
			}else{
				_node.style.display="none";
				that.foldref().style.overflow="hidden";
				that.animateContentHeight();
			}
		}
		setTimeout(step,0);
	}

	that.getMovingCheckpoints = function(start, end){
		var percent = .1;var startPos=start;var endPos=end;var nowPos=startPos;var posArray=new Array();
		while(percent!=0){percent = .1 * (endPos - 1*nowPos);if(percent > 0){percent = Math.ceil(percent);}else{percent = Math.floor(percent);}nowPos+=percent;posArray[posArray.length]=nowPos;}
		return posArray.reverse();
	}
	
	that.smoothMove=function(heightCheckPoints){
		var step = function(){
			that.foldref().style.height=heightCheckPoints[heightCheckPoints.length-1]+'px';
			heightCheckPoints.length-=(heightCheckPoints.length>2?2:1);
			if(heightCheckPoints.length > 0){window.setTimeout(step,10);
			}else{
				if(that.doShowContent) that.fadeInContent();
				else window.setTimeout(function(){that.lockButtons=false;},30);
			}
		}
		step();
	}

	if(_isOpen){
		that.clickref().onclick=that.clickClose;
		that.fastFadeIn=true;
		that.clickref().style.display="none";
		that.openContent();
	}else{
		that.clickref().onclick=that.clickOpen
	}
	if(_closeClickContainerId!=null)
		document.getElementById(_closeClickContainerId).onclick=that.clickClose;
	that.clickref().onmouseover=function(){this.style.cursor="pointer";}
	return that;
}


/**
 * mit der Funktion searchAgesSimple laesst sich mit der Methode setSearchAges() die 
 * Suchaltersverteilung anhand der Sinkowskischen Altersverteilung berechnen und setzen 
 * 
 * @param _fromAge			HiddenElement fuer "Suchalter von"
 * @param _toAge			HiddenElement fuer "Suchalter bis"
 * @param _sexRadio			RadioElement fuer "Ich Bin"
 * @param _searchSexRadio	RadioElement fuer "Ich suche" 
 * @param _birthDaySelect	GeburtstagsElement "Tag"
 * @param _birthMonthSelect	GeburtstagsElement "Monat"
 * @param _birthYearSelect	GeburtstagsElement "Jahr"
 */
var searchAgesSimple = function(_fromAge,_toAge,_sexRadio,_searchSexRadio,_birthDaySelect,_birthMonthSelect,_birthYearSelect){  
	var that = {};	
	that.minAge = 25;
	that.maxAge = 35;
	that.fromAge = _fromAge;
	that.toAge = _toAge;
	that.sex = _sexRadio;
	that.searchSex = _searchSexRadio;
	that.birthDay = _birthDaySelect;
	that.birthMonth = _birthMonthSelect;
	that.birthYear = _birthYearSelect;
	
	var getRadioValue = function(radioObj){
		for (var i=0; i<radioObj.length; i++){
			if (radioObj[i].checked){
				return radioObj[i].value;
			}
		}
		return 0;
	}
	
	that.setSearchAges = function(){
		calculateAges();		
		that.fromAge.value = that.minAge;
		that.toAge.value = that.maxAge;				
	}

	var calculateAges = function(){
		var myAge = getMyAge();
		var sex = parseInt(getRadioValue(that.sex));
		var searchSex = parseInt(getRadioValue(that.searchSex));
		that.minAge = getMinAge(myAge,sex,searchSex);
		that.maxAge = getMaxAge(myAge,sex,searchSex);
	}

	var getMinAge = function(myAge, sex, searchSex) {
		var minAge = 0;
		if(searchSex === 13002 || sex === searchSex){
			minAge = myAge-5;
		}else{			
			if(sex === 13000){
				minAge = myAge-7;				
			}else{
				minAge = myAge-3;
			}
		}
		if(minAge < 18){
			return 18;
		}
		return minAge;
	}

	var getMaxAge = function(myAge, sex,searchSex) {
		var maxAge = 0;
		if(searchSex === 13002 || sex === searchSex){
			maxAge = myAge+5;
		}else{			
			if(sex === 13000){
				maxAge = myAge+7;				
			}else{
				maxAge = myAge+10;
			}
		}
		return maxAge;
	}

	var getMyAge = function() {
		var day = that.birthDay.value;
		var month = that.birthMonth.value-1;		
		var year = new Date().getFullYear();
		var age = year - that.birthYear.value;
		if(day === '' || month === ''){
			return 30;
		}
		var currentStamp = new Date().getTime();	
		var thisYearsBirthdayStamp = new Date(year, month, day).getTime();		
		if(currentStamp <= thisYearsBirthdayStamp){	
			return age-1;
		}
		return age;
	}	
	return that;
}