// JavaScript Document
// written by Paul, Dec 29, 2007
// purpose: mouseover/mouseout set of functions to scale up and reset an imge inside
// a layer tag.
//
// functions take five arguments: layerID,imageID,posAnchor,posAlign, and scale
// layerID,imageID, and scale are self evident
// posAnchor defines 't' for top or 'b' for bottom corner anchor
// posAlign, defines 'l' (left, or 'r', right for flush left of right positioning 
						  
// usage, each image to rescale shold be inside a <div> element one per <div>
//insert anchor element below
// <a href="javascript:void('');" onmouseover="grow('dinnerImage4','dinner4','b','r','1.5');" onmouseout="resetSize('dinnerImage4','dinner4','b','r','1.5');"> </a> 
// around image element inside <div>
// change the argument names to match the div and image IDs and change the anchor and scale arguments as needed.

function grow(layerID,imageID,posAnchor,posAlign,scale)
	{
		var layer = document.getElementById(layerID);
		var image = document.getElementById(imageID);
		var i_width = image.width;
		var layerTop = layer.offsetTop;
		var layerLeft = layer.offsetLeft;
		var i_height = image.height;

		switch(posAnchor){
			case 't':		//if object is anchored at the top of the page ...
				switch(posAlign) {
				case 'l':
					image.width = Math.round(i_width * scale);
					image.height = Math.round(i_height * scale);
				break;
				case 'r':
					image.width = Math.round(i_width * scale);
					image.height = Math.round(i_height * scale);
					layer.style.left = layer.offsetLeft - (image.width - i_width) +'px';
					layer.style.zIndex = 1000;
					
				break;
				}
			break;			// stop here
			case 'm':		//if object is anchored at the middle of the page ...
				switch(posAlign) {
				case 'l':
					image.width = Math.round(i_width * scale);
					image.height = Math.round(i_height * scale);
				break;
				case 'r':
					image.width = Math.round(i_width * scale);
					image.height = Math.round(i_height * scale);
					layer.style.left = layer.offsetLeft - (image.width - i_width) +'px';
					layer.style.top =  layer.offsetTop - Math.round(i_height/8) +'px';
					layer.style.zIndex = 1000;
					
				break;
				}
			break;			// stop here

			case 'b':		//if object is anchored at the bottom of the page ...
				switch(posAlign) {
				case 'l':
					image.width = Math.round(i_width * scale);
					image.height = Math.round(i_height * scale);
					layer.style.top =  layer.offsetTop - (image.height - i_height) +'px';
					layer.style.zIndex = 1000;
				break;
				case 'r':
					image.width = Math.round(i_width * scale);
					image.height = Math.round(i_height * scale);
					layer.style.left = layer.offsetLeft - (image.width - i_width) +'px';
					layer.style.top =  layer.offsetTop - (image.height - i_height) +'px'; 
					layer.style.zIndex = 1000;
					
				break;
				}
			
			default: 	//if all else fails...
					image.width = Math.round(i_width * scale);
					image.height = Math.round(i_height * scale);
				
			break;		// stop here
		}
	}
	
function resetSize(layerID,imageID,posAnchor,posAlign,scale)
	{
		var layer = document.getElementById(layerID);
		var image = document.getElementById(imageID);
		var i_width = image.width;
		var layerTop = layer.offsetTop;
		var layerLeft = layer.offsetLeft;
		var i_height = image.height;

		switch(posAnchor){
			case 't':		//if object is anchored at the top of the page ...
				switch(posAlign) {
				case 'l':
					image.width = Math.round(i_width / scale);
					image.height = Math.round(i_height / scale);
					layer.style.zIndex = 500;
				break;
				case 'r':					
					image.width = Math.round(i_width / scale);
					image.height = Math.round(i_height / scale);
					layer.style.left = layer.offsetLeft + (i_width - image.width)  +'px';
					layer.style.zIndex = 500;					
				break;
				}
			break;			// stop here
			
			case 'm':		//if object is anchored at the middle of the page ...
				switch(posAlign) {
				case 'l':
					image.width = Math.round(i_width / scale);
					image.height = Math.round(i_height / scale);
					layer.style.zIndex = 500;
				break;
				case 'r':
					image.width = Math.round(i_width / scale);
					image.height = Math.round(i_height / scale);				
					layer.style.left = layer.offsetLeft + (i_width - image.width) +'px';
					layer.style.top =  layer.offsetTop + Math.round(i_height/8) +'px';
					layer.style.zIndex = 500;	
				break;
				}
			break;			// stop here 

			case 'b':		//if object is anchored at the bottom of the page ...
				switch(posAlign) {
				case 'l':
					image.width = Math.round(i_width / scale);
					image.height = Math.round(i_height / scale);
					layer.style.zIndex = 500;
				break;
				case 'r':
					image.width = Math.round(i_width / scale);
					image.height = Math.round(i_height / scale);
					layer.style.left = layer.offsetLeft + (i_width - image.width)  +'px';
					layer.style.top =  layer.offsetTop + (i_height - image.height) +'px'; 
					layer.style.zIndex = 500;
				break;		// stop here
			break;
				}
			break;		// stop here
			default: 	//if all else fails...
					image.width = Math.round(i_width / scale);
					image.height = Math.round(i_height / scale);
					layer.style.zIndex = 500;
			break;
		}
	}
	