/**
 *	JavaScript to handle rollover images and preloading by the Concept Shed theme.
 *	The file functions.php defines a function that creates a gallery with rollover 
 *  images.  This file is added to the WP header and any images with a rollover
 *  element are added to an array which is preloaded..
*/


var toLoad;

function rollover(element, src) {
	if(!document.getElementById) {
		return;
	}
	var im = document.getElementById(element);
	if(!im) {
		return;
	}
	document.oldImage = new Array;
	
	document.oldImage[0] = im;
	if(!im.orig) {
		im.orig = im.src;
	}
	im.src = src;
}

function rollout() {
	var im = document.oldImage[0];
	im.src = im.orig;
}

function preload() {
	positionSketches();
	if(!toLoad || 0 == toLoad.length) {
		return;
	}
	if(!document.images) {
		document.images = new Array;
	}
	var i;
	var j = document.images.length;
	var args = preload.arguments;
	var len = args.len;
	
	for(i = 0; i < len;i++) {
		if(0 != args[i].indexOf("#")) {
			document.images[j] = new Image();
			document.images[j].src = args[i];
			
		}
	}
}

function positionSketches() {
	if (document.getElementById) {
		var pg = document.getElementById("page");
		var windowHeight = pg.clientHeight;
		//alert("window height " + windowHeight);
		if (windowHeight > 0) {
			var elec = document.getElementById('electronicssketch');
			if(elec) {
				elec.style.top = (windowHeight - elec.clientHeight - 3) + "px";
			}
			var pump = document.getElementById('pumpbottomsketch');
			if(pump) {
				pump.style.top = (windowHeight - pump.clientHeight - 3) + "px";
			}
			var diag = document.getElementById('diagsketch');
			if(diag) {
				diag.style.top = (windowHeight - diag.clientHeight - 2) + "px";
			}
		}
	}
}