

<!--

// ==============================================

// Copyright 2003 by jsCode.com

// Source: jsCode.com

// Author: etLux

// Free for all; but please leave in the header.

// ==============================================



// Set up the image files to be used.

var theImages = new Array() // do not change this

// To add more image files, continue with the

// pattern below, adding to the array. Rememeber

// to increment the theImages[x] index!



theImages[0] = '/images/head.jpg'
theImages[1] = '/images/head2.jpg'
theImages[2] = '/images/head3.jpg'
theImages[3] = '/images/head4.jpg'
theImages[4] = '/images/head5.jpg'
theImages[5] = '/images/head6.jpg'
theImages[6] = '/images/head7.jpg'
theImages[7] = '/images/head8.jpg'
theImages[8] = '/images/head1.jpg'

// ======================================

// do not change anything below this line

// ======================================



var j = 0

var p = theImages.length;



var preBuffer = new Array()

for (i = 0; i < p; i++){

   preBuffer[i] = new Image()

   preBuffer[i].src = theImages[i]

}



var whichImage = Math.round(Math.random()*(p-1));

function showImage(){

document.write('<img src="'+theImages[whichImage]+'">');

}



// Internet Exploder is a pain. If it did what other browsers did, we could
// just redirect to the download here, but nooo... Microsoft has to prevent
// downloads and perform a page refresh to authorize them. Here comes some
// JavaScript voodoo...
function finished(tour) {
	// Take the current URL
	var url = document.location.href;

	// Strip off any sort of query string...
	url = url.replace(/[#?].*?$/, '');

	// Append '?download' to it (the tour stuff is a moot point right now
	// since we can use the current URL).
	url += '?download'+(tour != undefined ? '&tour='+tour : '');

	// And redirect...
	document.location.href = url;

	// Simple code for non-MS browsers:
	//document.location.href = '/regions/FPDI/download.php'+(tour != undefined ? '?tour='+tour : '');
}

// Function stolen from: http://phpjs.org/functions/basename:360
function basename(path, suffix) {
    var b = path.replace(/^.*[\/\\]/g, '');
     if (typeof(suffix) == 'string' && b.substr(b.length - suffix.length) == suffix) {
        b = b.substr(0, b.length - suffix.length);
    }
 
    return b;
}

// Look for a download flag...
if (document.location.href.indexOf('?download') != -1) {
	// Grab the current URL and use it for the PDF name...
	var url = document.location.href;
	var tour = url.replace(/^.*tour=([^&]+)(?:&|$)/, '$1');

	if (!tour || tour == url) {
		url = url.replace(/\.[^\.\/]+\?.*/, '');
		tour = basename(url);
	}

	// Clobber the window onLoad event. We redirect after the page is
	// loaded because if we do it before, the page will stop loading
	// somewhere in the middle.
	window.onload = function() {
		document.location.href = '/tours/FPDI/download.php?tour='+tour;
	};
}

