var path="http://glass-art.ro/img/";
function arata(buton){
      var img= path+"2.jpg"
	document.getElementById(buton).style.background = "url(" + img + ")";
}
function cellImg(idCell, imgName) {
document.getElementById(idCell).style.background = "url(" + imgName + ")";
}
function trigger(i, nr, nra) {
	var ml = document.getElementById('container').style.marginLeft;
	var semn = 1;
	var viteza = 3;
	if (ml.charAt(0) == '-') {
		semn = -1;
		ml = parseInt(ml.substring(1, ml.length-2));
	} else {
		ml = parseInt(ml.substring(0, ml.length-2));
	}
	var peste = document.getElementById('peste').value;
	peste = parseInt(peste);
//	if (peste && (ml > (-525+2)) && (ml < (525-2))) {
	if (peste && (ml > -(nr-nra)*105) && (ml < (nr-nra)*105)) {
		var nouml = semn*ml + parseInt(i)*viteza;
/* mers in cerc */
// 		if (nouml < (-525+3)) {
// 			nouml = 525 - 3;
// 		}
// 		if (nouml > (525-3)) {
// 			nouml = (-525+3);
// 		}
/* mers in limite */
		if (nouml < -(nr-nra)*105+1) {
			nouml = -(nr-nra)*105+1;
		}
		if (nouml > 0) {
			nouml = 0;
		}
		document.getElementById('container').style.marginLeft = nouml + "px";
		setTimeout("trigger('" + i + "', " + nr + ", " + nra + ")", 1);
	} else {
		document.getElementById('peste').value = 1;
	}
}
function termina() {
	document.getElementById('peste').value = 0;
}
function init(catepoze, prima) {
	document.getElementById('container').style.width = (catepoze*105) + "px";
//	document.getElementById('container').style.width = "735px";
	pozaShow(prima);
}
function pozaShow(val){
	document.getElementById('poza').src= "images/" + val;
	var tabel = document.getElementById('tabel');
	var tabele = tabel.getElementsByTagName('table');
	var tabelLength = tabele.length;
		for (i=0;i<tabelLength;i++) {
			var idTabel = tabele[i].getAttribute("id");
			if (idTabel == val) {
				tabele[i].setAttribute('class', 'vizibil');
				tabele[i].className= 'vizibil';
			} else {
				tabele[i].setAttribute('class', 'ascuns');
				tabele[i].className= 'ascuns';
			}
		}
}
