/*function foldBox(box, boxclass, specialmode) {
	$(boxclass).slideUp("fast");
	$(box).slideToggle("slow");
	//alert($(box).attr("id"));
}*/
debug = 0;
openBox = '';
function foldBox(box,specialmode,boxclass){
	box = "#"+box;
	if(debug) alert(box);
	//$("#"+box).slideUp("slow");
	//$("#"+box).slideDown("slow");
	
	//alert("openBox ist = "+openBox);
	var alt = openBox;
	var vorgang = "";	
	if (openBox == ''){
		if(debug) alert("noch keine openBox:\nopenBox ("+openBox+") = ''");
		// box oeffnen
		setActiveBox(box);
		//activateBox(box);
		$(box).slideDown("slow");
	} else {
		//if ($(box).attr("id") == openBox){
		if(box == openBox) {
		// geoeffnete box nochmal angeklickt - einklappen
			if(specialmode) {
				vorgang = "$(box).attr(id) ("+$(box).attr("id")+") == openBox("+openBox+") und specialmode aktiv <br>==> return true";
				if(debug) alert(vorgang);
				return true;
			} else {
				vorgang = "$(box).attr(id) ("+$(box).attr("id")+") == openBox("+openBox+") ohne specialmode <br>==> $("+box+").slideUp(slow);";
				if(debug) alert(vorgang);
				$(box).slideUp("slow");
				//deactivateBox(box);
				setActiveBox(-1);
			}
		} else {
			// andere box angeklickt, alte einklappen und neue ausklappen
			vorgang = "$(box->"+box+").attr(id) ("+$(box).attr("id")+") != openBox(openBox->"+openBox+") <br>==> $(openBox->"+openBox+").slideUp(slow); und $(box->"+box+").slideDown(slow);";
			if(debug) alert(vorgang);
			$(openBox).slideUp("slow");
			//deactivateBox(openBox);
			setActiveBox(box);
			//activateBox(box);
			$(box).slideDown("slow");
		}
	}
	//$("#debug").html("vorher aktuell: "+alt+"<br>aktuelle box ("+box+")<br>openBox ("+openBox+") ist = $(box).attr(id) ("+$(box).attr("id")+")<br>kein specialmode("+specialmode+"), <br>---<br>vorgang: "+vorgang);
			
}

function activateBox(item){
	if(debug) alert("activateBox(item->"+item+")");
	$(item).addClass('activeBox');
	//Element.addClassName(item, 'activeBox');
}

function deactivateBox(item){
	$(item).removeClass('activeBox');
}
	
function setActiveBox(item){
	if(debug) alert("setActiveBox(item->"+item+")");
	if (item == -1) {
		if(debug) alert("item->"+item+" == -1 => openBox=''");
		openBox = '';
	} else {
		if(debug) alert("item->"+item+" != -1 => openBox='"+item);
		//openBox = "#"+$(item).attr("id");
		//openBox = "#"+item;
		openBox = item;
	}
	if(debug) alert("openBox = "+openBox);
}





function openShadowbox(content, player, source, boxwidth, boxheight, boxgallery, boxtitle, boxoversizehandle) {
	/*	content = 	html content ODER http-URL
		player =	img, swf, flv, qt (quicktime), wmp, iframe (externe websites etc), html (direkter html-code ueber content eingegeben
		source = 	leer lassen oder "div" (content aus einer DIV lesen)
		boxwidth =	breite
		boxheight =	hoehe
		boxgallery = gallery fuer vor / zurueck buttons
		boxtitle = 	titel / ueberschrift
		boxoversizehandle = none, resize, drag (fuer bilder)	*/
	
	if(!player) 
		player = "img";
	if(source == "div") {
		divsrc = content;
		content = document.getElementById(divsrc).innerHTML;
	}
	if(boxwidth == "full")
		boxwidth = $(document).width();
	if(boxheight == "full")
		boxheight = $(document).height();
		
	Shadowbox.open({
		content:    	content,
		player:    		player,
		width:			boxwidth,
		height:			boxheight,
		gallery: 		boxgallery,
		title:			boxtitle,
		handleOversize: boxoversizehandle
	});
}; 
