// checking for a browser type
var isMinNS4 = document.layers; //
var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1; //Internet Explorer
var dom=document.getElementById&&!ie&&navigator.userAgent.indexOf("Opera")==-1; //Firefox

news_topedge = 680;  // location of news box from top of page
news_leftedge = 150;  // location of news box from left edge
news_boxheight = 120;  // height of news box
news_boxwidth = 168;  // width of news box

events_topedge = 680;  // location of events box from top of page
events_leftedge = 529;  // location of events box from left edge
events_boxheight = 120;  // height of events box
events_boxwidth = 168;  // width of events box

tradeshows_topedge = 680;  // location of tradeshows box from top of page
tradeshows_leftedge = 529;  // location of tradeshows box from left edge
tradeshows_boxheight = 120;  // height of tradeshows box
tradeshows_boxwidth = 168;  // width of tradeshows box

function scrollnews(cliptop) {

var news_layer;

//finds the position of a placeholder which is a relative div
//so we can insert our div in the right spot 

news_layer = getLayer("news_placeholder");
news_leftedge = getPageLeft(news_layer);
news_topedge = getPageTop(news_layer);

if (isMinNS4)
{
	newsDiv = document.news;
	newsDiv.clip.top = cliptop;
	newsDiv.clip.bottom = cliptop + news_boxheight;
	newsDiv.clip.left = 0;
	newsDiv.clip.right = news_boxwidth + news_leftedge;
	newsDiv.left = news_leftedge;
	newsDiv.top = news_topedge - cliptop;
}
if (ie)
{
	//alert(news_topedge);
	news_scrollheight = parseInt(document.all("news").offsetHeight) - 12; // total height of all data to be scrolled
	newsDiv = document.getElementById("news").style;
	newsDiv.clip = "rect(" + cliptop + "px " +  (news_boxwidth + news_leftedge) + "px "  + (cliptop + news_boxheight) + "px 0px)";
	newsDiv.left = news_leftedge;
	newsDiv.top = news_topedge - cliptop;
	//alert(newsDiv.pixelTop);
}
if (dom)
{
	//alert(news_topedge);
	news_scrollheight = document.all("news").clientHeight - 8; // total height of all data to be scrolled
	newsDiv = document.getElementById("news").style;
	newsDiv.clip = "rect(" + cliptop + "px " +  (news_boxwidth + news_leftedge) + "px "  + (cliptop + news_boxheight) + "px 0px)";
	newsDiv.left = news_leftedge;
	newsDiv.top = news_topedge - cliptop;
	//alert(newsDiv.pixelTop);
}

cliptop = (cliptop + 1) % (news_scrollheight + news_boxheight);
if (isMinNS4)
    news.visibility = "show";
if (ie||dom)
    news.style.visibility = "visible";
if ((cliptop % (news_scrollheight + news_boxheight) == 120) || (cliptop % (news_scrollheight + news_boxheight) == 240) || (cliptop % (news_scrollheight + news_boxheight) == 360))
{
	setTimeout("scrollnews(" + cliptop + ")", 0);
}
else
{
	setTimeout("scrollnews(" + cliptop + ")", 85);
}
}

function scrollevents(cliptop) {

var events_layer;

//finds the position of a placeholder which is a relative div
//so we can insert our div in the right spot 

events_layer = getLayer("events_placeholder");
events_leftedge = getPageLeft(events_layer);
events_topedge = getPageTop(events_layer);
if (isMinNS4)
{
	eventsDiv = document.events;
	eventsDiv.clip.top = cliptop;
	eventsDiv.clip.bottom = cliptop + events_boxheight;
	eventsDiv.clip.left = 0;
	eventsDiv.clip.right = 0;
	eventsDiv.left = events_leftedge;
	eventsDiv.top = events_topedge - cliptop;
}
if (ie)
{
	events_scrollheight = parseInt(document.all("events").offsetHeight) - 12; // total height of all data to be scrolled
	eventsDiv = document.getElementById("events").style;
	eventsDiv.clip = "rect(" + cliptop + "px " + (events_boxwidth + events_leftedge) + "px " + (cliptop + events_boxheight) + "px 0px)";
	eventsDiv.left = events_leftedge;
	eventsDiv.top = events_topedge - cliptop;
}
if (dom)
{
	events_scrollheight = parseInt(document.all("events").clientHeight) - 8; // total height of all data to be scrolled
	eventsDiv = document.getElementById("events").style;
	eventsDiv.clip = "rect(" + cliptop + "px " + (events_boxwidth + events_leftedge) + "px " + (cliptop + events_boxheight) + "px 0px)";
	eventsDiv.left = events_leftedge;
	eventsDiv.top = events_topedge - cliptop;
}
cliptop = (cliptop + 1) % (events_scrollheight + events_boxheight);
if (isMinNS4)
    events.visibility = "show";
if (ie||dom)
    events.style.visibility = "visible";
if ((cliptop % (events_scrollheight + events_boxheight) == 120) || (cliptop % (events_scrollheight + events_boxheight) == 240) || (cliptop % (events_scrollheight + events_boxheight) == 360))
{
	setTimeout("scrollevents(" + cliptop + ")", 2000);
}
else
{
	setTimeout("scrollevents(" + cliptop + ")", 15);
}
}

function scrolltradeshows(cliptop) {

var tradeshows_layer;

//finds the position of a placeholder which is a relative div
//so we can insert our div in the right spot 

tradeshows_layer = getLayer("tradeshows_placeholder");
tradeshows_leftedge = getPageLeft(tradeshows_layer);
tradeshows_topedge = getPageTop(tradeshows_layer);

if (isMinNS4)
{
	tradeshowsDiv = document.tradeshows;
	tradeshowsDiv.clip.top = cliptop;
	tradeshowsDiv.clip.bottom = cliptop + tradeshows_boxheight;
	tradeshowsDiv.clip.left = 0;
	tradeshowsDiv.clip.right = tradeshows_boxwidth + tradeshows_leftedge;
	tradeshowsDiv.left = tradeshows_leftedge;
	tradeshowsDiv.top = tradeshows_topedge - cliptop;
}
if (ie)
{
	//alert(news_topedge);
	tradeshows_scrollheight = parseInt(document.all("tradeshows").offsetHeight) - 12; // total height of all data to be scrolled
	tradeshowsDiv = document.getElementById("tradeshows").style;
	tradeshowsDiv.clip = "rect(" + cliptop + "px " +  (tradeshows_boxwidth + tradeshows_leftedge) + "px "  + (cliptop + tradeshows_boxheight) + "px 0px)";
	tradeshowsDiv.left = tradeshows_leftedge;
	tradeshowsDiv.top = tradeshows_topedge - cliptop;
	//alert(newsDiv.pixelTop);
}
if (dom)
{
	//alert(news_topedge);
	tradeshows_scrollheight = document.all("tradeshows").clientHeight - 8; // total height of all data to be scrolled
	tradeshowsDiv = document.getElementById("tradeshows").style;
	tradeshowsDiv.clip = "rect(" + cliptop + "px " +  (tradeshows_boxwidth + tradeshows_leftedge) + "px "  + (cliptop + tradeshows_boxheight) + "px 0px)";
	tradeshowsDiv.left = tradeshows_leftedge;
	tradeshowsDiv.top = tradeshows_topedge - cliptop;
	//alert(newsDiv.pixelTop);
}

cliptop = (cliptop + 1) % (tradeshows_scrollheight + tradeshows_boxheight);
if (isMinNS4)
    tradeshows.visibility = "show";
if (ie||dom)
    tradeshows.style.visibility = "visible";
if ((cliptop % (tradeshows_scrollheight + tradeshows_boxheight) == 120) || (cliptop % (tradeshows_scrollheight + tradeshows_boxheight) == 240) || (cliptop % (tradeshows_scrollheight + tradeshows_boxheight) == 360))
{
	setTimeout("scrolltradeshows(" + cliptop + ")", 2000);
}
else
{
	setTimeout("scrolltradeshows(" + cliptop + ")", 15);
}
}

function getLayer(name) {
  if (isMinNS4)
    return findLayer(name, document);
  if (ie)
    return eval('document.all.' + name);
  if (dom)
    return document.getElementById(name);
  return null;
}

function findLayer(name, doc) {

  var i, layer;

  for (i = 0; i < doc.layers.length; i++) {
    layer = doc.layers[i];
    if (layer.name == name)
      return layer;
    if (layer.document.layers.length > 0) {
      layer = findLayer(name, layer.document);
      if (layer != null)
        return layer;
    }
  }

  return null;
}

function getPageLeft(layer) {

  if (isMinNS4)
    return(layer.pageX);
  if (ie||dom)
    return(layer.offsetLeft);
  return(-1);
}

function getPageTop(layer) {

  if (isMinNS4)
    return(layer.pageY);
  if (ie||dom)
    return(layer.offsetTop);
  return(-1);
}