

function SliderBox(node, controllerObject) {
	
	var boxNode = node;
	var movingDesc = false;
	var closer = null;
	var globalTimeout = 2000;
	var controller = controllerObject;
	var index = boxNode.getAttribute("index");
	
	var movingDesc = false;
	var movingOpen = false;
	
	var eventCatcher = document.getElementById("eventCatcher_"+index);
	var openMover = document.getElementById("openMover_"+index);
	var modulId = parseInt( document.getElementById("modulId_"+index).innerHTML );
	var typeId = parseInt( document.getElementById("typeId_"+index).innerHTML );
	var balken = document.getElementById("balken_"+index);
	var boxIndex = boxNode.getAttribute("index");
	
	var ajaxurl = "";
	
	eventCatcher.onmouseover = boxOver;
	eventCatcher.onmouseout = boxOut;
	eventCatcher.onmousemove = boxMove;
		
	var IFIE = true;
	if(navigator.appVersion.match(/MSIE/)) {
		IFIE = false;
	}
	
	
	if(boxNode.getAttribute("set2") != "unselect") {
		boxNode.onmousedown = click;
	}else {
		
		//Meldung bei verschlossenden Modulen
		boxNode.onmousedown = function() {
			if(document.getElementById("a2Link_"+boxIndex)) {
				var message = 	'<h3>Auf die MCAS Prüfung  vorbereiten</h3>Für die Nutzung der Lerninhalte  für Fortgeschrittene ist es notwendig, '+
								'im jeweiligen Selbsttest alle Fragen  richtig zu beantworten oder in den zugeh&ouml;rigen Lernmodulen einen Lernstand von durchschnittlich 80% zu erreichen.<br/><br/>'+
								'<strong>Bemerkung:</strong> Bitte beachten  Sie, dass die Nutzung der Lerninhalte für Fortgeschrittene nur mit dem  Microsoft&nbsp; '+
								'Internetexplorer&nbsp; ab Version 7.x und dem Microsoft  Silverlight-Plugin 2.x möglich ist.';
								
			}else {			
				var message = 	'<h3>Wissen vertiefen</h3>Für die Nutzung der  interaktiven Übungen ist es notwendig, im jeweiligen Selbsttest alle Fragen richtig  '+
								'zu beantworten oder in den zugeh&ouml;rigen Lernmodulen einen Lernstand von durchschnittlich 80% zu erreichen.<br/><br/><strong>Hinweis:</strong> Die Übungen enthalten '+
								'Lerninhalte, die es Ihnen ermöglichen, ohne die jeweilige Applikation  zu installieren, Ihr Wissen interaktiv zu vertiefen.';
			}
			message = '<div style="padding-right:113px;">'+message+'<div>';
			top.contentLoader.loadContent('', 400, 265, 'message', null, true, null, null, null, 128, message);
		}
	}
	
	
	function boxMove(dasEreignis) {
		
		if(eventCatcher.getAttribute("state") == "" ) {
			boxOver(dasEreignis);
		}
		
		clearTimeout(closer);
		closer = setTimeout(function() {
			boxOut();
		},globalTimeout);
		
	}
	
	
	function boxOver() {
		controller.clearBoxen(index);
		
		if(movingDesc == true) return;
		if(eventCatcher.getAttribute("state") != "" ) return;
		
		movingDesc = true;
		new Effect.Move('desc_'+index, { x: 0, y: 81, mode: 'relative', duration: 0.3 });
		
		eventCatcher.setAttribute("state", "out");
		setTimeout(function() {
			movingDesc = false;
		},500);
		
		clearTimeout(closer);
		closer = setTimeout(function() {
			boxOut();
		},globalTimeout);
	}
	
	this.boxOut = function() { boxOut(); }
	function boxOut() {

		if(movingDesc == true) return
		if(eventCatcher.getAttribute("state") != "out") return;
		
		movingDesc = true;
		
		new Effect.Move('desc_'+index, { x: 0, y: -81, mode: 'relative', duration: 0.3 });
		eventCatcher.setAttribute("state", "");
		setTimeout(function() {
			movingDesc = false;
		},500);	
	}	
	
	function click() {
		var boxIndex = boxNode.getAttribute("index");
		controller.selectBox(boxIndex);
		
		if(movingOpen!=true) {
			movingOpen = true;
			openMover.style.display = "block";
			Effect.Puff(openMover, { duration: 0.3 });
		}else {
			return;
		}
		
		if(document.getElementById("mLink_"+boxIndex)) {
			var link = document.getElementById("mLink_"+boxIndex);
			setTimeout(function() {
				counterUp();
				controller.openModul(link.href, "cl", modulId, typeId);
				movingOpen = false;
			},500);
		}
		else if(document.getElementById("a2Link_"+boxIndex)) {
			var link = document.getElementById("a2Link_"+boxIndex);
			if(IFIE) {
				alert("Der Inhalt dieses Moduls kann nur vom Microsoft Internet Explorer dargestellt werden!\nBitte verwenden Sie den Microsoft Internet Explorer.");
			}
			setTimeout(function() {
				counterUp()
				advancedCounter();
				controller.openModul(link.href, "noDisplay", modulId, typeId);
				movingOpen = false;
			},500);			
		}
		else if( document.getElementById("extLink_"+boxIndex) ) {
			setTimeout(function() {
				top.location.href = document.getElementById("extLink_"+boxIndex).href;
			},1000);
			movingOpen = false;
		}
		else {
			var link = document.getElementById("aLink_"+boxIndex);
			setTimeout(function() {
				counterUp();
				advancedCounter();
				controller.openModul(link.href, "cl800x600", modulId, typeId);
				movingOpen = false;
			},500);
		}		
	}

	function counterUp() {
		var pars = 'op=counterUp&modulId='+modulId;
		
		var myAjax = new Ajax.Request(
				ajaxurl, 
				{
					method: 'post', 
					parameters: pars
				});				
	}
	
	
	function advancedCounter() {
		var pars = 'op=countAdvancedModul&modulId='+modulId;
		
		var myAjax = new Ajax.Request(
				ajaxurl, 
				{
					method: 'post', 
					parameters: pars
				});				
	}
		
	
	this.setProgress = function(p) { setProgress(p); }
	function setProgress(p) {
		var width = Math.round( (146 / 100) * p );
		balken.style.width = width+"px";
	}
	
	this.openBox = function() { openBox(); }
	function openBox() {
		document.getElementById("unselect_"+index).style.display = "none";
		boxNode.onmousedown = click;
	}
	
	this.getModulId = function() {
		return modulId;
	}
	
	this.getTypeId = function() {
		return typeId;
	}
	
	this.setAjaxUrl = function(url) {
		ajaxurl = url;		
	}
	
}



