

function openZoomAdvWindow()
{
	if (this.getElementsByTagName('img').length > 0) {
		if (!this.rowId) {
			this.rowId = false;
			if (this.id) {
				this.rowId = this.id.split('-');
				if (this.rowId[1]) {
					this.rowId = parseInt(this.rowId[1]);
				}
			}
		}
		
		this.id = 'zoomActionSrc';
		var zoomWin = document.getElementById('zoomBox');
		addClass(zoomWin, 'zoomProduit');
		zoomWin.preloadImg = new Image();
		zoomWin.preloadImg.onload = showZoomWindow;
		if (this.oldhref) {
			zoomWin.preloadImg.src = this.oldhref;
		} else {
			zoomWin.preloadImg.src = this.href;
		}	
		showBlackFrame();
		fillZoomWindow(this);
		
	} else {
		var obj = this.parentNode.parentNode;
		if (obj.firstChild.nodeName == 'LI') {
			obj = obj.getElementsByTagName('a');
			if (obj[0] && obj[0].onclick) {
				obj[0].onclick();
			}
		}
	}
	
	return false;
}




function fillZoomWindow(pointer)
{
	var h2, imgList, imgSrc;
	var zoomWin = document.getElementById('zoomBox');
	
	if (pointer.oldhref) {
		imgSrc = pointer.oldhref;
	} else {
		imgSrc = pointer.href;
	}
	
	if (pointer.rowId) {
		h2 = document.getElementById('productTitle-' + pointer.rowId);
		imgList = document.getElementById('photoProduitList-' + pointer.rowId);
		
	} else {
		h2 = document.getElementById('productTitle');
		imgList = document.getElementById('photoProduitList');
	}
	
	if (imgList) {
		imgList = imgList.getElementsByTagName('li');
	}

	// Affichage de l'image
	var targetObj = zoomWin.firstChild.firstChild.firstChild;
	targetObj.src = imgSrc;
	
	// affichage du titre
	targetObj = targetObj.parentNode.nextSibling.firstChild;
	if (h2 && h2.innerHTML) {
		targetObj.innerHTML = h2.innerHTML;
	}

	
	
    // Liste des autres miniatures
	targetObj = targetObj.nextSibling.nextSibling;
	targetObj.innerHTML = '';
	
	if (!imgList || imgList.length <= 2) {
		addClass(zoomWin, 'sansMini');
		return false;
	}

	
	// Clic sur une miniature : changement de zoom
	targetObj.onclick = function(e) { 
        if (!e && window.event) {
            e = window.event;
        }
        var target = getEventTarget(e);
        if (target.nodeName == 'IMG') {
        	target = target.parentNode;
        }
        
        if (target.nodeName == 'A') {
        	/*if (pointer.rowId) {
        		target.rowId = pointer.rowId;
        	}*/
        	var idLink = target.id.replace('mini-', '');
        	idLink = document.getElementById(idLink);
        	if (idLink) {
        		idLink = idLink.getElementsByTagName('a');
        		if (idLink && idLink[0] && idLink[0].onclick) {
        			closeZoomWindow();
            		idLink[0].onclick();
        		}
        	}
        }
		return false; 
	};
	
	
	// Code html des miniatures affichées dans le zoom
	var htmlCode = '', imgCode = '';
	htmlCode += '<ul class="elementList">';
	for (var i = 0; i < imgList.length; i++) {
		
		link = imgList[i].getElementsByTagName('a')[0];
		img = imgList[i].getElementsByTagName('img');
		if (!img || !img[0]) {
			continue;
		}
		img = img[0];
		
		htmlCode += '<li';
		if (link.id == 'zoomActionSrc') {
			htmlCode += ' class="courant"';
		}
		htmlCode += '>';
		htmlCode += '<a';
		htmlCode += ' href="' + link.href + '"';
		htmlCode += ' id="mini-' + imgList[i].id + '"';
		htmlCode += '>';		
		
		htmlCode += '<img';
		htmlCode += ' src="' + img.src.replace('-m.', '-s.')
		htmlCode += '" alt="" width="43" />';
		htmlCode += '</a>';
		htmlCode += '</li>';
	}		
	htmlCode += '</ul>';
	
	targetObj.innerHTML = htmlCode;
	
	return false;
}







