// JavaScript Document for Image schmooing

window.onload = function() {
	//make the caption box width to same as the image width
	if(document.getElementById('bigimage')) {
		var image_width = document.getElementById('bigimage').width;
		document.getElementById('caption').style.width = image_width + "px";
		Effect.Appear(document.getElementById('caption'), { duration:0.0001, from:0.0, to:0.7 })
	}
}

var imgObjects = [];
var imgNames = [];
for (var i=0; i<imgNames.length; i++) {
	imgObjects[i] = new Image();
	imgObjects[i].src = imgNames[i];
}

function swapPreview(thumb) {
	var new_thumb_name = thumb.replace("preview", "thumb");
	var new_thumb = document.getElementById(new_thumb_name);
	var img_old = document.getElementById(thumb);
	var old_source = img_old.src;
	var org_big = new_thumb.src;
	var org_big2 = org_big.replace("_thumb", "_preview");
	var re_sized = old_source.replace("_thumb", "_preview");	
	new_thumb = re_sized;
	img_old.src = org_big2;
}

function swapImage(thumb) {
	var img = document.getElementById('bigimage');
	var imgold = document.getElementById(thumb);
	var oldsource = imgold.src;
	var orgbig = img.src;
	var orgbig2 = orgbig.replace("_large", "_thumb");
	var resized = oldsource.replace("_thumb", "_large");	
	img.src = resized;
	imgold.src = orgbig2;
	//make the caption box width to same as the image width
	Effect.Appear(img, { duration:1.5, from:0.0, to:1.0 })
	var image_width = document.getElementById('bigimage').width;
	document.getElementById('caption').style.width = image_width + "px";
	//Effect.Appear(document.getElementById('caption'), { duration:0.0001, from:0.0, to:0.7 })
}

function showhide(e) {
	el = document.getElementById(e);
	el.style.display = el.style.display == "block" ? "none" : "block";
}
