/*variables required by this Javascript can be set in head section
var preloadimg="yes"
var optlinktarget="" //target for thumbnails
var href_target="" //target for main image
var mouseaction="click" ||"over"
var thumbborderwidth=0
var imgborderwidth=0
var filterstring="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=0)"
var dimension="1x3" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
var totalslots=dimension.split("x")[0]*dimension.split("x")[1]


Specify images:
galleryarray[x]=["path_to_thumbnail", "path_to_image", "optional_title_attribute", "optional_text_description", "optional_link"]
var galleryarray=new Array()


if (preloadimg=="yes"){
	for (x=0; x<galleryarray.length; x++){
		var myimage=new Image()
		myimage.src=galleryarray[x][1]
	}
}
*/
function returnimgcode(theimg){
	var imghtml=""
	if (theimg[4]!="") {
		imghtml='<a href="'+theimg[4]+'" target="'+optlinktarget+'">'
	}
	imghtml+='<img src="'+theimg[1]+'" alt="'+theimg[2]+'" title="'+theimg[2]+'" border="'+imgborderwidth+'"><br />'
	if (theimg[4]!="") {
		imghtml+='</a>'
	}
	imghtml+='<div><h1><b>'+theimg[2]+'</b></h1>'+theimg[3]+'</div>'
	return imghtml
}

function modifyimage(loadarea, imgindex){
	if (document.getElementById){
		var imgobj=document.getElementById(loadarea)
		//if (imgobj.filters && window.createPopup){
			//imgobj.style.filter=filterstring
			//imgobj.filters[0].Apply()
		//}
		imgobj.innerHTML=returnimgcode(galleryarray[imgindex])
		//if (imgobj.filters && window.createPopup)
			//imgobj.filters[0].Play()
			return false
	}
}


function buildimage(i){
var tempcontainer=galleryarray[i][4]!=""? '<a href="'+galleryarray[i][4]+'" target="'+href_target+'">' : ""
tempcontainer+='<img src="'+galleryarray[i][0]+'" border="'+thumbborderwidth+'" alt="'+galleryarray[i][2]+'" title="'+galleryarray[i][2]+'" '+mouseaction+'="modifyimage(\'dynloadarea\', '+i+')"/>'
tempcontainer=galleryarray[i][4]!=""? tempcontainer+'</a>' : tempcontainer
//tempcontainer=galleryarray[i][2]!=""? tempcontainer+'<br \/>'+galleryarray[i][2] : tempcontainer
return tempcontainer
}

function jumptopage(p){
	var startpoint=(p-1)*totalslots
	var y=1;
	for (i=0; i<totalslots; i++){
		document.getElementById("slide"+i).innerHTML=(typeof galleryarray[startpoint+i]!="undefined")? buildimage(startpoint+i) : ""
	}
	while(document.getElementById("navlink"+y)!=null){
		document.getElementById("navlink"+y).className=""
		y++
	}
	document.getElementById("navlink"+p).className="current"
}
