// <!-- FEB 2003 -->
// boss.js
//  ===============================================================
//  "BOSS" SCRIPT
//  for Shop@ssistant Classic Version 3.6.4C+ by Rodney Myers
//  Copyright © 2000-2003, Hodgson Myers Associates Ltd
//  Version 2.21
//  An Add-On for Shop@ssistant Classic
//  rodney@aflyingstart.net                       Tel +44 (0)1865 200025
//  http://www.aflyingstart.net/addons/
//  Last Revised February 2003
//  ===============================================================

// OSC vars
var osCsid='';
var osCsystem='http://www.nickys-nursery.co.uk/catalog';
// var osCsystem='http://www.nickys-nursery.co.uk/ota';
// var osCsystem='http://www.garden-games.biz/seeds-store';

// OSC functions

function search(){
document.write('<form name="search" action="'+osCsystem+'/advanced_search_result.php" method="GET">');
var u,v;
u=document.location.href.split("#");
document.write('<input type="hidden" name="anchor" value="top">');
document.write('<input type="hidden" name="SASSpage" value="'+u[0]+'">');
if(top.osCsid !=''){
	sid=top.osCsid.split("=");
	document.write('<input type="hidden" name="osCsid" size="64"  value="'+sid[1]+'">');
}
document.write('<input type="text" name="keywords" size="14">');
document.write('<br>');
document.write('<input type="Submit" value="   Search   " alt="Seed Search" name="B1"></form>');
}

function reviewbasket() { 
var path;
path=osCsystem+"/shopping_cart.php";
path=path+"?SASSpage="+getpage();
if(top.osCsid !=''){
path=path+"&"+top.osCsid;
}
top.location.href=path;
 }

function OSC_login()
{
var path;
path=osCsystem+"/login.php";
path=path+"?SASSpage="+getpage();
if(top.osCsid !=''){
path=path+"&"+top.osCsid;
}
top.location.href=path;
}

function OSC_contact_us()
{
var path;
path=osCsystem+"/contact_us.php";
path=path+"?SASSpage="+getpage();
if(top.osCsid !=''){
path=path+"&"+top.osCsid;
}
top.location.href=path;
}


function newchoice(d,r,v1,v2,p,q,w,t,per,group)
{
var path;
var model="";
var ref;
if(per==1 && group==2){
model="UK";
}
path=osCsystem+"/shopping_cart.php?products_model=";
path=path+r+model+"&action=sass_add_prod";
path=path+"&SASSpage="+getpage()+"&anchor="+r;
if(top.osCsid !=''){
path=path+"&"+top.osCsid;
}
top.location.href=path;
}

function v2getpage(){
	t=document.location.split("#");
	return(t[0]);
}

function getpage(){
var loc;
if(top.osCsid ==''){
	loc=document.location.href;
}
else{
	loc=osc.location.href;
}
var u=loc.split("#");
var v=u[0].split("?");
var t=v[0];
return(t);
}

// LOD/BOSS
var INSASS=false;

// LOD vars
var currencyCode="£";
var colPbar="|";var colPsemi=";";

// BOSS Vars
var MAX_QTY=99999999;
var usePOP=false; // set usePOP=true on any page where you wish to use the feature
var outsideSystemHandler=2;

// BOSS Functions
function start_shop()  {
if(common_test() && !top.INSASS)
	{
	setLocation(); // cookie
	top.location.href =startup+"?loadnow";
	}
} //

// Common LOD/BOSS functions
function setLocation(){
var saveLoc;
/*
If introducing an iframe eg from uk.affiliates.com (and no other frames)
name is inaccesssible so no point in adding a name to the iframe
*/
if(window.frames.length==0 || window.frames.length==1)
		{saveLoc = window.location.href;}
else	{saveLoc = myFrame.location.href;}
/*
If using a framed site and encountering problems please
delete if else clauses above and revert to next line
*/
// saveLoc=(window.frames.length>0)?myFrame.location.href:window.location.href;
document.cookie = "LOADTHISPAGENOW" + "=" + escape(saveLoc)+"; path=/";
}

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?"))
{ start_shop(); } else {return(' ');} }//


// For LOD type operation
function ToLobby()      { nosass(); }

function terms()        { 
window.open("http://www.nickys-nursery.co.uk/ota/html/terms.htm","","directories=0,height=500,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0,left=20,top=20,width=700"); 
}

function checkout()     { nosass(); }

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

// For display of prices
function MCP(V){
V=parseFloat(""+V);
V=Math.floor(V*100)/100;
if(V==Math.floor(V)){V+=".00";}else if(10*V==Math.floor(10*V)){V+="0";} return(currencyCode+V);}

function wMCP(V,Q,special){
if(typeof(special)=="string" && special=="p4q"){V=""+p4q(V,Q);}
if(top.osCsid ==''){
	document.write(MCP(V));
	}
else{
	osc.document.write(MCP(V));
	}
}

function wCMCP(V){wMCP(V);}
var MC=new MCF();
function MCF(){
this.MCPrice=MCP;
return(this);
}

function p4q(Pstring,Q){
var tmp=Pstring.split(colPbar);var min=tmp[0].split(colPsemi);
var prc=tmp[1].split(colPsemi);
for(var n=min.length-1;n>0;n--)
	{ if(Q>=1*min[n]){break;} }
return(""+prc[n]);
}


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){if(LTR){LTR=LTR.toUpperCase();if(LTR=="P"){usePOP=true;} }}


// 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 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;
var permitted="1234567890";
permitted += Increment<1 ? "." : "";
ev=clean(ev,permitted);
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;
}//

function clean(str,permitted){
str=""+str;
var nchar,n;var out="";
for(n=0;n<str.length;n++)
	{
	nchar=str.charAt(n);
	out+=permitted.indexOf(nchar)>-1?nchar:"";
	}
return(out);
}

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

// for currency change
function ChangeCurrency()    { nosass(); }
function cChange()    { nosass(); } // v3.x

// 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;

// Cookies
function setCookie(name,value,expire){ var temp=name; temp+="="+escape(value); temp+=(expire==null) ? "" : "; expires=" + expire.toGMTString(); temp+="; path=/"; document.cookie=temp; }
function getCookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      end = document.cookie.indexOf(";", offset);
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}
var ref;
var today=new Date();
var expires=new Date();
	expires.setTime(today.getTime() + 365*24*60*60*1000);
if (getCookie('nicky_referrer')==''){
	ref=document.referrer
	if(ref!=''){
		setCookie('nicky_referrer',ref,expires)
	}
}


function to_cart(){
        top.location='http://www.nickys-nursery.co.uk/catalog/shopping_cart.php'+"?SASSpage="+getpage();
}
        window.setTimeout('to_cart();',1000*1200);

