// History
//	2005-08-07	changed "myNavigate" so it's less dependent of the actual URL structure (esp. if "index.html" is missing)
//	2005-10-18	changed to UTF-8, added "zz"s
//	2005-10-21	added the low-probability donation reminder
//
var theList=new Array(
//	motion + time
	"mot_feet_lin","mot_mib","mot_ske", "mot_rotsnake", "mot_snakeAdLib",
	"mot_pinna-brelstaff", "mot_adapt", "mot_adaptSpiral", "mot_Roget", "mot_spokes",
	"mot_wagonWheel", "mot_strob", "mot_sigma",
	"mot_eyeJitter", "mot_biomot", "mot_flashlag1","mot_ramp-ada",
	"mot_enigma", "mot_freezeRot","mot_reverse-phi","mot_feet_rad", "mot_bounce", "mot_motionBinding", "mot_breathingSquare",
	"mot_miss-fund","mot_freq-doub","mot_kaleidoscope", "mot_Ternus", "mot_sam",
	"mot_zz",
//	Luminance
	"lum_herGrid","lum_herGridCurved", "lum_scGrid", "lum_induced-grating", "lum_diamond",
	"lum_cobc", "lum_wkoffka","lum_dynsimcontrast", "lum_pyramid", "lum_white",
	"lum_adelson-plaid","lum_adelsonCheckShadow", "lum_contrast-contrast", 
	"lum_contrast-adapt", "lum_lazyShadow","lum_hyperacuity",
	"lum_zz",
//	colour
	"col_lilacChaser", "col_benham", "col_neon", "col_equilu", "col_isoluNuBleu", "col_mix",
	"col_zz",
//	geometric
	"ang_hering", "ang_poggendorff", "ang_fraser", "ang_cafewall", "ang_trianglePuzzle",
	"geom_KitaokaBulge",
	"ang_zz",
//	size constancy
	"sze_muelue", "sze_moon", "sze_t-illusion", "sze_sineIllusion", 
	"sze_lumiloom", "sze_shepardTables", "sze_shepardTerrors", "sze_reverspective", 
	"sze_Necker", "sze_missCornerCube", "sze_silhouette", "sze_Frankfurter", "sze_anamorph",
	"sze_zz",
//	cognitive
	"cog_Darwin", "cog_blureffects","cog_blur_nsx", "cog_kanizsa", "cog_letters-ink", "cog_dalmatian", "cog_hiddenBird","cog_rotations",
	"cog_imposs1", "cog_impossHallucii", "cog_numerosity",
	"cog_zz",
//	faces
	"fcs_hollow-face", "fcs_face_in_beans", "fcs_face_on_mars", "fcs_thompson-thatcher",
	"fcs_ghostlyGaze", "fcs_SpatFreqComposites", 
	//"fcs_faceAdapt", 
	"fcs_mosaic",
//	end
	"_misc"
);


function myNavigate(direction) {
	//alert("*");
	//<protocol>//<host>[:<port>]/<pathname>[<hash>][<search>]
	var thePathname=window.location.pathname;  var newLocation ="";
//	var theProtocol=window.location.protocol, theHost=window.location.host, thePort=window.location.port;
	thePathname=thePathname.split("/");  
	if (thePathname[thePathname.length-1] == "index.html") {
		thePathname=thePathname[thePathname.length-2]+"/"+thePathname[thePathname.length-1];
	} else {
		thePathname=thePathname[thePathname.length-2]+"/index.html";
	}
	var theIndex=-9;
	for (i = 0; i < theList.length; i++) {
		if ((theList[i]+"/index.html")==thePathname) theIndex=i;
	}
	if ((theIndex<0) || (theIndex>=theList.length)) {
		newLocation = theList[0]+"/index.html";
		window.location.href = newLocation;
		return 1;
	}
	theIndex += direction;
	if ((theIndex<0) || (theIndex>=theList.length)) {
		newLocation = "../index.html";
	} else {
		newLocation = "../"+theList[theIndex]+"/index.html";
	}
//	newLocation = (theHost==""? "" : "theHost/")+newLocation;
//	alert(newLocation);
	window.location.href = newLocation;
	top.location.target="_top"
	if (window.location.target != "_top") {
		top.location.href = window.location.href
	}
	return 1;
}


function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function GetFlashVersion() {
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	var retValue = 0;
	if (plugin) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i) {
			if (isNaN(parseInt(words[i])))	continue;
			var MM_PluginVersion = words[i];
		}
		retValue = MM_PluginVersion;
    }
	return retValue;
}


/*
function IsFlashVersionSufficient(minimalVersion) {
	var vers = GetFlashVersion();
	return ((vers==0) || (vers >= minimalVersion));
}
function WriteFlashUpdateMessageWhenNeeded() {
	if (!IsFlashVersionSufficient(6)) {document.writeln('Please <a href="http://www.macromedia.com/go/getflashplayer">update your flash player</a>, current version is '+ GetFlashVersion())};
}
function FlashTooOldMessage(minimalVersion) {
	var retValue = "Please upgrade your Flash plugin";
	if FlashVersionSufficient(minimalVersion) {retValue = "";}
	return retValue;
}
*/

var gBackValue=-1;

function Initialize() {
	gBackValue=top.history.length;
}


function CreateBackButton() {
	document.write('<form onSubmit="0"><input type="button" value="Back" onClick="top.history.back()"></form>');
}


function CreateTopBackButton() {
	document.write('<form onSubmit="0">');
	document.write('<input type="button" value="Top" onClick="window.location.href=&quot;#anchor_top&quot;">');
//	document.write(' <input type="button" value="Back" onClick="top.history.go(gBackValue-top.history.length-1)">');
	document.write(' <input type="button" value="Back" onClick="top.history.back()">');
	document.write('</form>');
}


function DonationSuggestion() {
	var randomSelector = Math.round(Math.random()*3);
	switch (randomSelector) {
		case 0:
			document.write(
				'<h3 align="left">You may have noticed that there are no advertisements on this site…</h3><p>To help me keep it so, please consider contributing a small <a href="../_misc/donations.html"><b>&rarr;donation</b></a> to  help me to pay for traffic &amp; development tools.</p>');
			break
		case 1:
			document.write(
				'<h3 align="left">There are no advertisements on this site…</h3><p>Thus, please consider contributing a small <a href="../_misc/donations.html"><b>&rarr;donation</b></a> to  help me towards site maintainance &amp; development tools.</p>');
			break
		case 2:
			document.write(
				'<h3 align="left">Should you want to <a href="../_misc/donations.html">&rarr;donate</a>, you would help to further develop this site.</h3>');
		break
		case 3:
			document.write(
				'<h3 align="left">You enjoyed this site so far?</h3><p>If so, you might want to consider making a <a href="../_misc/donations.html"><b>&rarr;donation</b></a> to help me to pay for traffic &amp; development tools.</p>');
			break
		break
	}
}
