var chosenPic = 0;
function makeAttr(name, value) 
{
	return ' ' + name + '="' + value + '"';
}

function Pic(src, width, height, bigPic) {
	this.img = new Image(width, height);
	this.img.src = src;
	this.bigPic = bigPic;
	this.write = PicWrite;
}
function PicWrite() 
{
	document.write("<img id='projectImage'",
		makeAttr("src", this.img.src),
		makeAttr("border", 0),
		makeAttr("width", this.img.width),
		makeAttr("height", this.img.height),
		makeAttr("class", pics[chosenPic].bigPic ? "projMorePics" : "projMorePicsChosen"),
		makeAttr("alt", ""),
		makeAttr("onClick", "superSizeMe();"),
		">");
	if (pics.length > 1)
	{
		document.write("<div class='projMoreArrows'>",
		"<img class=\"projMorePics\" src=\"pics/leftArrow.gif\" width=\"9px\" height=\"7px\" alt=\"\" border=\"0\" onMouseOver=\"window.status='previous picture' ;return true\" onMouseOut=\"window.status='' ;return true;\" onClick='setPic(chosenPic-1)'>",
		"&nbsp;&nbsp;&nbsp;&nbsp;")
		for (var i=0; i<pics.length; i++)
		{
			document.write("<span class=\"projMorePics" + (i == chosenPic ? "Chosen" : "") + "\" id='pic_" + i + "' onclick=\"setPic(" + i + "); return true;\">" + (i+1) + "</span>", "&nbsp;&nbsp;");
		}
		document.write("&nbsp;&nbsp;",
			"<img class=\"projMorePics\" src=\"pics/rightArrow.gif\" width=\"9px\" height=\"7px\" alt=\"\" border=\"0\" onMouseOver=\"window.status='next picture' ;return true\" onMouseOut=\"window.status='' ;return true;\" onClick='setPic(chosenPic+1)'>", 
			"</div>");
	}
}
function setPic(picNo)
{
	if (picNo == chosenPic) return;	// nothing to do
	if (picNo >= pics.length) picNo = 0;	// loop round
	if (picNo < 0) picNo = pics.length-1;
	// restore style of currently chosen pic number
	var el = getObject("pic_" + chosenPic);
	if (el)
	{
		el.className = "projMorePics";
	}
	// set style of selected pic number
	el = getObject("pic_" + picNo);
	if (el)
	{
		el.className = "projMorePicsChosen";
	}
	chosenPic = picNo;
	el = getObject("projectImage");
	if (el)
	{
		el.src = pics[chosenPic].img.src;
		el.width = pics[chosenPic].img.width;
		el.height = pics[chosenPic].img.height;
		el.className = pics[chosenPic].bigPic ? "projMorePics" : "projMorePicsChosen";
	}
}
function superSizeMe()
{
	// if not showing big pic, show it; else show normal pic
	if (pics[chosenPic].bigPic)
	{
		el = getObject("projectImage");
		if (el)
		{
			var big = (el.src.indexOf(pics[chosenPic].img.src) >= 0);
			var pic = big ? pics[chosenPic].bigPic : pics[chosenPic];
			//alert("change el.src from " + el.src + " to " + pic.img.src + " with big = " + big);
			el.src = pic.img.src;
			el.width = pic.img.width;
			el.height = pic.img.height;
			el.className = "projMorePics";
			//el = getObject("hideMe")
			//if (el) el.style.display = big ? "none" : "inline";
			changeCss(".right", "visibility", big ? "hidden" : "visible");
			changeCss(".projText", "display", big ? "none" : "block");
			changeCss(".projOther", "display", big ? "none" : "block");
			changeCss(".projMoreArrows", "display", big ? "none" : "block");
//			changeCss(".footerOnWhite", "top", big ? "-400px" : "0px");
//			changeCss(".projBack", "top", big ? "-400px" : "0px");
			changeCss(".projBack", "display", big ? "block" : "none");
		}
	return true;
	}
}
function changeCss(theClass,element,value) 
{
	//documentation for this script at http://www.shawnolson.net/a/503/
	 var cssRules;
	 if (document.all) {
	  cssRules = 'rules';
	 }
	 else if (document.getElementById) {
	  cssRules = 'cssRules';
	 }
	 for (var S = 0; S < document.styleSheets.length; S++){
	  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
	  var selectorText = document.styleSheets[S][cssRules][R].selectorText;
	  if (selectorText.substr(0,1) == "*") selectorText = selectorText.substr(1);
	   if (selectorText.toLowerCase() == theClass.toLowerCase()) {
		//alert("found " + theClass);
	    document.styleSheets[S][cssRules][R].style[element] = value;
	   }
	  }
	 }	
	}
function dumpCss(theClass,element,value) 
{
return;
	//documentation for this script at http://www.shawnolson.net/a/503/
	 var cssRules;
	 if (document.all) {
	  cssRules = 'rules';
	 }
	 else if (document.getElementById) {
	  cssRules = 'cssRules';
	 }
	 for (var S = 0; S < document.styleSheets.length; S++){
		document.write("<br>stylesheet " + S + " length " + document.styleSheets[S][cssRules].length);
	  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
	    document.write("<br>", document.styleSheets[S][cssRules][R].selectorText);
	   }
	  }
	 }	

