function ScrollFWto(page,sel,objectId)
{
	
	//var currentUrl=window.location+''; // convert object into string by adding empty string '' to it 
	var currentPage=location.pathname.substring(location.pathname.lastIndexOf('/')+1)
	//alert(currentPage);
	
	pageName = page.substring( 0, page.indexOf('.') ); //remove extension
	//alert (pageName);
	
	if (!(currentPage.match(pageName))) { 
	//if (currentPage.indexOf("pageName")== -1) { //Not from the same page?
		//alert("not the same page");
		window.location=page+'?sel='+sel+'&#'+objectId;  //goto page
	
	} else {  //autoscroll
		var scrollSize=2; //no. of pixels per scroll
		var posX=0;
		var posY=findPosY(document.getElementById(objectId)); 
		//alert(posY);
	
		var scrollSize=5; //no. of pixels per scroll
		var speed=1; // smaller the faster
		
		for (var i=0; i<posY; i=i+scrollSize){
			window.scrollTo(0,i)
			for (var ii=0; ii<speed*10; ii++){} //delay
		}
	}
}



function findPosX(obj) { //get x position of object
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}

function findPosY(obj) {  //get y position of object
    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;
}



/*alert(location.href); // displays 'http://www.irt.org:8080/some/where/deep/inside/filename.htm?name=martin#anchorname'
alert(location.protocol); // displays 'http:'
alert(location.hostname); // displays 'www.irt.org'
alert(location.host); // displays 'www.irt.org:8080'
alert(location.port); // displays '8080'
alert(location.pathname); // displays '/some/where/deep/inside/filename.htm'
alert(location.search); // displays '?name=martin'
alert(location.hash); // displays 'anchorname'
*/


