YAHOO.namespace("axeti");

function initEmailForm()

{

	InitialiserPnlErreurCVCarrieres();

	YAHOO.axeti.wait = new YAHOO.widget.Panel("wait",  

										{ width: "240px", 

										  fixedcenter: true, 

										  close: false, 

										  draggable: false, 

										  zindex:4,

										  modal: true,

										  visible: false

										} 

									);

    

	YAHOO.axeti.wait.setHeader("Veuillez patienter svp...");

	YAHOO.axeti.wait.setBody("<img src=\"css/images3/rel_interstitial_loading.gif\"/>");

	YAHOO.axeti.wait.render(document.body);

	

	var handleSubmit = function() {

		var txt = YAHOO.axeti.panelEmplois.header.childNodes[0].nodeValue;

		document.getElementById("emploi_titre").value = txt.substring(14);

		this.submit();

	};

	var handleCancel = function() {

		this.cancel();

		YAHOO.axeti.wait.hide();

	};

	var handleSuccess = function(o) {

		var response = o.responseText;

		AfficherPnlReponse("Succ&egrave;s...", o.responseText);

		//document.getElementById("reponse").innerHTML = response;

		YAHOO.axeti.wait.hide();

	};

	var handleFailure = function(o) {

		AfficherPnlReponse("Erreur...", "Erreur : " + o.status);

		//alert("Échec de l'envoi: " + o.status);

		YAHOO.axeti.wait.hide();

	};



	var handleUpload = function(o) {

		var response = o.responseText;

		AfficherPnlReponse("Status de l'envoi...", response);

		//document.getElementById("reponse").innerHTML = response;

		YAHOO.axeti.wait.hide();

	};



	// Instantiate a Panel from script

	YAHOO.axeti.panelEmplois = new YAHOO.widget.Dialog("panelEmplois",

													{width:"385px",

													 visible:false,

													 fixedcenter:true,

													 zIndex:1000,

													 buttons:[{text:"Soumettre", handler:handleSubmit, isDefault:true },{ text:"Annuler", handler:handleCancel}]} );



	YAHOO.axeti.panelEmplois.setBody("<div id='panelEmplois'><form id='formEmplois' method='POST' action='php/email.php?mode=1'><input name='mode' type='hidden' value='1' /><table width='100%' border='0px'><tr><td width='23%'><span style='color:#FF0000'>*</span>Nom </td><td width='3%'>:</td><td width='74%'><input type='text' name='strname' /></td></tr><tr><td style='height:3px'></td></tr><tr><td style='height:3px'></td></tr><tr><td width='23%'><span style='color:#FF0000'>*</span>Courriel</td><td width='3%'>:</td><td width='74%'><input type='text' name='stremail' /></td></tr><tr><td style='height:3px'></td></tr><tr><td style='height:3px'></td></tr><tr><td width='23%'><span style='color:#FF0000'>*</span>CV</td><td width='3%'>:</td><td width='74%'><input type='file' name='strresume'/><input type='hidden' id='emploi_titre' name='emploi_titre' value=''/></td></tr><tr><td style='height:3px'></td></tr><tr><td style='height:3px'></td></tr><tr><td colspan='3'>Lettre de pr&eacute;sentation :</td></tr><tr><td colspan='3'><textarea name='txtPresentation' id='txtPresentation' class='mceSimple' cols='42' rows='20' dir='ltr'></textarea></td></tr><tr><td style='height:3px'></td></tr><tr><td style='height:3px'></td></tr><tr><td colspan='3'><span style='color:#FF0000'>*</span>Champs obligatoires</td></tr></table></form></div></div>");

	YAHOO.axeti.panelEmplois.render("zoneEmploiEmail");



	YAHOO.axeti.panelEmplois.render();



	// Validate the entries in the form to require that both first and last name are entered

	YAHOO.axeti.panelEmplois.validate = function() {

		var data = this.getData();

		if (data.strname == "" || data.stremail == "" || data.strresume == "")

		{

			//alert("Votre nom, votre adresse de courriel et votre CV sont obligatoires.");

			YAHOO.axeti.pnlErreurCVCarrieres.show();

			return false;

		}

		else

		{

			YAHOO.axeti.wait.show();

			return true;

		}

	};



	// Wire up the success and failure handlers

	YAHOO.axeti.panelEmplois.callback = { success: handleSuccess,

										  failure: handleFailure,

										  upload: handleUpload };
tinyMCE.init({
			mode : "textareas",
			theme : "advanced",
			theme_advanced_buttons1 : "mybutton,bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,undo,redo",
			theme_advanced_buttons2 : "",
			theme_advanced_buttons3 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom"
		});
}



YAHOO.util.Event.onAvailable("zoneEmplois", initEmailForm);



function InitialiserPnlErreurCVCarrieres()

{

	var handleYes = function() {

		YAHOO.axeti.pnlErreurCVCarrieres.hide();

	};

	

	YAHOO.axeti.pnlErreurCVCarrieres = new YAHOO.widget.SimpleDialog("erreurCVCarrieres", 

															 { width: "300px",

															   fixedcenter: true,

															   visible: false,

															   draggable: false,

															   close: true,

															   zIndex:1000,

															   text: "<span class='erreurCV'>Votre nom, votre adresse de courriel et votre CV sont obligatoires.</span>",

															   icon: YAHOO.widget.SimpleDialog.ICON_HELP,

															   constraintoviewport: true,

															   buttons: [ { text:"Fermer", handler:handleYes, isDefault:true } ]

															 } );

	YAHOO.axeti.pnlErreurCVCarrieres.setHeader("Erreur...");

	YAHOO.axeti.pnlErreurCVCarrieres.render("idErreurCVCarrieres");

}
