	$(document).ready(function(){
	
	Cufon.replace('#head', { fontFamily: 'TitilliumText22L-Regular', hover: false });
	Cufon.replace('#footer', { fontFamily: 'TitilliumText22L-Regular', hover: false });
	Cufon.replace('#footer b', { fontFamily: 'TitilliumText22L-Bold', hover: false });
	Cufon.replace('#head b', { fontFamily: 'TitilliumText22L-Bold', hover: false });
	Cufon.replace('.blogbox', { fontFamily: 'TitilliumText22L-Regular', hover: false });
	Cufon.replace('.blogbox b', { fontFamily: 'TitilliumText22L-Bold', hover: false });
	Cufon.replace('.blog_titel b', { fontFamily: 'TitilliumText22L-Bold', hover: false });
	Cufon.replace('#leistungen', { fontFamily: 'TitilliumText22L-Regular', hover: false });
	Cufon.replace('#leistungen b', { fontFamily: 'TitilliumText22L-Bold', hover: false });
	Cufon.replace('#leistungen2', { fontFamily: 'TitilliumText22L-Regular', hover: false });
	Cufon.replace('#leistungen2 b', { fontFamily: 'TitilliumText22L-Bold', hover: false });
	Cufon.replace('#impressum', { fontFamily: 'TitilliumText22L-Regular', hover: false });
	Cufon.replace('#impressum b', { fontFamily: 'TitilliumText22L-Bold', hover: false });
	Cufon.replace('h1', { fontFamily: 'TitilliumText22L-Bold', hover: false });
	Cufon.replace('h2', { fontFamily: 'TitilliumText22L-Bold', hover: false });
	Cufon.replace('h3', { fontFamily: 'TitilliumText22L-Bold', hover: false });
	Cufon.replace('h4', { fontFamily: 'TitilliumText22L-Bold', hover: false });
	Cufon.replace('#commercial', { fontFamily: 'TitilliumText22L-Regular', hover: false });
	Cufon.replace('#content2', { fontFamily: 'TitilliumText22L-Regular', hover: false });
	Cufon.replace('#content2 h1', { fontFamily: 'TitilliumText22L-Bold', hover: false });
	Cufon.replace('#content2 b', { fontFamily: 'TitilliumText22L-Bold', hover: false });
	Cufon.replace('#commercial b', { fontFamily: 'TitilliumText22L-Bold', hover: false });
	
	
		function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
	
	var contenth = $(window).height()-114;
	contenth = contenth.toString() + "px";
	$("#content").css({height:contenth});
	
	$(window).resize(function(){
	var contenth = $(window).height()-114;
	contenth = contenth.toString() + "px";
	$("#content").css({height:contenth});
	});
	
	$("#profil").hide();
	$("#datenschutz").hide();
	$("#links").hide();
	
	$("#profil-button").click(function (){
		$("#inhaber").hide();
		$("#datenschutz").hide();
		$("#links").hide();
		$("#profil").show();
	});
	
	$("#inhaber-button").click(function (){
		$("#profil").hide();
		$("#datenschutz").hide();
		$("#links").hide();
		$("#inhaber").show();
	});
	
	
	$("#links-button").click(function (){
		$("#profil").hide();
		$("#datenschutz").hide();
		$("#inhaber").hide();
		$("#links").show();
	});
	
	$("#datenschutz-button").click(function (){
		$("#inhaber").hide();
		$("#profil").hide();
		$("#links").hide();
		$("#datenschutz").show();
	});
	
	var elementCount = $("#images > div").size(); // wieviele Bilder
	var currElem = 0;
	
	var thwidth = $(window).width();
	$("#thumbs").width(thwidth);
		
	var img = $("#images");
	
	$(window).resize(function(){
	height = $(window).height()-114;	
	img.height(height);
	img.find('img').height(height);
	var thwidth = $(window).width();
	$("#thumbs").width(thwidth);
	});	
	
	var height = $(window).height()-114;
	img.height(height);
	
	
	$("#images > div").each(function (){
		$(this).addClass("img-"+currElem).height(height);
		$(this).find('a').height(height);
	
		currElem++;
	});
	
	currElem = 0;
	
	$("#thumbs > a").each(function (){
		$(this).addClass("" +currElem);
	
		currElem++;
	});
	
	currElem = 0;
	
	var idparam = getUrlVars()["id"];

if (idparam != null) {
	
	//$('#bild' + idparam).click();
	
	if (idparam >= elementCount || idparam < 0) {idparam = "0";}
	currElem = idparam;
	
	}
	
	img.find(".img-"+currElem).show();	
						
	$("span.name").text(img.find(".img-"+currElem).find('a').find('img').attr('title'));
	$("span.beschreibung").text(img.find(".img-"+currElem).find('a').find('img').attr('alt'));		
	
	Cufon.replace('.name', { fontFamily: 'TitilliumText22L-Bold' });
	Cufon.replace('.beschreibung', { fontFamily: 'TitilliumText22L-Regular' });
		
	$("#images a").click(function (){
		
		height = $(window).height()-114;
	
		img.height(height);
		$(this).height(height);
		$(this).find('img').height(height);

		$(this).parent().siblings().height(height);
		$(this).parent().siblings().find('img').height(height);
	
		img.find(".img-"+currElem).fadeOut();
		
		if(currElem < elementCount-1)
			currElem++;
		else
			currElem = 0;
			
		img.find(".img-"+currElem).fadeIn();
						
		$("span.name").text(img.find(".img-"+currElem).find('a').find('img').attr('title'));
		$("span.beschreibung").text(img.find(".img-"+currElem).find('a').find('img').attr('alt'));		
		
		Cufon.replace('.name', { fontFamily: 'TitilliumText22L-Bold' });
		Cufon.replace('.beschreibung', { fontFamily: 'TitilliumText22L-Regular' });
		
			return false;
	});
	
	$("#thumbs a").click(function (){
		
		
		height = $(window).height()-114;
		$("#images").find('img').height(height);
		
		img.find(".img-"+currElem).fadeOut();
		
		if(currElem < elementCount-1)
			currElem++;
		else
			currElem = 0;
		
		currElem = $(this).attr("class");
			
		img.find(".img-"+currElem).fadeIn();
		
		$("span.name").text(img.find(".img-"+currElem).find('a').find('img').attr('title'));
		$("span.beschreibung").text(img.find(".img-"+currElem).find('a').find('img').attr('alt'));		
		
		Cufon.replace('.name', { fontFamily: 'TitilliumText22L-Bold' });
		Cufon.replace('.beschreibung', { fontFamily: 'TitilliumText22L-Regular' });
		
			return false;
	});	
	
	if ($.browser.msie && $.browser.version < 8) {
    $("#thumbs").hide();
 }else{
	
	$('#thumbs a').imgPreview({
    containerID: 'imgPreviewWithStyles',
    imgCSS: {
        // Limit preview size:
        height: 50
    },
    // When container is shown:
    onShow: function(link){
        // Animate link:
        $(link).stop().animate({opacity:0.4});
        // Reset image:
        $('img', this).stop().css({opacity:0});
    },
    // When image has loaded:
    onLoad: function(){
        // Animate image
        $(this).animate({opacity:1}, 300);
    },
    // When container hides: 
    onHide: function(link){
        // Animate link:
        $(link).stop().animate({opacity:1});
    }
});
}


		
	})
