$(document).ready(function() {
	set_bg_props($(window).width(),$(window).height());
	$('#map > a').html('');


        $('#infotext').html('');
});


function set_bg_props(x,y) {
	$('#backimg').css('width',x + 'px');
	$('#backimg').css('height',y + 'px');
}


window.onresize = resize;

function resize() {
	set_bg_props($(window).width(),$(window).height());
}


$('a[rel="sup"]').live('click', function() {

		$('#images_to_scroll').animate({
			marginTop: '-=50'
		}, 'slow');
});

$('a[rel="sdown"]').live('click', function() {
		if($('#images_to_scroll').css('marginTop').replace("px", "")<0) {
			$('#images_to_scroll').animate({
				marginTop: '+=50'
			}, 'slow');
		}
});


$('a.pages').live('click', function() {
	var related_to=$(this).attr('rel');
	$('tr[rel!="'+related_to+'"]').hide();
	$('tr[rel="'+related_to+'"]').fadeIn('slow');	
	$('tr[rel="sorti"]').show();
        $('tr[rel="nein"]').show();
});


$('#tab_news').live('click', function() {
		$(this).css('fontWeight','bold');
	$('#location_info').css('display','none');
	$('#location_news').css('display','block');	
	$('#location_raum').css('display','none');
        $('#location_imgs').css('display','none');
});

$('#tab_raum').live('click', function() {
	$(this).css('fontWeight','bold');
	$('#umfassend_normal').css('display','none');
	$('#location_news').css('display','none');
	$('#location_raum').css('display','block');
        $('#location_imgs').css('display','block');
});


$('#tab_normal').live('click', function() {
	$(this).css('fontWeight','bold');
	
	if($('#location_news').css('display')=='block') {
		$('#tab_raum').css('fontWeight','normal');
		$('#tab_news').css('fontWeight','normal');
		$('#location_info').css('display','block');
		$('#location_raum').css('display','none');
		$('#location_news').css('display','none');
                $('#location_imgs').css('display','block');
	}
	else {
		$('#tab_raum').css('fontWeight','normal');
		$('#tab_news').css('fontWeight','normal');
		$('#umfassend_normal').css('display','block');
		$('#location_news').css('display','none');
		$('#location_raum').css('display','none');
                $('#location_imgs').css('display','block');
	}
});




$('#impressum').live('click', function() {
	fenster = window.open("impressum.php", "Impressum", "width=600,height=800,status=yes,scrollbars=yes,resizable=no");
	fenster.focus();
	return false;
});



$('input[rel="tocheck"]').live('click', function() {
    $(this).css('background', '#ffffff');
});


$('#send_register').live('click', function() {
    
    var fehler_arr=new Array();
    $('input[rel="tocheck"]').each(function() {
       if($(this).val()=='') {
            $(this).css('background', '#ff0000');
            fehler_arr[fehler_arr.length]=false;
       }
      if($(this).attr('name')=='email')
           if(!check_if_mail_exists($(this).val()))
               fehler_arr[fehler_arr.length]=false;
    });



    if(!$('#agb').attr('checked')) {
        fehler_arr[fehler_arr.length]=false;
        $('#agb').css('border', '2px solid #ff0000');
    }
    if(fehler_arr.length == 0)
        $('#registerform').submit();
    else
        alert('Bitte überprüfen Sie Ihre Eingabe.')
    
});


$('#login').live('click', function() {
   $('#login_screen').fadeIn('slow');
});

$('a[rel="login"]').live('click', function() {
    if($('#login_screen').html().indexOf("Download. Bitte")==-1)
        $('#login_screen').html('<strong><span style="color:#000">Geschützter Download. Bitte <a href="register.php">registrieren</a> Sie Sich jetzt.</span></strong><br /><br />' + $('#login_screen').html())
   $('#login_screen').fadeIn('slow');
});

$(document).keyup(function(e) {
   if($('#login_screen').css("display")=='block') {

        if(e.keyCode == 27) {
            $('#login_screen').hide();
        }
   }

});


function check_if_mail_exists(inpi) {
  

  
       return true;
}



function oeffnefenster (url) {
 fenster = window.open(url, "AGB", "width=600,height=400,status=yes,scrollbars=yes,resizable=yes");
 fenster.focus();
}

