//FUNZIONE DI SCROLLING

var clipTop;
var clipWidth;
var clipBottom ;
var topper;
var lyrheight;
var time,amount,theTime,theHeight,DHTML;
var conta=0

function prepLyr(divName,curclipTop,curclipWidth,curclipBottom,curtopper,curlyrheight)
{
	clipTop = curclipTop;
	clipWidth = curclipWidth;
	clipBottom = curclipBottom;
	topper =  curtopper;
	lyrheight = curlyrheight;
	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	var x = new getObj(divName);
	if (document.layers)
	{
		lyrheight = x.style.clip.bottom;
		x.style.clip.top = clipTop;
		x.style.clip.right = clipWidth;
		x.style.clip.bottom = clipBottom;
		x.style.clip.background = "#9FC9F7";
	}
	else if (document.getElementById || document.all)
	{
		lyrheight = x.obj.offsetHeight;
		x.style.clip = 'rect('+clipTop+' '+clipWidth+' '+clipBottom+' 0)'
		
	}
}

function scrollayerUpDown(layername,amt,tim)
{
	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	
		if(namePage=="profilo"){
			
			if(ie4){countHeight=document.all.scrollWitch.document.images["altro_0"].width}
			if(ns4){countHeight=document.layers["scrollWitch"].document.images["altro_0"].width}
			if(ns6){countHeight=document.getElementById("scrollWitch").document.images["altro_0"].width}
			
			var curHeight=lyrheight-countHeight
			conta+=amt
			if(conta==curHeight){
			
					if(ie4)	{
							document.all.botClip.style.visibility="hidden"; 
							document.all.topClip.style.visibility="visible";
					}
					if(ns6) {
							document.getElementById("botClip").style.visibility="hidden"; 
							document.getElementById("topClip").style.visibility="visible";
					}
					if(ns4) {
							document.layers["botClip"].visibility="hidden"; 
							document.layers["topClip"].visibility="show";
					}
				}
				
					if(conta>0 && conta<curHeight){
				
					if(ie4)	{
							document.all.topClip.style.visibility="visible"; 
							document.all.botClip.style.visibility="visible";
					}
					if(ns6) {
							document.getElementById("topClip").style.visibility="visible"; 
							document.getElementById("botClip").style.visibility="visible";
					}
					if(ns4) {
							document.layers["topClip"].visibility="show"; 
							document.layers["botClip"].visibility="show";
					}
					
				}
				
				if(conta==0){
				
					if(ie4)	{
							document.all.topClip.style.visibility="hidden"; 
							document.all.botClip.style.visibility="visible";
					}
					if(ns6) {
							document.getElementById("topClip").style.visibility="hidden"; 
							document.getElementById("botClip").style.visibility="visible";
					}
					if(ns4) {
							document.layers["topClip"].visibility="hidden"; 
							document.layers["botClip"].visibility="show";
					}
					
				}

		}
	realscroll();
}

function stopScroll()
{
	if (time) clearTimeout(time);
return true}

function realscroll()
{
	if (!DHTML) return;
	clipTop += amount;
	clipBottom += amount;
	topper -= amount;
	
	if (clipTop < 0 || clipBottom > lyrheight)
	{
		clipTop -= amount;
		clipBottom -= amount;
		topper += amount;
		return;
	}
	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop+' '+clipWidth+' '+clipBottom+' 0)'
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper;
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop;
		thelayer.style.clip.bottom = clipBottom;
		thelayer.style.top = topper;
	}
	if(namePage=="profilo"){
	time = setTimeout('stopScroll()',theTime);}
	else{time = setTimeout('realscroll()',theTime);}
	
}

function vis(divName,val)
{
	if (!DHTML) return;
	var f = new getObj(divName);
	f.style.visibility = val;
}

function getObj(name)
{
  if (document.getElementById)
  {
    this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
    this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}
