//Set optional link target to be added to all images with a link:
var optlinktarget="_blank"

//Set image border width
var imgborderwidth=0

//Optionally, change 1.0 and 0.7 below to affect Wipe gradient size and duration in seconds in IE5.5+:
var filterstring="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=0.7)"

function enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
var actualWidth=typeof optWidth!="undefined" ? optWidth : "600px" //set 600px to default width
var actualHeight=typeof optHeight!="undefined" ? optHeight : "500px" //set 500px to  default height
var winattributes="width="+actualWidth+",height="+actualHeight+",resizable=yes"
window.open(path,"", winattributes);
}

function returnimgcode(theimg){
var imghtml="";
var myimage=new Image();
myimage.src=theimg;
var gradreduce = 15.5;
var imgwidth = (myimage.width*gradreduce/100);
var imgheight = (myimage.height*gradreduce/100);
if(imgheight>302){
	gradreduce = (302*100/myimage.height);
}
if(imgwidth>402){
	gradreduce = (402*100/myimage.width);
}
if(gradreduce == 15.5){
	imgwidth = "401.76";
	imgheight = "301.32";
}else{
	imgwidth = (myimage.width*gradreduce/100);
	imgheight = (myimage.height*gradreduce/100);
}
	if (theimg!="")
		imghtml='<a href="javascript:enlargeimage('+String.fromCharCode(39)+theimg+String.fromCharCode(39)+')">'
		imghtml+='<img src="'+theimg+'" border="'+imgborderwidth+'" width="'+imgwidth+'" height="'+imgheight+'" style="border: 1px solid #cccccc">'
		if (theimg!="")
			imghtml+='</a>'
		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(imgindex)
		if (imgobj.filters && window.createPopup){
			imgobj.filters[0].Play()
			return false
		}
	}
}
