function ordersummary()
{
  // read the order from the cookie and display the number of items and the total
  var numitems = getcookie("numitems");
  if (numitems == "") numitems = 0;
  var total = 0;
  var subtotal = 0;
  var cnt = 1;
  do
  {
    if (cnt > numitems) break;
    fieldname = "orderline-"+cnt;
    orderline = getcookie(fieldname);
    price = items(orderline, 6, "%7C");
    qty = items(orderline, 3, "%7C");
    subtotal = price * qty;
    total = total + subtotal;    
    cnt++;
  } while (1==1);
  // format the total 
  total = total.toFixed(2);

  // display us over the homepage / header
  imgname = "homepage";
  var obj = FIND(imgname) || document.images[imgname] || document.links[imgname] || document.anchors[imgname];
// position : 741, 12 px from top left of homepage
  x = moveXbySlicePos (741, obj);
  y = moveYbySlicePos (10, obj);
  document.write('<div style="position : absolute; top : '+y+'px; left : '+x+'px; z-index : 10; color : black;">');
  document.write(numitems+' items - <b>&pound;'+total+'</b>');
  document.write('</div>');
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
alert(radioObj.name);
	var radioLength = radioObj.length;
alert(radioLength);
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}



function addtocart()
{
//  if (isNaN(document.getElementById("qty").value) || document.getElementById("qty").value == "")
//  {
//    alert("Please enter a quantity");
//    document.getElementById("qty").focus();
//    return;
//  }
//  document.getElementById("prodqty").value = document.getElementById("qty").value;

  document.shop.submit();
}

function hoselength(which)
{
  var hosestr = document.getElementById("hoselength1").value;
  if (which == 2) hosestr = document.getElementById("hoselength2").value;
  document.getElementById("prodsize").value = hosestr;
  if (which == 1) hosestr = document.getElementById("hoselength2").checked = false;
  if (which == 2) hosestr = document.getElementById("hoselength1").checked = false;

}


// support functions
function FIND(item) {
	if( window.mmIsOpera ) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}

function moveXbySlicePos (x, img) { 
	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.leftMargin && ! onWindows ) x += parseInt(par.leftMargin);
			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
			if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}
	} else if (img.x) x += img.x;
	return x;
}

function moveYbySlicePos (y, img) {
	if(!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}		
	} else if (img.y >= 0) y += img.y;
	return y;
}


