function dialog(t_url,t_title,t_width,t_height) {

if ((typeof(t_width)=="undefined")||(t_width=="")) t_width=400;
if ((typeof(t_height)=="undefined")||(t_height=="")) t_height=400;
if ((typeof(t_title)=="undefined")||(t_title=="")) t_title= 'Detailansicht';
t_width=t_width+25;
t_height=t_height+30;
if ((typeof(t_url)!="undefined")&&(t_title!="")){
	var win = new Window({className: "alphacube", resizable: false,maximizable: false,title: t_title, width:t_width, height:t_height, 
        url: t_url , showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff })
	win.showCenter();
	}
}

function imgupdate(t_url) {
new Ajax.Updater('outerimg', '/nwgetobject.phtml', {
  method: 'get',
  parameters: t_url
  });
       
  }

function openimg(t_url,t_width,t_height) {
if ((typeof(t_width)=="undefined")||(t_width=="")||(t_width < 460)) t_width=460;
if ((typeof(t_height)=="undefined")||(t_height=="")) t_height=460;
t_width=t_width+25;
t_height=t_height+90;

	if (!document.getElementById('overlay')){
		var objBody = document.getElementsByTagName('body').item(0);
		var objOverlay = document.createElement('div');
		objOverlay.setAttribute('id','overlay');
		var arrayPageSize = getPageSize();
		objOverlay.style.width = arrayPageSize[0] +"px";
		objOverlay.style.height = arrayPageSize[1] +"px";
		//objOverlay.setAttribute('id','loading_overlay');
		objBody.appendChild(objOverlay);


		var objLoading = document.createElement('div');
		objLoading.setAttribute('id','loading');
		objBody.appendChild(objLoading);
	
		var objLoadingImage = document.createElement('img');
		objLoadingImage.setAttribute('src', '/nw_style/alphacube/progress.gif');
		objLoading.appendChild(objLoadingImage);
	}else{
	document.getElementById('overlay').style.display = 'block';
 	document.getElementById('loading').style.display = 'block';
	}


      Dialog.alert({url: "/nwgetobject.phtml", options: {method: 'get', onLoading: loadHandler, onSuccess: completeHandler, onFailure: errorHandler, parameters: t_url }}, 
                    {width: t_width,height: t_height, className: "alphacube", okLabel:"Schließen"}) 



 
  }

function errorHandler() {
                alert('request_error')
            }

function loadHandler() {
	//	openInfoDialog()
            }

function completeHandler(req) {
	   //    Dialog.closeInfo()	
            }


function openInfoDialog() { 
Dialog.info("Das Bild wird geladen...", {width:250, height:100, className: "alphacube", showProgress: true}) 
} 


// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		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;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			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;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


