// communic8 - web realities...
// http://www.communic8.ch


<!--
var isIE = (document.getElementById && document.all)?true:false;
var isNS4 = (document.layers)?true:false;
var isNS6 = (document.getElementById && !document.all)?true:false;
function myGetElementById (id)
{
    if ( isIE )
    {
	var str = "document.all('" + id + "')";
	var o = eval(str);
	return o;
    }

    return document.getElementById(id);
}

// these globals that can be used from other routines
var pageWidth;
var pageHeight;

// window.onload	= function() { findDimensions(); };
// window.onresize	= function() { findDimensions(); };

function findDimensions ()
{
    var frameWidth;
    var frameHeight;
    var obj;

    if (self.innerWidth)
    {
	frameWidth = self.innerWidth;
	frameHeight = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientWidth)
    {
	frameWidth = document.documentElement.clientWidth;
	frameHeight = document.documentElement.clientHeight;
    }
    else if (document.body)
    {
	frameWidth = document.body.clientWidth;
	frameHeight = document.body.clientHeight;
    }
    else
	return;

    // if there's valid info, update the globals so they can be used elsehere
    pageWidth = frameWidth;
    pageHeight = frameHeight;

    if ( (obj = myGetElementById('background')) )
    {
	obj.style.width = frameWidth;
	obj.style.height = frameHeight;
    }

    if ( (obj = myGetElementById('background_image')) )
    {
	var iWidth = obj.width; 
	var iHeight = obj.height;
	var iRatio = iWidth / iHeight;
	var fRatio = frameWidth / frameHeight;	

	// reset to default position on resize/load
	obj.style.top = obj.style.left = 0;

	if ( iRatio < fRatio ) 
	{
	    obj.style.width = frameWidth;
	    obj.style.height = frameWidth / iRatio;
	} 
	else 
	{
	    obj.style.height = frameHeight;
	    obj.style.width = frameHeight * iRatio;
	}
    }
}

/*
 * this is called to reset the background image and height/width
 */
function setBackground (url, width, height)
{
    var obj = myGetElementById ('background_image');
    if ( obj )
    {
	obj.onload = function () { 
	    if ( width ) this.style.width = width;
	    if ( height ) this.style.height = height;
	    findDimensions();
	}
	obj.src = url;
    }
}

/*
 * this is called after a new page loads. id is the main content div
 * that has just been loaded and contains a special tag like:
 * <SPAN ID="PAGE_BACKGROUND" SRC="url" WIDTH="width" HEIGHT="height"></SPAN>
 */
function updateBackground (id)
{
    var obj = myGetElementById(id);
    if ( obj )
    {
	var newBgObj = myGetElementById("PAGE_BACKGROUND");
	var bgObj = myGetElementById("background_image");

	if ( newBgObj && bgObj )
	{
	    var src = newBgObj.getAttribute("src");

//	    alert ("Updating bg=" + bgObj.src + " " + bgObj.width + "x" + bgObj.height + " with " + src);
	    if ( src )
	    {
		setBackground (src,
		    newBgObj.getAttribute("width"),
		    newBgObj.getAttribute("height"));
	    }
	}
    }
}



function clearDragObject ()
{
    var obj = myGetElementById("dragObject");
    if ( obj )
    {
	obj.innerHTML = "";
	obj.style.display = "none";
	obj.style.top = "-100px";
	obj.style.left = "-100px";
	obj.arg = undefined;
    }
}

function initialize()
{


    // finally check the browser window dimensions and set stuff based on 'em
    findDimensions();
    pageIsLoaded = true;

}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		ausblenden = newImage("/images/ausblenden-over.jpg");
		preloadFlag = true;
	}
}


function popUp(url){
	window.open(url,"pop","width=550,height=405,toolbars=0,scrollbars=0,status=no")
}

//-->