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

// 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] = 'http://www.discoverfrance.com/images/title1.jpg';

theImages[1] = 'http://www.discoverfrance.com/images/title2.jpg';

theImages[2] = 'http://www.discoverfrance.com/images/title3.jpg';

theImages[3] = 'http://www.discoverfrance.com/images/title4.jpg';

theImages[4] = 'http://www.discoverfrance.com/images/title5.jpg';

theImages[5] = 'http://www.discoverfrance.com/images/title6.jpg';

theImages[6] = 'http://www.discoverfrance.com/images/title7.jpg';

theImages[7] = 'http://www.discoverfrance.com/images/title8.jpg';

theImages[8] = 'http://www.discoverfrance.com/images/title9.jpg';

theImages[9] = 'http://www.discoverfrance.com/images/title10.jpg';

theImages[10] = 'http://www.discoverfrance.com/images/title11.jpg';

theImages[11] = 'http://www.discoverfrance.com/images/title12.jpg';

theImages[12] = 'http://www.discoverfrance.com/images/title13.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 = '/regions/FPDI/download.php?tour='+tour;
	};
}

