// ----------------------------------------------------------------------------------
// Only digits in field!
// ----------------------------------------------------------------------------------
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;
}

//------------------------------------------------------------------------------------
// Script Textarea Maxlength script- © Dynamic Drive (www.dynamicdrive.com)
// This notice must stay intact for legal use.
// Visit http://www.dynamicdrive.com/ for full source code
//------------------------------------------------------------------------------------

function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}

//------------------------------------------------------------------------------------
// Script Anti-flash
//------------------------------------------------------------------------------------
function fixFlash(s) { document.write(s); }

//------------------------------------------------------------------------------------
// Script Notice légale
//------------------------------------------------------------------------------------
function showCPR(s) {
       var y = new Date().getYear();
       if (y<1900) y+=1900;
       if (s!=y)
          document.write(s + " - " + y);
	       else
          document.write(y);
}

//------------------------------------------------------------------------------------
// Fonction CacheMail
//------------------------------------------------------------------------------------

function CacheMail(mail,domain) {
	this.location = 'mailto:' + mail + '@'+ domain;
	}


//------------------------------------------------------------------------------------
// Fonction TestParam()
//------------------------------------------------------------------------------------

function isCP(obj) {
	if (isNaN(obj.value)==false && obj.value.length==5)  return true;
	else return false;
}

function isTel(obj) {
	if (isNaN(obj.value)==false && obj.value.length==10)  return true;
	else return false;
}

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 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 RefreshCaptchaEch() {
	var i = new Image();
	var d = new Date();
	i.src = 'Includes/modCaptcha-etude-chifree.asp?Type=4&Dt=' + d.getHours().toString() + d.getMinutes().toString() + d.getSeconds().toString() ;
	document.getElementById("Captcha").src =  i.src;
}


//------------------------------------------------------------------------------------
// Script Notice légale
//------------------------------------------------------------------------------------
// s est l'année de création du site.
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 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
}

// Contact Form
function TestParamContact() 
{
	var Form = document.forms["FormContact"]; //forms = tous les formulaires du document
	
	if (Form.eNom.value == "")
		{ alert("Attention, le champ 'Nom' doit être renseigné"); Form.eNom.focus(); return; }
	if (Form.ePrenom.value == "")
		{ alert("Attention, le champ 'Prénom' doit être renseigné"); Form.ePrenom.focus(); return; }
		
	if (Form.eEmail.value == "" || !isEmail(Form.eEmail))
		{ alert("Merci de renseigner le champ 'Email' correctement"); Form.eEmail.focus(); return; }	
		
	if (Form.eCodePostal.value != "" && !isCP(Form.eCodePostal))
		{ alert("Merci de renseigner le champ 'Code postal' correctement"); Form.eCodePostal.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();
}

// Contact Form "Conslut Pro"
function TestParamDemPerso() 
{
	var Form = document.forms["FormContact"]; //forms = tous les formulaires du document
	
	if (Form.eNom.value == "")
		{ alert("Attention, le champ 'Nom' doit être renseigné"); Form.eNom.focus(); return; }
	if (Form.ePrenom.value == "")
		{ alert("Attention, le champ 'Prénom' doit être renseigné"); Form.ePrenom.focus(); return; }
		
	if (Form.eEmail.value == "" || !isEmail(Form.eEmail))
		{ alert("Merci de renseigner le champ 'Email' correctement"); Form.eEmail.focus(); return; }	
		
	if (Form.eCodePostal.value != "" && !isCP(Form.eCodePostal))
		{ alert("Merci de renseigner le champ 'Code postal' correctement"); Form.eCodePostal.focus(); return; }
	
	Form.action = "/Procs/psPersonnalisee.asp";
	Form.submit();	
}

//------------------------------------------------------------------------------------
// Geolocalisation pop-ups
//------------------------------------------------------------------------------------
function openCarte(url, width, height){
  var pleft;
  pleft = 10;
  if (document.all) width = width + 20;
  if (document.all) { 
    if (width<document.body.clientWidth) pleft = (document.body.clientWidth-width)/2;
  } else { 
    if (width<window.innerWidth) pleft = (window.innerWidth-width)/2; 
  }

  window.open(url,'popup','width='+width+', height='+height+', top=10,left='+pleft+',status=yes,toolbar=no,menubar=no,location=no,scrollbars=no,directories=no,resizable=yes');
}

//------------------------------------------------------------------------------------
// Livrasion rollovers
//------------------------------------------------------------------------------------
function RollOnLivrRcol() {
		document.getElementById("livrPicRcol").src = 'Images/Content/peint-van-mover.png';
		document.getElementById("livrLnkRcol").style.textDecoration = 'underline';
	}
	
function RollOffLivrRcol() {
		document.getElementById("livrPicRcol").src = 'Images/Content/peint-van.png';
		document.getElementById("livrLnkRcol").style.textDecoration = 'none';
	}

//------------------------------------------------------------------------------------
// Produits Gallery rollovers
//------------------------------------------------------------------------------------
function RollOnProduits(id) {
		document.getElementById("imgProd"+id).src = 'Images/Content/transp-50-94x68.png';
		document.getElementById("imgProdLnk"+id).style.color = '#718504';
	}
	
function RollOffProduits(id) {
		document.getElementById("imgProd"+id).src = 'Images/Content/transp-94x68.png';
		document.getElementById("imgProdLnk"+id).style.color = '#515151';
	}
	
//------------------------------------------------------------------------------------
// Produits Gallery rollovers
//------------------------------------------------------------------------------------
function RollOnLivraison() {
		document.getElementById("livrPic").src = 'Images/Content/bus-mover.png';
		document.getElementById("livrLnk").style.textDecoration = 'underline';
	}
	
function RollOffLivraison() {
		document.getElementById("livrPic").src = 'Images/Content/bus.png';
		document.getElementById("livrLnk").style.textDecoration = 'none';
	}
	
function RollOnProdLink() {
		document.getElementById("retPic").src = 'Images/Content/paint-mover.png';
		document.getElementById("retLnk").style.textDecoration = 'underline';
	}
	
function RollOffProdLink() {
		document.getElementById("retPic").src = 'Images/Content/paint.png';
		document.getElementById("retLnk").style.textDecoration = 'none';
	}	
	
function RollOnPntLogLink() {
		document.getElementById("retPntP").src = 'Images/Content/pntr-mover.png';
		document.getElementById("retPntL").style.textDecoration = 'underline';
	}
	
function RollOffPntLogLink() {
		document.getElementById("retPntP").src = 'Images/Content/pntr.png';
		document.getElementById("retPntL").style.textDecoration = 'none';
	}	

//-------------------------------------------------------------------------------
// Fonction slider
//-------------------------------------------------------------------------------
	jQuery(document).ready(
	function()
	{
		$("div.scrollable").scrollable( { size: 7, clickable : false}); 	
		
		//Rotation du bandeau de la home
		$("#rotator").tabs({
			'fx': {opacity: "toggle"} //,
//			event : 'mouseover'
		}).tabs("rotate", 12000, true);

		// Pour chaque tab
		$(".ui-tabs-nav-item A").each(
			function(index, element) {
				// Sur le click
				$(element).click(
					function() {
						// On récupère l'attribut link
						var _link = $(element).attr('link');
						// On redirige la page vers le lien de link
						if (_link!='') location.href = _link;
					}
				)
			}
		);
		
		jQuery('.pics').cycle({ 
			fx: 'scrollHorz', 
   			delay: 500,
			speed: 400
			//easing:  'easeInOutElastic'
		});
		
		// Création des slides
		slide(1, 243);	// 243 + 15px padding
		slide(2, 243);
		// slide(3, 293);
		
//		// Positionne le menu au chargement de la page
//		positionnerMenu();
//		if(typeof(rub) != "undefined") {
//			positionnerActu(1, 386);
//			positionnerActu(2, 284);
//			positionnerActu(3, 232);
//		}
		
		jQuery(document).ready(function(){
			jQuery(".inline").colorbox({inline:true, href:"#inline_example1"});
			$(".iframe").colorbox({width:"850px", height:"670px", iframe:true});
		
		});
		
		 //Accordéon offres d'emploi
		 $('#list1a').accordion({
			autoheight: false,
			header: 'a.lienNavig',
			active : '.selected'
		});
		
	}
	);

//	// Lie la méthode resize de la fenêtre à la fonction positionnerPub
//	$(window).bind('resize',function(){
//		positionnerMenu();
//		positionnerActu(1, 386);
//		positionnerActu(2, 284);
//		positionnerActu(3, 232);
//	});
	
	// Création des slides
	function slide(item, width) {
		//Actualités emplacement 3
		$("#monslider" + item).wslide({
			width: width,
			height: 180,
			pos: 1,
			autolink: 'conteneur-menu' + item,
			horiz: true,
			duration: 500
		});		
	}
	
	// Positionne la pub
	/*function positionnerMenu() {
		// Récupère le point de l'entête (top, left)
		var _point = $('#top-menu').position();
		// Positionne en absolue la publicité
		$('#menu').css('left', _point.left + 'px');
	}*/
	
//	// Positionne la pub
//	function positionnerActu(item, width) {
//		var _point = $('#infos' + item).position();
//		if (_point != null) {
//			var _o = $('#conteneur-menu' + item);
//				_o.css('top', _point.top + 93 + 'px');
//				_o.css('left', (_point.left + width - _o.width()) + 'px');
//		}
//	}















