jQuery(document).ready(function(){
	placeFooter();
	
	//$('ul.multicolumnContainer li').equalColumns();
	$('.smallcontent, .bordercontent').equalColumns();
	
	if($('.tx-timtabsociable-pi1').length){				
		var c = 0;		
		$('.tx-timtabsociable-pi1 a').each(function(){			
			var icon = $(this).find('img:first').attr('src');
			$(this).find('img:first').hide();
			$(this).css({
				'background-image'	:	'url('+icon+')',
				'width'							: '20px',
				'height'						: '20px',
				'border'						:	'1px solid #aba59f'
			});
			c++;
		});
		if(c>7){
			$('.tx-timtabsociable-pi1 a:gt(6)').hide(function(){				
				
			});			
		}					
		$('.tx-timtabsociable-pi1').after('<a href="javascript:void(0);" class="show-more">... mehr</a><div class="show-less-wrap" style="display:none;"><a href="javascript:void(0);" class="show-less" >schließen</a></div>');	
		$('.tx-timtabsociable-pi1').css({
			'display':'inline'			
		});
	}

	
	
	
	$('.show-more').click(function() {								
		$('.tx-timtabsociable-pi1 a:gt(6)').show(function(){			
			$('.smallcontent, .bordercontent').equalColumns();
			$('.show-less-wrap').show();	
			$('.show-more').hide();	
		});			
	});
	$('.show-less').click(function() {								
		$('.tx-timtabsociable-pi1 a:gt(6)').hide(function(){			
			$('.smallcontent, .bordercontent').equalColumns();
			$('.show-more').show();	
			$('.show-less-wrap').hide();		
		});					
	});
	

	$(window).resize(function() {		
		placeFooter();	
	});
	
	
	var searchdefault = $('.searchdefault').val();
	$('.searchfield input').DefaultValue(searchdefault);
	
	
	$('.headmenu ul.menu li[class~="no"]').hover(function(){			
			$(this).css({
				'background-position'	: 'left bottom'
			});		
	},function(){
			$(this).css({
				'background-position'	: 'left top'
			});		
	});

	$("ul.submenu").supersubs({ 
      minWidth:    12,   
      maxWidth:    40,   
      extraWidth:  0     
  }).superfish({ 
	    delay:       400,
	    animation:   {height:'show'},
	    speed:       300,
	    autoArrows:  false	    
	});
	
	$("a.fancybox").fancybox({
		titlePosition		:	"over",
  	overlayColor		:	"#000000",
  	overlayOpacity	:	0.6,
  	padding					:	16,
  	cyclic					: true
	});
	$("a.lightbox").fancybox({
		titlePosition		:	"over",
  	overlayColor		:	"#000000",
  	overlayOpacity	:	0.6,
  	padding					:	16,
  	cyclic					: true
	});
	$("a.fancybox-teaser").fancybox({
		'overlayColor'	:	"#000000",
  	'overlayOpacity':	0.6,
  	'padding'				:	16,
		'width'					: 720,
		'height'				: 620,
		'autoScale'			: false,
		'transitionIn'	: 'none',
		'transitionOut'	: 'none',
		'type'					: 'iframe'
	});	
});




function placeFooter() {
	var h = $('.kli-head').height();
	var b = $('.kli-body').height();
	var f = $('.kli-foot').height();
	var hb = $('.kli-headbody-wrap').height();
	var w = $(window).height();	
	if(w > (hb+f)){
		var m = w - (hb+f);	// head, body, foor, margin from body to foot and arrow-space beyond headmenu
		$('.kli-foot').css({
			'margin-top': m+'px'
		});
	}	
}	






jQuery.fn.equalColumns = function(){
	
	var height        = 0;
  var maxHeight    = 0;
  this.each(function () {
  	jQuery(this).css('min-height', '0px');
  	//jQuery(this).attr('style','');
    height        = jQuery(this).outerHeight();
    maxHeight    = (height > maxHeight) ? height : maxHeight;
  });
  return this.each(function () {
		var t            = jQuery(this);
		var minHeight    = maxHeight - (t.outerHeight() - t.height());
		var property    = jQuery.browser.msie && jQuery.browser.version < 7 ? 'height' : 'min-height';		
		t.css(property, minHeight + 'px');
  });
};	

jQuery.fn.DefaultValue = function(text){
	return this.each(function(){		
		if(this.type != 'text' && this.type != 'password' && this.type != 'textarea')
			return;
		var fld_current=this;
    if(this.value=='') {
    	$(this).css({'color' : '#5b7f9f'});
			this.value=text;
		} 
		else {
			return;
		}
		$(this).focus(function() {
			if(this.value==text || this.value==''){
				$(this).css({'color' : '#00396b'});
				this.value='';
			}
		});
		$(this).blur(function() {
			if(this.value==text || this.value==''){
				$(this).css({'color' : '#5b7f9f'});
				this.value=text;
			}
		});
		$(this).parents("form").each(function() {	
			$(this).submit(function() {
				if(fld_current.value==text) {
					fld_current.value='';
				}
			});
		});
  });
};



/*
$.fn.equalColumns = function(){
	$('ul.multicolumnContainer').each(function(){
		var maxH = 0;		
		$(this).find('li.column').each(function(){							
			var thisH = $(this).height();			
			if(thisH > maxH) maxH = thisH;
		});		
		$(this).find('li.column').each(function(){						
			$(this).css({
				'min-height' : maxH+'px',
				'height' : 'auto'
			});
		});
	});
	if($('.bordercontent').length && $('.smallcontent').length){		
		var borderH = $('.bordercontent').height();
		var smallH = $('.smallcontent').height();
		if(borderH > smallH){
			$('.smallcontent').height(borderH);
		}
		else{
			$('.bordercontent').height(smallH);
		}
	}
}	
*/

/*
function setEqualHeight(columns){
 var tallestcolumn = 0;
 columns.each(function(){
 	currentHeight = $(this).height();
	if(currentHeight > tallestcolumn){
		tallestcolumn  = currentHeight;
	}
 });
 columns.height(tallestcolumn);
}

$(document).ready(function() {
 setEqualHeight($(".container  > div"));
});
*/


