// JavaScript Document
resize = new Object();
var resizesm = 1;
var resizeMultiplier = resizeM = 1.5;
var resizeimageHorg, resizeimageWorg;
//good fun this is.   the resize function recieves event data from the html. If no maxH,hieght value is given is simply uses the resizeM (mlitiplier).  Else it uses the max value with some algebra. 
resize.resizemouseroll =function(image,maxH){
	resize.hideOtherImage(image);
	image.style.cursor = "hand";
	if(!maxH)maxH=0;
	imageH = image.clientHeight;
	imageW = image.clientWidth;
		if(imageH*resizeM <= maxH || maxH=='0'){
			resizeimageHorg=imageH;
			resizeimageWorg=imageW;
			image.setAttribute('height',imageH * resizeM);
			image.setAttribute('width',imageW * resizeM);

		}
		else{
			resizeimageHorg=imageH;
			resizeimageWorg=imageW;
			imgRatio=imageH/imageW;
			image.setAttribute('height',maxH);	
			image.setAttribute('width',maxH*imageW/imageH);
		}
}
//resets the size of the image
resize.resizemouserollout = function(image,maxH){
		image.style.cursor ="default";
		resize.revealOtherImage(image);
		image.setAttribute('height',resizeimageHorg);
		image.setAttribute('width',resizeimageWorg);
}
// checks which imageby navigating and checking the DOM relations.  hides other image and reduces width to 0 for spacing.
resize.hideOtherImage=function(image){
	if(tdSpacer = image.parentNode.previousSibling){
		tdSpacer.previousSibling.firstChild.nextSibling.style.visibility ="hidden";
		tdSpacer.style.width="50px";
		tdSpacer.previousSibling.firstChild.nextSibling.style.width ="0";
		image.maxWidth="1000";
	} 
	else{
		image.parentNode.nextSibling.nextSibling.firstChild.nextSibling.style.visibility ="hidden";
		image.parentNode.nextSibling.style.width="50px";
		image.parentNode.nextSibling.nextSibling.firstChild.nextSibling.style.width ="0";
		image.maxWidth="1000";
	}
}
//reveals the width and breaks the width fixed value data.
resize.revealOtherImage=function(image){
	if(tdSpacer = image.parentNode.previousSibling){
		//alert(tdSpacer.previousSibling.firstChild.nextSibling);
		tdSpacer.previousSibling.firstChild.nextSibling.style.visibility="visible";
		tdSpacer.previousSibling.firstChild.nextSibling.style.maxWidth="450";
		tdSpacer.previousSibling.firstChild.nextSibling.style.width="auto";
		tdSpacer.style.width="50px";
		//alert(tdSpacer.style.width);
	}
	else{
		image.parentNode.nextSibling.nextSibling.firstChild.nextSibling.style.visibility="visible";
		image.parentNode.nextSibling.nextSibling.firstChild.nextSibling.style.maxWidth="450";
		image.parentNode.nextSibling.nextSibling.firstChild.nextSibling.style.width="auto";
		image.parentNode.nextSibling.style.width="50px";
		//alert(image.parentNode.nextSibling.style.width);
//image.parentNode.nextSibling.nextSibling.firstChild.nextSibling.setAttribute('src',resizeSrcVal);
	}
}
resize.cursor=function(image,mouseEvent){
	image.style.cursor='hand';
	alert(image.style.cursor);
}

resize.resizeonclick =function(image,maxH){
	resize.hideOtherImage(image);
	image.style.cursor = "hand";
	if(resizesm==1){
			if(!maxH)maxH=0;
		imageH = image.clientHeight;
		imageW = image.clientWidth;
			if(imageH*resizeM <= maxH || maxH=='0'){
				resizeimageHorg=imageH;
				resizeimageWorg=imageW;
				image.setAttribute('height',imageH * resizeM);
				image.setAttribute('width',imageW * resizeM);
	
			}
			else{
				resizeimageHorg=imageH;
				resizeimageWorg=imageW;
				imgRatio=imageH/imageW;
				image.setAttribute('height',maxH);	
				image.setAttribute('width',maxH*imageW/imageH);
			}
		resizesm*=-1;
	}
	else if(resizesm==-1){
		//resets the size of the image
		image.style.cursor ="default";
		resize.revealOtherImage(image);
		image.setAttribute('height',resizeimageHorg);
		image.setAttribute('width',resizeimageWorg);
		resizesm*=-1;
	}
}

