function pokaz( id, stan ) {
	document.getElementById(id).style.display = stan;
}
function print() {
	var link = document.location.href;
	link = link.indexOf('#') ? link.substr( 0, link.indexOf('#') ) : link;
	window.open( link+( link.indexOf('?')?'&':'?' )+'print=1','print','scrollbars=yes,status=no,width=600,height=600');
}
function okno(adres,szer,wys) {
  NoweOkno=window.open(adres,'Okno','toolbar=no,scrollbars=yes,resizable=yes,status=yes,location=no,directories=no,width='+eval(szer)+',height='+eval(wys)+',menubar=no');
}
function changePicture( newSrc, newDesc, linkObj ) {

	var prevClick = false;
	var nextClick = false;

	// picture update
	$('bigImage').src = newSrc;
	$('bigImage').next(0).update( newDesc );
	
	// pictures list update
	var linkParent = $( linkObj ).parentNode;
	if( $( linkParent ).readAttribute('class') == 'galleryShow' ) {
		// prev/next link was clicked
		linkObj = $('bigImage').next(3).down('.active');
		if( ( $( linkObj ).next('a') ) && ( $( linkObj ).next('a').readAttribute('onclick').indexOf(newSrc) ) > 0 ) {
			linkObj = $( linkObj ).next('a');
		}
		else {
			linkObj = $( linkObj ).previous('a');
		}
	}
	$('bigImage').next(3).childElements().each( function(el) { el.removeClassName('active'); } );
	if( linkObj ) {
		$( linkObj ).addClassName('active');
		if( $( linkObj ).previous('a') ) {
			prevClick = $( linkObj ).previous('a').readAttribute('onclick');
		}
		if( $( linkObj ).next('a') ) {
			nextClick = $( linkObj ).next('a').readAttribute('onclick');
		}
	}
	
	// links update
	if( prevClick ) {
		if( Prototype.Browser.IE ) {
			$('bigImage').next(1).replace('<a href="#" onclick="'+prevClick+'"><img src="html/img/btn_prev.gif"></a>');
		}
		else {
			$('bigImage').next(1).writeAttribute( 'onclick', prevClick );
		}
		$('bigImage').next(1).show();
	}
	else {
		$('bigImage').next(1).hide();
	}
	if( nextClick ) {
		if( Prototype.Browser.IE ) {
		$('bigImage').next(2).replace('<a href="#" onclick="'+nextClick+'"><img src="html/img/btn_next.gif"></a>');
		}
		else {
			$('bigImage').next(2).writeAttribute( 'onclick', nextClick );
		}
		$('bigImage').next(2).show();
	}
	else {
		$('bigImage').next(2).hide();
	}
}
function zoomPicture( pictureSrc ) {
	var bodyObj = $$('body')[0];
		bodyObj.insert( 
					new Element( 'div', { id: 'zoomBG' } )
				);
		bodyObj.insert( 
					new Element( 'div', { id: 'zoomFG' } )
						.insert( new Element( 'div', { id: 'zoomContent', onclick: 'closeZoomPicture();' } )
							.insert( new Element( 'div', { id: 'zoomClose' } )
							// unfortunetly IE doesn't handle onclick event created that way
							//	.insert( new Element( 'a', { href: '#', onclick: 'closeZoomPicture();' } ).update('X') )
								.insert( '<a href="#" onclick="closeZoomPicture();">X</a>' )
								)
							.insert( new Element( 'div', { id: 'zoomImage' } )
								.insert( new Element( 'img', { src: pictureSrc } ).hide() )
//								.insert( '<img src="'+pictureSrc+'"/>' )
								)
					).hide()
				);

	var pageWidth = ( bodyObj.getWidth() > document.viewport.getWidth() ) ? bodyObj.getWidth() : document.viewport.getWidth();
	var pageHeight= ( bodyObj.getHeight()> document.viewport.getHeight()) ? bodyObj.getHeight(): document.viewport.getHeight();
    $('zoomBG').setOpacity(0.6).setStyle( {width: pageWidth+'px', height: pageHeight+'px' } );

	var image = new Image();
	image.onload = (function(){ $('zoomFG').show(); setTimeout( $('zoomImage').down('img').show(), 5 ) } );
	image.src = $('zoomImage').down('img').src;

	var boxTop = ( bodyObj.getHeight() - image.height ) / 2;
	var boxLeft = ( bodyObj.getWidth() - image.width ) / 2;
	var boxWidth = image.width + 20;
	var boxHeight = image.height + 35;
	$('zoomFG').setStyle( { top: boxTop + 'px', left: boxLeft + 'px', width: boxWidth+'px', height: boxHeight+'px' } );
}
function closeZoomPicture() {
	if( $('zoomFG') ) $('zoomFG').remove();
	if( $('zoomBG') ) $('zoomBG').remove();
}
