
/*===== Funktionen f&uuml;r die Accordionbox ===========================================*/

function openAcc (klicked) {
	var animDuration = 0.4;
	
	klicked = $(klicked);
	if (klicked) {
		var myBlock = klicked.up(1);
		if (myBlock.hasClassName('open')) {
			return; // Nix zu tun, is schon offen
		}
		
		var myACC = myBlock.up(0);
		var allBlocks = myACC.select('.accBlock');
		var currentBlock;
		var accbottom = myACC.down('.accbottom');
		if (!accbottom) accbottom = myACC.down('.accbottom2');
		
		for (var i=0; i<allBlocks.length; i++) {
			currentBlock = allBlocks[i];
			//alert(currentBlock.className+' '+currentBlock.hasClassName('open'));
			if (currentBlock == myBlock) {
				currentBlock.addClassName('open');
				if (i==allBlocks.length-1) {
					accbottom.className = 'accbottom2';
				} else {
					if (isIE6()) {
						accbottom.className = 'accbottom';
					} else {
						accbottom.id = 'bottom_id_'+Math.round(Math.random()*10000);
						window.setTimeout("$('"+accbottom.id+"').className = 'accbottom'", animDuration * 1000 - 50);
					}
				}
				new Effect.SlideDown(currentBlock.down('.accContent'), {duration:animDuration});
			} else if (currentBlock.hasClassName('open')) {
				currentBlock.removeClassName('open');
				new Effect.SlideUp(currentBlock.down('.accContent'), {duration:animDuration});
			}
		}
	}
}

function isIE6 () {
	return document.all && !window.XMLHttpRequest;
}

/*===== Funktionen f&uuml;r die Fonds&uuml;bersicht ===========================================*/

var lastFondsDetailsOpen = null;
function openFondsDetails (wknID) {
	contentRow = $('wkn_'+wknID);
	headRow = $('wkn_'+wknID+'_h');
	
	if (contentRow) {
		var animDuration = 0.4;
		var col1 = contentRow.down('.tc12');
		var col2 = contentRow.down('.tc3');
		var col1Inner = col1.down();
		var col2Inner = col2.down();
				
		
		if (col1.visible()) {
			col1.show();
			col2.show();
			headRow.removeClassName('open');
			new Effect.SlideUp(col1Inner, {duration:animDuration});
			new Effect.SlideUp(col2Inner, {duration:animDuration});
			window.setTimeout('hideFondsDetailsComplete("'+wknID+'")',animDuration * 1000);
			lastFondsDetailsOpen = null;
		} else {
			headRow.addClassName('open');
			col1Inner.hide();
			col2Inner.hide();
			col1.show();
			col2.show();
			new Effect.SlideDown(col1Inner, {duration:animDuration});
			new Effect.SlideDown(col2Inner, {duration:animDuration});
			
			if (lastFondsDetailsOpen) {
				openFondsDetails(lastFondsDetailsOpen);
			}
			lastFondsDetailsOpen = wknID;
		}
	}
}

function hideFondsDetailsComplete (wknID) {
	contentRow = $('wkn_'+wknID);
	if (contentRow) {
		var col1 = contentRow.down('.tc12');
		var col2 = contentRow.down('.tc3');
		col1.hide();
		col2.hide();
	}
}

function checkOpenFondsDetails () {
	var wknID = window.location.hash.substr(1);
	if ($('wkn_'+wknID)) {
		openFondsDetails(wknID);
	}
}

/*===== Funktionen f&uuml;r die Manager details ============================================*/

var lastManagerDetailsOpen = null;

function openManagerDetails (managerID, instant) {
	var newManager = $('details_'+managerID);
	if (newManager) {
		var animDuration = 0.1;
		
		if (managerID != lastManagerDetailsOpen) {
			var lastManager = $('details_'+lastManagerDetailsOpen)
			if (instant) {
				if (lastManager) {lastManager.hide();}
				newManager.show();
			} else {
				var delayTime = 0;
				if (lastManager) {
					delayTime = animDuration + 0.1
					new Effect.Fade(lastManager, {duration:animDuration});
				}
				new Effect.Appear(newManager, {duration:animDuration, delay:delayTime});
			}
			lastManagerDetailsOpen = managerID;
		}
	}
}

function checkOpenManagerDetails () {
	var manager = window.location.hash.substr(1);
	if (!$('details_'+manager)) {
		manager = 'none';
	}
	openManagerDetails(manager, true);		
	return manager;
}

/*===========================================================================================*/

/**
 * KLappt einen Textblock aus oder wieder ein (Seite European Growth Funds
 */
function showMore (foldID) {
	var fold = $(foldID);
	var animDuration = 0.7;
	var btn;
	if (fold) {
		
		if (fold.visible()) {
			btn = fold.next('a.foldButtonOpen');
			btn.className = 'foldButton';
			btn.innerHTML = 'weiterlesen';
			new Effect.SlideUp(fold, {duration:animDuration});
		} else {
			btn = fold.next('a.foldButton');
			btn.className = 'foldButtonOpen';
			btn.innerHTML = 'schlie&szlig;en';
			new Effect.SlideDown(fold, {duration:animDuration});
		}
		btn.blur();
	}
}



function openPuzzle () {
	var win = window.open('/fonds/fondsimfokus/aktienfonds_europa/popup_european_growth_puzzle.html', 'Puzzle', 'width=780,height=700,resizable=yes,scrollbars=no,status=no,location=no,menubar=no,toolbar=no');
	win.focus();
	return;
}
