Cufon.replace('h2', {  color: '-linear-gradient(#ffbf00, #ff8e00)'});


$(document).ready(function(){
	//	$.sifr({path:'/fileadmin/js/'});
	//	$('h2').sifr({font:'MyriadG', link: '#666',  underline: false, hover: '#fff', textTransform: 'uppercase' });	
			
		$('a.context').livequery('click', function(event) { 	
			$('.news-context').hide();
			v = $(this).attr('href');
			$(v).fadeIn().animate({opacity: 1.0}, 2000).fadeOut();
			return false;
		});
		
		$('.news-context a').livequery('click', function(event) { 
			current = this;
			$.ajax({
	  				url: $(this).attr('href'),
	  				cache: true,
	  				beforeSend: function(){
	  					$('.news-context').hide();
	  					$("#news-container").empty().append('<div class="loading"></div>');
	  				},
	  				success: function(html){
	  					$("#news-container").empty().append(html).hide().fadeIn(); 
	  				//	$('h2').sifr({font:'MyriadG', link: '#666',  underline: false, hover: '#fff', textTransform: 'uppercase' });
	  					Cufon.replace('h2', {  color: '-linear-gradient(#ffe400, #ff9c00)'});	
	  				}
			});
			return false;
		});	
		
		$('#dateselector a').livequery('click', function(event) { 
			current = this;
			$.ajax({
	  				url: $(this).attr('href'),
	  				cache: true,
	  				beforeSend: function(){
	  					$("#calendar").empty().append('<div class="loading"></div>');
	  				},
	  				success: function(html){
	  					$("#calendar").replaceWith(html); 	
	  				}
			});
			return false;
		});	
		
		
		$("a.fancybox").fancybox(); 
		/*
		$('.content-more-inner').each(function(){
			var tmp = 0;
			var split_html = $(this).children();
			for (i = 0; i < split_html.length; i++){
				if (split_html[i].tagName == 'HR')	{
					$(this).children().slice(tmp, i).wrapAll('<div class="section"></div>');
					tmp = i;
				}
				else if (i == split_html.length - 1){
					$(this).children().slice(tmp, i).wrapAll('<div class="section"></div>');
				}
			}
		});
		*/
		
		$('.nexthidden').each(function(){
			$(this).nextAll().hide();
		});
		$('.nexthidden').toggle(
			function(){
				$(this).nextAll().slideDown();
			},
			function(){
				$(this).nextAll().slideUp();
			}
		);
		

		
		$(".toggle a").toggle(
			function () {
				v = $(this).attr('href');
				$(v + ' .inner').fadeIn();
				$(this).attr('class', 'expand-open');
		//		$(v + ' .content-preview').columnize({columns: 2, balance: true})
			},
			function () {
				v = $(this).attr('href');
				$(v + ' .inner').slideUp();
				$(this).attr('class', 'expand-close');
			}
		);
		
		$(".closeback a").livequery('click', function(event) {
			v = $(this).attr('href');
			v = '#' + v.split('#')[1];
			$(v + ' .inner').slideUp("fast");
			$(v + ' .content-more').hide();
			$(".toggle a").fadeIn();
			$(v + ' .toggle a').attr('class', 'expand-close');
			$(v + ' .more a').fadeIn();
			$('.content:not('+v+')').fadeIn();
			return false;
		});
		
		$(".more a").livequery('click', function(event) {
			v = $(this).attr('href');
			v = '#' + v.split('#')[1];
			$(v + ' .content-more').fadeIn();
			$(this).fadeOut();
			$(".toggle a").fadeOut();
			$('.content:not('+v+')').fadeOut();
			return false;
		});
		
		
		$("#slide ul a:first").addClass("current");
		$("#slide .slide:first").show();
		$("#slide ul a").click (function () {
			v = $(this).attr('href');
			$("#slide a").removeClass("current");
			$(this).addClass("current");
			$(".slide").hide();
			$(v).fadeIn();
			return false;
		});
		
		$('a').focus(function() {
			this.blur();
		});
		
		
		var myFile = document.location.toString();
		if (myFile.match('#')) { // the URL contains an anchor
  			var myAnchor = '#' + myFile.split('#')[1];
			$(myAnchor + ' .toggle a').click();
		}
		
});

jQuery.fn.dosplit = function() {
		var tmp = 0;
		var split_html = $(this).children();
		for (i = 0; i < split_html.length; i++){
			if (split_html[i].tagName == 'HR')	{
				$(this).children().slice(tmp, i).wrapAll('<div class="section"></div>');
				tmp = i;
			}
			else if (i == split_html.length - 1){
				$(this).children().slice(tmp, i).wrapAll('<div class="section"></div>');
			}
		}
};




