//  ===============================================================
//  Copyright © 2000, The Floyd Consultancy Ltd. All rights reserved.
//  Shop@ssistant by Rodney Myers
//  ===============================================================
//
var Ref         = ""       // Identifying Reference
var VarA        = ""
var VarB        = ""
var BasePrice   = 0             // Base model Price
var Price                       // Final Price
var Weight      = 0
var Taxcode     = 1             // 1 = standard rate (may be omitted and default code of 1 set for all)
var Q           = 1

var errormsg="";
var CRLF=unescape("%0D%0A");
var basics_chosen;
var choice=new Array();

//     NAME OF               WHAT IS        true IF
//     SELECT                CHOSEN         REQUIRED

choice["SEL1"]   = new SelObj("PC System"   , true );
choice["SEL2"]   = new SelObj("Processor"  , false);
choice["SEL3"]   = new SelObj("Monitor"     , false);
choice["SEL4"]   = new SelObj("Op. System"  , false );
choice["SEL5"]   = new SelObj("Software" , false );
choice["SEL6"]   = new SelObj("Speakers"   , false);
choice["SEL7"]   = new SelObj("Opt. Storage"  , false);
choice["SEL8"]   = new SelObj("Hard Drive"       , false);
choice["SEL9"]   = new SelObj("Miscellaneous"    , false);
choice["SEL10"]   = new SelObj("Graphics"      , false);
choice["SEL11"]   = new SelObj("Memory"   , false);
choice["SEL12"]   = new SelObj("Web Cam"     , false);
choice["SEL13"]  = new SelObj("Printer"     , false);
choice["SEL14"]  = new SelObj("Scanner", false);
choice["SEL15"]  = new SelObj("Keyboard", false);
choice["SEL16"]  = new SelObj("Network", false);
choice["SEL17"] = new SelObj("Warranty"    , false);
choice["SEL18"] = new SelObj("Delivery"    , true);

function SelObj(what,required){
this.what = what;
this.required = required; // If set true the item MUST be chosen
return(this);
}

function Add2Basket(form){
Q    = 1 ;
basics_chosen=true; // set false if any marked true are NOT chosen
errormsg="";
calcPrice(form)
VarA  = " which contains "+CRLF;

for(var Listname in choice) // Goes through all the Lists named as keys to choice[]
{
 VarA += textfrom(eval("form."+Listname), choice[Listname].what, choice[Listname].required);
}

VarB  = ""
if(basics_chosen)
 {top.newchoice(Description,Ref,VarA,VarB,Price,Q,Weight,Taxcode);}
else
 {alert("Please select : \n" +errormsg);}
return(false);
}

function textfrom(List,what,required){
var ret="";
if(List.selectedIndex!=0 )
 {
  ret=what+ " : "+top.listtext(List)+CRLF;
 }
else
 {
 // check if marked true and so essential
 errormsg+=required? " - "+what+"\n" :"";
 // set false if item IS required
 basics_chosen=required?false:basics_chosen;
 }
return(ret);
}

function calcPrice(form){
if(top.INSASS)
{
Price  = BasePrice;

for(var Listname in choice) // Goes through all the Lists named as keys to choice[]
{
 Price += 1*top.listvalue(eval("form."+Listname));
}

top.MC.setMCPrice(form.Total,Price)
// form.Total.value = top.padL(top.MC.MCPrice(Price)," ",12);

// above line positions price nicely, but will not be acceptable if
// Currency symbol is an image (eg for Euro),
// whereas this line will substitute the currency 3 letter code
// top.MC.setMCPrice(form.Total,Price);

}
else{nosass();}
}

function nomonitor(){
alert ("This is an upgrade option and only available with a full system.  If this option is chosen with any PC System without a monitor then the order will not be processed.  Thankyou")
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}