/* Ultimater's edited version of:
   http://jibbering.com/2002/4/httprequest.html
   to serve IE7 with XMLHttpRequest instead of ActiveX */

var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
	try
	{
		xmlhttp = new XMLHttpRequest();
	}catch(e)
	{
		xmlhttp=false;
 	}
}

/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
if (!xmlhttp){
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
}
@end @*/

if(!xmlhttp && window.createRequest)
{
	try
	{
		xmlhttp = window.createRequest();
	}catch(e)
	{
		xmlhttp=false;
	}
}

/* Ultimater's edited version of:
   http://javascript.internet.com/ajax/ajax-navigation.html */

var please_wait = "Please wait...";

function open_url(url, targetId)
{
	if(!xmlhttp)
		return false;
	
	var e=document.getElementById(targetId);
	
	if(!e)
		return false;
	
	if(please_wait)
		e.innerHTML = please_wait;

	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = function()
									{
										response(url, e);
									}
    
	try
	{
		xmlhttp.send(null);
	}catch(l)
	{
		while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
		e.appendChild(document.createTextNode("request failed"));
	}
}

function response(url, e)
{
	if(xmlhttp.readyState != 4)
		return;
	
	var tmp= (xmlhttp.status == 200 || xmlhttp.status == 0) ? xmlhttp.responseText : "Ooops!! A broken link! Please contact the webmaster of this website ASAP and give him the following error code: " + xmlhttp.status+" "+xmlhttp.statusText;
	var d=document.createElement("div");
	d.innerHTML=tmp;
	
	setTimeout
	(
		function()
		{
			while(e.firstChild)e.removeChild(e.firstChild);//e.innerHTML="" the standard way
			e.appendChild(d);
		},10
	)
}

//function replace(divId, newContent)
//{
//	document.getElementById(divId).innerHTML = newContent;
//}


function check_required_acri(accreditationForm) {
	var requiredFields = accreditationForm.required.value.split("|");
	var errorString = '';
	for (var i=0; i<requiredFields.length; i++) {
		var parts = requiredFields[i].split(",");
		var field = parts[0]; var title = parts[1];
		for (var j=0; j<accreditationForm.elements.length; j++) {
			var myElement = accreditationForm.elements[j];
			var isNull = false;
			if (myElement.name == field && myElement.style.display != "none") {
				if (myElement.type == "select-one" || myElement.type == "select-multiple") {
					if ((myElement.options[myElement.selectedIndex].value == null || myElement.options[myElement.selectedIndex].value == '') && errorString.indexOf(title) == -1) {
						isNull = true;
					}
				} else if ((myElement.value == null || myElement.value.search(/\w/) == -1) && errorString.indexOf(title) == -1) {
					isNull = true;
				}
				
				if (isNull) {
					errorString += title + ", ";
					if (document.getElementById('label_'+myElement.name)) { document.getElementById('label_'+myElement.name).className="er"; }
					myElement.className="fieldw";
				} else {
					if (document.getElementById('label_'+myElement.name)) {
						document.getElementById('label_'+myElement.name).className="s1";
					}
					myElement.className="s1";
				}
			}
		}
	}
	if (errorString != '') {
		errorString = errorString.slice(0,errorString.length-2);
		window.alert("Please fill in all the following fields:\n\n"+errorString)
		return false;
	}
	else {
		return true;
	}
}


		
function check_required(exhibitorForm) {
	var requiredFields = exhibitorForm.required.value.split("|");
	var errorString = '';
	for (var i=0; i<requiredFields.length; i++) {
		var parts = requiredFields[i].split(",");
		var field = parts[0]; var title = parts[1];
		for (var j=0; j<exhibitorForm.elements.length; j++) {
			var myElement = exhibitorForm.elements[j];
			var isNull = false;
			if (myElement.name == field && myElement.style.display != "none") {
				if (myElement.type == "select-one" || myElement.type == "select-multiple") {
					if ((myElement.options[myElement.selectedIndex].value == null || myElement.options[myElement.selectedIndex].value == '') && errorString.indexOf(title) == -1) {
						isNull = true;
					}
				} else if ((myElement.value == null || myElement.value.search(/\w/) == -1) && errorString.indexOf(title) == -1) {
					isNull = true;
				}
				
				if (isNull) {
					errorString += title + ", ";
					if (document.getElementById('label_'+myElement.name)) { document.getElementById('label_'+myElement.name).className="er"; }
					myElement.className="fieldw";
				} else {
					if (document.getElementById('label_'+myElement.name)) {
						document.getElementById('label_'+myElement.name).className="s1";
					}
					myElement.className="s1";
				}
			}
		}
	}
	if (errorString != '') {
		errorString = errorString.slice(0,errorString.length-2);
		window.alert("De volgende velden moeten nog ingevuld worden:\n\n"+errorString)
		return false;
	}
	else {
		return true;
	}
}
			
			function reloadPage()
			{
				var cm = document.exhibitorForm.company.value;
				var cp = document.exhibitorForm.contactperson.value;
				var a = document.exhibitorForm.adress.value;
				var z = document.exhibitorForm.zipcode.value;
				var r = document.exhibitorForm.residence.value;
				var p = document.exhibitorForm.phonenumber.value;
				var mp = document.exhibitorForm.mobilephonenumber.value;
				var e = document.exhibitorForm.email.value;
				var w = document.exhibitorForm.website.value;
				var se = document.exhibitorForm.sector.value;
				var su = document.exhibitorForm.surface.value;
				var cmm = document.exhibitorForm.comments.value;
				
				open_url('misc/exhibitor/newExhibitor.php?company='+cm+'&contactperson='+cp
						+'&adress='+a+'&zipcode='+z+'&residence='+r+'&phonenumber='+p
						+'&mobilephonenumber='+mp+'&email='+e+'&website='+w
						+'&sector='+se+'&surface='+su+'&comments='+cmm,'content');
			}
	



