    function new_moveto(id, size)
	{
        obj = document.getElementById(id);
        obj.style.left = "0px";
		moveto(id, size);
	}

    function moveto(id, size)
    {
        obj = document.getElementById(id);
        position = obj.style.left;
        position = clearPosition(position);
        position = (position*1) + (size*1);

		num_pos = position / sizeitem;
		if (num_pos < 0) num_pos = num_pos*(-1);

		if (minleft >= position && !(position > maxleft))
		{
			/* last pos */
			num_pos = numitems-1;
			fotos = document.getElementById("gal_fotos");
			if (fotos)
			{
				var first_item = true;
				var var_html = "";
				for (i = (numitems-pages); i < (numitems); i++)
				{
					if ((numitems > i) && (i >= 0))
					{
						if (!first_item)
							var_html += " | ";

						var_html += "<a href=\"javascript:new_moveto('list', (sizeitem)*(-"+i+"));\"";
						if (num_pos == i)
							var_html += 'class="scroll_highlight"';
						var_html += ">"+(i+1)+"</a>";
						first_item = false;
					}
				}
				fotos.innerHTML = var_html;
			}
		}
		else if (position > maxleft && !(minleft >= position))
		{
			/* first pos */
			num_pos = 0;
			fotos = document.getElementById("gal_fotos");
			if (fotos)
			{
				var first_item = true;
				var var_html = "";
				for (i = 0; i < pages; i++)
				{
					if ((numitems > i) && (i >= 0))
					{
						if (!first_item)
							var_html += " | ";

						var_html += "<a href=\"javascript:new_moveto('list', (sizeitem)*(-"+i+"));\"";
						if (num_pos == i)
							var_html += 'class="scroll_highlight"';
						var_html += ">"+(i+1)+"</a>";
						first_item = false;
					}
				}
				fotos.innerHTML = var_html;
//				fotos.innerHTML = " position = '" + position + "'<br/>pos = '" + num_pos + "' size = '" + size + "'";
			}
		}
		else
		{
			fotos = document.getElementById("gal_fotos");
			if (fotos)
			{
				var auxiliar = 0;
				var auxiliar_last = 0;

				if (position == 0)
					auxiliar = 1;
				if (num_pos == (numitems-1))
					auxiliar_last = -1;

				var first_item = true;
				var var_html = "";
				for (i = (0+auxiliar_last); i < (pages+auxiliar); i++)
				{
					var actual = (i+num_pos-1);
					if ((numitems > actual) && (actual >= 0))
					{
						if (!first_item)
							var_html += " | ";

						var_html += "<a href=\"javascript:new_moveto('list', (sizeitem)*(-"+actual+"));\"";
						if (num_pos == actual)
							var_html += 'class="scroll_highlight"';
						var_html += ">"+(actual+1)+"</a>";
						first_item = false;
					}
				}
//				var_html += " position = '" + position + "'<br/>pos = '" + num_pos + "' numitems = '" + numitems + "'";
				fotos.innerHTML = var_html;
			}
		}

        if (minleft >= position && position > maxleft)
        {
            obj.style.left = position + 'px';
            fadeInit();
        }
    }

    function clearPosition(pos)
	{
        if (pos)
		{
            return pos.replace('px','');
        }
		else
		{
            return 0;
        }
    }



// FADE SCRIPT

/* general variables */

var fadeTargetId = 'list'; /* change this to the ID of the fadeable object */
var fadeTarget;
var preInitTimer;
preInit();

/* functions */

function preInit()
{
    /* an inspired kludge that - in most cases - manages to initially hide the image
       before even onload is triggered (at which point it's normally too late, and a nasty flash
       occurs with non-cached images) */
    if ((document.getElementById)&&(fadeTarget=document.getElementById(fadeTargetId)))
	{
        fadeTarget.style.visibility = "hidden";
        if (typeof preInitTimer != 'undefined') clearTimeout(preInitTimer);
    }
	else
	{
        preInitTimer = setTimeout("preInit()",2);
    }
}

function fadeInit()
{
    if (document.getElementById)
	{
        /* get a handle on the fadeable object, to make code later more manageable */
        preInit(); /* shouldn't be necessary, but IE can sometimes get ahead of itself and trigger fadeInit first */
        /* set the initial opacity in a (hopefully) cross browser way
           notice that because of the way the image is in front, and not obfuscated
           by another object we need to "fade out", i don't need a fallback mechanism
           to show/hide the covering object...the image is just there, full stop */
        if (fadeTarget.style.MozOpacity!=null)
		{
            /* Mozilla's pre-CSS3 proprietary rule */
            fadeTarget.style.MozOpacity = 0;
        }
		else if (fadeTarget.style.opacity!=null)
		{
            /* CSS3 compatible */
            fadeTarget.style.opacity = 0;
        }
		else if (fadeTarget.style.filter!=null)
		{
            /* IE's proprietary filter */
            fadeTarget.style.filter = "alpha(opacity=0)";
        }
        /* make the object visible again */
        fadeTarget.style.visibility = 'visible';
        window.setTimeout("fadeIn(0)", 250);
    }
}

function fadeIn(opacity)
{
    if (fadeTarget)
	{
        if (opacity <= 100)
		{
            if (fadeTarget.style.MozOpacity!=null)
			{
                /* Mozilla's pre-CSS3 proprietary rule */
                fadeTarget.style.MozOpacity = (opacity/100)-.001;
                /* the .001 fixes a glitch in the opacity calculation which normally results in a flash when reaching 1 */
            }
			else if (fadeTarget.style.opacity!=null)
			{
                /* CSS3 compatible */
                fadeTarget.style.opacity = (opacity/100)-.001;
			}
			else if (fadeTarget.style.filter!=null)
			{
                /* IE's proprietary filter */
                fadeTarget.style.filter = "alpha(opacity="+opacity+")";
                /* worth noting: IE's opacity needs values in a range of 0-100, not 0.0 - 1.0 */
            }
            opacity += 10;
            window.setTimeout("fadeIn("+opacity+")", 60);
        }
    }
}

/* initialise fader by hiding image object first */
addEvent (window,'load',fadeInit)



/* 3rd party helper functions */

/* addEvent handler for IE and other browsers */
function addEvent(elm, evType, fn, useCapture)
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
 if (elm.addEventListener)
 {
   elm.addEventListener(evType, fn, useCapture);
   return true;
 }
 else if (elm.attachEvent)
 {
   var r = elm.attachEvent("on"+evType, fn);
   return r;
 }
}
