var bustcachevar=1 
var loadedobjects=""
var bustcacheparameter=""

function ajaxpage(url, containerid)
{
	var mypage_request = false
	if (window.XMLHttpRequest)
		mypage_request = new XMLHttpRequest()
	else if (window.ActiveXObject)
	{ 
		try
		{
			mypage_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e)
		{
			try
			{
				mypage_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else
		return false
	mypage_request.onreadystatechange=function()
	{
		loadpage(mypage_request, containerid)
	}
	if (bustcachevar)
		bustcacheparameter = (url.indexOf("?") != -1)? "&" + new Date().getTime() : "?" + new Date().getTime()
	mypage_request.open('GET', url + bustcacheparameter, true)
	mypage_request.send(null)
}

function loadpage(mypage_request, containerid)
{
	if (mypage_request.readyState == 4 && (mypage_request.status==200 || window.location.href.indexOf("http")==-1))
	{
		allText = mypage_request.responseText;
		lines = mypage_request.responseText.split("\n");
		var mytxt = "";
		
		mytxt += "<img class='imageHeader' src='images/nieuwsH1.png' alt='Nieuws' \/>";
		mytxt += "<p>";
		for (i = 0; i < lines.length; i++)
		{
			if (lines[i].match("<img src"))
			{
				mytxt += lines[i];
			}
			else if (lines[i].match("http://"))
			{
				words = lines[i].split(" ");
				for (j = 0; j < words.length; j++)
				{
					if (words[j].match("http://"))
					{
						mytxt += "<a href='" + words[j] + "' target='_blank'>" + words[j] + "<\/a> ";
					}
					else
					{
						mytxt += words[j] + " ";
					}
				}
			}
			else if (trim(lines[i]) == "")
			{
				mytxt += "<\/p><p>";
			}
			else if (lines[i].charAt(lines[i].length - 1) == "." || lines[i].charAt(lines[i].length - 1) == ":" || lines[i].charAt(lines[i].length - 1) == "!" || lines[i].charAt(lines[i].length - 1) == "?")
			{
				mytxt += lines[i] + "<br \/>";
			}
			else if (lines[i].match("Januari") || lines[i].match("Februari") || lines[i].match("Maart") || lines[i].match("April") || lines[i].match("Mei") || lines[i].match("Juni") || lines[i].match("Juli") || lines[i].match("Augustus") || lines[i].match("September") || lines[i].match("Oktober") || lines[i].match("November") || lines[i].match("December"))
			{
				mytxt += "<h2>" + lines[i] + "<\/h2>";
			}
			else 
			{
				mytxt += lines[i];
			}
		}
		mytxt += "<\/p>";
		
		$(containerid).innerHTML = mytxt;
		initGroup();
		initPages();
		openPage(0);
		setTimeout(loadImages(), 0);
	}
}

function trim(value) 
{
  value = value.replace(/^\s+/,''); 
  value = value.replace(/\s+$/,'');
  return value;
}
