$(document).ready(function() {
	
	if(typeof(DD_belatedPNG) !== 'undefined') {
		DD_belatedPNG.fix('#content_top_right_corner');
		DD_belatedPNG.fix('#content_top_left_corner');
		DD_belatedPNG.fix('#content_top');
		//DD_belatedPNG.fix('#top_slideshow_links li a');
	}
	
	// Login	
	$('#login_form div.hints').hide();
	
	$('#login_form input[type=text]').focus(function() {		
		$('#login_hints').fadeIn(300);
	});
	
	$('#login_form input[type=text]').blur(function() {
		$('#login_hints').fadeOut(300);
	});
	
	$('input.hints').live('focus', function() {	
		var default_value = $(this).attr('class').match(/\{label:(.*?)\}/)[1];
		if($(this).val() == default_value) {
			$(this).val('');
			$(this).removeClass('no_value');
		}
	});
	
	$('input.hints').live('blur', function() {		
		if($(this).val() == '') {
			$(this).val($(this).attr('class').match(/\{label:(.*?)\}/)[1]);
			$(this).addClass('no_value');
		}
	});
	
	// Hints
	$('input.hints').each(function() {	
		if($(this).val() == '') {		
			$(this).val($(this).attr('class').match(/\{label:(.*?)\}/)[1]);
			$(this).addClass('no_value');
		}
	});
	
	if ( $('[name=username]').val() != $('[name=username]').attr('class').match(/\{label:(.*?)\}/)[1] )
	{
		$("#top_password").trigger('focus');
	}
	
	// Resize main content
	resize_main_content();
	
	$(window).resize(resize_main_content);
});


function resize_main_content() {
	
	var window_height = $(window).height();	
	var main_content_top = $('#main_content').position().top;
	var main_content_padding = parseInt($('#main_content').css('padding-top'), 10) + parseInt($('#main_content').css('padding-bottom'), 10);
	var footer_height = parseInt($('#footer').height(), 10);
	var footer_padding = parseInt($('#footer').css('padding-top'), 10) + parseInt($('#footer').css('padding-bottom'), 10);
	var sub_menu_height = parseInt($('#sub_menu').height(), 10) - main_content_padding;	
	
	var min_height = window_height - main_content_top - main_content_padding - footer_height - footer_padding;
	
	if(sub_menu_height > min_height) {
		min_height = sub_menu_height;
	}
	
	$('#main_content').css('min-height', min_height);
	
}
