// JavaScript Document

function selectMenuItem(itemNr) {
	for(var i=1; i<6; i++) {
		el = document.getElementById('mi_'+i);
		if(el) {
			if(itemNr == i) {
				el.className = 'menu_act';
			} else {
				el.className = 'menu';
			}
		}
	}
}


function loadImage(url) {
	el = document.getElementById('image');
	el.src = url;
}
function loadCaption(pageID, cUID) {
	el = document.getElementById('caption');
	el.style.visibility = "hidden";
	el.src = 'index.php?id='+pageID+'&cid='+cUID+'&type=8';	
}

function artistListRoll(nr) {
	curr = 1
	el = document.getElementById('artist_'+curr);
	while(el) {
		if(curr == nr) {
			el.className = "act";
		} else {
			el.className = "norm";
		}
		curr++;
		el = document.getElementById('artist_'+curr);
	}
}
function showArtistImage(imgsrc) {
	el = document.getElementById('artistimage');
	el.src = imgsrc;
}


var windowWidth;

var thumbs;
var thumbsWidth;
var maxScroll = 0;
var currScroll = 0;

var mouseX;
var mouseY;

function windowResized() {
	windowWidth = document.body.clientWidth;
	
	if(thumbsWidth && thumbs) {
		maxScroll = Math.max(0, thumbsWidth - windowWidth);
		
		currScroll = Math.max(0, Math.min(maxScroll, currScroll));
		thumbs.style.left = -currScroll;		
	}
}


function rollThumbs(isOver) {
	hidePopup();
	
	if(!thumbs) {
		thumbs = document.getElementById('thumbnails');
	}
	if(thumbs) {
		if(isOver) {
			windowWidth = document.body.clientWidth;
			thumbsWidth = thumbs.clientWidth;
			maxScroll = Math.max(0, thumbsWidth - windowWidth);
	
			if (document.layers) { // Netscape
				document.captureEvents(Event.MOUSEMOVE);
			}
			document.onmousemove = getMouseXY;
	
			scrollUpdate();
		} else {
			maxScroll = 0;
			document.onmousemove = null;
			// alert(mouseX);
		}
	}
}

function scrollUpdate() {
	if(thumbs) {
		if(maxScroll) {
			var offc = mouseX - windowWidth/2;
			if (Math.abs(offc) > windowWidth/3) {
				var sign = Math.abs(offc)/offc;
				offc -= windowWidth/3 * sign;
				currScroll = Math.max(0, Math.min(maxScroll, currScroll+(offc*offc/10000*sign)));
				thumbs.style.left = -currScroll;
			}
		}
	}
	if(maxScroll) {
		setTimeout("scrollUpdate()", 80);
	}
}

function getMouseXY(e) {
  if (!e) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0;}
  if (tempY < 0){tempY = 0;}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  mouseX = tempX;
  mouseY = tempY;
  return true
}


function showPopup() {
	el = document.getElementById('menuitem_2');
	if(el) {
		nr = 1;
		el = document.getElementById('menuitem_1');
		while(el) {
			el.style.visibility = "hidden";
			nr++;
			el = document.getElementById('menuitem_'+nr);
		}
	
		el = document.getElementById('popmenu');
		el.style.visibility = "visible";
		
		setTimeout("showPopupItem(1);", 100);
	}
}
function hidePopup() {
	el = document.getElementById('popmenu');
	if(el) {
		el.style.visibility = "hidden";
	}
	nr = 1;
	el = document.getElementById('menuitem_1');
	while(el) {
		el.style.visibility = "hidden";
		nr++;
		el = document.getElementById('menuitem_'+nr);
	}
}
function showPopupItem(nr) {
	el = document.getElementById('menuitem_'+nr);
	if(el) {
		pe = document.getElementById('popmenu');
		if(pe.style.visibility == "visible") {
			el.style.visibility = "visible";
			nr++;
			setTimeout("showPopupItem("+nr+");", 100);
		}
	}
}

function selectPopItem(nr) {
	hidePopup();
}

/* function loadContentPageID(pageID) {
	top.loadContentPageID(pageID);
	els = top.document.getElementsByName('page');
	els[0].src = '../../index.php?id='+pageID+'&type=1';
} */




