

var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isDyn = (isDOM || isIE4 || isNS4);


function mdLoadVar(vn, rn){ with (this)
{
	if(this.tRunning==true)return(true);
	this.tRunning=true;
	this.storevar='';
	this.varrun=rn;
	this.varname=vn.split(',');
	this.vardata=new Array(this.varname.length);
	for (var i = 0; i < this.varname.length; ++i) this.vardata[i]='';
	
	this.tID = self.setTimeout(this.myName + ".ckvarloaddata()", 10);
	return (true);

}}

function mdGetVar(vn){ with (this)
{
	var foundnum=-1;
	for (var i = 0; i < this.varname.length; ++i){
		if (this.varname[i]==vn){
		  foundnum=i;
		}
	}
	if (foundnum<0)return ('');
	return (this.vardata[foundnum]);
}}




function mdgetRef(id)
{
 if (isDOM) return document.getElementById(id);
 if (isIE4) return document.all[id];
 if (isNS4) return document.layers[id];
}

function mdgetSty(id)
{
 return (isNS4 ? mdgetRef(id) : mdgetRef(id).style);
}


function ckVarLoadData(){ with (this)
{
clearTimeout(this.tID);

if (this.storevar==''){ 
	var actnum=-1;
	for (var i = 0; i < this.varname.length; ++i){
		if (this.vardata[i]==''){
		 	 this.storevar=this.varname[i];
		  	 this.tRunning=true;

			 var name = this.storevar;
			 var path = location.href.substring(0, location.href.lastIndexOf('/') + 1);
			 if (isDOM || isIE4)if ((name.substring(0, 5) != 'http:') && (name.substring(0, 5) != 'file:')) name = path + name;
			 this.bufRef.location.href = name;
			 this.tID = self.setTimeout(this.myName + ".ckvarloaddata()", 100);
		  	 return (true);
		}
	}
 setTimeout(this.varrun , 10);
 this.tRunning=false;			
 return (true);
}

else {
	var bufdata=this.bufRef.document.body.innerHTML;
	if (bufdata.indexOf('LOAD_DONE_BY_M.REDWEIK_2006') > -1){
		var bd=bufdata.split('LOAD_DONE_BY_M.REDWEIK_2006');
		this.bufRef.document.body.innerHTML='';
		for (var i = 0; i < this.varname.length; ++i)if (this.varname[i]==this.storevar) this.vardata[i]=bd[0];
		this.storevar='';
		this.tID = self.setTimeout(this.myName + ".ckvarloaddata()", 10);
		return (true);
	}
	
	this.tID = self.setTimeout(this.myName + ".ckvarloaddata()", 10);
	return (true);
}

}}


function scrFileLoaded() { with (this)
{
 this.activeScr = null;

 this.scrollBy(-100000);

 for (count = 0; count < this.divs.length; count++)
  mdgetSty(this.divs[count][0]).visibility = 'visible';
}}



function scrScrollBy(amount) { with (this)
{
 if (!isDyn || !loaded) return;

 amount = parseInt(amount);

 divHeight = document.all ? divRef.clientHeight :
  (isDOM ? divRef.offsetHeight : divRef.document.height);
 if (divHeight == 0) divHeight = 1;

 if ((cBot + amount) > divHeight) amount = divHeight - cBot;
 if ((cTop + amount) < 0) amount = 0 - cTop;

 cTop += amount;
 cBot += amount;
 if (isDOM || isIE4)
  divSty.clip = 'rect(' + cTop + 'px ' + cWidth + 'px ' + cBot + 'px ' + 0 + 'px)';
 else if (isNS4)
 {
  if (isNaN(cTop) || isNaN(cBot) || isNaN(amount)) layout();

  if (cBot < divSty.clip.top) divSty.clip.top = cTop;
  divSty.clip.bottom = cBot;
  divSty.clip.top = cTop;
 }

 divSty.top = eval(divs[0][2]) - cTop;


 thmHeight = Math.ceil(barHeight * ((cBot - cTop) / divHeight));

 if (thmHeight < minThmHeight) thmHeight = minThmHeight;
 if (thmHeight > barHeight) thmHeight = barHeight;

 if (isDOM || isIE4) thmSty.height = thmHeight;
 else if (isNS4) thmSty.clip.height = thmHeight;

 if (this.activeScr) return;

 fracDivDown = (cTop / (divHeight - (cBot - cTop)));
 thmSty.top = parseInt(barSty.top) + fracDivDown * (barHeight - thmHeight);

 if (loop) setTimeout(myName + '.scrollBy(' + amount + ')', loop);
}}



function scrThumbDown(evt)
{
 activeScr = this;

 if (document.all) this.scrOffset = event.offsetY;
 else scrOffset = evt.layerY;
 return false;
}


function scrThumbMove(evt){ 
 if (isNS4) document.routeEvent(evt);

 if (!activeScr) return true;
 else { with (activeScr)
 {
  if (isNaN(cTop) || isNaN(cBot)) divLayout();

  if ((cBot > divHeight) || (thmHeight == barHeight)) return;

  if (document.all) newTop = document.body.scrollTop + event.clientY - scrOffset;
  else newTop = evt.pageY - scrOffset;

  var barTop = parseInt(barSty.top);
  if (newTop < barTop) newTop = barTop;
  if (newTop + thmHeight > (barTop + barHeight))
   newTop = (barTop + barHeight) - thmHeight;
  thmSty.top = newTop;

  fracDivDown = cTop / (divHeight - (cBot - cTop));
  fracBarDown = (newTop - barTop) / (barHeight - thmHeight);

  scrollBy((fracBarDown - fracDivDown) * (divHeight - (cBot - cTop)));

  return false;
 }}
}


function scrThumbUp(evt){
 if (isNS4) document.routeEvent(evt);
 activeScr = null;
}



function scrBarClick(evt) { with (this)
{
 if (isNS4) document.routeEvent(evt);

 if (document.all) clickPos = document.body.scrollTop + event.clientY;
 else clickPos = evt.pageY;

 if (clickPos < parseInt(thmSty.top)) scrollBy(cTop - cBot);
 if (clickPos > (parseInt(thmSty.top) + thmHeight)) scrollBy(cBot - cTop);
}}



function scrLayout() { with (this)
{
 if (!isDyn) return;

 this.winWidth = document.all ? document.body.clientWidth : window.innerWidth;
 this.winHeight = document.all ? document.body.clientHeight : window.innerHeight;

 if (!loaded) return;

 if (this.winWidth < this.minWinWidth) this.winWidth = this.minWinWidth;
 if (this.winHeight < this.minWinHeight) this.winHeight = this.minWinHeight;

 for (count = 0; count < divs.length; count++)
 {
  var tmpObj = mdgetSty(divs[count][0]);
  if (divs[count][1]) tmpObj.left = eval(divs[count][1]);
  if (divs[count][2]) tmpObj.top = eval(divs[count][2]);
  if (divs[count][3])
  {
   var tmpW = eval(divs[count][3]);
   isNS4 ? tmpObj.clip.width = tmpW : tmpObj.width = tmpW;
  }
  if (divs[count][4] && count != 0)
  {
   var tmpH = eval(divs[count][4]);
   isNS4 ? tmpObj.clip.height = tmpH : tmpObj.height = tmpH;
  }
 }

 if ((isDOM || isIE4) && !cTop) cTop = 0;
 if (isNS4) cTop = divSty.clip.top;

 barHeight = eval(divs[1][4]);
 cBot = cTop + eval(divs[0][4]);
 cWidth = eval(divs[0][3]);
 if (isDOM || isIE4) divSty.width = cWidth;

 scrollBy(0);
}}


function scrData(divdata) { with (this)
{
  this.divRef.innerHTML = divdata;
  setTimeout(this.myName + '.fileLoaded()', 10);
}}



function scrSetup(defaultFile) { with (this)
{
 if (!isDyn) return;

 divRef = mdgetRef(divs[0][0]);
 divSty = mdgetSty(divs[0][0]);
 barSty = mdgetSty(divs[1][0]);
 thmSty = mdgetSty(divs[2][0]);
 
 bufRef = eval('window.' + bufRef);

 barRef = mdgetRef(divs[1][0]);
 thmRef = mdgetRef(divs[2][0]);

 if (isNS4)
 {
  barRef.captureEvents(Event.CLICK);
  thmRef.captureEvents(Event.MOUSEDOWN);
  document.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
 }

 barRef.onclick = new Function('evt', 'return ' + myName + '.barClick(evt)');
 thmRef.onmousedown = new Function('evt', 'return ' + myName + '.thumbDown(evt)');
 document.onmousemove = scrThumbMove;
 document.onmouseup = scrThumbUp;

 if (document.all) document.onselectstart = new Function('if (activeScr) return false');
 else if (isDOM) document.onselect = new Function('if (activeScr) return false');


 loaded = true;
 layout();


}}


function DHTMLScroller(myName, bufferID, Top)
{

 this.CT=Top;

 this.divRef = null;
 this.divSty = null;
 this.barSty = null;
 this.thmSty = null;

 this.divs = new Array();

 this.divs[0] = new Array('dyndata', '40', '10 + CT ','this.winWidth - 85','this.winHeight - 40 - this.CT');
 this.divs[1] = new Array('scrollBar', 'this.winWidth - 25', '50 + this.CT ', '15', 'this.winHeight - 95 - this.CT');
 this.divs[2] = new Array('scrollThumb', 'this.winWidth - 24', '', '13', '');

 this.divs[3] = new Array('upArrows', 'this.winWidth - 25', '20 + this.CT', '', '');
 this.divs[4] = new Array('downArrows', 'this.winWidth - 25', 'this.winHeight - 50', '', '');

 this.varname = new Array();
 this.vardata = new Array();
 this.varrun = '';

 this.storevar='';

 this.tRunning=false;
 this.tID=0;


 this.bufRef = bufferID;

 this.myName = myName;
 this.loaded = false;
 this.loop = 0;
 this.minThmHeight = 20;

 this.minWinWidth = 200;
 this.minWinHeight = 200;
 this.winWidth = 0;
 this.winHeight = 0;


 this.divHeight = 0;
 this.barHeight = 0;
 this.thmHeight = 0;
 this.cTop = 0;
 this.cBot = 0;
 this.cWidth = 0;
 
 this.fileLoaded = scrFileLoaded;
 this.scrollBy = scrScrollBy;
 this.thumbDown = scrThumbDown;
 this.barClick = scrBarClick;
 this.setup = scrSetup;
 this.layout = scrLayout;
 this.setdata = scrData;
 this.loadvar = mdLoadVar;
 this.getvar = mdGetVar;
 this.ckvarloaddata = ckVarLoadData;

}

 this.activeScr = null;
 this.scrOffset = 0;


