/*THIS FUNCTION OPENS THE POPUP PROMO PAGE*/
function openInfo(){	
var msgArgs="width=550,height=580,top="+((screen.availHeight/2)-290)+",left="+((screen.availWidth/2)-275)+",status=yes,scrollbars=1";
window.open('promoinfo.htm','info',msgArgs);
}

/*THESE FUNCTIONS HELPS PERFORM NUMERICAL LIST SORTING*/
function numOrdA(x,y){ return (x-y);}
function numOrdD(x,y){ return (y-x);}

/*THIS FUNCTION GETS THE MASTERCLASS TITLE*/
function masterClasses(prodcode){
var tut=getModuleData(prodcode,3);
var mClass="";
if (tut=="A") mClass="Working in cleanrooms";
if (tut=="B") mClass="Cleaning controlled environments";
if (tut=="C") mClass="Understanding cleanroom clothing";
if (tut=="D") mClass="Cleanroom operations";
if (tut=="H") mClass="GMP and people";
if (tut=="J") mClass="GMP and sterile production";
if (tut=="K") mClass="GMP operations";
if (tut=="M") mClass="GMP and engineering";
if (tut=="N") mClass="GMP and validation";
if (tut=="V") mClass="Laboratory skills";
if (tut=="W") mClass="Good Laboratory Practices";
if (tut=="R") mClass="Risk management";
if (tut=="S") mClass="GMP and quality auditing";
if (tut=="T") mClass="Training techniques";
return mClass;
}

/*THIS FUNCTION CONVERTS STRINGS TO NUMBERS*/
function vertToNum(strg){
var theNum = strg*1;
return theNum;
}

/*THIS FUNCTION CONVERTS NUMBERS TO DISPLAY FORMAT*/
function numToDisp(nmb){
var nm=nmb.toString();
var nLength=nm.length;
var dPoint=nm.indexOf(".",0);
if (dPoint==-1) { 
nm=nm+".00";}
else if (dPoint==nLength-2){
nm=nm+"0";}
else if (nLength>dPoint+3 && dPoint>-1) {
nm=nm.substring(0,dPoint+3);}
return nm;
}

/*THIS FUNCTION HAS THE HEADER BAR*/
function getHeaderBar(){
var orderform='ukorderform';
var company=readCookie('company');
if (company==null) {
window.document.location='index.htm';
exit;}
var color1="";
var color2="";
var color3="";
var color4="";
var color5="";
var color6="";
var color7="";
var color8="";
var color9="";
var color10="";
var color11="";
var color12="";
var color13="";
var color14="";
if (document.titleb=='home') color1="<font color='#DDAAAA'>";
if (document.titleb=='products') color2="<font color='#DDAAAA'>";
if (document.titleb=='formats') color3="<font color='#DDAAAA'>";
if (document.titleb=='contact') color4="<font color='#DDAAAA'>";
if (document.titleb=='basket') color5="<font color='#DDAAAA'>";
if (document.titleb=='downloads') color6="<font color='#DDAAAA'>";
if (document.titleb=='previews') color7="<font color='#DDAAAA'>";
if (document.titleb=='aboutus') color8="<font color='#DDAAAA'>";
if (document.titleb=='faqs') color9="<font color='#DDAAAA'>";
if (document.titleb=='news') color10="<font color='#DDAAAA'>";
if (document.titleb=='terms') color11="<font color='#DDAAAA'>";
if (document.titleb=='licenses') color12="<font color='#DDAAAA'>";
if (document.titleb=='orderform') color13="<font color='#DDAAAA'>";
if (document.titleb=='blog') color14="<font color='#DDAAAA'>";
var contactpage='';
if (company=='Inc'){
contactpage='contactus.htm';
}else{
contactpage='contactint.htm';
}
var headerBar="<a href='index.htm'><img src='graphics/10pixspacer.gif' align='absmiddle' width='1px' height='10px' border='no'></a> <img src='graphics/29pixhigh.gif' align='absmiddle'><a href='home.htm'>"+color1+"HOME</a></font></font><img src='graphics/butsep.jpg' align='absbottom'><font color='#CCFFFF'><a href='products.htm'>"+color2+"PRODUCTS</a></font><img src='graphics/butsep.jpg' align='absbottom'><font color='#CCFFFF'><a href='formats.htm'>"+color3+"FORMATS</a></font><img src='graphics/butsep.jpg' align='absbottom'><font color='#CCFFFF'><a href='licensing.htm'>"+color12+"NETWORK LICENSING</a></font><img src='graphics/butsep.jpg' align='absbottom'><font color='#CCFFFF'><font color='#CCFFFF'><a href='previews.htm'>"+color7+" PREVIEWS</a></font><img src='graphics/butsep.jpg' align='absbottom'><font color='#CCFFFF'><a href='basket.htm'>"+color5+"VIEW BASKET/CHECKOUT</font></a><img src='graphics/butsep.jpg' align='absbottom'><br><img src='graphics/29pixhigh.gif' align='absmiddle'><img src='graphics/butsep.jpg' align='absbottom'><a href='"+contactpage+"'>"+color4+"CONTACT US</font></a><font class='ten'><img src='graphics/butsep.jpg' align='absbottom'><a href='orderform.htm'>"+color13+"ORDER FORM</font></a><img src='graphics/butsep.jpg' align='absbottom'><font class='ten'><a href='aboutus.htm'>"+color8+"ABOUT US</a><img src='graphics/butsep.jpg' align='absbottom'><font class='ten'><a href='blog.htm'>"+color14+"BLOG</a><img src='graphics/butsep.jpg' align='absbottom'><a href='news.htm'>"+color10+"NEW RELEASES</a><img src='graphics/butsep.jpg' align='absbottom'><a href='faqs.htm'>"+color9+"FAQs</a><img src='graphics/butsep.jpg' align='absbottom'><a href='terms.htm'>"+color11+"TERMS & CONDITIONS</a>";
return headerBar;
}

/*THIS FUNCTION SETS THE SERIES COLOUR*/
function getColour(prodcode,which){
var tut=getModuleData(prodcode,3);
var colour='';
var logo='';
var basePixel=80;
if (tut=='A' || tut=='B' || tut=='C' || tut=='D') {
colour="<p style='background-color:#0066CC; height:60px;'>";
logo="<b style='position: relative;left:"+basePixel+"px;'><img src='graphics/logo.gif' width='100' height='82' align='absmiddle'></b>";
}
if (tut=='H' || tut=='J' || tut=='K' || tut=='N' || tut=='M') {
colour="<p style='background-color:#CC9900; height:60px;'>";
logo="<b style='position: relative;left:"+(basePixel+73)+"px;'><img src='graphics/logo.gif' width='100' height='82' align='absmiddle'></b>";
}
if (tut=='V' || tut=='W') {
colour="<p style='background-color:#993300; height:60px;'>";
logo="<b style='position: relative;left:"+(basePixel-27)+"px;'><img src='graphics/logo.gif' width='100' height='82' align='absmiddle'></b>";
}
if (tut=='T' || tut=='S' || tut=='R') {
colour="<p style='background-color:#990066; height:60px;'>";
logo="<b style='position: relative;left:"+(basePixel-68)+"px;'><img src='graphics/logo.gif' width='100' height='82' align='absmiddle'></b>";
}
if (which=='colour') {
return colour;
}
else
{
return logo;
}
}

/*THIS FUNCTION GETS THE PRICING INFORMATION*/
function getPrice(currency, format, code){
var pricePoint=getModuleData(code,10);
var pp="";
var pRegion=readCookie('country');
/*Prices                                            £                                            $                                             €  */
if (pricePoint=='0p') pp="|120.00 145.00 0.00 0.00 |223.00 270.00 0.00 0.00 |180.00 220.00 0.00 0.00 ";
if (pricePoint=='1') pp="|175.00 175.00 0.00 250.00 |335.00 335.00 0.00 475.00 |265.00 265.00 0.00 375.00 ";
if (pricePoint=='2') pp="|225.00 225.00 0.00 320.00 |430.00 430.00 0.00 610.00 |340.00 340.00 0.00 480.00 ";
if (pricePoint=='3') pp="|270.00 270.00 0.00 390.00 |515.00 515.00 0.00 745.00 |405.00 405.00 0.00 585.00 ";
if (pricePoint=='4') pp="|330.00 330.00 0.00 470.00 |630.00 630.00 0.00 895.00 |495.00 495.00 0.00 705.00 ";
if (pricePoint=='5') pp="|375.00 375.00 0.00 535.00 |715.00 715.00 0.00 1015.00 |565.00 565.00 0.00 805.00 ";
if (pricePoint=='7p') pp="|435.00 495.00 0.00 0.00 |827.00 945.00 0.00 0.00 |650.00 740.00 0.00 0.00 ";
if (pricePoint=='8') pp="|950.00 950.00 0.00 0.00 |1600.00 1600.00 0.00 0.00 |1425.00 1425.00 0.00 0.00 ";
if (pricePoint=='8r') pp="|1250.00 1250.00 1250.00 0.00 |1900.00 1900.00 1900.00 0.00 |1875.00 1875.00 1875.00 0.00 ";
if (pricePoint=='9r') pp="|1057.80 1057.80 0.00 2115.60 |2000.00 2000.00 0.00 4000.00 |1562.20 1562.20 0.00 3124.40 ";
if (pricePoint.substring(0,4)=='remP') pp=pricePoint.substring(4,pricePoint.length);
var prices =pp.split("|");
var nPrices="";
if (currency=='£') nPrices = prices[1];
if (currency=='$') nPrices = prices[2];
if (currency=='€') nPrices = prices[3];
var outPrice="";
var fPrices=nPrices.split(' ');
/*ADDED FOR GXP*/
if (format=='DVDg') outPrice = fPrices[0];
if (format=='DVDh') outPrice = numToDisp(fPrices[0]*2);
/*END*/
if (format=='DVD') outPrice = fPrices[0];
if (format=='DVDt') outPrice = numToDisp((parseInt(((fPrices[0]*2.5).toFixed(0))/5))*5);
if (format=='DVDp') outPrice = numToDisp(fPrices[0]*5);
if (format=='CDR') outPrice = fPrices[0];
if (format=='TBK') outPrice = fPrices[0];
if (format=='VCD') outPrice = fPrices[1];
if (format=='VCDt') outPrice = numToDisp((parseInt(((fPrices[1]*2.5).toFixed(0))/5))*5);
if (format=='VCDp') outPrice = numToDisp(fPrices[1]*5);
if (format=='PNT') outPrice = fPrices[1];
if (format=='VHS') outPrice = fPrices[2];
if (format=='CBT') outPrice = fPrices[3];
if (format=='CBTt') outPrice = numToDisp((parseInt(((fPrices[3]*2.5).toFixed(0))/5))*5);
if (format=='CBTp') outPrice = numToDisp(fPrices[3]*5);
return currency+outPrice;
}

/* THIS FUNCTION READS COOKIES*/
function readCookie(cookieName){
var cName = cookieName + "=";
var cLength = document.cookie.length;
var cStart = 0;
	while(0<document.cookie.length){
	var vStart = cStart + cName.length;
		if (document.cookie.substring(cStart,vStart) == cName){
		var cEnd = document.cookie.indexOf(";",vStart);
			if(cEnd == -1) cEnd = cLength;
			return unescape(document.cookie.substring(vStart, cEnd));
			}
		cStart = document.cookie.indexOf(" ", cStart) + 1;
			if(cStart == 0) break;
		}
	return;

}

/* THIS FUNCTION WRITES COOKIES*/
function writeCookie(cookieName, cookieValue){
document.cookie = cookieName + "=" + escape(cookieValue)+ ";path=/";
}

/* THIS FUNCTION WRITES LONG COOKIES*/
function writeCookieLong(cookieName, cookieValue){
document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=Thu,01-Jan-20 00:00:01 GMT;path=/";
}

/* THIS FUNCTION APPENDS COOKIES*/
function appendCookie(cookieName, cookieValue){
var preCooked = readCookie(cookieName);
document.cookie = cookieName + "=" + escape(preCooked +"\r\n" + cookieValue) + ";path=/";
/*document.cookie = cookieName + "=" + escape(preCooked +"\r\n" + cookieValue) + ";expires=Thu,01-Jan-20 00:00:01 GMT;path=/";*/
}

/*THIS FUNCTION CHECKS THE SIZE OF THE COOKIE*/
function checkBasket(){
var basket = '';
var resulte = 'true';
basket = readCookie('basket');
if (basket!=null){
var bList = basket.split('|')
if (bList.length>130) resulte='false';}
return resulte;
}

/*THIS FUNCTION ADDS PRODUCTS TO THE BASKET*/
function addToBasket(format,code,quantity){
var data = '';
if (code=="0011" && format.substring(0,3)=="CBT" || code=="0026" && format.substring(0,3)=="CBT"){
alert("This product is not available in the requested format!");
exit;}
if (code=="0280M" || code=="0260M") {
var mclassNum=readCookie("mclass");
if(mclassNum==undefined) mclassNum=0;
mclassNum=vertToNum(mclassNum)+vertToNum(quantity);
writeCookie("mclass", mclassNum);
}
var tester = checkBasket();
if (tester=='true'){
if (format=='DVD' || format=='DVDt' || format=='DVDp' || format=='DVDg' || format=='DVDh') data = data+'|'+quantity+' '+code+' '+format+' ';
if (format=='VCD' || format=='VCDt' || format=='VCDp') data = data+'|'+quantity+' '+code+' '+format+' ';
if (format=='TBK') data = data+'|'+quantity+' '+code+' '+format+' ';
if (format=='VHS') data = data+'|'+quantity+' '+code+' '+format+' ';
if (format=='CBT' || format=='CBTt' || format=='CBTp') data = data+'|'+quantity+' '+code+' '+format+' ';
if (format=='CDR') data = data+'|'+quantity+' '+code+' '+format+' ';
if (format=='PNT') data = data+'|'+quantity+' '+code+' '+format+' ';
appendCookie('basket',data);
/* START - THIS VARIABLE ADDED WHILE CREDIT CARDS UNAVAILABLE*/
var ccDown ='';
var mWidth='350';
var smWidth=175;
var mHeight='400';
var smHeight=200;
if (readCookie('company')=='Ltd') {
ccDown = '<span style=float:left><img src=graphics/info.gif></span><font color=#DD0000><span class=nine>INFORMATION: Currently we cannot offer credit card as a payment method.  This will be rectified soon.  Please continue with your order and you will receive a proforma invoice and details for payment within 2 working days.</span></font><br>'; 
mWidth='450';
smWidth=225;
mHeight='450';
smHeight=225;
}
/* END*/
if (quantity=='1') writeCookie('message', ccDown+quantity+' product has been added to your basket!');
if (quantity!='1') writeCookie('message', ccDown+quantity+' products have been added to your basket!');
var msgArgs="width="+mWidth+",height="+mHeight+",top="+((screen.availHeight/2)-smHeight)+",left="+((screen.availWidth/2)-smWidth)+",status=yes";
window.open('msgbox.htm','Message',msgArgs);
}
else{alert('The basket is full. You cannot add any more items.  It is suggested that you view the contents of your basket and remove any unwanted items or proceed to the checkout. Contact Micron Training for advice.');}
}

/*THIS FUNCTION ADDS PRODUCTS TO THE PRICELIST BASKET*/
function addToBasketL(format,code,quantity){
var data = '';
if (code=="0011" && format.substring(0,3)=="CBT" || code=="0026" && format.substring(0,3)=="CBT"){
alert("This product is not available in the requested format!");
exit;}
if (code=="0280M" || code=="0260M") {
var mclassNum=readCookie("mclass");
if(mclassNum==undefined) mclassNum=0;
mclassNum=vertToNum(mclassNum)+vertToNum(quantity);
writeCookie("mclass", mclassNum);
}
var tester = checkBasket();
if (tester=='true'){
if (format=='DVD' || format=='DVDt' || format=='DVDp') data = data+'|'+quantity+' '+code+' '+format+' ';
if (format=='VCD' || format=='VCDt' || format=='VCDp') data = data+'|'+quantity+' '+code+' '+format+' ';
if (format=='TBK') data = data+'|'+quantity+' '+code+' '+format+' ';
if (format=='VHS') data = data+'|'+quantity+' '+code+' '+format+' ';
if (format=='CBT' || format=='CBTt' || format=='CBTp') data = data+'|'+quantity+' '+code+' '+format+' ';
if (format=='CDR') data = data+'|'+quantity+' '+code+' '+format+' ';
if (format=='PNT') data = data+'|'+quantity+' '+code+' '+format+' ';
appendCookie('basket',data);
}
else{alert('The basket is full. You cannot add any more items.  It is suggested that you view the contents of your basket and remove any unwanted items or proceed to the checkout. Contact Micron Training for advice.');}
}

/*THIS FUNCTION GETS THE POSTAGE*/
function getPostage(itemNum){
var currency=readCookie('currency');
var company=readCookie('company');
var country=readCookie('country');
var masterClass=readCookie('mclass');
if(masterClass==undefined) masterClass=0;
itemNum=itemNum+vertToNum(masterClass);
var postagePoint=0;
var postage=0.00;
/*Rates        £UK   £EU   £US   £RoW  $UK   $EU   $US   $RoW   €UK  €EU    €US   €RoW  */
var rates=" 13.50 20.00 22.00 22.00 | 25.00 26.00 26.00 44.00 | 20.00 36.00 36.00 40.00 |";
var ratesList="";
var europe="Austria@Belgium@Bulgaria@Czech Republic@Cyprus@Denmark@Estonia@Finland@France@Germany@Greece@Hungary@Ireland@Italy@Latvia@Lithuania@Luxembourg@Malta@Netherlands@Norway@Poland@Portugal@Romania@Slovak Republic@Slovenia@Spain@Sweden"; 
var eList=europe.split('@');
 for (var i=0; i <=(eList.length-1); i++) { 
if (country==eList[i]) postagePoint=2;
}
var factaw=11;
if (postagePoint==0){
if (country=='United Kingdom') {
postagePoint=1;
factaw=2;
}
else if (country=='United States' || country=='Canada' || country=='Mexico') {
postagePoint=3;
}
else
{
postagePoint=4;
}}
var curRates=rates.split('|');
if (currency=='£') ratesList=curRates[0];
if (currency=='$') ratesList=curRates[1];
if (currency=='€') ratesList=curRates[2];
var pRates=ratesList.split(' ');
if (itemNum>2){
postage=(pRates[postagePoint]);
postage=vertToNum(postage)+((itemNum-1)*factaw);}
else{
postage=(pRates[postagePoint]);
if(country=='United Kingdom'){
postage=vertToNum(postage)+((itemNum-1)*factaw);}
else{
postage=vertToNum(postage)*(itemNum);}
}
var disCount=0;
postage=postage-((postage/100)*disCount);
/*postage=Math.round(postage,2);*/
postage=numToDisp(postage);
if(disCount==0){
writeCookie('pdiscount',' ')
}else{
writeCookie('pdiscount','<br><i>shipping discount available for 5 or more items</i>')
}
if(itemNum<1){postage=0.00;}
return postage;
}

/*THIS FUNCTION GETS THE PDA POSTAGE*/
function getPpostage(itemCost){
var postage=0.00;
if(itemCost!=0.00){
var currency=readCookie('currency');
var topRate=0;
var maxRate=0;
var minRate=0;
if(currency=='£') {
topRate=120.01;
maxRate=175.00;
minRate=15.00;}
else if(currency=='$') {
topRate=199.99;
maxRate=300.00;
minRate=20.00;}
else if(currency=='€') {
topRate=180.01;
maxRate=256.00;
minRate=18.00;}
var country=readCookie('country');
if(country=='United States' || country=='Canada' || country=='Puerto Rico') {
if(itemCost>15) postage=10.95;
if(itemCost>150) postage=12.95;
if(itemCost>250) postage=14.95;
if(itemCost>500) postage=17.95;
}
else{
	if(itemCost<=topRate){
	postage=(itemCost/100)*20}
	else{
	postage=(itemCost/100)*30}
if(postage<minRate) postage=minRate;
if(postage>maxRate) postage=maxRate;
}
}
postage=numToDisp(postage);
return postage;
}

/*THIS FUNCTION DISPLAYS THE CONTENTS OF THE BASKET*/
function getBasket(){
var basket = readCookie('basket');
var currency = readCookie('currency');
var bList = new Array();
var LicenseType="";
var formate=0;
var subTotal=0.00;
var PsubTotal=0.00;
var MsubTotal=0.00;
var productCount=0;
var bproductCount=0;
var bDisplay="";
var PDADisplay="";
var Total=0;
var vat=0;
var vatList=new Array();
writeCookie('audit','0000');
if (basket!= null) bList = basket.split('|');
 for (var i=1; i <=(bList.length-1); i++) {
	var nLine=new Array()
	nLine=bList[i].split(' ')
	var code=nLine[1]
	if (code=='0289') writeCookie('audit',code);
	var subIntPrice=0
	var subIntPriceb=0
	var PsubIntPrice=0
	var PPsubIntPrice=0
	var subPrice=getPrice(currency,nLine[2],code)
	LicenseType="Basic License";
	if (nLine[2]=='DVD' || nLine[2]=='DVDt' || nLine[2]=='DVDp') formate=6;
	if (nLine[2]=='DVDt' || nLine[2]=='DVDh') LicenseType='Plant License';
	if (nLine[2]=='DVDp') LicenseType='Intranet License';
	if (nLine[2]=='CDR') formate=6;
	if (nLine[2]=='TBK') formate=6;
	if (nLine[2]=='VCD' || nLine[2]=='VCDt' || nLine[2]=='VCDp') formate=7;
	if (nLine[2]=='VCDt')  LicenseType='Plant License';
	if (nLine[2]=='VCDp') LicenseType='Intranet License';
	if (nLine[2]=='PNT') formate=7;
	if (nLine[2]=='VHS') formate=8;
	if (nLine[2]=='CBT' || nLine[2]=='CBTt' || nLine[2]=='CBTp') formate=9;
	if (nLine[2]=='CBTt') LicenseType='Plant License';
	if (nLine[2]=='CBTp')	LicenseType='Intranet License';
	if(nLine[2]=='TBK') {
		bproductCount=bproductCount+1
		PsubIntPrice=nLine[0]*(vertToNum(subPrice.substring(1,6)))
		PDADisplay = PDADisplay +'<br><div align=left><i><font color=#AA00AA>"'+getModuleData(code, 4)+'"</font></i><br><div align=right>'+nLine[0]+' X '+getModuleData(code, (formate*1))+' [unit price '+subPrice+'] Price = <font color=#CC0000>'+currency+numToDisp(PsubIntPrice)+'</font><br><input type=button name='+i+' value=remove onClick={removeItem('+i+');window.location.reload();}><br>'}
	else{	
		productCount=productCount+(vertToNum(nLine[0]))
		subIntPrice=nLine[0]*(vertToNum(subPrice.substring(1,6)))
         		bDisplay = bDisplay +'<br><div align=left><i><font color=#AA00AA>'+getModuleData(code, 4)+'</font></i><br><div align=right>'+nLine[0]+' X '+getModuleData(code, (formate*1))+' <font color=#AA00AA>'+LicenseType+'</font> [unit price '+subPrice+'] Price = <font color=#CC0000>'+currency+numToDisp(subIntPrice)+'</font><br><input type=button name='+i+' value=remove onClick={removeItem('+i+');window.location.reload();}><br>'}
subIntPriceb=subIntPrice
PPsubIntPrice=PsubIntPrice
MsubTotal=MsubTotal+vertToNum(subIntPriceb)
PsubTotal=PsubTotal+vertToNum(PPsubIntPrice)
subTotal=PsubTotal+MsubTotal
     }
var postage=0.00;
postage=getPostage(productCount);
Ppostage=getPpostage(PsubTotal);
subTotal=subTotal+vertToNum(postage)+vertToNum(Ppostage);
subTotal=numToDisp(subTotal);
var Promo=getPromo(readCookie('promocode'));
/*THIS SECTION ADDED FOR BONUS COUPON*/
var Bonus=readCookie('bonus');
var bTotal=0;
var bPromo='';
if(Bonus=='ON'){
var PrList = new Array();
PrList=Promo.split('|');
bPromo=PrList[0];
bTotal=vertToNum(PrList[1]);
Promo=false;
}
/*END SECTION*/
if(Promo==false){
if (productCount>4){
Total=subTotal-(((subTotal-postage)/100)*5);
writeCookie('discount',numToDisp(((subTotal-postage)/100)*5));
Promo='<br>volume discount (5 programs or more) <font color=#CC0000>- '+currency+numToDisp(((subTotal-postage)/100)*5)+'</font><br>'}
else
{
Total=vertToNum(subTotal);
Promo='<br>A volume discount is available if you add another <font color=#CC0000>'+(5-productCount)+'</font> Micron Training items <br>'
}
}else{
var PrList = new Array();
PrList=Promo.split('|');
Promo=PrList[0];
Total=vertToNum(subTotal)-vertToNum(PrList[1]);
}
Total=Total-bTotal;/*LINE ADDED FOR BONUS COUPON*/
bDisplay=bDisplay+Promo+'<br>'+bPromo;/*bPROMO ADDED*/
var shipDisc=readCookie('pdiscount');
bDisplay = '<hr>There are '+productCount+' Micron Training item(s) in your basket<br>'+bDisplay+'<p align=right>Micron Training Handling & Shipping = <font color=#CC0000>'+currency+postage+shipDisc+'</font><hr><p align=left>There are '+bproductCount+' PDA/DHI Technical books in your basket<br>'+PDADisplay+'<p align=right>PDA/DHI Handling & Shipping = <font color=#CC0000>'+currency+Ppostage+'</font><hr></div>';
vatList=myVAT(Total).split('@');
vat=vatList[1];
Total=(Total*1)+(vat*1);
Total=numToDisp(Total);
 bDisplay = bDisplay+'<p align=right>'+vatList[0]+' = <font color=#CC0000>'+currency+vat+'</font><br><u>Total = <font color=#CC0000>'+currency+Total;
writeCookie('subtotal',subTotal);
writeCookie('total',Total);
writeCookie('postage', postage);
return bDisplay;
}

/*THIS FUNCTION DISPLAYS THE CONTENTS OF THE BASKET FOR CHECKOUT*/
function getBasketCH(){
var basket = readCookie('basket');
var currency = readCookie('currency');
var bList = new Array();
var LicenseType="";
var formate=0;
var subTotal=0.00;
var PsubTotal=0.00;
var MsubTotal=0.00;
var productCount=0;
var bproductCount=0;
var bDisplay="";
var PDADisplay="";
var Total=0;
var vat=0;
var vatList=new Array();
if (basket!= null) bList = basket.split('|');
 for (var i=1; i <=(bList.length-1); i++) {
	var nLine=new Array()
	nLine=bList[i].split(' ')
	var code=nLine[1]
	var subIntPrice=0
	var subIntPriceb=0
	var PsubIntPrice=0
	var PPsubIntPrice=0
	var subPrice=getPrice(currency,nLine[2],code)
	LicenseType="Basic License";
	if (nLine[2]=='DVD' || nLine[2]=='DVDt' || nLine[2]=='DVDp') formate=6;
	if (nLine[2]=='DVDt' || nLine[2]=='DVDh') LicenseType='Plant License';
	if (nLine[2]=='DVDp') LicenseType='Intranet License';
	if (nLine[2]=='CDR') formate=6;
	if (nLine[2]=='TBK') formate=6;
	if (nLine[2]=='VCD' || nLine[2]=='VCDt' || nLine[2]=='VCDp') formate=7;
	if (nLine[2]=='VCDt')  LicenseType='Plant License';
	if (nLine[2]=='VCDp') LicenseType='Intranet License';
	if (nLine[2]=='PNT') formate=7;
	if (nLine[2]=='VHS') formate=8;
	if (nLine[2]=='CBT' || nLine[2]=='CBTt' || nLine[2]=='CBTp') formate=9;
	if (nLine[2]=='CBTt') LicenseType='Plant License';
	if (nLine[2]=='CBTp')	LicenseType='Intranet License';
	if(nLine[2]=='TBK') {
		bproductCount=bproductCount+1
		PsubIntPrice=nLine[0]*(vertToNum(subPrice.substring(1,6)))
		PDADisplay = PDADisplay +'</i><br><div align=right>'+nLine[0]+' X '+getModuleData(code, (formate*1))+' [unit price '+subPrice+'] Price = <font color=#CC0000>'+currency+numToDisp(PsubIntPrice)+'</font>'}
	else{	
		productCount=productCount+(vertToNum(nLine[0]))
		subIntPrice=nLine[0]*(vertToNum(subPrice.substring(1,6)))
         		bDisplay = bDisplay +'</i><br><div align=right>'+nLine[0]+' X '+getModuleData(code, (formate*1))+' <font color=#AA00AA>'+LicenseType+'</font> [unit price '+subPrice+'] Price = <font color=#CC0000>'+currency+numToDisp(subIntPrice)+'</font>'}
subIntPriceb=subIntPrice
PPsubIntPrice=PsubIntPrice
MsubTotal=MsubTotal+vertToNum(subIntPriceb)
PsubTotal=PsubTotal+vertToNum(PPsubIntPrice)
subTotal=PsubTotal+MsubTotal
     }
var postage=0.00;
postage=getPostage(productCount);
Ppostage=getPpostage(PsubTotal);
subTotal=subTotal+vertToNum(postage)+vertToNum(Ppostage);
subTotal=numToDisp(subTotal);
var Promo=getPromo(readCookie('promocode'));
/*THIS SECTION ADDED FOR BONUS COUPON*/
var Bonus=readCookie('bonus');
var bTotal=0;
var bPromo='';
if(Bonus=='ON'){
var PrList = new Array();
PrList=Promo.split('|');
bPromo=PrList[0];
bTotal=vertToNum(PrList[1]);
Promo=false;
}
/*END SECTION*/
if(Promo==false){
if (productCount>4){
Total=subTotal-(((subTotal-postage)/100)*5);
writeCookie('discount',numToDisp(((subTotal-postage)/100)*5));
Promo='<br>Volume discount = <font color=#CC0000>- '+currency+numToDisp(((subTotal-postage)/100)*5)+'</font><br>'}
else
{
Total=vertToNum(subTotal);
Promo='<br>Volume discount = <font color=#CC0000>'+currency+'0.00</font><br>'
}
}else{
var PrList = new Array();
PrList=Promo.split('|');
Promo=PrList[0];
Total=vertToNum(subTotal)-vertToNum(PrList[1]);
}
Total=Total-bTotal;/*LINE ADDED FOR BONUS COUPON*/
bDisplay=bDisplay+Promo+'<br>'+bPromo;/*bPROMO ADDED*/
var shipDisc=readCookie('pdiscount');
bDisplay = '<hr>Micron Training item(s)<br>'+bDisplay+'Micron Training Handling & Shipping = <font color=#CC0000>'+currency+postage+shipDisc+'</font><hr><div align=left>PDA/DHI Technical books<br>'+PDADisplay+'<br>PDA/DHI Handling & Shipping = <font color=#CC0000>'+currency+Ppostage+'</font><hr></div>';
vatList=myVAT(Total).split('@');
vat=vatList[1];
Total=(Total*1)+(vat*1);
Total=numToDisp(Total);
 bDisplay = bDisplay+'<div align=right>'+vatList[0]+' = <font color=#CC0000>'+currency+vat+'</font><br><u>Total = <font color=#CC0000>'+currency+Total;
writeCookie('subtotal',subTotal);
writeCookie('total',Total);
writeCookie('postage', postage);
return bDisplay;
}

/*THIS FUNCTION DISPLAYS THE SUMMARY OF THE BASKET*/
function getBasketSummary(){
var basket = readCookie('basket');
var currency = readCookie('currency');
var bList = new Array();
var formate=0;
var subTotal=0.00;
var PsubTotal=0.00;
var MsubTotal=0.00;
var productCount=0;
var bproductCount=0;
var bDisplay="";
var PDADisplay="";
var Total=0;
var vat=0;
var vatList=new Array();
if (basket!= null) bList = basket.split('|');
 for (var i=1; i <=(bList.length-1); i++) {
	var nLine=new Array()
	nLine=bList[i].split(' ')
	var code=nLine[1]
	var subIntPrice=0
	var subIntPriceb=0
	var PsubIntPrice=0
	var PPsubIntPrice=0
	var subPrice=getPrice(currency,nLine[2],code)
	if(nLine[2]=='TBK') {
		bproductCount=bproductCount+1
		PsubIntPrice=nLine[0]*(vertToNum(subPrice.substring(1,6)))}
			else{	
		productCount=productCount+(vertToNum(nLine[0]))
		subIntPrice=nLine[0]*(vertToNum(subPrice.substring(1,6)))
         		}
subIntPriceb=subIntPrice
PPsubIntPrice=PsubIntPrice
MsubTotal=MsubTotal+vertToNum(subIntPriceb)
PsubTotal=PsubTotal+vertToNum(PPsubIntPrice)
subTotal=PsubTotal+MsubTotal
     }
var postage=0.00;
postage=getPostage(productCount);
Ppostage=getPpostage(PsubTotal);
subTotal=subTotal+vertToNum(postage)+vertToNum(Ppostage);
subTotal=numToDisp(subTotal);
bDisplay = bDisplay+'<br> Sub Total = <font color=#CC0000>'+currency+MsubTotal+'</font>';
PDADisplay = PDADisplay+'<br> Sub Total = <font color=#CC0000>'+currency+PsubTotal+'</font>';
var Promo=getPromo(readCookie('promocode'));
/*THIS SECTION ADDED FOR BONUS COUPON*/
var Bonus=readCookie('bonus');
var bTotal=0;
var bPromo='';
if(Bonus=='ON'){
var PrList = new Array();
PrList=Promo.split('|');
bPromo=PrList[0];
bTotal=vertToNum(PrList[1]);
Promo=false;
}
/*END SECTION*/
if(Promo==false){
if (productCount>4){
Total=subTotal-(((subTotal-postage)/100)*5);
Promo='<br>volume discount (5 programs or more) <font color=#CC0000>- '+currency+numToDisp(((subTotal-postage)/100)*5)+'</font>'}
else
{
Total=vertToNum(subTotal);
Promo='<br>A volume discount is available if you add another <font color=#CC0000>'+(5-productCount)+'</font> Micron Training items <br>'
}
}else{
var PrList = new Array();
PrList=Promo.split('|');
Promo="<br>Special Promotional Discount<font color='#CC0000'> -"+readCookie('currency')+numToDisp(PrList[1])+"</font>";
Total=vertToNum(subTotal)-vertToNum(PrList[1]);
}
Total=Total-bTotal;/*LINE ADDED FOR BONUS COUPON*/
bDisplay=bDisplay+Promo+'<br>'+bPromo;/*bPROMO ADDED*/
var shipDisc=readCookie('pdiscount');
bDisplay = '<hr><div align=right><font class=ten>There are '+productCount+' Micron Training item(s) in your basket<br>'+bDisplay+'<br>Micron Training Handling & Shipping = <font color=#CC0000>'+currency+postage+shipDisc+'</font><hr>There are '+bproductCount+' PDA/DHI Technical books in your basket<br>'+PDADisplay+'<br>PDA/DHI Handling & Shipping = <font color=#CC0000>'+currency+Ppostage+'</font><hr>';
vatList=myVAT(Total).split('@');
vat=vatList[1];
Total=(Total*1)+(vat*1);
Total=numToDisp(Total);
 bDisplay = bDisplay+vatList[0]+' = <font color=#CC0000>'+currency+vat+'</font><br><u>Total = <font color=#CC0000>'+currency+Total+'</font></div>';
writeCookie('subtotal',subTotal);
writeCookie('total',Total);
return bDisplay;
}


/*THIS FUNCTION REMOVES ITEMS FROM THE BASKET*/
function removeItem(itemNum){
var basket = readCookie('basket');
var bList = new Array();
var newList ="";
if (basket!= null){
bList = basket.split('|');
var dList=bList[itemNum].split(' ');
var quantinum=dList[0];
var cod=dList[1];
if(cod=='0280M' || cod=='0260M') {
quantinum=vertToNum(quantinum);
var mclassNum=readCookie("mclass");
if(mclassNum==undefined) mclassNum=0;
mclassNum=vertToNum(mclassNum)-quantinum;
writeCookie("mclass", mclassNum);
}
writeCookie('basket','');
 for (var i=1; i <=(bList.length-1); i++) {
	newList = '|'+bList[i].toString();
	if(i!=itemNum) appendCookie('basket', newList);
}
}}

/*THIS FUNCTION SETS THE REGIONAL VALUES*/
function setRegion(value, country){
var result='';
if (value=='blank') {
alert('You must select a country or choose "not listed"!');
result='false';}
else{
var currency=value.substring(0,1);
var company=value.substring(1,4);
var zone=value.substring(4,7);
var postagePoint=value.substring(7,8);
writeCookie('currency', currency);
writeCookie('company', company);
writeCookie('postagePoint', postagePoint);
writeCookie('country', country);
result='true';
}
return result;
}

/*THIS FUNCTION GETS THE CURRENCY*/
function getCurrency(){
var currency=readCookie('currency');
var sig='';
if (currency=='$') {
sig='</u>All prices shown in US Dollars';}
else if (currency=='€'){
sig='</u>All prices shown in Euros';}
else{
sig='</u>All prices shown in UK Sterling';}
return sig;
}

/* THIS FUNCTION PERFORMS THE VAT CALCULATION*/
function myVAT(price){
var vat = 0.00;
var vatDisp="applicable tax ";
var country =readCookie('country');
if (country=='United States') {
if (readCookie('state')=='DE') {
vat = (price/100)* 0.0;
vatDisp="DE local tax may apply";
}}
else if (readCookie('country')=='United Kingdom') {
vat = (price/100)* 17.5;
vatDisp="VAT ";
}
vat=numToDisp(vat);
vatDisp=vatDisp+'@'+vat;
return vatDisp;
}
