function terms() {
   var terms="<A NAME='tandc'></A><TABLE WIDTH='90%' BORDER='1' CELLSPACING='2' CELLPADDING='5'><TR><TD WIDTH='100%' BGCOLOR='#ffffff'>"
   terms+="<FONT SIZE='2' FACE='Arial'><B>Terms and Conditions:</B></FONT><FONT SIZE='1' FACE='Arial'><BR>"
   terms+="1. These Terms and Conditions constitute an agreement between Helen Hart t/as Mouseloft (hereinafter referred to as ‘The Seller’) and the party contracting with The Seller to acquire goods or services (hereinafter referred to as ‘The Buyer’) and supercede any previous agreements, warranties, representations, undertakings or understandings between the two parties and may not be varied except in writing.<BR>"
   terms+="2. Where there is a conflict between the meaning of any part of these Terms and Conditions and any part of any relevent further agreement made between the two parties these Terms and Conditions shall take precedence.<BR>"
   terms+="3. These Terms and Conditions will be deemed as accepted by both parties at the time The Seller receives a purchase order from The Buyer by any means, whether in writing or verbally.<BR>"
   terms+="4. Under these Terms and Conditions The Buyer undertakes to acquire from The Seller goods or services at a price consistent with The Seller’s relevant price list in use at the time that the order is submitted or at a price otherwise agreed between the two parties before the order is accepted by The Seller according to clause 6.<BR>"
   terms+="5. The Seller shall be under no obligation to accept an order from The Buyer and consequently The Seller shall not be liable in any way whatsoever to The Buyer until such acceptance is made according to clause 6.<BR>"
   terms+="6. An order shall be considered as accepted by The Seller upon the first date of delivery to The Buyer of all or part of the goods or services contained in the order or when The Buyer first receives written notification from The Seller which uniquely identifies the order and uses the words ‘your order has been accepted’.<BR>"
   terms+="7. All delivered goods remain the property of The Seller until full payment has been received from The Buyer for those goods.<BR>"
   terms+="8. A late payment is an amount of money which remains unpaid to The Seller on the due date as written on The Seller’s invoice. The Seller may charge interest for late payments at a rate of 1% per day of lateness for the first seven days and 0.1% per day thereafter.<BR>"
   terms+="9. Failed or cancelled payments including unpaid cheques will incur an administration charge of £20 for each occurrence.<BR>"
   terms+="10. The Seller may consider any order as cancelled upon the first occurrence of a failed, cancelled or otherwise stopped payment in respect of that order or upon any payment from the Buyer becoming late according to clause 8.<BR>"
   terms+="11. If The Buyer requests an alteration to any submitted order then the original order shall be considered cancelled and the altered order shall be considered a new order.<BR>"
   terms+="12. The Seller may charge The Buyer a fee appropriate to the work involved for any order which is cancelled by The Buyer for any reason including that given in clause 11 or cancelled by The Seller under clause 10. The Seller shall make a reasonable judgement as to the amount of the fee based upon work done and costs incurred for materials or services but the amount of the fee shall be limited to the full price which The Seller would have charged The Buyer for the cancelled order.<BR>"
   terms+="13. The risk in all goods delivered shall pass to The Buyer on delivery and The Buyer should insure accordingly.<BR>"
   terms+="14. The duty of The Seller to try to deliver goods under this contract shall be deemed to have been discharged after a reasonable number of delivery attempts at The Buyer’s usual delivery address or that stated in the order or upon the first refusal of the delivery by The Buyer for any reason whatsoever.<BR>"
   terms+="15. Any storage by The Seller of goods for which The Seller has discharged its responsibility to try to deliver according to clause 14 of this contract shall be charged to The Buyer at a rate deemed appropriate by The Seller.<BR>"
   terms+="16. The Seller shall not accept and shall not be liable for the return of goods from The Buyer unless it can be reasonably demonstrated that the goods were faulty or not fit for purpose at the time of delivery.<BR>"
   terms+="17. Advice of damage, delay or loss of goods in transit or of non-delivery must be given in writing to The Seller by The Buyer within 3 clear days (excluding Sundays) of delivery or in the case of non-delivery within 3 clear days (excluding Sundays) from the latest date agreed for delivery at the time of order or from the delivery date specified by The Seller where such a specification has been made. Where no delivery date has been agreed or specified by either party then The Buyer must advise The Seller of non delivery within four weeks from the date of The Buyer placing an order or within one week of the date of despatch of the goods if such a date has been communicated to The Buyer.<BR>"
   terms+="18. Insofar as is permitted by law The Seller’s liability under this contract shall be limited to the price charged by The Seller for goods which are shown to be defective or undelivered with no further liability for any consequential or inconsequential losses of The Buyer or of any third party with whom The Buyer is contracted.<BR>"
   terms+="19. Undelivered goods shall incur a liability upon The Seller limited by clause 18 when such goods remain undelivered two weeks after the latest delivery date reasonably expected according to the method of delivery. If the delivery is subsequently made after The Seller has refunded The Buyer or delivered replacement goods The Buyer shall either inform The Seller and request an invoice for the goods or shall make arrangements with The Seller for the return of the goods.<BR>"
   terms+="20. All intellectual property rights remain unaffected by the purchase of goods or services from The Seller unless explicitly agreed between the two parties in writing.<BR>"
   terms+="21. These Terms and Conditions shall be governed and construed in accordance with the laws of England.<BR>"
   terms+="22. Nothing in these Terms and Conditions shall affect the statutary rights of consumers.<BR>"
   terms+="23. All clauses and sub clauses of this agreement are severable and if any clause or identifiable part thereof is held to be unenforceable by any court of competent jurisdiction then such enforceability shall not affect the enforceability of the remaining provisions or identifiable parts thereof in these Terms and Conditions.<BR>"
   terms+="<P ALIGN='RIGHT'>This version of the Terms and Conditions has been applicable and on display at this website since 21 September 2010<BR>with part of clause 10 being added since the previous version<BR>"
   terms+="<A HREF='Mouseloft_TandC_21_09_10.pdf' TARGET='_blank'>DOWNLOAD PDF VERSION</A></P>"
   terms+="</FONT></TD></TR></TABLE>"
   return terms
}

function pageFooter()
{
  var footer="<TABLE BORDER='0' CELLSPACING='0' CELLPADDING='0'>"
  footer+="<TR><TD WIDTH='70'></TD>"
  footer+="<TD WIDTH='390' NOWRAP>"
  footer+="<B><FONT SIZE='+1'>This site is brought to you by a busy webmouse at</FONT></B><BR>"
  footer+="<IMG SRC='logoml.gif' WIDTH='405' HEIGHT='83' ALIGN='BOTTOM' BORDER='0' NATURALSIZEFLAG='3' ALT='Mouseloft' TITLE='Mouseloft'></TD>"
  footer+="<TD><B><FONT SIZE='-1' FACE='ARIAL'>"
  footer+="&quot;Mouseloft&quot;, the mouse device and all product range names are being used as trademarks by Helen Hart trading as Mouseloft,"
  footer+=" VAT REG. No. 616 4025 67<BR>&COPY; all product designs on this website Copyright Roger Hart and Helen Hart, 1995 to present. Nothing on this site may be copied or used in any way without permission.</FONT></B></TD>"
  footer+="<TD WIDTH='70' ALIGN='CENTER'><A HREF='http://www.fsb.org.uk/info' TARGET='_blank'>"
  footer+="<IMG SRC='fsblogo_member_white_60.jpg' WIDTH='60' HEIGHT='74' ALIGN='BOTTOM' BORDER='0' NATURALSIZEFLAG='3' ALT='Member of the FSB' TITLE='visit the FSB website'></TD>"
  footer+="</A></TR></TABLE>"
  return footer
}

function toHex(d)
{
  H=d.toString(16).toUpperCase()
  if(H.length % 2==1){H="0"+H}
  return H
}

function toHexString(Str)
{
  var hStr=""
  for(i=0;i<=Str.length-1;i++)
  {
    hStr+=toHex(Str.charCodeAt(i))
  }
  return hStr
}

function fromHexString(Str)
{
  var frmh=""
  if(Str.length % 2==1){Str="0"+Str}
  for(i=0;i<=Str.length-1;i+=2)
  {
    frmh+=String.fromCharCode(parseInt(Str.substring(i,i+2),16))
  }
  return frmh
}

function cyphr(InpString,kstr,d)
{
  var key=new Array(InpString.length)
  var keystr=kstr
  var zkey="m"
  while(keystr.length<InpString.length){keystr+=kstr}
  for(c=0; c<=InpString.length-1; c++)
  {
    key[c]=keystr.charCodeAt(c)-zkey.charCodeAt(0)
  }
  var cyphered=""
  var tempChar
  for(c=0; c<=InpString.length-1; c++)
  {
    tempChar=InpString.charCodeAt(c)+d*key[c]
    tempChar=tempChar & 255   // DON'T USE % 256 as treats negatives incorrectly
    cyphered+=String.fromCharCode(tempChar)
  }
  return cyphered
}

function cypher(InpString,kstr)
{return cyphr(InpString,kstr,-1)}

function uncypher(InpString,kstr)
{return cyphr(InpString,kstr,1)}

function cypherURI(InpString,kstr)
{return encodeURIComponent(cypher(InpString,kstr))}

function uncypherURI(InpString,kstr)
{return uncypher(decodeURIComponent(InpString),kstr)}

function cypherEsc(InpString,kstr)
{return escape(cypher(InpString,kstr))}

function uncypherEsc(InpString,kstr)
{return uncypher(unescape(InpString),kstr)}

function cypherHex(InpString,kstr)
{return toHexString(cypher(InpString,kstr))}

function uncypherHex(InpString,kstr)
{return uncypher(fromHexString(InpString),kstr)}

function oneWay(InpString)
{
  var c=cypher(InpString.substring(1,InpString.length),InpString)
  var cm=""
  var chck=0
  for (var i=0; i<InpString.length; i++)
  {
//alert(toHex(InpString.charCodeAt(i)))
    chck+=InpString.charCodeAt(i)
    chck&=255
  }
//alert("chck: "+toHex(chck))
  for (var i=0; i<c.length; i++)
  {
    cm+=String.fromCharCode((c.charCodeAt(i)+chck)&255)
  }
  return cm
}

function oneWayHex(InpString)
{return toHexString(oneWay(InpString))}



// -----------------------------------------------

function charRemoveNotify(teststring,dl,notify)
{
 if(dl.length>1){dl=dl.substring(0,1)}
// * is used as a delimiting char in the cust data cookie.
 dlimit=teststring.indexOf(dl,0)
 while(dlimit!=-1)
 {
   if(notify==true){alert(dl+" is an invalid character")}
   teststring=teststring.substring(0,dlimit)+teststring.substring(dlimit+1,teststring.length)
   dlimit=teststring.indexOf(dl,0)
 } 
 return teststring
}

function charRemove(teststring,dl)
{
 return charRemoveNotify(teststring,dl,true)
}

function charReplace(test, out, replace) {
  if(out==replace) return test;
  pos=test.indexOf(out);
  while(pos>-1) {
    test=test.substring(0,pos) + replace + test.substring(pos+out.length,test.length);
    pos=test.indexOf(out,pos+replace.length);
  }
  return test;
}

function plural(n)
{
  var s=""
  if(n!=1) {s="s"}
  return s
}

function reloadPage()
{
  document.execCommand("Refresh")
}

function trim(str)
{
  if(str.length==0) {return str}
  while(str.charAt(0)==" ") {str=str.substring(1,str.length)}
  while(str.charAt(str.length-1)==" ") {str=str.substring(0,str.length-1)}
  return str
}

function getSearchAsArray()
{
  var results=new Array();
  var input = parent.location.search;
  if (input)
  {
    if (input.substring(0, 1) == '?') {input = input.substring(1)}
    var srchArray=input
    var tempArray=srchArray.split("?")
    for(l=0; l<tempArray.length; l++) {
      var temp2Array=tempArray[l].split("=")
      results[temp2Array[0]]=unescape(tempArray[l].substring(temp2Array[0].length+1,tempArray[l].length))
    }
  }
  return results;
}

function checkFrameset()
{
  if(parent==window)
  {
    // use replace to keep current page out of history
    location.replace("index.htm?content="+escape(location.href))
  }
}

function kCheck()
{
  if(parent.dom.length==19) {keyword=oneWay(parent.dom)}
}

function setBackground()
{
  if(parent.TitleFrame.tradecust==true){document.body.background="aidaTrade.jpg"}
  else{document.body.background="aidaMO.jpg"}
}

function orderdatestring()
{
  var orderdate=new Date
  var ordDate=orderdate.getDate()
  var ordMonth=orderdate.getMonth()+1
  var ordYear=orderdate.getYear()
  var ordHours=orderdate.getHours()
  var ordMinutes=orderdate.getMinutes()
  var ordSeconds=orderdate.getSeconds()
  return ordDate+"/"+ordMonth+"/"+ordYear+" "+ordHours+":"+ordMinutes+":"+ordSeconds
}

function currency(v)
{
  var sgn=""
  if(v<0) {v=-v;sgn=" -"}
  pounds=Math.round(v-.5)
  pence=Math.round(v*100-pounds*100)
  if (pence==100){pounds=pounds+1;pence=0}
  if (pence<10){var z="0"}
  if (pence>=10){var z=""}
  res=""+sgn+pounds+"."+z+pence
  return res
}

function tradeCust()
{return parent.TitleFrame.tradecust}

function stkLinesCount()
{return parent.TitleFrame.stocknum}

function stkForSale()
{return parent.TitleFrame.stockcount}

function stkItem(i)
{return parent.TitleFrame.stitem[i]}

function stkLine(partNum)  // returns line number of this part number, -1 if not exist
{
  if(parent.TitleFrame.stPart[partNum]>=0){return parent.TitleFrame.stPart[partNum]}
  else{return -1}
}

function stkDesc(i)
{return parent.TitleFrame.stdesc[i]}

function stkCat(i)
{return parent.TitleFrame.sttype[i]}

function stkRRP(i)
{
  if(parent.TitleFrame.stprice[i]){return parent.TitleFrame.stprice[i]}
  else{return 0}
}

function stkTrdPrice(i)
{
  if(parent.TitleFrame.tradecust==true)
  {
    if(parent.TitleFrame.stTradePr[i]){return parent.TitleFrame.stTradePr[i]}
    else{return 0}
  }
  else
    {return stkRRP(i)}
}

function stkRetUnits(i)
{return parent.TitleFrame.stNumKits[i]}

function stkTrdMult(i)
{return parent.TitleFrame.stmult[i]}

function catTotCount()
{return parent.TitleFrame.cat}

function catName(ct)   // returns cat name of this number or "" if not exist
{
  if(parent.TitleFrame.catStockLine[ct]){return parent.TitleFrame.sttype[parent.TitleFrame.catStockLine[ct][0]]}
  else{return ""}
}

function catNum(thiscat)  // returns cat number of this name, -1 if not exist
{
  if(parent.TitleFrame.cName[thiscat]>=0){return parent.TitleFrame.cName[thiscat]}
  else{return -1}
}

function catComment(i)
{return parent.TitleFrame.comment[i]}

function catCommentTrade(i)
{return parent.TitleFrame.commentTrade[i]}

function catLinesCount(i)
{return parent.TitleFrame.catLineCount[i]}

function catForSale(i)
{return parent.TitleFrame.catcount[i]}

function catFindStock(ct,ln)
{return parent.TitleFrame.catStockLine[ct][ln]}

function tradeLogin()
{
  if(tradeCust()!=true){parent.ContentFrame.location="TradeEntry1.htm"}
  else
  {
     notTrade()
     switchTrol()
     parent.ContentFrame.location="home1.htm"
  }
}

function notTrade()
{
  parent.TitleFrame.tradecust=false
  parent.TitleFrame.setTradeCookie()
}

function switchTrol()
{
  if(parent.TitleFrame.altTrolCount>0)
  {
    //alert("retrieve "+parent.TitleFrame.altTrolCount+"; "+parent.TitleFrame.altTrItem.toString()+", "+parent.TitleFrame.altTrQuant.toString())
    parent.TitleFrame.trolcount=parent.TitleFrame.altTrolCount
    for(i=0; i<parent.TitleFrame.altTrolCount; i++)
    {
      parent.TitleFrame.tritem[i]=parent.TitleFrame.altTrItem[i]
      parent.TitleFrame.trquant[i]=parseInt(parent.TitleFrame.altTrQuant[i])
    }
    parent.TitleFrame.altTrolCount=0
  }
  else
  {
    parent.TitleFrame.altTrolCount=parent.TitleFrame.trolcount
    for(i=0; i<parent.TitleFrame.altTrolCount; i++)
    {
      parent.TitleFrame.altTrItem[i]=parent.TitleFrame.tritem[i]
      parent.TitleFrame.altTrQuant[i]=parseInt(parent.TitleFrame.trquant[i])
    }
    //alert("store "+parent.TitleFrame.altTrolCount+"; "+parent.TitleFrame.altTrItem.toString()+", "+parent.TitleFrame.altTrQuant.toString())
  }
  parent.TitleFrame.trsort(false)
}

function incVAT(prexV)
{return Math.round(100*(1+parent.TitleFrame.vatrate)*prexV-0.4999999)/100}

function exVAT(princV)
{return Math.round(100*princV/(1+parent.TitleFrame.vatrate)+0.4999999)/100}

function additem(i)  // calls tradd with line i
{                    // adding quantBox pieces
  document.products.elements["quantBox"+i].value=parent.TitleFrame.tradd(i,parseInt(document.products.elements["quantBox"+i].value))
}   

function picturetype(i)
{
  if((stkCat(i).indexOf("Retail Pack")!=-1)||(stkCat(i).indexOf("POS Display Box")!=-1))
    {return ".jpg"}
  else
    {return ".gif"}
}

function incQuant(c)
{
  var box=parseInt(document.products.elements["quantBox"+c].value)
  if(tradeCust()==true){box=box+stkTrdMult(c)}
  else{box=box+1}
  if(box<0){box=0}
  if(tradeCust()==true){box=tradeMult(c,box)}
//  getElementById("parent.ContentFrame.products.quantBox"+c).value=box
  document.products.elements["quantBox"+c].value=box
}

function decQuant(c)
{
  var box=parseInt(document.products.elements["quantBox"+c].value)
  if(tradeCust()==true){box=box-stkTrdMult(c)}
  else{box=box-1}
  if(box<0){box=0}
  if(tradeCust()==true){box=tradeMult(c,box)}
  document.products.elements["quantBox"+c].value=box
}

function tradeMult(i,q,notify)  // return <mult> adjusted q for item i
{
  var retValue
  if(tradeCust()==true) {
    if(stkTrdMult(i)==0) {retValue=0}
    else {retValue=stkTrdMult(i)*Math.round(0.49+q/stkTrdMult(i))}
  }
  else {retValue=q}
  
  if(notify==true && retValue!=q && retValue!=0) {alert("This item is sold in order multiples of "+stkTrdMult(i))}
//  if(retValue==0) {alert("This item is not available individually")}

  return retValue
}

function next()
{
  do {
    parent.TitleFrame.currentcat++
    if(parent.TitleFrame.currentcat>parent.TitleFrame.cat-1)
      {parent.TitleFrame.currentcat=0}
  } while(tradeCust()!=true && stkRetUnits(catFindStock(parent.TitleFrame.currentcat,0))!=1)
}

function prev()
{
  do {
    parent.TitleFrame.currentcat--
    if(parent.TitleFrame.currentcat<0)
      {parent.TitleFrame.currentcat=parent.TitleFrame.cat-1}
  } while(tradeCust()!=true && stkRetUnits(catFindStock(parent.TitleFrame.currentcat,0))!=1)
}

function testemail(emailadd) {
// max 254 characters
// The local-part of the e-mail address may use any of these ASCII characters:
//    * Uppercase and lowercase English letters (a–z, A–Z)
//    * Digits 0 to 9
//    * Characters !#$%&'*+-/=?^_`{|}~
//    * Character . (dot, period, full stop) provided that it is not the first
//      or last character, and provided also that it does not appear two or more
//      times consecutively (e.g. John..Doe@example.com)
//
// The domain name part of an email address has to conform to strict guidelines:
// it must match the requirements for a hostname, consisting of
// only the ASCII letters 'a' through 'z' (in a case-insensitive manner),
// the digits '0' through '9', and the hyphen ('-'), and '.'

    var errMsg="";
    var atPos=-1;
    var errAtMissing="@ symbol missing";
    var errAtMultiple="Too many @ symbols";
    var errDomainSyntax="Incorrect syntax after @ symbol";
    var errDot="Dot not allowed at start or end";
    var errInvalidDomainChar="Invalid character after @"
    var errInvalidLocalChar="Invalid character before @"

    if(emailadd.length>254) errMsg="Email Address Is Too Long";
    if(emailadd.length==0)  errMsg="No Email Address Entered";
    else {
        if(errMsg=="") {
            atPos=emailadd.indexOf("@",1)
            if(atPos==-1) errMsg=errAtMissing;
        }
        if(errMsg=="") {
            if(emailadd.indexOf("@",atPos+1)>-1) errMsg=errAtMultiple;
        }
        if(errMsg=="") {
            errMsg=errDomainSyntax;
            periodPos=emailadd.indexOf(".",atPos)
            while(periodPos>-1) {
                errMsg="";
                newPeriodPos=emailadd.indexOf(".",periodPos+1)
                if(newPeriodPos==periodPos+1) {
                    errMsg=errDomainSyntax;
                    newPeriodPos=-1
                }
                periodPos=newPeriodPos
            }
        }
        if(errMsg=="") {
            if(periodPos+3>emailadd.length) errMsg=errDomainSyntax;
        }
        if(errMsg=="") {
            if(emailadd.substring(0,1)=="." || emailadd.substring(emailadd.length-1,emailadd.length)==".") 
                errMsg=errDot;
        }

        if(errMsg=="") {
            var validChars="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-.";
            for(i=atPos+1; i<emailadd.length; i++) {
                if(validChars.indexOf(emailadd.charAt(i),0)==-1) {
                    errMsg=errInvalidDomainChar;
                }
            }
        }
        if(errMsg=="") {
            validChars+="!#$%&'*+/=?^_`{|}~";
            for(i=0; i<atPos; i++) {
                if(validChars.indexOf(emailadd.charAt(i),0)==-1) {
                    errMsg=errInvalidLocalChar;
                }
            }
        }
//        if(errMsg!="") {alert("Invalid email address")}
    }

    return errMsg;

}

function payMethods1() {
    document.write("<TABLE WIDTH='700' BORDER='1' CELLSPACING='2' CELLPADDING='0'>")
    document.write("<TR><TD ALIGN='CENTER'><FONT FACE='ARIAL' SIZE='2' COLOR='#000000'>")
    //document.write("<B>You will be able to pay by one of the following methods:</B><BR><BR>")
}

function payMethods2() {
    document.write("<B><I>")
    //document.write("RBS WorldPay (NOT YET AVAILABLE, COMING SOON)<BR>")
    document.write("<BR><BR>Or you can pay through your ")
    document.write("<A HREF='http://www.paypal.co.uk' TARGET='_blank'>")
    document.write("<IMG SRC='PayPal.gif' WIDTH='75' HEIGHT='30' ALIGN='MIDDLE' BORDER='0' NATURALSIZEFLAG='3' ALT='PayPal' TITLE='PayPal'></A>")
    document.write(" account if you have one<BR>")
    document.write("Or with your debit or credit card via PayPal (even if you don't have a PayPal account)<BR>")
    document.write(parent.TitleFrame.cardlogo)
    document.write("</B></I></B>")
    document.write("</FONT></TD></TR></TABLE>")
}

function PayPal(label) {
  document.write("<FORM NAME='ppform' ACTION='https://www.paypal.com/cgi-bin/webscr' TARGET='_top' METHOD='POST' onSubmit='return validate()' ENCTYPE='x-www-form-urlencoded'>")

  //  Customer Data ####################################

  document.write("<INPUT TYPE='hidden' NAME='email' VALUE='"+parent.TitleFrame.email+"'>")
  document.write("<INPUT TYPE='hidden' NAME='first_name' VALUE='"+parent.TitleFrame.firstname+"'>")
  document.write("<INPUT TYPE='hidden' NAME='last_name' VALUE='"+parent.TitleFrame.lastname+"'>")
  document.write("<INPUT TYPE='hidden' NAME='address1' VALUE='"+parent.TitleFrame.address1+"'>")
  document.write("<INPUT TYPE='hidden' NAME='address2' VALUE='"+parent.TitleFrame.address2+"'>")
  document.write("<INPUT TYPE='hidden' NAME='city' VALUE='"+parent.TitleFrame.address4+"'>")
  document.write("<INPUT TYPE='hidden' NAME='state' VALUE='"+parent.TitleFrame.address5+"'>")
  document.write("<INPUT TYPE='hidden' NAME='zip' VALUE='"+parent.TitleFrame.postcode+"'>")
  document.write("<INPUT TYPE='hidden' NAME='night_phone_a' VALUE='"+parent.TitleFrame.tlcode+"'>")
  document.write("<INPUT TYPE='hidden' NAME='night_phone_b' VALUE='"+parent.TitleFrame.tel+"'>")

  var X=""
  var listTrolley=true
  if(discount!=0 || parent.TitleFrame.trolcount>=parent.TitleFrame.maxTrolLines)
    {
      listTrolley=false
      X="X_"
    }
  var notListTrolley=!listTrolley


  //PayPal Variables, lifted from trollcont1.htm ###############################################

  if(listTrolley==true && notListTrolley==false)
    {
      document.write("<input type='hidden' name='cmd' value='_cart'>")
      document.write("<input type='hidden' name='upload' value='1'>")
    }
  else {document.write("<INPUT TYPE='hidden' NAME='cmd' VALUE='_xclick'>")}


  document.write(uncypherHex("BDEA38B2F4EFA303F3EEEFB0EEB4DE269EF0EFA8EAB0E0E8E8CCA1E0FFE630BADA35ADB2A1F72BAEF4E0C0B6EADF03E030AFDA02A7FAF6F42FAEEEE1F7BDDDEDB8E83273B3",parent.TitleFrame.keyword))

  document.write("<input type='hidden' name='page_style' value='Mouseloft'>")
  document.write("<input type='hidden' name='no_shipping' value='0'>")
  document.write("<input type='hidden' name='currency_code' value='GBP'>")
  document.write("<input type='hidden' name='no_note' value='1'>")


  if(listTrolley==true) {
    for(i=0; i<parent.TitleFrame.trolcount; i=i+1)
    {
      ItemName="input type='hidden' name='"+X+"item_name_"+(i+1)+"' value='"+stkDesc(stkLine(parent.TitleFrame.tritem[i]))+" "+stkCat(stkLine(parent.TitleFrame.tritem[i]))+"'"
  //document.write(ItemName+"<BR>")
      document.write("<"+ItemName+">")

      ItemNumber="input type='hidden' name='"+X+"item_number_"+(i+1)+"' value='"+parent.TitleFrame.tritem[i]
      if(i==0) {ItemNumber+="   ##"+orderRef}
      ItemNumber+="'"
  //document.write(ItemNumber+"<BR>")
      document.write("<"+ItemNumber+">")

        if(tradeCust()==true){itemprice=stkTrdPrice(stkLine(parent.TitleFrame.tritem[i]))}
        else{itemprice=stkRRP(stkLine(parent.TitleFrame.tritem[i]))}
      Amount="input type='hidden' name='"+X+"amount_"+(i+1)+"' value='"+currency(itemprice)+"'"
  //document.write(Amount+"<BR>")
      document.write("<"+Amount+">")
      Quantity="input type='hidden' name='"+X+"quantity_"+(i+1)+"' value='"+parent.TitleFrame.trquant[i]+"'"
  //document.write(Quantity+"<BR><BR>")
      document.write("<"+Quantity+">")
    } // end for i

  }

  if(notListTrolley==true) {
    if(tradeCust()==true) units=" retailable units"
      else                units=" items"
    document.write("<INPUT TYPE='hidden' NAME='item_name' VALUE='Contents of your Trolley, "+countunits+units+", order ref: "+orderRef+"'>")
    document.write("<INPUT TYPE='hidden' NAME='amount' VALUE='"+currency(total+discount)+"'>")
  }


  if(listTrolley==true && notListTrolley==false) {
    //              SHIPPING
    //document.write("Shipping "+currency(exVpaydel)+"<BR>")
    document.write("<input type='hidden' name='handling_cart' value='"+currency(exVpaydel)+"'>")

    //              VAT
    VATcode="input type='hidden' name='tax_cart' value='"+currency(payvat)+"'"
    //document.write(VATcode+"<BR>")
    document.write("<"+VATcode+">")
  }
  else {
    //              SHIPPING
    //document.write("Shipping "+currency(exVpaydel)+"<BR>")
    document.write("<input type='hidden' name='handling' value='"+currency(exVpaydel)+"'>")

    //              VAT
    VATcode="input type='hidden' name='tax' value='"+currency(payvat)+"'"
    //document.write(VATcode+"<BR>")
    document.write("<"+VATcode+">")
  }

  //              CHECK Invoice ID
  //document.write(parent.TitleFrame.InvoiceCheck+"<BR>")
    document.write("<input type='hidden' name='invoice' value='"+parent.TitleFrame.InvoiceCheck+"'>")

  Info="input type='hidden' name='custom' value='Linked from "+parent.TitleFrame.fromcookie+"'"
  //document.write(Info+"<BR>")
    document.write("<"+Info+">")

  document.write("<input type='hidden' name='return' value='http://www.mouseloft.co.uk'>")
  document.write("<input type='hidden' name='cancel_return' value='http://www.mouseloft.co.uk'>")

  //END OF PayPal Variables, lifted from trollcont1.htm ###############################################

  variablesWritten=true

  document.write("<IMG SRC='PayPal.gif' WIDTH='75' HEIGHT='30' ALIGN='MIDDLE' BORDER='0' NATURALSIZEFLAG='3' ALT='PayPal' TITLE='PayPal'>")
  document.write("<IMG SRC='nothing.gif' WIDTH='64' HEIGHT='30' ALIGN='MIDDLE' BORDER='0' NATURALSIZEFLAG='3'>")
  document.write("<INPUT TYPE='submit' VALUE='"+label+"' NAME='ClickToPay'>")

  document.write("</FORM>")
}

function PayPalSingle(label) {
  document.write("<FORM NAME='ppform' ACTION='https://www.paypal.com/cgi-bin/webscr' TARGET='_top' METHOD='POST' onSubmit='return validate()' ENCTYPE='x-www-form-urlencoded'>")

  document.write("<INPUT TYPE='hidden' NAME='email' VALUE='"+parent.TitleFrame.email+"'>")
  document.write("<INPUT TYPE='hidden' NAME='first_name' VALUE='"+parent.TitleFrame.firstname+"'>")
  document.write("<INPUT TYPE='hidden' NAME='last_name' VALUE='"+parent.TitleFrame.lastname+"'>")
  document.write("<INPUT TYPE='hidden' NAME='address1' VALUE='"+parent.TitleFrame.address1+"'>")
  document.write("<INPUT TYPE='hidden' NAME='address2' VALUE='"+parent.TitleFrame.address2+"'>")
  document.write("<INPUT TYPE='hidden' NAME='city' VALUE='"+parent.TitleFrame.address4+"'>")
  document.write("<INPUT TYPE='hidden' NAME='state' VALUE='"+parent.TitleFrame.address5+"'>")
  document.write("<INPUT TYPE='hidden' NAME='zip' VALUE='"+parent.TitleFrame.postcode+"'>")
  document.write("<INPUT TYPE='hidden' NAME='night_phone_a' VALUE='"+parent.TitleFrame.tlcode+"'>")
  document.write("<INPUT TYPE='hidden' NAME='night_phone_b' VALUE='"+parent.TitleFrame.tel+"'>")

  document.write("<INPUT TYPE='hidden' NAME='cmd' VALUE='_xclick'>")


  document.write(uncypherHex("BDEA38B2F4EFA303F3EEEFB0EEB4DE269EF0EFA8EAB0E0E8E8CCA1E0FFE630BADA35ADB2A1F72BAEF4E0C0B6EADF03E030AFDA02A7FAF6F42FAEEEE1F7BDDDEDB8E83273B3",parent.TitleFrame.keyword))

  document.write("<input type='hidden' name='page_style' value='Mouseloft'>")
  document.write("<input type='hidden' name='no_shipping' value='1'>")
  document.write("<input type='hidden' name='currency_code' value='GBP'>")
  document.write("<input type='hidden' name='no_note' value='0'>")

  document.write("<INPUT TYPE='hidden' NAME='item_name' VALUE=' '>")
  document.write("<INPUT TYPE='hidden' NAME='amount' VALUE='0'>")

  document.write("<input type='hidden' name='return' value='http://www.mouseloft.co.uk'>")
  document.write("<input type='hidden' name='cancel_return' value='http://www.mouseloft.co.uk'>")

  document.write("<IMG SRC='PayPal.gif' WIDTH='75' HEIGHT='30' ALIGN='MIDDLE' BORDER='0' NATURALSIZEFLAG='3' ALT='PayPal' TITLE='PayPal'>")
  document.write("<IMG SRC='nothing.gif' WIDTH='104' HEIGHT='30' ALIGN='MIDDLE' BORDER='0' NATURALSIZEFLAG='3'>")
  document.write("<INPUT TYPE='submit' VALUE='"+label+"' NAME='ClickToPay'>")

  document.write("</FORM>")
}

function RBSWP(label) {
  RBSWPplus(label,"ML_BillPay",0,0)
}

function RBSWPplus(label,thisOrderRef,thisPaytotal,thisCountunits) {

//return

 document.write("<form action='https://secure.wp3.rbsworldpay.com/wcc/purchase' name='wpform' method='POST' onSubmit='return validate()' TARGET='_top'>")
 // document.write("<form action='https://secure.wp3.rbsworldpay.com/wcc/purchase' name='wpform' method='POST' onSubmit='return validate()' TARGET='_blank'>")

 // ######## FOR TEST MODE ONLY; 
 // document.write("<input type='hidden' name='testMode' value='100'>")
  document.write("<input type='hidden' name='testMode' value='0'>")

 // ######## These first four elements are mandatory
  document.write("<input type='hidden' name='instId' value='249308'>")
  document.write("<input type='hidden' name='cartId' value='"+thisOrderRef+"'>") // 255 char Merchant's Reference - could carry timestamp
  document.write("<input type='hidden' name='currency' value='GBP'>")
  document.write("<input type='hidden' name='amount' VALUE='"+currency(thisPaytotal)+"'>")

 // ######## These elements below are optional
  document.write("<input type='hidden' name='hideCurrency'>")  //If present, this causes the currency drop down to be hidden, so fixing the currency that the shopper must purchase in
    if(tradeCust()==true) units=" retailable units"
    else                  units=" items"
  document.write("<input type='hidden' name='desc' value='Mouseloft Shopping Cart, "+thisCountunits+units+"'>")   // 255 char

 // ######## TEST   document.write("<input type='hidden' name='name' value='CAPTURED'>") // 40 char
 // ######## LIVE
  document.write("<input type='hidden' name='name' value='"+parent.TitleFrame.firstname+" "+parent.TitleFrame.lastname+"'>") // 40 char
  var tempaddress=parent.TitleFrame.address1;
    if(trim(parent.TitleFrame.address2)!="") tempaddress+="\n"+parent.TitleFrame.address2;
    if(trim(parent.TitleFrame.address4)!="") tempaddress+="\n"+parent.TitleFrame.address4;
    if(trim(parent.TitleFrame.address5)!="") tempaddress+="\n"+parent.TitleFrame.address5;
  document.write("<input type='hidden' name='address' value='"+tempaddress+"'>")   // 255 char
  document.write("<input type='hidden' name='postcode' value='"+parent.TitleFrame.postcode+"'>")              // 12 char
  document.write("<input type='hidden' name='country' value=''>")          // Leave out?  2 char Please refer to the appendix Country Codes
    if(parent.TitleFrame.country==                "United Kingdom")   document.wpform.country.value="GB"
    if(parent.TitleFrame.country.substring(0,7)== "Ireland")          document.wpform.country.value="IE"
    if(parent.TitleFrame.country.substring(0,15)=="Channel Islands")  document.wpform.country.value="GB"
  document.write("<input type='hidden' name='tel' value='"+parent.TitleFrame.tlcode+" "+parent.TitleFrame.tel+"'>")                 // 30 char
  document.write("<input type='hidden' name='email' value='"+parent.TitleFrame.email+"'>") // 80 char

 // ######## End of order details submission form elements

  document.write("<IMG SRC='poweredByRBSWorldPay.gif' WIDTH='139' HEIGHT='33' ALIGN='MIDDLE' BORDER='0' NATURALSIZEFLAG='3' ALT='RBS WorldPay' TITLE='RBS WorldPay'>")
  document.write("<IMG SRC='nothing.gif' WIDTH='40' HEIGHT='33' ALIGN='MIDDLE' BORDER='0' NATURALSIZEFLAG='3'>")

  document.write("<input type='submit' value='"+label+"' NAME='ClickToPay'>")
 // document.write("<input type='submit' value='RBS WorldPay NOT YET ACTIVE' NAME='ClickToPay'>")

  document.write("</FORM>")
}

