$(document).ready(function(){
	$('a[rel=external]').click(function(e){
		window.open(this.getAttribute('href'), '_blank');
		e.preventDefault();
	});
	
	$('a, submit, button').focus(function(e){
		this.blur();
		e.preventDefault();
	});
	
	var out = false;
	$('.box .box-top').click(function(){
		var id = this.id;
		id = id.split('-');
		id = parseInt(id[1]);
		if(out == false){
			switch(id){
				case 1:
					$('#box-1').animate({
						'height': '320px'
					});
					$('#box-1 .box-content').fadeIn();
					
					var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
					//Set a background image(thumbOver) on the <a> tag - Set position to bottom
					$(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
					//Animate the image to 0 opacity (fade it out)
					$(this).find("span").stop().fadeTo('normal', 0 , function(){
						$(this).hide() //Hide the image after fade
					});
					
					out = true;
					break;
				case 2:
					$('#box-1, #box-3').animate({
						'top': '-108px'
					});
					$('#box-2').animate({
						'height': '320px',
						'top': '-108px'
					});
					$('#box-2 .box-content').fadeIn();
					
					var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
					//Set a background image(thumbOver) on the <a> tag - Set position to bottom
					$(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
					//Animate the image to 0 opacity (fade it out)
					$(this).find("span").stop().fadeTo('normal', 0 , function(){
						$(this).hide() //Hide the image after fade
					});
					
					out = true;
					break;
				case 3:
					$('#box-1, #box-2').animate({
						'top': '-216px'
					});
					$('#box-3').animate({
						'height': '320px',
						'top': '-216px'
					});
					$('#box-3 .box-content').fadeIn();
					
					var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
					//Set a background image(thumbOver) on the <a> tag - Set position to bottom
					$(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
					//Animate the image to 0 opacity (fade it out)
					$(this).find("span").stop().fadeTo('normal', 0 , function(){
						$(this).hide() //Hide the image after fade
					});
					
					out = true;
					break;	
			}
		}
		else{
			switch(id){
				case 1:
					$('#box-1').animate({
						'height': '104px'
					});
					$('#box-1 .box-content').fadeOut();
					
					$(this).find("span").stop().fadeTo('normal', 1).show();
					
					out = false;
					break;
				case 2:
					$('#box-1, #box-3').animate({
						'top': '0px'
					});
					$('#box-2').animate({
						'height': '104px',
						'top': '0px'
					});
					$('#box-2 .box-content').fadeOut();
					
					$(this).find("span").stop().fadeTo('normal', 1).show();
					
					out = false;
					break;
				case 3:
					$('#box-1, #box-2').animate({
						'top': '0px'
					});
					$('#box-3').animate({
						'height': '104px',
						'top': '0px'
					});
					$('#box-3 .box-content').fadeOut();
					
					$(this).find("span").stop().fadeTo('normal', 1).show();
					
					out = false;
					break;	
			}
		}
	});
	
	$.sifr({
		path: '/flash/',
		save: true,
		over: 100,
		preventWrap: true
	});
	
	$('h1').sifr({
		font: 'universltstdlightcn'
	});
	
	$('.schnellanfrage h3').sifr({
		font: 'universltstdlightcn'
	});
	
	var zout = false;
	$('a.zimmer-link').click(function(){
		var zid = this.id;
		zid = zid.split('-');
		zid = parseInt(zid[1]);
		if($('#z-' + zid).css('display') == 'none'){
			$('#z-' + zid).slideDown('linear');
			$('#details-' + zid).addClass('aktiv');
		}
		else{
			$('#z-' + zid).slideUp('linear');
			$('#details-' + zid).removeClass('aktiv');	
		}
	});
});
