/*var clipTop = 0;
var clipWidth = 170;
var clipBottom = 50; */
var clipTop , clipWidth , clipBottom, clipLeft;
var topper = 0;
var lyrheight = 0;
var thelayer;
var time,amount,theTime,theHeight,DHTML;
var styleClip="";

 function getObj(name)
{
  if (document.getElementById)
  {
   if(document.getElementById(name)!=null)
   {
   var Obj =document.getElementById(name);
	return Obj;
	} else return null;
  }
  else if (document.all)
  {
	if(document.all(name)!=null)
	{
		this.obj = document.all[name];
		this.style = document.all[name].style;
	} else return null;
	
  }
  else if (document.layers)
  {
	if(document.layers[name]!=null)
	{
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	} else return null;
  }
}

function toCamelCase( sInput ) 
{
    var oStringList = sInput.split('-');

    if(oStringList.length == 1) 
	{	
        return oStringList[0];
	}
    var ret = sInput.indexOf("-") == 0 ?

       oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0];

    for(var i = 1, len = oStringList.length; i < len; i++)
	{
        var s = oStringList[i];
        ret += s.charAt(0).toUpperCase() + s.substring(1)
    }
    return ret;
}

function getStyle(el, style) 
{
   if(!document.getElementById) return;
     var value ="";
	 value=el.style[toCamelCase(style)];
    if(!value)
	{
        if(document.defaultView)
		{
            value = document.defaultView.getComputedStyle(el, "").getPropertyValue(style);
		}
	    else 
		{
			if(el.currentStyle)
			{
				value = el.currentStyle[toCamelCase(style)];
			}
		}
	}
	
     return value;

}

function setStyle(objId, style, value) 
{
 document.getElementById(objId).style[style] = value;
}


/*
function init()
{
	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	if (getObj("modeLists")!=null)
	{
		var x = new getObj('modeLists');
		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;
			//topper =x.style.top;
		}
		else if (document.getElementById || document.all)
		{
			lyrheight = x.offsetHeight;
			//lyrheight=0;
			//topper =document.getElementById('mode').offsetHeight;
			x.style.clip = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
			//alert(x.style);
		}
	}
}
*/

function GetClipSettings(thelayer)
{
	var clipSyle=getStyle(thelayer, "clip").toString();
	 if (!clipSyle)
	 {
		return ;
	 }
	 var clipArray =((((clipSyle).replace("rect(" ,"")).replace(")","")).replace(/px/g,"")).replace(/,/g,"").split(" ");
	
		clipTop = parseInt(clipArray[0]);
		clipWidth = parseInt(clipArray[1]);
		clipBottom = parseInt(clipArray[2]);
		clipLeft = parseInt(clipArray[3]);
}

function scrollayer(layername,amt,time)
{

	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML)
	{
		return;
	}
	
	if (getObj(layername)!=null)
	{
		
	    theTime = time;
		thelayer = new getObj(layername);
		if (!thelayer)
		{
			return;
		}
		GetClipSettings(thelayer);
		topper=thelayer.offsetTop;
		lyrheight = thelayer.offsetHeight;
	//	alert(lyrheight);
		amount = amt;
		 
		realscroll();
		
	}
}

function realscroll()
{
	clipTop += amount;
	clipBottom += amount;
	topper -= amount;
	//alert("intru "+ clipTop +"  <0 "+clipBottom+"> "+lyrheight);
	
	if (clipTop < 0 || clipBottom > lyrheight)
	{
		clipTop -= amount;
		clipBottom -= amount;
		topper += amount;
		return;
	}
	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop+'px '+clipWidth+'px '+clipBottom+'px '+ clipLeft+ 'px)';
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper + 'px ';
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop;
		thelayer.style.clip.bottom = clipBottom;
		thelayer.style.top = topper;
	}
	time = setTimeout('realscroll()',theTime);
}

function stopScroll()
{
	if (time) clearTimeout(time);

}
