jQuery(function( $ ){
  var container = $( "#container" );
  var subnav = false;
  container.height(($(window).height()-127));
  $('#bigimage').load('ajax/bigimage.php?id=0');
	$( "a" ).click(
    function( event ){
		  if ($(this).attr("target") == "_blank") {
        $('#bigimage').load('ajax/bigimage.php');
		  } else {
		    event.preventDefault();
		    switch ($(this).attr("href")) {
		    	case "#news":
		    	  if (subnav){
              $('#subnav').fadeOut('slow');
              $(this).find('img').attr('hover', 'img/nav_news_i.gif');
              subnav = false;
            } else {
            	$('#subnav').fadeIn('slow');
              $(this).find('img').attr('hover', 'img/nav_news_a.gif');
            	subnav = true;
            }
            break;
          case "#sponsoren":
            $('#bigimage').load('ajax/sponsoren.html');
            break;
          case "#impressum":
            $('#bigimage').load('ajax/impressum.html');
            break;
          default:
            if (container.is( ":visible" )){
              container.slideUp( 400 );
              $('#bigimage').load('ajax/bigimage.php');
              $('#claim').fadeOut('fast');
              $('#back').fadeOut('slow', function() {
              	$('#mainnav').fadeIn('fast');
              	if (subnav) {
              		$('#subnav').fadeIn('fast');
              	}
              });
 			      } else {
              container.slideDown( 400 );
              if (subnav) {
              	$('#subnav').fadeOut('slow');
              }
              $('#mainnav').fadeOut('slow', function() {
              	$('#back').fadeIn('fast');
              	$('#claim').fadeIn('fast');
              });
			      	container.html('<iframe src="'+$(this).attr("href")+'" width="100%" height="100%"></iframe>');
			      }
			      break;
			  }
			}		  	
		  	
    }
  );
  $('.rollover').hover(function() {
	  var currentImg = $(this).attr('src');
		$(this).attr('src', $(this).attr('hover'));
		$(this).attr('hover', currentImg);
	}, function() {
		var currentImg = $(this).attr('src');
		$(this).attr('src', $(this).attr('hover'));
		$(this).attr('hover', currentImg);
	});
	$(window).bind("resize", resizeWindow);
	function resizeWindow( e ) {
		container.height(($(window).height()-127));
	}	
});

