function toggleLongDesc() {
	var b = document.getElementById('long_desc');
	if(b.style.display != "none") {
		b.style.display = "none";
	} else {
		b.style.display = "block";
	}
}
if(document.getElementById("js_highlight") != null) {//if pulling a random highlight banner..
	var hpics = document.getElementById("js_highlight").getElementsByTagName("p");
	var m = Math.floor(Math.random()*hpics.length);
	if(hpics[m].innerHTML != "") {
		document.getElementById("dleft_image_caption").innerHTML = '<a href="'+hpics[m].getAttribute("url")+'">'+hpics[m].innerHTML+'</a>';
	} else {
		document.getElementById("dleft_image_caption").style.display = "none";
	}
	if(hpics[m].getAttribute("url") == "") { //if no external link for highlight photo
		document.getElementById("dleft_image").innerHTML = '<img src="'+hpics[m].getAttribute("path")+'">';
	} else { //there is an external link
		document.getElementById("dleft_image").innerHTML = '<a href="'+hpics[m].getAttribute("url")+'"><img src="'+hpics[m].getAttribute("path")+'"></a>';
	}
}

if(document.getElementById("js_mainimages") != null) {// if pulling a random small banner..
	var b = document.getElementById('js_mainimages').getElementsByTagName('p');
	var r = Math.floor(Math.random()*b.length);
	var a = document.getElementById('dmain_image_caption');
	var c = document.getElementById('js_mainimages').getElementsByTagName('i');
	if(c[r].getAttribute("photourl")!="" && c[r].innerHTML=="") { // if external link and no long description
		var d = ' <a href="'+c[r].getAttribute("photourl")+'"> ... more</a>';
	} else if(c[r].innerHTML!="") { // if long description
		var d = ' <a style="cursor:pointer;" onClick="toggleLongDesc()"> ... more</a>';
	} else {
		var d = '';
	}
	if(b[r].innerHTML == "") { //if there is no caption for the photo, hide the caption div
		a.style.display = "none";
	} else { //there is a caption for the photo
		a.innerHTML = b[r].innerHTML+d; //append the "...more" link at the end of the caption
		var g = document.createElement("div");
		g.setAttribute("id","long_desc");
		a.appendChild(g);
		if(c[r].getAttribute("photourl")!="") {
			g.style.paddingBottom = "20px";
			g.innerHTML = c[r].innerHTML+'<a style="float:right; display:block; margin:5px;" href="'+c[r].getAttribute("photourl")+'">'+c[r].getAttribute("linktext")+'</a>';
		} else {
			g.innerHTML = c[r].innerHTML;
		}
		g.style.display = "none";
		a.style.display = "block";
	}
	document.getElementById("dmain_image").innerHTML = '<img src="'+b[r].getAttribute("path")+'">';
}