header_height = 0;
footer_height = 0;

function resizeFront(){
	header_height = parseInt($('#clearheader').height() );//	parseInt($('#header').height() + $('#path').height());
	footer_height = parseInt($('#clearfooter').height());
	var page_w = getPageSize('windowwidth');
	var page_h = getPageSize('windowheight');
	var img_h = $('#img_container img').attr('height');
	var img_w = $('#img_container img').attr('width');
	var prop = img_w / img_h;
	var calculated_height = page_h - header_height - footer_height - 2;
	$('#front').css('overflow','hidden');
	$('#front').css('width',getPageSize('windowwidth'));
	$('#img_container').css('overflow','hidden');


	if (page_w > page_h){

		//$('#img_container img').attr('height', calculated_height);

		$('#img_container').attr('width',page_w);
		$('#img_container').attr('height',Math.floor(page_w/prop));

		//$('#img_container img').attr('width', page_w);
		$('#img_container img').attr('width',page_w);
		$('#img_container img').attr('height',Math.floor(page_w/prop));

		//alert(page_w+' '+page_h+' # '+$('#img_container img').attr('width')+' '+$('#img_container img').attr('height'));


	}else{
		//alert(calculated_height+' '+calculated_height/prop);
		$('#img_container').attr('width',page_w);
		$('#img_container').attr('height',Math.floor(page_w/prop));

		//$('#img_container img').attr('width', page_w);
		$('#img_container img').attr('width',page_w);
		$('#img_container img').attr('height',Math.floor(page_w/prop));

		//alert('142');


	}


	$('#img_container img').attr('width', page_w);

	//$('#img_container img').attr('height', getPageSize('windowheight'));

	//console.log($('#img_container img').attr('height'));
	$('#front').css('height',calculated_height);
	//$('#front').animate({ scrollTop: $('#img_container img').attr('height') }, 0);
	//alert($('#img_container img').attr('height'));

}

$('document').ready(function(){

	$('#news-block h1 a').click(function(){
		$('.project-images').hide();
		$('.bigimage div.'+$(this).attr('className')).fadeIn();
        $('#titelproject p').hide();
        $('#titelproject p.'+$(this).attr('className')).fadeIn();

		return false;
	});


	//resizeFront();
	//$('.project-info projectstart')

	/*	$('.project').mouseenter(function(){
	 $('.project-info').slideDown()}
	 ).mouseleave(function(){
	 $('.project-info').stop(true,true);$('.project-info').slideUp()
	 }
	 );*/
	var speed = 300;
	$('div.project').mouseover(function(){
		//$(this).find('.project-info').slideUp();
		$(this).find('.project-info').animate({
			                                     
			                                      top: '84'
			                                      
		                                      }, speed);
	});
	$('div.project').mouseleave(function(){
		//$(this).find('.project-info').slideDown();
		$(this).find('.project-info').stop(true, true);
		$(this).find('.project-info').animate({

			                                      top: '108'

		                                      }, speed);
	});
	window.onresize = resizeFront;

	$('a.for_click').click(function(){
		$('.submenu').hide();

		var target = $(this).attr('id').replace('target_','');
		$('.'+target).slideDown();
		return false;
	});

	$('body').find(':not(a.for_click)').click(function(){
		$('.submenu').hide();
	});
	$('#img_container img').load(function(){
		$(this).show();
		resizeFront();
	})
});

function getPageSize(t) {
	var xScroll, yScroll;
	var pageHeight, pageWidth;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight) { // Explorer 6 strict mode
		xScroll = document.documentElement.scrollWidth;
		yScroll = document.documentElement.scrollHeight;
	} else { // Explorer Mac...would also work in Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) { // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if (yScroll < windowHeight) {
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if (xScroll < windowWidth) {
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	if (t == 'pageheight'){
		return pageHeight;
	}else if(t == 'pagewidth'){
		return pageWidth;
	}else if(t == 'windowheight'){
		return windowHeight;
	}else if(t == 'windowwidth'){
		return windowWidth;
	}else
		return [pageWidth,pageHeight,windowWidth,windowHeight];
}
