function quicksearch() {
	
	var url = '/DE/search/';
	
	if($('searchgender')) {
		var checkedGender = $$('#searchgender input').filter(function(el){return el.get('checked')}).get('value');
		if(checkedGender.length==0 || checkedGender.length==2) {
			//nothing to do
		}else if(checkedGender.length==1) {
			url += 'gender_'+checkedGender[0]+'/';
		}
	}
	if($('searchgender_select'))
		url += 'gender_'+$('searchgender_select').get('value')+'/';
	
	url += 'alle.html?search=true';
	
	if(parseInt($('agefrom').value)>0) {
		url += '&age[von]='+parseInt($('agefrom').get('value'));
	}
	
	if(parseInt($('ageto').value)>0) {
		url += '&age[bis]='+parseInt($('ageto').get('value'));
	}
	
	if($('searchfor')) url += '&searchfor='+$('searchfor').get('value');
	if($('umkreis')) url += '&umkreis='+$('umkreis').get('value');
	if($('imageonly')) url += '&imageonly='+$('imageonly').get('value');
	
	location.href=url;
	return false;
}



LANG = new Object();
LANG.LANG = 'DE';


/* A workaround for IE issues in mootools 1.2.1
 * - Recreates FX.Scroll() but utilises 1.2.0's getPosition/getOffset routines.
 */
Fx.Scroll2 = new Class({
 
    'Extends': Fx.Scroll,
    'styleString': Element.getComputedStyle,
    'styleNumber': function(element, style) {
        return this.styleString(element, style).toInt() || 0;
    },
    'borderBox': function(element) {
        return this.styleString(element, '-moz-box-sizing') == 'border-box';
    },
    'topBorder': function(element) {
        return this.styleNumber(element, 'border-top-width');
    },
    'leftBorder': function(element) {
        return this.styleNumber(element, 'border-left-width');
    },
    'isBody': function(element) {
        return (/^(?:body|html)$/i).test(element.tagName);
    }, 
    'toElement': function(el) {
        var offset   = {x: 0, y: 0};
        var element  = $(el);
       
        if (this.isBody(element)) {
            return offset;
        }
        var scroll = element.getScrolls();
               
        while (element && !this.isBody(element)){
            offset.x += element.offsetLeft;
            offset.y += element.offsetTop;
           
            if (Browser.Engine.gecko){
                if (!this.borderBox(element)){
                    offset.x += this.leftBorder(element);
                    offset.y += this.topBorder(element);
                }
                var parent = element.parentNode;
                if (parent && this.styleString(parent, 'overflow') != 'visible'){
                    offset.x += this.leftBorder(parent);
                    offset.y += this.topBorder(parent);
                }
            } else if (Browser.Engine.trident || Browser.Engine.webkit){
                offset.x += this.leftBorder(element);
                offset.y += this.topBorder(element);
            }
 
            element = element.offsetParent;
            if (Browser.Engine.trident) {
                while (element && !element.currentStyle.hasLayout) {
                    element = element.offsetParent;
                }
            }
        }
        if (Browser.Engine.gecko && !this.borderBox(element)){
            offset.x -= this.leftBorder(element);
            offset.y -= this.topBorder(element);
        }
       
        var relative = this.element;
        var relativePosition = (relative && (relative = $(relative))) ? relative.getPosition() : {x: 0, y: 0};
        var position = {x: offset.x - scroll.x, y: offset.y - scroll.y};
       
        return this.start(position.x - relativePosition.x, position.y - relativePosition.y);
    }
});


var register_errors = new Object();
register_errors["nick"] = new Object();
register_errors["nick"]["exists"] = "Dieser Benutzername existiert bereits.";
register_errors["nick"]["toshort"] = "Dieser Benutzername ist zu kurz.";
register_errors["nick"]["tolong"] = "Dieser Benutzername ist zu lang.";
register_errors["nick"]["notvalid"] = "Dieser Benutzername ist ungültig. Bitte nur Zahlen, Buchstaben und _ -";
register_errors["nick"]["forbidden"] = "Dieser Benutzername ist verboten.";
register_errors["email"] = new Object();
register_errors["email"]["exists"] = "Diese Email existiert bereits.";
register_errors["email"]["invalid"] = "Dies ist keine gültige Email.";
register_errors["pass"] = new Object();
register_errors["pass"]["short"] = "Das Passwort ist zu kurz.";
register_errors["pass"]["nick"] = "Aus Sicherheitsgründen nicht den Benutzername als Passwort verwenden.";


window.addEvent('domready', function()
{
	if($('slider_minmax_gutter_m')) new Slider($('slider_minmax_gutter_m'), $('slider_minmax_minKnobA'),$('slider_bkg_img'), {
		start: 18,
		end: 50,
		offset:0,
		snap:false,
		onChange: function(pos){$('slider_minmax_min').setHTML(pos.minpos+' Jahre');$('slider_minmax_max').setHTML(pos.maxpos+' Jahre');
			$('agefrom').set('value', pos.minpos);
			$('ageto').set('value', pos.maxpos);
		}
	}, $('slider_minmax_maxKnobA')).setMin(20).setMax(31);

	// define scrollable preview area
	var act_page = 0;
	var act_type = 'toppics';
	var last_page = 2;
	if($('pics2')) var scrollEl = $('pics2');
	else if($$('.picsSlideshow')) var scrollEl = $$('.picsSlideshow')[0];
	if(scrollEl){
		var scroll = new Fx.Scroll2(scrollEl,
		{
			wait: false,
			duration: 500,
			offset: {'x': 0, 'y': -20},
			transition: Fx.Transitions.Quad.easeInOut
		});
	}
	// set pictures get from ajax request
	showPics = function(r)
	{
		var clips = JSON.decode(r);
		var page = 0;
		var div = new Element('div', {'id': ('picpage' + page), 'class': 'picpage'}).inject(this);
		var i = 0;
		this.setStyle('background', 'none');
		clips.each(function(el)
		{
			if (i%PAGINATE_COUNT==0 && i > 0) {
				page++;
				div = new Element('div', {'id': ('picpage' + page), 'class': 'picpage'}).inject(this);
			}
			var a = new Element('a', {href: '/' + LANG.LANG + '/profile/'+ escape(el.title) + '.html'}).inject(div);
			new Element('img', {src: el.image, width: 70, height: 53, border: 0}).inject(a);
			i++;
		}.bind(this));
		// set pagination
		var pages = (clips.length/PAGINATE_COUNT).ceil();
		last_page = pages-1;
		for (var c = 0; c < pages; c++)
		{
			var a = new Element('a', {'href': '#', 'class': 'page', 'html': c+1});
			a.addEvent('click', function(event)
			{
				event = new Event(event).stop();
				act_page = this.innerHTML-1;
				scroll.toElement('picpage' + act_page);
			}.bind(this));
			a.inject($('pages'));
		}
	}
	
	// go to next page
	if($('pics_next')){
		$('pics_next').addEvent('click', function(event)
			{
				event = new Event(event).stop();
				next_page = act_page+1;
				if (!$('picpage' + next_page))
					next_page = 0;
				scroll.toElement('picpage' + next_page);
				act_page = next_page;
			});
		// go to prev page
		$('pics_prev').addEvent('click', function(event)
			{
				event = new Event(event).stop();
				if(act_page > 0){
					prev_page = act_page-1;
				}else{
					prev_page = act_page;
				}
				if (!$('picpage' + prev_page))
					prev_page = last_page;
				scroll.toElement('picpage' + prev_page);
				act_page = prev_page;
			});
		
	}
	// tags
	if($('tags')) $('tags').addEvent('change', function (el)
	{
		$('pics-inner').empty();
		$('pics-inner').setStyle('background', 'transparent url(\'/images/common/loading.gif\') scroll no-repeat 310px 50px');
		scroll.set(0, 0);
		act_page = 0;
		//$('pages').empty();
		sendform(this.form.id, 'Gallery::showpics', showPics.bind($('pics-inner')));
	});
	if($('tagsXXX')) $('tagsXXX').addEvent('change', function (el)
	{
		$('picsXXX-inner').empty();
		$('picsXXX-inner').setStyle('background', 'transparent url(\'/images/common/loading.gif\') scroll no-repeat 310px 50px');
		scroll.set(0, 0);
		act_page = 0;
		//$('pages').empty();
		sendform(this.form.id, 'Gallery::showpics', showPics.bind($('picsXXX-inner')));
	});




	// customize formcheck
	if(typeof(FormCheck)!='undefined') {
		FormCheck.implement({
			directAjaxSubmit: function(name){
				this.reinitialize();

				this.validations.each(function(el) {
					var validation = this.manageError(el,'submit');
					if(!validation) this.form.isValid = false;
				}, this);

				if (this.form.isValid) {
					if (this.options.submitByAjax) {
						this.submitByAjax();
					}
				} else {
					if (this.elementToRemove && this.elementToRemove != this.firstError && this.options.display.indicateErrors == 1) {
						this.removeError(this.elementToRemove);
					}
					this.focusOnError(this.firstError)
				}
			},
			AjaxErrorHandler: function(data)
			{
				if (data == parseInt(data))
				{
					location.href='/DE/my/regready/#profile';
				}
				else
				{
					this.reinitialize();
					this.form.isValid = false
					if(data=='') {alert('Ein Fehler ist aufgreten, bitte versuchen Sie es erneut!');return;}
					var err = JSON.decode(data);
					for (el in err['err'])
					{
						if ($(el) && $(el).errors) {
								$(el).errors.push((typeof register_errors[el] != 'undefined' && typeof register_errors[el][err['err'][el]] != 'undefined') ? register_errors[el][err['err'][el]] : err['err'][el]);
						}
						else
							alert('Ein Fehler ist aufgreten, bitte versuchen Sie es erneut!');
						if(!this.firstError) this.firstError = $(el);
						this.addError($(el));
					}
					if (this.elementToRemove && this.elementToRemove != this.firstError && this.options.display.indicateErrors == 1) {
						this.removeError(this.elementToRemove);
					}
					this.focusOnError(this.firstError);
				}
			}
		});


		//new Form.Validator.Inline('quickregform', {useTitles:true});
		new FormCheck('quickregform', {
				'display': {'showErrors': 1, 'indicateErrors': 2, 'errorsLocation': 1, 'scrollToFirst': false},
				'submitByAjax': true,
				'onAjaxSuccess': function(data) {this.AjaxErrorHandler(data)},
				'onAjaxFailure': function() {alert('failed');}
		});
	}
});




/*
Class: Slider
        Creates a slider with two elements: a knob and a container. Returns the values.
Note:
        The Slider requires an XHTML doctype.
Arguments:
        element - the knob container
        knob - the handle
        options - see Options below
        maxknob - an optional maximum slider handle
Options:
		start - the minimum value for your slider.
		end - the maximum value for your slider.
        mode - either 'horizontal' or 'vertical'. defaults to horizontal.
        offset - relative offset for knob position. default to 0.
        knobheight - positions the max slider knob
		snap - whether the slider will slide in steps
		numsteps - number of slide steps
Events:
        onChange - a function to fire when the value changes.
        onComplete - a function to fire when you're done dragging.
        onTick - optionally, you can alter the onTick behavior, for example displaying an effect of the knob moving to the desired position.
                Passes as parameter the new position.
*/
var Slider = new Class({
	options: {
		onChange: Class.empty,
		onComplete: Class.empty,
		onTick: function(pos){
			this.moveKnob.setStyle(this.p, pos);
		},
		start: 0,
		end: 80,
		offset: 0,
		knobheight: 22,
		knobwidth: 18,
		mode: 'horizontal',
		clip_w:0,
		clip_l:0,
		isinit:true,
		snap: false,
		range: false,
		numsteps:null
	},
    initialize: function(el, knob,bkg, options, maxknob) {
		this.setOptions(options);
		this.element = $(el);
		this.knob = $(knob);
		this.previousChange = this.previousEnd = this.step = -1;
		this.bkg = $(bkg);
		if(this.options.steps==null){
			this.options.steps = this.options.end - this.options.start;
		}
		if(maxknob!=null)
			this.maxknob = $(maxknob);
		//else
		//	this.element.addEvent('mousedown', this.clickedElement.bindWithEvent(this));
		var mod, offset;
		switch(this.options.mode){
			case 'horizontal':
				this.z = 'x';
				this.p = 'left';
				mod = {'x': 'left', 'y': false};
				offset = 'offsetWidth';
				break;
			case 'vertical':
				this.z = 'y';
				this.p = 'top';
				mod = {'x': false, 'y': 'top'};
				offset = 'offsetHeight';
		}
		this.max = this.element[offset] - this.knob[offset] + (this.options.offset * 2);
		this.half = this.knob[offset]/2;
		this.full = this.element[offset] - this.knob[offset] + (this.options.offset * 2);
		this.min = $chk(this.options.range[0]) ? this.options.range[0] : 0;
		this.getPos = this.element['get' + this.p.capitalize()].bind(this.element);
		this.knob.setStyle('position', 'relative').setStyle(this.p, - this.options.offset);

		this.range = this.max - this.min;
		this.steps = this.options.steps || this.full;
		this.stepSize = Math.abs(this.range) / this.steps;
		this.stepWidth = this.stepSize * this.full / Math.abs(this.range) ;


		if(maxknob != null) {
			this.maxPreviousChange = -1;
			this.maxPreviousEnd = -1;
			this.maxstep = this.options.end;
			this.maxknob.setStyle('position', 'relative').setStyle(this.p, + this.max - this.options.offset);
		}
		var lim = {};
		//status = this.z
		lim[this.z] = [- this.options.offset, this.max - this.options.offset];
		//lim[this.z] = [100, this.max - this.options.offset];

		this.drag = new Drag(this.knob, {
			limit: lim,
			modifiers: mod,
			snap: 0,
			onStart: function(){
					this.draggedKnob();
			}.bind(this),
			onDrag: function(){
					this.draggedKnob();
			}.bind(this),
			onComplete: function(){
					this.draggedKnob();
					this.end();
			}.bind(this)
		});
		if(maxknob != null) {
			this.maxdrag = new Drag(this.maxknob, {
				limit: lim,
				modifiers: mod,
				snap: 0,
				onStart: function(){
					this.draggedKnob(1);
				}.bind(this),
				onDrag: function(){
					this.draggedKnob(1);
				}.bind(this),
				onComplete: function(){
					this.draggedKnob(1);
					this.end();
				}.bind(this)
			});
		}

		if (this.options.snap) {
			//this.drag.options.grid = Math.ceil(this.stepWidth);
			this.drag.options.grid = (this.full)/this.options.numsteps ;
			this.drag.options.limit[this.z][1] = this.full;
			//this.drag.options.grid = this.drag.options.grid - (this.knob[offset]/this.options.numsteps);
			status = "GRID - " + this.drag.options.grid  + "  , full = " + this.full// DEBUG

		}
		if (this.options.initialize) this.options.initialize.call(this);
    },
	setMin: function(stepMin){
		this.step = stepMin.limit(this.options.start, this.options.end);
		this.checkStep();
		this.end();
		this.moveKnob = this.knob;
		this.bkg.style.clip = "rect(0px "+  (parseInt(this.toPosition(this.step)) +3) + "px 10px 0px)";
		status =this.bkg.style.clip + "  vl= " + parseInt(this.toPosition(this.step)) ; //Debug
		this.fireEvent('onTick', this.toPosition(this.step));
		return this;
	},
	setMax: function(stepMax){
		this.maxstep = stepMax.limit(this.options.start, this.options.end);
		this.checkStep(1);
		this.end();
		this.moveKnob = this.maxknob;
		var w= Math.abs(this.toPosition(this.step)- this.toPosition(this.maxstep)) + 3 ;
		var r = parseInt(this.clip_l + w);
		this.bkg.style.clip = "rect(0px "+  r + "px 10px "+ this.clip_l + "px)";

		this.fireEvent('onTick', this.toPosition(this.maxstep));
		// For Init Only
		if(this.options.isinit){
			var lim = {}; var mi,mx;
			mi = - this.options.offset;
			mx= parseInt(this.maxknob.getStyle('left')) - this.options.offset-4 ;
			lim[this.z] = [mi, mx];
			this.drag.options.limit = lim;
			this.options.isinit = false;
		}
		return this;
	},
	clickedElement: function(event){
		var position = event.page[this.z] - this.getPos() - this.half;
		position = position.limit(-this.options.offset, this.max -this.options.offset);

		this.step = this.toStep(position);

		//this.moveKnob = this.knob;
		this.bkg.style.clip = "rect(0px "+  (parseInt(this.toPosition(this.step)) +3) + "px 10px 0px)"
		//status =this.bkg.style.clip; //Debug
		this.checkStep();
		this.end();
		this.fireEvent('onTick', position);
	},

	draggedKnob: function(mx){
		var lim = {}; var mi,mx;
		if(mx==null) {
			this.step = this.toStep(this.drag.value.now[this.z]);
			this.checkStep();
		}else {
			this.maxstep = this.toStep(this.maxdrag.value.now[this.z]);
			this.checkStep(1);
		}
	},
	checkStep: function(mx){
		var lim = {}; var mi,mx;
		var limm = {};
		if(mx==null) {if (this.previousChange != this.step){this.previousChange = this.step;}}
		else {if (this.maxPreviousChange != this.maxstep){this.maxPreviousChange = this.maxstep;}}

		if(this.maxknob!=null) {

			mi = - this.options.offset;
			mx= parseInt(this.maxknob.getStyle('left')) - this.options.offset-4 ;
			//mx= parseInt(this.maxknob.getStyle('left')) - this.options.offset ;
			lim[this.z] = [mi, mx];
			this.drag.options.limit = lim;


			mi = parseInt(this.knob.getStyle('left'))-this.options.offset+22;
			//mi = parseInt(this.knob.getStyle('left'))-this.options.offset;

			mx= this.max - this.options.offset;
			limm[this.z] = [mi, mx];
			this.maxdrag.options.limit = limm;

			if(this.step < this.maxstep){
				this.fireEvent('onChange', { minpos: this.step, maxpos: this.maxstep });
				//this.clip_l = parseInt(this.knob.getStyle('left'));
			}
			else{
				this.fireEvent('onChange', { minpos: this.maxstep, maxpos: this.step });
				//this.clip_l = (parseInt(this.maxknob.getStyle('left')) + 10) ;
			}
			this.clip_l = parseInt(this.knob.getStyle('left')) + 10;
			//var w = Math.abs(parseInt(this.knob.getStyle('left')) - parseInt(this.maxknob.getStyle('left'))) + 3;
			var w = Math.abs(parseInt(this.knob.getStyle('left')) - parseInt(this.maxknob.getStyle('left')));
			//if(w > 3) w = w+3;

			var r = parseInt(this.clip_l + w);
			this.bkg.style.clip = "rect(0px "+  r + "px 10px "+ this.clip_l + "px)"
			//status =this.bkg.style.clip  + " w= " + w //Debug

		}else {
			this.fireEvent('onChange', this.step);
			this.bkg.style.clip = "rect(0px "+  (parseInt(this.drag.value.now[this.z]) +3)  + "px 10px 0px)"

		}
	},
	end: function(){
		if (this.previousEnd !== this.step || (this.maxknob != null && this.maxPreviousEnd != this.maxstep)) {
			this.previousEnd = this.step;
			if(this.maxknob != null) {
				this.maxPreviousEnd = this.maxstep;
				if(this.step < this.maxstep)
					this.fireEvent('onComplete', { minpos: this.step + '', maxpos: this.maxstep + '' });
				else
					this.fireEvent('onComplete', { minpos: this.maxstep + '', maxpos: this.step + '' });
			}else{
				this.fireEvent('onComplete', this.step + '');
			}
		}
	},

	toStep: function(position){
		return Math.round((position + this.options.offset) / this.max * this.options.steps) + this.options.start;
	},

	toPosition: function(step){
		return (this.max * step / this.options.steps) - (this.max * this.options.start / this.options.steps) - this.options.offset;
	}

});

Slider.implement(new Events);
Slider.implement(new Options);
