$(document).ready(function(){
	$('#text').height($(window).height() - 176);
	$('#content').height($(window).height() - 176);
	$('select[name="lg"]').hide();
	$('.left_part .form select[name="mod"]').hide();
	$('.form input[type="submit"]').css('background-image', 'url(/images/search.jpg)');
	$('.form input[type="submit"]').css('height', '22px');
	$('.form input[type="submit"]').css('width', '22px');
	$('.form input[type="submit"]').attr('value', '');
	$('.form input[type="submit"]').css('cursor', 'pointer');
	$('.form input[type="submit"]').css('border', 'none');
	
	$('.form input[name="keywords"]').css('width', '110px');
	if (window.location.pathname.substr(1, 2) == 'fr' ) {
		$('.form input[name="keywords"]').attr('value', 'Insérer un mot clé');
		$('.form input[name="keywords"]').click(function() {
			if ($(this).attr('value') == 'Insérer un mot clé')
				$(this).attr('value', '');
		});
		$('.form input[name="keywords"]').blur(function() {
			if ($(this).attr('value') == '')
				$(this).attr('value', 'Insérer un mot clé');
		});
	} else {
		$('.form input[name="keywords"]').attr('value', 'Suchbegriff');
		$('.form input[name="keywords"]').click(function() {
			if ($(this).attr('value') == 'Suchbegriff')
				$(this).attr('value', '');
		});
		$('.form input[name="keywords"]').blur(function() {
			if ($(this).attr('value') == '')
				$(this).attr('value', 'Suchbegriff');
		});
	}
	
	$("#menu li").hover(function(){
		$('>ul', this).fadeIn('fast');
	}, function(){
		$('>ul', this).fadeOut('slow');
	});

	$(window).resize(function(){
		$('#text').height($(window).height() - 176);
		$('#content').height($(window).height() - 176);
	});
	
	$('#top').click(function(){
		$("#text").scrollTop(0);
	});
	
	if (window.location.pathname.substr(3, 5) != 'print' ) {
		$("#text").hover(function () {
			if ( $(this).css("z-index") == "9999" )
			$(this).css("overflow","visible");
		},
		function () {
			if ( $(this).css("z-index") != "9999" )
			$(this).css("overflow","auto");
		});
	}
	
	$('#refreshpassword').click(function() {
		$.ajax({
			type: 'POST',
			url: '/include/functions.inc.php',
			data: { 
				func: 'create_pass'
			},
			async: false,
			success:
				function (data) {
					$('#m_password').val(data);
					$('#m_password').trigger('keyup');
				}
		});
	});
	
	$('#new_pass').click(function() {
		if ( $('#m_email').val() != "" ) {
			$.ajax({
				type: 'POST',
				url: '/sendNewPass.php',
				data: { 
					m_email: $('#m_email').val()
				},
				async: false,
				success:
					function (data) {
						alert(data);
					}
			});
		}
	});
});
