jQuery.noConflict();

jQuery(document).ready(function($) {
    
    // vars
    var login = '#login';
    var logout = '#logout';        
	var layer = '#login_layer';
	var screen = '#login_screen';
	var both = '#login_layer, #login_screen';
	var input1 = '#login_content input[type="text"]:eq(0)';
	var error = '#error_msg > div';
	var forgot = '#forgot_msg > div';
	var close = '.close_window';
	var name = $('#logstatus .username').text();
	//var name = $('#login_content #error_msg > div').text();
	var navS = '.navSelector';
	var calNav = '#calendar-nav tr > td:first';
	var calEvent = '.month-large span.default_catheader_text, #cal_list_wrap span.cal_event_title';
	var calMore = '#cal_list_content .cal_event_more';
		
	// always focus the first input
	$(input1).focus();
		
	// show login layer
	$(login).click(function() {
		$(both).fadeIn(350);
		$(input1).focus();
	});             
	
	// hide login layer
	if ($(close).length) {
		$(layer).click(function() {
			window.location.href = $('a', close).attr('href');
		});
	} else {
		$(layer).click(function() {
			$(both).fadeOut(350);
		});
	}
	
	// login error
	if($(error).text() != '') {
		$(both).show();
	}
	
	// forgot something
	if($(forgot).text() != '') {
		$(both).show();
		$(input1).focus();
	}
	
	// sitemap
	//$("#fusszeile .csc-sitemap ul li ul li:last-child").after('<li>&nbsp;</li>');
	
	// slider link whole nav items
	$(navS).click(function() {
		window.location.href = $('a.readmore', this).attr('href');
		return false;
	});

	// cal - link to login layer if not linked already
	$(calEvent).each(function() {
		if ($(this).children('a').size() == 0) {
			$(this).css('cursor','pointer').click(function() {
				$(both).fadeIn(350);
				$(input1).focus();
			});
		}
	});
	// same for more
	$(calMore).each(function() {
		if ($(this).children('a').size() == 0) {
			$(this).css('cursor','pointer').click(function() {
				$(both).fadeIn(350);
				$(input1).focus();
			});
		}
	});
	
	// anmeldung next scroll up
/*
	$('.command.next').click(function() {
		$('html, body').animate({
    		scrollTop: $("#titelbild").offset().top
		}, 200);
	});
*/
		
});
