$(document).ready(function() {
	
	// Definitionen der benoetigten Keys
	var KEY_LEFT			 = 37;
	var KEY_UP				 = 38;
	var KEY_RIGHT			 = 39;
	var KEY_DOWN			 = 40;
	var KEY_ESC				 = 27;
	var KEY_TAB				 =  9; 
	
	
	$('#main-title').next('h2').css('margin-top', '10px'); // Margin-top beim ersten h2 entfernen
	$('#main-title').next('p').find('img').css('margin-top', '4px'); // Margin-top beim Thumbnail anpassen
	$('#divmainnav ul ul li:nth-child(9)').css({marginBottom:'15px', display:'block'}); // Abstand nach dem 8 Element erweitern
	 
	var pathname = window.location.pathname;
	pathname = pathname.replace(/bilder-/g,'');
	$('#ps-close-me').attr('href', pathname);	
	
	if (pathname.match(/werkliste/g) || pathname.match(/buro/g)) {
		$('#divcont').css({width:'573px', paddingRight:'297px'});
		}



// Keypress-Event
		if ($.browser.msie){
			$('body').live('keydown', function(e) { $(this).keyEvent(e); });
		} else if ($.browser.webkit){
		  $('body').live('keyup', function(e) { $(this).keyEvent(e); });
		} else {
			$('body').live('keypress', function(e) { $(this).keyEvent(e); });
		}


$.prototype.keyEvent = function(e) {
		var c = e.keyCode > 0 ? e.keyCode : e.which;
		// alert(c);
			switch(c) {
			
			case KEY_ESC:			
									window.location.href=pathname;
									break;			

			case KEY_DOWN:
			case KEY_RIGHT:
									$('#portfolio-slideshow1').cycle('next'); 
									break;
									
			case KEY_UP:
			case KEY_LEFT:
									$('#portfolio-slideshow1').cycle('prev'); 
									break;						
};
e.preventDefault();
};
	/*
	$('body').keyup(function(e){
	var c = e.keyCode > 0 ? e.keyCode : e.which;
	alert(c);
	if (c === 27){
		window.location.href=pathname;
	}
	});
*/
});
