


// Flash

function flash(nom, width, height, flashvar) {
	var NomF= nom;
	var WidthF = width;
	var HeightF = height;
	var FlashVarF = flashvar;
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ WidthF +'" height="'+ HeightF +'" id="'+ NomF +'">\n');
	document.write('<param name=movie value="'+ NomF +'.swf" />\n');
	document.write('<param name=quality value=high />\n');
	document.write('<param name="width" value="'+ WidthF +'" />\n');
	document.write('<param name="height" value="'+ HeightF +'" />\n');
	document.write('<param name="FlashVars" value="'+ FlashVarF +'" />\n');
	document.write('<embed src="'+ NomF +'.swf?'+ FlashVarF +'" FlashVars="'+ FlashVarF +'" quality="high" width="'+ WidthF +'" height="'+ HeightF +'" name="'+ NomF +'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ></embed>\n');
	document.write('</object>\n');
	}

function flash2(nom, width, height, flashvar) {
	var NomF= nom;
	var WidthF = width;
	var HeightF = height;
	var FlashVarF = flashvar;
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ WidthF +'" height="'+ HeightF +'" id="'+ NomF +'">\n');
	document.write('<param name="movie" value="'+ NomF +'.swf" />\n');
	document.write('<param name="quality" value=high />\n');
	document.write('<param name="width" value="'+ WidthF +'" />\n');
	document.write('<param name="height" value="'+ HeightF +'" />\n');
	document.write('<param name="wmode" value="transparent" />\n');
	document.write('<param name="FlashVars" value="'+ FlashVarF +'" />\n');
	document.write('<embed src="'+ NomF +'.swf?'+ FlashVarF +'" FlashVars="'+ FlashVarF +'" quality="high" width="'+ WidthF +'" height="'+ HeightF +'" name="'+ NomF +'" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ></embed>\n');
	document.write('</object>\n');
	}



// Validation du formulaire

function MM_findObj(n, d) {
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() {
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
	if (val) { nm=val.name; if ((val=val.value)!="") {
	if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
	if (p<1 || p==(val.length-1)) errors+='- le champ E-mail doit contenir une adresse e-mail valide.\n\n';
	} else if (test!='R') { num = parseFloat(val);
	if (isNaN(val)) errors+='- le champ '+nm+' doit être un numéro.\n\n';
	if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
	min=test.substring(8,p); max=test.substring(p+1);
	if (num<min || max<num) errors+='- le champ '+nm+' doit contenir un numéro entre '+min+' et '+max+'.\n\n';
	} } } else if (test.charAt(0) == 'R') errors += '- le champ '+nm+' doit être rempli.\n\n'; }
	} if (errors) alert('Erreur :\n\n'+errors);
	document.MM_returnValue = (errors == '');
}



// Validation de l'antispam

var CTK_ANTISPAM_CONF = {urlPCheckName:'ctkas', urlPCheckdefaultValue:'oki', ctrlErrorMessage:"Attention!\nLe code de sécurité que vous avez entré dans la zone anti-spam n'est pas correcte...\nMerci de rectifier votre formulaire."};
	if( (location.search).indexOf('?') != -1 ) {
		var query = location.search.substring(1,location.search.length) + "&check=1";
		var params=[];
		params = query.split('&');
		for(p=0;p<params.length;p++) {
			pName = params[p].substring(0, params[p].indexOf("="));
			pValue = params[p].substring(params[p].indexOf("=")+1, params[p].length);
			if ( pName == CTK_ANTISPAM_CONF.urlPCheckName ) { 
				if (pValue!=CTK_ANTISPAM_CONF.urlPCheckdefaultValue) {
					alert(CTK_ANTISPAM_CONF.ctrlErrorMessage);
				}
			}
		}
	}



// Pop-up centré

function ouvrir(l,h,url) {
	largeur=Math.round((screen.availWidth-l)/2);
	hauteur=Math.round((screen.availHeight-h)/2);
	window.open(""+url+"","","toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,menubar=0,top="+hauteur+",left="+largeur+",width="+l+",height="+h);
}



// Pop-up

function popup(WinURL,WinName,WinFeat) {
		window.open(WinURL,WinName,WinFeat);
	}



// Scroll

var ss = {
  fixAllLinks: function() {
    var allLinks = document.getElementsByTagName('a');
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if ((lnk.href && lnk.href.indexOf('#') != -1) && 
          ( (lnk.pathname == location.pathname) ||
	    ('/'+lnk.pathname == location.pathname) ) && 
          (lnk.search == location.search)) {
        ss.addEvent(lnk,'click',ss.smoothScroll);
      }
    }
  },

  smoothScroll: function(e) {
    if (window.event) {
      target = window.event.srcElement;
    } else if (e) {
      target = e.target;
    } else return;

    if (target.nodeName.toLowerCase() != 'a') {
      target = target.parentNode;
    }
  
    if (target.nodeName.toLowerCase() != 'a') return;
  
    anchor = target.hash.substr(1);
    var allLinks = document.getElementsByTagName('a');
    var destinationLink = null;
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if (lnk.name && (lnk.name == anchor)) {
        destinationLink = lnk;
        break;
      }
    }
    if (!destinationLink) destinationLink = document.getElementById(anchor);

   	if (!destinationLink) return true;
  
    var destx = destinationLink.offsetLeft; 
    var desty = destinationLink.offsetTop;
    var thisNode = destinationLink;
    while (thisNode.offsetParent && 
          (thisNode.offsetParent != document.body)) {
      thisNode = thisNode.offsetParent;
      destx += thisNode.offsetLeft;
      desty += thisNode.offsetTop;
    }
  
    clearInterval(ss.INTERVAL);
  
    cypos = ss.getCurrentYPos();
  
    ss_stepsize = parseInt((desty-cypos)/ss.STEPS);
    ss.INTERVAL =
setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);
  
    if (window.event) {
      window.event.cancelBubble = true;
      window.event.returnValue = false;
    }
    if (e && e.preventDefault && e.stopPropagation) {
      e.preventDefault();
      e.stopPropagation();
    }
  },

  scrollWindow: function(scramount,dest,anchor) {
    wascypos = ss.getCurrentYPos();
    isAbove = (wascypos < dest);
    window.scrollTo(0,wascypos + scramount);
    iscypos = ss.getCurrentYPos();
    isAboveNow = (iscypos < dest);
    if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
      window.scrollTo(0,dest);
      clearInterval(ss.INTERVAL);
      location.hash = anchor;
    }
  },

  getCurrentYPos: function() {
    if (document.body && document.body.scrollTop)
      return document.body.scrollTop;
    if (document.documentElement && document.documentElement.scrollTop)
      return document.documentElement.scrollTop;
    if (window.pageYOffset)
      return window.pageYOffset;
    return 0;
  },

  addEvent: function(elm, evType, fn, useCapture) {
    if (elm.addEventListener){
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent){
      var r = elm.attachEvent("on"+evType, fn);
      return r;
    } else {
      alert("Handler could not be removed");
    }
  } 
}

ss.STEPS = 25;

ss.addEvent(window,"load",ss.fixAllLinks);
