// ******************** HACK POSITION FIXED POUR IE6 ********************
// **********************************************************************

var LastPosY = 0;

function move_DIV() {
	var y = (ns_pos)? window.pageYOffset :
		(ie_std && ie_pos) ? Math.max(document.documentElement.scrollTop, document.body.scrollTop) :
		ie_std ? document.documentElement.scrollTop : document.body.scrollTop;
	y+=1;//	y+=10;
	if (y!=LastPosY) {
		if (window.opera) {
			document.getElementById('movelay').style.pixelTop=y;
		}
		else if (document.layers) {
			document.layers['movelay'].top=y;
		}
		else if (document.getElementById) {
			document.getElementById('movelay').style.top=y+'px';
		}
		else if (document.all) {
			document.all['movelay'].style.pixelTop=y;
		}
		LastPosY=y;
	}
	if (TimeScroll)	window.setTimeout('move_DIV()',100);
}

var TimeScroll = true;

function floatbutt() {
if(document.all){
	ns_pos = (typeof window.pageYOffset!='undefined');
	ie_std = (document.documentElement && typeof document.documentElement.scrollTop!='undefined');
	ie_pos = (document.body && typeof document.body.scrollTop!='undefined');
	window.onscroll=function(){window.onscroll=move_DIV;TimeScroll=false;};
	if (ns_pos||ie_std||ie_pos) move_DIV();
	}
}

// ******************** OMBRES DOM *************************************
// *********************************************************************

var DOMsupport = document.getElementById && document.getElementsByTagName && document.createElement;

function applyShadow(targetElement, shadowColor, swidth, smargin, sindent, salign, spad, fsiz, shadowOffset) {
  if (typeof(targetElement) != 'object') {
    targetElement = document.getElementById(targetElement);
  }
  var value = targetElement.firstChild.nodeValue;
  targetElement.style.position = 'relative';
    targetElement.style.left = '0px';
  targetElement.style.zIndex = 1;
    
  var newEl = document.createElement('span');
	newEl.appendChild(document.createTextNode(value));
	newEl.className = 'shadowed';
	newEl.style.color = shadowColor;
	newEl.style.margin = smargin;
	newEl.style.width = swidth;
	newEl.style.textIndent = sindent;
	newEl.style.textAlign = salign;
	newEl.style.fontSize = fsiz;
	newEl.style.fontFamily = 'Verdana';
	newEl.style.fontWeight = 'bold';
	newEl.style.padding = spad;
	newEl.style.position = 'absolute';
	newEl.style.left = shadowOffset + 'px';
	newEl.style.top = shadowOffset + 'px';
	newEl.style.zIndex = -1;
  
  targetElement.appendChild(newEl);
}


// ******************** GET VAR ****************************************
// *********************************************************************

	getVar = function (nomVariable) {
		var infos = location.href.substring(location.href.indexOf("?")+1, location.href.length)+"&"
		if (infos.indexOf("#")!=-1)
		infos = infos.substring(0,infos.indexOf("#"))+"&"
	var variable=0
	{
		nomVariable = nomVariable + "="
		var taille = nomVariable.length
			if (infos.indexOf(nomVariable)!=-1)
			variable = infos.substring(infos.indexOf(nomVariable)+taille,infos.length).substring(0,infos.substring(infos.indexOf(nomVariable)+taille,infos.length).indexOf("&"))
	}
	return variable
}


// ******************** GETELEMENTSBYCLASSNAME **************************
// **********************************************************************

		function getElementsByClassName(oElm, strTagName, oClassNames){
			var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
			var arrReturnElements = new Array();
			var arrRegExpClassNames = new Array();
			if(typeof oClassNames == "object"){
				for(var i=0; i<oClassNames.length; i++){
					arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
				}
			}
			else{
				arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
			}
			var oElement;
			var bMatchesAll;
			for(var j=0; j<arrElements.length; j++){
				oElement = arrElements[j];
				bMatchesAll = true;
				for(var k=0; k<arrRegExpClassNames.length; k++){
					if(!arrRegExpClassNames[k].test(oElement.className)){
						bMatchesAll = false;
						break;
					}
				}
				if(bMatchesAll){
					arrReturnElements.push(oElement);
				}
			}
			return (arrReturnElements)
		}
/*
function x() {
var myArray = getElementsByClassName(document, "p", "first-letter");
for ( var i=0, len=myArray.length; i<len; ++i ){
// myArray[i].style.MozOpacity= '0.7';
 myArray[i].style.color= '#000000';
	}
}
*/

// ******************** DETECTION VERSION IE ****************************
// **********************************************************************


  var rv = -1;
function getIEVersion(){
  if (navigator.appName == 'Microsoft Internet Explorer') {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 ); }
  return rv}

	getIEVersion();
// if (rv >= 5) etc...


// ******************** mesirer tailles de la fenetre *******************
// **********************************************************************

var theWidth, theHeight;

function mesurage() {

if (window.innerWidth)
theWidth=window.innerWidth;
else if (document.documentElement && document.documentElement.clientWidth)
theWidth=document.documentElement.clientWidth;
else if (document.body)
theWidth=document.body.clientWidth;

if (window.innerHeight)
theHeight=window.innerHeight;
else if (document.documentElement && document.documentElement.clientHeight)
theHeight=document.documentElement.clientHeight;
else if (document.body)
theHeight=document.body.clientHeight;

	voirFenetre = function () {window.alert('L fenetre = '+ theWidth +' et H fenetre = '+ theHeight)};

//arraytheWidththeHeight = new Array(theWidth,theHeight);
//return arraytheWidththeHeight;

}


// ******************** calcul hauteur totale de la page ****************
// **********************************************************************

function getPageSizeWithScroll(){
//mesurage();
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}

//	alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
//	alert(yWithScroll)

	var taquet = document.getElementById('pushtop');
	if(taquet) {if ((rv > 0) && (rv <= 6)) {taquet.style.top = yWithScroll - theHeight +10 + 'px'} else
	{taquet.style.top = yWithScroll - theHeight + 'px'}};
	
		voirPage = function () {window.alert('L Page = '+ xWithScroll +' et H Page = '+ yWithScroll)};

//	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
//	return arrayPageSizeWithScroll;

}


// ******************** mesurer tailles de la fenetre *******************
// **********************************************************************

//	getIEVersion();
	var path; 
	if (rv > 0) {path = 'designie/'} else {path = 'design/'};

	var styl_1, styl_2, styl_3, styl_4;

 minS=function() {	if (styl_1) styl_1.remove();
	new Asset.css(path + 'styl1.css', {id: 'styl1'});
	styl_1 = $('styl1');}

 medS=function() {	if (styl_2) styl_2.remove();
	new Asset.css(path + 'styl2.css', {id: 'styl2'});
	styl_2 = $('styl2');}

 larS=function() {	if (styl_3) styl_3.remove();
	new Asset.css(path + 'styl3.css', {id: 'styl3'});
	styl_3 = $('styl3');}

 maxS=function() {	if (styl_4) styl_4.remove();
	new Asset.css(path + 'styl4.css', {id: 'styl4'});
	styl_4 = $('styl4');}


function adaptpage() {

	if (theWidth <= 1000) {minS()}; // 
	if ((theWidth > 1000) && (theWidth <= 1250)) {medS()}; // seuil réel : 1214
	if (theWidth > 1250) {larS()}; // seuil réel : 1413
}

window.addEvent('domready', function(){

	var path; 
	if (rv > 0) {path = 'designie/'} else {path = 'design/'};

	var styl_1, styl_2, styl_3, styl_4;

 minS=function() {	if (styl_1) styl_1.remove();
	new Asset.css(path + 'styl1.css', {id: 'styl1'});
	styl_1 = $('styl1');}

 medS=function() {	if (styl_2) styl_2.remove();
	new Asset.css(path + 'styl2.css', {id: 'styl2'});
	styl_2 = $('styl2');}

 larS=function() {	if (styl_3) styl_3.remove();
	new Asset.css(path + 'styl3.css', {id: 'styl3'});
	styl_3 = $('styl3');}

 maxS=function() {	if (styl_4) styl_4.remove();
	new Asset.css(path + 'styl4.css', {id: 'styl4'});
	styl_4 = $('styl4');}

$$('.scroll').each(function(el, i){
var VoirFx = new Fx.Style(el, 'opacity', {wait: false,duration: 750,transition: Fx.Transitions.Quart.easeInOut});
el.addEvent('mouseover', function() { VoirFx.start(1, 0.1);});
el.addEvent('mouseout', function() { VoirFx.start(0.1, 1);});
});

});


//----------------------------------------------------------------------------
// BORDURES CLIGNOTANTES.
//----------------------------------------------------------------------------

var imgList = [];

function createImgList() {
	// create an array of images to apply the border effect
	var imgs = document.body.getElementsByTagName("ins");
	for (var i=0; i < imgs.length; i++) {
		if (imgs[i].className == "border0") {
			imgList.push(imgs[i]);
		}
	}
	borderchange(1);
}

function borderchange(n) {
	for (var i=0; i < imgList.length; i++) {
		imgList[i].className = "border" + n;
	}
	setTimeout(function () {borderchange(Math.abs(n-1));},1000);
}

