/***********************************************
/*RMS image viewer library.  Portions based on
/* Dynamic Drive DHTML code library (www.dynamicdrive.com)
/* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
/***********************************************/

function returnimgcode(theimg)
{	
	var imghtml="";	
	imghtml += '<img src="' + theimg[0] + '" width="' + imgWidth + '" height="' + imgHeight + '" border="' + imgborderwidth +'">';
	// New code for image description
	imghtml += '<div id="imageDesc">' + theimg[1] + '</div>';	
	return imghtml;
}

//
// This function is for images in a single page
//
function modifyImage(loadarea, direction)
{
		if (document.getElementById)
		{
			// Code to check for recycling of image
			if(direction=='n')
			{
				imgIndex++;
				if(imgIndex > (dynimages.length - 1))
					imgIndex = 0;
			}
			else if(direction=='p')
			{
				imgIndex--;
				if(imgIndex < 0)
					imgIndex = dynimages.length - 1;
			}
			else
			imgIndex = direction;							
			//		
			var imgobj=document.getElementById(loadarea);
			if (imgobj.filters && window.createPopup)
			{
				imgobj.style.filter=filterstring;
				imgobj.filters[0].Apply();
			}
			imgobj.innerHTML = returnimgcode(dynimages[imgIndex]);
			if (imgobj.filters && window.createPopup)
				imgobj.filters[0].Play();
				
			return false;
		}
}
//
// This function is for images that are in a different frame.  Eventually, this should be merged with modifyimage
//
function modifyParentImage(loadarea, direction)
{
	if (document.getElementById)
		{
			// Code to check for recycling of image
			if(direction=='n')
			{
				imgIndex++;
				if(imgIndex > (dynimages.length - 1))
					imgIndex = 0;
			}
			else if(direction=='p')
			{
				imgIndex--;
				if(imgIndex < 0)
					imgIndex = dynimages.length - 1;
			}
			else
				imgIndex = direction;					
			//		
			var imgobj=window.parent.document.getElementById(loadarea);			
			imgobj.innerHTML = returnimgcode(dynimages[imgIndex]);				
			return false;
		}
}

//
// unitInfoLoad is designed to be executed by the unit information page to initialize the mapping of the unit
//
function unitInfoLoad()
{	
	if (GBrowserIsCompatible()) 
	{        
        var map = new GMap2(document.getElementById("map"));        
   		map.addControl(new GMapTypeControl());
		map.addControl(new GSmallMapControl());        
        map.setCenter(point, 15);
		var marker = new GMarker(point);
		map.addOverlay(marker);
		marker.openInfoWindowHtml(UNIT_HTML);
    }
    
    return modifyImage('imageArea',0);
}


