function presearch_result(count) {
	if (count != jQuery('#presearch_result_count_inner').html()) {
		jQuery('#presearch_result_count_inner').fadeOut('fast', function() {
			jQuery(this).html(count);
			jQuery(this).fadeIn('fast');
		});
	}
}

function validateJobsuche() {
	plz = $('#jobsuche_plz').val();
	if ((plz.length == 0) || (plz.length >= 3)) {
		return true;
	}
	else {
		$('#plz_min3chars').fadeIn('fast');
		return false;
	}
}

function initJobsucheBox() {
	$('#jobsuche_volltext').example('Ihr Suchbegriff');
	$('#jobsuche_plz').example('Postleitzahl');
	
	$('#jobsuche_plz').keyup(function() {
		if (($(this).val() != 'Postleitzahl') && ($(this).val() != '')) {
			$(this).animate(
				{width: 30},
				'fast',
				function() {
					$('#jobsuche_umkreis').fadeIn('fast');
				}
			);
		}
		else {
			$('#jobsuche_umkreis').fadeOut('fast', function() {
				$('#jobsuche_plz').animate(
					{width: 120},
					'fast'
				);
			});
		}
	});
	
	$('#jobsuche_plz').blur(function() {
		foo = $(this).val();
		if (foo.length < 3) {
			$('#plz_min3chars').fadeIn('fast');
		}
		else {
			$('#plz_min3chars').fadeOut('fast');
		}
	});
	
	$('#plz_min3chars').click(function() {
		$(this).fadeOut('fast');
	});
	
	//live-suchergebnisse
	$('.presearch').blur(function() {
		var formID = $(this).parents('form').attr('id');
		xajax_jobs_presearch(xajax.getFormValues(formID));
	});	
	$('select.presearch').change(function() {
		var formID = $(this).parents('form').attr('id');
		xajax_jobs_presearch(xajax.getFormValues(formID));
	});
}

jQuery(document).ready(function($) {
	$('#jobslider').cycle({
		fx: 'scrollHorz',
		prev: '#jobslider_prev',
		next: '#jobslider_next',
		timeout: 0,
		speed: 500
	});
	
	//smooth scrolling to anchors
	$(".smoothscroll").click(function(event){
		event.preventDefault();

		var full_url = this.href;

		var parts = full_url.split("#");
		var trgt = parts[1];

		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;

		$('html, body').animate({scrollTop:target_top}, 500);
	});
	
	flowplayer('a.videoplayer',
		{
			src: '/flash/flowplayer/flowplayer-3.2.5.swf',
			wmode: 'opaque'
		},
		{ 
			clip: {
				autoPlay: false,
				autoBuffering: true
			},
			play: {
				replayLabel: 'Erneut abspielen'
			}
		});
		
	flowplayer('a.videoplayer_teaser',
		{
			src: '/flash/flowplayer/flowplayer-3.2.5.swf',
			wmode: 'opaque'
		},
		{ 
			clip: {
				autoPlay: false,
				autoBuffering: true
			},
			play: {
				replayLabel: 'Erneut abspielen'
			},
			plugins: {
				controls: {
					all: false,
					play: true,
					scrubber: true,
					fullscreen: true
				}
			}
		});
		
	//firmenlogos breite begrenzen
	var logo = $('#anzeige .firmenlogo');
	if (logo.width() > 450) {
		logo.width(450);
	}
		
	xajax_fetch_jobsuche_box();
});
