// dimensions.js
// Barry Hansen, barry@coilgun.info

function dShow(imgid) {
	if (document.getElementById) { // check for function's existence
		if (arrow = document.getElementById(imgid))
			arrow.style.display = 'inline'; 
		//else
		//	alert('Webmaster: Element ' + imgid + 'was not found');
	}
}

function dHide(imgid) {
	if (document.getElementById) { // check for function's existence
		if (arrow = document.getElementById(imgid)) {
//			alert('Arrow classname is "' + arrow.className + '"');
			if (arrow.className.indexOf(' active')>=0) 
				{ /* nothing - don't hide the active icon */ }
			else 
				{ arrow.style.display = 'none'; }
		}
	}
}

// replace <img id="id1"> with new visual of same size
function dSwap(id1,img_name) {
	//alert('Replacing id=' + id1 + ' with image ' + img_name);
	d = document;
	x1 = d.getElementById(id1);
	x1.src = img_name;
}

// ----- dOver, dOut, dClick -----
// change CSS class for this object
function dOver(spanid) {
	//alert('Set class to ' + newclass);
	if (document.getElementById) { // check function existence
		if (myspan = document.getElementById(spanid)) {
			if (myspan.className == 'navthumb active')
				{ /* do nothing */ }
			else
				{ myspan.className = 'navthumb hover'; }
		}
	}
}

function dOut(myspanid) {
	//alert('Set class to ' + newclass);
	if (document.getElementById) { // check function existence
		if (myspan = document.getElementById(myspanid)) {
			if (myspan.className == 'navthumb active')
				{ /* do nothing */ }
			else
				{ myspan.className = 'navthumb'; }
		}
	}
}

function dClick(myspanid,myimg) {
	// span id MUST be named: v1, v2, v3, ...
	//alert('Set id ' + spanid + ' for image ' + imgname);
	//alert('idlist has ' + idlist.length + ' elements');
	if (document.getElementById) { // check function existence
		for (vnum=1; ; vnum++) { // loop through all <span id="vnum">
			spanid = 'v' + vnum;
			if (myspan = document.getElementById(spanid)) {
				if (myspanid == spanid) {
					myspan.className = 'navthumb active';
				} else {
					myspan.className = 'navthumb';
				}
			} else {
				break; // no more spans were found
			}
		}
		medium = 'medium/' + myimg;
		large  = 'large/' + myimg;
		dSwap('fullsize',medium);
		// link to corresponding largest available image
		if (image_obj = document.getElementById('fullsizelink')) {
			//alert('Changing image object link from (' + image_obj.href + ') to (' + large + ')');
			image_obj.href = large;
		} else {
			alert('Id \'fullsizelink\' not found');
		}
	}
}


/* ----- library functions ----- */
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
