// JavaScript Document
window.addEvent('domready', function(){
	MM_preloadImages('../images/menu01_o.gif','../images/menu02_o.gif','../images/menu03_o.gif','../images/menu04_o.gif','../images/menu05_o.gif','../images/ico_flagEn_o.jpg','../images/ico_flagSpain_o.jpg','../images/ico_flagBelgium_o.jpg');
	hoverImages('.menu img');
	hoverImages('.footerlinks img');
	clearFooterInput();
	if ($('mediacont')) {showtemoi(0,'cont16');}
	if ($('hold')) {initScrollLayer();}
	if ($('hold2')) initScrollLayer2();
	if ($('hold3')) initScrollLayer3();
	if ($('hold4')) initScrollLayer4();
	if ($('hold5')) initScrollLayer5();
	//shplusprod(0,'.cont18','.cont18desc');	
	if ($('lyr2')) {initcolor("#lyr2", "plcRoot_Layout_CMSWebPartZoneMainContent_CP_KitchenProductDetailASCX_imgMatertialImage");}
	if ($('lyr3')) {initcolor("#lyr3", "plcRoot_Layout_CMSWebPartZoneMainContent_CP_KitchenProductDetailASCX_imgMatertialImage");}
    //if ($('lyr4')) {initcolor("#lyr4", "plcRoot_Layout_CMSWebPartZoneMainContent_CP_BathroomDetailASCX_imgMatertialImage");}
    //if ($('lyr5')) {initcolor("#lyr5", "plcRoot_Layout_CMSWebPartZoneMainContent_CP_BathroomDetailASCX_imgMatertialImage");}
	hideallelements('.submenu');
	//shelement('smenu01');
  /*Opacity animate on Homepage*/
  	var fadeFxIm=new Array();
	var IncNumImg=0;
	$$('#t1 div').each(function(liImg) { // try also: $$('.learn img').each(function(liImg)	
		liImg.MyNum=IncNumImg++;
		fadeFxIm[liImg.MyNum] = new Fx.Style(liImg, 'opacity', {duration: 300}).set(1);
			liImg.addEvents({
			'mouseover':function(){
				fadeFxIm[this.MyNum].start(0.6);
			},
			'mouseout': function(){		
				fadeFxIm[this.MyNum].stop();
				fadeFxIm[this.MyNum].start(1);
			 }
			});
	});
	
  /*Opacity animate on interm_electro*/
  	var fadeFxIm2=new Array();
	var fadeFxLink=new Array();
	var IncNumImg2=0;
	$$('.cont13 img').each(function(liImg) { // try also: $$('.learn img').each(function(liImg)	
		liImg.MyNum=IncNumImg2++;
		//$$('.cont13 .lnk01')[liImg.MyNum].style.display="none";
		fadeFxIm2[liImg.MyNum] = new Fx.Style(liImg, 'opacity', {duration: 250}).set(0.5);		
		fadeFxLink[liImg.MyNum] = new Fx.Style($$('.cont13 .lnk01')[liImg.MyNum], 'opacity', {duration: 250}).set(0);		
			liImg.addEvents({
			'mouseover':function(){
				fadeFxIm2[this.MyNum].start(1);
				fadeFxLink[this.MyNum].start(1);
				//$$('.cont13 .lnk01')[this.MyNum].style.display="block";
			},
			'mouseout': function(){		
				fadeFxIm2[this.MyNum].stop();
				fadeFxLink[this.MyNum].stop();
				fadeFxIm2[this.MyNum].start(0.5);
				fadeFxLink[this.MyNum].start(0);
				//$$('.cont13 .lnk01')[this.MyNum].style.display="none";
			 }
			});		
	});
	changebgd (".imcate01",".lnkcate01","url(images/bgd_cate01_n.png)","url(images/bgd_cate01_o.png)");
	changebgd (".imcate02",".lnkcate02","url(images/bgd_cate02_n.png)","url(images/bgd_cate02_o.png)");
	changebgd (".imcate03",".lnkcate03","url(images/bgd_cate03_n.png)","url(images/bgd_cate03_o.png)");
	changebgd (".imcate04",".lnkcate04","url(images/bgd_cate04_n.png)","url(images/bgd_cate04_o.png)");
	changebgd (".lnkcate05",".lnkcate05","url(images/ico_plus_n.png)","url(images/ico_plus_o.png)");
		/**
	 * Default options for that one, except the origin. Getting the coordinates for the
	 * <img> element inside allows a correct positioning for the remooz clone-box.
	 * (Mainly becaue the <a> element is not exactly wrapped around the image)
	 */
 
   $$('.bloc12 a').each(function(element) {
        // Constructor, takes the element and options as arguments
        new ReMooz(element, {
            centered: false, // Zoom the center of the screen
            origin: element.getElement('img') // Take the image inside as origin for the zooming element
        });
    });

   $$('.bloc08 a').each(function(element) {
        // Constructor, takes the element and options as arguments
        new ReMooz(element, {
            centered: false, // Zoom the center of the screen
            origin: element.getElement('img') // Take the image inside as origin for the zooming element
        });
    });
	
	/*Random Engagements*/
	var amImg = [new Array("images/im_engagement07.gif", "shelement2('item6')", "location.href='Commitment.aspx?CommitmentID=14'"),new Array("images/im_engagement08.gif", "shelement2('item7')", "location.href='Commitment.aspx?CommitmentID=18'"),new Array("images/im_engagement09.gif", "shelement2('item8')", "location.href='Commitment.aspx?CommitmentID=19'"),new Array("images/im_engagement10.gif", "shelement2('item9')", "location.href='Commitment.aspx?CommitmentID=20'")];
//	var amImg = ['images/im_engagement07.gif','images/im_engagement08.gif','images/im_engagement09.gif','images/im_engagement10.gif'];
	timelyImg();

	function timelyImg() {
		var timenow = new Date(); var time = timenow.getHours();
		var src = amImg.getRandom(); // (time == 0 || time > 0 && time < 10) ? amImg.getRandom() : pmImg.getRandom();
		if ($('imengage')){
			$('imengage').setProperty('src',src[0]);
			if(window.location.pathname.substring(window.location.pathname.lastIndexOf("/")) == "/Commitment.aspx")
			{
				$('imengage').setProperty('onClick',src[1]);
				$('Engagement_lnk').setProperty('onClick', src[1]);
			}
			else{
				$('imengage').setProperty('onClick',src[2]);
				$('Engagement_lnk').setProperty('onClick', src[2]);
			}
		}
		setTimeout(timelyImg,4000);
	}

});

function initcolor(id, replaceim) {
	var srcImg=$(replaceim);
	if (srcImg == undefined)	
	    srcImg = $("plcRoot_Layout_CMSWebPartZoneMainContent_CP_BathroomDetailASCX_imgMatertialImage");
	$$(id+' a').each(function(alink) { 
			alink.addEvents({
			'click':function(){
				//alert (this.href);
				srcImg.src=this.title;
				srcImg.width="105";
				srcImg.height="154";
			}
			});
	});
	
}

function showid (id, lnkid) {
	$(id).style.display="block";
	$(lnkid).style.fontWeight="bold";	
}

function hideid (id, lnkid) {
	$(id).style.display="none";
	$(lnkid).style.fontWeight="normal";
}



function shplusprod (id, arrim, arrdesc) {
    //alert("OK0");
    for(i=0; i<$$(arrim).length; i++) {		
		$$(arrim)[i].style.display="none";
	}    
	for(i=0; i<$$(arrdesc).length; i++) {		
		$$(arrdesc)[i].style.display="none";
	}
	$$(arrdesc)[id].style.display="block";
	if (id < 5)
	{
	    stopVideo('videoproduct');
	}
	if (id >= 5)
	{
	    $$(arrim)[5].style.display="block";	    
	    switch(id)	    
	    {
	        case 5:
	        {
	            playVideo('flv/MeublesdAngles.flv', 'videoproduct');
	            break;
	        }
	        case 6:
	        {
	            playVideo('flv/Tiroirs.flv', 'videoproduct');
	            break;
	        }
	        case 7:
	        {
	            playVideo('flv/Rangements.flv', 'videoproduct');
	            break;
	        }
	        case 8:
	        {
	            playVideo('flv/Qualite.flv', 'videoproduct');
	            break;
	        }
	    }
	}
	else
	{
	    $$(arrim)[id].style.display="block";
	}		
	initSmScroller(".smScrollContent7","smScroller7");
	//alert("OK1");
}


function showtemoi (arrid, arrtemoi) {
	hideallelements('.'+arrtemoi+' div');
	$$('.'+arrtemoi+' div')[arrid].style.display="block";	
	for (i=0; i<$$('.ulist04 a').length; i++) {
		$$('.ulist04 a')[i].style.color="#6d6c6c";
	}
	$$('.ulist04 a')[arrid].style.color="#cc3300";
}

function changebgd (clkobj, bgdobj, curim , changeim) {
	$$(clkobj).addEvents({
		'mouseover':function(){
			$$(bgdobj)[0].style.background=changeim;
		},
		'mouseout': function(){		
			$$(bgdobj)[0].style.background=curim;
		 }
	});
}

function hideallelements(param1) {
	for(i=0; i<$$(param1).length; i++) {
		$$(param1)[i].style.display="none";
	}
}

function shelement(menuid) {
	hideallelements('.submenu');
	$(menuid).style.display="block";
}

function shelement2(contid) { /*fiche engagement*/
	hideallelements('.cont08');
	$(contid).style.display="block";
}
var IncNumImg2=0;
function hilielement(objects, mclass) {
	$$(objects).each(function(mobj) { // try also: $$('.learn img').each(function(liImg)	
		mobj.MyNum=IncNumImg2++;
		mobj.addEvents({
		'click':function(){		
			for(i=0; i<$$(objects).length; i++) {
				$$(objects)[i].className="nornav";
			}	
			mobj.className=mclass;
		}
		});
	});
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function initScrollLayer() {
  // arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll, 
  // if horizontal scrolling, id of element containing scrolling content (table?)
  var wndo = new dw_scrollObj('wn', 'lyr1', 't1');
  // pass id's of any wndo's that scroll inside tables
  // i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');
  dw_scrollObj.GeckoTableBugFix('wn'); 	  $$('.leftarrow')[0].style.display="none";
	wndo.on_scroll = function() {$$('.leftarrow')[0].style.display="block"; $$('.rightarrow')[0].style.display="block";}
	wndo.on_scroll_start = function() {}
	wndo.on_scroll_end = function() {
		if(this.x==0) {
			$$('.rightarrow')[0].style.display="block";
			$$('.leftarrow')[0].style.display="none";
		}else if (this.x<0) {
			$$('.rightarrow')[0].style.display="none";
		}
	
	}
}

function initScrollLayer2() {
  // arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll, 
  // if horizontal scrolling, id of element containing scrolling content (table?)
  var wndo = new dw_scrollObj('wn2', 'lyr2', 't2');
  // pass id's of any wndo's that scroll inside tables
  // i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');
  dw_scrollObj.GeckoTableBugFix('wn2'); 	  $$('.leftarrow2')[0].style.display="none";

  	check12clrs('lyr2','.rightarrow2');

	wndo.on_scroll = function() {$$('.leftarrow2')[0].style.display="block"; $$('.rightarrow2')[0].style.display="block";}
	wndo.on_scroll_start = function() {}
	wndo.on_scroll_end = function() {
		if(this.x==0) {
			$$('.rightarrow2')[0].style.display="block";
			$$('.leftarrow2')[0].style.display="none";
		}else if (this.x<0) {
			$$('.rightarrow2')[0].style.display="none";
		}
	
	}

}

function initScrollLayer3() {
  // arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll, 
  // if horizontal scrolling, id of element containing scrolling content (table?)
  var wndo = new dw_scrollObj('wn3', 'lyr3', 't3');
  // pass id's of any wndo's that scroll inside tables
  // i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');
  dw_scrollObj.GeckoTableBugFix('wn3'); 	  $$('.leftarrow3')[0].style.display="none";
  
  check12clrs('lyr3','.rightarrow3');
	wndo.on_scroll = function() {$$('.leftarrow3')[0].style.display="block"; $$('.rightarrow3')[0].style.display="block";}
	wndo.on_scroll_start = function() {}
	wndo.on_scroll_end = function() {
		if(this.x==0) {
			$$('.rightarrow3')[0].style.display="block";
			$$('.leftarrow3')[0].style.display="none";
		}else if (this.x<0) {
			$$('.rightarrow3')[0].style.display="none";
		}
	}
}

function initScrollLayer4() {
  // arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll, 
  // if horizontal scrolling, id of element containing scrolling content (table?)
  var wndo = new dw_scrollObj('wn4', 'lyr4', 't4');
  // pass id's of any wndo's that scroll inside tables
  // i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');
  dw_scrollObj.GeckoTableBugFix('wn4'); 	  $$('.leftarrow4')[0].style.display="none";
  
  check12clrs('lyr4','.rightarrow4');
	wndo.on_scroll = function() {$$('.leftarrow4')[0].style.display="block"; $$('.rightarrow4')[0].style.display="block";}
	wndo.on_scroll_start = function() {}
	wndo.on_scroll_end = function() {
		if(this.x==0) {
			$$('.rightarrow4')[0].style.display="block";
			$$('.leftarrow4')[0].style.display="none";
		}else if (this.x<0) {
			$$('.rightarrow4')[0].style.display="none";
		}
	}
}

function initScrollLayer5() {
  // arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll, 
  // if horizontal scrolling, id of element containing scrolling content (table?)
  var wndo = new dw_scrollObj('wn5', 'lyr5', 't5');
  // pass id's of any wndo's that scroll inside tables
  // i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');
  dw_scrollObj.GeckoTableBugFix('wn5'); 	  $$('.leftarrow5')[0].style.display="none";
  
  check12clrs('lyr5','.rightarrow5');
	wndo.on_scroll = function() {$$('.leftarrow5')[0].style.display="block"; $$('.rightarrow5')[0].style.display="block";}
	wndo.on_scroll_start = function() {}
	wndo.on_scroll_end = function() {
		if(this.x==0) {
			$$('.rightarrow5')[0].style.display="block";
			$$('.leftarrow5')[0].style.display="none";
		}else if (this.x<0) {
			$$('.rightarrow5')[0].style.display="none";
		}
	}
}



function check12clrs (layerid, nextarrow) {
	if ($(layerid).offsetWidth < 220) {
		$$(nextarrow)[0].style.display="none";
	}	
}

function hoverImages(arrIm) {
	var arrmenu = $$(arrIm);
	for (i=0;i<arrmenu.length;i++) {
	if (arrmenu[i].src.indexOf("_o.", 0)==-1) {
		arrmenu[i].addEvents ({
			'mouseover':function(){	
				this.src=this.src.replace(/(\.[^.]+)$/, '_o$1');

			},
			'mouseout': function(){
				this.src=this.src.replace(/_o(\.[^.]+)$/, '$1');
			}
	});}
	}
}

function clearFooterInput () {
	/*$('femail').addEvents ({
		'focus': function() {
			if (this.value != "" && this.value=="E-mail")
			this.value="";	
		},
		'blur': function() {
			if (this.value == "")
			this.value="E-mail";
		}		
	});
	$('fpass').addEvents ({
		'focus': function() {
			if (this.value != "" && this.value=="mot de passe")
			this.value="";	
		},
		'blur': function() {
			if (this.value == "")
			this.value="mot de passe";
		}		
	});*/
	$('plcRoot_Layout_CP_Footer1_txtSearch').addEvents ({
		'focus': function() {
			if (this.value != "" && this.value=="Chercher")
			this.value="";	
		},
		'blur': function() {
			if (this.value == "")
				this.value="Chercher";
		}		
	});
}


