<!-- hide script from old browsers

function acceptsCookies() {
// This next little bit of code tests whether the user accepts cookies.
// The code attempts to create a cookie called DinsdaleTest.  If it fails
// to do so then one can assume that cookies are not allowed.
  var acceptsCookies = false;
  var expDate = new Date ();
  expDate.setTime( expDate.getTime() - 10 ); 
  document.cookie = 'DinsdaleTest=yes; expires='+expDate.toGMTString();
  expDate.setTime( expDate.getTime() + 100000 ); 
  document.cookie = 'DinsdaleTest=yes; expires='+expDate.toGMTString();
  if(document.cookie.indexOf('DinsdaleTest=yes') != -1) {
  	acceptsCookies = true; 
        document.cookie = 'DinsdaleTest=yes';
  }
  return acceptsCookies;
}

function openWindow(url) {
// Open a URL in a new window 
// First check if an object OpenWindow exists, if it doesn't then open it.
// If it does close and recreate it.
	var type;
	type = typeof OpenWindow;
	if (type == 'undefined' ) {
		OpenWindow=window.open(url,'newwindow','alwaysRaised=yes,resizable=yes,height=300,width=300,toolbar=no,menubar=no,location=no,status=yes,scrollbars=yes');
	} else {
		OpenWindow.close();
		OpenWindow=window.open(url,'newwindow','alwaysRaised=yes,resizable=yes,height=300,width=300,toolbar=no,menubar=no,location=no,status=yes,scrollbars=yes');
	}
}

function deleteCookies() {
//
// Delete all the cookies used by the shopping cart system
//
    var expDate = new Date ();
    var cval;
    expDate.setTime( expDate.getTime() - 1 ); 
    cval = getmycookielist ('DinsdaleBasketDestination');
    document.cookie='DinsdaleBasketDestination='+cval+'; expires='+expDate.toGMTString()+' path=/';
    cval = getmycookielist ('DinsdaleBasket');
    document.cookie='DinsdaleBasket='+cval+'; expires='+expDate.toGMTString()+' path=/';
    cval = getmycookielist ('DinsdaleInfo');
    document.cookie='DinsdaleInfo='+cval+'; expires='+expDate.toGMTString()+' path=/';
    cval = getmycookielist ('DinsdaleTest');
    document.cookie='DinsdaleTest='+cval+'; expires='+expDate.toGMTString()+' path=/';
    alert('All cookies associated with Dinsdale Embroideries have been removed');
}

function buyItem(newItem,newPrice,newTaxable,newWeight,newField1,newAP,newQuantity) {
//
// The user has requested to buy an item
    var rc, fulllist, newItemList, thisitem, itemstart, fullstart, itemend, thequantity;
    var itemList, theItem, thePrice, theTaxable, theWeight, theField1, theAP;
    // The routine first checks to see if cookies are accepted.
    if ( acceptsCookies() == false ) {
        rc = alert('Your web browser does not accept cookies, see our terms and conditions for more information');
	return;
    }
    // The user might have entered a silly quantity, check for it
    keep = newQuantity;
    newQuantity = parseInt(newQuantity)+"";
    if ( isNaN ( parseInt(newQuantity) ) ) {
        rc = alert('You must request a whole number quantity, '+keep+' is not valid');
    } else if ( parseInt(newQuantity) <=0 ) {
        rc = alert('You must request a whole number quantity, '+keep+' is not valid');
    } else if ( keep != newQuantity ) {
        rc = alert('You must request a whole number quantity, '+keep+' is not valid');
    // Now we are ready to proceed
    } else {
        // Check if the user is happy to go on
        if (confirm('Do you wish to add '+newQuantity+' x '+newItem+' to your shopping basket?')) {
	    // get the full list of items stored in DinsdaleBasket cookie
	    fulllist = getmycookielist('DinsdaleBasket');
	    // Now initialise the new item list and loop around the old one.
	    // Each record consists of
	    // [ Name | price | taxabale | weight | field1 | AP | quantity ]
            newItemList=''; 
            newItemList=fulllist+'['+newItem+'|'+newPrice+'|'+newTaxable+'|'+newWeight+'|'+newField1+'|'+newAP+'|'+newQuantity+']';
	     writeDinsdaleBasket(newItemList);
        }
    }
}   

function presentValue(value) {
// format value into pounds and pence
// and return the result
    var newPounds, dec, newPence, compstring, newString;
    if(value<=0.9999) {
        newPounds='0';
    } else {
        newPounds=parseInt(value);
    }
    dec='1';
    for (var i=1; i<=2;i++) {
        dec=dec+'0';
    }
    if (value>0) {
        newPence=Math.round((value+.000008 - newPounds)*(eval(dec)));
    } else {
        newPence=0;
    }
    compstring='9';
    for (var i=1; i <=2-1;i++) {
        if (eval(newPence) <= eval(compstring)) newPence='0'+newPence;
        compstring=compstring+'9';
    }
    if (2>0) {
        newString='£' + newPounds + '.' + newPence + '';
    } else {
        newString='£' + newPounds + '';
    }
    return (newString);
}

function addFiller(curnum) {
    var newnum;
    newnum=parseInt(curnum);
    if (newnum<10) return '00'+newnum;
    if (newnum<100) return '0'+newnum;
    return newnum;
}

function getmycookielist(cookie) {
// Return the values stored in 'cookie'
 var index, countbegin, countend, fulllist;
 fulllist='';
 index=document.cookie.indexOf(cookie);
 if (index==-1) return fulllist;
 countbegin=(document.cookie.indexOf('=',index)+1);
 countend=document.cookie.indexOf(';',index);
 if (countend==-1) { countend=document.cookie.length; }
 fulllist=document.cookie.substring(countbegin,countend);
 //jk alert('getmycookielist: '+cookie+'='+fulllist);
 return fulllist;
}

function writeDinsdaleBasket(items) {
// Set the DinsdaleBasket with the content in items.
//jk    var expDate = new Date ();
//jk    expDate.setTime( expDate.getTime() + (1 * 24 * 60 * 60 * 1000) ); 
    document.cookie='DinsdaleBasket='+items+'; path=/';
}

// end hiding script from old browsers>
