function gE(id) {

	if (typeof(id) != "string") {
		alert('gE did not receive required parameter "id" as a string'); 
		return false;
	}
	
	// get the reference to the object
	if (document.getElementById) {
		return document.getElementById(id);
	} else {
		alert('This browser doesn\'t support document.getElementById'); 
		return false;
	}
}

function gsP(id,prop,newVal) {
	//if the object doesn't exist, abort
	if (!gE(id)) {
		alert('gsP couldn\'t get a reference to ' + id);
		return false;
	}
	if (newVal) {
		eval("gE(id)" + "." + prop + "= newVal");
		return true;
	} else {
		return eval("gE(id)" + "." + prop );
		return true;
	}
}

function tP(id,prop,val1,val2) {
  (gsP(id,prop) == val1) ? gsP(id,prop,val2):gsP(id,prop,val1);
}


//megaPreload("",".gif","portfolio/images",["arrow_yellowsquare"],["off","on"])
function megaPreload (depth,format,imageDir,namesArray,statesArray,showLog) {
	if (document.images) {
		if (showLog) var progressLog = "Mega Preload Status Log:\n------------------------------\n\n";
		for (var state in statesArray) {
			for (var name in namesArray) {
				eval(namesArray[name] + "_" + statesArray[state] +  '= new Image()')
				eval(namesArray[name] + "_" + statesArray[state] + '.src = "' + depth + imageDir + "/" + namesArray[name] + '_' + statesArray[state] + format + '"')
				if (showLog) progressLog += namesArray[name] + "_" + statesArray[state] + " loaded at: " + eval(namesArray[name] + "_" + statesArray[state] + ".src") + "\n"
			}
		}
	}
	if (showLog) alert(progressLog);
}

function swapImage(imageName, imageState) {
	if (document.images) {
		if (document.getElementById) {
			gsP(imageName,'src',eval(imageName + "_" + imageState + ".src"))
		}
	}
}

