/* (c) Dynamic Web Coding at www.dyn-web.com */

function initGlideLyr() {
  // exclude op < 7 (???)
  var i, el, ua = navigator.userAgent;
  if ( (i = ua.indexOf("Opera")) != -1 ) { if ( parseFloat(ua.substr(i+6,4)) < 7 ) return; }

  var glideLyrs = new Array();
	// arguments: id, amount to be visible (left offset calculated), top
	// set width in style sheet (width and height are null here)
    // duration of glide onscroll, accel (-1 to 1, -1 decelerates)  

 glideLyrs[0] = new Glider('glideDiv0',23,2,null,null,1000, -1);
 glideLyrs[1] = new Glider('glideDiv1',23,86,null,null,1000, -1);
 glideLyrs[2] = new Glider('glideDiv2',23,122,null,null,1000, -1);
 glideLyrs[3] = new Glider('glideDiv3',23,40,null,null,1000, -1);
 glideLyrs[4] = new Glider('glideDiv4',23,125,null,null,1000, -1);
 glideLyrs[5] = new Glider('glideDiv5',23,234,null,null,1000, -1);
 glideLyrs[6] = new Glider('glideDiv6',23,286,null,null,1000, -1);


  for (i=0; glideLyrs[i]; i++) {
		// hold amount to be left visible 
		glideLyrs[i].xOff = glideLyrs[i].x;
		if ( !glideLyrs[i].y ) // position based on previous glideLyrs height and position
			if ( glideLyrs[i-1] ) glideLyrs[i].y = glideLyrs[i-1].y + glideLyrs[i-1].h + 2;	
		glideLyrs[i].shiftTo( -(glideLyrs[i].w - glideLyrs[i].xOff), glideLyrs[i].y );
		glideLyrs[i].show();
    el = dynObj.getElemRef( glideLyrs[i].id );
    if (el) {
      el.onmouseover = slideIntoView;
      el.onmouseout = slideOutOfView;
    }
  }  
}

function slideIntoView() {
  var glideLyr = dynObj.getInstance(this.id);
  glideLyr.slideTo(2, null, 750, -1);
}

function slideOutOfView(e) {
  var glideLyr = dynObj.getInstance(this.id);
	e = e? e: window.event;
  var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
  if ( toEl != glideLyr.el && !contained(toEl, glideLyr.el) ) 
	  glideLyr.slideTo( -(glideLyr.w - glideLyr.xOff), null, 800, -1);
}

// returns true if oNode is contained by oCont (container)
function contained(oNode, oCont) {
  if (!oNode) return; // in case alt-tab away while hovering (prevent error)
  while ( oNode = oNode.parentNode ) if ( oNode == oCont ) return true;
  return false;
}

function initScrollLayer() {
  // arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll, 
  // if horizontal scrolling, id of element containing scrolling content (table?)
 
  var wndo2 = new dw_scrollObj('wn2', 'lyr2',null);
  var wndo3 = new dw_scrollObj('wn3', 'lyr3',null);
  var wndo4 = new dw_scrollObj('wn4', 'lyr4',null);
  var wndo5 = new dw_scrollObj('wn5', 'lyr5',null);
  
  // bSizeDragBar set true by default (explained at www.dyn-web.com/dhtml/scroll/ )
  // wndo.bSizeDragBar = false;

  // arguments: dragBar id, track id, axis ("v" or "h"), x offset, y offset
  // (x/y offsets of dragBar in track)

  
  wndo2.setUpScrollbar("dragBar2", "track2", "v", 1, 1);
  wndo3.setUpScrollbar("dragBar3", "track3", "v", 1, 1);
  wndo4.setUpScrollbar("dragBar4", "track4", "v", 1, 1);
  wndo5.setUpScrollbar("dragBar5", "track5", "v", 1, 1);

	// dies im moment zuletzt, weil diese Scrollarea nur in "projekt" vorkommt
	//
	//	ANPASSEN JE NACH SEITENINHALT!!! GIBT SONST UNAUFFINDBARE FEHLER!!!
	// 

 	var wndo1 = new dw_scrollObj('wn1', 'lyr1',null);
	wndo1.setUpScrollbar("dragBar1", "track1", "v", 1, 1);
	
  // pass id('s) of scroll area(s) if inside table(s)
  // i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');

  	//dw_scrollObj.GeckoTableBugFix('wn1','wn2','wn3','wn4','wn5'); 

  // sometimes ns6+ needs extra help to position correctly
  // dw_scrollObj.rePositionGecko(); 

	// check ob content kleiner als Div
	dw_scrollObj.checkScrollbar('wn1');
	dw_scrollObj.checkScrollbar('wn2');
	dw_scrollObj.checkScrollbar('wn3');
	dw_scrollObj.checkScrollbar('wn4');
	dw_scrollObj.checkScrollbar('wn5');

}
