/* Javscript - Sarenza */

/***** Sommaire *****/
// 10 - writeFlash
// 20 - autoRoll
// 30 - Field cleaner
// 40 - CustomBox
// 50 - Fold / Unfold
// 60 - Scrolls
// 70 - Product View
// 75 - Layer adds
// 80 - Tabs
// 85 - Comments
// 99 - onLoad
/******************/

/***** 10 - writeFlash *****/
//function writeFlash(url,id,w,h,o){
//	document.write('\n<object id="'+id+'" type="application/x-shockwave-flash" data="'+url+'" width="'+w+'" height="'+h+'">\n');
//	document.write('\t<param name="movie" value="'+url+'" />\n');
//	if(o != ''){
//		var flashOptionsTab = new Array();
//		flashOptionsTab = o.split('|');
//		for(i=0; i<flashOptionsTab.length; i++){
//			var tempParam = flashOptionsTab[i].split('#')[0];
//			var tempValue = flashOptionsTab[i].split('#')[1];
//			document.write('\t<param name="'+tempParam+'" value="'+tempValue+'" />\n');
//		}
//	}
//	document.write('</object>\n');
//}

/***** 20 - autoRoll *****/
var onAdd="-on";

function autoRoll(Img,Event){
	if(!Img.onmouseout && Event == true) Img.onmouseout = function(){ autoRoll(Img) };
	imgExt = Img.src.substring(Img.src.lastIndexOf("."));
	imgName = Img.src.substring(0,Img.src.lastIndexOf("."));
	imgOn = imgName+onAdd+imgExt;
	if(imgName.indexOf(onAdd) != -1) imgName = imgName.substring(0,imgName.length-onAdd.length);
	imgOff = imgName+imgExt;
	if(Img.src.indexOf(onAdd) != -1) Img.src = imgOff;
	else Img.src = imgOn;
}

function autoRollEvents(){
	var imgTable = arguments[0].getElementsByTagName('img');
	for(var i=0; i<imgTable.length; i++){
		imgTable[i].onmouseout = null;
		if(imgTable[i].src.indexOf(onAdd) == -1) imgTable[i].onmouseover = function(){autoRoll(this,true)};
	}
}
function autoRollHeader(Img,imgTable){
	
	for(var i=0; i<imgTable.length; i++){
		
		imgTable[i].src=imgTable[i].src.replace(onAdd,"");
		
	}
	var imgExt = Img.src.substring(Img.src.lastIndexOf("."));
	var imgName = Img.src.substring(0,Img.src.lastIndexOf("."));
	if(Img.src.indexOf(onAdd) == -1) Img.src=imgName+onAdd+imgExt;
	
}

function autoRollEventsHeader(){
	var imgTable = arguments[0].getElementsByTagName('img');
	for(var i=0; i<imgTable.length; i++){
		
		imgTable[i].onmouseover = function(){autoRollHeader(this,imgTable)};
		
	}
	arguments[0].onmouseout= function(){
	     for(var i=0; i<imgTable.length; i++){
    		
		    imgTable[i].src=imgTable[i].src.replace(onAdd,"");
		    if(imgTable[i].getAttribute("default")=="yes")
		    {
		        var imgExt = imgTable[i].src.substring(imgTable[i].src.lastIndexOf("."));
	            var imgName = imgTable[i].src.substring(0,imgTable[i].src.lastIndexOf("."));
	            imgTable[i].src = imgName+onAdd+imgExt;
		    }
    		
	    }
	};
}

/***** 30 - Field cleaner *****/
function fieldCleaner(field,message){
	if(field.value == message){
		field.value = '';
	}
}

/***** 40 - CustomBox *****/
function customBoxClick(id){
	if($(id,'input',0).checked == true){
		$S('del',$(id,'label',0),'on');
	} else {
		$S('add',$(id,'label',0),'on');
	}
}

/***** 50 - Fold / Unfold ******/
var foldTimer;
var foldSize = 20;
var foldSpeed = 30;
var maskObj;
var contObj;
var stopFold=false;
var isFolding=false;
var isUnFolding=false;
function fold(mask,cont){
	maskObj = mask;
	contObj = cont;
	foldEffect();
}
function foldEffect(){
	//isFolding=true;
	//if (stopFold && !isUnFolding)
	//{
//	    maskObj.style.height = contObj.offsetHeight+'px';
//	    return;
//	}
	//if (isUnFolding)
	//{
	//    isFolding=false;
	//    return;
	//}
	
	if((maskObj.offsetHeight+foldSize) < contObj.offsetHeight ){
		maskObj.style.height = (maskObj.offsetHeight+foldSize)+'px';
		
		    foldTimer = setTimeout('foldEffect();',foldSpeed);
	} else {
	    //isFolding=false
		maskObj.style.height = contObj.offsetHeight+'px';
		
		    
	}
}
function unFold(mask,cont){
	maskObj = mask;
	contObj = cont;
	unFoldEffect();
}
function unFoldEffect(){
//	isUnFolding=true;
//	if (stopFold && !isFolding)
//	{
//	    maskObj.style.height = '0';
//	    return;
//	}
//	if (isFolding)
//	{
//	    isUnFolding=false;
//	    return;
//	}
	
	if((maskObj.offsetHeight-foldSize) > 0){
		maskObj.style.height = (maskObj.offsetHeight-foldSize)+'px';
		
		    foldTimer = setTimeout('unFoldEffect();',foldSpeed);
		    
	} else {
	    
		maskObj.style.height = '0';
		if (maskObj.getAttribute('id')=='divSize')
		{
		    //fold($('divSize'),$('divSize','div',0));
		    var unFoldElt=getElement_By_Id("UnFolddivSize");

	        if (unFoldElt!=null)
		        unFoldElt.className="toFold";
		}
	}
}

/***** 60 - Scrolls *****/
var scrollTimer;
var scrollSpeed = 10;
var scrolLDelay = 20;

function scroll(item,maskHeight,contentHeight,toolHeight){
	item.ratio = maskHeight/contentHeight;
	item.maskHeight = maskHeight;
	item.contentHeight = contentHeight;
	item.trackHeight = maskHeight-(toolHeight*2);
	item.trackStart = toolHeight;
	item.barHeight = item.trackHeight*item.ratio;
	item.barRatio = item.barHeight/item.maskHeight;
	item.trackMax = item.trackHeight-item.barHeight-toolHeight*2;
}

function scrollUp(index){
	if(($('scroll'+index,'div',0).offsetTop+scrollSpeed) < 0){
		$('scroll'+index,'div',0).style.top = ($('scroll'+index,'div',0).offsetTop+scrollSpeed)+'px';
		scrollTimer = setTimeout('scrollUp('+index+');', scrolLDelay);
	} else {
		$('scroll'+index,'div',0).style.top = '0';
	}
	updateScrollBar(index);
}
function scrollDown(index){
	if(($('scroll'+index,'div',0).offsetTop-scrollSpeed) > ($('scroll'+index).offsetHeight-$('scroll'+index,'div',0).offsetHeight)){
		$('scroll'+index,'div',0).style.top = ($('scroll'+index,'div',0).offsetTop-scrollSpeed)+'px';
		scrollTimer = setTimeout('scrollDown('+index+');', scrolLDelay);
	} else {
		$('scroll'+index,'div',0).style.top = ($('scroll'+index).offsetHeight-$('scroll'+index,'div',0).offsetHeight)+'px';
	}
	updateScrollBar(index);
}
function updateScrollBar(index){
	var newDelta = Math.floor(-$('scroll'+index,'div',0).offsetTop*$('scroll'+index).barRatio)+$('scroll'+index).trackStart;
	$('scroll'+index+'Tools','div',1).style.top = newDelta+'px';
}

/***** 70 - Product View *****/
var coeffZoom='4';
function viewProduct(id){
	var viewerId = id.split('Thumb')[0]
	var thumbIndex = id.split('Thumb')[1]
	//var coeffZoom='2';
	var productId='';
	try
	{
	    coeffZoom=getElement_By_Id("ViewInfos_CoeffZoom").value;
	    productId=getElement_By_Id("ViewInfos_ProductId").value;
	}
	catch(ex)
	{}
	
	var objFlash = getElement_By_Id("productFlash");
    
    if(objFlash!=null){
        //var myFlashObject = new FlashObject(productId, $(viewerId+'Thumb'+thumbIndex).src.replace('/thumbs/','/big/'),coeffZoom, 8,false);
        var myFlashObject = new FlashObject(productId, $(viewerId+'Thumb'+thumbIndex).src.replace('/thumbs/','/big/').replace('PI_',''),coeffZoom, 8,false);

        myFlashObject.write("productFlash");
    }
	//$(viewerId+'View','img',0).src = $(viewerId+'Thumb'+thumbIndex).src.replace('/thumbs/','/big/');
}
var FlashObject = function(prd, src, zoom, ver, isZoomVig, isCarousselBrand, fromFamille) {
    this.prd = prd;
    this.zoom = zoom;
    this.isZoomVig = isZoomVig;
    this.src = src;
    this.version = ver;
    this.params = new Object();
    this.addParam('quality', 'high'); // default to high
    this.doDetect = getQueryParamValue('detectflash');
    this.flashPath = "http://cache.sarenza.com/V4/";
    this.imagePath = "";
    this.isCarousselBrand = isCarousselBrand;
    this.fromFamille = fromFamille;
}

var FOP = FlashObject.prototype;
FOP.addParam = function(name, value) { this.params[name] = value; }
FOP.getParams = function() { return this.params; }
FOP.getParam = function(name) { return this.params[name]; }

FOP.getParamTags = function() {
 var paramTags = "";
 for (var param in this.getParams()) {
 paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
 }
 return (paramTags == "") ? false:paramTags;
}

FOP.getHTML = function(width, height) {
    var flashHTML = "";
    //flashHTML += '<object type="application/x-shockwave-flash" data="/webapp/wcs/stores/servlet/Hermes1/commun/produits/' + this.cat + '/int/flash/zoom.swf" width="534" height="476" id="">';
    //flashHTML += '<param name="movie" value="/webapp/wcs/stores/servlet/Hermes2/commun/produits/' + this.cat + '/int/flash/zoom.swf" />';
    //flashHTML += '<param name="FlashVars" value="xmlProduct=<product id=\'' + this.prd + '\' img=\'/webapp/wcs/stores/servlet/Hermes3/commun/produits/' + this.cat + '/int/detail/' + this.prd + '.jpg\' imgzoom=\'/webapp/wcs/stores/servlet/Hermes4/commun/produits/' + this.cat + '/int/zoom/' + this.prd + '.jpg\' />" />';
    if (width == undefined || width == '')
        width = 652;
    if (height == undefined || height == '')
        height = 50;
    if (this.isCarousselBrand) {

        if (this.fromFamille) {
            flashHTML += '<OBJECT id="" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" data="http://cache.sarenza.com/V4/carouselBrands-6522.swf">';
            flashHTML += '<PARAM value="http://cache.sarenza.com/V4/carouselBrands-6522.swf" name="movie" />';
        }
        else {
            flashHTML += '<OBJECT id="" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" data="http://cache.sarenza.com/V4/carouselBrands-652.swf">';
            flashHTML += '<PARAM value="http://cache.sarenza.com/V4/carouselBrands-652.swf" name="movie" />';
        }

        flashHTML += '<PARAM value="playWhenGTH=14&xmlBrands=<icons home=\'' + getElement_By_Id("carouselBrandFlashHiddenHome").value + '\' urlImage=\'' + getElement_By_Id("carouselBrandFlashHiddenUrlImages").value + '\'>' + getElement_By_Id("carouselBrandFlashHiddenImages").value + '</icons> " name="FlashVars" />';
        flashHTML += '<PARAM value="transparent" name="wmode" />';
        flashHTML += '<PARAM NAME="AllowScriptAccess" VALUE="always">';
        flashHTML += '</OBJECT>';
        getElement_By_Id("carouselBrandFlashHiddenImages").value = "";
        return flashHTML;
    }

    if (!this.isZoomVig) {
        //    flashHTML += '<object type="application/x-shockwave-flash" data="' + this.flashPath + 'zoom.swf" width="380" height="253" id="">';
        //    flashHTML += '<param name="movie" value="' + this.flashPath + 'zoom.swf" />';
        //    flashHTML += '<param name="FlashVars" value="xmlProduct=<product id=\'' + this.prd + '\' CoeffZoom=\''+ this.zoom+'\' img=\''+this.imagePath+this.src+'\'  />" />';//ajouter imgzoom=\''+this.imagePath+this.src+'\' en cas ou on a une image HD 
        //
        flashHTML += '<object type="application/x-shockwave-flash" data="' + this.flashPath + 'zoomV4.swf" width="380" height="253" id="">';
        flashHTML += '<param name="movie" value="' + this.flashPath + 'zoomV4.swf" />';
        var splitedSrc = this.src.split('/');
        flashHTML += '<param name="FlashVars" value="xmlProduct=<product id=\'' + this.prd + '\' CoeffZoom=\'' + this.zoom + '\' img=\'' + this.imagePath + this.src + '\' imgzoom=\'' + this.imagePath + this.src.replace(splitedSrc[splitedSrc.length - 1], 'HD_' + splitedSrc[splitedSrc.length - 1]) + '\'   />" />'; //ajouter imgzoom=\''+this.imagePath+this.src+'\' en cas ou on a une image HD 

    }
    else {
        flashHTML += '<object type="application/x-shockwave-flash" data="' + this.src.toString().split('_img/productsV4/')[0] + 'V4/zoom.swf" width="360" height="240" id="">';
        flashHTML += '<param name="movie" value="' + this.src.toString().split('_img/productsV4/')[0] + 'V4/zoomVig.swf" />';
        flashHTML += '<param name="FlashVars" value="xmlProduct=<product id=\'' + this.prd + '\'  img=\'' + this.imagePath + this.src + '\'  />" />'; //ajouter imgzoom=\''+this.imagePath+this.src+'\' en cas ou on a une image HD 
    }
    flashHTML += '<param name="wmode" value="transparent">'
    flashHTML += '</object>';
    return flashHTML;
}

FOP.write = function(elementId, width, height) {
 if(detectFlash(this.version) || this.doDetect=='false') {
    if (elementId)
        document.getElementById(elementId).innerHTML = this.getHTML(width, height);
   
 } 
 else {

    if (elementId)
    {
        if (this.isCarousselBrand)
            return;
        if (!this.isZoomVig)
            document.getElementById(elementId).innerHTML = "<img src="+this.imagePath+this.src+" width=\"380\" height=\"253\" id=visuprd>";
        else
             document.getElementById(elementId).innerHTML = "<img src="+this.imagePath+this.src+" width=\"360\" height=\"240\" id=visuprd>";
    }
            
         
    }
}

/* ---- detection functions ---- */
function getFlashVersion() {
 var flashversion = 0;
 if (navigator.plugins && navigator.mimeTypes.length) {
    
    var x = navigator.plugins["Shockwave Flash"];
    
    if(x && x.description) {
        var y = x.description;
              
        flashversion = parseInt(y.substr(y.indexOf('.')-2,2),10);
    }
 } else {
    result = false;
    
    for(var i = 15; i >= 3 && result != true; i--){
        execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
        flashversion = i;
    }  
 }
 return flashversion;
}

function detectFlash(ver) {
 
 return (getFlashVersion() >= ver) ? true:false;
 }
 // get value of query string param
function getQueryParamValue(param) {
 var q = document.location.search || document.location.href.split("#")[1];
 if (q) {
 var detectIndex = q.indexOf(param +"=");
 var endIndex = (q.indexOf("&", detectIndex) > -1) ? q.indexOf("&", detectIndex) : q.length;
 if (q.length > 1 && detectIndex > -1) {
 return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
 } else {
 return "";
 }
 }
}

function changeFlash(prd,src){
 var myFlashObject = new FlashObject(prd, src,coeffZoom, 8,false);
 myFlashObject.write("GrandVisuel");
}

/***** 75 - Layer adds *****/
function openBasketAdd(){
	if($$('div','basketAdd')[0]){
		$$('div','basketAdd')[0].style.visibility = 'visible';
	}
}
function closeBasketAdd(){
	if($$('div','basketAdd')[0]){
		$$('div','basketAdd')[0].style.visibility = 'hidden';
	
		 //getElement_By_Id("viewer0View").onmousemove = move;
    
	}
}

function openBasketSummary(){
	if($$('div','summary basketSummary scrolling')[0]){
	    getElement_By_Id("divTerminerCommande").style.display="none";
		$$('div','summary basketSummary scrolling')[0].style.visibility = 'visible';
	    basketLineItems = ReadCookie("BasketLineItems");
        if (basketLineItems!="") {
            basketLineItems = basketLineItems.split(";");
            if (basketLineItems.length >5 ) {
                getElement_By_Id("scrollBasketPrev").style.visibility="visible";
                getElement_By_Id("scrollBasketNext").style.visibility="visible";
            }
        }
	}
}
function closeBasketSummary(){
	if($$('div','summary basketSummary scrolling')[0]){
		getElement_By_Id("divTerminerCommande").style.display="block";
		$$('div','summary basketSummary scrolling')[0].style.visibility = 'hidden';
	    getElement_By_Id("scrollBasketPrev").style.visibility="hidden";
		getElement_By_Id("scrollBasketNext").style.visibility="hidden";
	}
}

function openSelectionSummary(){
	if($$('div','selectionSumamry')[0]){
		getElement_By_Id("divTerminerCommande").style.display="none";
		$$('div','selectionSumamry')[0].style.visibility = 'visible';
		if($$('li','selection')[0].getElementsByTagName('img')[0].src.indexOf(onAdd) == -1){
			autoRoll($$('li','selection')[0].getElementsByTagName('img')[0],false);
		}
	}
}
function closeSelectionSummary(){
	if($$('div','selectionSumamry')[0]){
		$$('div','selectionSumamry')[0].style.visibility = 'hidden';
		if($$('li','selection')[0].getElementsByTagName('img')[0].src.indexOf(onAdd) != -1){
			autoRoll($$('li','selection')[0].getElementsByTagName('img')[0],false);
		}
	}
}

/***** 80 - Tabs *****/
var lastTab = -1;

function showTab(index){
	if(lastTab != -1){
		$('tab'+lastTab,'div',0).style.visibility = 'hidden';
		$S('del',$('tab'+lastTab,'a',0),'on');
	}
	$('tab'+index,'div',0).style.visibility = 'visible';
	$S('add',$('tab'+index,'a',0),'on');
	lastTab = index;
}

var lastAltTab = -1;

function showAltTab(index){
	if(lastAltTab != -1){
		$('tabAlt'+lastAltTab+'Cont').style.display = 'none';
		autoRoll($('tabsAltLinks','li',lastAltTab,'img',0),false);
	}
	$('tabAlt'+index+'Cont').style.display = 'block';
	autoRoll($('tabsAltLinks','li',index,'img',0),false);
	lastAltTab = index;
}

/***** 85 - Comments *****/
var lastComment = -1;
var commentCount = 0;

function showComment(index){
	if(lastComment != -1){
		$('comment'+lastComment).style.display = 'none';
	}
	$('comment'+index).style.display = 'block';
	buildCommentPager(index);
	lastComment = index;
}

function buildCommentPager(index){
	if(commentCount > 1){
		var prevClass = 'prevOn';
		var prevAction = 'javascript:showComment('+(index-1)+');';
		var nextClass = 'nextOn';
		var nextAction = 'javascript:showComment('+(index+1)+');';
		if(index == 0){
			prevClass = 'prevOff';
			prevAction = '#0';
		}
		if(index == commentCount-1){
			nextClass = 'nextOff';
			nextAction = '#0';
		}
		var commentPagerCh = '';
		commentPagerCh += '<a class="'+prevClass+'" href="'+prevAction+'"></a>';
		commentPagerCh += '<span>'+(index+1)+'/'+commentCount+'</span>';
		commentPagerCh += '<a class="'+nextClass+'" href="'+nextAction+'"></a>';
		$('commentPager').innerHTML = commentPagerCh;
	}
}

/***** 99 - onLoad *****/
var object = new Array();

function Slide(N,oCont){
	this.N  = N;
	this.S  = 1.1;
	this.object = new Array();
    this.AutoRun=true;
	this.CObj = function (parent,N){

		this.parent = parent;
		this.N = N;
		this.obj = parent.frm[N];
		this.tit = this.obj.getElementsByTagName("div")[0];
		
		this.div = this.obj.getElementsByTagName("div")[1];
		this.div.style.visibility = "hidden";
		this.y0 = N * 18;
		this.Y1 = this.y0;
		this.obj.style.top = Math.round(this.y0) + 'px';
		this.obj.style.height = Math.round(parent.H - (parent.NF-1) * 18 - 3) + 'px';
		this.obj.style.visibility = "visible";
		this.obj.parent = this;
		this.run = false;
       
		this.move = function(){
			with(this){
				dy = (y1-y0)/parent.S;
				if(Math.abs(dy)>.1){
					y0+=dy;
					obj.style.top = Math.round(y0) + 'px';;
					setTimeout("object["+parent.N+"].object["+N+"].move();", 16);
				} else {
					run = false;
					if(dy>0)div.style.visibility="hidden";
					else if(N>0)parent.object[N-1].div.style.visibility="hidden";
				}
			}
		}
       
	   
		
		this.obj.onmouseover = function(){
			with(this.parent){
				if(!run){
					run = true;
					div.style.visibility="visible";
					
					for(i=0;i<parent.NF;i++)parent.object[i].tit.className = "titleHomeGender";
					tit.className = "titleHomeGender_o";
					for(i=0;i<=N;i++){
						parent.object[i].y1 = i*25;
						parent.object[i].move();
					}
					for(i=N+1;i<parent.NF;i++){
						parent.object[i].y1 = parent.H-(parent.NF-i)*25;
						parent.object[i].move();
					}
				}
			}
		}
		
		
	}

	this.divFrm = document.getElementById(oCont);
	if (this.divFrm!=null)
	{
	    
	    this.divFrm.onmouseout = function(){
		    this.setAttribute("AutoRun","true");
		}
		this.divFrm.onmouseover = function(){
		    this.setAttribute("AutoRun","false");
		}
	    this.H = this.divFrm.offsetHeight;
	    this.frm = this.divFrm.getElementsByTagName("span");
	    this.NF = this.frm.length;
	    for(i=0; i < this.NF; i++) this.object[i] = new this.CObj(this, i);
	    this.object[0].obj.onmouseover();
    	
	    //window.setTimeout("this.object[1].obj.MoveFunction();",5000);
	    this.S = 10;
	}
}
function AutoRun(i)
{
  
    if(i>=object[0].object.length)
        i=0;
    if(object[0].divFrm.getAttribute("AutoRun")==null || object[0].divFrm.getAttribute("AutoRun")=="true")
        object[0].object[i].obj.onmouseover();
    
    window.setTimeout("AutoRun("+(i+1)+");",4000);
}


var objectSarenzaSlide;
function SarenzaSlide(data,oCont,speed,useopacity){
  
  objectSarenzaSlide=new MainSarenzaSlide(data,oCont,speed,useopacity);
  

}
function MainSarenzaSlide(data,oCont,speed,useopacity)
{
  this.divFrm = document.getElementById(oCont);
  this.data=data;
  
  this.speed=speed;
  this.useopacity=useopacity;
  this.principalImage=this.divFrm.getElementsByTagName("img")[0];
  
  this.principalLink=this.divFrm.getElementsByTagName("a")[0];
  this.thumbnails=new Array();
  this.StopAutoRun=false;
  
  this.principalImage.onmouseover=function()
  {
    objectSarenzaSlide.StopAutoRun=true;
  }
  
  this.principalImage.onmouseleave=function()
  {
    objectSarenzaSlide.StopAutoRun=false;
  }
  this.principalImage.onmouseout=function()
  {
    objectSarenzaSlide.StopAutoRun=false;
  }
  
  this.autoRun=function(i){
  
    
    if(i>=this.thumbnails.length)
        i=0;
    if(!this.StopAutoRun)
        this.thumbnails[i].move();
    
    window.setTimeout("objectSarenzaSlide.autoRun("+(i+1)+")",this.speed);
   
    
  }
  this.thumbnail=function(image,parent)
  {
    this.image=image;
    this.parent=parent;
    this.image.onmouseover=function()
    {
        parent.StopAutoRun=true;
        if(parent.useopacity)
        {
            for(var i=0;i<parent.thumbnails.length;i++)
            {
                parent.thumbnails[i].image.style.filter="alpha(opacity:50)";
                parent.thumbnails[i].image.style.opacity=0.5;
            }
            image.style.filter="alpha(opacity:100)";
            image.style.opacity=1;
        }
        parent.principalLink.href=image.parentNode.href;
        parent.principalLink.target=image.parentNode.target;
        parent.principalImage.src=image.src.replace(/t(\.[^\.]+)$/, '$1');
    }
    this.image.onmouseleave=function()
    {
        parent.StopAutoRun=false;
    }
    this.image.onmouseout=function()
    {
        parent.StopAutoRun=false;
    }
    this.move=function()
    {
        if(parent.useopacity)
        {
            for(var i=0;i<parent.thumbnails.length;i++)
            {
                parent.thumbnails[i].image.style.filter="alpha(opacity:50)";
                parent.thumbnails[i].image.style.opacity=0.5;
            }
            image.style.filter="alpha(opacity:100)";
            image.style.opacity=1;
        }
        parent.principalLink.href=image.parentNode.href;
        parent.principalLink.target=image.parentNode.target;
        parent.principalImage.src=image.src.replace(/t(\.[^\.]+)$/, '$1');
        
    }
  }
  if(this.divFrm)
  {
    var  slideshowThumbnails=document.createElement("div");
    slideshowThumbnails.className="slideshow-thumbnails";
    slideshowThumbnails.style.overflow="hidden";
    var  slideshowThumbnailsUL=document.createElement("ul");
    var i=0;
    for(image in data)
    {
        var  slideshowThumbnailsLI=document.createElement("li");        
        var  slideshowThumbnailsA=document.createElement("a");
        slideshowThumbnailsA.href=data[image].href?data[image].href:"";
        slideshowThumbnailsA.target=data[image].target?data[image].target:"";
        var  slideshowThumbnailsIMG=document.createElement("img");
        slideshowThumbnailsIMG.src=image.replace(/(\.[^\.]+)$/, 't$1');
        if(this.useopacity)
        {
            slideshowThumbnailsIMG.style.filter="alpha(opacity:50)";
            slideshowThumbnailsIMG.style.opacity=0.5;
        }
        this.thumbnails[i]=new this.thumbnail(slideshowThumbnailsIMG,this);
        
        
        slideshowThumbnailsA.appendChild(slideshowThumbnailsIMG);
        slideshowThumbnailsLI.appendChild(slideshowThumbnailsA);
        slideshowThumbnailsUL.appendChild(slideshowThumbnailsLI);
        i++;
    }
    slideshowThumbnails.appendChild(slideshowThumbnailsUL);
    this.divFrm.appendChild(slideshowThumbnails);
    this.autoRun(0);
    
  }
}

window.onload = function(){
	
	object[0] = new Slide(0, "frames");
	 if(object[0].divFrm!=null && object[0].object.length!=0)
	    AutoRun(0);
	// 20 - autoRoll
	if($$('div','customerNav')[0]){
		autoRollEvents($$('div','customerNav')[0]);
	}
	if($$('div','productNav')[0]){
		autoRollEventsHeader($$('div','productNav')[0]);
	}
	if($$('div','buttons')[0]){
		autoRollEvents($$('div','buttons')[0]);
	}
	
	// 40 - CustomBox
	var customBoxTab = $$('div','customBox');
	for(i=0; i<customBoxTab.length; i++){
		// IDs
		customBoxTab[i].id = 'customBox'+i;
		if($('customBox'+i,'input',0).checked == true){
			$S('add',$('customBox'+i,'label',0),'on');
		}
		$('customBox'+i,'label',0).onmouseover = function(){ $S('add',this,'hover'); }
		$('customBox'+i,'label',0).onmouseout = function(){ $S('del',this,'hover'); }
		$('customBox'+i,'label',0).onclick = function(){ customBoxClick(this.parentNode.id); }
	}
	
	// 50 - Fold / Unfold
//	if($('filterAction')){
//		$('filterAction').onclick = function(){
//			if($('filterTools').offsetHeight > 10){
//				$S('add',$('filterAction'),'advanceHidden');
//				unFold($('filterTools'),$('filterTools','div',0));
//			} else {
//				$S('del',$('filterAction'),'advanceHidden');
//				fold($('filterTools'),$('filterTools','div',0));
//			}
//		}
//	}
	
	// 60 - Scrolls
	/*var scrollTab = $$('div','scroll');
	for(i=0; i<scrollTab.length; i++){
		// IDs
		scrollTab[i].id = 'scroll'+i;
		if($('scroll'+i).offsetHeight < $('scroll'+i,'div',0).offsetHeight){
			// Ajout des outils
			var newScroller = document.createElement('div');
			newScroller.setAttribute('id','scroll'+i+'Tools'); 
			$('scroll'+i).appendChild(newScroller);
			$('scroll'+i+'Tools').className = 'scrollTools';
			$('scroll'+i+'Tools').innerHTML += '<div class="scrollUp"></div><div class="scrollBar"></div><div class="scrollDown"></div>';
			// Events
			$('scroll'+i+'Tools','div',0).onmousedown = function(){ clearTimeout(scrollTimer); scrollUp(parseInt(this.parentNode.id.replace('scroll',''))); }
			$('scroll'+i+'Tools','div',0).onmouseup = $('scroll'+i+'Tools','div',0).onmouseout = function(){ clearTimeout(scrollTimer); }
			$('scroll'+i+'Tools','div',2).onmousedown = function(){ clearTimeout(scrollTimer); scrollDown(parseInt(this.parentNode.id.replace('scroll',''))); }
			$('scroll'+i+'Tools','div',2).onmouseup = $('scroll'+i+'Tools','div',2).onmouseout = function(){ clearTimeout(scrollTimer); }
			// Dimmension
			new scroll($('scroll'+i),$('scroll'+i).offsetHeight,$('scroll'+i,'div',0).offsetHeight,$('scroll'+i+'Tools','div',0).offsetHeight);
			$('scroll'+i+'Tools').style.height = $('scroll'+i).maskHeight+'px';
			$('scroll'+i+'Tools','div',1).style.height = $('scroll'+i).barHeight+'px';
			$('scroll'+i+'Tools','div',1).style.top = $('scroll'+i).trackStart+'px';
		}
	}*/
	
	// 70 - Product View
	var viewerTab = $$('div','productViewer');
	for(i=0; i<viewerTab.length; i++){
		// IDs
		//viewerTab[i].id = 'viewer'+i;
		//$('viewer'+i,'div',0).id = 'viewer'+i+'View';
		//$('viewer'+i,'div',1).id = 'viewer'+i+'Thumbs';
		var viewerThumbs = $('viewer'+i+'Thumbs','img',-1);
		for(j=0; j<viewerThumbs.length; j++){
			//viewerThumbs[j].id = 'viewer'+i+'Thumb'+j;
			viewerThumbs[j].onmouseover = function(){ viewProduct(this.id); }
		}
	}
	
	// 75 - Layer adds
	
	if($('mon_panier')){
		$('mon_panier').onmouseover = function(){ openBasketSummary(); }
		$('mon_panier').onmouseout = function(){ closeBasketSummary(); }
	}
	try
	{
	    if($$('div','summary basketSummary scrolling')[0]){
		    $$('div','summary basketSummary scrolling')[0].onmouseover = function(){ openBasketSummary(); }
		    $$('div','summary basketSummary scrolling')[0].onmouseout = function(){ closeBasketSummary(); }
	    }
	}
	catch(ex){}
	try
	{
	    if($$('li','selection')[0]){
		    $$('li','selection')[0].onmouseover = function(){ openSelectionSummary(); }
		    $$('li','selection')[0].onmouseout = function(){ closeSelectionSummary(); }
	    }
	}
	catch(ex){}
	
	// 80 - Tabs
	if($$('li','tab').length > 0){
		var tabsTab = $$('li','tab');
		for(i=0; i<tabsTab.length; i++){
			// IDs
			tabsTab[i].id = 'tab'+i;
			$('tab'+i,'a',0).href = 'javascript:showTab('+i+');';
		}
		showTab(0);
	}
	
	if($$('div','tabsAlt')[0]){
		$$('div','tabsAlt')[0].id = 'tabsAltLinks';
		var tabsAltLength = $('tabsAltLinks','li',-1);
		var tabAltContent = $$('div','tabAltCont');
		if(tabAltContent.length == tabsAltLength.length){
			for(i=0; i<tabAltContent.length; i++){
				$('tabsAltLinks','li',i,'a',0).href = 'javascript:showAltTab('+i+');';
				tabAltContent[i].id = 'tabAlt'+i+'Cont';
			}
		}
		showAltTab(0);
	}
	
	// 85 - Comments
	try
	{
	    if($$('div','comment').length > 0){
		    var commentsTab = $$('div','comment');
		    commentCount = commentsTab.length;
		    for(i=0; i<commentsTab.length; i++){
			    // IDs
			    commentsTab[i].id = 'comment'+i;
		    }
		    // Pose le place holder du pager
		    var newPager = document.createElement('div');
		    newPager.setAttribute('id','commentPager'); 
		    $$('div','comments')[0].appendChild(newPager);
		    showComment(0);

	    }
	}
	catch(ex)
	{}
	
	// 86 - Navigation
	if($("navTop"))
	{
	    var nodes = $("navTop").getElementsByTagName("li");
	    for (var i=0;i<nodes.length;i++) {
		    if (nodes[i].parentNode.tagName=="UL") {
    		
			    nodes[i].onmouseover = function () {
			        try {
				    this.getElementsByTagName("ol")[0].style.visibility = "visible";
				    var img = this.getElementsByTagName("img")[0];
				    if(img.src.indexOf(onAdd) == -1) { autoRoll(img,true); };
				    } catch(ex){}
			    }
			    nodes[i].onmouseout = function () {
				    try {
				    this.getElementsByTagName("ol")[0].style.visibility = "hidden";
				    } catch(ex){}
			    }
		    }
	    }
	}

	//*************************
	AfterInitPage();
	 
}