//generic site scripts for mouseovers and preloaders
function swapImgRestore() { 
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

var myimages=new Array()
function preloadimages(){
	for (i=0;i<preloadimages.arguments.length;i++){
	myimages[i]=new Image()
	myimages[i].src=preloadimages.arguments[i]
	}
}
preloadimages("images/01.jpg","images/02.jpg","images/03.jpg","images/04.jpg","images/05.jpg","images/06.jpg","images/07.jpg")



function findObj(n, d) { 
  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=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

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

//script for slideshow
//split URL into parameters and set variables
var params = document.location.href.split("?");
var filename = /(\w*\.\w*)$/.exec(params[0]);
var pictures = new Array();
var captions = new Array();
var numAlbums=0;
var folderName;
var picture=0;
var album=0;
var paramString="?";

//increment through all of the params, extract album and picture information and save additional params
if(params[1]){
	splitParams = params[1].split("&");
	for(i in splitParams){
		var a = /album=(\d+)/.exec(splitParams[i]);
		if(a)
			album=parseInt(a[1]);
		else{
			var p = /pic=(\d+)/.exec(splitParams[i]);
			if(p)		
				picture=parseInt(p[1]);
			else{
				paramString+=splitParams[i]+"&";
			}
		}
	}
}

//Adds a picture to the current album with the filename and caption you specify
function add(filename,caption){
	if(numAlbums==0)
	alert("I am sorry.  There is currently a problem with images loading.");
	var index = pictures[numAlbums-1].length;
	pictures[numAlbums-1][index] = folderName+filename;
	captions[numAlbums-1][index] = caption;
}

//Creates a new album and looks for images in current folder or the folder you specify
function newAlbum(folder){
	pictures[numAlbums]=new Array();
	captions[numAlbums]=new Array();
	if(folder)
		folderName=folder+"/";
	else
		folderName="";
	numAlbums++;
}

//returns number of the previous image
function prevLinkHtml(content){
	if(!content)
		content="";
	document.writeln("<a href='/dev/two/"+filename[0]+paramString+"album="+album+"&pic="+(picture+pictures[album].length-1)%pictures[album].length+"'>"+content+"</a>");
}

//returns the number of the next image
function nextLinkHtml(content){
	if(!content)
		content="";
	document.writeln("<a href='/dev/two/"+filename[0]+paramString+"album="+album+"&pic="+(picture+1)%pictures[album].length+"'>"+content+"</a>");
}

//prints html code to display current image
function printImageHtml(){
	if(pictures[album][picture])
		document.write("<img src='/dev/two/"+pictures[album][picture]+"' width='328' height='228'>");
	else
		alert("I am sorry.  There is currently a problem with images loading.");
}

//prints the caption
function printCaption(){
	document.write(captions[album][picture]);
}

//used to see if a caption exists
function captionExists(){
	return captions[album][picture];
}

function albumExists(){
	if(album>=numAlbums||album<0)
		alert("I am sorry.  There is currently a problem with images loading.");
}