// JavaScript Document
//main navigation 
topNavHover = function() {
	if ($('topNavigation')){
		var className = 'hover';
		var pattern = new RegExp('(^|\\s+)' + className + '(\\s+|$)');
		
		var lis = $('topNavigation').getElementsByTagName("LI");
		for (var i=0; i<lis.length; i++) {
			if (lis[i].id !='homeLink') {
				lis[i].onmouseover=function() {
					//this.className="hover";
					this.className = this.className += ' ' + className;
				}
				lis[i].onmouseout=function() {
					//this.className="";
					this.className = this.className.replace(pattern, ' ');
				}
			}
		}
	}
}


mainNavHover = function() {
	if ($('mainNav')){

		var className = 'hover';
		var pattern = new RegExp('(^|\\s+)' + className + '(\\s+|$)');
		var lis = $('mainNav').getElementsByTagName("LI");
		for (var i=0; i<lis.length; i++) {
			lis[i].onmouseover=function() {
				this.className = this.className += ' ' + className;
				uls = this.getElementsByTagName("UL");
				links = this.getElementsByTagName("span");
				for (var j=0; j<uls.length; j++) {
					uls[j].style.left = this.offsetLeft + 'px';
					clWidth = document.documentElement.clientWidth;
					ulWidth = clWidth - this.offsetLeft - (clWidth-950)/2;
					uls[j].style.width = ulWidth + "px";
				}
			}
			lis[i].onmouseout=function() {
				this.className = this.className.replace(pattern, ' ');
			}
		}
	}
}

function previewImage(imageContainer, imageWidth) {
//	$('galleryPreview').src = imageSource.src;
	var imgSource = $(imageContainer).getElementsByTagName("IMG");
	for (var i=0; i<imgSource.length; i++) {
		$('galleryPreview').src = imgSource[i].src;
		$('galleryPreview').width = imageWidth;
	}
	return false;
}




function moveThumbnails(direction, count) {
	if (direction == 'top') {
		obj = $('thumbs');
		if (parseInt($('currentImage').value) > 0) {
			new Effect.Move(obj,{x:0, y:290, mode: 'relative'});
			$('currentImage').value = parseInt($('currentImage').value) - 8;
		}
	} else {
		obj = $('thumbs');
		if (parseInt($('currentImage').value) < parseInt($('imagesCount').value)  - count) {
			new Effect.Move(obj,{x:0, y:-290, mode: 'relative'});
			$('currentImage').value = parseInt($('currentImage').value) + 8;
		}
	}
	return false;
}



Event.observe(window, 'load', topNavHover);
Event.observe(window, 'load', mainNavHover);