// JavaScript Document for scrolling

var clipTop = 0;
var clipWidth = 651;	// the width of the gallery
var clipBottom = 105;
var clipLeft = 0;		// start of banner, within an object
var clipRight = 651;	// the max width of the gallery
var topper = 360;
var lefter = 0;			// the default left position
var lyrheight = 0;
var time,amount,theTime,theHeight,DHTML;

function init()
{
	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	var x = new getObj('banner');
	var z = new getObj('banner_detail');
	var y = new getObj('position');
/*	if (document.layers)
	{
		lyrheight = x.style.clip.bottom;
		lyrheight += 20;
		x.style.clip.top = clipTop;
		x.style.clip.left = 0;
		x.style.clip.right = clipWidth;
		x.style.clip.bottom = clipBottom;
	}
	else if (document.getElementById || document.all)
	{
*/		lyrheight = x.obj.offsetHeight;
		lyrwidth = x.obj.offsetWidth;
		lefter = y.obj.offsetLeft;		// take the left position from the span
		x.style.left = lefter + 'px';	// move the banner over
		x.style.clip = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,' + clipLeft + 'px)';	// clip the banner
		x.style.visibility = 'hidden';	// show the banner
		
		// setup for banner with links to image details
		lyrheight = z.obj.offsetHeight;
		lyrwidth = z.obj.offsetWidth;
		lefter = y.obj.offsetLeft;		// take the left position from the span
		z.style.left = lefter + 'px';	// move the banner over
		z.style.clip = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,' + clipLeft + 'px)';	// clip the banner
		//z.style.visibility = 'visible';	// show the banner
		
// in theory some broswers will require you to get the parent of the parent... not sure if this applies to me
/*	if (x.obj.offsetParent) {
		while (y.obj.offsetParent) {
			lefter += x.obj.offsetLeft;
			y = y.obj.offsetparent;
		}
	}
	else if (obj.x) {
		curleft += y.x;
	}	*/
//	}
}

function ScrolLayerHorz(layername,amt,tim) {
	if (!DHTML) {
		return;
	}
	thelayer = new getObj(layername);
	if (!thelayer) {
		return;
	}
	amount = amt;
	theTime = tim;
	realScrollHorz();
}

/*function realscroll()
{
	if (!DHTML) return;
	clipTop += amount;
	clipBottom += amount;
	topper -= amount;
	if (clipTop < 0 || clipBottom > lyrheight)
	{
		clipTop -= amount;
		clipBottom -= amount;
		topper += amount;
		return;
	}
	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper + 'px';
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop;
		thelayer.style.clip.bottom = clipBottom;
		thelayer.style.top = topper;
	}
	time = setTimeout('realscroll()',theTime);
}
*/
function realScrollHorz() {
	clipLeft += amount;
	clipRight += amount;
	lefter -= amount;
	if (clipLeft < 0 || clipRight > lyrwidth) {
		clipLeft -= amount;
		clipRight -= amount;
		lefter += amount;
		return;
	}
	clipstring = 'rect(' + clipTop + 'px, ' + clipRight + 'px, ' + clipBottom + 'px, ' + clipLeft + ')';
	thelayer.style.clip = clipstring;
	thelayer.style.left = lefter + 'px';
	time = setTimeout('realScrollHorz()',theTime);
}

function stopScroll()
{
	if (time) clearTimeout(time);
}

function getObj(name)
{
  if (document.getElementById)
  {
    this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
    this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function updateGallery(gallery) {
	document.getElementById("banner").innerHTML = "<span style='color:white;'>GOOD MORNING</span>";
}

/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

var timer_id;
function scroll_iframe(frm,inc,dir) {
  if (timer_id) clearTimeout(timer_id);
  if (window.frames[frm]) {
    if (dir == "v") window.frames[frm].scrollBy(0, inc);
    else window.frames[frm].scrollBy(inc, 0);
    timer_id = setTimeout("scroll_iframe('" + frm + "'," + inc + ",'" + dir + "')", 20);
  }
}

function stopScroll2() { if (timer_id) clearTimeout(timer_id); }
/* END DYNAMIC WEB CODE	*/
