var pre="previous";
var nxt="next";


var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// pinched from http://www.jibbering.com/2002/4/httprequest.html
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

function testIfExists (url2get) {
 xmlhttp.open("HEAD", url2get,true);
 xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) {
   //alert(xmlhttp.getAllResponseHeaders())
  }
 }
 xmlhttp.send(null)
 }


function hideLayer(whichLayer)
{
try {
if (document.getElementById)
	{
	// this is the way the standards work
	var style2 = document.getElementById(whichLayer).style;
	style2.display = "none";
	}
}
catch(err)
{
// do nothing
}
}

function send_to(clickedlump) {
var currentloc=location.href; // save this in case it all goes wrong

try {
	// stash the name of this image
	temp=clickedlump.src;
	if (temp.lastIndexOf("/") > 0)
	  temp=temp.substring(temp.lastIndexOf("/")+1);
  	temp=temp.split(".")[0];
  	if (temp.substr(temp.length-3)=="_sm") {
                temp=temp.substr(0,temp.length-3) + ".html";


                testIfExists(temp)

		location.href=temp;

        }
 }
 catch(err)
 {
        // Components.utils.reportError(err);
 	location.href=currentloc;
        return(false);
 }
}

function afterLastSlash(chunk) {
	if (chunk.lastIndexOf("/") > 0)
	  chunk=chunk.substring(chunk.lastIndexOf("/")+1);
        return chunk;
}

function loader() {
try {
	var temp=afterLastSlash(location.href).split(".")[0];
        var pfx="";
        var nxtpage="";
        if (temp.lastIndexOf("_") > 0) {

          pfx=temp.substring(0,temp.lastIndexOf("_")+1);
          temp=temp.substring(temp.lastIndexOf("_")+1);
          var m = temp.split("x")[0];
          var n = temp.split("x")[1];
          if (parseInt(m) == 1) {
          hideLayer("prev");
          hideLayer("prev1");
                }
          else if (parseInt(m) == parseInt(n)) {
          hideLayer("next");
          hideLayer("next1");
          }
        }
        else
        {
        // do nowt
        }
}
catch(err)
{
// do nothing
}
}


function next() {
try {
	var temp=afterLastSlash(location.href).split(".")[0];
        var pfx="";
        var nxtpage="";
        if (temp.lastIndexOf("_") > 0) {

          pfx=temp.substring(0,temp.lastIndexOf("_")+1);
          temp=temp.substring(temp.lastIndexOf("_")+1);
          var m = temp.split("x")[0];
          var n = temp.split("x")[1];
          if (parseInt(m)+1 <= parseInt(n)) {
                nxtpage=pfx +  (parseInt(m)+1) + "x" + n+".html";
                }
                else // wraparound
                {
                nxtpage=pfx +  "1x" + n+".html";
                }
          location.href=nxtpage;
        }
        else
        {
        // do nowt
        }
}
catch(err)
{
// do nothing
}

}

function prev() {
try {
	var temp=afterLastSlash(location.href).split(".")[0];
        var pfx="";
        var nxtpage="";

        if (temp.lastIndexOf("_") > 0) {

          pfx=temp.substring(0,temp.lastIndexOf("_")+1);
          temp=temp.substring(temp.lastIndexOf("_")+1);
          var m = temp.split("x")[0];
          var n = temp.split("x")[1];
          if (parseInt(m)-1 > 0) {
                nxtpage=pfx +  (parseInt(m)-1) + "x" + n+".html";
                }
                else // wraparound to end
                {
                nxtpage=pfx +  n + "x" + n+".html";
                }
          location.href=nxtpage;
        }
        else
        {
        // do nowt
        }
}
catch(err)
{
// do nothing
}

}