
// version 2008-05-26
// © Jérémie Fontana




// Affichage / Masquage Div

function div_affiche(code) {
	divEl = document.getElementById(code);
	if (divEl.style.display=="block") {
		divEl.style.display="none";
	} else {
		divEl.style.display="block";
	}
}
	
function div_cache(code) {
	divEl = document.getElementById(code);
	if (divEl.style.display=="block") {
		divEl.style.display="none";
	}
}




// Menu déroulant

function menu_ouvre(code) {
	navigation = document.getElementById(code);
	navigation.style.display="block";
}
	
function menu_ferme(code) {
	navigation = document.getElementById(code);
	if (navigation.style.display=="block") {
		navigation.style.display="none";
	}
}




// 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 +'" />\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 +'?'+ 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 +'" />\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 +'?'+ 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);




// Simple.js

function $(id){
return document.getElementById(id);
}
function STO(_24,_25){
return window.setTimeout(_24,_25);
}
function DecToHexa(_26){
var _27=parseInt(_26).toString(16);
if(_26<16){
_27="0"+_27;
}
return _27;
}
function addslashes(str){
str=str.replace(/\"/g,"\\\"");
str=str.replace(/\'/g,"\\'");
return str;
}
function $toggle(id){
if(act_height(id)==0){
$blinddown(id);
}else{
$blindup(id);
}
}
function act_height(id){
height=$(id).clientHeight;
if(height==0){
height=$(id).offsetHeight;
}
return height;
}
function act_width(id){
width=$(id).clientWidth;
if(width==0){
width=$(id).offsetWidth;
}
return width;
}
function max_height(id){
var ids=$(id).style;
ids.overflow="hidden";
if(act_height(id)!=0){
return act_height(id);
}else{
origdisp=ids.display;
origheight=ids.height;
origpos=ids.position;
origvis=ids.visibility;
ids.visibility="hidden";
ids.height="";
ids.display="block";
ids.position="absolute";
height=act_height(id);
ids.display=origdisp;
ids.height=origheight;
ids.position=origpos;
ids.visibility=origvis;
return height;
}
}
function $blindup(id,_2f){
if(!_2f){
_2f=200;
}
acth=act_height(id);
maxh=max_height(id);
if(acth==maxh){
$(id).style.display="block";
var _30;
_30=Math.ceil(_2f/acth);
for(i=0;i<=acth;i++){
newh=acth-i;
STO("$('"+id+"').style.height='"+newh+"px'",_30*i);
}
}
}
function $blinddown(id,_32){
if(!_32){
_32=200;
}
acth=act_height(id);
if(acth==0){
maxh=max_height(id);
$(id).style.display="block";
$(id).style.height="0px";
var _33;
_33=Math.ceil(_32/maxh);
for(i=1;i<=maxh;i++){
STO("$('"+id+"').style.height='"+i+"px'",_33*i);
}
}
}
function $opacity(id,_35,_36,_37){
if($(id).style.width==0){
$(id).style.width=act_width(id);
}
var _38=Math.round(_37/100);
var _39=0;
if(_35>_36){
for(i=_35;i>=_36;i--){
STO("changeOpac("+i+",'"+id+"')",(_39*_38));
_39++;
}
}else{
if(_35<_36){
for(i=_35;i<=_36;i++){
STO("changeOpac("+i+",'"+id+"')",(_39*_38));
_39++;
}
}
}
}
function $pulsate(id,num,speed){
if (!speed) speed = 300;
for(i = 1; i <= num; i++) {
numx=i*((speed*2)+100)-(speed*2);
STO("$opacity('"+id+"', 100, 0, "+speed+")",numx);
STO("$opacity('"+id+"', 0, 100, "+speed+")",numx+speed+100);
}
}
function changeOpac(_3a,id){
var ids=$(id).style;
ids.opacity=(_3a/100);
ids.MozOpacity=(_3a/100);
ids.KhtmlOpacity=(_3a/100);
ids.filter="alpha(opacity="+_3a+")";
}
function $shiftOpacity(id,_3e){
if($(id).style.opacity<0.5){
$opacity(id,0,100,_3e);
}else{
$opacity(id,100,0,_3e);
}
}
function currentOpac(id,_40,_41){
var _42=100;
if($(id).style.opacity<100){
_42=$(id).style.opacity*100;
}
$opacity(id,_42,_40,_41);
}
function $highlight(id,_44,_45,_46){
if(_44){
milli=_44;
}else{
milli=900;
}
if(_45){
endcol=_45;
}else{
endcol="#FFFFFF";
}
if(_46){
origcol=_46;
}else{
origcol="#FFFFA6";
}
$colorize(origcol,endcol,id,milli,"high");
}
function $textColor(id,_48,_49,_4a){
if(_4a){
milli=_4a;
}else{
milli=900;
}
$colorize(_48,_49,id,milli,"text");
}
function $morphColor(id,_4c,_4d,_4e,_4f,_50,_51,_52){
if(_52){
milli=_52;
}else{
milli=900;
}
$colorize(_4c,_4d,id,milli,"text");
$colorize(_4e,_4f,id,milli,"back");
if(_50!=false){
$colorize(_50,_51,id,milli,"border");
}
}
function $colorize(_53,end,id,_56,_57){
dr=parseInt(_53.substring(1,3),16);
dg=parseInt(_53.substring(3,5),16);
db=parseInt(_53.substring(5,7),16);
fr=parseInt(end.substring(1,3),16);
fg=parseInt(end.substring(3,5),16);
fb=parseInt(end.substring(5,7),16);
steps=_56/10;
cr=dr;
cg=dg;
cb=db;
sr=(fr-dr)/steps;
sg=(fg-dg)/steps;
sb=(fb-db)/steps;
var zzi=10;
for(var x=0;x<steps;x++){
color="#"+DecToHexa(cr)+DecToHexa(cg)+DecToHexa(cb);
if(x==(steps-1)){
if(_57=="high"){
color="";
}else{
color=end;
}
}
mytime=(x);
if(_57=="back"||_57=="high"){
newfonc="$(\""+id+"\").style.backgroundColor=\""+color+"\";";
}else{
if(_57=="text"){
newfonc="$(\""+id+"\").style.color=\""+color+"\";";
}else{
if(_57=="border"){
newfonc="$(\""+id+"\").style.borderColor=\""+color+"\";";
}
}
}
STO(newfonc,zzi);
cr+=sr;
cg+=sg;
cb+=sb;
zzi+=10;
}
}