function open_win(location,title){
	win = window.open(location, title, 'width=700, height=700, resizable=yes, scrollbars=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, copyhistory');
	win.focus();
}

function load(){
	hide_details();
	for (var i = 0; i < document.links.length; ++i){
		if (document.links[i].target){
			document.links[i].onclick=function(){open_win(this,this.text); return false};
		}
	}
}

function hide_details(){
	$$('tr.beschreibung',
	'tr.knr', 'tr.dozent', 'tr.ort', 'tr.datum', 'tr.tage', 'tr.zeit', 'tr.stunden', 'tr.kosten', 'tr.teilnmax', 'tr.material', 'tr.status', 'tr.buchen').invoke('hide');
}
function show_detail(knr){
	try {Element.show('beschreibung_' + knr)} catch(e){};
	try {Element.show('knr_' + knr)} catch(e){};
	try {Element.show('dozent_' + knr)} catch(e){};
	try {Element.show('ort_' + knr)} catch(e){};
	try {Element.show('datum_' + knr)} catch(e){};
	try {Element.show('tage_' + knr)} catch(e){};
	try {Element.show('zeit_' + knr)} catch(e){};
	try {Element.show('stunden_' + knr)} catch(e){};
	try {Element.show('kosten_' + knr)} catch(e){};
	try {Element.show('teilnmax_' + knr)} catch(e){};
	try {Element.show('material_' + knr)} catch(e){};
	try {Element.show('status_' + knr)} catch(e){};
	try {Element.show('buchen_' + knr)} catch(e){};
}

function showv(knr){
	if ($$('.active')[0] == $('headline_' + knr)){
		hide_details();
		$$('.active').map(function(elm){elm.removeClassName('active')});
	}else{
		hide_details();
		$$('.active').map(function(elm){elm.removeClassName('active')});
		show_detail(knr);
		$('headline_' + knr).addClassName('active');
		setSize();		
	}
}

// this returns the the document WITHIN the iFrame
function getIFramedDocument(aID){ 
	var rv = null;
	if (parent != self){
		return document;
	}else{
		// if contentDocument exists, W3C compliant (Mozilla) 
		if (document.getElementById(aID).contentDocument){ 
			rv = document.getElementById(aID).contentDocument; 
		} else { 
			// IE 
			rv = document.frames[aID].document; 
		} 
	}
	return rv; 
}

function setIframHeight(iframe,iframe_height){
	if (iframe_height > 0){
		add_height = 100;		
	}else{
		add_height = 0;
	}
	// for Firefox:
	if (iframe.setStyle){
		iframe.setStyle({ 'height' : iframe_height + add_height + 'px' });
	// for IEs:
	}else{
		iframe.style.setAttribute("height", iframe_height + add_height, "false");
	}
}

// set the size of the named iframe.
function setSize() {
	// $$('#inhalt *').invoke('hide'); Element.show('kufer_iframe');
	// $$('#inhalt *').reject(function(elm){ return elm.match('iframe'); }).invoke('hide');
	var iframe = parent.document.getElementById('kufer_iframe')
	if (iframe){
		if (getIFramedDocument('kufer_iframe').getElementById('hauptseite')){
			if (document == parent.document){
				$$('#inhalt *').reject(function(elm){ return elm.match('iframe'); }).invoke('remove');				
			}
			var iframe_height = getIFramedDocument('kufer_iframe').getElementById('hauptseite').offsetHeight;
			setIframHeight(iframe,iframe_height)
			// remove scrollbar:
			iframe.scrolling = "no"
			iframe.scroll = "no"
		}else{
			setIframHeight(iframe,0)
		}
	}
}

