function ajaxFunction()
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
			return false;
			}
		}
	}

	return xmlHttp;
}
	
function updateMediaDiv(media_type, filepath, video_thumb, obj)
{
	var xmlHttp=ajaxFunction();

	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			if (xmlHttp.status==200)
			{
				document.getElementById('indicator').style.display='none';
				document.getElementById(obj).innerHTML=xmlHttp.responseText;
				
				if (media_type=='video')
				{
					if (video_thumb!='')
						str='&image='+video_thumb;
					else
						str='';
						
					var s1 = new SWFObject('include/player.swf','player','420','315','9');
					s1.addParam('allowfullscreen','true');
					s1.addParam('allowscriptaccess','always');
					s1.addParam('flashvars','file=../'+filepath+'&skin=include/nacht.swf'+str);
					s1.write(obj);
				}
				else if (media_type=='image')
				{
					var newImg=document.createElement('img');
					newImg.src=filepath;
					newImg.setAttribute('alt', filepath);
					newImg.setAttribute('border', 0);
					document.getElementById(obj).appendChild(newImg);
				}
	
			}
		}
		else
		{
			document.getElementById('indicator').style.display='block';
			document.getElementById(obj).innerHTML='';
		}
	}
	var params='?media_type='+media_type+'&filepath='+filepath;

  xmlHttp.open("GET", "updateMediaAjax.php"+params, true);
  xmlHttp.send(null);
}

function addLoadEvent(func) 
{ 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function') { 
		window.onload = func; 
	} else { 
	window.onload = function() { 
			if (oldonload) { 
				oldonload(); 
			} 
			func(); 
		} 
	} 
} 

function fixContentHeight()
{
	var main=document.getElementById('main');
	if (main.offsetHeight<500)
		main.style.height='500px';
}