function swapProjectImage(callingElement)
{
	var sourceMain = document.getElementById("projectMainPicture").src;
	document.getElementById("projectMainPicture").src = callingElement.src;
	callingElement.src = sourceMain;
}

function changeProjectMenuImage(link, callingElementId, imageSrc)
{
	var elem = document.getElementById(callingElementId);
	
	if (link.className != "active")
	{
		elem.src = imageSrc;
	}
}

function displayProjectItem(item)
{
	var links = document.getElementById("projectMenu").getElementsByTagName("a");
	for (var i = 0; i < links.length; i++)
	{
		if (links[i].className == "active") // make old item inactive
		{
			var oldItem = links[i].firstChild.id.replace("projectMenuItem", "");
			if (document.getElementById("project" + oldItem) != null)
			{
				document.getElementById("project" + oldItem).style.display = "none";
			}
			
			links[i].firstChild.src = links[i].firstChild.src.replace("_active", "");
			links[i].className = "";
			break;
		}
	}

	// make item active
	document.getElementById("projectMenuItem" + item).parentNode.className = "active";
	if (document.getElementById("project" + item) != null)
	{
		document.getElementById("project" + item).style.display = "block";
		
		if (item != "Pictures" && item != "Youtube")
		{
			var funcName = "display" + item;
			eval(funcName + "()");
		}
	}
	
	return false;
}

function displayVideo()
{
	var div = document.getElementById("projectVideo");
	if (!isNaN(div.innerHTML))
	{
		var id = div.innerHTML;
		div.innerHTML = "";
		
		xml = document.createElement("root");
		
		var idNode = document.createElement("id");
		idNode.innerHTML = id;
		xml.appendChild(idNode);
		
		var playerNode = document.createElement("moviePlayer");
		playerNode.innerHTML = "flash/movieplayer_simple.swf";
		xml.appendChild(playerNode);
		
		_smi_movieplayer(div, xml);
		
		getWidget(div.id).addEventListener("loaded", function()
		{
			div.style.backgroundImage = "none";
		});
	}
}

function displayMap()
{
	var div = document.getElementById("projectMap").firstChild;
	if (/^[0-9.]+;[0-9.]+$/.test(div.innerHTML))
	{
		var location = div.innerHTML.split(";");
		div.innerHTML = "";
		
		var map = new GMap2(div);
	    map.setCenter(new GLatLng(location[0], location[1]), 14);
	    map.setUIToDefault();
	    
	    icon = new GIcon();
	    icon.image = dircat(g_baseDir, "images/icons/gmap_marker.png");
	    icon.iconSize = new GSize(33, 41);
	    icon.iconAnchor = new GPoint(16, 35);
	    icon.infoWindowAnchor = new GPoint(16, 0);
	    
	    var latLng = map.getCenter();
		var marker = new GMarker(latLng,
		{
			title: "Locatie",
			icon: icon,
			clickable: false,
			draggable: false
		});
		map.addOverlay(marker);
		
		div.parentNode.style.backgroundImage = "none";
	}
}

function runMap(location)
{
	var div = document.getElementById("projectMap").firstChild;
	div.innerHTML = location;
	displayMap();
}


