function showDiv(title,whichdiv,what,zoom){
createNewImage(whichdiv,what)
document.stuff.imgheight.value = myImage.height
document.stuff.imgwidth.value = myImage.width
document.stuff.whichdiv.value = whichdiv
document.stuff.what.value = what
document.stuff.title.value = title
document.stuff.zoom.value = zoom
stuffImage()
}

function createNewImage(what,whichdiv){
myImage = new Image() 
myImage.src = "images/" + what + "/" + whichdiv + ".gif"
return myImage;
}

function redrawScreen(){
document.body.style.overflow = "hidden" //use document.documentElement if your DTD is strict
THIS_DIV_WRAPPER = document.getElementById("container")
THIS_DIV_WRAPPER.style.height = Math.abs(parseInt(document.body.clientHeight)) - HEIGHT_MODIFICATION_MAIN + "px" // use document.documentElement if your DTD is strict. subtract the container margin
THIS_DIV_WRAPPER.style.width = Math.abs(parseInt(document.body.clientWidth)) - WIDTH_MODIFICATION_MAIN  + "px" // subtract the container margin
	if(parseInt(document.getElementById("container").style.width,10) == document.getElementById("container").scrollWidth){
	document.getElementById("container").style.overflowX = "hidden"
	}else{
	document.getElementById("container").style.overflowX = "auto"
	}
	try{
	stuffImage() // stuff first so html height and widths will be rendered
	}catch(e){}		
	if(document.getElementById("divimages")){
		document.getElementById("divimages").style.height = (parseInt(document.body.clientHeight) - HEIGHT_MODIFICATION_GALLERY) + "px"
		document.getElementById("picturedetail").style.height = (parseInt(document.body.clientHeight) - HEIGHT_MODIFICATION_GALLERY) + "px"	
		document.getElementById("container").style.overflowY = "hidden"				
		// for viewing slider and making border dotted
		if(parseInt(document.getElementById("divimages").scrollHeight) <= document.getElementById("container").clientHeight){
		document.getElementById("divimages").style.borderRight = "1px dashed #666666"
		document.getElementById("divimages").style.width = (parseInt(SCROLL_DIV_WIDTH) - SCROLLING_DIV_OFFSET) + "px"
		}else{
		document.getElementById("divimages").style.borderRight = "0px"
		document.getElementById("divimages").style.width = SCROLL_DIV_WIDTH
		}
	}
	try{
		if(document.getElementById("guestbook")){
		document.getElementById("guestbook").style.height = (parseInt(THIS_DIV_WRAPPER.style.height) - HEIGHT_MODIFICATION_GUESTBOOK) + "px"
		document.getElementById("guestbook").style.width = (parseInt(THIS_DIV_WRAPPER.style.width) - WIDTH_MODIFICATION_GUESTBOOK) + "px"
		document.getElementById("container").style.overflow = "hidden"	
		}
	}catch(e){}	
window.onresize = redrawScreen;
}
//document.stuff.zoom.value == "true" ||  THIS_ZOOM == "true" 
function stuffImage(){
	if(document.stuff.what.value == ""){ // then page just loaded.
		// either the page just loaded without a request, or it did with a particular outside link.
		if(THIS_REQUESTED_IMAGE == ""){ // THIS_REQUESTED_IMAGE is the request to view an image from a link outside the gallery.
		document.getElementById("picturedetail").innerHTML = returnMainInnerHTML(THIS_FIRST_TITLE,THIS_FIRST_DIV,THIS_FIRST_IMAGE,THIS_FIRST_ZOOM)
		}else{
		document.getElementById("picturedetail").innerHTML = returnMainInnerHTML(THIS_REQUESTED_TITLE,THIS_PAGE,THIS_REQUESTED_IMAGE,THIS_REQUESTED_ZOOM)
		}	
	}else{
	document.getElementById("picturedetail").innerHTML = returnMainInnerHTML(document.stuff.title.value,document.stuff.what.value,document.stuff.whichdiv.value,document.stuff.zoom.value)
	}
}

function showProgressSnapshot(thisNode){
	// get to work in fireFOX
	switch(thisNode.parentNode.clickcount % 2){
	case 0:
	thisNode.src=thisNode.offsrc
	break;
	case 1:
	thisNode.src=thisNode.onsrc
	break;
	}
thisNode.parentNode.clickcount++
}

function returnMainInnerHTML(thisTitle,thisDiv,thisMainImage,thisZoom){
var newInnerHTML = "<center>"
newInnerHTML += "<font class='grayfontbold15'>" 
newInnerHTML += unescape(stripPluses(thisTitle)) 
newInnerHTML += "</font>"
newInnerHTML += (thisZoom == "true") ? zoomDiv() : "" ;
newInnerHTML += "</center>" 
newInnerHTML += SPACER_5 
newInnerHTML += "<br>"
newInnerHTML += "<center>"
newInnerHTML += "<img class='imageDetail' src='images/" + thisDiv + "/" + thisMainImage + ".gif' width:auto; border: solid thick rgb(102,51,0);'></center>"
newInnerHTML += eval("document.getElementById('" + unescape(stripPluses(thisMainImage)) + "').innerHTML")
return newInnerHTML;
}

function zoomDiv(){
//alert(thisMainImage)
var zoomdiv = "<div style='white-space:nowrap;font-size:10px;color:#666666;font-family:verdana;'>"
zoomdiv += "<img src='images/zoom.gif' align='absmiddle'>Snapshots of the drawing in progress are available below."
zoomdiv += "</div>"
return zoomdiv;
}



function stripPluses(s){    /* DO NOT TRY-CATCH 'RETURN' FUNCTIONS (locator string: RETURN_FUNCTION) */
var t="" 
for(var i=0;i<s.length;++i){ 
  ch= s.charAt(i) 
	 if(ch=='+'){
	ch=" "
	} 
	t += ch 
}
return t 
}
