var is = new browserCheck();
var left_min = 0, top_min = 0, left_max = 0, top_max = 0, leftIndent = 0;
var activeObject;
var myLayers = new Array ("body");
function browserCheck() {
	var b = navigator.appName;
	this.agent = window.navigator.userAgent;
	this.win = (this.agent.indexOf('Win')>0);
	this.mac = (this.agent.indexOf('Mac')>0);
	switch (b) {
		case "Netscape": this.b = "ns"; break;
		case "Microsoft Internet Explorer": this.b = "ie"; break;
		default: this.b = b};
	this.version = navigator.appVersion;
	this.v = parseInt(this.version);
	this.ns = (this.b=="ns" && this.v>=4);
	this.ns4 = (this.b=="ns" && this.v==4);
	this.ns5 = (this.b=="ns" && this.v==5);
	this.ie = (this.b=="ie" && this.v>=4);
	this.ie4 = (this.version.indexOf('MSIE 4')>0);
	this.ie5 = (this.version.indexOf('MSIE 5')>0);
	this.min = (this.ns||this.ie);
	if (this.ns4) {
		var d = document; var w = window;
		if (typeof d.cs == 'undefined') {
			d.cs = new Object;
			d.cs.csFix = new Object};
		d.cs.csFix.w = w.innerWidth;
		d.cs.csFix.h = w.innerHeight;
		window.onresize = NSFixFct}};
function NSFixFct() {
	var d = document; var w = window;
	if (d.cs.csFix.w != w.innerWidth || d.cs.csFix.h != w.innerHeight) {
		d.location = d.location}};

function layerObj (id) {
	this.id = id;
	this.obj = findLayer (this.id);
	if (is.ns4) {
		this.x = this.obj.left;
		this.y = this.obj.top}
	else {
		this.x = this.obj.offsetLeft;
		this.y = this.obj.offsetTop};
	this.write = writeLayer;
	this.clip = clipLayer;
	this.getWidth = getWidth;
	this.getHeight = getHeight;
	this.setHeight = setHeight;
	this.getClip = getClipValue;
	this.moveTo = moveLayerTo;
	this.moveBy = moveLayerBy;
	//this.scrollBy = scrollLayerBy;
	this.alignMiddle = alignMiddle;
	this.show = show;
	this.hide = hide};

function textObj (id, w, h) {
	this.id = id + "TextObj";
	eval(this.id+"=this");
	this.layer = new layerObj (id);
	this.layer.w = this.layer.getWidth ();
	this.layer.h = this.layer.getHeight ();
	if (w == null) {
		w = this.layer.w};
	if (h == null) {
		h = this.layer.h};
	this.layer.show ()};
function findElement(name, layer) {
	if (is.version < 4) {
		return document[name]};
	if (is.v == 4) {
		var curDoc = layer ? layer.document : document, elem = curDoc[name];
		if (!elem) {
			for (var i=0;i<curDoc.layers.length;i++) {
				elem = findElement (name, curDoc.layers[i]);
				if (elem) {
					return elem}}}}
	else {
		elem = document.getElementById (name)};
	return elem};
function findLayer (name) {
	if (is.ie) {
		return document.all.tags("div")[name]}
	else {
		return findElement(name,0)}};
function getWidth () {
	if (is.ie) {
		return (is.ie4)? this.obj.style.pixelWidth :  this.obj.offsetWidth}
	else {
		if (is.ns4) {
			if ( this.obj.document.width) {
				return ( this.obj.document.width)}
			else {
				return ( this.obj.clip.right -  this.obj.clip.left)}}
		else {
			return this.obj.style.width}};
	return -1};
function getHeight () {
	if (is.ns4) {
		return this.obj.clip.height}
	else if (is.ie) {
		if (this.obj.style.pixelHeight) {
			return this.obj.style.pixelHeight}
		else {
			return this.obj.clientHeight}}
	else {
		return parseInt (this.obj.scrollHeight)};
	return -1};

function setHeight (value) {
	if (is.ns4) {
		this.obj.document.height = value}
	else {
		this.obj.style.height = value};
	return true};
function writeLayer (html) {
	if (is.ns4) {
		this.obj.document.open ();
		this.obj.document.write (html);
		this.obj.document.close ()}
	else {
		this.obj.innerHTML = html}};
function moveLayerTo (x, y) {
	if (x!=null) {
		this.x = x;
		if (is.ie) {
			 this.obj.style.pixelLeft = this.x}
		else {
			if (is.ns4) {
				this.obj.left = this.x}
			else {
				this.obj.style.left = this.x}}};
	if (y!=null) {
		this.y = y;
		if (is.ie) {
			 this.obj.style.pixelTop = this.y}
		else {
			if (is.ns4) {
				this.obj.top = this.y}
			else {
				this.obj.style.top = this.y}}}};
function moveLayerBy (dx, dy) {
	this.moveTo(this.x+dx,this.y+dy)};
function clipLayer(clipleft, cliptop, clipright, clipbottom) {
	if (is.ns4) {
		this.obj.clip.left  = clipleft;
		this.obj.clip.top = cliptop;
		this.obj.clip.right = clipright;
		this.obj.clip.bottom = clipbottom}
	else {
		this.obj.style.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';}};
function getClipValue (which) {
	if (is.ns4) {
		return this.obj.clip[which]}
	else {
		if (this.obj.style.clip) {
			var clip = getIEClipValues(this.obj.style.clip);
			switch (which) {
				case "top": return clip[0];
				case "right": return clip[1];
				case "bottom": return clip[2];
				case "left": return clip[3]}}};
	return 0;
	return -1};
function getIEClipValues(str) {
	var clip = new Array();
	var i;
	i = str.indexOf("(");
	clip[0] = parseInt(str.substring(i + 1, str.length), 10);
	i = str.indexOf(" ", i + 1);
	clip[1] = parseInt(str.substring(i + 1, str.length), 10);
	i = str.indexOf(" ", i + 1);
	clip[2] = parseInt(str.substring(i + 1, str.length), 10);
	i = str.indexOf(" ", i + 1);
	clip[3] = parseInt(str.substring(i + 1, str.length), 10);
	return(clip)};
function show () {
	if (is.ns4) {
		this.obj.visibility = 'show'}
	else {
		this.obj.style.visibility = "visible"}};
function hide () {
	if (is.ns4) {
		this.obj.visibility = 'hide'}
	else {
		this.obj.style.visibility = "hidden"}};
function alignMiddle () {
	var pageWidth = 770;
	var pageHeight = 600;
	if (is.ie) {
		leftIndent = (document.body.clientWidth-pageWidth)/2;
		topIndent = (document.body.clientHeight-pageHeight)/2;
	} else {
		leftIndent = (window.innerWidth-pageWidth)/2;
		topIndent = (window.innerHeight-pageHeight)/2;
	}
	left = leftIndent + this.pos_x;
	//topx = topIndent + this.pos_y;
	//if (left < this.pos_x) {
	//	left = this.pos_x};this.pos_ythis.pos_y
	//alert(topx);
	this.moveTo (left,this.pos_y);
}
function newsclicker() {
	var temp= tickers[ini].substring(0,st)+"_";
	var x= tickers[ini].length;

	temp = "<span style='font:verdana;font-size:16px;font-weight:bold'><i>"+temp+"</a></span>";
	if (is.ie) {
		  slideshowdiv.innerHTML = ""+temp;
	}else if (is.ns4) {
		document.slideshowlayer.document.open();
		document.slideshowlayer.document.write(temp);
		document.slideshowlayer.document.close();
	}else if (is.ns) {
		document.getElementById("slideshowdiv").innerHTML = temp;
	}
	
	if(st++==x) {
		//Adjust timer for delay between messages
		st=0;
		setTimeout("newsclicker()",2000);
		ini++;
		if(ini==lgth) {
			ini=0; 
			x=tickers[ini].length;
		}
	}else {
		setTimeout("newsclicker()",10);
	}
};

function toggleDiv(id,flagit) {
	if (flagit=="1") {
		if (document.layers) {
			document.layers[''+id+''].visibility = "show";
			}
		else if (document.all) {
			document.all[''+id+''].style.visibility = "visible";
			}
		else if (document.getElementById) {
			document.getElementById(''+id+'').style.visibility = "visible";
			};
		}
	else if (flagit=="0") {
		if (document.layers) {
			document.layers[''+id+''].visibility = "hide";
			}
		else if (document.all) {
			document.all[''+id+''].style.visibility = "hidden";
			}
		else if (document.getElementById) {
			document.getElementById(''+id+'').style.visibility = "hidden";
			}};
	};
	
function alignLayers() {
	for (var ct=0;ct<myLayers.length;ct++) {
		myObj = eval(myLayers[ct] + "TextObj");
		myObj.layer.alignMiddle ();
		}
	};
function init() {
	//alert("done");
	for (var ct=0;ct<myLayers.length;ct++) {
		myObj = new textObj (myLayers[ct], null, null);
		myObj.layer.pos_x = myObj.layer.x;
		myObj.layer.pos_y = myObj.layer.y;
		myObj.layer.alignMiddle ();
	}
	window.onresize = alignLayers;
	//activeObject = eval(activeObject)
	//activeObject[3] = 1
	
	initialized = true
}
