
WebFontConfig = {
	google: { families: [ 'Open+Sans:400,600,700,400italic,600italic,700italic:latin' ] }
};
(function() {
	var wf = document.createElement('script');
    wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
      '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
    wf.type = 'text/javascript';
    wf.async = 'true';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(wf, s);
})();


$(document).ready(function() {
	// Search Field
	$('#SearchForm_results_Search').hover(function() {
		if($(this).val() == 'Search' || $(this).val() == 'Search') {
			$(this).attr('placeholder',$(this).val());
			$(this).attr('value','');
		} else {
			if(!$(this).val()) {
				$(this).val($(this).attr('placeholder'));
			}
		}
	});

	// dropDown Menu 
	var isAnimate = false;
	$('.dropdown').bind({
		mouseenter: function() {	
			if(!$('header').hasClass('home') && !isAnimate /*&& !$(this).children('dropdown-menu').hasClass('currentMenuItem') && !$(this).children('ul').hasClass('dropdown-menu-open')*/) {
				$('.dropdown-menu, .dropdown-menu-open').stop().fadeOut();
				$(this).children('.dropdown-menu').stop().attr('style','').fadeIn();
			}
	   	},
		mouseleave: function() {
			if(!$('header').hasClass('home') /* && !$(this).children('.dropdown-menu').hasClass('section')*/ && !isAnimate) {
				$('.dropdown-menu').stop().fadeOut();
				//$('.dropdown-menu-open').stop().attr('style','').fadeIn();
			}
	   	}
	});
	
	// Overlay / PopUP
	$('a[rel*=facebox], a.popup').facebox({
		closeImage: '/themes/maas/images/close.gif'
	}) 
	
	// Overlay Slideshow 
	var slideshowOptions = { 
    	speed:  1000,
    	timeout: 0,
    	next:   '#nextSlide', 
   		prev:   '#prevSlide',
   		width: 471,
   		height:290,
   		fit:1,
   		start:0
  	}
  	
	$('.slideshowContainer').livequery( function() {
		$('.slideshowContainer').cycle(slideshowOptions);
	});

	$('.slideshowNav .project').live('click', function() {
		href = $(this).attr('rel');
		
		$('.slideshowNav').removeClass('activeSlide');
		$(this).parent().addClass('activeSlide');
	
	
		$('.slideshowContainer').cycle('destroy');
		$('.slideshowContainer').html(''); 
		
		$.getJSON(href +'/slideshow', function(data) {
			$.each(data.items, function(key, value) {	
				var parentKey = key;
				$.get(href +'/slideshowImage', {id:value.ImageID}, function(imageSrc) {
					title = "";
					if(value.Title) {
						title = value.Title;
					}
					
					text = "";
					if(value.Text) {
						text = value.Text;
					}
					
					newItem = $('<div></div>').addClass('slideshow'+parentKey).append(
						$('<img />').attr('src',imageSrc)
					).append(
						$('<h2></h2>').text(value.Title)
					).append(text);
					
					if(parentKey == 0) {
						newItem.prependTo('.slideshowContainer');
					} else {
						newItem.hide().appendTo('.slideshowContainer');
					}
				});
			});
		});	
		
		$('.slideshow0').children('img').load(function() {
			alert("ready");
		});
		return false;
	});

	// slideshow 
	$('#slideshow').coinslider({
		width:1024,
		height:465,
		navigation:false,
		effect: 'straight', // random, swirl, rain, straight
		delay:5000,
		hoverPause: true,
		spw: 7,
		sph: 3,
		opacity: 1,
		links:false
	});
		
	// link in der slideshow
	$('.sbutton').live('click', function () {
		$(location).attr('href',$(this).attr('rel'));
	});
	
	// Accordion
	//$(".accordion").slideToggle({ header: "h2", active: false });
	
	$('.openSlide').click(function() {
		$(this).parent('h2').parent('.slideLayer').children('.slideElement').slideToggle('slow');
 		return false;
	});
});




