﻿// <![CDATA[

// nav-script

/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'rollover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, 'b'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('b'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

// end nav


// _____ gallery-function with preload _____

// preload

var pli = new Array(10);

function preloadit(group, many) {
	for (i=1; i<=many; i++) {         
    	pli[i] = new Image();
    	pli[i].src = "images/" + group + "_" + i + ".jpg";
	}
}

// end preload

thispic = 1;

function gofurther(group, many) {
	if (thispic == many) {
		thispic = 1;
	}
	else {
		thispic = thispic + 1;
	}
	document.getElementById('linkit').style.backgroundImage = 'url(images/' + group + '_' + thispic + '.jpg)';
 }
 
 function updateNav(a,b) {
	 piece = a;
	 piecesTot = b;
	 document.getElementById('piecesIndex').firstChild.nodeValue = a + " | " + b;
 }

 
 function goback(group, many) {
	if (thispic == 1) {
		thispic = many;
	}
	else {
		thispic = thispic - 1;
	}
	document.getElementById('linkit').style.backgroundImage = 'url(images/' + group + '_' + thispic + '.jpg)';
 }
 
// ]]>
