// JavaScript Document
var swfu;
var page;
$(document).ready(function() {
	//FIX IE6
	var height = parseInt($('#contenu').height());
	if(height > $('#bg_corps').height()){$('#bg_corps').height(height);}
	//FIN FIX
	$('#reload_captcha').click(function(){
										document.getElementById('captcha').src = 'library/common/captcha/captcha_image.php?sid=' + Math.random(); return false;
										});
	$('#popup').click(function(){
							   window.open('ressources/player/playerFlash.html','popup','menubar=no,status=no,location=no, directories=no,scrollbars=no,menubar=no,width=250,height=60,resizable=yes');
							   });
	
	 $("a.fancyBox").fancybox(); 
	init();
	function init()
	{
		$('#envoyer_form').click(function(){
				contactAjax();
				return false;
		});
		
		$("form").submit(function(){
				contactAjax();
				return false;
		});
		
		$('input, textarea').focus(function(){
								  $(this).css({border : "1px solid #0080c7", backgroundColor : "white"});
								});
		$('input, textarea').blur(function(){
								  $(this).css({border : "1px solid #5B5B5B", backgroundColor : "#E7E7E7"});
								});
		
		$('#envoyer_form').mouseover(function(){
								  $(this).css({border : "1px solid #0080c7", backgroundColor : "white"});
								});
		
		$('#envoyer_form').mouseout(function(){
								  $(this).css({border : "1px solid #5B5B5B", backgroundColor : "#E7E7E7"});
								});
	}
	
	function contactAjax()
	{
		$('.errMsg').slideUp('normal', function(){$('.errMsg').remove();});
		$('.successMsg').slideUp('normal', function(){$('.successMsg').remove();});
		$('form').after('<div class="loadMsg"></div>');
		$('.loadMsg').hide();
		$('.loadMsg').slideDown();
		var ent_pseudo = $('#ent_pseudo').val();
		var ent_message = $('#ent_message').val();
		var ent_mail = $('#ent_mail').val();
		var ent_code = $('#ent_code').val();
		$.ajax({
				   type: "POST",
				   url: "index.php",
				   data: "ajax=true&mdl=contact&action=send&ent_pseudo="+ent_pseudo+"&ent_mail="+ent_mail+"&ent_message="+ent_message+"&ent_code="+ent_code,
				   async: false,
				   success: function(repPHP){
					  $('.loadMsg').slideUp('normal', function(){
						  var t = setTimeout(function(){clearTimeout(t);}, 1000);
						  $('.loadMsg').remove();
						  if(repPHP == 'error'){
							  $('form').after('<div class="loadMsg">Une erreur inconnue s\'est produite.</div>');
							  $('.loadMsg').hide();
							  $('.loadMsg').slideDown();
							  var t = setTimeout(function(){$('.loadMsg').slideUp();$('.loadMsg').remove();clearTimeout(t);}, 4000);
							  return false;
						  }
						  $('#contenu_contact').html(repPHP);
						  $('.errMsg').hide();
						  $('.errMsg').slideDown();
						  $('.successMsg').hide();
						  $('.successMsg').slideDown();
						  var t = setTimeout(function(){$('.successMsg').slideUp();$('.successMsg').remove();clearTimeout(t);}, 4000);
						  init();
					  });
				   }
				});
	}
	
});

