var timp = 0;

function resize(x) {
	var a = document.body.style.fontSize;
	a = eval(a.substring(a,a.length-2));	
	if ( x != 0 ) a = a + x
	else a = 10;
	if (a<8) a = 8;
	document.body.style.fontSize = a +'px';
}

function goleste(id) {
	if ((id.value == 'Votre e-mail') || (id.value == 'password') || (id.value == 'Votre email')) {
		id.value = '';
	}
}

function umple(text,id) {
	if (id.value == '') {
		id.value = text;
	}
}
function mf_inchis(id) {

	var x = 'none'
	if(document.getElementById(id)) document.getElementById(id).style.display = x;
	//if(id=="login") refreshLoginBox();
}
function mf(id) {
	var x = document.getElementById(id).style.display;
	if (x == 'block') x = 'none'
	else x = 'block';
	document.getElementById(id).style.display = x;
	//if(id=="login") refreshLoginBox();
}

function mf2(id) {
	var x = document.getElementById(id).style.display;
	if (x == 'block') x = 'none'
	else {
		x = 'block';
		activare_cos(id);
	}
	document.getElementById(id).style.display = x;
	
}

function activare_cos(id)
{
	productsListCart();
	document.getElementById(id).style.display="block";
	
}


function meniu(id) {
	if (id.className == '') id.className = 'activ'
	else id.className = '';
}


function meniuT1(id) {
	id.className = 'activ';

}

function meniuT2(id) {
	id.className = '';
}


function meniu1(id) {
	id.className = 'activ';
	if (navigator.appName=="Microsoft Internet Explorer") {
		var b_version=navigator.appVersion;
		var version=parseFloat(b_version);	
		var x;
				if (self.innerHeight) // all except Explorer
				{
					x = self.innerWidth;
				}
				else if (document.documentElement && document.documentElement.clientHeight)
					// Explorer 6 Strict Mode
				{
					x = document.documentElement.clientWidth;
				}
				else if (document.body) // other Explorers
				{
					x = document.body.clientWidth;
				}

		var bf = document.body.style.fontSize.substring(0,eval(document.body.style.fontSize.length-2));
		var left = 0;
		var top = 0;

		left = findPos(id)[0]-((x-95*bf)/2)-198;
		top = findPos(id)[1]+(2.4*bf);
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 
			var ieversion=new Number(RegExp.$1)
		} else {ieversion=6;}
		
		//alert(ieversion);
		id.getElementsByTagName('ul')[0].style.visibility = 'visible';
		if (ieversion==7) id.getElementsByTagName('ul')[0].style.marginLeft = left+'px';
		if (ieversion==6) id.getElementsByTagName('ul')[0].style.left = left+'px';
		if (ieversion==8) {
			left=left-21;
			id.getElementsByTagName('ul')[0].style.position = 'absolute';			
			id.getElementsByTagName('ul')[0].style.left = '0px';
		}
		id.getElementsByTagName('ul')[0].style.top = top+'px';				
	}
}

function meniu2(id) {
	id.className = '';
	if (navigator.appName=="Microsoft Internet Explorer") {
		id.getElementsByTagName('ul')[0].style.left = -9000+'px';
	}
	
}


function pressEnter(e) {

var keynum

if(window.event) // IE
	{
	keynum = e.keyCode
	}
else if(e.which) // Netscape/Firefox/Opera
	{
	keynum = e.which
	}

	if (keynum == 13) {
		submitRecherche(0,0,0,0,0,-2) ;
	}
}

function pressEnter2(e) {

var keynum

if(window.event) // IE
	{
	keynum = e.keyCode
	}
else if(e.which) // Netscape/Firefox/Opera
	{
	keynum = e.which
	}
	if (keynum == 13) {
		submitRecherche('couleur','domaine','appellation','classement','millesime',-1);
	}
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}



function contMenu(id) {
	var i;
	for (i=1;i<=4;i++) {
		if (document.getElementById('c'+i)) {
			document.getElementById('c'+i).className='';
			document.getElementById('c'+i).getElementsByTagName('ul')[0].style.left = '-9000px';
		}
	}
	if (id) {
		id.className = 'active';
		
				var x;
				if (self.innerHeight) // all except Explorer
				{
					x = self.innerWidth;
				}
				else if (document.documentElement && document.documentElement.clientHeight)
					// Explorer 6 Strict Mode
				{
					x = document.documentElement.clientWidth;
				}
				else if (document.body) // other Explorers
				{
					x = document.body.clientWidth;
				}

		var bf = document.body.style.fontSize.substring(0,eval(document.body.style.fontSize.length-2));
		var left = 0;
		var top = 0;


		left = findPos(id)[0]-((x-95*bf)/2);
		top = findPos(id)[1]+(2.4*bf);
		
		//alert(x+'--'+findPos(id)[0]+'--'+left);
		id.getElementsByTagName('ul')[0].style.visibility = 'visible';
		id.getElementsByTagName('ul')[0].style.left = left+'px';
		id.getElementsByTagName('ul')[0].style.top = top+'px';
	}

}

function selectOnLoad() {
	if (document.getElementById('cauta')) {
		var select = document.getElementById('cauta').getElementsByTagName('select');
		for (var i=0;i<select.length;i++) {
			schimba(select[i]);
		}
	}
}	

function schimba(id) {
	for (var i=0;i<document.getElementById('cauta').getElementsByTagName('label').length;i++) {
		if (document.getElementById('cauta').getElementsByTagName('label')[i].htmlFor == id.id) {
			if (id.options[id.selectedIndex].value == '-1') {
				document.getElementById('cauta').getElementsByTagName('label')[i].getElementsByTagName('a')[0].className = '';
			}
			else document.getElementById('cauta').getElementsByTagName('label')[i].getElementsByTagName('a')[0].className = 'activ';
		}	
	}	
}

function cantitate(cat,id) {
	x = document.getElementById(id).getElementsByTagName('input')[0].value;
	x = eval(x) + eval(cat);
	if (x <= 0) x = 0;
	document.getElementById(id).getElementsByTagName('input')[0].value = x;
	mod_pret(id);
}

function pret_final(total,products_number) {
	document.getElementById('prod').getElementsByTagName('em')[1].innerHTML = total+'&euro;';
		document.getElementById('prod').getElementsByTagName('em')[0].innerHTML = products_number;

}

function mod_pret(id,value) {
	var price=eval(document.getElementById(id).getElementsByTagName('input')[0].value) * eval(document.getElementById(id).getElementsByTagName('small')[0].getElementsByTagName('span')[0].innerHTML) + '&euro;';
	document.getElementById(id).getElementsByTagName('em')[0].innerHTML = value;//price.substring(price,price.indexOf(".")+3);
	
	
}


function size(id) {

	var inner_x,inner_y;
		if (self.innerHeight) // all except Explorer
		{
			inner_x = self.innerWidth;
			inner_y = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
			// Explorer 6 Strict Mode
		{
			inner_x = document.documentElement.clientWidth;
			inner_y = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			inner_x = document.body.clientWidth;
			inner_y = document.body.clientHeight;
		}
	
	var scroll_y;
		if (self.pageYOffset) // all except Explorer
		{
			scroll_y = self.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop)
			// Explorer 6 Strict
		{
			scroll_y = document.documentElement.scrollTop;
		}
		else if (document.body) // all other Explorers
		{
			scroll_y = document.body.scrollTop;
		}
	
	
	
	document.getElementById(id).style.left = eval(inner_x/2)+'px';
	document.getElementById(id).style.top = eval(scroll_y+inner_y/2)+'px';
}


function inchide(id) {
	document.getElementById(id).style.left = -9000+'px';
}

function deschide(id) {
	size(id);
	document.getElementById(id).className = '';
}


function init_dia() {
	
	setTimeout("diaporama()", 5000);
}

function diaporama() {
	timp++;
	if (timp >= 3) timp = 1;
	document.getElementById('dia').src = document.getElementById('dia').src.substr(0,document.getElementById('dia').src.length-5)+timp+'.jpg';
	setTimeout("diaporama()", 5000);

}



//PENTRU MENIU STANGA
function arataMeniu() {
	var numar = this.id.substring(4,this.id.length);
	allLi = this.parentNode.getElementsByTagName('li');
	if (this.className != 'sageataJos') {
		numar = eval(numar-16);
	}
	for (var i = 0; i<=numar; i++) {
		allLi[i].style.display = 'none';
	}
	for (var i = eval(numar+1); i<allLi.length; i++) {
		allLi[i].style.display = 'block';
	}
}


//PENTRU MENIU STANGA FOR IE
function arataMeniuIE(id) {
	var numar = id.alt.substring(4,id.alt.length);
	allLi = id.parentNode.getElementsByTagName('li');
	if (id.className != 'sageataJos') {
		numar = eval(numar-16);
	}
	for (var i = 0; i<=numar; i++) {
		allLi[i].style.display = 'none';
	}
	for (var i = eval(numar+1); i<allLi.length; i++) {
		allLi[i].style.display = 'block';
	}
	
}


function scrollMenu() {
	var menuLi=	document.getElementById('newsletter').parentNode.getElementsByTagName('ul')[0].getElementsByTagName('ul')[3].parentNode;
	menuLi.style.width = '11em';
	
	var ul1 = document.getElementById('leftMenu').getElementsByTagName('ul')[1].getElementsByTagName('ul');
	for (var i = 0; i<ul1.length; i++) {
		if (ul1[i]) {
			var li = ul1[i].getElementsByTagName('li');
			if (li.length > 15) {
				li[0].parentNode.style.height = '22.5em';
				
					if (navigator.appName == "Microsoft Internet Explorer") {
						li[0].parentNode.style.height = '22.2em';
					}
					
				var j = 0;
				while (j<li.length) {
					if ((j+1)%15 == 0) {
						try {
							    var sageataJos = document.createElement("<li class='sageataJos' onclick='arataMeniuIE(this);' title='Appelations suivantes' alt='elem"+j+"'><a>&nbsp;</a></div>");
								ul1[i].insertBefore(sageataJos,li[j]);
								j++;
							    var sageataSus = document.createElement("<li class='sageataSus' onclick='arataMeniuIE(this);' title='Appelations pr&eacute;c&eacute;dentes' alt='elem"+j+"'><a>&nbsp;</a></div>");
								ul1[i].insertBefore(sageataSus,li[j]);
								j++;
							} catch (e) {
								var sageataJos = document.createElement('li');
								var sageataJosA = document.createElement('a');
									sageataJos.setAttribute('class','sageataJos');
									sageataJos.setAttribute('id','ele'+i+j);
									sageataJos.setAttribute('title','Appelations suivantes');
									sageataJos.onclick = arataMeniu;
									sageataJos.appendChild(sageataJosA);
									ul1[i].insertBefore(sageataJos,li[j]);
									j++;
								var sageataSus = document.createElement('li');
								var sageataSusA = document.createElement('a');
									sageataSus.setAttribute('class','sageataSus');
									sageataSus.setAttribute('id','ele'+i+j);
									sageataSus.setAttribute('title','Appelations précédentes');
									sageataSus.onclick = arataMeniu;
									sageataSus.appendChild(sageataSusA);
									ul1[i].insertBefore(sageataSus,li[j]);
									j++;
							}		
					}
					j++;
				}
			}
		}	
	}
}

