function show_object(ID)
{
	var object=document.getElementById(ID);
	if (object) 
	{
		object.style.visibility = "visible";
	}
}

function hide_object(ID)
{
	var object=document.getElementById(ID);
	if (object) 
	{
		object.style.visibility = "hidden";
	}
}

function getWindowWidth()
{
	var myWidth = 0
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	myWidth = window.innerWidth;
	} else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
	} else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	myWidth = document.body.clientWidth;
	}
	return myWidth
}

function getWindowHeight()
{
	var myHeight = 0
	if( typeof( window.innerHeight ) == 'number' ) {
	//Non-IE
	myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientHeight || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientHeight || document.body.clientHeight ) ) {
	//IE 4 compatible
	myHeight = document.body.clientHeight;
	}
	return myHeight
}

function findPositionX(obj)
{
    var left = 0;
    if(obj.offsetParent)
    {
        while(1) 
        {
          left += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    }
    else if(obj.x)
    {
        left += obj.x;
    }
    return left;
}

function findPosY(obj)
{
    var top = 0;
    if(obj.offsetParent)
    {
        while(1)
        {
          top += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    }
    else if(obj.y)
    {
        top += obj.y;
    }
    return top;
}
  
function get_scaled_y()
{
  //gibt die fuer das Bild maximal verfügbare Bildschirmhöhe zurück
  return getWindowHeight()-findPosY(document.getElementById("navtable"))-120;
}  

function get_scaled_x()
{
  //gibt die fuer das Bild maximal verfügbare Bildschirmbreite zurück
  return getWindowWidth()-document.getElementById('navtable').offsetWidth-20;
}


/*function get_scaled_y()
{
	myTarget=document.getElementById("navtable");
	up=0;
        try {
		while(myTarget!= document.body) { 
			up += myTarget.offsetTop;
			myTarget = myTarget.offsetParent;
		}
		}
        catch(ex) {}
	return getWindowHeight()-up-120;
}
*/

function get_image_to_screen_x(origX,origY,ElementID)
{
	var scaledX=get_scaled_x(/*ElementID*/);
	var scaledY=get_scaled_y(/*ElementID*/);
	var zoomX=(scaledX/origX);
	var zoomY=(scaledY/origY);
	var retval=0;
	
	if (zoomX<zoomY)
	{
		retval=scaledX;
	}
	else
	{
		retval=origX*zoomY;
	}
	return Math.round(retval);
}

function get_image_to_screen_y(origX,origY,ElementID)
{
	var scaledX=get_scaled_x(/*ElementID*/);
	var scaledY=get_scaled_y(/*ElementID*/);
	var zoomX=(scaledX/origX);
	var zoomY=(scaledY/origY);
	var retval=0;
	
	if (zoomX<zoomY)
	{
		retval=origY*zoomX;
	}
	else
	{
		retval=scaledY;
	}
	return Math.round(retval);
}

function zoom_image_to_screen(origX,origY)
{
	img=document.getElementById("photo")
	scaledX=get_scaled_x(/*"dcontent"*/); //maximale breite 
	scaledY=get_scaled_y(/*"dcontent"*/); //maximale höhe
	zoomX=(scaledX/origX); //zoom-faktor bei skalierung auf x-achse
	zoomY=(scaledY/origY); //zoom-faktor bei skalierung auf y-achse
	targetX=get_image_to_screen_x(origX,origY,"dcontent"); //festgelegte breite
	targetY=get_image_to_screen_y(origX,origY,"dcontent"); //festgelegte höhe
	
	document.getElementById("photo").width=targetX;
	document.getElementById("photo").height=targetY;	
	document.getElementById("imageframe").style.width=targetX + 'px';
	document.getElementById("lupe").src='./album/lupe_plus.gif';
	
	var canvas=document.getElementById("map_canvas");
	if (canvas) {
		targetX=targetX-0;
		canvas.style.width=targetX+'px';
		map.checkResize();
	}


}

function zoom_image_to_100(origX,origY)
{
	document.getElementById("photo").width=origX;
	document.getElementById("photo").height=origY;
	document.getElementById("imageframe").style.width=origX+ 'px';
	var canvas=document.getElementById("map_canvas");
	if (canvas) {
		targetX=origX-0;
		canvas.style.width=targetX+'px';
		map.checkResize();
		}
	document.getElementById("lupe").src='./album/lupe_minus.gif';
}

function zoom_image_toggle(origX,origY)
{
	img=document.getElementById("photo")
	content=document.getElementById("dcontent")
	if (img.width==origX)	{
		zoom_image_to_screen(origX,origY);
	}
	else
	{
		zoom_image_to_100(origX,origY);
	}
}