// JavaScript Document

function scrollTopWin(){
	window.scrollTo(0,0);
}

function Supprime(url,tx){
	if (confirm(tx)) {
		document.location.href = url;
	}
}


function Imprime(){
	window.print();
}

function EnvoiForm(){
	document.rechoffre.submit();
}

function verifAboForm(){
	document.abonnement.submit();
}

function SwitchFormulaire(moi){
	if(document.getElementById("postuler").style.display=="none"){
		document.getElementById("postuler").style.display="block";
	}else{
		document.getElementById("postuler").style.display="none";
	}
}

function SwitchEnvoiAmi(moi){
	if(document.getElementById("envoiami").style.display=="none"){
		document.getElementById("envoiami").style.display="block";
	}else{
		document.getElementById("envoiami").style.display="none";
	}
}

function verifForm(formId) {
	
	var errors = '';
	var form = document.getElementById(formId);

	switch(formId) {
		case "postuler":
			if (form.can_nom.value == '') { errors+=" - Le champ nom doit être renseigné.\n"; }
			if (form.can_prenom.value == '') { errors+=" - Le champ prénom doit être renseigné.\n";}
			if (form.can_adresse.value == '') { errors+=" - Le champ adresse doit être renseigné.\n";}
			if (form.can_code_postal.value == '') { errors+=" - Le champ code postal doit être renseigné.\n"; }
			if (form.can_ville.value == '') { errors+=" - Le champ ville doit être renseigné.\n"; }
			if (form.can_pays.value == '') { errors+=" - Le champ pays doit être renseigné.\n"; }
			if (form.can_email.value == '') { errors+=" - Le champ e-mail doit être renseigné.\n"; }
			if (form.can_cv.value == '') { errors+=" - Vous devez ajouter votre CV.\n"; }
			if (form.can_lettre_motiv.value == '') { errors+=" - Vous devez ajouter votre lettre de motivation.\n"; }			
			else if (!verifmail(form.can_email.value)){ errors+=" - Le champ e-mail doit être une adresse valide.\n"; }
			if (form.can_date_naiss.value != '') {
				if (form.can_date_naiss.value.substring(2,3) != '/' && form.can_date_naiss.value.substring(5,6) != '/') 
					errors+=" - Le champ date de naissance doit être au format JJ/MM/AAAA.\n";
				else if (form.can_date_naiss.value.length != 10)
					errors+=" - Le champ date de naissance doit être au format JJ/MM/AAAA.\n";
			}
		break;
	}

	if (errors != '') {
		alert ('Les éléments suivant requierent votre attention: \n'+errors);
	}
	else {
		form.submit();
	}
}

function protectmail(origine,lien){
	
	learo="benjaminsisko";
	lepoint="jonathanarcher";
	origine=origine.split(learo);
	origine = origine[0]+"@"+origine[1];
/*
	origine[0]+="@";
	origine=origine[0].concat(origine[1]);
	
/*
origine=origine.split(lepoint);
	origine[0]+=".";
	origine=origine[0].concat(origine[1]);
	*/
	if(lien){
		return '<a href="mailto:'+origine+'">'+lien+'</a>';
	}else{
		return '<a href="mailto:'+origine+'">'+origine+'</a>';
	}
}

function GoTo(url){
	document.location.href = url;
}

function show_image(adresse,largeur,hauteur,couleur,zeangle){
	if(zeangle){
		adresse = "imgs/image.swf?fichier="+adresse+"&angleimg="+zeangle;
	}else{
		adresse = "imgs/image.swf?fichier="+adresse;
	}
	if(couleur){ adresse += "&couleur="+couleur }
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+largeur+'" height="'+hauteur+'" id="image" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="allowFullScreen" value="false" />');
	document.write('<param name="movie" value="'+adresse+'" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="scale" value="exactfit" />');
	document.write('<param name="salign" value="lt" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="'+adresse+'" quality="high" scale="exactfit" salign="lt" bgcolor="#ffffff" width="'+largeur+'" height="'+hauteur+'" name="image" align="middle" allowScriptAccess="sameDomain" wmode="transparent" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

function show_flash(adresse,largeur,hauteur){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+largeur+'" height="'+hauteur+'" id="image" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="allowFullScreen" value="false" />');
	document.write('<param name="movie" value="'+adresse+'" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="scale" value="exactfit" />');
	document.write('<param name="salign" value="lt" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="'+adresse+'" quality="high" scale="exactfit" salign="lt" bgcolor="#ffffff" width="'+largeur+'" height="'+hauteur+'" name="image" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

function ShowSlide(){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" name="slideshow" width="262" height="197" id="slideshow">');
    document.write('<param name="movie" value="slideshow.swf?xml_source=util/slide.php"/>');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="bgcolor" value="#ffffff" />');
    document.write('<param name="wmode" value="transparent" />');
    document.write('<param name="allowScriptAccess" value="sameDomain" />');
    document.write('<embed src="slideshow.swf?xml_source=util/slide.php" quality="high" wmode="transparent" bgcolor="#ffffff" width="262" height="197" name="slideshow" allowscriptaccess="sameDomain" swliveconnect="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>');
    document.write('</object>');
}

function SendAmi(){
	if(document.getElementById('sendaminom').value!="" && document.getElementById('sendamiprenom').value!="" && document.getElementById('sendamimail').value!="" && verifmail(document.getElementById('sendamimail').value)){
		document.envoiami.submit();
	}
		
}



function verifmail(adrr){
	 var reg= /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
	 if(reg.test(adrr)==true) return true;
	 else return false;  
}


