 function openCertDetails()
{
	
	var referer = "";
	var siteSealImage;

	if (self.sampleReferer) 
		referer = self.sampleReferer;
	else
		referer = window.location; 
	
	if (document.images) {
		siteSealImage = document.images["thawteSiteSeal"]
		siteSealImage.src="https://www.thawte.com/cgi/server/seal_generator.exe?referer=" + referer
	}

	certDetailsUrlWithReferer = "https://www.thawte.com/cgi/server/certdetails.exe?referer=" + referer;
	thewindow = window.open(certDetailsUrlWithReferer,
		"newWindow", config="height=500,width=516,toolbar=no,menubar=no," +
		"scrollbars=yes,resizable=no,location=no,directories=no,status=yes");
}
 
  var thequantity;
  var theorder;
  
    function presentValue(value) {
        if(value<=0.9999) {
            newPounds='0';
        } else {
            newPounds=parseInt(value);
        }
        
        if (value>0) {
            newPence=Math.round((value+.000008 - newPounds)*100);
        } else {
            newPence=0;
        }        
        
        if (newPence==100){newPence=0; ++newPounds}//fix bug
        	
        compstring='9';
        for (var i=1; i <=1;i++) {
            if (eval(newPence) <= eval(compstring)) newPence='0'+newPence;
            compstring=compstring+'9';
        }
        newString='£' + newPounds + '.' + newPence + '';

        return (newString);
    }
	
var basketsum,rediv
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function basketsummary() {

        index = document.cookie.indexOf('TheBasket');
        countbegin=(document.cookie.indexOf('=',index)+1);
        countend=document.cookie.indexOf(';',index);
        if (countend==-1) { countend=document.cookie.length; }
        fulllist=document.cookie.substring(countbegin,countend);
              
        itemlist=0;
        for(var i=0; i<=fulllist.length;i++) {
            if(fulllist.substring(i,i+1)=='['){itemlist=itemlist+1;}
        }
if ((basketsum!=null)&(basketsum!="")){rediv="yes"}
basketsum="";
basketsum=basketsum+'<TABLE WIDTH="155" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#006699" ALIGN="CENTER"><TR><TD><TABLE WIDTH="155" BORDER="0" CELLSPACING="1" CELLPADDING="3" ALIGN="CENTER"><TR BGCOLOR="#0099CC"><TD ROWSPAN="2" WIDTH="40"  height="40" align="center"><IMG SRC="images/basket1.gif" WIDTH="30" HEIGHT="30"></TD><TD COLSPAN="2"><p><b><font color="#FFCC00">Your Basket</font></b></p></TD></TR><TR><TD BGCOLOR="#0099CC" NOWRAP><p><b><font color="#FFCC00">';
if(itemlist==0){basketsum=basketsum+='empty';}else if(itemlist==1){basketsum=basketsum+='1 item';}else{basketsum=basketsum+=itemlist+' items';}
basketsum=basketsum+'</font></b></p></TD><TD WIDTH="42" BGCOLOR="#0099CC" ALIGN="CENTER"><A HREF="basket.asp"><B><font color="#FFCC00">View</font></B></A></TD></TR></TABLE></TD></TR></TABLE>';
if (rediv!="yes")document.write(basketsum);
if (rediv=="yes")basketsumdiv.innerHTML=basketsum;
}

    
 function showBuyBasket() {
        index = document.cookie.indexOf('TheBasket');
        countbegin=(document.cookie.indexOf('=',index)+1);
        countend=document.cookie.indexOf(';',index);
        if (countend==-1) { countend=document.cookie.length; }
        fulllist=document.cookie.substring(countbegin,countend);
        totprice=0;
        deliverytot=0;
        subtotal=0;
        
        theorder='****************************************************\n\n';
 		document.writeln('<input type="hidden" name="Order_Summary_" value="">');

        document.writeln('<table cols=5 border=0 cellspacing=5 cellpadding=5>');
        document.writeln('<tr><td align=left><b><p>Product</p></b></td><td align=left>&nbsp;</td><td align=right><b><p>Quantity</p></b></td><td align=right><b><p>Unit Price</p></b></td><td align=right><b><p>Total Cost</p></b></td></tr>');

        
      
        itemlist=0;
        for(var i=0; i<=fulllist.length;i++) {
            if(fulllist.substring(i,i+1)=='[') {
                itemstart=i+1;
                thisitem=1;
            }else if (fulllist.substring(i,i+1)==']') {
                	itemend=i;
                	thequantity=fulllist.substring(itemstart,itemend);
                	itemtotal=0;
                	itemtotal=eval(theprice * thequantity);
					
					quantity=thequantity;
					del=eval(quantity * 9.45);
					
                	temptotal=itemtotal*100;
                	totprice=totprice+itemtotal;
                	itemlist=itemlist+1;
                	deliverytot=deliverytot+thequantity;
                	theorder = theorder + thequantity +  ' of ' + field1 + ' '+ option + ' @ ' + presentValue(eval(theprice)) + ' = '+ presentValue(itemtotal) +'\n';
                	document.writeln('<tr><td><p>'+field1+'&nbsp;</p></td><td><p>'+option+'&nbsp;</p></td><td align=right><p>&nbsp;'+thequantity+'</p></td><td align=right><p>&nbsp;'+presentValue(eval(theprice))+'</p></td><td align=right><p>&nbsp;'+presentValue(itemtotal)+'</p></td></tr>');
            		
            		} else if (fulllist.substring(i,i+1)=='|') {
                	    if (thisitem==1) field1 = fulllist.substring(itemstart,i);
                	    if (thisitem==2) theprice = fulllist.substring(itemstart,i);
                	    if (thisitem==3) field4 = fulllist.substring(itemstart,i);
                	    if (thisitem==4) option = fulllist.substring(itemstart,i);
                	    thisitem++;
                	    itemstart=i+1;
            		}
            }
        document.writeln('<tr><td colspan=5><hr></td></tr>');
        document.writeln('<tr><td colspan=4 align=right><p>Sub Total</p></td><td align=right><p>&nbsp;'+presentValue(totprice)+'</p></td><td></td></tr>');
        theorder=theorder+'\n\n';
        subtotal=totprice;
        theorder=theorder+'Sub Total       : '+ presentValue(subtotal)+'\n';

	//deliverytot=deliverytot*9.45;
	deliverytot=del;
	alert(deliverytot);
        document.writeln('<tr><td colspan=4 align=right><p>Delivery charge</p></td><td align=right><p>'+presentValue(deliverytot)+'</p></td><td></td></tr>');
        
       
	document.writeln('<tr><td colspan=5><hr></td></tr>');
        document.writeln('<tr><td colspan=4><p><b>Total Goods</b></p></td><td align=right><p>'+presentValue(totprice)+'</p></td><td></td></tr>');
        document.writeln('<tr><td colspan=5><hr></td></tr>');
        document.writeln('</table>');	      
        
    }
    
 


    function removeItem(itemno) {
        alert(itemno);
        newItemList=null;
        itemlist=0;
        for(var i=0;i<=fulllist.length;i++) {
            if (fulllist.substring(i,i+1)=='[') {
                itemstart=i+1;
            } else if (fulllist.substring(i,i+1)==']') {
                itemend=i;
                theitem = fulllist.substring(itemstart,itemend);
                itemlist=itemlist+1;
                if(itemlist != itemno) {
                    newItemList = newItemList+'['+fulllist.substring(itemstart,itemend)+']';
                }
            }
        }
        index = document.cookie.indexOf('TheBasket');
        document.cookie='TheBasket='+newItemList
        self.location = 'buy.htm';
    }

    function showBasket() {
        index = document.cookie.indexOf('TheBasket');
        countbegin=(document.cookie.indexOf('=',index)+1);
        countend=document.cookie.indexOf(';',index);
        if (countend==-1) { countend=document.cookie.length; }
        fulllist=document.cookie.substring(countbegin,countend);
        totprice=0;
        document.writeln('<form name="basketform">');
        document.writeln('<table cols=5 border=0 cellspacing=5 cellpadding=5>');
        document.writeln('<tr><td align=left><b><p>Product</p></b></td><td align=left>&nbsp;</td><td align=right><b><p>Quantity</p></b></td><td align=right><b><p>Unit Price</p></b></td><td align=right><b><p>Total Cost</p></b></td><td align=center><b><p>Action</p></b></td></tr>');

        
        itemlist=0;
        for(var i=0; i<=fulllist.length;i++) {
            if(fulllist.substring(i,i+1)=='[') {
                itemstart=i+1;
                thisitem=1;
            }else if (fulllist.substring(i,i+1)==']') {
                	itemend=i;
                	thequantity=fulllist.substring(itemstart,itemend);
                	itemtotal=0;
                	itemtotal=(eval(theprice*thequantity));
                	temptotal=itemtotal*100;
                	totprice=totprice+itemtotal;
                	itemlist=itemlist+1;
                	document.writeln('<tr><td><p>'+field1+'&nbsp;</p></td><td><p>'+option+'&nbsp;</p></td><td align=right>&nbsp;<INPUT TYPE=TEXT NAME="quant'+itemlist+'" VALUE="'+thequantity+'" SIZE=3></td><td align=right><p>&nbsp;'+presentValue(eval(theprice))+'</p></td><td align=right><p>&nbsp;'+presentValue(itemtotal)+'</p></td><td><a href="javascript:removeItem(' +itemlist+ ');"><img src="images/Remove.gif" border="0" alt="Remove ' +field1+' from shopping basket"></a></td></tr>');
					theorder = theorder + thequantity +  ' of ' + field1 + ' '+ option + ' @ ' + presentValue(eval(theprice)) + ' = '+ presentValue(itemtotal) +'\n';

            	} else if (fulllist.substring(i,i+1)=='|') {
                	if (thisitem==1) field1 = fulllist.substring(itemstart,i);
                	if (thisitem==2) theprice = fulllist.substring(itemstart,i);
                	if (thisitem==3) field4 = fulllist.substring(itemstart,i);
                	if (thisitem==4) option = fulllist.substring(itemstart,i);
             
                	thisitem++;
                	itemstart=i+1;
            }
        }
        document.writeln('<tr><td colspan=6><hr></td></tr>');
        document.writeln('<tr><td colspan=4><p><b>Total Goods</b></p></td><td align=right><p>&nbsp;'+presentValue(totprice)+'</p></td><td></td></tr>');
        document.writeln('</table>');
        document.writeln('<br><input type="image" border="0" src="images/empty-bask.gif" value="Clear basket" onClick="clearBasket();">');
        document.writeln('&nbsp;<input type="image" border="0" src="images/basket-update.gif" value="Update" onClick="updateBasket();">');
        document.writeln('</form>');
    }

    function removeItem(itemno) {
        newItemList=null;
        itemlist=0;
        for(var i=0;i<=fulllist.length;i++) {
            if (fulllist.substring(i,i+1)=='[') {
                itemstart=i+1;
            } else if (fulllist.substring(i,i+1)==']') {
                itemend=i;
                theitem = fulllist.substring(itemstart,itemend);
                itemlist=itemlist+1;
                if(itemlist != itemno) {
                    newItemList = newItemList+'['+fulllist.substring(itemstart,itemend)+']';
                }
            }
        }
        index = document.cookie.indexOf('TheBasket');
        document.cookie='TheBasket='+newItemList
        self.location = 'basket.asp';
    }

    function clearBasket() {
        if (confirm('Are you sure you wish to clear the basket?')) {
            index=document.cookie.indexOf('TheBasket');
            document.cookie='TheBasket=.';
            self.location='basket.asp';
        }
    }

    function updateBasket() {
        newItemList=null;
        itemlist=0;
        for(var i=0;i<=fulllist.length; i++) {
            if(fulllist.substring(i,i+1)=='[') {
                thisitem=1;
                itemstart=i+1;
                fullstart=i+1;
            } else if(fulllist.substring(i,i+1)==']') {
                itemend=i;
                itemlist++;
                thiselement='quant'+itemlist;
                newItemList=newItemList+'['+field1+'|'+field2+'|'+field3+'|'+field4+'|'+document.basketform.elements[thiselement].value+']';
            } else if(fulllist.substring(i,i+1)=='|') {
                if (thisitem==1) field1 = fulllist.substring(itemstart,i);
                if (thisitem==2) field2 = fulllist.substring(itemstart,i);
                if (thisitem==3) field3 = fulllist.substring(itemstart,i);
                if (thisitem==4) field4 = fulllist.substring(itemstart,i);
                thisitem++;
                itemstart=i+1;
            }
        }
        index=document.cookie.indexOf('TheBasket');
        document.cookie='TheBasket='+newItemList
        self.location='basket.asp';
    }

    function BuyItem(newItem, newPrice, newTaxable, newOption, newQuantity) {
        if(newQuantity<=0) {
            rc = alert('The quantity entered is incorrect');
        } else {
            if (confirm('Would you like to add a '+newItem+' '+newOption+' to your shopping basket? ')) {
                index=document.cookie.indexOf('TheBasket');
                countbegin=(document.cookie.indexOf('=',index)+1);
                countend=document.cookie.indexOf(';',index);
                if(countend==-1) {
                    countend=document.cookie.length;
                }
              
                document.cookie='TheBasket='+document.cookie.substring(countbegin,countend)+'['+newItem+'|'+newPrice+'|'+newTaxable+'|'+newOption+'|'+newQuantity+']';
            }
        }
    }
function calcShipping(){
	

        if (thequantity > 1) 
        	{deliverytot=0;}
        else
        	{deliverytot=0;}
	
	document.basketform.Delivery.value=presentValue(deliverytot);
	totprice=subtotal;
	totprice=totprice+deliverytot;
	document.basketform.Total.value=presentValue(totprice);

}
function finishOrder(){
	theorder = theorder + '\n****************************************************\n\n';
	document.basketform.Order_Summary_.value=theorder;
}

function submitOrder(){
	document.basketform.thebasket.value=Get_Cookie('TheBasket');
	document.basketform.submit();
}

function gotoCheckout(){
	alert('Thank you for your order.\n\nYou are just about to be transported to our Secure Server.\n\nIf you have any problems:\n\nPlease press your browser\'s BACK button\n\nthen try our Alternative Secure Server.');
	submitOrder();
}

function setAltSecureServer(){
	document.basketform.action='https://secure.esterling.co.uk/teleconferencing.co.uk/checkout.asp';
	//document.basketform.action='checkout.asp';
	submitOrder();
}



function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { 
	alias=args[i+1];
	test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
		if (alias.length == 0) {
			alias = nm;
		}
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+alias+' must contain a valid email address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+alias+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+alias+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
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);
//-->