
var contentHeight = 0;
var contentWidth = 0;
var divLeft = 0;
var divTop = 0;



function onResizeFunc(imgobj, divobj, imgOrigHeight, imgOrigWidth) {

	newContentHeight = document.viewport.getHeight();
	newContentWidth = document.viewport.getWidth() + 30;
	//get bg object
	
	var imgWidth;
	var imgHeight;

	//check for window resize
	if (contentHeight !=  newContentHeight || contentWidth !=  newContentWidth) {
		//window has been resized
		contentWidth = newContentWidth;
		contentHeight = newContentHeight;
		
		if (contentWidth/contentHeight > imgOrigWidth/imgOrigHeight) {
			//overheight
			imgWidth = contentWidth;
			imgHeight = contentWidth*imgOrigHeight/imgOrigWidth;
		} else {
			//overwidth
			imgWidth = contentHeight*imgOrigWidth/imgOrigHeight;
			imgHeight = contentHeight;
		}
		
		//clac vertical middle
		var ytrend = 0.9; // < 1: tendenz zu top-alignment, > 1: tendenz zu bottom-alignment im overheight-modus
		var ydiff = (newContentHeight - imgHeight)/2*ytrend;
		ydiff = Math.round(ydiff);
		
		
		if (ydiff) {
			divTop = ydiff;
			divLeft = -30 + 10;
		}
		
		//clac horizontal middle
		var xtrend = 1.1; // < 1: tendenz zu left-alignment, > 1: tendenz zu right-alignment im overwidth-modus
		var xdiff = (newContentWidth - imgWidth)/2*xtrend;
		if (xdiff) {
			divTop = 0;
			divLeft = (xdiff - 30);
		}
	
		divobj.style.top = divTop.toString() + 'px';
		divobj.style.left = divLeft.toString() + 'px';
		
		divobj.style.width = (-divLeft + document.viewport.getWidth()) + 'px';
		divobj.style.height = (-divTop + document.viewport.getHeight()) + 'px';
		
		
		
		//imgobj.width = imgWidth;
		//imgobj.height = imgHeight;
		
		
		imgobj.style.width = imgWidth + 'px';
		imgobj.style.height = imgHeight + 'px';
		
		

		//repeat viewport detection as scrollbar may disappear after setting divobj sizes
		divobj.style.height = (-divTop + document.viewport.getHeight()) + 'px';
	}
	return true;
}


function onScrollFunc(divobj) {
	//var scrollOffsets = document.body.cumulativeScrollOffset();
	//divobj.style.left = (divLeft + scrollOffsets[0] )+ 'px';
}





var browser = new Array();
function getBrowser() {
	/*
	* original version by Kristof Lipfert
	* http://www.lipfert-malik.de/webdesign/tutorial/bsp/browser_js_test.html
	*/
	if (browser['id']) {
		return browser;
	}

	if(document.ids) {
		x='nc4';
	} else if( document.all && !document.getElementById ) {
		x='ie4';
	} else if( window.opera && !document.createElement ) {
		x='op5';
	} else if( window.opera && window.getComputedStyle )  {
	       if(document.createRange) {
				x='op8';
	        } else if(window.navigate) {
				x='op7.5';
			} else  {
				x='op7.2';
			}
	} else if( window.opera && document.compatMode ) {
		x='op7';
	} else if( window.opera && document.releaseEvents ) {
		x='op6';
	} else if( document.contains && !window.opera ) {
		x='kq3';
	} else if (window.XML) {
		
		if (window.postMessage) {
			x='ff3';
		} else if(window.external) {
			x='ff2';

		} else {
			x='ff1';
		}
	} else if( window.getSelection && window.atob ) {
		x='nn7';
	} else if( window.getSelection && !document.compatMode ) {
		x='nn6';
	} else if( window.clipboardData && document.compatMode ) {
		x='ie6';
	} else if( window.clipboardData ){
		x='ie5';
	    if( !document.createDocumentFragment ) {
			x+='.5';
		}
	    if( document.doctype && !window.print ) {
			x+='m';
		}
	} else if( document.getElementById && !document.all ) {
		x='op4';
	} else if( document.images && !document.all ) {
		x='nn3';
	} else if(document.clientWidth&&!window.RegExp) {
		x='kq2';
	} else  {
		x='???';
	}
	try {
		os = navigator.platform;
		os = os.toLowerCase();
	} catch (e) {
		os = '???';
	}
	browser['app_name'] = x.substring(0,2);
	browser['app_ver'] = x.substring(2);
	browser['os_name']= os.substring(0,3);
	browser['os_ver'] = os.substring(3);
	browser['id'] = browser['app_name'] + browser['app_ver'] + browser['os_name'];
	return browser;
}
