function initPage()
{
	var nav = document.getElementById("nav");
	if (nav)
	{
		var nodes = nav.getElementsByTagName("li");
		for (var i = 0; i < nodes.length; i++)
		{
			nodes[i].onmouseover = function () 
			{
				if (this.className.indexOf("hover") == -1)
				{
					this.className += " hover";
				}
			}
			nodes[i].onmouseout = function ()
			{
				this.className = this.className.replace(" hover", "");
			}
		}
	}
}
function initRightproduct()
{
	var nav = document.getElementById("right-product");
	if (nav)
	{
		var nodes = nav.getElementsByTagName("li");
		for (var i = 0; i < nodes.length; i++)
		{
			nodes[i].onmouseover = function () 
			{
				if (this.className.indexOf("hover") == -1)
				{
					this.className += " hover";
				}
			}
			nodes[i].onmouseout = function ()
			{
				this.className = this.className.replace(" hover", "");
			}
		}
	}
}

if (window.attachEvent && !window.opera){
	window.attachEvent("onload", initPage);
	window.attachEvent("onload", initRightproduct);
}



var img_counter = null;
var img_preview = null;
var img_zoom = null;

var _nodes = [];
var _current = 0;

function initGallery() {
	var _box = $('gallery');
	img_preview = $('gallery-preview');
	img_counter = $('gallery-counter');
	img_zoom = $('gallery-zoom');
	
	_nodes = $ES('a','gallery');
	_nodes.each(function(_node, i) {
		_node._index = i;
		_node.onclick = function() {
			_nodes.each(function(_tmp){
				_tmp.parentNode.className = _tmp.parentNode.className.replace("active", "");
			});
			if (img_preview && this.rev)
			{
				img_preview.src = this.rev;
			}
			if (img_counter)
			{
				img_counter.innerHTML = this._index+1;
			}
			_current = this._index;
			this.parentNode.className += " active";
			return false;
		};
	});
	if (_box)
	{
		var hs = new noobSlide({
		box: _box,
		items: $ES('li','gallery'),
		size: 79,
		_cut: 2,
		mode: 'vertical',
		interval: 3000,
			fxOptions: {
				duration: 500,
				wait: false
			},
			buttons: {
				previous: $('gallery-prev'),
				next: $('gallery-next')
			}
		});
	}
	if (img_zoom)
	{
		img_zoom.onclick = function() {
			if (Lightbox && Lightbox.anchors.length)
			{
				_nodes[_current]._onclick();
			}
			return false;
		};
	}
}


if (window.addEventListener)
	window.addEventListener("load", initGallery, false);
else if (window.attachEvent && !window.opera)
	window.attachEvent("onload", initGallery);

