jQuery(document).ready(function(){
	
	Shadowbox.init({
	    handleOversize: "resize",
	    modal: true
	});
	
	
	if($('.contentwrap').height() < 200){
		$('.main-to-top').hide();
	}
	
	$('.backtotop').click(function(){
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;
	});
	
	
	Cufon.replace('h1', { fontFamily: 'Univers Next Pro' });
	Cufon.replace('.typeface-js', { fontFamily: 'Univers Next Pro' });
	
	$('.news-list-content').hide();
	
	$('.news-list-title h2 a').live('click',function(){										
		if ($(this).parents('.news-list-item:first').find('.news-list-content:first').is(':visible') ) {
			$(this).parents('.news-list-item:first').find('.news-list-morelink:first').css({'background-image' : 'url(fileadmin/grafik/more_arrow.png)'})
			$('.news-list-content').hide(300);
  		$(this).parents('.news-list-item:first').find('.news-list-content:first').hide(300);
  		$('.news-list-morelink').html('more');
		} 
		else{
			$('.news-list-morelink').html('more');
			$('.news-list-morelink').css({'background-image' : 'url(fileadmin/grafik/more_arrow.png)'})
			$('.news-list-content').hide(300);
  		$(this).parents('.news-list-item:first').find('.news-list-content:first').show(300);
  		$(this).parents('.news-list-item:first').find('.news-list-morelink:first').css({'background-image' : 'url(fileadmin/grafik/less_arrow.png)'})
  		$(this).parents('.news-list-item:first').find('.news-list-morelink:first').html('less');
		}		
		return false;
	});
	
	$('.news-list-morelink').live('click',function(){										
		if ($(this).parents('.news-list-item:first').find('.news-list-content:first').is(':visible') ) {
			$(this).css({'background-image' : 'url(fileadmin/grafik/more_arrow.png)'})
			$('.news-list-content').hide(300);
  		$(this).parents('.news-list-item:first').find('.news-list-content:first').hide(300);
  		$('.news-list-morelink').html('more');
		} 
		else{
			$('.news-list-morelink').html('more');
			$('.news-list-morelink').css({'background-image' : 'url(fileadmin/grafik/more_arrow.png)'})
			$('.news-list-content').hide(300);
  		$(this).parents('.news-list-item:first').find('.news-list-content:first').show(300);
  		$(this).css({'background-image' : 'url(fileadmin/grafik/less_arrow.png)'})
  		$(this).html('less');
		}
		
		return false;
	});
		
	$(".list").treeview({
		animated: "fast",
		collapsed: true,
		unique: true
	});
	
	$('.tx-macinasearchbox-pi1 .searchsubmit').click(function() {
  		$('#searchform').submit();
	});
	
	$('.tx-indexedsearch-searchbox .searchsubmit').click(function() {
  		$('#tx_indexedsearch').submit();
	});
	
	jQuery('ul.sf-menu').superfish({ 
	    delay:       800,
	    animation:   {height:'show'},
	    speed:       300,
	    autoArrows:  false,
	    dropShadows: false 
	});
		
	$('.searchinput input').DefaultValue('Search');
	
});


jQuery.fn.DefaultValue = function(text){
    return this.each(function(){
		//Make sure we're dealing with text-based form fields
		if(this.type != 'text' && this.type != 'password' && this.type != 'textarea')
			return;
		
		//Store field reference
		var fld_current=this;
		
		//Set value initially if none are specified
        if(this.value=='') {
			this.value=text;
		} else {
			//Other value exists - ignore
			return;
		}
		
		//Remove values on focus
		$(this).focus(function() {
			if(this.value==text || this.value=='')
				this.value='';
		});
		
		//Place values back on blur
		$(this).blur(function() {
			if(this.value==text || this.value=='')
				this.value=text;
		});
		
		//Capture parent form submission
		//Remove field values that are still default
		$(this).parents("form").each(function() {
			//Bind parent form submit
			$(this).submit(function() {
				if(fld_current.value==text) {
					fld_current.value='';
				}
			});
		});
    });
};


	






