function changePicture(tochange,src, trigger)
	{

	//change tab image and reset others
		var i = 1;
		while (document.getElementById(tochange+'_'+i))
			{
				document.getElementById(tochange+'_'+i).className = 'project_image_tab';
				i++;
			}

		document.getElementById(trigger).className = 'project_image_tab_current';

	//change project image
		document.getElementById(tochange).src = src;

	}
	 
function navigate(item_id, section)
{
	if(document.getElementById('right'))
		{
			//alert("right != current");
			if (document.getElementById('left'))
			{
				//alert("2 != current -> 3 = current");
				document.getElementById('current').id = 'left2';
			}
			else
			{
				//alert("2 = current");
				document.getElementById('current').id = 'left';
			}
		}
		else
		{
				//alert("1 = current");
				document.getElementById('current_right').id = 'right';
		}

	if (item_id == 'right')
	{
		document.getElementById(item_id).id = 'current_right';
	}
	else 
	{
		document.getElementById(item_id).id = 'current';
	}
	
	var rand = Math.random(9999);

	if (section == 'home')
		{
			var toGet = "home.html?rand=" + rand;
			callAHAH(toGet, 'target', 'Loading...', 'Fehler!', '');	
		}
		else if (section == 'work')
		{
			var toGet = "project.html?rand=" + rand;
			callAHAH(toGet, 'target', 'Loading...', 'Fehler!', 'proj');
		}
		else if (section == 'contact')
		{
			var toGet = "contact.html?rand=" + rand;
			callAHAH(toGet, 'target', 'Loading...', 'Fehler!', '');				
		}
}


function navigateproject(item_id, section)
{
	if(document.getElementById('work_0'))
		{
			if (document.getElementById('work_1'))
			{
				if (document.getElementById('work_2'))
				{
					document.getElementById('work_current').id ='work_3';
				}
				else
				{
					document.getElementById('work_current').id = 'work_2';
				}
			}
			else
			{
				document.getElementById('work_current').id = 'work_1';
			}
		}
		else
		{
			document.getElementById('work_current').id = 'work_0';
		}

	document.getElementById(item_id).id = 'work_current';


	var rand = Math.random(9999);
	if (section == 'interface')
		{
			var toGet = "project/interface.html?rand=" + rand;
		}
		else if (section == 'web')
		{
			var toGet = "project/web.html?rand=" + rand;
		}
		else if (section == 'app')
		{
			var toGet = "project/app.html?rand=" + rand;
		}
		else if (section == 'physical')
		{
			var toGet = "project/physical.html?rand=" + rand;
		}		
	
	callAHAH(toGet, 'project_target', 'Loading...', 'Fehler!','');	
}

function callAHAH(url, pageElement, callMessage, errorMessage, projLoad)
{
	document.getElementById("load_feedback").style.visibility = "visible";
	try
		{
		req = new XMLHttpRequest();
		}
	catch(e)
		{
			try
				{
				req = new ActiveXObject("Msxml2.XMLHTTP");
				}
			catch (e)
				{
					try
						{
							req = new ActiveXObject("Microsoft.XMLHTTP");						
						}
					catch (e)
						{
								req = false;							
						}
				}
		}
	req.onreadystatechange = function() {responseAHAH(pageElement, errorMessage, projLoad);};
	req.open("GET",url,true);
	req.send(null);
}

function responseAHAH(pageElement, errorMessage, projLoad)
{
	if(req.readyState == 4)
	{
		if(req.status == 200)
		{
		output = req.responseText;
		document.getElementById(pageElement).innerHTML = output;
		document.getElementById("load_feedback").style.visibility = "hidden";
			if (projLoad == 'proj')
			{
				navigateproject('work_0','interface');
			}
		}
		else {
		document.getElementById(pageElement).innerHTML = errorMessage+"n"+responseText;
		}
	}
}