var isNS = false;
var isIE = false;
var isW3C = false;

if (navigator.appName.indexOf('Netscape')>-1) {isNS=true; isIE=false; isW3C=false;}
if (document.getElementById) {isNS=false; isIE=false; isW3C=true;}
if (document.all) {isNS=false; isIE=true; isW3C=false;}

var option_prod = new Array("<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Paris – Service Pianos Acoustiques</em><br />Contactez-nous  au 01 43 58 05 45 <br />ou <U><a href=\"mailto:piano@centre-chopin.com\">piano@centre-chopin.com</a></U><p> <em>Centre Chopin Boulogne – Service Pianos  Acoustiques</em><br />Contactez-nous au 01  46 10 44 77 <br />ou <U><a href=\"mailto:boulogne@centre-chopin.com\">boulogne@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Paris – Service Pianos Numériques</em><br />Contactez-nous  au 01 43 58 05 45 <br />ou <U><a href=\"mailto:numerique@centre-chopin.com\">numerique@centre-chopin.com</a></U></p><p> <em>Centre Chopin Boulogne – Service Pianos  Numériques</em><br />Contactez-nous au 01  46 10 44 77 <br />ou <U><a href=\"mailto:boulogne@centre-chopin.com\">boulogne@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Paris – Boutique Accessoires &amp; Guitares</em><br />Contactez-nous  au 01 43 58 05 45 <br />ou <U><a href=\"mailto:boutique@centre-chopin.com\">boutique@centre-chopin.com</a></U></p><p> <em>Centre Chopin Boulogne – Boutique  Accessoires &amp; Guitares</em><br />Contactez-nous  au 01 46 10 44 77 <br />ou <U><a href=\"mailto:boulogne@centre-chopin.com\">boulogne@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Boulogne – Service Pianos Acoustiques</em><br />Contactez-nous  au 01 46 10 44 77 <br />ou <U><a href=\"mailto:boulogne@centre-chopin.com\">boulogne@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Paris – Service Pianos Acoustiques</em><br />Contactez-nous  au 01 43 58 05 45 <br />ou <U><a href=\"mailto:piano@centre-chopin.com\">piano@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Paris – Service Pianos Numériques</em><br />Contactez-nous  au 01 43 58 05 45 <br />ou <U><a href=\"mailto:numerique@centre-chopin.com\">numerique@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Boulogne – Service Pianos Numériques</em><br />Contactez-nous  au 01 46 10 44 77 <br />ou <U><a href=\"mailto:boulogne@centre-chopin.com\">boulogne@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Boulogne – Boutique Accessoires &amp;  Guitares</em><br />Contactez-nous au 01 46  10 44 77 <br />ou <U><a href=\"mailto:boulogne@centre-chopin.com\">boulogne@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Paris – Boutique Accessoires &amp; Guitares</em><br />Contactez-nous  au 01 43 58 05 45 <br />ou <U><a href=\"mailto:boutique@centre-chopin.com\">boutique@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Paris – Service Pianos Acoustiques</em><br />Contactez-nous  au 01 43 58 05 45 <br />ou <U><a href=\"mailto:piano@centre-chopin.com\">piano@centre-chopin.com</a></U></p><p> <em>Centre Chopin Boulogne – Service Pianos  Acoustiques</em><br />Contactez-nous au 01  46 10 44 77 <br />ou <U><a href=\"mailto:boulogne@centre-chopin.com\">boulogne@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Paris – Service Pianos Numériques</em><br />Contactez-nous  au 01 43 58 05 45 <br />ou <U><a href=\"mailto:numerique@centre-chopin.com\">numerique@centre-chopin.com</a></U></p><p> <em>Centre Chopin Boulogne – Service Pianos  Numériques</em><br />Contactez-nous au 01  46 10 44 77 <br />ou <U><a href=\"mailto:boulogne@centre-chopin.com\">boulogne@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Paris – Boutique Accessoires &amp; Guitares</em><br />Contactez-nous  au 01 43 58 05 45 <br />ou <U><a href=\"mailto:boutique@centre-chopin.com\">boutique@centre-chopin.com</a></U></p><p> <em>Centre Chopin Boulogne – Boutique  Accessoires &amp; Guitares</em><br />Contactez-nous  au 01 46 10 44 77 <br />ou <U><a href=\"mailto:boulogne@centre-chopin.com\">boulogne@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Boulogne – Service Pianos Acoustiques</em><br />Contactez-nous  au 01 46 10 44 77 <br />ou <U><a href=\"mailto:boulogne@centre-chopin.com\">boulogne@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Paris – Service Pianos Acoustiques</em><br />Contactez-nous  au 01 43 58 05 45 <br />ou <U><a href=\"mailto:piano@centre-chopin.com\">piano@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Boulogne – Service Pianos Numériques</em><br />Contactez-nous  au 01 46 10 44 77 <br />ou <U><a href=\"mailto:boulogne@centre-chopin.com\">boulogne@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Paris – Service Pianos Numériques</em><br />Contactez-nous  au 01 43 58 05 45 <br />ou <U><a href=\"mailto:numerique@centre-chopin.com\">numerique@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Boulogne – Boutique Accessoires &amp;  Guitares</em><br />Contactez-nous au 01 46 10 44 77 <br />ou <U><a href=\"mailto:boulogne@centre-chopin.com\">boulogne@centre-chopin.com</a></U></p>" , "<p><span class=\"texte-rouge\"> NOUS CONSULTER</span><br /><em>Centre  Chopin Paris – Boutique Accessoires &amp; Guitares</em><br />Contactez-nous  au 01 43 58 05 45 <br />ou <U><a href=\"mailto:boutique@centre-chopin.com\">boutique@centre-chopin.com</a></U></p>" , "");

function zl_lref(l)
{
	if (isIE) return document.all[l];
	if (isW3C) return document.getElementById(l);
}

function changeStyle(id,styleName)
{
	zl_lref(id).className = styleName;
}

function changeImg(id,src) {
	zl_lref(id).src = src;
}

function changeContent(obj,content)
{
	zl_lref(obj).innerHTML=content;
}

function changeValue(obj,content)
{
	zl_lref(obj).value=content;
}

function hideBlock(id)
{
	zl_lref(id).style.display = 'none';
}

function showBlock(id)
{
	zl_lref(id).style.display = 'block';
}

function showHide(id)
{
	if(zl_lref(id).style.display == 'none') showBlock(id);
	else if(zl_lref(id).style.display == 'block') hideBlock(id);
}

function hideContent(id)
{
	zl_lref(id).style.visibility = 'hidden';
}

function showContent(id)
{
	zl_lref(id).style.visibility = 'visible';
}

function hideSRub(currentItem)
{
	for(var i=0; i<tabItem.length; i++)
	{
		if(tabItem[i] != currentItem) hideContent(tabItem[i]);
	}
}

function popUp(src,name,x,y,w,h)
{
	w = window.open(src,name,"left="+x+",top="+y+",height="+h+",width="+w+",scrollbars=0,status=0,location=0,menubar=0,resizable=0");
	w.focus();
}

function popUpScroll(src,name,x,y,w,h)
{
	w = window.open(src,name,"left="+x+",top="+y+",height="+h+",width="+w+",scrollbars=1,status=0,location=0,menubar=0,resizable=0");
	w.focus();
}

function showZoom(img)
{
	popUp("/include/media_players/play_img.php?media=../../"+img,"zoom",10,10,200,200);
}

function selectStock(selStock,field)
{
	val = parseInt(zl_lref(field).value);
	currentStock = selStock;
	if(val > stock[currentStock] && stock[currentStock] > 0)
	{
		zl_lref(field).value = stock[currentStock];
	}
	return stock[currentStock];
}

function selectDelai(selStock,field)
{
	val = parseInt(zl_lref(field).value);
	currentStock = selStock;
	if(val > stock[currentStock] && stock[currentStock] > 0)
	{
		zl_lref(field).value = stock[currentStock];
	}
	return stock[currentStock];
}

function inc_quantity(field) {
	val = parseInt(zl_lref(field).value);
	if(val+1 > stock[currentStock]) alert("Stock insuffisant - Maximum stock reached");
	else zl_lref(field).value++;
}

function dec_quantity(field) {
	if(zl_lref(field).value-1>0) zl_lref(field).value--;
}

function affichePort(selectId, weight)
{
	sel = zl_lref(selectId);
	idPays = sel.options[sel.selectedIndex].value;
	changeContent("zoneFraisPort",ajax("ajax/calcfraisport/frame.html?idCountry="+idPays+"&weight="+weight))
}

function updateProd()
{
	var id = "";
	var optLabel = "";
	for(var i=0; i<optId.length; i++)
	{
		sel = zl_lref('selectOption'+optId[i]);
		id += sel.options[sel.selectedIndex].value + "-";
		name = sel.options[sel.selectedIndex].text;
		optLabel += "\n" + name;
		changeContent('infoOption'+optId[i], name);
	}
	if(ref[id])
	{
		showBlock('achat');
		showBlock('buyProd');
		hideBlock('achatNoExist');
		if(ref[id][3])
		{
			price = ref[id][3].toFixed(2) + '';
			oldprice = ref[id][1].toFixed(2) + '';
			changeValue('item_price', price);
			price = price.replace(/\./,",");
			oldprice = oldprice.replace(/\./,",");
			changeContent('prixProd', price);
			changeContent('prixProdOld', oldprice);
			showBlock('promo');
		}
		else
		{
			price = ref[id][1].toFixed(2) + '';
			oldprice = '0,00';
			changeValue('item_price', price);
			price = price.replace(/\./,",");
			changeContent('prixProd', price);
			changeContent('prixProdOld', oldprice);
			hideBlock('promo');
		}
		if(ref[id][4])
		{
			price = ref[id][4].toFixed(2) + '';
			price = price.replace(/\./,",");
			changeContent('prixCat', price);
			showBlock('prixCatDiv');
		}
		else
		{
			price = "";
			changeContent('prixCat', price);
			hideBlock('prixCatDiv');
		}
		if(ref[id][2] == 0)
		{
			showBlock('portDiv');
		}
		else
		{
			hideBlock('portDiv');
		}
		changeValue('item_ref', ref[id][0]);
		changeValue('item_weight', ref[id][2]);
		changeValue('item_optLabel', optLabel);
		var afficheprix = pricedisplay[ref[id][0]];
		if(afficheprix >= 0 && afficheprix <= 8)
		{
		hideBlock('achat');
		hideBlock('buyProd');
		changeContent('achatContactOnly', option_prod[afficheprix]);
		}
		else if(afficheprix >= 9 && afficheprix <= 17)
		{
		showBlock('achat');
		hideBlock('buyProd');
		changeContent('achatContactOnly', option_prod[afficheprix]);
		}
		else
		{
		showBlock('achat');
		showBlock('buyProd');
		changeContent('achatContactOnly', option_prod[afficheprix]);
		}
		var stock = selectStock(ref[id][0], 'item_quantity');
		if(stock == 0)
		{
			/*
			zl_lref('dispoProd').className = "dispo dispo_0";
			changeContent('dispoProd','Article non disponible');
			*/
			hideBlock('buyProd');
		}
		else if(stock > 0)
		{
			/*
			zl_lref('dispoProd').className = "dispo dispo_1";
			changeContent('dispoProd','Exp&eacute;dition imm&eacute;diate');
			*/
		}
		if(offer[ref[id][0]])
		{
			separ="";
			html="";
			for(var i=0; i<offer[ref[id][0]].length; i++)
			{
				html+="<li>"+separ+"<div class=\"cadeau\">";
				html+="<div class=\"infos\"></div>";
				html+="<div class=\"img\"><img src=\"dyn/produits/images/image_ape_"+offer[ref[id][0]][i][0]+".jpg\" title=\""+offer[ref[id][0]][i][1]+"\" /></div>";
				html+="</div></li>";
				separ = "<div class=\"plus\"></div>";
			}
			changeContent('cadeauHtml',html);
			showBlock('cadeauxDiv');
		}
		else
		{
			hideBlock('cadeauxDiv');
		}
	}
	else
	{
		hideBlock('achat');
		showBlock('achatNoExist');
	}
}

function optionImage(selectId, optionValue, prodUpdate)
{
	sel = zl_lref('selectOption'+selectId);
	var l = sel.options.length;
	for(var i=0; i<l; i++)
	{
		if(sel.options[i].value == optionValue)
		{
			sel.selectedIndex = i;
		}
	}
	for(var i=0; i<zl_lref('imgOptions_'+selectId).childNodes.length; i++)
	{
		if(zl_lref('imgOptions_'+selectId).childNodes[i].className == "imageOption imageOptionOn")
		{
			zl_lref('imgOptions_'+selectId).childNodes[i].className = "imageOption";
		}
	}
	zl_lref('clickImage'+optionValue).className = "imageOption imageOptionOn";
	changeImg('imgProdMoy','dyn/produits/option/image/image_moy_'+optionValue+'.jpg');
	changeValue('item_img', 'dyn/produits/option/image/image_ape_'+optionValue+'.jpg');
	imgZoom = 'dyn/produits/option/image/image_zoom_'+optionValue+'.jpg';
	if(prodUpdate == true) updateProd();
}

function optionToImage(selectId)
{
	sel = zl_lref('selectOption'+selectId);
	optionValue = sel.options[sel.selectedIndex].value;
	optionImage(selectId, optionValue, false);
}

function ajax(fichier)
{
	if(window.XMLHttpRequest) // FIREFOX
		xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	else 
		return(false); 
	xhr_object.open("GET", fichier, false); 
	xhr_object.send(null); 
	if(xhr_object.readyState == 4)
		return(xhr_object.responseText);
	else
		return(false);
}

function verifSize(elem,size) {
	if(elem.value.length>size) {
		alert("La longeur du texte ne doit pas dépasser "+size+" caracteres");
		elem.value=elem.value.slice(0,size);
	}
}

function saveNewsEmail()
{
	email = zl_lref('newsEmail').value;
	changeContent("resultEmail", "En cours d'envoi");
	changeContent("resultEmail",ajax("ajax/inscriptionnewsletter/frame.html?newsEmail="+email));
}

