var speed=100
var loop, timer
var nPage = 70
var nSub=0
var nClipHeight = new Array(), nTextHeight = new Array();

function Scroll(offset, what) {
	loop=true;
	if (what=="last") {
		container = 'divContainerLast';
		content = 'divContentLast';
	}
	if (what=="news") {
		container = 'divContainerNews';
		content = 'divContentNews';
	}
	var docText = doc(content, Array(container));
	var styText = sty(content, Array(container));
	if (is.ns4) {
		if ((offset>0 && parseInt(styText.top) < nYPadding) || (offset<0 && parseInt(styText.top) > nClipHeight[what]-nTextHeight[what])) {
			//alert("qqq");
			var top = ClipGet(docText,'t') - offset;
			var right = ClipGet(docText,'r');
			var bottom = ClipGet(docText,'b') - offset;
			var left = ClipGet(docText,'l');
			ClipTo(docText,top,right,bottom,left);
			styText.top = parseInt(styText.top) + offset;
//Stop();
			if(loop) timer = setTimeout('Scroll('+offset+',"'+what+'")',speed);
		}
	} else if (is.ie4) {
		if ((offset>0 && parseInt(styText.pixelTop) < nYPadding) || (offset<0 && parseInt(styText.pixelTop) > nClipHeight[what]-nTextHeight[what])) {
		//alert("qqq");
			var top = ClipGet(docText,'t') - offset;
			var right = ClipGet(docText,'r');
			var bottom = ClipGet(docText,'b') - offset;
			var left = ClipGet(docText,'l');
			ClipTo(docText,top,right,bottom,left);
			styText.pixelTop = parseInt(styText.pixelTop) + offset;
//Stop();
			if(loop) timer = setTimeout('Scroll('+offset+',"'+what+'")',speed);
		//}
		//else {
		//	alert(offset);
		}
	}
//Stop();
//return false;
}

function Stop() {
	loop=false
	clearTimeout(timer)
}

function Is() {
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.ns2 = (this.ns && (this.major == 2));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4b = (this.ns && (this.minor < 4.04));
    this.ns4 = (this.ns && (this.major >= 4));
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie3  = (this.ie && (this.major == 2));
    this.ie4  = (this.ie && (this.major >= 4));
    this.op3 = (agent.indexOf("opera") != -1);
    this.win   = (agent.indexOf("win")!=-1);
    this.mac   = (agent.indexOf("mac")!=-1);
    this.unix  = (agent.indexOf("x11")!=-1);
}
var is = new Is();

function onerror() {
    document.location.href = "javascript:";
}

function doc(id,nest) {
	if (is.ns4)
		return eval('document.' + ((nest) ? nest.join('.document.')+'.document.' : '') + id);
	else if (is.ie4)
		return eval(id);
}

function sty(id,nest) {
	if (is.ns4)
		return eval('document.' + ((nest) ? nest.join('.document.')+'.document.' : '') + id);
	else if (is.ie4)
		return eval(id+'.style');
}


function MoveTo(obj,x,y) {
	if (x!=null) {
		if (is.ns4) obj.left = x
		else obj.style.pixelLeft = x
	}
	if (y!=null) {
		if (is.ns4) obj.top = y
		else obj.style.pixelTop = y
	}
}

function MoveBy(obj,x,y) {
	if (is.ns4) MoveTo(obj.left+x,obj.top+y)
	else if (is.ie4) MoveTo(obj.style.pixelLeft+x, obj.style.pixelTop+y)
}

function ClipGet(obj,which) {
	if (is.ie4) var clipv = obj.style.clip.split("rect(")[1].split(")")[0].split("px")
	if (which=="t") return (is.ns4)? obj.clip.top : Number(clipv[0])
	if (which=="r") return (is.ns4)? obj.clip.right : Number(clipv[1])
	if (which=="b") return (is.ns4)? obj.clip.bottom : Number(clipv[2])
	if (which=="l") return (is.ns4)? obj.clip.left : Number(clipv[3])
}

function ClipTo(obj,t,r,b,l) {
	if (is.ns4) {
		if (t != null) obj.clip.top = t
		if (r != null) obj.clip.right = r
		if (b != null) obj.clip.bottom = b
		if (l != null) obj.clip.left = l
	}
	else if (is.ie4) {
		if (t == null) t = ClipGet(obj,'t')
		if (r == null) r = ClipGet(obj,'r')
		if (b == null) b = ClipGet(obj,'b')
		if (l == null) l = ClipGet(obj,'l')
		obj.style.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"
	}
}

function InitDiv() {
	nXPadding = 0;
	nYPadding = 0;
	
	//Initialize Last Minutes
	what = "last";
	docText = doc('divContentLast', Array('divContainerLast'));
	styText = sty('divContentLast', Array('divContainerLast'));
	nTextHeight[what] = (is.ns4) ? docText.document.height : docText.offsetHeight;
	nClipHeight[what] = (is.ns4) ? sty('divContainerLast').clip.bottom : 140;
	nClipWidth = (is.ns4) ? sty('divContainerLast').clip.right : 200;

	if (is.ns4) {
		MoveTo(docText,nXPadding,nYPadding);
		document.layers.divContainerLast.visibility = "visible";
	} else {
		MoveTo(docText,null,nYPadding);
		ClipTo(docText,0,nClipWidth,nClipHeight[what]-nYPadding,0);
		document.all.divContainerLast.style.visibility = "visible";
	};
	
	//Initialize News
	what = "news";
	docText = doc('divContentNews', Array('divContainerNews'));
	styText = sty('divContentNews', Array('divContainerNews'));
	nTextHeight[what] = (is.ns4) ? docText.document.height : docText.offsetHeight;
	nClipHeight[what] = (is.ns4) ? sty('divContainerNews').clip.bottom : 140;
	nClipWidth = (is.ns4) ? sty('divContainerNews').clip.right : 200;

	if (is.ns4) {
		MoveTo(docText,nXPadding,nYPadding);
		document.layers.divContainerNews.visibility = "visible";
	} else {
		MoveTo(docText,null,nYPadding);
		ClipTo(docText,0,nClipWidth,nClipHeight[what]-nYPadding,0);
		document.all.divContainerNews.style.visibility = "visible";
	};
}

function doc(id,nest) {
	if (is.ns4)		
	
		return eval('document.' + ((nest) ? nest.join('.document.')+'.document.' : '') + id);
	else if (is.ie4)
		return eval(id);
}
