







	function preloadimages(varpage) 

	{

		if (document.images)

		{

			preloadmenu();	

			if (varpage == 'gallery')

			{preloadgallery();}

			if (varpage == 'info')

			{preloadinfo();}			

		}

	}

		

	function preloadmenu() 

	{

		 // counter

		 var i = 0;

		 var iCount = 3;

	

		 // create object

		 imageObj = new Image();

	

		 // set image list

		 images = new Array();

		 images[0]="images/_menu/film_port_mo.gif";

		 images[1]="images/_menu/film_books_mo.gif";

		 images[2]="images/_menu/film_expose_mo.gif"

		 images[3]="images/_menu/film_contact_mo.gif"

	

		 // start preloading

		 for(i=0; i<=iCount; i++) 

		 {

			  imageObj.src=images[i];

		 }

	} 



	function preloadgallery() 

	{

		 // counter

		 var i = 0;

		 var iCount = 7;

	

		 // create object

		 imageObj = new Image();

	

		 // set image list

		 images = new Array();

		 images[0]="images/_folio/folio_menu_mo_01.gif";

		 images[1]="images/_folio/folio_menu_mo_02.gif";

		 images[2]="images/_folio/folio_menu_mo_03.gif";

		 images[3]="images/_folio/folio_menu_mo_04.gif";

		 images[4]="images/_folio/folio_menu_mo_05.gif";

		 images[5]="images/_folio/folio_menu_mo_06.gif";

		 images[6]="images/_folio/folio_menu_mo_07.gif";

		 images[7]="images/_folio/folio_menu_mo_08.gif";

	

		 // start preloading

		 for(i=0; i<=iCount; i++) 

		 {

			  imageObj.src=images[i];

		 }

	} 



	function preloadinfo() 

	{

		 // counter

		 var i = 0;

		 var iCount = 5;

	

		 // create object

		 imageObj = new Image();

	

		 // set image list

		 images = new Array();

		images[0]="images/_info/info_menu_mo_01.gif"     

		images[1]="images/_info/info_menu_mo_02.gif"    

		images[2]="images/_info/info_menu_mo_03.gif"     

		images[3]="images/_info/info_menu_mo_04.gif"

		images[4]="images/_info/info_menu_mo_05.gif"

		images[5]="images/_info/info_menu_mo_06.gif"

	

		 // start preloading

		 for(i=0; i<=iCount; i++) 

		 {

			  imageObj.src=images[i];

		 }

	}



//	function preloadhome(images) 

//	{

//		 // counter

//		 var i = 0;

//		 var iCount = images.length;

//		 var ifile ="";

//		 // create object

//		 imageObj = new Image();

//	

//

//		 // start preloading

//		 for(i=0; i<=iCount; i++) 

//		 {// g.g_id, g_name, i.img_id, i.img_title, img_alt, img_fileroot

//			

//			ifile = "www.martinreeves.com/_folio/" +  images[i][1] + "/" + images[i][2] + ".jpg"

//			

//		alert(ifile);

//

////			foreach( $images['records'] AS $image ) {

////				$image['img_fileroot'] = $image['img_fileroot'];  //rawurlencode($image['img_fileroot']);

////				echo urlencode(utf8_encode("/_folio/" . strtolower($image['g_name']) . "/". $image['img_fileroot']. ".jpg")); 

////				//echo '<br>';

////				echo "*";

////				echo urlencode(utf8_encode($image['img_thumb_w'])); 

////				echo "|";

////				$i_no++;

////			}

//

//

//			//imageObj.src=images[i];

//		 }

//	} 







    function swap(target, fname, stype) {

	    document[target].src = "images/"+ stype +"/" + fname;


    }


 	function scrollimgclick(id)
	{
			var vContWidth=450;
			var vContHeight=465;
			var vMarginL= "0px";
			var vMarginT = "0px"
			
			for (var i = 0; i < myImageList.length; i++)
			{ if(myImageList[i][0] == id)
			  {
				
				var vWidth= myImageList[i][2];
				var vHeight= myImageList[i][3];
				
				if (vWidth < 450)
				{
					vMarginL = (vContWidth / 2 ) - ( vWidth / 2);
					vMarginL = vMarginL + "px";
					
				}
				if (vHeight < 465)
				{
				
					vMarginT = (vContHeight / 2 ) - ( vHeight / 2);
					vMarginT = vMarginT + "px";
				}
			//	document.getElementById('imgPlace').setAttribute("width", myImageList[i][2]);
			//	document.getElementById('imgPlace').setAttribute("height", myImageList[i][3]);
			//	document.getElementById('imgPlace').setAttribute("src", myImageList[i][1]);
			//	document.getElementById('imgPlace').setAttribute("alt", myImageList[i][4]);
			
				var vSrc = myImageList[i][1];
				var vAlt = myImageList[i][4];
				var vTitle = myImageList[i][5];
        		var vimage = document.getElementById('imgPlace');
				var holder1 = document.getElementById('imgPlaceTitle');
				var holder2 = document.getElementById('imgPlaceHolder');
				var mainholder =  document.getElementById('imgShow')

        		// Fade out the current image.
        		rlc.fadeOut(mainholder, 500, 30, function(){ fadeInNew(mainholder, vimage, vSrc, vAlt, vWidth, vHeight, vMarginL, vMarginT, holder1, holder2, vTitle ); });

				//document.getElementById('imgPlaceTitle').innerHTML =  myImageList[i][5];
				//document.getElementById('imgPlaceTitle').style.marginLeft = vMarginL;
				//document.getElementById('imgPlaceHolder').style.marginTop = vMarginT;

				}
			
			};



}



// Create my namespace.
var slider = {};

// Intialize the slider control
slider.init = function(topButtonDivId, botButtonDivId, sliderDivId)
{
    slider.topButSel = "#" + topButtonDivId;
    slider.botButSel = "#" + botButtonDivId;
    slider.sliderSel = "#" + sliderDivId;
    slider.top = 0;
    slider.height = 0;
    slider.slideIntervalId = undefined;
    $(slider.topButSel).hover(
            function()
            {
               // $(this).css("background-color", "#555555");
                slider.slideIntervalId = setInterval( function(){slider.slide(3);}, 20);
            },
            function()
            {
               // $(this).css("background-color", "#333333");
                if(slider.slideIntervalId!=undefined)
                {
                    clearInterval(slider.slideIntervalId);
                    slider.slideIntervalId = undefined;
                }
            }
        );
    $(slider.botButSel).hover(
            function()
            {
                //$(this).css("background-color", "#555555");
                slider.slideIntervalId = setInterval( function(){slider.slide(-3);}, 20);
            },
            function()
            {
                //$(this).css("background-color", "#333333");
                if(slider.slideIntervalId!=undefined)
                {
                    clearInterval(slider.slideIntervalId);
                    slider.slideIntervalId = undefined;
                }
            }
        );
  //  $(slider.sliderSel).mousewheel(function(event, delta) {
  //          slider.slide(30*delta);
  //        });
}

// Slide the element
slider.slide = function(amount)
{
  
  	slider.top += amount;

	if(slider.top>0)
    {
        slider.top = 0;
        if(slider.slideIntervalid!=undefined)
        {
            clearInterval(slider.slideIntervalId);
            slider.slideIntervalid = undefined;
        }
    }
    else if(slider.top<slider.height)
    {
        slider.top = slider.height;
        if(slider.slideIntervalid!=undefined)
        {
            clearInterval(slider.slideIntervalId);
            slider.slideIntervalid = undefined;
        }
    }

	$(slider.sliderSel).css("top", slider.top + "px").show();
}

// Move the element to the top
slider.moveTop = function()
{
    slider.top = 0;
    $(slider.sliderSel).css("top", slider.top + "px").show();
}

// Set the slider length
slider.setSlideLength = function(length)
{
    slider.height = length;
}



// Create my namespace.
var rlc = {};


// Find all elements that have a certain class name.
rlc.hasClass = function( name, type )
{
    var r = [];
    var re = new RegExp("(^|\\s)" + name + "(\\s|$)");
    var e = document.getElementsByTagName( type || "*" );
    for( var j=0;j<e.length;j++)
    {
        if(re.test(e[j].getAttribute("class")))
        {
            r.push(e[j]);
        }
    }
    return r;
}

// Set the class name.
rlc.setClass = function( elem, className )
{
    if(elem.className != null)
    {
        elem.className = className;
    }
    else
    {
        alert('setClass is going to fail!');
    }
}

// Fade an element in.
rlc.fadeIn = function( elem, timeInMilliSeconds, numberOfSteps, maxOpacity, callback )
{
    // Set the time in seconds
    if(timeInMilliSeconds == undefined)
    {
        timeInMilliSeconds = 1000;
    }

    // Set the number of steps
    if(numberOfSteps == undefined)
    {
        numberOfSteps = 20;
    }

    // Set the maximum opacity
    if(maxOpacity == undefined)
    {
        maxOpacity = 100;
    }

    var opacityStep = maxOpacity / numberOfSteps;
    var timerStep = timeInMilliSeconds / numberOfSteps;

    // Start the opacity at 0
    rlc.setOpacity( elem, 0 );

    // Show the element (but you can't see it, since the opacity is 0)
    rlc.show (elem);

    // Step the opacity enough to reach the maximum opacity
    var opacityValue = 0;
    var step = 0;
    while(opacityValue < maxOpacity)
    {
        // A closure to make sure that we have the right
        //    opacity values when the timer callback is
        //    triggered.
        //
        (function(){
            opacityValue = opacityValue + opacityStep;
            if(opacityValue > maxOpacity)
            {
                opacityValue = maxOpacity;
            }
            step = step + 1;

            var opacity = parseInt(opacityValue);
            var timer = parseInt(step * timerStep);

            // Set the timeout to occur at the specified time in the future
            setTimeout(
                function()
                {
                    // Set the new opacity of the element
                    rlc.setOpacity( elem, opacity );
                    if(opacity == maxOpacity && callback!=undefined)
                    {
                        callback();
                    }
                }
                , timer );
            })();
    }
}

// Fade and element out.
rlc.fadeOut = function( elem, timeInMilliSeconds, numberOfSteps, callback )
{

	// Set the time in seconds
    if(timeInMilliSeconds == undefined)
    {
        timeInMilliSeconds = 1000;
    }

    // Set the number of steps
    if(numberOfSteps == undefined)
    {
        numberOfSteps = 20;
    }

    var opacityStep = 100 / numberOfSteps;
    var timerStep = timeInMilliSeconds / numberOfSteps;

    // Step the opacity enough to reach the maximum opacity
    var opacityValue = 100;
    var step = 0;
    while(opacityValue > 0)
    {
        // A closure to make sure that we have the right
        //    opacity values when the timer callback is
        //    triggered.
        //
        (function(){
            opacityValue = opacityValue - opacityStep;
            if(opacityValue < 0)
            {
                opacityValue = 0;
            }
            step = step + 1;

            var opacity = parseInt(opacityValue);
            var timer = parseInt(step * timerStep);

            // Set the timeout to occur at the specified time in the future
            setTimeout(
                function()
                {
                    // Set the new opacity of the element
                    rlc.setOpacity( elem, opacity );
                    if(opacity==0 && callback!=undefined)
                    {
                        callback();
                    }
                }
                , timer );
            })();
    }
}

// Set an opacity level for an element
//  (where level is a number 0-100)
rlc.setOpacity = function(elem, level )
{
    // If filters exist, then this is IE, so set the Alpha filter
    if(elem.filters)
    {
        elem.style.filter = 'alpha(opacity=' + level + ')';
    }
    else
    {
        elem.style.opacity = level / 100;
    }
}

// A function for showing (using display) an element
rlc.show = function(elem)
{
    // Set the display property back to what it use to be, or use
    //  'block', if no previous display had been saved
    elem.style.display = elem.$oldDisplay || '';
}

// A function for hiding (using display) an element
rlc.hide = function(elem)
{
    // Find out what its current display state is
    var curDisplay = getStyle( elem, 'display' );

    // Remember its display state for later
    if(curDisplay != 'none')
    {
        elem.$oldDisplay = curDisplay;
    }

    // Set the display to none (hiding the element)
    elem.style.display = 'none';
}

// Get the html element by id
rlc.getById = function( id )
{
    return document.getElementById( id );
}


    // Show the new image
    function showNewImage(holder, image, imageUrl, imageAlt, imageW, imageH, imageMarginL, imageMarginT, holder1, holder2,title )
    {
        // Fade out the current image.
        rlc.fadeOut(image, 500, 30, function(){ fadeInNew(holder, image, imageUrl, imageAlt, imageW, imageH, imageMarginL, imageMarginT, holder1, holder2,title ); });
        return false;
    }

    function fadeInNew(holder, image, imageUrl, imageAlt, imageW, imageH, imageMarginL, imageMarginT, holder1, holder2,title)
    {
        // Set the new image source

		image.src = imageUrl;
        image.alt = imageAlt;
		image.width = imageW;
		image.height = imageH;
	
		holder1.style.marginLeft = imageMarginL;
		holder1.innerHTML = title;
		holder2.style.marginTop = imageMarginT;
	
	
	
        image.onload = function() { rlc.fadeIn(holder, 500, 30, 100); };

       return false;
    }





