// init

$.fn.valueChange = function() {
	return this.focus(function() {
		if (this.value == this.defaultValue) {
			this.value = '';
			$(this).css({ color: '#333' });
		}
	}).blur(function() {
		if (!this.value.length) {
			this.value = this.defaultValue;
			$(this).css({ color: '#aaa' });
		}
	});
};


$.fn.suckerfish = function() {  
	if ($.browser.msie && $.browser.version*1 < 7) {  
		this.find("li").hover(function() {  
			$(this).addClass('over');  
		},
		function(){  
			$(this).removeClass('over');  
		});  
	}  
};

$(document).ready(function() {
	
	// Kategorien auf der Startseite
	$('div.themenbox').mouseover(function() {
		if (!$.browser.version*1 < 6){
			$(this).addClass('hover');
		}
	}).mouseout(function() {
		$(this).removeClass('hover');
	}).click(function() {
		window.open($(this).children('p').children('a').attr('href'),'_self');
	});
		
	// Suche
	$('input#ctrl_1, input#ctrl_32').valueChange();
	
	// to Top
	
	$('a[href*=#]').click(function() {
		var duration = 500;
		var easing = 'swing';
		// make sure it's the same location      
		if(location.pathname.replace(/^\//,'')==this.pathname.replace(/^\//,'') && location.hostname==this.hostname && this.hash.replace(/#/,'')) {
			// get parameters
			var hash = this.hash;
			var target = $(hash).offset().top;
			// animate to target and set the hash to the window.location after the animation
			$("html:not(:animated),body:not(:animated)").animate({
				scrollTop: target
			}, duration, easing, function(){
				location.hash = hash;
			});
			// cancel default click action
			return false;
		}
	});

	// Nav fuer IE6 (burn in hell, sucker)
	$('div#nav').suckerfish();
	
	// div toggle index
	$('div.toggleContent').hide();
	$('p.toggler').hide();
	$('p#toggler01').show();
	
	
	//toggle the componenet with class msg_body
	$('p#toggler01 a').click(function()	{
		$('div#toggleContent01').slideToggle(600);
		//$('div#toggleContent01').show(600);
		$('p#toggler01').hide(100);
		$('p#toggler02').show(100);
	});
	
	$('p#toggler02 a').click(function()	{
		$('div#toggleContent02').slideToggle(600);
		$('p#toggler02').hide(100);
		$('p#toggler03').show(100);
	});
	
	$('p#toggler03 a').click(function()	{
		$('div#toggleContent03').slideToggle(600);
		$('p#toggler03 a').hide(100);
	});
	
	$('div.image_container a').fancybox({
		'zoomSpeedIn': 500,
		'zoomSpeedOut': 500,
		'overlayShow': true,
		'zoomOpacity': true
	});
	
	$('#tab-liste table.all_records').tablesorter().tablesorterPager({container: $('#pager')});
	
});



