photos = Array();
galleryPhotos = Array();
i=0;
/*
IE5 Mac display block bug
display = '' resets to block by default
*/
function hidedetail()
{
	document.getElementById('detail').style.display = 'none';
	document.getElementById('viewer').style.display = '';
}
function showdetail()
{
	document.getElementById('detail').style.display = '';
	document.getElementById('viewer').style.display = 'none';
}

function fillCopyright()
{
	if (document.forms[0].copyright.value == '')
	{
		dateVar = new Date();
		document.forms[0].copyright.value = 'Copyright ' + document.forms[0].name.value + ' ' + dateVar.getFullYear();
	}
}

function next()
{
    if (document.images)
    {
		if (i + 1 < photos.length)
			i++;
		else
			i=0;
		
		document.getElementById('gallery').src = '/boilerhouse/img/folio/' + photos[i];	
	}
}

function previous() 
{
    if (document.images)
    {
		if (i - 1 >= 0)
			i--;
		else
			i= photos.length-1;	
		
		document.getElementById('gallery').src = '/boilerhouse/img/folio/' + photos[i];	
	}
}

function preload()
{
    if (document.images)
    {
      preload_image_object = new Image();

       var j = 0;
       for(j=0; j<=photos.length-1; j++) 
         preload_image_object.src = '/boilerhouse/img/folio/' + photos[j];
    }  
}



// An article about using the XHTML Target Module to allow the target="_blank"
// However the extending of DTD with XHTML Target Module is badly implemented in most browsers
// http://www.zeldman.com/daily/0503a.shtml#strictlyspeaking
// http://www.w3.org/TR/2001/REC-xhtml-modularization-20010410/dtd_module_defs.html#a_module_Target

// Another article showing another technique to mark up then dynamically add the target attribute after the page has loaded
// http://www.sitepoint.com/article/standards-compliant-world
function targetBlank() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "external" ||  anchor.getAttribute("rel") == "download"))
     	anchor.target = "_blank";
 }
}


window.onload = function() 
{
	targetBlank();
	preload();
	preloadGalleryImg();
}


function popup(obj)
{
	window.open(obj.href, 'box', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,left=440,top=362');	
	return false;
}

	galleryPhotos = Array(
Array('fair_ride.jpg', 'Fair Ride. Copyright Pete Willis 2006'),
Array('the_laines.jpg', 'The Laines. Copyright Pete Willis 2006'),
Array('brighton_pier.jpg', 'Brighton Pier. Copyright Pete Willis 2006'),
Array('cornish_lugger.jpg', 'Cornish Lugger. Copyright Sara James 2006'),
Array('fatepur_sikri.jpg', 'Fatepur Sikri. Copyright Boilerhouse 2006'),
Array('mies_van_der_rohe_pavillion.jpg', 'Mies Van der Rohe Pavillion. Copyright Boilerhouse 2006'),	
Array('homepage1.jpg', 'Copyright Boilerhouse 2006'),
Array('homepage2.jpg', 'Birmingham Jewellery Quarter. Copyright Boilerhouse 2006'),
Array('homepage3.jpg', 'Lake District. Copyright Phil Dawson 2006')
);
	
function previousGalleryImg()
{
    if (document.images)
    {
		if (i - 1 >= 0)
			i--;
		else
			i= galleryPhotos.length-1;	
		
		var gallery = document.getElementById('gallery');
		gallery.src = '/boilerhouse/img/gallery/' + galleryPhotos[i][0];
		gallery.title = galleryPhotos[i][1];	
	}
}
function nextGalleryImg()
{
    if (document.images)
    {
		if (i + 1 < galleryPhotos.length)
			i++;
		else
			i=0;
		
		var gallery = document.getElementById('gallery');
		gallery.src = '/boilerhouse/img/gallery/' + galleryPhotos[i][0];
		gallery.title = galleryPhotos[i][1]
	}
}
function preloadGalleryImg()
{
    if (document.images)
    {
      preload_image_object2 = new Image();

       var j = 0;
       for(j=0; j<=galleryPhotos.length-1; j++) 
         preload_image_object2.src = '/boilerhouse/img/gallery/' + galleryPhotos[j][0];
    }  
}