/*
<SCRIPT language="JavaScript" src="/common/scripts/OpenImageWindow.js" type="text/javascript"></SCRIPT>
*/

// Function opens a window for the specified image with user specified height/width
function OpenImageWindow( ImageName, Directory, WindowHeight, WindowWidth, ScrollBars ) 
{ 
	// ImageName     filename without extension
	// Directory     subdirectory containing image, relative off of the root, /foo/bar with no trailing slash
	// WindowHeight  Height of image
	// WindowWidth   width of image
	// ScrollBars    'yes' or 'no' whether or not the window will have scroll bars.        
	//               Scroll bars are useful for tall images.        

    // Pad height +65 and width +20 to allow for window border & a close button
    // change height adjustment due to non ASP code now.
    //WindowHeight += 65;

    WindowHeight += 20;
    WindowWidth  += 20;  
    
    // compensate for scroll bars
    if (ScrollBars == 'yes' ) 
	{
		WindowWidth +=20;
		WindowHeight +=15;
	}    
    // remove the extension from the filename to set the window title
    var TempArray = ImageName.split(".");             
    WindowTitle   = TempArray[0];
		
    // build the url variables & pass to .page

   var OpenedWindow = window.open( '/common/DisplayImage.php?image=' + ImageName + '&subdir=' + Directory + '&title=' + WindowTitle, WindowTitle,  'height=' + WindowHeight + ',width=' + WindowWidth + ',scrollbars=' + ScrollBars + ',toolbar=no,status=no,directories=no,location=no,resizable=yes' );

//   var OpenedWindow = window.open( Directory + "/" + ImageName, WindowTitle, 'height=' + WindowHeight + ',width=' + WindowWidth + ',scrollbars=' + //ScrollBars + ',toolbar=no,status=no,directories=no,location=no,resizable=yes') 
             

    // focus this window (useful if window already open)
    if ( OpenedWindow )
        OpenedWindow.focus();    
}

// Function opens an 800x600 window of an image with a link to the original size image.                  
function OpenResizedImageWindow( ImageName, Directory ) 
{         
	// ImageName    filename (assumes 800x600 is named resized_image.nam)
	// Directory    subdirectory containing image, relative to the root, /foo/bar with no trailing slash        
                 
    // get the filename without the extension to set the window title
    var TempArray   = ImageName.split('.');             
    var WindowTitle = TempArray[0];
    
    // build the url variables & pass to .ASP page 
    var OpenedWindow = window.open( '/common/DisplayResizedImage.php?image=' + ImageName + 
    '&subdir=' + Directory + '&title=' +WindowTitle, WindowTitle,     
    'height=700,width=845,scrollbars=yes,toolbar=no,status=no,directories=no,location=no,resizable=yes' );

    // var OpenedWindow = window.open( Directory + "/" + ImageName, WindowTitle, 'height=768,width=1024,scrollbars=yes,toolbar=no,status=no,directories=no,location=no,resizable=yes' ) 
        
    // focus this window (useful if window already open)
    if ( OpenedWindow )
		OpenedWindow.focus();     
}
