//------------------------------------------------------------------------------------
// 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);
}

//------------------------------------------------------------------------------------
// Script Anti-flash
//------------------------------------------------------------------------------------
function fixFlash(s) { document.write(s); }

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 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 toFieldLen(val, fld, len) {
  if (val.length==len) {
	eval("document." + fld + ".focus();");
  }
}

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 TestParamDevis(Form) 
{
	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 (Form.eTel.value != "" && (Form.eTel.value).length!=10)
		{ alert("Merci d'indiquer un téléphone correct"); Form.eTel.focus(); return }
	if (!isEmail(Form.eEmail))
		{ alert("Merci d'indiquer un E-mail correct"); Form.eEmail.focus(); return }
	if (Form.eCodePostal.value != "" && !verifCode(Form.eCodePostal))
		{ alert("Merci d'indiquer un code postal correct"); Form.eCodePostal.focus(); return }
	if (Form.eNatProjet.value == "") 
		{ alert("Attention, le Nature du projet est nécessaire"); Form.eNatProjet.focus(); return }
	if (Form.eComment.value=="")
		{ alert("Attention, le Message est nécessaire"); Form.eComment.focus(); return }
	if (Form.eCaptcha.value == "")
		{ alert("Merci de saisir les caractères indiqués par l'image"); Form.eCaptcha.focus(); return; }
	Form.submit();															
}

function TestParam(Form) 
{
	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 (Form.eTel.value != "" && (Form.eTel.value).length!=10)
		{ alert("Merci d'indiquer un téléphone correct"); Form.eTel.focus(); return }
	if (!isEmail(Form.eEmail))
		{ alert("Merci d'indiquer un E-mail correct"); Form.eEmail.focus(); return }
	if (Form.eCodePostal.value != "" && !verifCode(Form.eCodePostal))
		{ alert("Merci d'indiquer un code postal correct"); Form.eCodePostal.focus(); return }
	if (Form.eComment.value=="")
		{ alert("Attention, le Message est nécessaire"); Form.eComment.focus(); return }
	if (Form.eCaptcha.value == "")
		{ alert("Merci de saisir les caractères indiqués par l'image"); Form.eCaptcha.focus(); return; }
	Form.submit();															
}

function TestParamAmi(Form) 
{
	if (!isEmail(Form.eEmail))
		{ alert("Merci d'indiquer un E-mail correct"); Form.eEmail.focus(); return }
	if (!isEmail(Form.eEmailAmi))
		{ alert("Merci d'indiquer un 'L'e-mail de votre ami' correct"); Form.eEmailAmi.focus(); return }
	if (Form.eCaptcha.value == "")
		{ alert("Merci de saisir les caractères indiqués par l'image"); Form.eCaptcha.focus(); return; }
	Form.submit();															
}

function swapint(id) {
  var tmp;
  if (document.all) tmp = document.all(id).style.display;
     else tmp = document.getElementById(id).style.display;
  //alert(tmp);
  if (tmp=="none") {
   if (document.all) document.all(id).style.display = "block";
     else document.getElementById(id).style.display = "block";
  } else {
   if (document.all) document.all(id).style.display = "none";
     else document.getElementById(id).style.display = "none";
  }
}

//------------------------------------------------------------------------------------
// Fonction CacheMail
//--------------------------------------------------------------------------------
function CacheMail(mail,domain) {
 this.location = 'mailto:' + mail + '@'+ domain;
}

//-------------------------------------------------------------------------------
// Fonction Captcha()
//-------------------------------------------------------------------------------
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() ;
	var obj;
    if (document.all) obj = document.all("Captcha");
	 else obj = document.getElementById("Captcha");
	obj.src = i.src;
	//$('Captcha').src =  i.src;
}

function onLoadFunc() {
  document.getElementById('tbl1').style.height = document.getElementById('cell1').offsetHeight+"px";
}

function openPopup(url, width, height, scrollbars, resizeable){
  if (document.all) posX = (document.body.clientWidth-width)/2;
   else { posX = (window.innerWidth-width)/2; }
  if (document.all) heightA = document.body.clientHeight;
   else heightA = window.innerHeight;
  if (heightA < height) height = heightA;
  window.open(url,'popup','top=20, left='+ posX + ', width='+width+', height='+height+', scrollbars='+scrollbars+', resizeable='+resizeable+'')
}

function printImage(id) {
var url = "print.asp?id=" + id;
window.open(url, "printWindow", "status = 1, height = 637, width = 851, resizable = 0" );
}

var partCurIndex = 0;
// TIMER
function runLogoSlide() {
   setTimeout("changeLogo()",5000); // 5 sec.
}

function changeLogo() {
	partCurIndex++;
	if (partCurIndex>=partIndex) partCurIndex = 0;
	var obj = document.getElementById("logoPart");
	obj.src = "/Upload/Partenaires/" + arrPartLogo[partCurIndex];
	obj.alt = arrPartTitle[partCurIndex];
    setTimeout("changeLogo()",5000); // 5 sec.
}


