// ASM SCROLLER 2.0 - (c) 2000 Brent Gustafson, vitaflo.com and assembler.org
//
//
// -Brent (brent@assembler.org)
// assembler.org || vitaflo.com

var w3c = (document.getElementById) ? 1:0
var ns4 = (document.layers) ? 1:0
var ie4 = (document.all) ? 1:0

var range = "";
var cap = "";
var mutex = 0;
var yplace = 0;
var ymax = 0;
var ymin = 0;
var xplace = 0;
var xmax = 0;
var xmin = 0;
var newsHeight = 0;
var newsWidth = 0;

/** The only code you should ever need to change here are the following 3 vars **/
var speed = 3;                        //speed at which the news scrolls
var newsId = "content";              //name of the overall news div
var newsClipId = "container";       //name of the news clipping div

function redrawScreen() {
  location.reload();
  return false
}

function shiftTo(obj, x, y) {
  if (w3c) {
    obj.style.left = x + "px";
    obj.style.top = y + "px";
  }
  else if (ns4) {
	 obj.moveTo(x,y);
  } 
  else if (ie4) {
    obj.style.pixelLeft = x;
	obj.style.pixelTop = y;
  }
}

function getObject(obj) {
	var theObj = eval("document." + range + obj + cap);
	return theObj;
} 
//Scroll Up####################################################
function scrollUp() {
  if (mutex == 1){
    var theObj = getObject(newsId);
    if (yplace < ymax) {
      yplace = yplace + speed;
      if (yplace > ymax) yplace = ymax;
      shiftTo(theObj, xplace, yplace);
      setTimeout("scrollUp()",25);
	  init()
    }
  }
}
//Scroll Down####################################################
function scrollDown() {
  if (mutex == 2){
    var theObj = getObject(newsId);
    if (yplace > ymin) {
      yplace = yplace - speed;
      if (yplace < ymin) yplace = ymin;
      shiftTo(theObj, xplace, yplace);
      setTimeout("scrollDown()",25);
	  init()
    }
  }
}
//Scroll Left####################################################
function scrollLeft() {
  if (mutex == 3){
    var theObj = getObject(newsId);
    if (xplace < xmax) {
      xplace = xplace + speed;
      if (xplace > xmax) xplace = xmax;
      shiftTo(theObj, xplace, yplace);
      setTimeout("scrollLeft()",25);
	  init()
    }
  }
}
//Scroll Right####################################################
function scrollRight() {
  if (mutex == 4){
    var theObj = getObject(newsId);
    if (xplace > xmin) {
      xplace = xplace - speed;
      if (xplace < xmin) xplace = xmin;
      shiftTo(theObj, xplace, yplace);
      setTimeout("scrollRight()",25);
	  init()
    }
  }
}


function scrollIt(msg, dir) {
  window.status = msg; 
  mutex = dir;
  if (mutex == 1) scrollUp();
  else if (mutex == 2) scrollDown();
  else if (mutex == 3) scrollLeft();
  else if (mutex == 4) scrollRight();
}

function init() {
  if (w3c) {
    range = "getElementById(\"";
    cap = "\")";
	//height
    theObj = getObject(newsClipId);
    newsHeight = parseInt(theObj.offsetHeight);
    theObj = getObject(newsId);
    ymin = (parseInt(theObj.offsetHeight) - newsHeight) * -1;
	//width
    theObj = getObject(newsClipId);
    newsWidth = parseInt(theObj.offsetWidth);
    theObj = getObject(newsId);
    xmin = (parseInt(theObj.offsetWidth) + newsWidth) * -1;
  }
  else if (ns4) {
    window.captureEvents(Event.RESIZE);
    window.onresize = redrawScreen;
	//height
    theObj = getObject(newsClipId);
    newsHeight = theObj.clip.height;
    newsId = newsClipId + ".document." + newsId;
    theObj = getObject(newsId);
    ymin = (theObj.clip.height - newsHeight) * -1;
	//width
    theObj = getObject(newsClipId);
	newsWidth = theObj.clip.width;
	alert(newsWidth)
    newsId = newsClipId + ".document." + newsId;
    theObj = getObject(newsId);
    xmin = (theObj.clip.width - newsWidth) * -1;
  }
  else if (ie4) {
    range = "all.";
	//height
    theObj = getObject(newsClipId);
    newsHeight = theObj.offsetHeight;
    theObj = getObject(newsId);
    ymin = (theObj.offsetHeight - newsHeight) * -1;
	//width
    theObj = getObject(newsClipId);
	newsWidth = theObj.offsetWidth;
    theObj = getObject(newsId);
    xmin = (theObj.offsetWidth - newsWidth) * -1;
  }
}

// END OF LINE

