// <![CDATA[


var root = 
		(top.location.href.lastIndexOf("bruessel") == -1 
		&& top.location.href.lastIndexOf("localhost") == -1)
		?"/"
		:"/tomorrowfund/";


//-------------------------------------------------------------------------------------------------


function changePic(name,newpic){
	if (document.images) //mouseover supported
		document.images[name].src = newpic;
}


function changeImgSrc(lo_src, imgObj, isMouseOver){
	
	//alert("lo_src="+lo_src + " imgObj="+imgObj + " isMouseOver="+isMouseOver);

	if(!isMouseOver){ //trivial exit - muose out
		imgObj.src = lo_src;
		return;
	}


	/*******************************
	if mouse over:
	start
	*******************************/

	chunksArray = lo_src.split("/"); //split src in chunks

	//get lo version img-name
	fileName_lo = chunksArray[chunksArray.length-1]; //e.g. dummy.gif - is last item in array
	//alert("fileName_lo=" + fileName_lo); 

	//get hi version img-name
	rx = /(\w.+)\.(\w.+)/; //alphanum.alphanum
	rx.exec(fileName_lo);
	fileName_hi = RegExp.$1 + "_hi." + RegExp.$2; //e.g. dummy_hi.gif
	//alert("fileName_hi=" + fileName_hi);

	fileName_hi = fileName_hi.replace(/_lo_hi/, "_hi"); //evtl. if original name was dummy_lo.gif - pervent dummy_lo_hi.gif 
	//alert("fileName_hi=" + fileName_hi);

	hi_src = lo_src.replace(fileName_lo,fileName_hi);
	//alert("hi_src=" + hi_src);

	imgObj.src = hi_src;

	/*******************************
	if mouse over:
	end
	*******************************/	
}

//---------------------------------------------------------------------------------------------


function isIE(){
	return(navigator.appName.indexOf("Microsoft")!=-1);
}


//---------------------------------------------------------------------------------------------

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

//---------------------------------------------------------------------------------------------


function swapLayerContent(destLayer,srcLayer) {
	//alert(destLayer);
	if(document.layers) { // Netscape 4.x
		document.layers[destLayer].document.open();
		document.layers[destLayer].document.write("NS4");
		document.layers[destLayer].document.close();
	}
	else if(document.all) { // Internet Explorer 4+
		document.all[destLayer].innerHTML=document.all[srcLayer].innerHTML;
		document.all[srcLayer].innerHTML = "";
	}
	else if(document.getElementById) { // W3C konform zB. Opera, Mozilla, Netscape 6+
		//var temp=document.createTextNode(text);
		var div1 = document.getElementById(destLayer);
		var div2 = document.getElementById(srcLayer);
		//alert("destLayer=" + destLayer);
		//alert("srcLayer=" + srcLayer);
		//alert("div1=" + div1);
		//alert("div2=" + div2);
		while (div1.hasChildNodes()) {
			div1.removeChild(div1.lastChild);
		}
		div1.appendChild(div2.cloneNode(true));
		while (div2.hasChildNodes()) {
			div2.removeChild(div2.lastChild);
		}
	}
}

//---------------------------------------------------------------------------------------------
function changeObjectVisibility(objectId, newVisibility) {
    var styleObject = getStyleObject(objectId, document);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	return false;
    }
} 

function getStyleObject(objectId) {
	if(document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId).style;
	} else if (document.all && document.all(objectId)) {
		return document.all(objectId).style;
	} else if (document.layers && document.layers[objectId]) {
		return getObjNN4(document,objectId);
	} else {
		return false;
	}
} 


function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}



//--------------------------------------------------------------------------------------------------


function openLink(l) {
	chunksArray = l.split("/"); //hier kommt ne url rein a la http://server/tfm/395/index.aspx
	var tabId = 0;

	//selektiere die tabId aus dem link
	for(i=0;i<chunksArray.length;i++){
		//alert("is numeric=" + !isNaN(chunksArray[i]));
		chunk = chunksArray[i];
		if(chunk!= null && chunk != "" && !isNaN(chunksArray[i])){
			//alert("tabId=" + chunksArray[i]);
			tabId = 1*chunksArray[i];
			break;
			}
	}

	//alert(tabId);
	switch(tabId){
		case 483: 
			openKontakt();
			return;
		case 437: 
			openImpressum();
			return;
		case 439: 
			openSitemap();
			return;
		case 440: 
			openSuche();
			return;
		case 441: 
			openDownloads();
			return;
		case 442: 
			openFAQ('');
			return;
		case 515:
			openGlossar();
			return;

		case 463:
			popupPerson('Sylvia Granowski');
			return;
		case 464:
			popupPerson('George Weinberg');
			return;
		case 465:
			popupPerson('Gerwin');
			return;
		case 466:
			popupPerson('Willoughby');
			return;
		case 467:
			popupPerson('Brownlow');
			return;
		case 468:
			popupPerson('Weden');
			return;
		case 469:
			popupPerson('Dozel');
			return;
		case 470:
			popupPerson('Berman');
			return;
		case 471:
			popupPerson('Gilbert');
			return;
		case 472:
			popupPerson('Kolber');
			return;
	}


	if(top.opener != null && !top.opener.closed)
		top.opener.location.href = l;
	else
		top.location.href = l;
	
	
}

//--------------------------------------------------------------------------------------------------

function popup(URL,popupname,b,h,scrollbars) {
	var PopUpName = popupname || 'PopUp';
	var breite = b || 410;
	var hoehe = h || 450;
	var ScrollBars = scrollbars || 'auto';
	var xPos = (screen.availWidth - breite) / 2
	var yPos = (screen.availHeight - hoehe ) / 2
	window.open(URL,PopUpName,'width='+breite+',height='+hoehe+',scrollbars='+ScrollBars+',toolbar=no,menubar=no,screenX='+xPos+',screenY='+yPos+',left='+xPos+',top='+yPos);
}



//--------------------------------------------------------------------------------------------------

function faq(anchorName) {
	openFAQ(anchorName);
}

//--------------------------------------------------------------------------------------------------

function openFAQ(anchorName) {
	openTabInContent('faq', 0);
	//popup(root + 'TFMPopups/popupLoader/default.aspx?tabName=faq', 'faq', 400, 600, 'yes');
}

//--------------------------------------------------------------------------------------------------

function glossar(anchorName) {
	//alert("wird später zu glossar/" + anchorName + " verlinkt");
	popup(root + 'TFMPopups/popupLoader/default.aspx?tabName=glossar#'+anchorName, 'glossar', 464, 422, 'no');
}

//--------------------------------------------------------------------------------------------------

function linkFromFlash(tabId) {
	openTabInContent("", tabId);
	//alert("wird später zu tab=" + tabId + " verlinkt");
}

//--------------------------------------------------------------------------------------------------

function openGlossar(anchorName) {
	glossar(anchorName);
}

//--------------------------------------------------------------------------------------------------

function openDownloads() {
	openTabInContent('alldownloads', 0);
	//popup(root + 'TFMPopups/popupLoader/default.aspx?tabName=alldownloads', 'downloads', 400, 600, 'yes');
}

//--------------------------------------------------------------------------------------------------

function openKontakt() {
	openTabInContent('kontakt', 0);
	//popup(root + 'TFMPopups/popupLoader/default.aspx?tabName=kontakt', 'kontakt', 400, 600, 'yes');
}

//--------------------------------------------------------------------------------------------------

function openImpressum() {
	openTabInContent('impressum', 0);
	//popup(root + 'TFMPopups/popupLoader/default.aspx?tabName=impressum', 'impressum', 400, 600, 'yes');
}

//--------------------------------------------------------------------------------------------------

function openSitemap() {
	popup(root + 'TFMPopups/popupLoader/default.aspx?tabName=sitemap', 'sitemap', 464, 422, 'no');
}

//--------------------------------------------------------------------------------------------------

function openSuche() {
	popup(root + 'TFMPopups/popupLoader/default.aspx?tabName=suche', 'suche', 464, 422, 'no');
}

//--------------------------------------------------------------------------------------------------

function popupPerson(personenTabName) {
	popup(root + 'TFMPopups/popupLoader/default.aspx?tabName='+personenTabName, 'personen', 464, 422, 'no');
}

//--------------------------------------------------------------------------------------------------

function openEn() {
	top.location.href = root + 'default.aspx?alias=tfm_en';
}
function openDe() {
	top.location.href = root + 'default.aspx?alias=tfm_de';
}



//--------------------------------------------------------------------------------------------------

function openTabInContent(tabName, tabId) { //either name or id of the tab
	if(tabId>0)
		top.location.href = root + 'TFMRedirector/default.aspx?tabId='+tabId;
	else
		top.location.href = root + 'TFMRedirector/default.aspx?tabName='+tabName;
}

//--------------------------------------------------------------------------------------------------




function fadeOut(el){
      Effect.Fade(el);
}

function fadeIn(el){
      Effect.Appear(el);
}

function slideUp(el){
      Effect.BlindUp(el);
}

function slideDown(el){
      Effect.BlindDown(el);
}

function slideUpDown(el){
	if(Element.getStyle(el, 'display') == "none")
		slideDown(el);
	else
		slideUp(el);

     // alert(Element.getOpacity(el));
	  //alert(Element.getStyle(el, 'display'));
}

function fadeInOut(el){
	if(Element.getStyle(el, 'display') == "none")
		fadeIn(el);
	else
		fadeOut(el);

     // alert(Element.getOpacity(el));
	  //alert(Element.getStyle(el, 'display'));
}



// ]]>
