var photosNumber = photoNames.length-1, curc = 1, cura = 1, maxCura = 6, start = 1;

function changePhotosLayoutOn(index) {
	var t,rot = 0;
	if (index == cura) {
		return;
	} else if (index == 'prev') {
		index = cura - 1;
		if (!index) index--;
		rot = -1;
	} else if (index == 'next') {
		index = cura + 1;
		rot = 1;
	} else {
		t = document.images['selarr' + cura].src;
		document.images['selarr' + cura].src = empty.src;
		cura = index;
	}
//alert(index);
	if (index > 0) curc = start + index - 1;
	else curc = start + index;

	start += rot;
	if (start > photosNumber) start -= photosNumber;
	else if (start < 1) start += photosNumber;

	if (curc > photosNumber) curc -= photosNumber;
	if (curc < 1) curc += photosNumber;

	document.images.photo0.src = photoTemp.src;
	document.images.photo0.src = bigImgDir + '/' + photoNames[curc];

	if (rot != 0) for (var i = 1; i <= 6; i++) {
		var curp = start + i - 1;
		if (curp > photosNumber) curp -= photosNumber;
		else if (curp < 1) curp += photosNumber;
		document.images['photo' + i].src = smallImgDir + '/' + photoNames[curp];
	} else {
		document.images['selarr' + cura].src = t;
	}
}
