/**
 * Kommentar: 
 * 
 * @headurl				$HeadURL: svn://dsrv.eeb.de/IxeaCMS/trunk/app/webroot/js/showimage.js $
 * @author				$Author: mtr $
 * @version				$Revision: 307 $
 * @date				$Date: 2007-08-30 15:28:12 +0200 (Do, 30 Aug 2007) $
 * @id					$Id: showimage.js 307 2007-08-30 13:28:12Z mtr $
 *
 * @copyright			Copyright (c) 2007, EEB GmbH www.eeb.de
 * 											Gutenbergstra?e 7
 * 											70794 Filderstadt
 */

var actimagePos = null;
var actimageId = null;

function showMainImage( imgId, rootpath, filename, alttext, isPrintimage, height, width, imgClass ,showPrintIcon, showAltText, showLightview )
{
	//F?r Lightview-Ansicht
	if( document.getElementById( filename ) )
		{
		document.getElementById( filename ).rel = 'nogallery';
		lastFilename = document.getElementById( 'LightviewLastimage' ).value;
		if( lastFilename != '' )
		{
			document.getElementById( lastFilename ).rel = 'gallery[imagegallery]';
		}
		document.getElementById( 'LightviewLastimage' ).value = filename;
	}
	
	if( showPrintIcon == true)
	{
		if( showLightview == 'false' )
		{
			imgString =  '<a href="#" onclick="javascript:openPopup( \'/popups/show/' + imgId +'\',' + height + ', ' + width + '); return false">' + '<img src="/'+ rootpath + filename + '" class="'+ imgClass +'" alt="'+ alttext +'">';
		}
		else
		{
			imgString = '<a href="/' + rootpath + 'printimages/' + filename + '" class="lightview" rel="gallery[imagegallery]">' + '<img src="/'+ rootpath + filename + '" class="'+ imgClass +'" alt="'+ alttext +'">';
		}
		
		if( imgClass != 'galleryimage' )
		{
			imgString += '<br><img class="print_icon" src="/img/icons/printicon.gif' + '" alt="'+ alttext +'">';
		}
		imgString += '</a>';		
	}
	
	if( showPrintIcon == false)
	{
		imgString = '<img class="'+ imgClass +'" src="/'+ rootpath + filename + '" alt="'+ alttext +'"><br>';	
	}
	
	if( showAltText == true )
	{
		imgString += alttext;
	}
	
	imgString += '<input type="hidden" id="actSelectedImageID" value="' + imgId + '>';
	
	document.getElementById('image').innerHTML = imgString;
}


function openPopup( path, height, width )
{
	popup = window.open( path, 'PopupBild', 'resizable=yes, scrollbars=yes, left=100, top=200, width=' + width + ',height=' + height );
  	popup.focus();
}

function browseMainImage( rootpath, imgPos )
{
	if( actimagePos == null )
	{
		actimagePos = parseInt(1);
	}
	
	imgString = '<img class="articleimage" src="/'+ rootpath + Images[imgPos] + '" alt=""><br>';	
	document.getElementById('image').innerHTML = imgString;
	
	document.getElementById( 'browseLink' + actimagePos ).className = 'browseImageLink';	
	document.getElementById( 'browseLink' + imgPos ).className = 'browseImageLink_selected';
	
	
	actimagePos = parseInt(imgPos);
}

function browseNextMainImg( rootpath )
{
	
	if( actimagePos == null )
	{
		actimagePos = parseInt(1);
	}
	oldimagepos = actimagePos;
	
	if(  actimagePos + parseInt(1) < Images.length ) 
	{
		actimagePos = parseInt(actimagePos) + parseInt(1);
	
		imgString = '<img class="articleimage" src="/'+ rootpath + Images[actimagePos] + '" alt=""><br>';
		
		document.getElementById('image').innerHTML = imgString;
		
		
		document.getElementById( 'browseLink' + oldimagepos ).className = 'browseImageLink';	
		document.getElementById( 'browseLink' + actimagePos ).className = 'browseImageLink_selected';
	}
}


function browsePrevMainImg( rootpath )
{
	if( actimagePos == null )
	{
		actimagePos = parseInt(1);
	}
	oldimagepos = actimagePos;
	
	if(  actimagePos  > parseInt(1)) 
	{
		actimagePos = parseInt(actimagePos) - parseInt(1);
	
		imgString = '<img class="articleimage" src="/'+ rootpath + Images[actimagePos] + '" alt=""><br>';
		
		document.getElementById('image').innerHTML = imgString;
		
		document.getElementById( 'browseLink' + oldimagepos ).className = 'browseImageLink';	
		document.getElementById( 'browseLink' + actimagePos ).className = 'browseImageLink_selected';
	}
}
