var xmlHttp
var firstSize = 0;
var secondSize = 0;
var thirdSize = 0;
var forthSize = 0;
var fifthSize = 0;
var sNote = '<div class="note">Your item is too large - please use the <a href="http://zx.co.nz/lhquote.htm" class="note">Large/Heavy Item Quote Form</a></div>';
var sGlobalFunctionType = '';
var sGlobalqqc = '';
var sGlobalpc = 0;
var sGlobalps = 0;

function smquote(sFunctionType)
{
  sGlobalFunctionType = sFunctionType;
  var firstweightMultiplier = 0;
  var firstsizeMultiplier = 0
  var firstMul = 0;
  var secondweightMultiplier = 0;
  var secondsizeMultiplier = 0
  var secondMul = 0;
  var thirdweightMultiplier = 0;
  var thirdsizeMultiplier = 0
  var thirdMul = 0;
  var forthweightMultiplier = 0;
  var forthsizeMultiplier = 0
  var forthMul = 0;
  var fifthweightMultiplier = 0;
  var fifthsizeMultiplier = 0
  var fifthMul = 0;
  var sruralpickup = 'no';
  var sruraldelivery = 'no';

  //alert (CheckFieldsBeforeCalculation());
 if (sGlobalFunctionType == 'postform') {
  if (CheckFieldsBeforeCalculation(false))
  {
  
  if (!document.SmallQuoteForm.First_item_height.disabled)
  { 
     firstweightMultiplier = compareweightmul(document.SmallQuoteForm.first_item_weight.value);
     firstsizeMultiplier = comparesizemul(firstSize);
     firstMul = comparetwomul(firstweightMultiplier, firstsizeMultiplier);
     //alert (firstsizeMultiplier + ' ' + firstMul);
  
     secondweightMultiplier = compareweightmul(document.SmallQuoteForm.second_item_weight.value);
     secondsizeMultiplier = comparesizemul(secondSize);
     secondMul = comparetwomul(secondweightMultiplier, secondsizeMultiplier);

     thirdtweightMultiplier = compareweightmul(document.SmallQuoteForm.third_item_weight.value);
     thirdsizeMultiplier = comparesizemul(thirdSize);
     thirdMul = comparetwomul(thirdweightMultiplier, thirdsizeMultiplier);

     forthweightMultiplier = compareweightmul(document.SmallQuoteForm.forth_item_weight.value);
     forthsizeMultiplier = comparesizemul(forthSize);
     forthMul = comparetwomul(forthweightMultiplier, forthsizeMultiplier);

     fifthweightMultiplier = compareweightmul(document.SmallQuoteForm.fifth_item_weight.value);
     fifthsizeMultiplier = comparesizemul(fifthSize);
     fifthMul = comparetwomul(fifthweightMultiplier, fifthsizeMultiplier);

    }
	else {
      firstMul = document.SmallQuoteForm.firstmul.value;
	  if (eval("typeof(document.SmallQuoteForm.secondmul) != 'undefined'")){  secondMul = document.SmallQuoteForm.secondmul.value; }
	  if (eval("typeof(document.SmallQuoteForm.thirdmul) != 'undefined'")){  thirdMul = document.SmallQuoteForm.thirdmul.value; }
	  if (eval("typeof(document.SmallQuoteForm.forthmul) != 'undefined'")){  forthMul = document.SmallQuoteForm.forthmul.value; }
	  if (eval("typeof(document.SmallQuoteForm.fifthmul) != 'undefined'")){  fifthMul = document.SmallQuoteForm.fifthmul.value; }
	}

   if ((document.SmallQuoteForm.elements['rural_pickup'][0].checked) )
   {
    sruralpickup = 'yes';
   }
 
   if ((document.SmallQuoteForm.elements['rural_delivery'][0].checked) )
   {
    sruraldelivery = 'yes';
   }

   var stype = document.SmallQuoteForm.Island_type.value;

   xmlHttp=GetXmlHttpObject();

   if (xmlHttp==null)
   {
   alert ("Your browser does not support AJAX!");
   return;
   } 

   var url="smallcalculation.php";
   url= url + "?type=" + stype + "&pickuprural=" + sruralpickup + "&deliveryrural=" + sruraldelivery + "&firstmul=" + firstMul + "&secondmul=" + secondMul + "&thirdmul=" + thirdMul + "&forthmul=" + forthMul + "&fifthmul=" + fifthMul;

   //alert(url);

   xmlHttp.open("GET",url,true);
   xmlHttp.setRequestHeader('Content-Type',  "text/xml");
   xmlHttp.onreadystatechange=stateChanged;
   xmlHttp.send(null);


 }//if (checkfieldsbeforecalculation)
}//if (sGlobalFunctionType == 'postform')
else if (sGlobalFunctionType == 'qqcform'){
  if (CheckFieldsBeforeCalculation(true))
  {
  

   firstweightMultiplier = compareweightmul(document.SmallQuoteForm.first_item_weight.value);
   firstsizeMultiplier = comparesizemul(firstSize);
   firstMul = comparetwomul(firstweightMultiplier, firstsizeMultiplier);

   secondweightMultiplier = compareweightmul(document.SmallQuoteForm.second_item_weight.value);
   secondsizeMultiplier = comparesizemul(secondSize);
   secondMul = comparetwomul(secondweightMultiplier, secondsizeMultiplier);

   thirdtweightMultiplier = compareweightmul(document.SmallQuoteForm.third_item_weight.value);
   thirdsizeMultiplier = comparesizemul(thirdSize);
   thirdMul = comparetwomul(thirdweightMultiplier, thirdsizeMultiplier);

   forthweightMultiplier = compareweightmul(document.SmallQuoteForm.forth_item_weight.value);
   forthsizeMultiplier = comparesizemul(forthSize);
   forthMul = comparetwomul(forthweightMultiplier, forthsizeMultiplier);

   fifthweightMultiplier = compareweightmul(document.SmallQuoteForm.fifth_item_weight.value);
   fifthsizeMultiplier = comparesizemul(fifthSize);
   fifthMul = comparetwomul(fifthweightMultiplier, fifthsizeMultiplier);

   //alert(document.SmallQuoteForm.pick_up_city.value);
   spickupcity = GetPickupCityUniqueKey(document.SmallQuoteForm.pick_up_city.value);
   //alert(spickupcity);
   if (eval("typeof(document.SmallQuoteForm.pick_up_suburb) != 'undefined'") && (document.SmallQuoteForm.pick_up_city.value != 'Other-North-Island') && (document.SmallQuoteForm.pick_up_city.value != 'Other-South-Island'))
   {
        //alert(document.SmallQuoteForm.pick_up_suburb.value);
        spickupsuburb = document.SmallQuoteForm.pick_up_suburb.value;
		
		spickupsuburb = GetPickupSuburbUniqueKey(document.SmallQuoteForm.pick_up_city.value, spickupsuburb);
   }
   else { spickupsuburb = '00'; }

   //alert(spickupsuburb);
   
   //alert (firstsizeMultiplier + ' ' + firstMul);
  
  if ((document.SmallQuoteForm.elements['rural_pickup'][0].checked) )
   {
    sruralpickup = 'yes';
   }
 
     xmlHttp=GetXmlHttpObject();

   if (xmlHttp==null)
   {
   alert ("Your browser does not support AJAX!");
   return;
   } 

   var url="smallqqcgenerator.php";
   url= url + "?type=s&pickupcity=" +spickupcity +"&pickupsuburb="+ spickupsuburb + "&pickuprural=" + sruralpickup + "&firstmul=" + firstMul + "&secondmul=" + secondMul + "&thirdmul=" + thirdMul + "&forthmul=" + forthMul + "&fifthmul=" + fifthMul;;

   //alert(url);

   xmlHttp.open("GET",url,true);
   xmlHttp.setRequestHeader('Content-Type',  "text/xml");
   xmlHttp.onreadystatechange=stateChanged;
   xmlHttp.send(null);


 }//if (CheckQQCFieldsBeforeCalculation())

}//else
else //decodeqqc
{

   xmlHttp=GetXmlHttpObject();

   if (xmlHttp==null)
   {
   alert ("Your browser does not support AJAX!");
   return;
   } 

   var url="smallqqcgdecoder.php";
   url= url + "?qqc=" +sGlobalqqc;

   //alert(url);

   xmlHttp.open("GET",url,true);
   xmlHttp.setRequestHeader('Content-Type',  "text/xml");
   xmlHttp.onreadystatechange=stateChanged;
   xmlHttp.send(null);
}

} 

function stateChanged() 
{ 
 if (xmlHttp.readyState==4)
 { 
   //var response = xmlHttp.responseText;
   //alert(xmlHttp.responseText);
   
   var xmlDoc=xmlHttp.responseXML.documentElement;
   //alert(xmlDoc);

   if (sGlobalFunctionType == 'postform')
   {
     if ( xmlDoc.getElementsByTagName("firsttotal")[0].childNodes[0].nodeValue > 45 )
     {
     //document.getElementById('First_note').innerHTML  = sNote;
	 //document.SmallQuoteForm.Total_cost.value = '';
	 document.SmallQuoteForm.First_item_cost.value = formatCurrency(xmlDoc.getElementsByTagName("firsttotal")[0].childNodes[0].nodeValue);
     }
     else {
       document.getElementById('First_note').innerHTML = ''
       document.SmallQuoteForm.First_item_cost.value = formatCurrency(xmlDoc.getElementsByTagName("firsttotal")[0].childNodes[0].nodeValue);
     }

     if (xmlDoc.getElementsByTagName("secondtotal")[0].childNodes[0].nodeValue > 45)
     {
       //document.getElementById('Second_note').innerHTML  = sNote;
	   //document.SmallQuoteForm.Total_cost.value = '';
	   document.SmallQuoteForm.Second_item_cost.value = formatCurrency(xmlDoc.getElementsByTagName("secondtotal")[0].childNodes[0].nodeValue);
     }
     else {
       document.getElementById('Second_note').innerHTML = '';
       document.SmallQuoteForm.Second_item_cost.value = formatCurrency(xmlDoc.getElementsByTagName("secondtotal")[0].childNodes[0].nodeValue);
     }

     if (xmlDoc.getElementsByTagName("thirdtotal")[0].childNodes[0].nodeValue > 45)
     {
       //document.getElementById('Third_note').innerHTML  = sNote;
	   //document.SmallQuoteForm.Total_cost.value = '';
	   document.SmallQuoteForm.Third_item_cost.value = formatCurrency(xmlDoc.getElementsByTagName("thirdtotal")[0].childNodes[0].nodeValue);
     }
     else {
       document.getElementById('Third_note').innerHTML = '';
       document.SmallQuoteForm.Third_item_cost.value = formatCurrency(xmlDoc.getElementsByTagName("thirdtotal")[0].childNodes[0].nodeValue);
     }
     if (xmlDoc.getElementsByTagName("forthtotal")[0].childNodes[0].nodeValue > 45)
     {
       //document.getElementById('Forth_note').innerHTML = sNote;
	   //document.SmallQuoteForm.Total_cost.value = '';
	    document.SmallQuoteForm.Forth_item_cost.value = formatCurrency(xmlDoc.getElementsByTagName("forthtotal")[0].childNodes[0].nodeValue);
     }
     else {
       document.getElementById('Forth_note').innerHTML = '';
       document.SmallQuoteForm.Forth_item_cost.value = formatCurrency(xmlDoc.getElementsByTagName("forthtotal")[0].childNodes[0].nodeValue);
     }
     if (xmlDoc.getElementsByTagName("fifthtotal")[0].childNodes[0].nodeValue > 45)
     {
       //document.getElementById('Fifth_note').innerHTML = sNote;
	   //document.SmallQuoteForm.Total_cost.value = '';
	   document.SmallQuoteForm.Fifth_item_cost.value = formatCurrency(xmlDoc.getElementsByTagName("fifthtotal")[0].childNodes[0].nodeValue);
     }
     else {
       document.getElementById('Fifth_note').innerHTML = '';
       document.SmallQuoteForm.Fifth_item_cost.value = formatCurrency(xmlDoc.getElementsByTagName("fifthtotal")[0].childNodes[0].nodeValue);
     }
     if (xmlDoc.getElementsByTagName("totalcost")[0].childNodes[0].nodeValue > 45)
     {
       //document.getElementById('totalCostNote').innerHTML = '<div class="note">Your total shipment cost is over $45 - please use the <a href="large_heavy_items_quote_form_2a.htm" class="note">Large/Heavy Item Quote Form</a></div>';
	   document.getElementById('totalCostNote').innerHTML = '';
	   document.SmallQuoteForm.Total_cost.value = formatCurrency(xmlDoc.getElementsByTagName("totalcost")[0].childNodes[0].nodeValue);
     }
     else {
       document.getElementById('totalCostNote').innerHTML = '';
       document.SmallQuoteForm.Total_cost.value = formatCurrency(xmlDoc.getElementsByTagName("totalcost")[0].childNodes[0].nodeValue);
     }


     if (CheckFields())
     {
	   
	   document.SmallQuoteForm.submit();
     }

   }//if (sGlobalFunctionType == 'postform')
   if (sGlobalFunctionType == 'qqcform')
   {
     //alert (xmlDoc.getElementsByTagName("qqc")[0].childNodes[0].nodeValue);
     document.getElementById('quickquotecode').innerHTML = '<input type="hidden" name="qqc" value='+ xmlDoc.getElementsByTagName("qqc")[0].childNodes[0].nodeValue +'>'; 
     if (CheckQQCFields())
     {
	   
	   document.SmallQuoteForm.submit();
     }

   }//end  if (sGlobalFunctionType == 'qqcform')
   if (sGlobalFunctionType == 'decodeqqc')
   {
	 sGlobalpc = xmlDoc.getElementsByTagName("pickupcity")[0].childNodes[0].nodeValue;
	 //alert(sGlobalpc.indexOf('0'));
	 if (sGlobalpc.indexOf('0') == 1)
	 {
	   	 sGlobalpc = parseInt(sGlobalpc);
	 }
	 else {
       sGlobalpc = parseInt(sGlobalpc.replace('0',''));
	 }

	 document.SmallQuoteForm.elements['pick_up_city'].selectedIndex = sGlobalpc;

     sPickupcity = document.SmallQuoteForm.pick_up_city.value;  

     sPickupcity = sPickupcity.replace(' ','');

	 sPickupSuburb = xmlDoc.getElementsByTagName("pickupsuburb")[0].childNodes[0].nodeValue;


	 //getweight();
	 if (sPickupSuburb != '00')
	 {
	     sGlobalps = GetPickupSuburbIndex(sPickupcity, sPickupSuburb);
	     GetSearchLocations(document.SmallQuoteForm.pick_up_city.value, document.SmallQuoteForm.pick_up_suburb, 'pickupsuburb', 'pick_up_suburb'); 
	     document.SmallQuoteForm.elements['pick_up_suburb'].selectedIndex = sGlobalps;
		 document.SmallQuoteForm.pick_up_city.disabled = true;
		 document.SmallQuoteForm.pick_up_suburb.disabled = true;
	 }
    
	 if (xmlDoc.getElementsByTagName("pickuprural")[0].childNodes[0].nodeValue == 'y')
	 {
	    document.SmallQuoteForm.elements['rural_pickup'][0].checked = true; 
	 }
	 else {
       document.SmallQuoteForm.elements['rural_pickup'][1].checked = true; 	   
	 }
	 document.SmallQuoteForm.elements['rural_pickup'][1].disabled = true;
     document.SmallQuoteForm.elements['rural_pickup'][0].disabled = true;

	 document.getElementById('firstmul').innerHTML = '<input type="hidden" name="firstmul" value='+ xmlDoc.getElementsByTagName("firstmul")[0].childNodes[0].nodeValue +'>'; 
	 if (xmlDoc.getElementsByTagName("secondmul")[0].childNodes[0].nodeValue != '')
	 {
	  	 document.getElementById('secondmul').innerHTML = '<input type="hidden" name="secondmul" value='+ xmlDoc.getElementsByTagName("secondmul")[0].childNodes[0].nodeValue +'>'; 

	 }
	 if (xmlDoc.getElementsByTagName("thirdmul")[0].childNodes[0].nodeValue != '')
	 {
	  	 document.getElementById('thirdmul').innerHTML = '<input type="hidden" name="thirdmul" value='+ xmlDoc.getElementsByTagName("thirdmul")[0].childNodes[0].nodeValue +'>'; 

	 }
	 if (xmlDoc.getElementsByTagName("forthmul")[0].childNodes[0].nodeValue != '')
	 {
	  	 document.getElementById('forthmul').innerHTML = '<input type="hidden" name="forthmul" value='+ xmlDoc.getElementsByTagName("forthmul")[0].childNodes[0].nodeValue +'>'; 

	 }
	 if (xmlDoc.getElementsByTagName("fifthmul")[0].childNodes[0].nodeValue != '')
	 {
	  	 document.getElementById('fifthmul').innerHTML = '<input type="hidden" name="fifthmul" value='+ xmlDoc.getElementsByTagName("fifthmul")[0].childNodes[0].nodeValue +'>'; 

	 }
	 
	 document.SmallQuoteForm.First_item_height.disabled = true;
	 document.SmallQuoteForm.First_item_height.className = "total";  
	 document.SmallQuoteForm.First_item_length.disabled = true;
	 document.SmallQuoteForm.First_item_length.className = "total";
	 document.SmallQuoteForm.First_item_width.disabled = true;
	 document.SmallQuoteForm.First_item_width.className = "total";
	 document.SmallQuoteForm.First_item_description.disabled = true;
	 document.SmallQuoteForm.First_item_description.className = "total";

	 document.SmallQuoteForm.Second_item_height.disabled = true;
	 document.SmallQuoteForm.Second_item_height.className = "total";
	 document.SmallQuoteForm.Second_item_length.disabled = true;
	 document.SmallQuoteForm.Second_item_length.className = "total";
	 document.SmallQuoteForm.Second_item_width.disabled = true;
	 document.SmallQuoteForm.Second_item_width.className = "total";
	 document.SmallQuoteForm.Second_item_description.disabled = true;
	 document.SmallQuoteForm.Second_item_description.className = "total";

	 document.SmallQuoteForm.Third_item_height.disabled = true;
	 document.SmallQuoteForm.Third_item_height.className = "total";
	 document.SmallQuoteForm.Third_item_length.disabled = true;
	 document.SmallQuoteForm.Third_item_length.className = "total";
	 document.SmallQuoteForm.Third_item_width.disabled = true;
	 document.SmallQuoteForm.Third_item_width.className = "total";
	 document.SmallQuoteForm.Third_item_description.disabled = true;
	 document.SmallQuoteForm.Third_item_description.className = "total";

	 document.SmallQuoteForm.Forth_item_height.disabled = true;
	 document.SmallQuoteForm.Forth_item_height.className = "total";
	 document.SmallQuoteForm.Forth_item_length.disabled = true;
	 document.SmallQuoteForm.Forth_item_length.className = "total";
	 document.SmallQuoteForm.Forth_item_width.disabled = true;
	 document.SmallQuoteForm.Forth_item_width.className = "total";
	 document.SmallQuoteForm.Forth_item_description.disabled = true;
	 document.SmallQuoteForm.Forth_item_description.className = "total";

	 document.SmallQuoteForm.Fifth_item_height.disabled = true;
	 document.SmallQuoteForm.Fifth_item_height.className = "total";
	 document.SmallQuoteForm.Fifth_item_length.disabled = true;
	 document.SmallQuoteForm.Fifth_item_length.className = "total";
	 document.SmallQuoteForm.Fifth_item_width.disabled = true;
	 document.SmallQuoteForm.Fifth_item_width.className = "total";
	 document.SmallQuoteForm.Fifth_item_description.disabled = true;
	 document.SmallQuoteForm.Fifth_item_description.className = "total";

	 document.getElementById("getqqcbutton").style.display = "none";
     
   }//end  if (sGlobalFunctionType == 'decodeqqc')

 }//end if (xmlHttp.readyState==4)
}//end function stateChanged() 

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function comparetwomul(first, second) {
  var multiplier = 0;
 
  if (first == second  ) {
   multiplier = second ;
  } 
  else if (first > second  ) {
    multiplier = first ;
  }
  else {
    multiplier = second ;
  }

  return multiplier
}



function compareweightmul(weight) {
  var weightmultiplier = 0;
 
  if   (weight == "up to 3kg") {
    weightmultiplier = 1;
  }
  else if   (weight == "3.1kg to 8kg") {
    weightmultiplier = 2;
  }

  else if   (weight == "8.1kg to 13kg") {
    weightmultiplier = 3;
  }
  else if   (weight == "13.1kg to 18kg") {
    weightmultiplier = 4;
  }
  else if   (weight == "18.1kg to 25kg") {
    weightmultiplier = 5;
  }
  else if   (weight == "25kg or less") {
    weightmultiplier = 1;
  }

  return weightmultiplier
}

function comparesizemul(size) {
  //alert (size);
  var sizemultiplier = 0;
 
  if ((size > 0) && (size <= 0.015)) {
    sizemultiplier = 1;
  }   
  if ((size > 0.015)  && (size <= 0.04)) {
   sizemultiplier = 2;
  } 
  if ((size > 0.04)  && (size <= 0.065 )) {
   sizemultiplier = 3;
  } 
  if ((size > 0.065)  && (size <= 0.09 )) {
   sizemultiplier = 4;
  } 
  if ((size > 0.09)  && (size <= 0.125 )) {
   sizemultiplier = 5;
  }
  //alert (sizemultiplier);
  return sizemultiplier
}

/*
function compareweightmul(weight) {
  var weightmultiplier = 0;
 
  if   (weight == "up to 5kg") {
    weightmultiplier = 1;
  }
  else if   (weight == "5.1kg to 10kg") {
    weightmultiplier = 2;
  }

  else if   (weight == "10.1kg to 15 kg") {
    weightmultiplier = 3;
  }
  else if   (weight == "15.1kg to 20kg") {
    weightmultiplier = 4;
  }
  else if   (weight == "20.1kg to 25kg") {
    weightmultiplier = 5;
  }
  else if   (weight == "25kg or less") {
    weightmultiplier = 1;
  }

  return weightmultiplier
}

function comparesizemul(size) {
  //alert (size);
  var sizemultiplier = 0;
 
  if ((size > 0) && (size <= 0.025)) {
    sizemultiplier = 1;
  }   
  if ((size > 0.025)  && (size <= 0.05)) {
   sizemultiplier = 2;
  } 
  if ((size > 0.05)  && (size <= 0.075 )) {
   sizemultiplier = 3;
  } 
  if ((size > 0.075)  && (size <= 0.1 )) {
   sizemultiplier = 4;
  } 
  if ((size > 0.1)  && (size <= 0.125 )) {
   sizemultiplier = 5;
  }
  //alert (sizemultiplier);
  return sizemultiplier
}
*/

function CheckFieldsBeforeCalculation(qqc) { 
//alert ('before' + (document.SmallQuoteForm.First_item_height.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));
if (!document.SmallQuoteForm.First_item_height.disabled)
{


 var firstHeight =  removeSpaces((document.SmallQuoteForm.First_item_height.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));
 var firstLength = removeSpaces((document.SmallQuoteForm.First_item_length.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));
 var firstWidth = removeSpaces((document.SmallQuoteForm.First_item_width.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));

 var secondHeight =  removeSpaces((document.SmallQuoteForm.Second_item_height.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));
 var secondLength = removeSpaces((document.SmallQuoteForm.Second_item_length.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));
 var secondWidth = removeSpaces((document.SmallQuoteForm.Second_item_width.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));

 var thirdHeight =  removeSpaces((document.SmallQuoteForm.Third_item_height.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));
 var thirdLength = removeSpaces((document.SmallQuoteForm.Third_item_length.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));
 var thirdWidth = removeSpaces((document.SmallQuoteForm.Third_item_width.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));

 var forthHeight =  removeSpaces((document.SmallQuoteForm.Forth_item_height.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));
 var forthLength = removeSpaces((document.SmallQuoteForm.Forth_item_length.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));
 var forthWidth = removeSpaces((document.SmallQuoteForm.Forth_item_width.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));

 var fifthHeight =  removeSpaces((document.SmallQuoteForm.Fifth_item_height.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));
 var fifthLength = removeSpaces((document.SmallQuoteForm.Fifth_item_length.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));
 var fifthWidth = removeSpaces((document.SmallQuoteForm.Fifth_item_width.value.replace(/[(*!a-zA-Z)&^@#$%_+,";:,?/\|><{}]/g,"")));

// alert (firstHeight);
 
 firstSize = (firstHeight * firstLength * firstWidth)/ 1000000;
 secondSize = (secondHeight * secondLength * secondWidth)/ 1000000;
 thirdSize = (thirdHeight * thirdLength * thirdWidth)/ 1000000;
 forthSize = (forthHeight * forthLength * forthWidth)/ 1000000;
 fifthSize = (fifthHeight * fifthLength * fifthWidth)/ 1000000;
// alert (firstSize + ' ' + secondSize + ' ' + thirdSize + ' ' + forthSize + ' ' + fifthSize);
}
	if (document.SmallQuoteForm.pick_up_city.value == "0" ) {
		// something is wrong
		alert('Please enter pick up city');
                            document.SmallQuoteForm.pick_up_city.focus();
		return false;
	}
	if (!qqc)
	{
	  if (document.SmallQuoteForm.delivery_city.value == "0" ) {
		// something is wrong
		alert('Please enter delivery city');
                            document.SmallQuoteForm.delivery_city.focus();
		return false;
	  }
	}
	if (( (eval("typeof(document.SmallQuoteForm.pick_up_suburb) != 'undefined'")) && (document.SmallQuoteForm.pick_up_suburb.value == "0" )) ) {
		// something is wrong
		alert('Please enter pick up suburb');
                            document.SmallQuoteForm.pick_up_suburb.focus();
		return false;
	}
	if (!qqc)
	{
		if (((eval("typeof(document.SmallQuoteForm.delivery_suburb) != 'undefined'")) && (document.SmallQuoteForm.delivery_suburb.value == "0" )) ){
		// something is wrong
		alert('Please enter delivery suburb');
                            document.SmallQuoteForm.delivery_suburb.focus();
		return false;
	   }
	}

    if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.first_item_weight.value == "0" ) &&  (document.SmallQuoteForm.First_item_height.value > 0) )
	  {	  		// something is wrong
		alert('Please select weight');
         document.SmallQuoteForm.first_item_weight.focus();
		return false;
	  }

    if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.First_item_length.value > 0 ) &&  (document.SmallQuoteForm.First_item_height.value > 0) && (!document.SmallQuoteForm.elements['First_item_Box_or_Cylinder'][0].checked) && (!document.SmallQuoteForm.elements['First_item_Box_or_Cylinder'][1].checked) )
	  {	  		// something is wrong
		alert('Please select Box or Cylinder for 1st item');
         document.SmallQuoteForm.elements['First_item_Box_or_Cylinder'][1].focus();
		return false;
	  }

    if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.first_item_weight.value == "Over 25kg"))
      {
	    document.getElementById('First_note').innerHTML = sNote;
		return false;
      }
//else if (eval("typeof(document.SmallQuoteForm.second_item_weight) != 'undefined'")) {
	 if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.second_item_weight.value == "0" ) &&  (document.SmallQuoteForm.Second_item_height.value > 0) )
	  {	  		// something is wrong
		alert('Please select weight');
         document.SmallQuoteForm.second_item_weight.focus();
		return false;
	  }
	  if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.Second_item_length.value > 0 ) &&  (document.SmallQuoteForm.Second_item_height.value > 0) && (!document.SmallQuoteForm.elements['Second_item_Box_or_Cylinder'][0].checked) && (!document.SmallQuoteForm.elements['Second_item_Box_or_Cylinder'][1].checked) )
	  {	  		// something is wrong
		alert('Please select Box or Cylinder for 2nd item');
         document.SmallQuoteForm.elements['Second_item_Box_or_Cylinder'][0].focus();
		return false;
	  }

      if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.second_item_weight.value == "Over 25kg"))
      {
	    document.getElementById('Second_note').innerHTML = sNote;
		return false;
      }
//   else { return true; }
		
//	}
//	else if (eval("typeof(document.SmallQuoteForm.third_item_weight) != 'undefined'")) {
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.third_item_weight.value == "0" ) &&  (document.SmallQuoteForm.Third_item_height.value > 0) )
	  {	  		// something is wrong
		alert('Please select weight');
         document.SmallQuoteForm.third_item_weight.focus();
		return false;
	  }
    if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.Third_item_length.value > 0 ) &&  (document.SmallQuoteForm.Third_item_height.value > 0) && (!document.SmallQuoteForm.elements['Third_item_Box_or_Cylinder'][0].checked) && (!document.SmallQuoteForm.elements['Third_item_Box_or_Cylinder'][1].checked) )
	  {	  		// something is wrong
		alert('Please select Box or Cylinder for third item');
         document.SmallQuoteForm.elements['Third_item_Box_or_Cylinder'][0].focus();
		return false;
	  }
     if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.third_item_weight.value == "Over 25kg"))
      {
	    document.getElementById('Third_note').innerHTML = sNote;
		return false;
      }
//  else { return true; }
	   
//	}
//	else if (eval("typeof(document.SmallQuoteForm.forth_item_weight) != 'undefined'")) {
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.forth_item_weight.value == "0" ) &&  (document.SmallQuoteForm.Forth_item_height.value > 0) )
	  {	  		// something is wrong
		alert('Please select weight');
         document.SmallQuoteForm.forth_item_weight.focus();
		return false;
	  }
    if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.Forth_item_length.value > 0 ) &&  (document.SmallQuoteForm.Forth_item_height.value > 0) && (!document.SmallQuoteForm.elements['Forth_item_Box_or_Cylinder'][0].checked) && (!document.SmallQuoteForm.elements['Forth_item_Box_or_Cylinder'][1].checked) )
	  {	  		// something is wrong
		alert('Please select Box or Cylinder for forth item');
         document.SmallQuoteForm.elements['Forth_item_Box_or_Cylinder'][0].focus();
		return false;
	  }
    if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.forth_item_weight.value == "Over 25kg"))
      {
	    document.getElementById('Forth_note').innerHTML = sNote;
		return false;
      }
//	    else { return true; }
//	}
//	else if (eval("typeof(document.SmallQuoteForm.fifth_item_weight) != 'undefined'")) {
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.fifth_item_weight.value == "0" ) &&  (document.SmallQuoteForm.Fifth_item_height.value > 0) )
	  {	  		// something is wrong
		alert('Please select weight');
         document.SmallQuoteForm.fifth_item_weight.focus();
		return false;
	  }
    if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.Fifth_item_length.value > 0 ) &&  (document.SmallQuoteForm.Fifth_item_height.value > 0) && (!document.SmallQuoteForm.elements['Fifth_item_Box_or_Cylinder'][0].checked) && (!document.SmallQuoteForm.elements['Fifth_item_Box_or_Cylinder'][1].checked) )
	  {	  		// something is wrong
		alert('Please select Box or Cylinder for fifth item');
         document.SmallQuoteForm.elements['Fifth_item_Box_or_Cylinder'][0].focus();
		return false;
	  }
    if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.fifth_item_weight.value == "Over 25kg"))
      {
	    document.getElementById('Fifth_note').innerHTML = sNote;
		return false;
      }
//	  else { return true; }
//	}
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.first_item_weight == "0") && (document.SmallQuoteForm.second_item_weight == "0") && (document.SmallQuoteForm.third_item_weight == "0") && (document.SmallQuoteForm.forth_item_weight == "0") && (document.SmallQuoteForm.fifth_item_weight == "0"))
	{		
	     alert('Please select weight');
         document.SmallQuoteForm.first_item_weight.focus();
		 return false;
	}
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (removeSpaces(document.SmallQuoteForm.First_item_height.value) == "") && (removeSpaces(document.SmallQuoteForm.Second_item_height.value) == "") && (removeSpaces(document.SmallQuoteForm.Third_item_height.value) == "") && (removeSpaces(document.SmallQuoteForm.Forth_item_height.value) == "") && (removeSpaces(document.SmallQuoteForm.Fifth_item_height.value) == ""))
	{		
	     alert('Please enter height');
         document.SmallQuoteForm.First_item_height.focus();
		 return false;
	}
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (removeSpaces(document.SmallQuoteForm.First_item_length.value) == "") && (removeSpaces(document.SmallQuoteForm.Second_item_length.value) == "") && (removeSpaces(document.SmallQuoteForm.Third_item_length.value) == "") && (removeSpaces(document.SmallQuoteForm.Forth_item_length.value) == "") && (removeSpaces(document.SmallQuoteForm.Fifth_item_length.value) == ""))
	{		
	     alert('Please enter length');
         document.SmallQuoteForm.First_item_length.focus();
		 return false;
	}
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (removeSpaces(document.SmallQuoteForm.First_item_width.value) == "") && (removeSpaces(document.SmallQuoteForm.Second_item_width.value) == "") && (removeSpaces(document.SmallQuoteForm.Third_item_width.value) == "") && (removeSpaces(document.SmallQuoteForm.Forth_item_width.value) == "") && (removeSpaces(document.SmallQuoteForm.Fifth_item_width.value) == ""))
	{		
	     alert('Please enter width');
         document.SmallQuoteForm.First_item_width.focus();
		 return false;
	}

	//check 1st item height
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.first_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.First_item_height.value) == ""))
	{		
	     alert('Please enter height');
         document.SmallQuoteForm.First_item_height.focus();
		 return false;
	}
	//check 1st item length
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.first_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.First_item_length.value) == ""))
	{		
	     alert('Please enter length');
         document.SmallQuoteForm.First_item_length.focus();
		 return false;
	}
	//check 1st item width
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.first_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.First_item_width.value) == ""))
	{		
	     alert('Please enter width');
         document.SmallQuoteForm.First_item_width.focus();
		 return false;
	}
	//check 1st item description
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.first_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.First_item_description.value) == ""))
	{		
	     alert('Please enter description');
         document.SmallQuoteForm.First_item_description.focus();
		 return false;
	}

	//check 2nd item height
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.second_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Second_item_height.value) == ""))
	{		
	     alert('Please enter height');
         document.SmallQuoteForm.Second_item_height.focus();
		 return false;
	}
	//check 2nd item length
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.second_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Second_item_length.value) == ""))
	{		
	     alert('Please enter length');
         document.SmallQuoteForm.Second_item_length.focus();
		 return false;
	}
	//check 2nd item width
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.second_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Second_item_width.value) == ""))
	{		
	     alert('Please enter width');
         document.SmallQuoteForm.Second_item_width.focus();
		 return false;
	}
	//check 2nd item description
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.second_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Second_item_description.value) == ""))
	{		
	     alert('Please enter description');
         document.SmallQuoteForm.Second_item_description.focus();
		 return false;
	}

	//check 3rd item height
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.third_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Third_item_height.value) == ""))
	{		
	     alert('Please enter height');
         document.SmallQuoteForm.Third_item_height.focus();
		 return false;
	}
	//check 3rd item length
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.third_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Third_item_length.value) == ""))
	{		
	     alert('Please enter length');
         document.SmallQuoteForm.Third_item_length.focus();
		 return false;
	}
	//check 3rd item width
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.third_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Third_item_width.value) == ""))
	{		
	     alert('Please enter width');
         document.SmallQuoteForm.Third_item_width.focus();
		 return false;
	}
	//check 3rd item description
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.third_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Third_item_description.value) == ""))
	{		
	     alert('Please enter description');
         document.SmallQuoteForm.Third_item_description.focus();
		 return false;
	}

	//check 4th item height
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.forth_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Forth_item_height.value) == ""))
	{		
	     alert('Please enter height');
         document.SmallQuoteForm.Forth_item_height.focus();
		 return false;
	}
	//check 4th item length
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.forth_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Forth_item_length.value) == ""))
	{		
	     alert('Please enter length');
         document.SmallQuoteForm.Forth_item_length.focus();
		 return false;
	}
	//check 4th item width
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.forth_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Forth_item_width.value) == ""))
	{		
	     alert('Please enter width');
         document.SmallQuoteForm.Forth_item_width.focus();
		 return false;
	}
	//check 4th item description
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.forth_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Forth_item_description.value) == ""))
	{		
	     alert('Please enter description');
         document.SmallQuoteForm.Forth_item_description.focus();
		 return false;
	}

	//check 5th item height
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.fifth_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Fifth_item_height.value) == ""))
	{		
	     alert('Please enter height');
         document.SmallQuoteForm.Fifth_item_height.focus();
		 return false;
	}
	//check 5th item length
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.fifth_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Fifth_item_length.value) == ""))
	{		
	     alert('Please enter length');
         document.SmallQuoteForm.Fifth_item_length.focus();
		 return false;
	}
	//check 5th item width
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.fifth_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Fifth_item_width.value) == ""))
	{		
	     alert('Please enter width');
         document.SmallQuoteForm.Fifth_item_width.focus();
		 return false;
	}
	//check 5th item description
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.fifth_item_weight.value != "0" ) && (removeSpaces(document.SmallQuoteForm.Fifth_item_description.value) == ""))
	{		
	     alert('Please enter description');
         document.SmallQuoteForm.Fifth_item_description.focus();
		 return false;
	}


	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.First_item_height.value > 190) ||(document.SmallQuoteForm.First_item_length.value > 190) || (document.SmallQuoteForm.First_item_width.value > 190)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.First_item_total_size.focus();
		return false;
	}
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.Second_item_height.value > 190) ||(document.SmallQuoteForm.Second_item_length.value > 190) || (document.SmallQuoteForm.Second_item_width.value > 190)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.First_item_total_size.focus();
		return false;
	}
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.Third_item_height.value > 190) ||(document.SmallQuoteForm.Third_item_length.value > 190) || (document.SmallQuoteForm.Third_item_width.value > 190)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.First_item_total_size.focus();
		return false;
	}
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.Forth_item_height.value > 190) ||(document.SmallQuoteForm.Forth_item_length.value > 190) || (document.SmallQuoteForm.Forth_item_width.value > 190)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.First_item_total_size.focus();
		return false;
	}
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.Fifth_item_height.value > 190) ||(document.SmallQuoteForm.Fifth_item_length.value > 190) || (document.SmallQuoteForm.Fifth_item_width.value > 190)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.First_item_total_size.focus();
		return false;
	}
    
	if ((!document.SmallQuoteForm.First_item_height.disabled) && (document.SmallQuoteForm.First_item_height.value != '') && (firstSize == 0)) {
		// something is wrong
		alert('please enter number > 0 for all dimensions');
                            document.SmallQuoteForm.First_item_total_size.focus();
		return false;
	}

	if ((!document.SmallQuoteForm.First_item_height.disabled)  && (firstSize > 0.125)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.First_item_total_size.focus();
		return false;
	}

	if ((!document.SmallQuoteForm.Second_item_height.disabled) && (document.SmallQuoteForm.Second_item_height.value != '') && (secondSize == 0)) {
		// something is wrong
		alert('please enter number > 0 for all dimensions');
                            document.SmallQuoteForm.Second_item_total_size.focus();
		return false;
	}

	if ((!document.SmallQuoteForm.Second_item_height.disabled) && (secondSize > 0.125)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.Second_item_total_size.focus();
		return false;
	}
	if ((!document.SmallQuoteForm.Third_item_height.disabled) && (document.SmallQuoteForm.Third_item_height.value != '')&& (thirdSize == 0)) {
		// something is wrong
		alert('please enter number > 0 for all dimensions');
                            document.SmallQuoteForm.Third_item_total_size.focus();
		return false;
	}
	if ((!document.SmallQuoteForm.Third_item_height.disabled) && (thirdSize > 0.125)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.Third_item_total_size.focus();
		return false;
	}


	if ((!document.SmallQuoteForm.Forth_item_height.disabled) && (document.SmallQuoteForm.Forth_item_height.value != '') && (forthSize == 0)) {
		// something is wrong
		alert('please enter number > 0 for all dimensions');
                            document.SmallQuoteForm.Forth_item_total_size.focus();
		return false;
	}
	
	if ((!document.SmallQuoteForm.Forth_item_height.disabled) && (forthSize > 0.125)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.Forth_item_total_size.focus();
		return false;
	}

	if ((!document.SmallQuoteForm.Fifth_item_height.disabled) && (document.SmallQuoteForm.Fifth_item_height.value != '') && (fifthSize == 0)) {
		// something is wrong
		alert('please enter number > 0 for all dimensions');
                            document.SmallQuoteForm.Fifth_item_total_size.focus();
		return false;
	}
	
	if ((!document.SmallQuoteForm.Fifth_item_height.disabled) && (fifthSize > 0.125)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.Fifth_item_total_size.focus();
		return false;
	}
	
	if (!document.SmallQuoteForm.First_item_height.disabled)
	  {
	    document.SmallQuoteForm.First_item_total_size.value = firstSize;
	    document.SmallQuoteForm.Second_item_total_size.value = secondSize;
	    document.SmallQuoteForm.Third_item_total_size.value = thirdSize;
	    document.SmallQuoteForm.Forth_item_total_size.value = forthSize;
        document.SmallQuoteForm.Fifth_item_total_size.value = fifthSize;  
	  } 

	  return true;			
    
}

function CheckFields() { 

   //smquote();  

	
	if ((document.SmallQuoteForm.First_item_total_size.value > 0.125)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.First_item_total_size.focus();
		return false;
	}
	if ((document.SmallQuoteForm.Second_item_total_size.value > 0.125)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.Second_item_total_size.focus();
		return false;
	}
	if ((document.SmallQuoteForm.Third_item_total_size.value > 0.125)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.Third_item_total_size.focus();
		return false;
	}
	if ((document.SmallQuoteForm.Forth_item_total_size.value > 0.125)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.Forth_item_total_size.focus();
		return false;
	}
	if ((document.SmallQuoteForm.Fifth_item_total_size.value > 0.125)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.Fifth_item_total_size.focus();
		return false;
	}
	if (document.SmallQuoteForm.your_name.value == "" ) {
		// something is wrong
		alert('Please enter your name');
                            document.SmallQuoteForm.your_name.focus();
		return false;
	}
	if (document.SmallQuoteForm.email_address.value == "" ) {
		// something is wrong
		alert('Please enter your email');
                            document.SmallQuoteForm.email_address.focus();
		return false;
	}
	if (document.SmallQuoteForm.confirm_email_address.value == "" ) {
		// something is wrong
		alert('Please confirm your email');
                            document.SmallQuoteForm.confirm_email_address.focus();
		return false;
	}
	if (!document.SmallQuoteForm.owned_email.checked ) {
		// something is wrong
		alert('Are your the owner of the email address?');
                            document.SmallQuoteForm.owned_email.focus();
		return false;
	}
   // if ((document.SmallQuoteForm.Total_cost.value != '' ) && (parseFloat(document.SmallQuoteForm.Total_cost.value) > 45) ) {
    //                        alert ('Your total shipment cost is over $45 - please use the Large/Heavy Item Quote Form');
   //                         document.getElementById('totalCostNote').focus();
	//	return false;                        
   //                 }
	 if ((document.SmallQuoteForm.Total_cost.value == '' ) ) {
        alert ('No Calculation');
                            document.getElementById('totalCostNote').focus();
		return false;                        
   }

   if ((!document.SmallQuoteForm.elements['rural_pickup'][0].checked) && (!document.SmallQuoteForm.elements['rural_pickup'][1].checked))
   {
     document.SmallQuoteForm.elements['rural_pickup'][1].checked = true; 
   }
   if ((!document.SmallQuoteForm.elements['rural_delivery'][0].checked) && (!document.SmallQuoteForm.elements['rural_delivery'][1].checked))
   {
     document.SmallQuoteForm.elements['rural_delivery'][1].checked = true; 
   }

	return true; 

}

function CheckQQCFields() { 

   //smquote();  

	
	if ((document.SmallQuoteForm.First_item_total_size.value > 0.125)) {
		// something is wrong
		alert('please use the Large/Heavy Item Quote Form');
                            document.SmallQuoteForm.First_item_total_size.focus();
		return false;
	}
	
	if (document.SmallQuoteForm.your_name.value == "" ) {
		// something is wrong
		alert('Please enter your name');
                            document.SmallQuoteForm.your_name.focus();
		return false;
	}
	if (document.SmallQuoteForm.email_address.value == "" ) {
		// something is wrong
		alert('Please enter your email');
                            document.SmallQuoteForm.email_address.focus();
		return false;
	}
	if (document.SmallQuoteForm.confirm_email_address.value == "" ) {
		// something is wrong
		alert('Please confirm your email');
                            document.SmallQuoteForm.confirm_email_address.focus();
		return false;
	}
	if (!document.SmallQuoteForm.owned_email.checked ) {
		// something is wrong
		alert('Are your the owner of the email address?');
                            document.SmallQuoteForm.owned_email.focus();
		return false;
	}
   // if ((document.SmallQuoteForm.Total_cost.value != '' ) && (parseFloat(document.SmallQuoteForm.Total_cost.value) > 45) ) {
    //                        alert ('Your total shipment cost is over $45 - please use the Large/Heavy Item Quote Form');
   //                         document.getElementById('totalCostNote').focus();
	//	return false;                        
   //                 }

   if ((!document.SmallQuoteForm.elements['rural_pickup'][0].checked) && (!document.SmallQuoteForm.elements['rural_pickup'][1].checked))
   {
     document.SmallQuoteForm.elements['rural_pickup'][1].checked = true; 
   }

	return true; 

}

function compare() {
  if (document.SmallQuoteForm.confirm_email_address.value != document.SmallQuoteForm.email_address.value){
    alert ("Email address doesn't match");
 }

}

function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + '.' + cents);
//return (((sign)?'':'-')  + num);
}

function decodeqqc(sQQC)
{

  sGlobalqqc = sQQC;
  smquote('decodeqqc');

}
