$(document).ready(function(){
	
	if( $.browser.msie && $.browser.version < 7 ){
		
		$('#navigation').remove();
		
		var ie6 = 
			'<div id="ie6">'+
				'<p><strong>Ihr Browser ist leider veraltet!</strong></p>'+
				'<p>Sollte ein Update oder Browserwechsel nicht zum gewünschten Erfolg führen,<br />'+
				'so können Sie mich gerne unter der Mailadresse <a href="mailto:mail@martinhochreiter.at">mail@martinhochreiter.at</a> erreichen.</p>'+
				'<p>Vielen Danke für Ihren Besuch!</p>'+
			'</div>';
		
		$('#header').after(ie6);
	
	}
	
	$("#navigation a")
		.hover(
			function() {
				$(this).animate({ backgroundColor: "#000" }, 450);
			},
			function() {
				$(this).animate({ backgroundColor: '#'+$(this).next().text() }, 350);
			}
		);

	$("#meta a")
		.hover(
			function() {
				$(this).animate({ color: "#0382b7" }, 250);
			},
			function() {
				$(this).animate({ color: '#000' }, 250);
			}
		);
	
	var links = $('#wrapper-links');
	
	if( links.length > 0 ){
		
		links.height( $(document).height() );
		
		$('a#links').click(function(e){
			
			var w = ( links.width() ) ? 0 : 150;
			links.animate({width:w}, 500);
			
			return false;
		});

		links.find('a')
			.mouseover(function(e){
				//links.find('a').
				$(this).animate({opacity: 1},300);
				links.find('a').not($(this)).animate({opacity: 0.2},300);
				return false;
			});
		
		links.mouseleave(function(e){
			links.find('a').animate({opacity: 1},300);
		});
		
		links.children('h2').click(function(e){
			links.animate({width:0}, 300);
			return false;
		});
		
		
	}
	
});

function scrollUp(ss,move,speed,elements){
	
	var position = ss.position();
	
	if( position.top > (move * (elements-1)*-1) ){
		ss.animate({"top":"-="+move+"px"},speed);
	}else{
		ss.animate({"top":"0px"},(elements*speed /2) );
	}
	
}

function scrollDown(ss,move,speed,elements){
	
	var position = ss.position();
	
	if( position.top <  0 ){
		ss.animate({"top":"+="+move+"px"},speed);
	}
	
}

function setCookie(){
	var expire = new Date();
	var days = expire.getTime() + (14 * 24 * 60 * 60 * 1000);
	expire.setTime(days);
	document.cookie = "legend=false; expires=" + expire.toGMTString();
				
}

function resizeImg(){

	var bWidth 	= $('body').width();
	var bHeight = $('body').height();
	var wHeight = $('#wrapper').height();
	
	var iWidth = parseInt(bHeight / 667 * 1000);

	if( bWidth > iWidth ){
		iWidth = bWidth;
		bHeight = parseInt(iWidth * 667 / 1000);
	}
	
	$("img.martin").css("width", iWidth);
	$("img.martin").css("height", bHeight);	
	
	
	
//	var iHeight = parseInt(bWidth * 667 / 1000);
//	$("img.martin").css("width", bWidth);
//	$("img.martin").css("height", iHeight);	
}
