			function popup_weightToKg(weight_lb) {

				var x=document.getElementById("weight_kg");
				if (weight_lb.value > 0) {
					x.value = Math.round(10*weight_lb.value / 2.2)/10;
				}
			}
			function popup_weightToLb(weight_kg) {
				var x=document.getElementById("weight_lb");
				if (weight_kg.value > 0) {
					x.value = Math.round(10*weight_kg.value * 2.2)/10;
				}
			}

			function popup_dimWeight ()
			{	  
				  var convfact, vol, volw, b, v, fweight, error_message, error;

				  // conversion factor is taken from the hidden field called 'div' - this is the factor by by which we divide the volume (which is the product of length*width*depth), in order to get the dim weight
				  // set based on countries_id
				  var countries_id = document.getElementById('countries_id').value;
				  var dim_weight = document.getElementById('dim_weight');
				  var dim_length = document.getElementById('dim_length');
				  var dim_width = document.getElementById('dim_width');
				  var dim_height = document.getElementById('dim_height');
				  var dim_weight_text  = document.getElementById('dim_weight_text');

/*				  // must have country input
				  if (countries_id == '') {
					  dim_weight.value = 0;
					  dim_weight_text.value = '';
					  document.getElementById('textDim').className	="noDisplay";
					  document.getElementById('valueDimText').className	="noDisplay";
					  return;
				  }
*/
				  // must have all 3 dimensions input in order to get dim weight
				  if  ((dim_length.value == '') ||
					  (dim_width.value == '')  ||
					  (dim_height.value == ''))  {
					  dim_weight.value = 0;
					  dim_weight_text.value = '';
					  document.getElementById('textDim').className	="noDisplay";
					  document.getElementById('valueDimText').className	="noDisplay";
					  return;
				  }

				  var unit;
				  var unit_type = document.getElementById('imp');

				  if(document.getElementById('imp').checked){
					  unit = 'imp';
				  }else{
					  unit = 'met';
				  }

				  var country_type;
				  if (countries_id == '223')
				  {
					  country_type = "dom";
				  }else{
					  country_type = "int";
				  }

				  if( country_type == "dom" ) 			// if domestic
				  {
					if (unit == "imp") // inches
					{
					   convfact=166;
					}
					else // metric
					{
					   convfact=7012;
					}
				  }
				  else 					// if International
				  {
					if (unit == "imp")
					{
					   convfact=139; //inches
					}
					else
					{
					   convfact=5000; // metric
					}
				  }

				  // volume is the product of length*width*depth
				  vol = dim_length.value * dim_width.value * dim_height.value;

				  // divide volume by factor
				  volw =  vol / convfact;

				  // get remainder and round up
				  b = volw - parseInt( volw );	  
				  if( b <= .5 && 0 < b && (convfact == 6000 || convfact == 7012) )
				  {
					c=.5;		// if Kg go to next pound or half Kilo
				  }
				  else // if( (.5 < b) && (b < 1 ) )
				  {
					c=1;		// if Lbs go to next pound
				  }
				  if( b==0 ) c=0;

				  fweight = volw - b + c;

				  if( vol != 0 && ( isNaN( fweight ) || fweight < 1 ) ) fweight = 1;

				  if (unit_type.checked)
				  {
					 unit = " Pound(s)";
					 // put dim weight in lbs on page so can pass to calculator.php page when submitted
					 passWeight = parseFloat(fweight);
					 dim_weight.value = parseFloat(fweight);
				  }
				  else
				  {
					 unit = " Kilogram(s)";
					 // put dim weight in kg on page so can pass to calculator.php page when submitted
					 // there is no domestic option in kg on caculator page, so don't pass weight_lb
					 passWeight = parseFloat(fweight);
					 dim_weight.value = parseFloat(fweight * 2.2); // convert to lbs
				  }

				  dim_weight_text.value = parseFloat(fweight)+unit;
//				  document.getElementById('textDim').className	="doDisplay";
//				  document.getElementById('valueDimText').className	="doDisplay";
			//alert('dim='+dim_weight.value);
				  return 1;

				}

				function popup_changetype(element)
				{
				  var unit, convfact, form, type;
				  form=element.form;
				  if (unit_type.checked)
				  {
					 unit = "imp"; // inches
				  }
				  else
				  {
					 unit = "met"; // metric
				  }
				  type=element.value;

				  if( type == "dom" ) 			// if domestic
				  {
					if (unit == "imp") // inches
					{
					   convfact=166;
					}
					else // metric
					{
					   convfact=7012;
					}
				  }
				  else 					// if International
				  {
					if (unit == "imp")
					{
					   convfact=139; //inches
					}
					else
					{
					   convfact=5000; // metric
					}
				  }
				}

				function popup_changeunits(element)
				{
				  var unit, convfact, form, type, conv;
				  form=element.form;
				  if (unit_type.checked)
				  {
					 type = "dom"; // domestic
				  }
				  else
				  {
					 type = "int";// intl
				  }
				  unit=element.value;
				  conv=1;

				  if( unit == "imp" ) // inches
				  {
					if (type == "dom") // domestic
					{
					   convfact=166;
					}
					else // metric
					{
					   convfact=139;
					}
				  }
				  else
				  {
					if (type == "dom") // domestic
					{
					   convfact=7012;
					}
					else // intl
					{
					   convfact=5000;
					}
				  }
				}

