// functions.js
function setVariation(txtDesc){
 if (document.getElementById){
      document.getElementById('varDesc').innerHTML=txtDesc;
  } else if (document.all){
      document.all['varDesc'].innerHTML=txtDesc;
  }
}

function selectVariation(vsNum){
 var fldVS = document.getElementById('fldVS');
 fldVS.value=vsNum;
 var vsDisp = document.getElementById('vsDisp');
 vsDisp.innerHTML=vsNum;
}

function largeProdImage(imageId){
  popupWin=window.open("", "largeImage", "width=300,height=300,status=no,resizable=no,scrollbars=no");
  popupWin.document.writeln('<html>');
  popupWin.document.writeln('<head>');
  popupWin.document.writeln('<title>Colour and Detail</title>');
  popupWin.document.writeln('</head>');
  popupWin.document.writeln('<body bgcolor="#FFFFFF" marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">');
  popupWin.document.writeln('<img src="'+imageId+'" width="300" height="300">');
  popupWin.document.writeln('</body>');
  popupWin.document.writeln('</html>');
}

function basketAdd(){
 var fldVS = document.getElementById('fldVS');
 var fldQty = document.getElementById('fldQty');
  AddProduct.add2Shopping(fldVS.value, fldQty.value,addedBasket); 
}


function basketAdd(vsFieldId, qtyFieldId){
   var qty = 1;
	 var fldVS = document.getElementById(vsFieldId);
	 if (qtyFieldId != null){
	 	var fldQty = document.getElementById(qtyFieldId);
	 	if (fldQty != null){
	 		qty = fldQty.value;
	 	}
	 }
  AddProduct.add2Shopping(fldVS.value, qty, addedBasket); 
}

function add2Basket4ProductList(pNum, qtyFieldId){
  var qty = 1;
  var fldQty = document.getElementById(qtyFieldId);
  if (fldQty != null){
  	qty = fldQty.value;
  }
  AddProduct.add2Shopping(pNum, qty, addedBasket);     	
}


function dittoAdd(){
 var fldVS = document.getElementById('fldVS');

  AddProduct.add2Ditto(fldVS.value, addedDitto);	
}

function shoppingListAdd(title, isSponsoring){
  var fldVS = document.getElementById('fldVS');
  if (isSponsoring == true){
  	confirmAdd2SponsoringShoppingList(fldVS.value);
  }else{
  	confirmAdd2ShoppingList(fldVS.value);	
  }
}


function addedBasket(bs){
  if(""!=bs.itemQty){
    var  itm=document.getElementById('bsItemQty');
    if(itm!=null)
      itm.innerHTML=bs.itemQty;
    itm=document.getElementById('bsPriceIBO');
    if(itm!=null)
      itm.innerHTML=bs.priceIBO;
    itm=document.getElementById('bsPriceMember');
    if(itm!=null)
      itm.innerHTML=bs.priceMember;
    itm=document.getElementById('bsPriceRetail');
    if(itm!=null)
      itm.innerHTML=bs.priceRetail;
    itm=document.getElementById('bsPV');
    if(itm!=null)
      itm.innerHTML=bs.pv;
    itm=document.getElementById('bsBV');
    if(itm!=null)
      itm.innerHTML=bs.bv;
    itm=document.getElementById('bsSavingsIBO');
    if(itm!=null)
      itm.innerHTML=bs.savingsIBO;
    itm=document.getElementById('bsSavingsMember');
    if(itm!=null)
      itm.innerHTML=bs.savingsMember;
    alert(bs.lastDescription+" ("+bs.lastVSNumber+") has been added to your basket.");	
  }else{
    alert("Error adding product ("+bs.lastVSNumber+") to your basket.");
  }
}
function addedDitto(text){
  alert(text);
}

