//
// user variables, modify to whatever you want
//

var picX = 320;                 // where is the X center of the picture? Negative numbers = no moving
var picY = 264;                 // where is the Y center of the picture? Negative numbers = no moving
var fade = true;                // should we fade at all?
//var picCurrent = 0;             // which picture in the array should we start with? (0 = first)
var fadingSpeed = 20;           // how fast the transition should be
var fadingSteps = 10;           // how small steps the transition should use
var takeItEasy = 2000;          // how long the picture should be shown, at minimum, in milliseconds. I *strongly* suggest 250 or over as a value!
var cacheAhead = 2;             // how many pictures after the current one should be precached
var cacheBack = 1;              // as above, but before the current one. Set both to 0 to disable precaching
var loopSlideshow = false;	// should slideshows repeat ad infinitum?
var slideshow = false;		// is this a slideshow to begin with?
var hires = false;

//
// vital functions below, don't touch
//


draggable = false;

visLayer = 'scroller';
cellWidth = 110;

fadeOn = new Image(83,15);
fadeOn.src = "/pics/fade-on.gif";
fadeOff = new Image(83,15);
fadeOff.src = "/pics/fade-off.gif";
slideshowOn = new Image(83,15);
slideshowOn.src = "/pics/slideshow-on.gif";
slideshowOff = new Image(83,15);
slideshowOff.src = "/pics/slideshow-off.gif";

nphr = new Image(96,59);
nphr.src = "/pics/nextprevhires.gif";
nphrNR = new Image(96,59);
nphrNR.src = "/pics/nextprevhiresNORIGHT.gif";
nphrNL = new Image(96,59);
nphrNL.src = "/pics/nextprevhiresNOLEFT.gif";


if (!Array.prototype.forEach)
{
  Array.prototype.forEach = function(fun /*, thisp*/)
  {
    var len = this.length;
    if (typeof fun != "function")
      throw new TypeError();

    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this)
        fun.call(thisp, this[i], i, this);
    }
  };
}

function setPageVariables()
{
scrollTime = 20;
walkingPath = 3;
upperLimit = 147;
lowerLimit = 651;

dragBox.width = setUnit(50);
dragBox.height = setUnit(14);

scrollDirection = 'horizontal';
}


function mousePos(e)
{
if (hires != true)
{
if (ie > 3)
	{
	if (ie > 5)
		{
		mouseX = (event.clientX + document.documentElement.scrollLeft);
		mouseY = (event.clientY + document.documentElement.scrollTop);
		}
	else
		{
		mouseX = (event.clientX + document.body.scrollLeft);
		mouseY = (event.clientY + document.body.scrollTop);
		}
	}
else
	{
	mouseX = e.pageX;
	mouseY = e.pageY;
	}

if (((mouseY < 362 ) && (mouseY > 225)) || (draggable == true))
	{
	rawhide('bobContainer',true);
	rawhide('thumbBg',false);
	setLayerTrans('container',100);
	if (ie > 3)
		{
		document.all.container.style.zIndex = "8";
		if (ie == 5)
			document.all.thumbBg.style.zIndex = "1";
		}
	else
		document.getElementById('container').style.zIndex = "8";
		//stopScroll();
	}
else
	{
	rawhide('bobContainer',false);
	if (opera == 0)
		rawhide('thumbBg',true);
	setLayerTrans('container',50);
	if (ie > 3)
		{
		document.all.container.style.zIndex = "-1";
		if (ie == 5)
			document.all.thumbBg.style.zIndex = "-1";
		}
	else
		document.getElementById('container').style.zIndex = "0";
	}


pageWidthAdjusted = ((document.body.offsetWidth/2)-492);
// window.status = (mouseX+' ,'+mouseY);
if (((mouseY < 185 ) && (mouseY > 115) && (mouseX < (275+pageWidthAdjusted)) && (mouseX > (165+pageWidthAdjusted))) || ((mouseY < 220 ) && (mouseY > 115) && (mouseX < (166+pageWidthAdjusted)) && (mouseX > (67+pageWidthAdjusted))))
	{
	setLayerTrans('mainmenu',100);
	setLayerTrans('submenu',100);
	}
else
	{
	setLayerTrans('mainmenu',20);
	setLayerTrans('submenu',20);
	}
}
}




function softScroll(where)
{
if (delUnit(scrollBox.left) < (delUnit(xMarksTheSpot) - where + 10))
	{
	steps = (steps/2);
	if (steps < 1)
		steps = 1;
	}
else
	{
	steps = 4;
	}
//alert (steps);
scrollByUnit(steps, true);
//alert (scrollBox.left);
if (delUnit(scrollBox.left) > (delUnit(xMarksTheSpot) - where))
	softID=setTimeout('softScroll('+(where)+')',0);
}

function checkHiresNav(where)
{
if (hires)
	{
	if (where <= 0)
		{
		switchImage('nphires', 'nphrimg', nphrNL);
		}
	else if (where >= picSrc.length-1)
		{
		switchImage('nphires', 'nphrimg', nphrNR);
		}
	else
		{
		switchImage('nphires', 'nphrimg', nphr);
		}
	}
}

function go(where)
{
//imgCurrent = ('thumbImg' + picCurrent);
addToStack(picCurrent+where);
checkHiresNav(picCurrent+where);
//xMarksTheSpot = scrollBox.left;
//steps = 10;
//softScroll (where*(document.images[imgCurrent].width+6));
}

function toggleFade(what)
{
if ((fade == false) || (what == true))
	{
	fade = true;
	switchImage('whitebanner', 'fade', fadeOn);
	}
else
	{
	fade = false;
	switchImage('whitebanner', 'fade', fadeOff);
	}
Set_Cookie( 'fade', fade, '3650', '/', '', '' );
}

function toggleSlideshow()
{
if (slideshow == false)
	{
	writeInLayer ('browserWarningLayer', 'Slideshow running: 6 second delay');
	rawhide ('browserWarningLayer', true);
	switchImage('whitebanner', 'slide', slideshowOn);
	if (picCurrent == 0)
		startSlideShow(1,6000,false);
	else
		startSlideShow(0,6000,false);
	}
else
	{
	switchImage('whitebanner', 'slide', slideshowOff);
	rawhide ('browserWarningLayer', false);
	stopSlideShow();
	writeInLayer ('browserWarningLayer', '');
	checkCompatibility();
	}
}

function firstPageStart(donotfade)
{
if ((ie == 0) || (ie == 4) || (ie > 6))
	{
menuPhotos = new Image(103,65);
menuPhotos.src = "/pics/mainmenu3-photos-over-PNG.gif";
menuArticles = new Image(103,65);
menuArticles.src = "/pics/mainmenu3-articles-over-PNG.gif";
menuServices = new Image(103,65);
menuServices.src = "/pics/mainmenu3-services-over-PNG.gif";
menuAbout = new Image(103,65);
menuAbout.src = "/pics/mainmenu3-about-over-PNG.gif";
menuStandard = new Image(103,65);
menuStandard.src = "/pics/mainmenu3-PNG.gif";
mainmenuPNGgallery = new Image(103,65);
mainmenuPNGgallery.src = "/pics/mainmenu-gallery.png";
	switchImage('mw', 'mw1', mwPNG);
	switchImage('mw', 'mw2', commonTrans);
	switchImage('mw', 'mw3', commonTrans);
	switchImage('mw', 'mw4', commonTrans);
	switchImage('mainmenu', 'dynmenuimg', menuStandard);
	switchImage('mainmenu', 'mainmenu2', commonTrans);
	switchImage('mainmenu', 'mainmenu4', commonTrans);
//if (ie > 6)
//	switchImage('mainmenu', 'mainmenu0', mainmenuPNGgallery);
//else
	switchImage('mainmenu', 'mainmenu0', mainmenuPNG);
	}
if (ns == 4)
        {
        document.pic1Layer.document.images.pic1.src = picPath + picSrc[0];
        }
else
        {
	if (((opera > 0) && (opera < 9)) || (ie == 4))
		{
		fade = false;
		if (ie == 4)
			{
			document.all.thumbBg.style.backgroundColor = 'transparent';
			document.all.thumbBg.style.backgroundImage = 'url(\'/pics/bluechecker.gif\')';
			}
		else
			{
			document.getElementById('thumbBg').style.backgroundColor = 'transparent';
			document.getElementById('thumbBg').style.backgroundImage = 'url(\'/pics/bluechecker.gif\')';
			}
		}
	else
		{
		if (donotfade != true)
			{
				if ((Get_Cookie('fade')) == 'false')
				fade = false;
			else
				toggleFade(true);
			}
		}
	//alert(Get_Cookie('fade'));

	checkCompatibility();
	requestPic = getParam('pic');
	if ((requestPic != '') && (requestPic != -1) && (requestPic < picSrc.length))
		picCurrent = requestPic;
        startMeUp();
	//addToStack (picCurrent);
        }
}

function writeInLayer (ID, sText)
{
if ((ie > 3) && (ie < 8))
	{
	document.all[ID].innerHTML = sText;
	}
else
	{
	document.getElementById(ID).innerHTML = sText;
	}
} 

function checkCompatibility()
{
evilMessage = '';
if (ie == 4)
	evilMessage = 'Your browser is not supported. IE4 works somewhat but have rendering problems.';
if ((opera < 8) && (opera > 0))
	evilMessage = 'Your browser is not supported. Opera versions lower than 8 are bad and I\'m lazy. Try the slideshow!';
if (opera == 8)
	evilMessage = 'Your browser lacks transparency support. Try <a style="color: #D0D0FF;" href=\"http://www.opera.com/download/\">a newer Opera browser</a>!';
if (evilMessage != '')
	{
	evilMessage = ('<span style="color: #FFB0B0; text-decoration: blink;">NOTE:</span> ' + evilMessage);
	writeInLayer ('browserWarningLayer', evilMessage);
	rawhide ('browserWarningLayer', true);
	}
}

function goHi(action)
{
// alert (action);
if (action == true)
	{
	loadpic2 = new Image(76,15);
	loadpic2.src = "/pics/loadpic2.gif";
	switchImage('loadpicLayer', 'loadpic', loadpic2);
	hires = true;
	fade = false;
	oldPicY = picY;
	picY = 352;
	oldPicCurrent = picCurrent;
	oldPicPath = picPath;
	picPath = picPath + 'hires/';
	switchImage('whitebanner', 'fade', fadeOff);
	rawhide ('mwcontainer', false);
	rawhide ('submenu', false);
	rawhide ('mainmenu', false);
	rawhide ('photoInfo', false);
	rawhide ('bobContainer', false);
	rawhide ('container', false);
	rawhide ('thefog', true);
	rawhide ('nphires', true);
	writeInLayer ('lowerblack', '');
	markImagesAsUncached();
	firstPageStart(true);
	checkHiresNav(picCurrent);
	}
else
	{
	hires = false;
	picY = oldPicY;
	//picCurrent = oldPicCurrent;
	picPath = oldPicPath;
	rawhide ('nphires', false);
	rawhide ('thefog', false);
	rawhide ('mainmenu', true);
	rawhide ('submenu', true);
	rawhide ('mwcontainer', true);
	rawhide ('container', true);
	//rawhide ('bobContainer', true);
	rawhide ('photoInfo', true);
	writeInLayer ('lowerblack', '<p>'+copyrightNotice+'</p>');
	markImagesAsUncached();
	firstPageStart();
	loadpic1 = new Image(76,15);
	loadpic1.src = "/pics/loadpic.gif";
	switchImage('loadpicLayer', 'loadpic', loadpic1);
	rawhide ('loadpicLayer', false);
	}
}

function checkarrow(what)
{
//if (what.keyCode == 27)
//	goHi(false);
if (what.keyCode == 37)
	go(-1);
else if (what.keyCode == 39)
	go(+1);
}
