/*	---------------------------------------- * *	COMMON FUNCTIONS * *	---------------------------------------- */root =  location.protocol + '//' + location.host + '/';if(jQuery)(function(){$.extend($.fn,{rightClick:function(handler){$(this).each(function(){$(this).mousedown(function(e){var evt=e;$(this).mouseup(function(){$(this).unbind('mouseup');if(evt.button==2){handler($(this),evt);return false;}else{return true;}});});$(this)[0].oncontextmenu=function(){return false;}});return $(this);},rightMouseDown:function(handler){$(this).each(function(){$(this).mousedown(function(e){if(e.button==2){handler($(this),evt);return false;}else{return true;}});$(this)[0].oncontextmenu=function(){return false;}});return $(this);},rightMouseUp:function(handler){$(this).each(function(){$(this).mouseup(function(e){if(e.button==2){handler($(this),evt);return false;}else{return true;}});$(this)[0].oncontextmenu=function(){return false;}});return $(this);},noContext:function(){$(this).each(function(){$(this)[0].oncontextmenu=function(){return false;}});return $(this);}});})(jQuery);(function(A){A.fn.hasEvent=function(C){var B=this.data("events");return(B&&B[C])}})(jQuery);$(function() { $("ul#main_menu").lavaLamp({ fx: "easeout", speed: 200 }); $("a").bind("focus",function(){if(this.blur)this.blur();});});	// Ajax setup	$.ajaxSetup({		complete : function(){hideLoading()},		beforeSend: function(){showLoading()}	});	// Loading functions	function showLoading(){		loadingFrame = 1;		if( typeof loadingTimer != 'undefined' ){			clearInterval(loadingTimer);		}		var pos = getViewport();		$("#loading").css({'left': ((pos[0] - 40) / 2 + pos[2]), 'top': ((pos[1] - 40) / 2 + pos[3]), 'z-index': 6001}).show();		$("#loading").click(function(){			if( req ) req.abort();			hideLoading();		});		loadingTimer = setInterval(animateLoading, 66);	};	function hideLoading(){		if( typeof loadingTimer != 'undefined' ){			clearInterval(loadingTimer);		}		$("#loading").hide();	}	function animateLoading(el, o){		if (!$("#loading").is(':visible')){			clearInterval(loadingTimer);			return;		}		$("#loading > div").css('top', (loadingFrame * -40) + 'px');		loadingFrame = (loadingFrame + 1) % 12;	};	function getViewport(){		var xScroll, yScroll;		if (self.pageYOffset) {			yScroll = self.pageYOffset;			xScroll = self.pageXOffset;		} else if (document.documentElement && document.documentElement.scrollTop) {			yScroll = document.documentElement.scrollTop;			xScroll = document.documentElement.scrollLeft;		} else if (document.body) {			yScroll = document.body.scrollTop;			xScroll = document.body.scrollLeft;			}		return [$(window).width(), $(window).height(), xScroll, yScroll];	}		function cancelRequest(){	}	// ----------- End of loading functions	//	Function to replace "," with "."	//	parameter: s == Id	function makeNumber(s){		s = $(s).innerHTML;		a = s.search(/\,/);		if(a > -1){			s = s.replace(/\./,'');		}		s = s.replace(/\,/,'.');		s = Number(s);		return s;	}	//	Makes a nice looking number	//	parameter: s == Number	function makeString(s){		if(s==""){s = 0;}		s = parseFloat(s);		s = s.toFixed(2);		s = Number(s).toLocaleString();				a = s.lastIndexOf(',');		if(a<0){			s += ',00';		} else {			a = s.slice(a, a+3);			if(a.length == 2){				s += '0';			}		}		return s;	}	function toggleTooltip( obj, e ){		var text = $(obj).attr('title');		var mouseX = e.pageX + 15;		var mouseY = e.pageY + 15;		$('<div style="left:' + mouseX + 'px; top:' + mouseY + 'px; position:absolute; display:none;" id="tooltip">' + text + '</div>').appendTo('body').fadeIn(250);		$(obj).attr({title: ''});		$(obj).mouseout(function(){			$('#tooltip').remove();			$(obj).attr({title: text});		});		$(obj).mousemove(function(e){			var mouseX = e.pageX + 15;			var mouseY = e.pageY + 15;			$('#tooltip').css({left: mouseX + 'px', top: mouseY + 'px'});		});	}	function showContextMenu(obj, e){		$('.contextMenu').remove();		var mouseX = e.pageX;		var mouseY = e.pageY;		var dots = 4;		var radius = 60;		var centerOne = true;		$('<div class="contextMenu" id="contextMenu_0"></div>').appendTo('body');		var half = $('#contextMenu_0').height() / 2;		$('#contextMenu_0').css({left: (mouseX - half), top: (mouseY - half), opacity: 0});		for( i=1; i<dots; i++ ){			tmp = $('#contextMenu_0').clone();			$(tmp).attr({id: 'contextMenu_' + i}).appendTo('body');		}		var pi = Math.PI;		$('.contextMenu').each(function(i){			if( i == 0 && centerOne == true ){				$(this).animate({ opacity: 0.8 }, 140);				dots--;						} else {				angle = i * ( 360 / dots ) * 2 * pi / 360;				posX = ( mouseX - half ) + Math.round( Math.cos( angle ) * radius );				posY = ( mouseY - half ) - Math.round( Math.sin( angle ) * radius );				$(this).animate({left: posX, top: posY, opacity: 0.8 }, 140);			}		});		$('.contextMenu').noContext();	}/*	---------------------------------------- * *	Categories * *	---------------------------------------- */function activateSearch(){	$('#categories').children().each(function(){		$(this).css({float: 'left;', clear: 'both;'});		$(this).after('<input type="checkbox" style="float:right;">');	});}//-------------------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------------------/*	---------------------------------------- * *	Forms * *	---------------------------------------- */function activateFormValidadtion(){	$('input[type=text],input[type=password],input[type=checkbox]').each(function(i){	    if( typeof $(this).attr('required') != 'undefined' ){			// Disable Button from the Form			$('input[type="submit"]:not(.noerror)', $(this).get(0).form).get(0).disabled = true;			$(this).change(function(){checkValidation(this);})	        /*$(this).keyup(function(){				if( typeof timeout != 'undefined' ){					window.clearTimeout(timeout);					delete timeout;				}				var obj = this;				timeout = window.setTimeout(function(){					checkValidation(obj);				}, 800);	        });*/	    }	});}function checkValidation( obj ){	var errorColor = '#FFAAAA';	var normalColor = '#FFFFFF';	var valid = true;		if( typeof validation_error == 'undefined' ){		validation_error = {};	}	var type = $(obj).attr('required');	var val = obj.value;	if(type == 'text'){		if( !val.match(/^[a-zA-Z]+$/) || val == '' ){			$(obj).addClass('input_error'); ;			valid = false;		} else {			$(obj).removeClass('input_error');		}	} else if(type == 'zip'){		if( isNaN( val ) || val == '' ){			$('#zip_not_valid').show();			$('#form_validation_error').show();			$(obj).addClass('input_error'); ;			valid = false;		} else {			$('#zip_not_valid').hide();			$('#form_validation_error').show();			$(obj).removeClass('input_error'); ;		}	} else if(type == 'number'){		if( isNaN( val ) || val == '' ){			$(obj).addClass('input_error');			valid = false;		} else {			$(obj).removeClass('input_error');		}			} else if(type == 'email'){		if( val.match(/([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]+)/gi) ){			$('#email_not_valid').hide();			$.post( root + 'js.validate_input.php?action=check_email', {				val: val			},			function( data ){				if( data == 'true' ){					$(obj).removeClass('input_error');					$('#email_already_in_use').hide();					delete validation_error.email;				} else {					valid = false;					$(obj).addClass('input_error');					$('#email_already_in_use').show();					$('#form_validation_error').show();					validation_error.email = true;				}			});		} else {			valid = false;			$(obj).addClass('input_error');			$('#email_not_valid').show();			$('#form_validation_error').show();		}	} else if( type == 'username' ){		if( val.length > 3 && val.length < 23 && !/\W/.test(val) ){			$('#username_not_valid').hide();			$.post( root + 'js.validate_input.php?action=check_username', {				val: val			},			function( data ){				if( data == 'true' ){					$(obj).removeClass('input_error');					$('#username_already_in_use').hide();					delete validation_error.username_already_in_use;				} else {					valid = false;					$(obj).addClass('input_error');					$('#username_already_in_use').show();					$('#form_validation_error').show();					validation_error.username_already_in_use = true;				}			});		} else {			valid = false;			$(obj).addClass('input_error');			$('#username_not_valid').show();			$('#form_validation_error').show();		}	} else if( type == 'password' ){		if( $('#form_password_1').val() != $('#form_password_2').val() && $('#form_password_2').val() != '' && $('#form_password_1').val() != '' ){			valid = false;			$('#password_not_valid').show();			$('#form_validation_error').show();			$('input[required="password"]').addClass('input_error');		} else {			$('#password_not_valid').hide();			$('input[required="password"]').removeClass('input_error');		}	} else if( type == 'pre_name' ) {		if( !val.match(/^[a-zA-Z]+$/) || val == '' ){			$('#pre_name_not_valid').show();			$('#form_validation_error').show();			$(obj).addClass('input_error');			valid = false;		} else {			$('#pre_name_not_valid').hide();			$(obj).removeClass('input_error');		}	} else if( type == 'last_name' ) {		if( !val.match(/^[a-zA-Z]+$/) || val == '' ){			$('#last_name_not_valid').show();			$('#form_validation_error').show();			$(obj).addClass('input_error');			valid = false;		} else {			$('#last_name_not_valid').hide();			$(obj).removeClass('input_error');		}	} else if( type == 'city' ) {		if( !val.match(/^[a-zA-Z\-_\s]+$/) || val == '' ){			$('#city_not_valid').show();			$('#form_validation_error').show();			$(obj).addClass('input_error');			valid = false;		} else {			$('#city_not_valid').hide();			$(obj).removeClass('input_error');		}	} else if( type == 'address' ) {		if( val == '' ) {			$('#address_not_valid').show();			$('#form_validation_error').show();			$(obj).addClass('input_error');			valid = false;		} else {			$('#address_not_valid').hide();			$(obj).removeClass('input_error');		}	} else if( type == 'date' ){		if( val == '' || !/[0-9]{2}\.[0-9]{2}\.[0-9]{4}/.test(val) ) {			$('#date_not_valid').show();			$('#form_validation_error').show();			$(obj).addClass('input_error');			valid = false;		} else {			$('#date_not_valid').hide();			$(obj).removeClass('input_error');		}	}	$('input[required][type!=submit][type!=checkbox][type!=radio]', obj.form).each(function(){		if( $(this).val() == '' ){			valid = false;			$('#fill_out_all_fields').show();			$('#form_validation_error').show();		}	});		if( $('input.input_error').length > 0 ){		valid = false;	}		if( $('input[required=checkbox]', obj.form).length > 0 && $('input[required=checkbox]', obj.form)[0].checked == false ){		valid = false;		$('#fill_out_all_fields').show();		$('#form_validation_error').show();	}	if( valid == true ){		$('#form_validation_error').hide();		$('input[type="submit"]', $(obj).get(0).form).get(0).disabled = false;	} else {		$('input[type="submit"]', $(obj).get(0).form).get(0).disabled = true;	}}		//-------------------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------------------/*	---------------------------------------- * *	Profile * *	---------------------------------------- */function loadProfileTab( obj ){	if( obj ){		t = obj;		t = obj.id;		t = t.split('_');		t = t[0];		if( t == 'images' ){			$('#profile_div, #map_div').css('display', 'none');			$('#gallery_div').css('display', 'block');		} else if( t == 'map' ){			$('#gallery_div, #profile_div').css('display', 'none');			$('#map_div').css('display', 'block');		} else if( t == 'profile' ){			$('#gallery_div, #map_div').css('display', 'none');			$('#profile_div').css('display', 'block');		}	}}function loadNextComments( id, offset ){	req = $.ajax({		type: "GET",		url: "index.php",		data: 'ax=load_comments&id=' + id + '&offset=' + offset,		success: function(data){			if( data != 'false' ){				$('#comments').css('height', $('#comments').height());				$(data).appendTo($('#comments'));				$('#comments').animate({height: $('#comments').get(0).scrollHeight + 'px'});				/**				 *	Wohin Scrollen:				 *	$('html').height():					Komplette Dokumenthöhe				 *	$('#comments div:last').height()	Höhe des letzten Kommentars die abgezogen wird // sollte actually der letzte auf dem Bildschirm sichtbarer Comment sein ( window.height & last comment offsetTop )				 *	39:									Margin-Top				 *	45:									Padding-Bottom ($('comment div:last '),  zweites td)				 *	8 & 8								Weiter Paddings				 */								var anim_scrollTop = $('html').height() - $('#comments div:last').height() - 39 - 45 - 8 - 8;				$('html').animate({scrollTop: anim_scrollTop + 'px'}, 1000);				$('.next_comments').unbind('click');				$('.next_comments').click(function(){					if( typeof first_offset == 'undefined' ){						first_offset = offset;					}					next = offset + first_offset;					loadNextComments(id,next);				});			} else {				alert('Es ist ein Fehler aufgetreten.');			}		}	});}function insertSmilie( obj ){	var code = obj.attr('alt');	var text = $('#comment_textarea').get(0).value;	$('#comment_textarea').get(0).value = text + code;	$('#comment_textarea').get(0).focus();}//-------------------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------------------function createCookie(name,value,days) {	if (days) {		var date = new Date();		date.setTime(date.getTime()+(days*24*60*60*1000));		var expires = "; expires="+date.toGMTString();	}	else var expires = "";	document.cookie = name+"="+value+expires+"; path=/";}function readCookie(name) {	var nameEQ = name + "=";	var ca = document.cookie.split(';');	for(var i=0;i < ca.length;i++) {		var c = ca[i];		while (c.charAt(0)==' ') c = c.substring(1,c.length);		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);	}	return null;}function eraseCookie(name) {	createCookie(name,"",-1);}function toggleSearchPanel(){	if( parseFloat( $('#search_panel').css('left') ) == 0 ){		$('#search_panel').animate({left: '-775px'}, 100);	} else {		$('#search_panel').animate({left: '0px'}, 100);	}}function getSelectedText(){    if(window.getSelection){        return window.getSelection().toString();    }    else if(document.getSelection){        return document.getSelection();    }    else if(document.selection){        return document.selection.createRange().text;    }}