function showCPR(s) {
       var y = new Date().getYear();
       if (y<1900) y+=1900;
       if (s!=y)
          document.write(s + " - " + y);
	       else
          document.write(y);
}


function isEmail(obj) {
       if (obj.value.indexOf(" ") + "" == "-1"
       && obj.value.indexOf("@") + "" != "-1"
       && (obj.value.lastIndexOf(".") > obj.value.indexOf("@"))
       && obj.value != "") return true;
       else return false;
}

function verifCode(obj) {
       return (obj.value == "") || (obj.value.length == 5 && !isNaN(obj.value));
	   //si le champ est vide, je retourne vrai (parce que ca n est pas un champ obligatoire)
	   // ou si le champ a une longueur de 5 caractères et que c'est un nombre, je returne vrai
}

function checkKeyFull(field, evt, fld, len) {
	if (checkKey(field, evt)) {
		if ((field.value).length==len) {
			eval("document." + fld + ".focus();");
		}
		return true;
	} else return false;
}

function checkKey(field, evt) {
  var keyCode = 
    document.layers ? evt.which :
    document.all ? event.keyCode :
    document.getElementById ? evt.keyCode : 0;
  //alert(keyCode);
  if ((document.all || document.getElementById) && evt.shiftKey) {
    if (keyCode == 9) return true;
	return false;
  }
  if (document.layers && evt.modifiers & event.SHIFT_MASK) {
    if (keyCode == 9) return true;
	return false;
  }
  // 0 .. 9, 0 .. 9 on right keyboard, Backspace, Tab, End, Home, Left Arrow, Right Arrow, Del button
  if ((keyCode > 47 && keyCode < 58) || (keyCode > 95 && keyCode < 106) || keyCode == 8 || keyCode == 9 || keyCode == 35 || keyCode == 36 || keyCode == 37 || keyCode == 39  || keyCode == 46) return true;
  return false;
}

function setChkBtn(fldName,setIndex,maxIndex) {
 var i, t;
 t = eval("document." + fldName + setIndex + ".checked");
 if (t) {
  for (i=1; i<=maxIndex; i++) 
   if (i!=setIndex) eval("document." + fldName + i + ".checked = false;");
 }
}
function TestParam() 
{
	var Form = document.forms["FormContact"];
	if (Form.eNom.value == "") 
		{ alert("Attention, le nom est nécessaire"); Form.eNom.focus(); return }
	if (Form.ePrenom.value == "") 
		{ alert("Attention, le prénom est nécessaire"); Form.ePrenom.focus(); return }
	if (!isEmail(Form.eEmail))
		{ alert("Merci d'indiquer un email correct"); Form.eEmail.focus(); return }	
	if (!verifCode(Form.eCodePostal))
		{ alert("Merci d'indiquer un code postal correct"); Form.eCodePostal.focus(); return }
	if (Form.eTel.value != "" && (Form.eTel.value).length!=10)
		{ alert("Attention, le téléphone est nécessaire"); Form.eTel.focus(); return }		
	if (Form.eMessage.value == "")
		{ alert("Attention, le champ 'Message' doit être renseigné."); Form.eMessage.focus();
			return }		
	Form.action = "Procs/psContact.asp";
	Form.submit();															
}

function TestParrainage() 
{
	var Form = document.forms["FormParrainage"];
	if (Form.eParNomPrenom.value == "") 
		{ alert("Attention, le nom et le prénom du parrain sont nécessaires"); Form.eParNomPrenom.focus(); return }
	if (Form.eParTelephone.value == "" || (Form.eParTelephone.value).length!=10) 
		{ alert("Attention, le téléphone du parrain est nécessaire et doit faire 10 chiffres"); Form.eParTelephone.focus(); return }
	if (!isEmail(Form.eParEmail))
		{ alert("Merci d'indiquer un email correct"); Form.eParEmail.focus(); return }	
	if (Form.eFilNomPrenom.value == "") 
		{ alert("Attention, le nom et le prénom du filleul sont nécessaires"); Form.FilNomPrenom.focus(); return }
	if (Form.eFilTelephone.value == "" || (Form.eFilTelephone.value).length!=10) 
		{ alert("Attention, le téléphone du filleul est nécessaire et doit faire 10 chiffres"); Form.eFilTelephone.focus(); return }
	
	if (Form.eFilDepartement.value == "" || isNaN(Form.eFilDepartement.value)) 
		{ alert("Attention, le département de construction est nécessaire et doit être composé de deux chiffres"); Form.eFilDepartement.focus(); return }
	Form.action = "Procs/psParrainage.asp";
	Form.submit();															
}

function TestEtudeChiffree() 
{
	var Form = document.forms["FormEtudeChiffree"];
	if (Form.eNom.value == "") 
		{ alert("Attention, le nom est nécessaire"); Form.eNom.focus(); return }
	if (Form.ePrenom.value == "") 
		{ alert("Attention, le prénom est nécessaire"); Form.ePrenom.focus(); return }
	if (!isEmail(Form.eEmail))
		{ alert("Merci d'indiquer un email correct"); Form.eEmail.focus(); return }	
	if (!verifCode(Form.eCodePostal))
		{ alert("Merci d'indiquer un code postal correct"); Form.eCodePostal.focus(); return }
	if (Form.eTel.value != "" && (Form.eTel.value).length!=10)
		{ alert("Attention, le téléphone est nécessaire"); Form.eTel.focus(); return }		
	if (Form.eMessage.value == "")
		{ alert("Attention, le champ 'Message' doit être renseigné."); Form.eMessage.focus();
			return }		
	Form.action = "Procs/psEtudeChiffree.asp";
	Form.submit();															
}

function CacheMail(mail,domain) {
 this.location = 'mailto:' + mail + '@'+ domain;
}


function RefreshCaptcha() {
	var i = new Image();
	var d = new Date();
	i.src = 'Includes/modCaptcha.asp?Type=4&Dt=' + d.getHours().toString() + d.getMinutes().toString() + d.getSeconds().toString() ;
	document.getElementById("Captcha").src =  i.src;
}

function checkEMail(strEMail) {
   if (strEMail.indexOf(" ")!=-1) return false;
   var tmpPos = strEMail.indexOf("@");
   if (tmpPos<2 || (strEMail.indexOf("@",tmpPos+1)>-1) )  return false;
   if ((strEMail.charAt(0)=='@') || (strEMail.charAt(strEMail.length-1)=='@')) return false;
   return true;
   // var goodEmail = strEMail.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
 }

function myPopup2() {
window.open( "/interview-Karl-Touzalin.asp", "myWindow", 
"scrollbars=yes,toolbar=no,menubar=no,status=no,width = 885, height=750, resizable = 0" )
}

jQuery(document).ready(
function()
{
		jQuery("#slider").wslide({
				width: 161,
				height: 220,
				pos: 1,
				autolink: 'slider-menu',
				horiz: true,
				duration: 500
		});
		jQuery("#slider02").wslide({
				width: 161,
				height: 220,
				pos: 1,
				autolink: 'slider02-menu',
				horiz: true,
				duration: 500
		});
                
                jQuery("#slider-modele").wslide({
				width: 230,
				height: 225,
				pos: 1,
				autolink: 'slider-menu-modele',
				horiz: true,
				duration: 500
		});
                
                 window.setInterval( 'ws_autostart()', 8000 );
		
		// --------------------------------------------------------------------------		 
		// Parrainage	
		// --------------------------------------------------------------------------		 
		
		// Si aucun cookie
		if ($.cookie('parrainage')==null && window.location.href.indexOf('tracking')==-1) {
			var _bg = document.createElement('div');
				_bg.style.backgroundColor = '#000000';
				_bg.style.display = 'block';
				_bg.style.position = 'absolute';
				_bg.style.zIndex = '1000';
				_bg.style.top = 0;
				_bg.style.left = 0;
				_bg.style.opacity = '0.8';
				_bg.style.filter = 'alpha(opacity=80)';
				_bg.id = 'parrainageBg';
			
			document.body.appendChild(_bg);
			
			var _img = document.createElement('img');
				_img.src = '../images/overlay/offres_emplois.png';
				_img.style.display = 'block';
				_img.style.position = 'absolute';
				_img.style.zIndex = '1001';
				_img.style.top = 0;
				_img.style.left = 0;
				_img.style.cursor = 'pointer';
				_img.id = 'parrainageImg';
				
			document.body.appendChild(_img);		

			resize();
			
			// On enregistre le cookie			
			$.cookie('parrainage', 'true');
		}
		
		$(window).resize(function() {
			if ($('#parrainageBg').css('display') == 'block') resize();
		});	
		
		$('#parrainageBg').click(function() {
			$(this).hide();
			$('#parrainageImg').hide();
		});
	
		$('#parrainageImg').click(function() {
			document.location = 'http://www.groupe-bcmi.com/contacts.asp?constructeur=0';
		});
	
		// --------------------------------------------------------------------------		 
		// Parrainage	
		// --------------------------------------------------------------------------		 

		$('.layer1 A, .layer1 IMG').click(function() {
			$('.layer2').animate({
					left: '-=350'
				}, 500, 'easeOutQuad'
			);
		});
				 
}
);

function resize() {
	var _h = $(document).height();
	var _w = $(document).width();
	
	var _bg = $('#parrainageBg');
		_bg.css('height', _h + 'px');
		_bg.css('top', 0);
		_bg.css('left', 0);
		_bg.css('width', '100%');
			
	var _h = $(window).height();
	var _w = $(window).width();
	var _l = (_w - 707) /2;
	var _t = (_h - 668) /2;
	
	var _img = $('#parrainageImg');
		_img.css('width', '707px');
		_img.css('height', '668px');
		_img.css('top', _t + 'px');
		_img.css('left', _l + 'px');
}

function ws_autostart()
{
	var current = 0;
	var nbPages = 0;
	$("#slider-menu-modele a").each(function(cpt){
		if ($(this).hasClass("wactive"))
			current = cpt +1;
			nbPages++;
	});
	if (current > 0 && current <nbPages)
	{
		$("#slider-menu-modele a:eq("+parseInt(current)+")").click();
	}
	if (current > 0 && current == nbPages)
	{
		$("#slider-menu-modele a:eq(0)").click();
	}
}
