innerHTML = "";
var adminPath = backLeftStr(backLeftStr(leftStr(window.location.href, ".nsf"), "/"), "/") + "/pc_admin.nsf/";

// Confirmation-Box-Layer-Objekt
var CB = {
	
	mouseX: 0,			// horizontale und ...
	mouseY: 0,			// vertikale Mausposition
	div_width: 300,		// Breite und ...
	div_height: 250,			// Hoehe des Confirmation-Containers
	distX: 10,			// horizontaler und ...
	distY: 10,			// vertikaler Abstand von Mauszeiger
	rollX: 0,			// horizontale und ...
	rollY: 0,			// vertikale Scrollposition
	container: null,		// DIV-Container
/*	windowTitle: null,  //Window title
	boxText: null,
	textOK: null,
	actionOK: null,
	textCancel: null,
	actionCancel: null,
	dragger: null, */

	create: function(windowTitle, boxText, textOK, actionOK, textCancel, actionCancel, picture) {
		CB.container = document.createElement("div");		
		CB.container.id = "confirmationbox";		
//		CB.container .setAttribute("style", "overflow:auto");
	

		innerHTML += '<div id="confirmationboxheader" onmousedown="CB.drag_prepare(event)">' + windowTitle + '<div id="confirmationboxclosebutton" onclick="CB.closeBox()"></div></div>';	
		innerHTML += '<table id="confirmationboxcontent"><tr>';
		if (picture == "Question") innerHTML += '<td id="confirmationboxpic"><img src="../../Script/' + adminPath + "msgQuestion.gif" + '"></td>';
		else if (picture == "Exclamation") innerHTML += '<td id="confirmationboxpic"><img src="../../Script/' + adminPath + "msgExclamation.gif" + '"></td>';
		innerHTML += '<td id="confirmationboxtext">' + boxText +  '</td></tr></table>';

		
		
		//if(textCancel == '') CB.container.style.height = "150px";
		//else CB.container.style.height = "200px";
		
		CB.container.style.height = CB.div_height + "px";
		
		innerHTML += '<div id="confirmationboxbuttons">';
		if (textOK != "") {
			innerHTML += '<span style="left:';
			if (textCancel == "") innerHTML += Math.round((CB.div_width - 6 - 128) / 2) + 'px"><a href="../../Script/';
			else  innerHTML += Math.round((CB.div_width - 6 - 266) / 2) + 'px"><a href="';			
			if (actionOK == '') innerHTML += 'javascript:CB.closeBox()">' + textOK + '</a></span>';
			else innerHTML += actionOK +  '" onclick="CB.hideBox()">' + textOK + '</a></span>';
		}
		if (textCancel != "") {
			innerHTML += '<span style="left:';
			if (textOK == "") innerHTML += (Math.round((CB.div_width - 6 - 128) / 2) + 138) + 'px"><a href="../../content/Script/';
			else  innerHTML += (Math.round((CB.div_width - 6 - 266) / 2) + 138) + 'px"><a href="';
			if (actionCancel == '') innerHTML += 'javascript:CB.closeBox()">' + textCancel + '</a></span>';
			else innerHTML += actionCancel +  '">' + textCancel + '</a></span>';
		}
		innerHTML += '</div>';
					
		CB.roll();
		CB.container.innerHTML = innerHTML;
		CB.container.style.width = CB.div_width + "px";
		//CB.container.style.height = CB.div_height + "px";
		


		//CB.container.style.left = Math.round((g_pageWidth - CB.div_width) / 2) + "px";
		//CB.container.style.left = Math.round((window.innerWidth - CB.div_width) / 2) + "px";
		if (document.body.offsetWidth) CB.container.style.left = Math.round((document.body.offsetWidth - CB.div_width) / 2) + "px";
		else CB.container.style.left = Math.round((window.innerWidth - CB.div_width) / 2) + "px";
		//alert(CB.container.style.left );
//		CB.container.style.top = CB.rollY + pos_y + "px";	

		CB.container.style.top = Math.round( (viewportGetHeight() - CB.div_height)/2 ) + viewportGetScrollY() + "px";

	//	CB.dragger = document.getElementById("confirmationboxheader"); // oder ... = FN.container
	//	CB.dragger.onmousedown = CB.drag_prepare;
	//	CB.dragger.style.cursor = "move";	
		
		return CB.container;
	},

	closeBox: function() {
		innerHTML = "";
		// loecht den Container
		document.getElementsByTagName("body")[0].removeChild(CB.container);
		CB.container = null;
	},
	
	roll: function() {
		// Gibt die horizontale oder vertikale Scroll-Verschiebung zurueck
		if (isFinite(self.pageYOffset)) {	// DOM
			CB.rollX = self.pageXOffset;
			CB.rollY = self.pageYOffset;
		}
		else if (isFinite(document.documentElement && document.documentElement.scrollTop)) {	// IE neu
			CB.rollX = document.documentElement.scrollLeft;
			CB.rollY = document.documentElement.scrollTop;
		}
		else if (isFinite(document.body.scrollTop)) {	// IE alt
			CB.rollX = document.body.scrollLeft;
			CB.rollY = document.body.scrollTop;
		}
	},
	
	drag_prepare: function(event) {
		// registriert die ziehen-Funktion fuer Mausbewegungen,
		// Abbruch bei Loslassen der Maustaste
		if (!event) var event = window.event;
		CB.position_determine(event);
		document.onmousemove = CB.drag;
		document.onmouseup = CB.stop;
 	},
 	
 	position_determine: function(event) {
		// ermittelt die Position des Mauszeigers
		// (Pixel von der linken oberen Fensterecke)
		if (!event) var event = window.event;
		CB.mouseX = event.clientX;
		CB.mouseY = event.clientY;
		CB.roll();
		// Safari rechnet clientX/Y vom Dokumentenanfang aus
		if (CB.mouseX > CB.rollX && CB.rollX >= window.innerWidth) CB.mouseX -= CB.rollX;
		if (CB.mouseY > CB.rollY && CB.rollX >= window.innerHeight) CB.mouseY -= CB.rollY;
 	},
 	
 	drag: function(event) {
		// verschiebt den Colorpicker-Container parallel zu Mausbewegungen
		if (!event) var event = window.event;
		// Sicherheitsmassnahme: manche Browser kommen mit den Ereignissen
		// durcheinander
		// (Safari) oder bei Maus-Hektik (IE); in diesem Fall loest ein
		// Mausklick den am Zeiger klebenden Container.
		document.onmousedown = CB.stop;
		// 1.) aktuelle Position ermitteln
		var windowX = parseInt(CB.container.style.left.slice(0,-2));
		var windowY = parseInt(CB.container.style.top.slice(0,-2));
		// 2.) alte Mausposition speichern
		var mouseX_old = CB.mouseX;
		var mouseY_old = CB.mouseY;
		// 3.) neue Mausposition ermitteln
		CB.position_determine(event);
		// 4.) um die Differenz verschieben
		CB.container.style.left = windowX + CB.mouseX - mouseX_old + "px";
		CB.container.style.top = windowY + CB.mouseY - mouseY_old + "px";
 	},
 
	stop: function() {
		// loescht Event-Handler, laesst Container los
		document.onmousemove = null;
		document.onmouseup = null;
		// gleicht Sicherheitsmassnahme in CB.ziehen() aus
		/*
		if (document.onmousedown) {			
			document.onmousedown = null;
			CB.dragger.onmousedown = CB.drag_prepare;
  		}*/
 	},
 	
 	hideBox: function() { 
		document.getElementById("confirmationbox").style.visibility = "hidden"; 		
 	}

}



//Box anzeigen
function showConfirm(strWindowTitle, strWindowText, strButtonOk, strActionOk , strButtonCancel, strActionCancel, strPicture) {
		if (CB.container) CB.closeBox();
		document.getElementsByTagName("body")[0].appendChild(CB.create(strWindowTitle, strWindowText, strButtonOk, strActionOk , strButtonCancel, strActionCancel, strPicture));			
}

function showOK(strWindowTitle, strWindowText, strButtonOk, strPicture) {
		if (CB.container) CB.closeBox();
		document.getElementsByTagName("body")[0].appendChild(CB.create(strWindowTitle, strWindowText, strButtonOk, '' , '', '', strPicture));			
}

function validationFailure(text) {
	showOK(clubName, text, "OK", "Exclamation");
}

function showOKMessage(text) {
	showOK(clubName, text, "OK", "Exclamation");
}
