$(document).ready(function() {
	$('#swf_menu').flash( {
		src : '../flash/menu.swf',
		width : 430,
		height : 390,
		flashvars : {
			urlProjets : '../../?q=simulation&t=projet',
			urlAutos : '../../?q=simulation&t=auto',
			urlTravaux : '../../?q=simulation&t=travaux',
			r_mo : 15000,
			r_du : 60
		}
	}, {
		version : 8
	});
	$('#sim_projet').flash( {
		src : '../flash/projet.swf',
		width : 467,
		height : 408,
		flashvars : {
			xmlurl : '../xml/ppc-projets_CHKWEB20.xml',
			url_pop : 'http://www.financo.fr/financo/servlet/saisieEtude.do',
			simProjet : '../../?q=simulation&t=projet',
			simAuto : '../../?q=simulation&t=auto',
			simTravaux : '../../?q=simulation&t=travaux'
		}
	}, {
		version : 7
	});
	$('#sim_auto').flash( {
		src : '../flash/auto.swf',
		width : 467,
		height : 408,
		flashvars : {
			xmlurl : '../xml/ppc-auto_CHKWEB20.xml',
			url_pop : 'http://www.financo.fr/financo/servlet/saisieEtude.do',
			simProjet : '../../?q=simulation&t=projet',
			simAuto : '../../?q=simulation&t=auto',
			simTravaux : '../../?q=simulation&t=travaux'
		}
	}, {
		version : 7
	});
	$('#sim_travaux').flash( {
		src : '../flash/travaux.swf',
		width : 467,
		height : 408,
		flashvars : {
			xmlurl : '../xml/ppc-travaux_CHKWEB20.xml',
			url_pop : 'http://www.financo.fr/financo/servlet/saisieEtude.do',
			simProjet : '../../?q=simulation&t=projet',
			simAuto : '../../?q=simulation&t=auto',
			simTravaux : '../../?q=simulation&t=travaux'
		}
	}, {
		version : 7
	});
	$('#sim_reserve').flash( {
		src : '../flash/reserve.swf',
		width : 467,
		height : 408,
		flashvars : {
			xmlurl : '../xml/ppr-20080704.xml',
			url_pop : 'http://www.financo.fr/financo/servlet/saisieEtude.do',
			urlSimProjets : '../../?q=simulation&t=projet'
		}
	}, {
		version : 7
	});

	$("#form-reserve").validationEngine( {
		success : false,
		failure : function() {
		}
	});
	$("#form-projet").validationEngine( {
		success : false,
		failure : function() {
		}
	});
	$("#form-auto").validationEngine( {
		success : false,
		failure : function() {
		}
	});
	$("#form-travaux").validationEngine( {
		success : false,
		failure : function() {
		}
	});
	$("#login-form").validationEngine( {
		success : true,
		failure : function() {
		}
	});

	$("#ddnC-jour, #ddnC-mois, #ddnC-annee").change(function() {
		var d = $("#ddnC-jour").val();
		var m = $("#ddnC-mois").val();
		var y = $("#ddnC-annee").val();
		$("#ddnC").val(y + "-" + m + "-" + d);
	}).change();
	$(".formError").click(function() {
		$(this).fadeOut("slow");
	});
});

// *************************************************************************************
// *************************************************************************************
// GESTION DES POPUP
// *************************************************************************************
// *************************************************************************************

// -------------------------------------------------------------------------------------
// Function : closeWin
// Description : ferme la popup ouverte par la fonction javascript popUp
// Parameters :
// Returns :
// --------------------------------------------------------------------------------------
var newWin = null;
function closeWin() {
	if (newWin != null) {
		if (!newWin.closed)
			newWin.close();
	}
}
// --------------------------------------------------------------------------------------
// Function : popUp
// Description : ouvre la popup
// Parameters : console :
// fixed :
// elastic :
// Returns :
// --------------------------------------------------------------------------------------

function popUp(strURL, strType, strHeight, strWidth) {
	closeWin();
	var strOptions = "";
	if (strType == "console")
		strOptions = "resizable,height=" + strHeight + ",width=" + strWidth;
	if (strType == "fixed")
		strOptions = "status,height=" + strHeight + ",width=" + strWidth;
	if (strType == "elastic")
		strOptions = "toolbar,menubar,scrollbars,resizable,location,height="
				+ strHeight + ",width=" + strWidth;
	newWin = window.open(strURL, 'newWin', strOptions);
	newWin.focus();
}
