if(document.location.host != 'www.oecher-design.de') document.location.href='http://www.oecher-design.de'+document.location.pathname;
	
var Status = '';
var Loop;

var Hoehe = new Array();
	Hoehe['gestalten'] = '530';
	Hoehe['spektrum'] = '680';
	Hoehe['referenzen'] = '560';
	Hoehe['querschnitt'] = '620';
	Hoehe['netz'] = '350';
	Hoehe['kontakt'] = '540';

$(document).ready(function() {
	$('a[rel=external]').attr('target', '_blank'); // Externe Links in neuem Fenster öffnen

	$('a[rel=popup]').click(function() { // Popup-Fenster öffnen
		var target = $(this).attr('href');
	
		window.open(target, 'Popup', 'width=680, height=700, left=50, top=50');
	
		return false;
	});
	
	$('img#Laedchen, img#Kalender, img#Kalenderblatt').hover(function() {
		$(this).animate({top: '0'}, 100);
	}, function() {
		$(this).animate({top: '-4'}, 200);
	});
	
	$('div.Box h2 a').click(function() {
		$(this).parents('div.Box').box_einblenden();
		return false;
	});
	
	// var Ziel = document.location.pathname.replace('.html', "").replace('/', "");
	var Ziel = document.location.hash.replace(/#/, '');
	if(Ziel!='' && $('div.Box.'+Ziel).length==1) $('div.Box.'+Ziel).box_einblenden();
	
	document.location.hash = '';
});

function showcase_init() {
	$('#Showcase .Arbeiten .Arbeit').each(function(index) {
		var pos = index*530;
		
		$(this).css('left', pos);
	});
	
	$('#Showcase .prev').click(function() {
		showcase_prev();
		
	});
	
	$('#Showcase .next').click(function() {
		showcase_next();
	});
}

function showcase_next() {
	var pos = $('#Showcase .Arbeiten').css('left').replace('px','');
	var len = $('#Showcase .Arbeit').length;
	
	if(pos>(0-(len*530-530))) $('#Showcase .Arbeiten').animate({'left':'-=530'});
	else $('#Showcase .Arbeiten').animate({'left':'0'});
	return false;
}

function showcase_prev() {
	var pos = $('#Showcase .Arbeiten').css('left').replace('px','');
	var len = $('#Showcase .Arbeit').length;
	
	if(pos<0) $('#Showcase .Arbeiten').animate({'left':'+=530'});
	else $('#Showcase .Arbeiten').animate({'left':(0-(len*530-530))});
	return false;
}

$.fn.box_einblenden = function() {
	var Name = $(this).attr('name');
	var Box = $(this);
	
	$.get('http://www.oecher-design.de/inhalte/'+Name+'.html', function(data) {
		Box.find('.Inhalt').html(data).fadeIn();
		$('a.Lightbox, a.Lightboxx').lightBox();
	
		if(Name=='referenzen') showcase_init();
	});
	
	if(Status == Name) {
		$('div.Box').animate({width: '190',height: '115'}, 700);
		$('h1').animate({width: '312',height: '209'}, 700);
		Status = '';
	} else {
		if(Status == '') $('h1').animate({width: '180',height: '120'}, 700);
		
		$('div.Box').animate({width: '150',height: '80'}, 700);
		$(this).animate({width: '630',height: Hoehe[Name]}, 700);
		Status = Name;
	}
}

function back_home() {
	var Ziel = document.location.pathname.replace('.html', "").replace('/', "");
	
	document.location.href = 'http://www.oecher-design.de/#'+Ziel;
}
