$('document').ready(function() {
	$('.boutonConnexion').click(function(){
		$("#f_login	").submit();
	});
	
	$('.slide').hover(
		function() {
			$(this).find('.caption').stop(false,true).animate({bottom:0},{duration:200});
			//$(this).find('.box_titre2').css('backgroundImage','url(../images/css_box_titre_bleu_340.png)');
			//$('.pngHack').ifixpng();
		},
		function() {
			$(this).find('.caption').stop(false,true).animate({bottom:-100},{duration:200});
			//$(this).find('.box_titre2').css('backgroundImage','url(../images/css_box_titre_blanc_340.png)');
			//$('.pngHack').ifixpng();
		}
	);
	
	/*
	$('.slideSousMenu').hover(
		function() {
			$(this).find('.caption').stop(false,true).animate({bottom:0},{duration:200});
		},
		function() {
			$(this).find('.caption').stop(false,true).animate({bottom:-80},{duration:200});
		}
	);
	*/

	$('.slideSousMenu').hover(
		function() {
			$(this).next().find('.caption').stop(false,true).animate({bottom:-2},{duration:200});
		},function() {
			$(this).next().find('.caption').stop(false,true).animate({bottom:-80},{duration:200});
		}
	);
		

	
	$('.pngHack').ifixpng();
	$('#link_devis').hover(
		function() {$(this).attr('src','images/devis_on.png');$('.pngHack').ifixpng();}
		,function() {$(this).attr('src','images/devis.png');$('.pngHack').ifixpng();}
	);
	
	$('#bt_espace_client').hover(
		function() {$(this).attr('src','images/espace_client_on.png');$('.pngHack').ifixpng();}
		,function() {$(this).attr('src','images/espace_client.png');$('.pngHack').ifixpng();}
	);
	
	$('#bt_espace_client').click(function() { alert("Disponible prochainement...");});
	
	
	$('.boutonConnexion').hover(
		function() {$(this).css('backgroundImage','url(../images/css_login_on.png)');$('.pngHack').ifixpng();}
		,function() {$(this).css('backgroundImage','url(../images/css_login.png)');$('.pngHack').ifixpng();}
	);
	
	$('.bouton_valider_form').hover(
		function() {$(this).attr('src','images/validation_form_on.png');$('.pngHack').ifixpng();}
		,function() {$(this).attr('src','images/validation_form.png');$('.pngHack').ifixpng();}
	);
	
	
	$('.blockMission').hover(
		function() {$(this).find('.box_contenu').addClass('blockMission_hover');}
		,function() {$(this).find('.box_contenu').removeClass('blockMission_hover');}
	);
	
	
	$('.blockMission').click(function(){
		//alert($(this).attr('id'));
		document.location.href = $(this).attr('id') + '.html';
	});
	
	 
	
	if ($('#flash_slideshow').attr('id') != undefined) {
		var so = new SWFObject("slide.swf", "movie", "710", "160", "8");
		so.useExpressInstall('js/expressinstall.swf');
		so.addParam("wmode", "transparent");
		so.addParam('allowScriptAccess', 'always');
		so.addParam("id", "movie");
		so.addVariable("sloganRotatorXml","slideshow.xml");
		so.write("flash_slideshow");
	}
	
	
	$('#fichiers_joints').val("");
		
	$("#uploadify").uploadify({
		'uploader'       : 'pages/upload/uploadify.swf',
		'script'         : 'pages/upload/uploadify.php',
		'cancelImg'      : '/images/cancel.png',
		//'folder'         : '/uploads',
		'folder'         : $('#folder_upload').val(),
		//'checkScript'    : 'pages/upload/check.php',
		'queueID'        : 'fileQueue',
		'buttonText'     : 'Ajouter des fichiers',
		'buttonImg'      : '/images/joindre_fichiers.png',
		'width'          : '208',
		'height'         : '81',
		'queueSizeLimit' : '3',
		'wmode'          : 'transparent',
		//'auto'           : false,
		'auto'           : true,
		'multi'          : true,
		'onComplete'     : function(e,q,f) {
			var val = $('#fichiers_joints').val();
			$('#fichiers_joints').val(val+"::"+f.name);
		},
		'onAllComplete'     : function(e,d) {
			$('#bouton_form_recrutement').show();
			$('#patienter_form_recrutement').hide();
			//$('#patienter_form_recrutement').ifixpng();
		},
		'onSelectOnce'    : function() {
			$('#bouton_form_recrutement').hide();
			$('#patienter_form_recrutement').show();
			//$('#patienter_form_recrutement').ifixpng();
		}
	});
	
	FileToUploadUploader=document.getElementById("uploadifyUploader"); 
	
	
	
	$('#bouton_form_devis').click(function(){
		$('#txt_champs_obligatoires').css('visibility','hidden');
		var serializedCheckboxes = "";
		$("#f_devis input:checkbox").each(function() {
			if($(this).attr("checked"))	serializedCheckboxes += (serializedCheckboxes != '' ? ', ' : '') + $(this).attr("value");
		});
		$('#val_demande').val(serializedCheckboxes);
		var trouve = false;
		$(".obligatoire").each(function(){
			$(this).removeClass('required');
			if ($(this).val().replace(/ /gi,'') == '') {
				$(this).addClass('required');
				trouve = true;
			}
		});
		if (trouve) $('#txt_champs_obligatoires').css('visibility','visible');
		else {
			var val = $("#f_devis input,#f_devis select,#f_devis textarea").serialize();
			$('#div_form_input').hide();
			$('#div_form_traite').show();
			$.post("traite.php",val,function(data){
				if (data=='1') {
					window.setTimeout(function() {
						$('#div_form_traite').hide();
						$('#div_form_confirm').show();
					},3000);
				}
				else {
					window.setTimeout(function() {
						$('#div_form_traite').hide();
						$('#div_form_erreur').show();
					},3000);
				}
			});
		}
	});
	
	
	$('#bouton_form_contact').click(function(){
		$('#txt_champs_obligatoires').css('visibility','hidden');
		var trouve = false;
		$(".obligatoire").each(function(){
			$(this).removeClass('required');
			if ($(this).val().replace(/ /gi,'') == '') {
				$(this).addClass('required');
				trouve = true;
			}
		});
		if (trouve) $('#txt_champs_obligatoires').css('visibility','visible');
		else {
			var val = $("#f_contact input,#f_contact textarea").serialize();
			$('#div_form_input').hide();
			$('#div_form_traite').show();
			
			$.post("traite.php",val,function(data){
				if (data=='1') {
					window.setTimeout(function() {
						$('#div_form_traite').hide();
						$('#div_form_confirm').show();
					},3000);
				}
				else {
					window.setTimeout(function() {
						$('#div_form_traite').hide();
						$('#div_form_erreur').show();
					},3000);
				}
			});
		}
	});
	
	
	
	$('#bouton_form_recrutement').click(function(){
		$('#txt_champs_obligatoires').css('visibility','hidden');
		var trouve = false;
		$(".obligatoire").each(function(){
			$(this).removeClass('required');
			if ($(this).val().replace(/ /gi,'') == '') {
				$(this).addClass('required');
				trouve = true;
			}
		});
		if (trouve) $('#txt_champs_obligatoires').css('visibility','visible');
		else {
			var val = $("#f_recrutement input,#f_recrutement textarea").serialize();
			$('#div_form_input').hide();
			$('#div_form_traite').show();
			$.post("traite.php",val,function(data){
				if (data=='1') {
					window.setTimeout(function() {
						$('#div_form_traite').hide();
						$('#div_form_confirm').show();
					},3000);
				}
				else {
					window.setTimeout(function() {
						$('#div_form_traite').hide();
						$('#div_form_erreur').show();
					},3000);
				}
			});
		}
	});
	
	
	
	
	
	
});


