width = 600;
height = 540;
//boxX=620; /* horizontal rechts aussen */
//boxY=50; /* vertikale position */

//boxX=document.body.offsetWidth - (width/2); /* horizontal rechts aussen */
boxY=50; /* vertikale position */


function showRoom(url,dummy_src){

	toggleFlash('none');

	var iframe = "<div id='loading'><img src='../images/loading.gif' alt='../images/loading.gif'/></div><iframe onload='hideLoading()' frameborder='0' src='" + url + "' id='show-frame' name='show-frame'></iframe>";
	var content = $('widget').innerHTML + iframe;

	var bodyWidth = isIE ? document.body.clientWidth : window.innerWidth;
	//alert(bodyWidth+' - ' + document.body.offsetWidth);
	boxX = (bodyWidth - width) / 2 + width;
	//alert(bodyWidth + '-' +boxX);
	createBox('show-room', content, boxX, boxY, width, height);

	$('show-room').style.zIndex = 5;
	$('show-frame').src = url;
	$('dummy').style.display = 'block';
	$('dummy-image').src = dummy_src;

}

function hideLoading(){
	$('loading').style.display = 'none';
}

function toggleFlash(display){

	visible = 'hidden';
	if(display == 'block'){
		visible = 'visible';
	}

	var items = $A(document.getElementsByTagName('embed'));
	items.each(function(item){
			//item.style.display = display;
			item.style.visibility = visible;
			return false;
	});
	var items = $A(document.getElementsByTagName('object'));
	items.each(function(item){
			//item.style.display= display ;
			item.style.visibility = visible;
			return false;
	});
}

function hideRoom(){

	toggleFlash('block');
	remove_div('show-room');
	$('dummy').style.display = 'none';

}

function mouseX(event) {
	event = event || window.event;
	if (event.pageX) return event.pageX;
	if (event.clientX)
	   return event.clientX + (document.documentElement.scrollLeft ?
	   document.documentElement.scrollLeft :
	   document.body.scrollLeft);
	else return null;
}
function mouseY(event) {
	event = event || window.event;
	if (event.pageY) return event.pageY;
	if (event.clientY)
	   return event.clientY + (document.documentElement.scrollTop ?
	   document.documentElement.scrollTop :
	   document.body.scrollTop);
	else return null;
}
/*
 * Pops up an infobox (appends div to document.body)
 * style it with css class ".infobox"
 *
 * @param elementid			dom id for the infobox
 * @param content			contents of the infobox
 * @param x,y,width	position and dimensions (absoulute)	 *
*/
function createBox(elementid,content,x,y,width, height) {

	if(document.getElementById(elementid)){
		return false;
	}
 	//postion: left of cursor, if there's enough place
 	x = x - width;
	z = document.documentElement.scrollLeft ?
 		document.documentElement.scrollLeft :
		document.body.scrollLeft;
	if ( x < z ) {
 		x = z;
 	}

 	var dstyle = "position: absolute; top:" + (y-10) + "px; left:" + (x+10) + "px; width:" + width + "px;" + " height: " + height + "px;";

 	var infobox=document.createElement('div');
 	infobox.setAttribute('id',elementid);

	var isIE = ( navigator.userAgent.match(/MSIE/) && !navigator.userAgent.match(/Opera/) );
 	if (isIE) {
 		infobox.setAttribute('className','widget');
 		infobox.style.cssText = dstyle;
 	} else {
 		infobox.setAttribute('class','widget');
	    infobox.setAttribute('style',dstyle);
 	}

	infobox.innerHTML=content;
    document.body.appendChild(infobox);
}

function remove_div(elementid) {
	var el=document.getElementById(elementid);
	document.body.removeChild(el);
}
