/*************************************************************************
 * Oxebox 0.9                                                            *
 *************************************************************************
 * Div-Popup mit iFrame und buntischen Hintergrund                       *
 * Usage:                                                                *
 * oxebox_open(string URL, string TITEL, int BREITE, int HÖHE)           *
 *                                                                       *
 * Author: Peter Navrodt                                                 *
 * Letzte Änderung: 16.10.07, PN                                         *
 *                                                                       *
 * www.ladies.de                                       (c) 2007 RTO GmbH *
 *************************************************************************/

var oxe_x, oxe_y, oxe_x_b, oxe_y_b, oxe_width, oxe_height, oxe_title, oxe_trans_time;
var oxe_trans_max = 7;
var oxe_trans_interval = 50;
var oxe_add_height = 27;
var oxe_add_width = 6;

if(typeof(OXE_ROOT_DIR) == "undefined") {
	var OXE_ROOT_DIR = "oxebox";
}

function oxebox_open(ptitle, url, pwidth, pheight) {
	oxe_width = pwidth;
	oxe_height = pheight;
	oxe_title = ptitle;
	divid = "oxebox_container";
	div_oxebox = document.createElement("div");
	div_oxebox.setAttribute("class", "oxebox");
	div_oxebox.setAttribute("className", "oxebox");
	div_oxebox.setAttribute("id", divid);
	div_body = document.getElementsByTagName("body")[0];
	div_body.appendChild(div_oxebox);
	
	try 
	{
		document.getElementById('noswf').style.display='';
		document.getElementById('swf').style.display='none';
	}
	catch (e) 
	{/**/}
	bg_open();
	setTimeout('oxebox_create("'+url+'","'+divid+'");', oxe_trans_time);
}
function oxebox_create(url, divid) {
	
	
	var out = '';
	div_pink = document.getElementById(divid);
	get_xy();
	div_pink.style.left = oxe_x+'px';
	div_pink.style.top = oxe_y+'px';
	div_pink.style.display = 'block';
	out += '	<div class="head" id="head"><span class="title">'+oxe_title+'</span> <div class="close"><a href="javascript:oxebox_close(\''+divid+'\');">Schlie&szlig;en</a> <a href="javascript:oxebox_close(\''+divid+'\');"><img src="'+OXE_ROOT_DIR+'/oxeclose.gif" border="0"></a></div></div>';
	out += '	<iframe class="pink" width="'+oxe_width+'" height="'+oxe_height+'" src="'+url+'" frameborder="0"></iframe>';
	div_pink.innerHTML = out;
	div_head = document.getElementById("head");
	div_head.style.width = oxe_width;
}
function oxebox_close(divid) {
	
	try 
	{
		document.getElementById('noswf').style.display='none';
		document.getElementById('swf').style.display='';
	}
	catch (e) 
	{/**/}
	div_oxebox = document.getElementById(divid);
	div_oxebox.innerHTML = '';
	div_oxebox.style.left = '0px';
	div_oxebox.style.top = '0px';
	div_oxebox.style.display = 'none';
	div_body = document.getElementsByTagName("body")[0];
	div_body.removeChild(div_oxebox);
	bg_close();
}
function bg_open() {
	div_oxebox_bg = document.createElement("div");
	div_oxebox_bg.setAttribute("class", "oxebox_bg");
	div_oxebox_bg.setAttribute("className", "oxebox_bg");
	div_oxebox_bg.setAttribute("id", "oxebox_bg");
	div_body = document.getElementsByTagName("body")[0];
	div_body.appendChild(div_oxebox_bg);
	div_bg = document.getElementById("oxebox_bg");
	
	get_bodyxy();
	div_bg.style.width = oxe_x_b+"px";
	div_bg.style.height = oxe_y_b+"px";
	div_bg.style.filter = "alpha(opacity=0)";
	div_bg.style.opacity = "0.0";
	div_bg.style.zIndex = "1110";
	div_bg.style.display = "block";
	
	initFade(div_bg);
}
function bg_close() {
	div_bg = document.getElementById("oxebox_bg");
	div_bg.style.width = "0px";
	div_bg.style.height = "0px";
	div_bg.style.display = "none";
	div_body = document.getElementsByTagName("body")[0];
	div_body.removeChild(div_bg);
}
function initFade(div_bg) {
	oxe_trans_time = 0;
	for (var i=0;i<oxe_trans_max;i++) {
		setTimeout('setOpacity('+i+', div_bg)',oxe_trans_interval*i);
		oxe_trans_time = oxe_trans_time + ((oxe_trans_interval-25)*i);
	}
	return false;
}
function setOpacity(value, div_bg)
{
	div_bg.style.opacity = value/10;
	div_bg.style.filter = 'alpha(opacity=' + value*10 + ')';
}
function get_xy() {
	// The inner dimensions of the window or frame.
	if (self.innerHeight) { // all except Explorer 
		x_w = self.innerWidth;
		y_w = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		// Explorer 6 Strict Mode
		x_w = document.documentElement.clientWidth;
		y_w = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		x_w = document.body.clientWidth;
		y_w = document.body.clientHeight;
	}
	// How much the page has scrolled.
	if (self.pageYOffset) { // all except Explorer
		x_o = self.pageXOffset;
		y_o = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		// Explorer 6 Strict
		x_o = document.documentElement.scrollLeft;
		y_o = document.documentElement.scrollTop;
	} else if (document.body) { // all other Explorers
		x_o = document.body.scrollLeft;
		y_o = document.body.scrollTop;
	}
	// Mitte berechnen
	oxe_x = Math.round(x_w/2 - (oxe_width+oxe_add_width)/2 + x_o);
	oxe_y = Math.round(y_w/2 - (oxe_height+oxe_add_height)/2 + y_o);
}
function get_bodyxy() {
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight;
	if (test1 > test2) { // all but Explorer Mac
		oxe_x_b = document.body.scrollWidth;
		oxe_y_b = document.body.scrollHeight;
	} else { // Explorer Mac;
		//would also work in Explorer 6 Strict, Mozilla and Safari
		oxe_x_b = document.body.offsetWidth;
		oxe_y_b = document.body.offsetHeight;
	}
}