


//
//	this file was based on Cyclomedia Scroller Object - v 0.1
//
//	In order for the Javascript to be able to override the settings in the
//	CSS file it must be loaded, in the pages HEAD section *before* this file
//

// The CSS override, activated if (compatible) javascript is available
if( document.getElementById )
	document.write('<' + 'link rel="stylesheet" type="text/css" href="oliver.css">');

// Collection of scroller objects
var gaScrollers = new Array();


//
// oScroller
//
// The scroller object, holds position and state information for each scroller
// hScroller: handle to "scrollinner" div the object controls
// iMaxLeft: maximum left scroll amount, usually width minus width of parent "scroller" div
// iMaxTop: maximum top scroll amount, usually width minus width of parent "scroller" div
// iLeft: left position in pixels
// iTop: top position in pixels
// iOfsLeft: left offset, in case scroller outer div has borders or padding
// iOfsTop: top offset, as above
// iHeight: height of inner div, check before accessing as it may have changed
// iWidth: width, as above
// iTimeout: scrolling state as per above constants

function oScroller( hScroller , iMaxLeft , iMaxTop )
{
	this.hScroller = hScroller;
	this.iMaxLeft = iMaxLeft;
	this.iMaxTop = iMaxTop;

	this.iLeft = 0;
	this.iTop  = 0;

    this.iOfsLeft =  hScroller.offsetLeft;
	this.iOfsTop = hScroller.offsetTop;

	this.iHeight = hScroller.offsetHeight;
	this.iWidth = hScroller.offsetWidth;

	this.iTimeout = 0;

}


function fScroller_set(iLeft, iTop, sScrollerID)
{
    var o = fScroller_get( sScrollerID );

	if( o )
	{
		o.iTop	= iTop;
        o.iLeft	= iLeft;
		o.hScroller.style.top = o.iTop + "px";
        o.hScroller.style.left = o.iLeft + "px";
	}
}


function getScrollTopPosition(sScrollerID){
    var o = fScroller_get( sScrollerID );

	if( o )
	{
		return o.iTop;
	}

    return null;
}

//
// fScroller_init
//
// load and initialise a scrolling panel, called by fScroller_get if no panel is found on first try
//
function fScroller_init( sScrollerID )
{
	if( document.getElementById && !gaScrollers[ sScrollerID ] )
	{
		var hScroller = document.getElementById(sScrollerID);

		if( hScroller )
			gaScrollers[ sScrollerID ] = new oScroller( hScroller , hScroller.parentNode.offsetWidth , hScroller.parentNode.offsetHeight );

	}

}

//
// fScroller_get
//
// return handle to specified scroller
//
function fScroller_get( sScrollerID )
{
	if( !gaScrollers[ sScrollerID ] )
		fScroller_init( sScrollerID );

	return gaScrollers[ sScrollerID ];		// warning: may still be null!
}

//
// fScroller_stop
//
// stops specified scroller from scrolling
//
function fScroller_stop( sScrollerID )
{
	var o = fScroller_get( sScrollerID );

	if( o )
		clearTimeout( o.iTimeout );
}

//
// fScroller_up
//
// scrolls specified scroller up 10 pixels, then sets a timeout to call itself in .1 of a second
//
function fScroller_up( eEvent , sScrollerID )
{
	var o = fScroller_get( sScrollerID );

	if( o )
	{
		clearTimeout( o.iTimeout );

		fScroller_events( eEvent , sScrollerID );

		o.iTimeout	= 0;
		o.iTop		= (o.hScroller.offsetTop + 10) - o.iOfsTop;
		o.iHeight	= o.hScroller.offsetHeight;

		if( o.iTop > 0 )
			o.iTop = 0;
		else
			o.iTimeout = setTimeout( "fScroller_up(null,'" + sScrollerID + "')" , 100 );

		o.hScroller.style.top = o.iTop + "px";
	}
}

//
// fScroller_down
//
// scrolls specified scroller down 10 pixels, then sets a timeout to call itself in .1 of a second
//
function fScroller_dn( eEvent , sScrollerID )
{
	var o = fScroller_get( sScrollerID );

	if( o )
	{
		clearTimeout( o.iTimeout );

		fScroller_events( eEvent , sScrollerID );

		o.iTimeout	= 0;
		o.iTop		= (o.hScroller.offsetTop - 10) - o.iOfsTop;
        o.iHeight	= o.hScroller.offsetHeight;

        document.title = " itop: "+o.iTop+" offset: "+o.hScroller.offsetTop+"   iofset: "+o.iOfsTop+"   height: "+o.hScroller.offsetHeight;

        if( o.iTop + o.iHeight < o.iMaxTop )			//dont allow to scroll up too far
			if( o.iHeight > o.iMaxTop )					//only if it's actually taller than the container
				o.iTop = o.iMaxTop - o.iHeight;
			else
				o.iTop = 0;
		else
			o.iTimeout = setTimeout( "fScroller_dn(null,'" + sScrollerID + "')" , 100 );

		o.hScroller.style.top = o.iTop + "px";
	}
}

//
// fScroller_lt
//
// scrolls specified scroller left
//
function fScroller_lt( eEvent , sScrollerID )
{
	var o = fScroller_get( sScrollerID );

	if( o )
	{
		clearTimeout( o.iTimeout );

		fScroller_events( eEvent , sScrollerID );

		o.iTimeout	= 0;
		o.iLeft		= (o.hScroller.offsetLeft + 10) - o.iOfsLeft;
		o.iWidth	= o.hScroller.offsetWidth;

		if( o.iLeft > 0 )
			o.iLeft = 0;
		else
			o.iTimeout = setTimeout( "fScroller_lt(null,'" + sScrollerID + "')" , 100 );

		o.hScroller.style.left = o.iLeft + "px";
	}
}

//
// fScroller_rt
//
// scrolls specified scroller left
//
function fScroller_rt( eEvent , sScrollerID )
{
	var o = fScroller_get( sScrollerID );

	if( o )
	{
		clearTimeout( o.iTimeout );

		fScroller_events( eEvent , sScrollerID );

		o.iTimeout	= 0;
		o.iLeft		= (o.hScroller.offsetLeft - 10) - o.iOfsLeft;
		o.iWidth	= o.hScroller.offsetWidth;

		if( o.iLeft + o.iWidth < o.iMaxLeft )			//dont allow to scroll too far
			if( o.iWidth > o.iMaxLeft )					//only if it's actually wider than the container
				o.iLeft = o.iMaxLeft - o.iWidth;
			else
				o.iLeft = 0;
		else
			o.iTimeout = setTimeout( "fScroller_rt(null,'" + sScrollerID + "')" , 100 );

		o.hScroller.style.left = o.iLeft + "px";
	}
}

function fScroller_events( eEvent , sScrollerID )
{
	if( !eEvent )
		return;

	var hClicked;

	if( window.event )
	{
		eEvent = window.event;
		hClicked = eEvent.srcElement;
	}
	else
		hClicked = eEvent.target;

	if( hClicked )
	{
		if( !hClicked.onmouseup )
			hClicked.onmouseup = function () { fScroller_stop( sScrollerID ); };

		if( !hClicked.onmouseout )
			hClicked.onmouseout = function () { fScroller_stop( sScrollerID ); };
	}
}

function debug( s )
{
	var d = document.getElementById("debug");

	if(d)
		d.innerHTML = s;
}


// get argument from url
function getParameter(name)
{
var url = window.location.href;
var paramStart = url.indexOf("?");
	if (paramStart != -1){
		var paramStr = url.substr(paramStart + 1);
		var tokenStart = paramStr.indexOf(name);
		if(tokenStart != -1){
			var paramToEnd = paramStr.substr(tokenStart + name.length + 1);
			var delimiterPos = paramToEnd.indexOf("&");
			if (delimiterPos == -1){
				return paramToEnd;
			}else{
				return paramToEnd.substr(0, delimiterPos);
			}

		}
	}
}

function getURL()
{
var url = window.location.href;
var paramStart = url.indexOf("?");
	if (paramStart != -1){
		var paramStr = url.substr(paramStart + 1);
		var tokenStart = paramStr.indexOf("url");
		return paramStr.substr(tokenStart + 3 + 1);
	}
}

// get formated title from url
function getFormatedParameter(name)
{

}



// DATA
var images = new Array();
images[0] = "paintings.html?image=01.JPG&title=Horizon&dimensions=69.5 x 60cm&materials=Oil paint on canvas&index=0";
images[1] = "paintings.html?image=03.JPG&title=Dream&dimensions=51 x 51cm&materials=Enamel and oil paint on canvas&index=1";
images[2] = "paintings.html?image=04.JPG&title=Gaze&dimensions=60 x 73cm&materials=Enamel and oil paint on canvas&index=2";
images[3] = "paintings.html?image=05.JPG&title=Watch&dimensions=60 x 73cm&materials=Pearlescent silver, resin, oil paint on canvas&index=3";
images[4] = "paintings.html?image=06.JPG&title=Stranger&dimensions=60 x 73cm&materials=Pearlescent and graphite silver, resin, oil paint on canvas&index=4";
images[5] = "paintings.html?image=07.JPG&title=Parting&dimensions=60 x 73cm&materials=Pearlescent gold, resin, oil paint on canvas&index=5";
images[6] = "paintings.html?image=08.JPG&title=Shadow&dimensions=51 x 76cm&materials=Pearlescent and graphitesilver, resin, oil paint on canvas&index=6";
images[7] = "paintings.html?image=09.JPG&title=Biding&dimensions=51 x 76cm&materials=Oil paint on canvas&index=7";
images[8] = "paintings.html?image=10.JPG&title=Outsider&dimensions=54 x 73cm&materials=Oil paint on canvas&index=8";
images[9] = "paintings.html?image=11.JPG&title=Wrench&dimensions=60 x 73cm&materials=Pearlescent and graphite silver, resin, oil paint on canvas&index=9";
images[10] = "paintings.html?image=12.JPG&title=Wave&dimensions=51 x 61cm&materials=Pigment and resign on canvas&index=10";
images[11] = "paintings.html?image=13.JPG&title=Divide&dimensions=54 x 73.5cm&materials=Pearlescent and graphite silver, resin, oil paint on canvas&index=11";
images[12] = "paintings.html?image=14.JPG&title=Desert&dimensions=51 x 51cm&materials=Pigment, gloss paint, oil paint on canvas&index=12";
images[13] = "paintings.html?image=15.JPG&title=Desert 2&dimensions=69.5 x 60cm&materials=Pigment, resign on canvas&index=13";
images[14] = "paintings.html?image=16.JPG&title=Lift&dimensions=69.5 x 60cm&materials=Pearlescent gold, resign, oil paint on canvas&index=14";
images[15] = "paintings.html?image=18.JPG&title=Brush&dimensions=33x 41cm&materials=Pearlescent copper, resign, oil paint on canvas&index=15";
images[16] = "paintings.html?image=19.JPG&title=Steps&dimensions=76.5 x 76.5cm&materials=Oil paint on canvas&index=16";
images[17] = "paintings.html?image=20.JPG&title=Voyage&dimensions=51 x 51cm&materials=Enamel and oil paint on canvas&index=17";
images[18] = "paintings.html?image=21.JPG&title=Reach&dimensions=51 x 76cm&materials=Pearlescent and graphite silver, resin, oil paint on canvas&index=18";
images[19] = "paintings.html?image=22.JPG&title=Bruise&dimensions=51 x 61cm&materials=Pearlescent and graphite silver, resin, oil paint on canvas&index=19";
images[20] = "paintings.html?image=23.JPG&title=Wanderer&dimensions=60 x 73cm&materials=Pearlescent gold, resin, oil paint on canvas&index=20";
images[21] = "paintings.html?image=24.JPG&title=Nudge&dimensions=154 x 154cm&materials=Pearlescent and graphite silver, resin, oil paint on canvas&index=21";
images[22] = "paintings.html?image=25.JPG&title=Torn 2&dimensions=33 x 41cm&materials=Pearlescent gold, resin, oil paint on canvas&index=22";
images[23] = "paintings.html?image=26.JPG&title=Severance 1&dimensions=33 x 41cm&materials=Oil paint on canvas&index=23";
images[24] = "paintings.html?image=27.JPG&title=Torn 4&dimensions=33 x 41cm&materials=Pearlescent gold, resin, oil paint on canvas&index=24";
images[25] = "paintings.html?image=28.JPG&title=Suspension 2&dimensions=33 x 41cm&materials=Pearlescent and graphite silver, resin, oil paint on canvas&index=25";
images[26] = "paintings.html?image=29.JPG&title=Spring&dimensions=94 x 163cm&materials=Pearlescent and graphite silver, resin, oil paint on wood&index=26";
images[27] = "paintings.html?image=30.JPG&title=Thaw&dimensions=53 x 70cm&materials=Pearlescent and graphite silver, resin, oil paint on wood&index=27";
images[28] = "paintings.html?image=31.JPG&title=Opening&dimensions=154 x 154cm&materials=Pearlescent and graphite silver, resin, oil paint on canvas&index=28";
images[29] = "paintings.html?image=32.JPG&title=Thorn 1&dimensions=33 x 41cm&materials=Oil paint on canvas&index=29";
images[30] = "paintings.html?image=33.JPG&title=Copse&dimensions=86 x 117cm&materials=Oil paint on wood&index=30";
images[31] = "paintings.html?image=34.JPG&title=Passing&dimensions=76 x 102cm&materials=Oil paint on wood&index=31";
images[32] = "paintings.html?image=35.JPG&title=Drift&dimensions=79 x 150cm&materials=Oil paint on wood&index=32";



var drawings = new Array();
drawings[0] = "drawings.html?image=01.JPG&title=Span&dimensions=40 x 43cm&materials=Ink on cardboard&index=0";
drawings[1] = "drawings.html?image=02.JPG&title=Hill&dimensions=41 x 45cm&materials=Ink on cardboard&index=1";
drawings[2] = "drawings.html?image=03.JPG&title=Run&dimensions=43 x 49cm&materials=Ink on cardboard&index=2";
drawings[3] = "drawings.html?image=04.JPG&title=Cavern&dimensions=50 x 90cm&materials=Charcoal on paper&index=3";
drawings[4] = "drawings.html?image=05.JPG&title=Touch&dimensions=33 x 41cm&materials=Charcoal on paper&index=4";
drawings[5] = "drawings.html?image=06.JPG&title=Window&dimensions=50 x 80cm&materials=Charcoal on paper&index=5";
drawings[6] = "drawings.html?image=07.JPG&title=Cycle 2&dimensions=33 x 41cm&materials=Charcoal on paper&index=6";
drawings[7] = "drawings.html?image=08.JPG&title=Drift&dimensions=33 x 41cm&materials=Charcoal on paper&index=7";
drawings[8] = "drawings.html?image=09.JPG&title=March&dimensions=33 x 41cm&materials=Charcoal on paper&index=8";
drawings[9] = "drawings.html?image=10.JPG&title=Entry&dimensions=33 x 41cm&materials=Charcoal on paper&index=9";
drawings[10] = "drawings.html?image=11.JPG&title=Spill&dimensions=33 x 41cm&materials=Charcoal on paper&index=10";
drawings[11] = "drawings.html?image=12.JPG&title=Clash&dimensions=40 x 60cm&materials=Charcoal on paper&index=11";
drawings[12] = "drawings.html?image=13.JPG&title=Harvest&dimensions=33 x 41cm&materials=Charcoal on paper&index=12";
drawings[13] = "drawings.html?image=14.JPG&title=Descent&dimensions=33 x 41cm&materials=Charcoal on paper&index=13";
drawings[14] = "drawings.html?image=15.JPG&title=Emergence&dimensions=56 x 76cm&materials=Charcoal on paper&index=14";
drawings[15] = "drawings.html?image=16.JPG&title=Climb&dimensions=33 x 41cm&materials=Charcoal on paper&index=15";
drawings[16] = "drawings.html?image=17.JPG&title=Break&dimensions=50 x 90cm&materials=Charcoal on paper&index=16";
drawings[17] = "drawings.html?image=18.JPG&title=Rest&dimensions=50 x 90cm&materials=Charcoal on paper&index=17";
drawings[18] = "drawings.html?image=19.JPG&title=Squeeze&dimensions=33 x 41cm&materials=Charcoal on paper&index=18";
drawings[19] = "drawings.html?image=20.JPG&title=Wind&dimensions=50 x 90cm&materials=Charcoal on paper&index=19";
drawings[20] = "drawings.html?image=21.JPG&title=Higland&dimensions=50 x 90cm&materials=Charcoal on paper&index=20";
drawings[21] = "drawings.html?image=22.JPG&title=Cloud&dimensions=50 x 90cm&materials=Charcoal on paper&index=21";
drawings[22] = "drawings.html?image=23.JPG&title=Reflection&dimensions=50 x 80cm&materials=Acrylic, ink on paper&index=22";
drawings[23] = "drawings.html?image=24.JPG&title=Reflection 2&dimensions=45 x 80cm&materials=Acrylic, structura, ink on  paper&index=23";
drawings[24] = "drawings.html?image=25.JPG&title=Mountain&dimensions=50 x 90cm&materials=Charcoal on paper&index=24";
drawings[25] = "drawings.html?image=26.JPG&title=Rock&dimensions=33 x 41cm&materials=Charcoal on paper&index=25";
drawings[26] = "drawings.html?image=27.JPG&title=Severance 5&dimensions=33 x 41cm&materials=Charcoal on paper&index=26";
drawings[27] = "drawings.html?image=28.JPG&title=Watch&dimensions=33 x 41cm&materials=Charcoal on paper&index=27";
