function changeMeasurment()
{
	themetric=document.getElementById('metric');
	thefeet=document.getElementById('feet');
	
	if(themetric.checked)
	{
		measurez="Metric";
	}
	else if(thefeet.checked)
	{
		measurez="Feet";
	}
	
	drawQuantity();
	
}


function changeMaterial()
{
	themarble=document.getElementById('marblez');
	thegranite=document.getElementById('granitez');
	thesandstone=document.getElementById('sandstonez');
	theslate=document.getElementById('slatez');
	typeselect=document.getElementById('typez');
	
	
	theType="";
	if(themarble.checked)
	{
		theType="Marble";
	}
	else if(thegranite.checked)
	{
		theType="Granite";
	}
	else if(thesandstone.checked)
	{
		theType="Sandstone";
	}
	else if(theslate.checked)
	{
		theType="Slate";
	}	
	for(var r=typeselect.options.length-1; r>=0; r--)
	{
		typeselect.remove(r);
	}

	for (var i=0;i<x['count'];i++)
	{
		if(x[i]['type']==theType)
		{
			var anOption = document.createElement("OPTION");
			anOption.text = x[i]['name'];
			anOption.value = x[i]['name'];
			
			typeselect.options.add(anOption);
		}
	}
	

	
}




function changeCut(getObj)
{
	thecut=getObj.options[getObj.selectedIndex].value;
	
	drawQuantity();
}

function drawQuantity()
{
	divObj=document.getElementById('info');
	
	strng="";
	
	strng+="<table border=0 cellpadding=5 cellspacing=0 class=smally>";
	
	mez="";
	if(measurez=="Metric")
	{
		Bq="m<sup>3</sup>";
		Sq="m<sup>2</sup>";
		Tq="m<sup>2</sup>";
		Ts="cm";
	}
	else if(measurez=="Feet")
	{
		Bq="cubic feet";
		Sq="square feet";
		Tq="square feet";
		Ts="inch";
	}
	
	
	if(thecut=="Blocks")
	{
		strng+="<tr><td>Quantity</td><td><input type='text' name='quantity' size=3> "+Bq+"</td></tr>";
	}
	else if(thecut=="Slabs")
	{
		strng+="<tr><td>Thickness</td><td><select name='thickness' onchange='checkSize(this)'><option value=''></option><option value='2cm'>2cm</option><option value='3cm'>3cm</option><option value='Other'>Other</option></select><input type='text' id='otherthick' name='otherthick' size='10' disabled></td></tr><tr><td>Quantity</td><td><input type='text' name='quantity' size=3> "+Sq+"</td></tr>";
	}
	else if(thecut=="Tiles")
	{
		strng+="<tr><td>Thickness</td><td><table border=0 cellpadding=0 cellspacing=0><tr><td><select name='thickness' onchange='checkSize(this)'><option value=''></option><option value='1cm'>1cm</option><option value='2cm'>2cm</option><option value='3cm'>3cm</option><option value='Other'>Other</option></select></td><td><div id='otherthickdiv' style='visibility:hidden;'><input type='text' id='otherthick' name='otherthick' size='10' disabled></div></td></tr></table></td></tr><tr><td>Size</td><td><input name='size1' type='text' size='3'> X <input name='size2' type='text' size='3'> "+Ts+"</td></tr><tr><td>Quantity</td><td><input type='text' name='quantity' size=3> "+Tq+"</td></tr>";
	}
	
	strng+="</table>";
	
	divObj.innerHTML=strng;
	
}


function validateForm()
{
	if(f1.name.value.length==0)
	{
		alert('Enter your name');
		f1.name.focus();
		return false;
	}
	

	if(f1.email.value.length==0)
	{
		alert('Enter your email');
		f1.email.focus();
		return false;
	}
	else
	{
		validRegExp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;  
		if(f1.email.value.search(validRegExp) == -1) 
		{
			alert('Enter correct email');
			f1.email.focus();
			return false;
		}
	}
	
	if(f1.company.value.length==0)
	{
		alert('Enter your company name');
		f1.company.focus();
		return false;
	}

	if(f1.telephone.value.length==0)
	{
		alert('Enter your telephone');
		f1.telephone.focus();
		return false;
	}
	
	return true;
}
function checkSize(selObj)
{
	theVal=selObj.options[selObj.selectedIndex].value;
	otherObj=document.getElementById('otherthick');
	otherDiv=document.getElementById('otherthickdiv');
	if(theVal=='Other')
	{
		otherObj.disabled='';
		otherDiv.style.visibility='visible';
	}
	else
	{
		otherObj.disabled='true';
		otherObj.value='';
		otherDiv.style.visibility='hidden';
	}	
}
