﻿
// JScript File

var MS_isNS = (document.layers) ? 1 : 0; 

var MS_isIE = (document.all) ? 1 : 0; 
var MS_isMZ = (!MS_isIE && document.getElementById) ? 1 : 0; 

var MS_exhibitionHtml1, MS_exhibitionHtml2;
var MS_basePath, MS_selectedIndex, MS_thumbPosition, MS_continueScroll, MS_imageCount, MS_totalVisibleWidth, MS_thumbWidth;

var MS_scrollBars = []; var MS_scrollThumbs = []; 
/*
function MS_initStrings()
{
    exhibitionHtml1 = new Array();
    exhibitionHtml2 = new Array();
    
    exhibitionHtml1[1] = "<p> <strong>William Peers<br /></strong><em>New York in marble</em><br />19 September - 13 October 2007</p>"
    exhibitionHtml1[2] = "<p> <strong>Gennadii Gogoliuk<br /></strong><em>Silver Threads</em><br />29 June - 21 July 2007</p>"
    exhibitionHtml1[3] = "<p> <strong>Rupert Gatfield<br /></strong><em>Six Months in the Beautiful Chaos</em><br />1 June - 23 June 2007</p>"
    exhibitionHtml1[4] = "<p> <strong>New York<br /></strong><em>Fred Yates in Provence</em><br />20 June - 7 July 2007</p>"
    exhibitionHtml1[5] = "<p> <strong>Pat Harris Sean McSweeney John Shinnor<br /></strong>9 May - 26 May 2007</p>"
    exhibitionHtml1[6] = "<p> <strong>Barry McGlashan<br /></strong><em>Way Out West</em><br />27 March - 28 April 2007</p>"
    exhibitionHtml1[7] = "<p> <strong>Francis Hamel<br /></strong><em>Circus Paintings</em><br />6 March - 24 March 2007</p>"
    exhibitionHtml1[8] = "<p> <strong>Francis Hamel<br /></strong><em>Circus Paintings</em><br />6 March - 24 March 2007</p>"
    exhibitionHtml1[9] = "<p> <strong>Francis Hamel<br /></strong><em>Circus Paintings</em><br />6 March - 24 March 2007</p>"

    exhibitionHtml2[1] = "<h2>William Peers<br /><em>New York in marble</em><br />19 September - 13 October 2007</h2>"
    exhibitionHtml2[2] = "<h2>Gennadii Gogoliuk<br /><em>Silver Threads</em><br />29 June - 21 July 2007</h2>"
    exhibitionHtml2[3] = "<h2>Rupert Gatfield<br /><em>Six Months in the Beautiful Chaos</em><br />1 June - 23 June 2007</h2>"
    exhibitionHtml2[4] = "<h2>New York<br /><em>Fred Yates in Provence</em><br />20 June - 7 July 2007</h2>"
    exhibitionHtml2[5] = "<h2>Pat Harris Sean McSweeney John Shinnor<br />9 May - 26 May 2007</h2>"
    exhibitionHtml2[6] = "<h2>Barry McGlashan<br /><em>Way Out West</em><br />27 March - 28 April 2007</h2>"
    exhibitionHtml2[7] = "<h2>Francis Hamel<br /><em>Circus Paintings</em><br />6 March - 24 March 2007</h2>"
    exhibitionHtml2[8] = "<h2>Francis Hamel<br /><em>Circus Paintings</em><br />6 March - 24 March 2007</h2>"
    exhibitionHtml2[9] = "<h2>Francis Hamel<br /><em>Circus Paintings</em><br />6 March - 24 March 2007</h2>"
}
*/
function MS_initPage(basePath, imageCount, totalVisibleWidth, thumbWidth) 
{
	MS_initStrings();
 
    MS_basePath = basePath;
    MS_imageCount = imageCount;
    MS_totalVisibleWidth = totalVisibleWidth;
    MS_thumbWidth = thumbWidth;

    if (imageCount > 5) 
    {
	    MS_instantiateScroller(0, "MS_thumb_strip_parent", "MS_thumb_strip", 0, 0, totalVisibleWidth, 0, 250);
        MS_createHDragger(0, "MS_scroll", 0,  MS_scrollBars[0].clipW, MS_scrollBars[0].clipH, MS_scrollBars[0].clipH);        
    }

	var images = document.getElementsByTagName('img');
	var preloadImages = new Array();
	var imgSrc = new Array();
	var imgSrcOver = new Array();
	
	for (i=0; i<images.length; i++) 
	{	    
	    if (images[i].getAttribute('srcindex')) 
	    {	    
			imgSrc[i] = images[i].getAttribute('src');
			imgSrcOver[i] = images[i].getAttribute('srcover');			
			
			preloadImages[i] = new Image();
	        preloadImages[i].src = imgSrcOver[i];	        
			
			images[i].setAttribute('srcout', imgSrc[i]);			
			
			images[i].onmouseover = MS_thumbnailMouseOver;
			images[i].onmouseout = MS_thumbnailMouseOut;
			images[i].onclick = MS_thumbnailMouseClick;
	    }
	}
	
	MS_selectedIndex = 1;
	MS_thumbPosition = 0;
	
    if (document.getElementById("MS_thumb" + MS_selectedIndex)) 
    {
        var thumb = document.getElementById("MS_thumb" + MS_selectedIndex);
    	thumb.setAttribute('src', thumb.getAttribute('srcover'));
    }
}

function MS_instantiateScroller(count, containerid, contentid, left, top, width, height, speed)
{
	if(document.getElementById) {
		MS_scrollBars[count] = new ypSimpleScroll(containerid, contentid, left, top, width, height, speed);
	}
}

function MS_createHDragger(count, rootName, minX, maxX, minY, maxY)
{
    var thumbWidth = (MS_imageCount > 0) ? Math.min(36 + 27 * 36 / MS_imageCount, maxX - 30) : 0;

    var buttons = '<div class="scrollleft" id="leftarrow" onmouseover="MS_scrollBars[' + count + '].scrollWest(\'' + count + '\')" '+
                  'onmouseout="MS_scrollBars[' + count + '].endScroll()" onclick="return false;">'+
                  '<img src="/test/resources/images/arrow_left.jpg" width="6" height="11"></div>'+
                  '<div class="scrollright"  id="rightarrow" onmouseover="MS_scrollBars[' + count + '].scrollEast(\'' + count +       '\')" '+
                  'onmouseout="MS_scrollBars[' + count + '].endScroll()" onclick="return false;">'+
                  '<img src="/test/resources/images/arrow_right.jpg" width="6" height="11"></div>'+
                  '<div class="scrollthumb" id="scrollthumb">'+
                  '<img src="/test/resources/images/scroll_bar_horizontal.jpg" width="' + thumbWidth + '" height="12"></div>';


    var rootLayer = document.getElementById(rootName);
    rootLayer.innerHTML = rootLayer.innerHTML + buttons;

    var thumbLayer = document.getElementById("scrollthumb");
    
    var leftArrowLayer = document.getElementById("leftarrow");
    var rightArrowLayer = document.getElementById("rightarrow");

    thumbLayer.style.border = 0;
    thumbLayer.style.top = parseInt(minY + 1) + "px";
    thumbLayer.style.left = parseInt(minX + 12) + "px";

    leftArrowLayer.style.top = parseInt(minY) + "px";
    leftArrowLayer.style.left = 0 + "px";

    rightArrowLayer.style.top = parseInt(minY) + "px";
    rightArrowLayer.style.left = parseInt(minX + maxX - 10) + "px";

    MS_scrollThumbs[count] = thumbLayer;
    MS_scrollBars[count].load();

    Drag.init(thumbLayer, null, minX + 12, maxX - 13 - thumbWidth, minY + 1, maxY + 1);

    var thumbTravel = thumbLayer.maxX - thumbLayer.minX;

    var ratio = (MS_scrollBars[count].scrollW) / thumbTravel;

    MS_scrollThumbs[count].onDrag = function(x, y) {
	    MS_scrollBars[count].jumpTo(Math.round((x - thumbLayer.minX) * ratio), null);
    }
}		

function MS_thumbnailMouseOver()
{
	this.setAttribute('src', this.getAttribute('srcover'));

    if (document.getElementById("MS_exhibition_html1")) {
        document.getElementById("MS_exhibition_html1").innerHTML = exhibitionHtml1[parseInt(this.getAttribute('srcindex'))];
    }
}

function MS_thumbnailMouseOut()
{
    if (parseInt(this.getAttribute('srcindex')) != MS_selectedIndex) {    
	    this.setAttribute('src', this.getAttribute('srcout'));
	}
	
    if (document.getElementById("MS_exhibition_html1")) {
        document.getElementById("MS_exhibition_html1").innerHTML = "<p/>";
    }
}

function MS_thumbnailMouseClick()
{
    MS_selectThumbnail(parseInt(this.getAttribute('srcindex')));    
    return false;
}

function MS_selectThumbnail(index)
{
    if (document.getElementById("MS_thumb" + index)) 
    {
        var thumb = document.getElementById("MS_thumb" + index);
	    thumb.src = thumb.getAttribute('srcover');
    }
    
    if (document.getElementById("MS_big_img")) 
    {
        var bigImg = document.getElementById("MS_big_img");
//        bigImg.src = MS_basePath + MS_padDigits(index, 2) + '.jpg';
	bigImg.src = MS_basePath + exhibitionBigImages[index] + '.jpg';
    }

    if (index != MS_selectedIndex && document.getElementById("MS_thumb" + MS_selectedIndex)) 
    {
        var selectedThumb = document.getElementById("MS_thumb" + MS_selectedIndex);
	    selectedThumb.src = selectedThumb.getAttribute('srcout');
    }

    if (document.getElementById("MS_exhibition_html2")) {
        document.getElementById("MS_exhibition_html2").innerHTML = exhibitionHtml2[index];
    }

    MS_selectedIndex = index;
    
    if (MS_imageCount > 5)
    {
        MS_scrollToIndex(MS_selectedIndex - 1);
    }
}

function MS_scrollLeft() 
{
    if (MS_selectedIndex > 1) 
    {
        MS_selectThumbnail(MS_selectedIndex - 1);
    }
}

function MS_scrollRight()
{
    if (MS_selectedIndex < MS_imageCount) 
    {
        MS_selectThumbnail(MS_selectedIndex + 1);
    }
}

function MS_scrollToIndex(index)
{
    var nextPosition; 

    if (index < 2) {
        nextPosition = 0;
    }
    else if (index >= MS_imageCount - 2) {
        nextPosition = MS_imageCount - MS_totalVisibleWidth / (MS_thumbWidth - 1);
    }
    else {
        nextPosition = index - 2;
    }    
    
    var offset = nextPosition * MS_thumbWidth - MS_thumbPosition * MS_thumbWidth;
    var direction;
    
    if (offset < 0) {
        direction = 1;
        offset = -offset;
    }
    else {
        direction = -1;
    }

    MS_scrollLayerTo("MS_thumb_strip", - nextPosition * MS_thumbWidth );
    
    MS_thumbPosition = nextPosition;
}

function MS_scrollLayerTo(layerName, offsetLeft) 
{
    if (MS_getLayer(layerName)) 
    {
        layer = MS_getLayer(layerName);
        
        steps = Math.floor(10 * Math.abs(((offsetLeft - MS_getLeft(layer)) / (MS_thumbWidth - 1))));
        offsetDelta = Math.abs(offsetLeft - MS_getLeft(layer));
        direction = (offsetLeft > MS_getLeft(layer)) ? -1 : 1;
        delay = 15;
        
        continueScroll = true;
        setTimeout("MS_scrollOneStep(\"" + layerName + "\", " + steps + ", 0, " + delay + ", " + MS_getLeft(layer) + ", " + offsetDelta + ", " + direction + ")", delay);
    }
}

function MS_scrollOneStep(layerName, totalSteps, actualStep, delay, start, offset, direction) 
{
    if (continueScroll && actualStep < totalSteps) 
    {        
        if (actualStep < totalSteps / 2)
        {
            currentX = MS_easeInOut(0, offset, totalSteps, actualStep, 3);
            nextX = MS_easeInOut(0, offset, totalSteps, actualStep + 1, 3);
        }
        //else
        {
            currentX = MS_easeInOut(0, offset, totalSteps, actualStep, .7);
            nextX = MS_easeInOut(0, offset, totalSteps, actualStep + 1, .7);
        }
        
        MS_scrollBars[0].moveTo(0, direction * nextX - start, null);                
        //MS_moveLayerBy(MS_getLayer(layerName), direction * (nextX - currentX), 0);
        
        actualStep += 1;

        setTimeout("MS_scrollOneStep(\"" + layerName + "\", " + totalSteps + ", " + actualStep + ", " + delay + ", " + start + ", " + offset + ", " + direction + ")", delay);
    }
}

function MS_easeInOut(minValue, maxValue, totalSteps, actualStep, powr) 
{
	var delta = maxValue - minValue;
	var stepp = minValue + (Math.pow(((1 / totalSteps) * actualStep), powr) * delta);
	return Math.ceil(stepp);
}

function MS_getLayer(name) 
{ 
    if (MS_isMZ) return document.getElementById(name); 
    else if (MS_isIE) return eval('document.all.' + name); 
    else { 
        var layer; 
        for (var i = 0; i < document.layers.length; i++) { 
            layer = document.layers[i]; if (layer.name == name) return layer; 
        } 
    } 
} 

function MS_getLeft(layer) 
{ 
    if (MS_isNS) return(layer.left); 
    else {
        var left = parseInt(layer.style.left.replace('px', '')); 
        if (isNaN(left)) left = 0;
        return left;
    }
} 

function MS_getTop(layer) 
{ 
    if (MS_isNS) return(layer.top); 
    else {
        var top = parseInt(layer.style.top.replace('px', '')); 
        if (isNaN(top)) top = 0;
        return top;
    }
} 

function MS_moveLayerBy(layer, x, y) 
{ 
    if (MS_isNS) layer.moveBy(x, y); 
    else { 
        layer.style.left = MS_getLeft(layer) + x + 'px'; 
        layer.style.top = MS_getTop(layer) + y + 'px'; 
    } 
} 

function MS_scrollLayer(layer, scrollLeft, scrollTop) 
{ 
    layer.scrollLeft = scrollLeft; 
    layer.scrollTop = scrollTop; 
} 


function MS_padDigits(n, totalDigits) 
{ 
    n = n.toString(); 
    var pd = ''; 
    if (totalDigits > n.length) 
    { 
        for (i=0; i < (totalDigits-n.length); i++) 
        { 
            pd += '0'; 
        } 
    } 
    return pd + n.toString(); 
} 


/**************************************************
 * dom-drag
 **************************************************/

var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag	= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup	= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};


/* =======================================================
* ypSimpleScroll
* ======================================================= */

ypSimpleScroll.prototype.scrollNorth = function(count) { this.startScroll(90, count) }
ypSimpleScroll.prototype.scrollSouth = function(count) { this.startScroll(270, count) }
ypSimpleScroll.prototype.scrollWest = function(count) { this.startScroll(180, count) }
ypSimpleScroll.prototype.scrollEast = function(count) { this.startScroll(0, count) }

ypSimpleScroll.prototype.startScroll = function(deg, count) {
	if (this.loaded){
		if (this.aniTimer) window.clearTimeout(this.aniTimer)
		this.overrideScrollAngle(deg)
		this.speed = this.origSpeed
		this.lastTime = (new Date()).getTime() - this.y.minRes
		this.aniTimer = window.setTimeout(this.gRef + ".scroll('"+deg+"','"+count+"')", this.y.minRes)
	}
}

ypSimpleScroll.prototype.endScroll = function() {
	if (this.loaded){
		window.clearTimeout(this.aniTimer)
		this.aniTimer = 0;
		this.speed = this.origSpeed
	}
}

ypSimpleScroll.prototype.overrideScrollAngle = function(deg) {
	if (this.loaded){
		deg = deg % 360
		if (deg % 90 == 0) {
			var cos = deg == 0 ? 1 : deg == 180 ? -1 : 0
			var sin = deg == 90 ? -1 : deg == 270 ? 1 : 0
		} 
		else {
			var angle = deg * Math.PI / 180
			var cos = Math.cos(angle)
			var sin = Math.sin(angle)
			sin = -sin
		}
		this.fx = cos / (Math.abs(cos) + Math.abs(sin))
		this.fy = sin / (Math.abs(cos) + Math.abs(sin))
		this.stopH = deg == 90 || deg == 270 ? this.scrollLeft : deg < 90 || deg > 270 ? this.scrollW : 0
		this.stopV = deg == 0 || deg == 180 ? this.scrollTop : deg < 180 ? 0 : this.scrollH
	}
}

ypSimpleScroll.prototype.overrideScrollSpeed = function(speed) {
	if (this.loaded) this.speed = speed
}

ypSimpleScroll.prototype.scrollTo = function(stopH, stopV, aniLen) {
	if (this.loaded){
		if (stopH != this.scrollLeft || stopV != this.scrollTop) {
			if (this.aniTimer) window.clearTimeout(this.aniTimer)
			this.lastTime = (new Date()).getTime()
			var dx = Math.abs(stopH - this.scrollLeft)
			var dy = Math.abs(stopV - this.scrollTop)
			var d = Math.sqrt(Math.pow(dx,2) + Math.pow(dy,2))
			this.fx = (stopH - this.scrollLeft) / (dx + dy)
			this.fy = (stopV - this.scrollTop) / (dx + dy)
			this.stopH = stopH
			this.stopV = stopV
			this.speed = d / aniLen * 1000
			window.setTimeout(this.gRef + ".scroll()", this.y.minRes)
		}
	}
}

ypSimpleScroll.prototype.jumpTo = function(nx, ny) { 
	if (this.loaded){
		nx = Math.min(Math.max(nx, 0), this.scrollW)
		ny = Math.min(Math.max(ny, 0), this.scrollH)
		this.scrollLeft = nx
		this.scrollTop = ny
		if (this.y.ns4)this.content.moveTo(-nx, -ny)
		else {
			this.content.style.left = -nx + "px"
			this.content.style.top = -ny + "px"
		}
	}
}

ypSimpleScroll.prototype.moveTo = function(count, nx, ny) { 
	if (this.loaded){
		nx = Math.min(Math.max(nx, 0), this.scrollW)
		ny = Math.min(Math.max(ny, 0), this.scrollH)
		this.scrollLeft = nx
		this.scrollTop = ny
		if (this.y.ns4)this.content.moveTo(-nx, -ny)
		else {
			this.content.style.left = -nx + "px"
			this.content.style.top = -ny + "px"
		}
	}
    
    MS_scrollThumbs[count].style.top = parseInt(((MS_scrollThumbs[count].maxY-MS_scrollThumbs[count].minY)*this.scrollTop/this.scrollH)+MS_scrollThumbs[count].minY) + "px"; //ok nomes down	
    MS_scrollThumbs[count].style.left = parseInt(((MS_scrollThumbs[count].maxX-MS_scrollThumbs[count].minX)*this.scrollLeft/this.scrollW)+MS_scrollThumbs[count].minX) + "px"; //ok nomes down	
}

ypSimpleScroll.minRes = 10
ypSimpleScroll.ie = document.all ? 1 : 0
ypSimpleScroll.ns4 = document.layers ? 1 : 0
ypSimpleScroll.dom = document.getElementById ? 1 : 0
ypSimpleScroll.mac = navigator.platform == "MacPPC"
ypSimpleScroll.mo5 = document.getElementById && !document.all ? 1 : 0

ypSimpleScroll.prototype.scroll = function(deg,count) {
	this.aniTimer = window.setTimeout(this.gRef + ".scroll('"+deg+"','"+count+"')", this.y.minRes)
	var nt = (new Date()).getTime()
	var d = Math.round((nt - this.lastTime) / 1000 * this.speed)
	if (d > 0){
		var nx = d * this.fx + this.scrollLeft
		var ny = d * this.fy + this.scrollTop
		var xOut = (nx >= this.scrollLeft && nx >= this.stopH) || (nx <= this.scrollLeft && nx <= this.stopH)
		var yOut = (ny >= this.scrollTop && ny >= this.stopV) || (ny <= this.scrollTop && ny <= this.stopV)
		if (nt - this.lastTime != 0 && 
			((this.fx == 0 && this.fy == 0) || 
			(this.fy == 0 && xOut) || 
			(this.fx == 0 && yOut) || 
			(this.fx != 0 && this.fy != 0 && 
			xOut && yOut))) {
			this.jumpTo(this.stopH, this.stopV)
			this.endScroll()
		}
		else {
			this.jumpTo(nx, ny)
			this.lastTime = nt
		}

	MS_scrollThumbs[count].style.top = parseInt(((MS_scrollThumbs[count].maxY-MS_scrollThumbs[count].minY)*this.scrollTop/this.scrollH)+MS_scrollThumbs[count].minY) + "px"; //ok nomes down
	MS_scrollThumbs[count].style.left = parseInt(((MS_scrollThumbs[count].maxX-MS_scrollThumbs[count].minX)*this.scrollLeft/this.scrollW)+MS_scrollThumbs[count].minX) + "px"; //ok nomes down
	}
}

function ypSimpleScroll(containerid, contentid, left, top, width, height, speed) {
	var y = this.y = ypSimpleScroll
	if (document.layers && !y.ns4) history.go(0)
	if (y.ie || y.ns4 || y.dom) {
		this.loaded = false
		this.containerid = containerid
		this.contentid = contentid
		this.origSpeed = speed
		this.aniTimer = false
		this.op = ""
		this.lastTime = 0
		this.clipH = height
		this.clipW = width
		this.scrollTop = 0
		this.scrollLeft = 0
		this.gRef = "ypSimpleScroll_" + containerid
		eval(this.gRef+"=this")
    }
}

ypSimpleScroll.prototype.load = function() {
	var d, lyrId1, lyrId2
	d = document
	lyrId1 = this.containerid
	lyrId2 = this.contentid
	this.container = this.y.dom ? d.getElementById(lyrId1) : this.y.ie ? d.all[lyrId1] : d.layers[lyrId1]
	this.content = obj2 = this.y.ns4 ? this.container.layers[lyrId2] : this.y.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	this.docH = Math.max(this.y.ns4 ? this.content.document.height : this.content.offsetHeight, this.clipH)
	this.docW = Math.max(this.y.ns4 ? this.content.document.width : this.content.offsetWidth, this.clipW)
	this.scrollH = this.docH - this.clipH
	this.scrollW = this.docW - this.clipW
	this.loaded = true
	this.scrollLeft = Math.max(Math.min(this.scrollLeft, this.scrollW),0)
	this.scrollTop = Math.max(Math.min(this.scrollTop, this.scrollH),0)
	this.jumpTo(this.scrollLeft, this.scrollTop)
}


