/* (c) Kalamun 2009 - GPL 3 */

function chooseColor(id) {
	document.getElementById('mainimg').src=colori[id];
	
	div=document.getElementById('menuColori').getElementsByTagName('div');
	for(var i=0;div[i];i++) {
		if(div[i].id.substring(0,11)=="prevScritte") div[i].className="prevScritte";
		}
	div=document.getElementById('menuColori').getElementsByTagName('li');
	for(var i=0;div[i];i++) {
		if(div[i].id.substring(0,10)=="rigaColore") div[i].className="rigaColore";
		}
	document.getElementById('rigaColore'+id).className="rigaColoreSel";
	document.getElementById('prevScritte'+id).className="prevScritteSel";
	}

k_Navigator=function() {
	var currentImg=0;
	var div_container=false;
	var Timer=false;
	var show="true";
	var imgs=Array();
	var tmphh=0;
	var destinationURL="";
	var offset=120;
	var pixelratio=1;

	this.setContainer=function(c) {
		div_container=document.getElementById(c).getElementsByTagName('UL')[0];
		div_container.style.position="absolute";
		div_container.style.top="30px";
		div_container.style.left=0;
		}

	this.init=function() {
		imgs=div_container.getElementsByTagName('li');
		var height=0;
		var sel=false;
		for(var i=0;imgs[i];i++) {
			if(imgs[i].className=="sel") sel=true;
			if(sel==false) tmphh+=imgs[i].offsetHeight+40;
			height+=imgs[i].offsetHeight+5;
			var a=imgs[i].getElementsByTagName('A')[0];
			a.setAttribute("i",i);
			}
		tmphh+=imgs[i-1].offsetHeight/2;
		div_container.style.height=height+'px';
		if(height>div_container.parentNode.offsetHeight) {
			div_container.onmouseover=this.moveStart;
			div_container.onmouseout=this.moveStop;
			pixelratio=(height-div_container.parentNode.offsetHeight+offset)/(div_container.parentNode.offsetHeight-offset);
			}
		}
	
	this.moveStart=function() {
		Timer=setInterval(move,20);
		}
	this.moveStop=function() {
		clearInterval(Timer);
		}
	this.move=function() {
		var posNow=-((kWindow.mousePos.y-offset)*pixelratio)+offset;
		div_container.style.top=parseInt(div_container.style.top)-((parseInt(div_container.style.top)-posNow)/10)+'px';
		}
	move=this.move;
	}