
function profile_changed(selected)
{
	if (selected)
	{
		var html = document.getElementById('dimension').innerHTML;
		html = "<p>Select core rail size.</p><select id='dimension' name='dimenstion' onchange='dimension_changed(this.options[this.selectedIndex].value); return false;'>";
		html += '<option value="">Select a dimension</option>';
	
		if ( selected == 'Standard')
		{
			html += '<option value="30 x 8">30 x 8</option>';
			html += '<option value="35 x 8">35 x 8</option>';
			html += '<option value="40 x 8">40 x 8</option>';
			html += '<option value="50 x 8">50 x 8</option>';
			html += '<option value="60 x 8">60 x 8</option>';
		}
		else if ( selected == 'R40')
		{
			html += '<option value="R40 (25 x 15)">R40 (25 x 15)</option>';	
		}
		else if ( selected == 'R55')
		{
			html += '<option value="R55 (40 x 8)">R55 (40 x 8)</option>';	
		}
	
		html += "</select>";
		document.getElementById('dimension').innerHTML = html;
		document.getElementById('colour').innerHTML = '';
	}
	else
	{
		document.getElementById('dimension').innerHTML = '';
		document.getElementById('colour').innerHTML = '';
	}
}

function dimension_changed(selected)
{
	if (selected)
	{
	//alert(selected);
		var html = document.getElementById('colour').innerHTML;
		html = "<p>Select colour.</p><select id='colour' name='colour'>";
		html += '<option value="">Select a colour</option>';
	
		if ( selected == '30 x 8')
		{
			html += '<option value="Black 1309 (Ral 9017)">Black 1309 (Ral 9017)</option>';
		}
		else if ( selected == '35 x 8')
		{
			html += '<option value="Black 1309 (Ral 9017)">Black 1309 (Ral 9017)</option>';
		}
		else if ( selected == '40 x 8')
		{
			html += '<option value="Black 1309 (Ral 9017)">Black 1309 (Ral 9017)</option>';
			html += '<option value="White 814 (Ral 9003)">White 814 (Ral 9003)</option>';
			html += '<option value="Grey 1116 (Ral 7004)">Grey 1116 (Ral 7004)</option>';
			html += '<option value="Blue 1208 (Ral 5002)">Blue 1208 (Ral 5002)</option>';
			html += '<option value="Red 1000 (Ral 3020)">Red 1000 (Ral 3020)</option>';
			html += '<option value="Red 1307 (Ral 3002)">Red 1307 (Ral 3002)</option>';
			html += '<option value="Burgundy 1414 (Ral 2004)">Burgundy 1414 (Ral 2004)</option>';
			html += '<option value="Green 1222 (Ral 6005)">Green 1222 (Ral 6005)</option>';
			html += '<option value="Green 1120 (Ral 6000)">Green 1120 (Ral 6000)</option>';
			html += '<option value="Brown 1701 (Ral 8016)">Brown 1701 (Ral 8016)</option>';
			html += '<option value="Gold 652 (Ral 7008)">Gold 652 (Ral 7008)</option>';
			html += '<option value="Silver 651 (Ral 9007)">Silver 651 (Ral 9007)</option>';
			html += '<option value="Yellow (Ral 1018)">Yellow (Ral 1018)</option>';
			html += '<option value="Light Oak 9551">Light Oak 9551</option>';
		}
		else if ( selected == '50 x 8')
		{
			html += '<option value="Black 1309 (Ral 9017)">Black 1309 (Ral 9017)</option>';
			html += '<option value="White 814 (Ral 9003)">White 814 (Ral 9003)</option>';
			html += '<option value="Grey 1116 (Ral 7004)">Grey 1116 (Ral 7004)</option>';
			html += '<option value="Blue 1208 (Ral 5002)">Blue 1208 (Ral 5002)</option>';
			html += '<option value="Red 1000 (Ral 3020)">Red 1000 (Ral 3020)</option>';
			html += '<option value="Red 1307 (Ral 3002)">Red 1307 (Ral 3002)</option>';
			html += '<option value="Burgundy 1414 (Ral 2004)">Burgundy 1414 (Ral 2004)</option>';
			html += '<option value="Green 1222 (Ral 6005)">Green 1222 (Ral 6005)</option>';
			html += '<option value="Green 1120 (Ral 6000)">Green 1120 (Ral 6000)</option>';
			html += '<option value="Brown 1701 (Ral 8016)">Brown 1701 (Ral 8016)</option>';
			html += '<option value="Gold 652 (Ral 7008)">Gold 652 (Ral 7008)</option>';
			html += '<option value="Silver 651 (Ral 9007)">Silver 651 (Ral 9007)</option>';
			html += '<option value="Yellow (Ral 1018)">Yellow (Ral 1018)</option>';
		}
		else if ( selected == '60 x 8')
		{
			html += '<option value="Black 1309 (Ral 9017)">Black 1309 (Ral 9017)</option>';
			html += '<option value="Grey 1116 (Ral 7004)">Grey 1116 (Ral 7004)</option>';
			html += '<option value="Blue 1208 (Ral 5002)">Blue 1208 (Ral 5002)</option>';
                        html += '<option value="Red 1000 (Ral 3020)">Red 1000 (Ral 3020)</option>';
			html += '<option value="Green 1222 (Ral 6005)">Green 1222 (Ral 6005)</option>';
			html += '<option value="Brown 1701 (Ral 8016)">Brown 1701 (Ral 8016)</option>';
			html += '<option value="Gold 652 (Ral 7008)">Gold 652 (Ral 7008)</option>';
		}
		else if ( selected == 'R40 (25 x 15)')
		{
			html += '<option value="Black 1309 (Ral 9017)">Black 1309 (Ral 9017)</option>';
			html += '<option value="White 814 (Ral 9003)">White 814 (Ral 9003)</option>';
			html += '<option value="Grey 1116 (Ral 7004)">Grey 1116 (Ral 7004)</option>';
			html += '<option value="Blue 1208 (Ral 5002)">Blue 1208 (Ral 5002)</option>';
			html += '<option value="Silver 651 (Ral 9007)">Silver 651 (Ral 9007)</option>';
		}
		else if ( selected == 'R55 (40 x 8)')
		{
			html += '<option value="Black 1309 (Ral 9017)">Black 1309 (Ral 9017)</option>';
			html += '<option value="White 814 (Ral 9003)">White 814 (Ral 9003)</option>';
			html += '<option value="Grey 1116 (Ral 7004)">Grey 1116 (Ral 7004)</option>';
			html += '<option value="Blue 1208 (Ral 5002)">Blue 1208 (Ral 5002)</option>';
			html += '<option value="Red 1000 (Ral 3020)">Red 1000 (Ral 3020)</option>';
			html += '<option value="Red 1307 (Ral 3002)">Red 1307 (Ral 3002)</option>';
			html += '<option value="Green 1222 (Ral 6005)">Green 1222 (Ral 6005)</option>';
			html += '<option value="Yellow (Ral 1018)">Yellow (Ral 1018)</option>';
			html += '<option value="Silver 651 (Ral 9007)">Silver 651 (Ral 9007)</option>';
		}
		
		html += "</select>";
		document.getElementById('colour').innerHTML = html;
	}
	else
	{
		document.getElementById('colour').innerHTML = '';
	}
}


function validate_form()
{
	form = document.getElementById('quotation_form');
	var invalid = 0;
	
	if ( ! form.name.value.match(/^[\w\-\s\'\,]+$/) )
	{ 
		form.name.style.backgroundColor = '#fcc';
		invalid=1;
	}
	else
	{
		form.name.style.backgroundColor = '#fff';
	}
	
	if ( isNaN (form.telephone.value.match) && ! form.telephone.value.match(/^[\d-\(\)\s\#]+$/))
	{ 
		form.telephone.style.backgroundColor = '#fcc';
		invalid=1;
	}
	else
	{
		form.telephone.style.backgroundColor = '#fff';
	}


	if ( ! form.email.value.match(/^\s*[\w\-\_\.]+@[\w\-\_\.]+\s*$/) )
	{ 
		form.email.style.backgroundColor = '#fcc';
		invalid=1;
	}
	else
	{
		form.email.style.backgroundColor = '#fff';
	}
	
	if ( invalid == 1)
	{	
		document.getElementById('form_error').innerHTML = 'Please fill in the highlighted fields';
		return false;
	}
	else
	{
		return true;
	}
}	
