function getScrollY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [scrOfY];
 
  var ls= getScrollY();
	} 



function setScrollY() {
		var scx = readCookie("adminLastScroll");
	if (scx > 0){
			window.scrollTo(1000, scx);
			}
	} 


  function findPosY(obj)
  {
	  obj = document.getElementById(obj);
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }


var vscrollfrom = 0;
var vscrollto = 0;

function scr(obj){
vscrollfrom = parseFloat(getScrollY());
vscrollto = findPosY(obj);

if (vscrollfrom < vscrollto){
scrolluj();
} 

if (vscrollfrom > vscrollto){
scrollujSpat();
} 

}


function scrolluj(){
	curY = parseFloat(getScrollY());
//	alert (curY);
//	alert (vscrollto);
	var nextY = curY+((vscrollto-curY)/15)+2;
	if (curY < vscrollto) {window.scrollTo(0,nextY); setTimeout(scrolluj,8);}
//	document.title = nextY;
	
}

function scrollujSpat(){
	curY = parseFloat(getScrollY());
//	alert (curY);
//	alert (vscrollto);
//alert (curY);
//alert (vscrollto);
	var nextY = curY-((curY-vscrollto)/15)-2;
	if (curY > vscrollto) {window.scrollTo(0,nextY); setTimeout(scrollujSpat,8);}
//	document.title = nextY;
	
}



function CenterToScreen(objwidth, objheight) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = (window.innerWidth - objwidth) / 2;
    myHeight = ((window.innerHeight - objheight) / 2) + document.documentElement.scrollTop;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = (document.documentElement.clientWidth - objwidth) / 2;
    myHeight = ((document.documentElement.clientHeight - objheight) / 2) + document.documentElement.scrollTop;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = (document.body.clientWidth - objwidth) / 2;
    myHeight = ((document.body.clientHeight - objheight) / 2) + document.body.scrollTop;
  }
 
  return [myWidth,myHeight];
}


function ToScreen(objwidth, objheight) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = (document.body.clientWidth - objwidth);
    myHeight = ((window.innerHeight - objheight)) + document.documentElement.scrollTop;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = (document.documentElement.clientWidth - objwidth) ;
    myHeight = ((document.documentElement.clientHeight - objheight) ) + document.documentElement.scrollTop;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = (document.body.clientWidth - objwidth);
    myHeight = ((document.body.clientHeight - objheight)) + document.body.scrollTop;
  }
 
//  return [myWidth,myHeight];
  return myWidth;
}

function advert(obj,w,h){
var wid = ToScreen(w,h);
document.getElementById(obj).style.left = wid+"px";
}
