$(function() {

	$('#s').focus(function() {
		if ($(this).val() == 'Suchbegriff eingeben')
			$('#s').val('');
	});
	
	$('marquee').marquee('pointer').mouseover(function () {
			$(this).trigger('stop');
		}).mouseout(function () {
			$(this).trigger('start');
		}).mousemove(function (event) {
			if ($(this).data('drag') == true) {
				this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
			}
		}).mousedown(function (event) {
			$(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
		}).mouseup(function () {
			$(this).data('drag', false);
		});

	$('form#commentform .formsubmit').click( function () {

		$('form#commentform .comment_error').fadeOut('fast').html('');
		$('form#commentform .error').removeClass('error');
		var hasError = false;
		$('.requiredField').each(function() {
			if(jQuery.trim($(this).val()) == '' || ($(this).attr('name') == 'email' && !isEmail( jQuery.trim($(this).val()) )) ) {
			
				$(this).addClass('error');
				hasError = true;
			}
		});
		if(hasError) {
			$('form#commentform .comment_error').html('Bitte f&uuml;hlen Sie alle Pflichtfelder aus.').fadeIn();
			return false;
		}
		else
			$('#commentform').submit();
	});



	$("[title]").tooltip({ 
		track: true,
		delay: 1500,
		showURL: false
	});
	
	
	function isEmail(s) {
		return test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
	}
	function test(s, p) {
		s = s.nodeType == 1 ? s.value : s;
		return s == '' || new RegExp(p).test(s);
	}

});
