var enlarged = 0;
var currentPhoto;
function Photo(id, src, width, height, widthEnl, heightEnl)
{
	this.id = id;
	if(!document.getElementById(id))
	{
			var imgEl = document.createElement("img");
			imgEl.className = "photo";
			imgEl.id = id; 
			document.body.appendChild(imgEl);
			this.imgEl = imgEl;
	} else
		this.imgEl = document.getElementById(id);
	imgEl.src = src;
	this.ChangeSrc = ChangeSrc;
	this.OnClick = TogglePhotoSize;
	this.TogglePhotoDimensions = TogglePhotoDimensions;
	this.ShadowPhoto = ShadowPhoto;
	this.width = width;
	this.widthEnl = widthEnl;
	this.height = height;
	this.heightEnl = heightEnl;
	this.currentWidth = width;
	this.currentHeight = height;

	if (width){
		newLeft = parseInt(getStyleValue(imgEl,"left").replace(/px/,"")) - width;
	}
	else
		newLeft = parseInt(getStyleValue(imgEl,"left").replace(/px/,"")) - parseInt(imgEl.width);
	this.imgEl.style.left = newLeft+"px";
	currentPhoto = this;
}
function ChangeSrc(imgEl, src)
{
	var leftPx = getStyleValue(imgEl,"left");
	oldLeft = parseInt(leftPx.replace(/px/,"")) + parseInt(this.currentWidth);
	imgEl.style.visibility ="hidden";
	imgEl.src = src;
	this.TogglePhotoDimensions();
	newLeft = oldLeft - this.currentWidth ;
	pausecomp(200);
	imgEl.style.left = newLeft+"px";
	imgEl.style.visibility='visible';
	this.ShadowPhoto();

}

function ShadowPhoto()
{
	var shadowID = this.id+"shadow";
	ShadowEl = document.getElementById(shadowID);
	if (ShadowEl)
		document.body.removeChild(ShadowEl);
	var imageEl = document.getElementById(this.id);
	shadowImgEl1 = document.createElement('img');
	shadowImgEl1.id = this.id+"shadow";
	shadowImgEl1.setAttribute('src','image_shadow.gif');
	shadowImgEl1.setAttribute('width',this.currentWidth);
	shadowImgEl1.setAttribute('height',this.currentHeight);
	shadowImgEl1.className = "shadowImage";
	shadowImgEl1.style.left = GetAbsoluteLeft(imageEl) + 5;
	shadowImgEl1.style.top = GetAbsoluteTop(imageEl) + 5;
	shadowImgEl1.style.zIndex = imageEl.style.zIndex - 1;
	// to  
	document.body.appendChild(shadowImgEl1); 
}


function ShadowImage(id)
{
	var shadowID = id+"shadow";
	ShadowEl = document.getElementById(shadowID);
	if (ShadowEl)
		document.body.removeChild(ShadowEl);
	//alert (id);
	var imageEl = document.getElementById(id);
	shadowImgEl1 = document.createElement('img');
	shadowImgEl1.id = id+"shadow";
	shadowImgEl1.setAttribute('src','image_shadow.gif');
	shadowImgEl1.setAttribute('width',imageEl.width);
	shadowImgEl1.setAttribute('height',imageEl.height);
	shadowImgEl1.className = "shadowImage";
	shadowImgEl1.style.left = GetAbsoluteLeft(imageEl) + 5;
	shadowImgEl1.style.top = GetAbsoluteTop(imageEl) + 5;
	shadowImgEl1.style.zIndex = imageEl.style.zIndex - 1;
	document.body.appendChild(shadowImgEl1); 
}


function TogglePhotoSize()
{ 
    var imageEl = document.getElementById("Photo");
	var srcstring = imageEl.src;
	var tmp = document.getElementById("commEnlph").innerHTML;
	enlarged = 1 - enlarged;
	//currentPhoto.TogglePhotoDimensions();
	if (!enlarged){
		
		currentPhoto.ChangeSrc(imageEl, srcstring.replace(/\/hires/,""));
		document.getElementById("commEnlph").innerHTML = commEnlphString;
		}
		else {
		currentPhoto.ChangeSrc(imageEl, srcstring.replace(/(\w+\.\w+$)/,"hires/$1"));
		document.getElementById("commEnlph").innerHTML = commEnlphString;
		}
	commEnlphString = tmp;
}

function TogglePhotoDimensions()
{
	if (!enlarged){
		this.currentWidth = this.width;
		this.currentHeight = this.height;
	} else {
		this.currentWidth = this.widthEnl;
		this.currentHeight = this.heightEnl;
	}
 }<!-- 
 --><!-- 
 -->
