

// based on Lightbox http://www.huddletogether.com/projects/lightbox/
// ajax and rest (c) Robert Waksmundzki http://www.waksmundzki.com/

function createRequestObject()
{
	var ro;
	try{
		ro = new XMLHttpRequest();
	}
	catch (Error){
 		try{
			ro = new ActiveXObject("Microsoft.XMLHTTP");
 		}
		catch (Error){
			return false;
		}
	}
  return ro;
}


var http = createRequestObject();
function machfenster2(url,i_width,i_height)
{
    var oldtxt = document.getElementById('wn_dialog1').innerHTML;
    if(oldtxt == '')
    {
    	var toplen;
    	if (self.pageYOffset){
				toplen = self.pageYOffset + 100;
			}else if (document.documentElement && document.documentElement.scrollTop){
				toplen = document.documentElement.scrollTop + 100;
			}else if (document.body){
				toplen = document.body.scrollTop + 100;
			}
			
			var arrayPageSize = getPageSize();
		
		  document.getElementById('wn_dialog1').innerHTML = '<div style="display: none; background-image: url(\'http://ea52.linux-hosting.de/lola/bg_4x4_v.gif\');left: 0px;position: absolute;top: 0px;z-index: 1000; width: 100%; height: 100%;"  id="wn_dialog2"><div id="wn_dialog3" style="margin-left: ' + ( (arrayPageSize[0] - i_width ) / 2 ) + 'px; margin-top: ' + toplen + 'px;"></div></div>';
      
			document.getElementById('wn_dialog2').style.height = (arrayPageSize[1] + 'px');
			document.getElementById('wn_dialog2').style.width = (arrayPageSize[0] + 'px');
			document.getElementById('wn_dialog2').style.display = 'block';
			
			document.getElementById('wn_dialog3').style.height = i_height + 'px';
			document.getElementById('wn_dialog3').style.width = i_width + 'px';
			document.getElementById('wn_dialog3').style.background = '#ffffff';
			document.getElementById('wn_dialog3').style.overflow = 'hidden';
			document.getElementById('wn_dialog3').style.border = '1px #ED9129 solid';
      http.open('get', url + "&" + Math.random());
      http.onreadystatechange = handleResponse;
      http.send(null);
    }
    else
    {
    	document.getElementById('wn_dialog1').innerHTML = '';
    }
    
}

function handleResponse(){
    if(http.readyState == 4){
        var response = http.responseText;
        var prepend = "";
				document.getElementById('wn_dialog3').innerHTML = prepend + response;
				document.getElementById('wn_dialog3').style.display = 'block';
    }
}			

function getPageSize(){

	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


function machfenster3(url,i_width,i_height){
    var oldtxt = document.getElementById('wn_dialog1').innerHTML;
    if(oldtxt == ''){
    	var toplen;
    	if (self.pageYOffset){
				toplen = self.pageYOffset + 100;
			}else if (document.documentElement && document.documentElement.scrollTop){
				toplen = document.documentElement.scrollTop + 100;
			}else if (document.body){
				toplen = document.body.scrollTop + 100;
			}
			
			var arrayPageSize = getPageSize();
		
		  document.getElementById('wn_dialog1').innerHTML = '<div style="display: none; background-image: ' + 
		  'url(\'http://ea52.linux-hosting.de/lola/bg_4x4_v.gif\');left: 0px;position: absolute;top: 0px; ' + 
		  'z-index: 1000; width: 100%; height: 100%;"  id="wn_dialog2"><div id="wn_dialog3" style="margin-left: ' + 
		  ( (arrayPageSize[0] - i_width ) / 2 ) + 'px; margin-top: ' + toplen + 'px;"><iframe width="100%" ' + 
		  'height="100%" src="' + url + '" border="0" frameborder="0"></iframe></div></div>';
      
			document.getElementById('wn_dialog2').style.height = (arrayPageSize[1] + 'px');
			document.getElementById('wn_dialog2').style.width = (arrayPageSize[0] + 'px');
			document.getElementById('wn_dialog2').style.display = 'block';
			
			document.getElementById('wn_dialog3').style.height = i_height + 'px';
			document.getElementById('wn_dialog3').style.width = i_width + 'px';
			document.getElementById('wn_dialog3').style.background = '#ffffff';
			document.getElementById('wn_dialog3').style.overflow = 'hidden';
			//document.getElementById('wn_dialog3').style.border = '1px #ED9129 solid';
			
     // http.open('get', url + "&" + Math.random());
     // http.onreadystatechange = handleResponse;
     // http.send(null);
    }else{
    	document.getElementById('wn_dialog1').innerHTML = '';
    }
}