
var antal_klick = 0
var clipTop = 15;
var clipWidth = 600;
var clipBottom = 300;
var topper = 80;
var lyrheight = 0;
var time,amount,theTime,theHeight,DHTML;


function prepLyr()
{
	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	var x = new getObj('books');
	if (document.layers)
	{
		
		lyrheight = x.style.clip.bottom;
		lyrheight += 20;
		x.style.clip.top = clipTop;
		x.style.clip.left = 0;
		x.style.clip.right = clipWidth;
		x.style.clip.bottom = clipBottom;
		
		
		
	}
	else if (document.getElementById || document.all)
	{
		lyrheight = x.obj.offsetHeight;
	
		 clipTop = 15;
		 clipWidth = 600;
		 clipBottom = 300;
		 
		x.style.clip = 'rect('+clipTop+' '+clipWidth+' '+clipBottom+' 0)'
				
	}
}

function scrollayer(layername,amt,tim)
{

	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	topper = 80;
	
	realscroll();
}

function stopScroll()
{
	if (time) clearTimeout(time);
}

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;
	}
	time = setTimeout('realscroll()',theTime);
}

function noll(){
// Värdet på top och topper reglerar hur högt lagret kommer
if (document.all) {
		document.all['books'].style.clip = 'rect('+0+' '+600+' '+300+' 0)';
		document.all['books'].style.top = 80;
		topper=80;}
		
		
else if (document.getElementById) {
		document.getElementById('books').style.clip = 'rect('+0+' '+600+' '+300+' 0)';
    	document.getElementById('books').style.top = 80;
		topper=80;}

else if (document.layers) {	
		document.layers['books'].style.clip.top = 0;
		document.layers['books'].style.clip.bottom = 300;
		document.layers['books'].style.style.top = 80;
		topper=80;}	
}


function vis(val)
{
	if (!DHTML) return;
	var f = new getObj('books');
	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];
  }
}



function scrollayer_up(layername,amt,tim)
{
	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll_up();
}

function realscroll_up()
{
	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;
	}
	time = setTimeout('realscroll()',theTime);
}


function scrollayer_down(layername,amt,tim)
{
	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll_down();
}

function realscroll_down()
{


	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;
		//ändra så att topper värdet blir rätt - lagrar från tidigare scroll!!!!!!!!!!!!!!!!

	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop;
		thelayer.style.clip.bottom = clipBottom;
		thelayer.style.top = topper;
	}

	time = setTimeout('realscroll()',theTime);
}

