
function createCookie(name,value)
{
        var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function checkcookies() {

  if (readCookie('fm11_NumberOfCompost') != null )
  {  document.enquriyform.fm11_NumberOfCompost.value = readCookie('fm11_NumberOfCompost'); }

  if (readCookie('fm12_NumberOfTubMix') != null )
  {  document.enquriyform.fm12_NumberOfTubMix.value = readCookie('fm12_NumberOfTubMix'); }
   
  if (readCookie('fm13_NumberOfRoseMulch') != null )
  {  document.enquriyform.fm13_NumberOfRoseMulch.value = readCookie('fm13_NumberOfRoseMulch'); }

  if (readCookie('fm14_NumberOfBarkNuggets') != null )
  {  document.enquriyform.fm14_NumberOfBarkNuggets.value = readCookie('fm14_NumberOfBarkNuggets'); }

 if (readCookie('fm15_NumberOfBarkMulch') != null )
  {  document.enquriyform.fm15_NumberOfBarkMulch.value = readCookie('fm15_NumberOfBarkMulch'); }

  if (readCookie('fm16_NumberOfTopSoil') != null )
  {  document.enquriyform.fm16_NumberOfTopSoil.value = readCookie('fm16_NumberOfTopSoil'); }

  if (readCookie('fm17_NumberOfPeaStraw') != null )
  {  document.enquriyform.fm17_NumberOfPeaStraw.value = readCookie('fm17_NumberOfPeaStraw'); }

  if (readCookie('fm18_NumberOfSheepPellets') != null )
  {  document.enquriyform.fm18_NumberOfSheepPellets.value = readCookie('fm18_NumberOfSheepPellets'); }

  if (readCookie('fm02_CustomerName') != null )
  {  document.enquriyform.fm02_CustomerName.value = readCookie('fm02_CustomerName'); }

  if (readCookie('fm03_TelHome') != null )
  {  document.enquriyform.fm03_TelHome.value = readCookie('fm03_TelHome'); }

  if (readCookie('fm04_TelWork') != null )
  {  document.enquriyform.fm04_TelWork.value = readCookie('fm04_TelWork'); }

  if (readCookie('fm05_Street') != null )
  {  document.enquriyform.fm05_Street.value = readCookie('fm05_Street'); }

  if (readCookie('fm06_Suburb') != null )
  {  document.enquriyform.fm06_Suburb.value = readCookie('fm06_Suburb'); }

  if (readCookie('fm07_City') != null )
  {  document.enquriyform.fm07_City.value = readCookie('fm07_City'); }

  if (readCookie('fm01_Email') != null )
  {  document.enquriyform.fm01_Email.value = readCookie('fm01_Email'); }

  if (readCookie('fm08_DeliverWhere') != null )
  {  document.enquriyform.fm08_DeliverWhere.value = readCookie('fm08_DeliverWhere'); }

  if (readCookie('fm09_Comments') != null )
  {  document.enquriyform.fm09_Comments.value = readCookie('fm09_Comments'); }

  if (readCookie('fm10_FoundUs') != null )
  {  document.enquriyform.fm10_FoundUs.value = readCookie('fm10_FoundUs'); }

}

function writecookies() 
{
	createCookie('fm11_NumberOfCompost',document.enquriyform.fm11_NumberOfCompost.value);
	createCookie('fm12_NumberOfTubMix',document.enquriyform.fm12_NumberOfTubMix.value);
	createCookie('fm13_NumberOfRoseMulch',document.enquriyform.fm13_NumberOfRoseMulch.value);    
	createCookie('fm14_NumberOfBarkNuggets',document.enquriyform.fm14_NumberOfBarkNuggets.value);  
	createCookie('fm15_NumberOfBarkMulch',document.enquriyform.fm15_NumberOfBarkMulch.value);  
	createCookie('fm16_NumberOfTopSoil',document.enquriyform.fm16_NumberOfTopSoil.value);  
	createCookie('fm17_NumberOfPeaStraw',document.enquriyform.fm17_NumberOfPeaStraw.value);  
	createCookie('fm18_NumberOfSheepPellets',document.enquriyform.fm18_NumberOfSheepPellets.value);  
	createCookie('fm02_CustomerName',document.enquriyform.fm02_CustomerName.value);  
	createCookie('fm03_TelHome',document.enquriyform.fm03_TelHome.value);  
	createCookie('fm04_TelWork',document.enquriyform.fm04_TelWork.value);  
	createCookie('fm05_Street',document.enquriyform.fm05_Street.value);  
	createCookie('fm06_Suburb',document.enquriyform.fm06_Suburb.value);  
	createCookie('fm07_City',document.enquriyform.fm07_City.value);  
	createCookie('fm01_Email',document.enquriyform.fm01_Email.value);  
	createCookie('fm08_DeliverWhere',document.enquriyform.fm08_DeliverWhere.value);  
	createCookie('fm09_Comments',document.enquriyform.fm09_Comments.value);  
	createCookie('fm10_FoundUs',document.enquriyform.fm10_FoundUs.value);  
}

function CheckFields() 
{
	if (document.enquriyform.fm02_CustomerName.value == "" ) {
		// something is wrong
		alert('Please enter your name');
		document.enquriyform.fm02_CustomerName.focus();
		return false;
	}
	if (document.enquriyform.fm03_TelHome.value == "" ) {
		// something is wrong
		alert('Please enter your home phone number');
		document.enquriyform.fm03_TelHome.focus();
		return false;
	}
	if (document.enquriyform.fm05_Street.value == "" ) {
		// something is wrong
		alert('Please enter your address');
		document.enquriyform.fm05_Street.focus();
		return false;
	}
	if (document.enquriyform.fm07_City.value == "" ) {
		// something is wrong
		alert('Please enter your city');
		document.enquriyform.fm07_City.focus();
		return false;
	}
	if (document.enquriyform.fm01_Email.value == "" ) {
		// something is wrong
		alert('Please enter your email');
		document.enquriyform.fm01_Email.focus();
		return false;
	}
	if (document.enquriyform.fm08_DeliverWhere.value == "" ) {
		// something is wrong
		alert('Please enter deliver where');
		document.enquriyform.fm08_DeliverWhere.focus();
		return false;
	}
	
	return true; 
}

function popitup(url) {
  newwindow=window.open(url,'name','height=150,width=450,left=100,top=100,screenX=100,screenY=100');
  if (window.focus) {newwindow.focus()}
  return false;
}

