// boss.js
//  ===============================================================
//  "BOSS" SCRIPT
//  for Shop@ssistant Classic Version 3.6.4C+ by Rodney Myers
//  Copyright © 2000-2002, Hodgson Myers Associates Ltd
//  Version 2.1
//  An Add-On for Shop@ssistant Classic
//  rodney@aflyingstart.net                       Tel +44 (0)1865 200025
//  http://www.aflyingstart.net/addons/
//  Last Revised August 2002
//  ===============================================================
var INSASS=false;
var outsideSystemHandler=2;
var MAX_QTY=99999999;
var currencyCode="£";
var usePOP=false; // set usePOP=true on any page where you wish to use the feature
function start_shop()  {
if(common_test() && !top.INSASS)
	{
	setLocation(); // cookie
	top.location.href =startup;
	}
} //
function pages_browser_test(){
/* Adapted from Ultimate client-side JavaScript client sniff. (C) Netscape Communications 1999.  Permission granted to reuse and distribute. */
var agt,is_major,is_nav,is_nav3up,is_ie3up;
 agt=navigator.userAgent.toLowerCase();
 is_major = parseInt(navigator.appVersion);
 is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1));
 is_nav3up = (is_nav && (is_major >=3));
 is_ie3up  = ((agt.indexOf("msie") != -1) && (is_major >=2));
 ////// Allow OPERA 6 : July 2002
 var is_opera6up=(is_major >= 4) && (agt.indexOf('opera 6')>-1);
 return(is_nav3up||is_ie3up||is_opera6up);
 }// end pages_browser_test

function common_test(){
var ret=pages_browser_test();
if(!ret){alert("Sorry, your browser is not supported");}
return(ret);
}


function nosass(){ /* Used if system not loaded and functions in "For LOD" section are called */
if(confirm("Load shopping system,then\nreturn to this page to continue?\n Please note you'll have to click the button again?n eg click on review basket or terms\n once the system is loaded"))
{ start_shop(); } else {return(' ');} }//

// For LOD
// -------
function ToLobby()      { nosass(); }
function reviewbasket() { nosass(); }
function terms()        { nosass(); }
function checkout()     { nosass(); }

// For BOSS operation
// ------------------
function newchoice(d,r,v1,v2,p,q,w,t,per,group){
per=(per==null)?1:per;group=(group==null)?'0':group;
newchoice1(d,r,v1,v2,p,q,w,t,per,group);}

function newchoice1(d,r,v1,v2,p,q,w,t,per,group){
per=(per==null)?1:per;// for FromPop
group=(group==null)?'0':group;
if(common_test())
{
var loc=startup;
loc+="?";
loc+="d="+u(d)+"&";
loc+="r="+u(r)+"&";
loc+="v1="+u(v1)+"&";
loc+="v2="+u(v2)+"&";
loc+="p="+u(p)+"&";
loc+="q="+u(q)+"&";
loc+="w="+u(w)+"&";
var TAX_DEFAULT=1; // Match this with vars of same name in tax.htm and startup file 'root' index.html
t= (t==null) ? TAX_DEFAULT : t ;
loc+="t="+u(t)+"&";
loc+="per="+u(per)+"&";
loc+="group="+u(group);
// For Pop-up of basket addition
// set usePOP=true on any page where you wish to use the feature
loc+=usePOP?"&f=BOSSPOP":"";
setLocation();
window.location.href=loc;
}
}//

function dpw(d,p,w){ w=(w==null)?0:w; newchoice(d,"","","",p,1,w,null,1,0); }
function drpw(d,r,p,w){ w=(w==null)?0:w; newchoice(d,r,"","",p,1,w,null,1,0); }
function tempBuyConfirmation(LTR){LTR=LTR.toUpperCase();if(LTR=="P"){usePOP=true;} }


function setLocation(){
var saveLoc=(window.frames.length>0)?myFrame.location.href:window.location.href;
document.cookie = "LOADTHISPAGENOW" + "=" + escape(saveLoc)+"; path=/";
}

// Make data into URL format
function u(str){ var ret="";var ch; str=escape(str); for(var i=0;i<str.length;i++){ch=str.charAt(i);ret+=(ch=="+")?"%2B":ch;} return(ret); }

// For display of prices
function MCP(V){V=parseFloat(""+V);if(V==Math.floor(V)){V+=".00";}else if(10*V==Math.floor(10*V)){V+="0";} return(currencyCode+V);}
function wMCP(V){ var WD=(window.frames.length>0)?myFrame.document:window.document; WD.write(MCP(V));}
function wCMCP(V){wMCP(V);}
var MC=new MCF();
function MCF(){
this.MCPrice=MCP;
return(this);
}

// MC4 buttonbars and links (no action, no error)
function makeButtonBarH(){}
function makeButtonBarV(){}
function makeTextLinksH(){}
function makeTextLinksV(){}


// For quantity/remove checkbox features in Review
function noremove(V){return(""+-1*parseFloat(V))+"!";}
function revQfix(a,i,n,x){i=(i==null)?1:i;n=(n==null)?1:n;x=(x==null)?999999:x;return (""+a+";"+i+";"+n+";"+x);}
function qlock(V){return(-1*parseFloat(V));}

// for Quantity inputs
function qty_fix(elem,Increment,qMin,qMax) { var ev=elem.value; ev=Math.abs(ev); qMax=(qMax==null)?MAX_QTY:qMax;if(ev=="NaN"){ev=qMin;} else if(ev<qMin){ev=qMin;} else if(ev>qMax){ev=qMax;} else if( (ev-qMin)/Increment != Math.ceil((ev-qMin)/Increment)){ev=1*qMin+Math.ceil((ev-qMin)/Increment)*Increment;} elem.value=ev; }

// for SELECT boxes
function listvalue(List){return(List.options[List.selectedIndex].value);}
function listtext(List){return(List.options[List.selectedIndex].text);}

// For splitting data
function parser(InString,Sep){ Sep=(Sep==null)?";":Sep; InString="_"+Sep+InString; var ARR=InString.split(Sep);ARR[0]=ARR.length-1; return(ARR); }

// for MC4 frameset
waiting3=false;

