function initTeam(){
	var m = document.getElementById("content");
	var d = m.getElementsByTagName("div");
    var toc = document.getElementById("toc");
	var a = toc.getElementsByTagName("a");
	document.lastTarget = null;
    for (var i=1; i<d.length; i++) {
		if (location.hash=="") {
			if (i > 1) d[i].style.display="none";
			a[0].className = "active";
		}
        if (d[i].id && (d[i].id != "toc")) {						
            if (location.hash==("#" + d[i].id)) {
                d[i].style.display="block";
                document.lastTarget=d[i];
            } 
            for (var j=0; j<a.length; j++) {
                if (a[j].hash==("#" + d[i].id)) a[j].targetEl = d[i]; 
					   a[j].onclick = function() {						
						for (var k=1; k<d.length; k++) {
							d[k].style.display="none";
						}
						for (var l=0; l<a.length; l++) {
							a[l].className = "";
						}
						this.className = "active";
                    	if (document.lastTarget) document.lastTarget.style.display="none";
                    	if (this.targetEl) this.targetEl.style.display="block"; 
						document.lastTarget=this.targetEl;
                    	return false;
                }
            }
        }
    }
}

function initFundJump(){
	var form = document.getElementById("fundjump");
	addAnEvent(form, "submit", openDir);
}
function openDir() { 
	var newIndex = this.fundselect.selectedIndex;
	if (newIndex != 0) {
		cururl = this.fundselect.options[newIndex].value; 
		window.location.assign(cururl); 
	}
    return false;
} 

function initTransactions(){
	var links = document.getElementById("news").getElementsByTagName("a");
	for (var i=0; i<links.length; i++) {
		if (links[i].className == "transactionhd") addAnEvent(links[i],'click',toggleTrans);
	}
}
function toggleTrans(){
	var id = this.href.split("#");
	id = id[1];
	var trans = document.getElementById(id)
	if (trans.style.display=="block") {
		trans.style.display="none";
		this.className = "transactionhd";
	} else {
		trans.style.display="block";
		this.className += " open";	
	}
	return false;
}


function addAnEvent(target, eventName, functionName){
	eval('target.on'+eventName+'=functionName');
}

function initPage(){
	if (document.getElementById){
		if (document.getElementById("properties-results") || document.getElementById("news")) initLightbox();		
		if (document.getElementById("about-team")) initTeam();
		if (document.getElementById("fundjump")) initFundJump();
		if (document.getElementById("news")) initTransactions();
		if (document.getElementById("googlemap")) load();		
	}
}

function uninitPage(){
	if (document.getElementById){
		if (document.getElementById("googlemap")){
			var map = new GMap(document.getElementById("googlemap")); 

			//map.addControl(new GLargeMapControl()); 
			//map.removeControl(GLargeMapControl()); 
			   map.removeControl(GLargeMapControl()); 
			   map.removeControl(GSmallMapControl()); 
			   map.removeControl(GSmallZoomControl()); 
			   map.removeControl(GMapTypeControl()); 
			//Nullify? setMapType(null); Test 
			   map.setMapType(null) 
			   map.closeInfoWindow(); 
			   map.clearOverlays();
			GUnload();	
		} 
		
	}
}

window.onload=initPage;
window.onunload=uninitPage;