	
	// layers for help and permanent menu are optionals
	if ( document.getElementById('help') )
		var a = document.getElementById('help').style
	if ( document.getElementById('help1') )
		var a1 = document.getElementById('help1').style
	
	// variables for image size
	var wFoto
	var hFoto
	
	// starting sizes
	var owFoto
	var ohFoto
	

	// take image dimensions and fit if needed
	function loaded() {
		wFoto=document.getElementById('foto').width; 
		hFoto=document.getElementById('foto').height;
		owFoto = wFoto
		ohFoto = hFoto
		if ( startFit  ) {
			document.getElementById('foto').width=176 
			wFoto = document.getElementById('foto').width
			hFoto=document.getElementById('foto').height;
		}
		else {
			if ( x > windowWidthHalf && y > windowHeightHalf ) {
				window.scrollTo(x-windowWidthHalf,y-windowHeightHalf)
				a.top = document.body.scrollTop+15
				a.left = document.body.scrollLeft+15
				a1.top = document.body.scrollTop+topMenu
				a1.left = document.body.scrollLeft+leftMenu
			}
		}

		// help layer hidden in 3 seconds
		if ( document.getElementById('help') )
			setTimeout("document.getElementById('help').style.visibility = 'hidden'",3000);
		if ( document.getElementById('titlediv') )
			setTimeout("document.getElementById('titlediv').style.visibility = 'hidden'",1500);
		window.focus();		
	}
	
	
	// attend the keystrokes to zoom or move the image
	function keyStroke() {
		switch(event.keyCode) {

			// resizing commands
			
			case 49: // 1 = home 
				if ( typeof(onClickOne) != 'undefined' )
					onClickOne()
				else {				
					if ( allowHome ) {
						window.scroll(0,0); 
						a.top = document.body.scrollTop+15
						a.left = document.body.scrollLeft+15
						a1.top = document.body.scrollTop+topMenu
						a1.left = document.body.scrollLeft+leftMenu
					}
				}
				break 
			case 53:  // 5 y almohadilla = fit / full screen
			case 35: //almohadilla
			case 97:
			case 65:
			case 45:
				if ( allowFit ) {
					window.scroll(0,0); 
					document.getElementById('foto').width=176 
					wFoto = document.getElementById('foto').width
					document.getElementById('foto').height=parseInt(ohFoto*wFoto/owFoto);  
					hFoto = document.getElementById('foto').height
					a.top = document.body.scrollTop+15
					a.left = document.body.scrollLeft+15
					a1.top = document.body.scrollTop+topMenu
					a1.left = document.body.scrollLeft+leftMenu
					zoom=1
				}
				break
			case 55:  // 7 = zoom+
				if ( zoom < topZoom ) {
					zoom++
					document.getElementById('foto').width=new Number(wFoto)+(zoom-1)*pixZoom; 
					document.getElementById('foto').height=new Number(hFoto)+(zoom-1)*parseInt(pixZoom*actualScreenHeight/windowWidth); 
					a.top = document.body.scrollTop+15
					a.left = document.body.scrollLeft+15
					a1.top = document.body.scrollTop+topMenu
					a1.left = document.body.scrollLeft+leftMenu
				}
				break
			case 51: // 3 = zoom-	
				if ( zoom > 1 ) {
					zoom--
					document.getElementById('foto').width=new Number(wFoto)+(zoom-1)*pixZoom; 
					document.getElementById('foto').height=new Number(hFoto)+(zoom-1)*parseInt(pixZoom*actualScreenHeight/windowWidth);  
					a.top = document.body.scrollTop+15
					a.left = document.body.scrollLeft+15
					a1.top = document.body.scrollTop+topMenu
					a1.left = document.body.scrollLeft+leftMenu
				}
				break 

			
			// scrolling commands

			case 56: 
				if ( document.body.scrollTop+parseInt(pixScroll*actualScreenHeight/windowWidth)+actualScreenHeight-pixScroll < document.getElementById('foto').height ) {
					window.scroll(document.body.scrollLeft,document.body.scrollTop+parseInt(pixScroll*actualScreenHeight/windowWidth))
					a.top = document.body.scrollTop+15
					a1.top = document.body.scrollTop+topMenu
				}
				break // 8 = abajo
			case 50: 
				window.scroll(document.body.scrollLeft,document.body.scrollTop-parseInt(pixScroll*actualScreenHeight/windowWidth))
				a.top = document.body.scrollTop+15
				a1.top = document.body.scrollTop+topMenu
				break // 2 = arriba


			case 54:  // 6 = derecha
				window.scroll(document.body.scrollLeft+pixScroll,document.body.scrollTop)
				a.left = document.body.scrollLeft+15
				a1.left = document.body.scrollLeft+leftMenu
				break
			case 52:  // 4 = izquierda					
				window.scroll(document.body.scrollLeft-pixScroll,document.body.scrollTop)
				a.left = document.body.scrollLeft+15
				a1.left = document.body.scrollLeft+leftMenu
				break



			case 57:	// 9 = exit
			case 42: //asterisco = exit
			case 67:
			case 99:
				if ( urlQuit != null )
					location = urlQuit + (urlQuit.indexOf('?') == -1 ? '?' : '&' ) + 'ts=' + new Date().valueOf()
				break
			case 48: // 0 help hide/unhide
				if ( document.getElementById('help').style.visibility == 'visible' ) {
					document.getElementById('help').style.visibility = 'hidden'
					// if exists title div layer hide also
					if ( document.getElementById('titlediv') )
						document.getElementById('titlediv').style.visibility = 'hidden'
				}
				else {
					document.getElementById('help').style.visibility = 'visible'
					// if exists title div layer show first
					if ( document.getElementById('titlediv') ) {
						document.getElementById('titlediv').style.visibility = 'visible'
						setTimeout("document.getElementById('titlediv').style.visibility = 'hidden'",3000);
					}
					document.getElementById('help').style.visibility = 'visible'
					// hide after 5 seconds
					setTimeout("document.getElementById('help').style.visibility = 'hidden'",6000);
				}
				break
			default:
				break
		}
	}	

