// JavaScript Document
var xmlhttp

function configurator()
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}

	var str = "";
	if(document.getElementById('product').value != '') str += "product="+document.getElementById('product').value+"&";
	if(document.getElementById('hoogte').value != '') str += "hoogte="+document.getElementById('hoogte').value+"&";
	if(document.getElementById('ventilator').value != '') str += "ventilator="+document.getElementById('ventilator').value+"&";
	if(document.getElementById('kleur').value != '') str += "kleur="+document.getElementById('kleur').value+"&";
	if(document.getElementById('bedrukking').value != '') str += "bedrukking="+document.getElementById('bedrukking').value+"&";
	if(document.getElementById('accessoires'))
	{
		accessoires = '';
		iBox = parent.document.formBestellen.accessoires.length;
		//alert(iBox);
		
		for (i=0; i<iBox; i++) 
		{
			if(parent.document.formBestellen.accessoires[i].checked) 
			{
				accessoires += parent.document.formBestellen.accessoires[i].value + '|';
			}
		}
		
		if(accessoires != '')
		{
			str += 'accessoires='+accessoires+"&"
		}
	}
	
	str += "submit="+'true'+"&";

	if(window.location.hostname=='airlusion.dev.local') 
	{
		var url="http://airlusion.dev.local/modules/configurator/configurator.php";
	}
	else
	{
		var url="http://"+window.location.hostname+"/modules/configurator/configurator.php";
	}
	url=url+"?"+str;
	
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChanged()
{
	if(xmlhttp.readyState==4)
	{
		var divConfigurator
			divConfigurator = document.getElementById('configurator');

			divConfigurator.innerHTML=xmlhttp.responseText;
	}
}

function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	
	if (window.ActiveXObject)
	{
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	return null;
}
