debugger;

function gofile(form) {
var vssel=form.dest.selectedIndex
location = (form.dest.options[vssel].value);
}

function priceFormat(value) {
 if (parseInt(value) > 0.99) {
 adjHundred = parseInt(value);
 ften = parseInt((value+.0008 - parseInt(value))* 100);
  if (ften < 10) {
  adjTen = '0' + ften;}
  else{
  adjTen = ften;
  }
 adjResult = adjHundred + '.' + adjTen;
 } else {
 ften = '0' + value;
  if (ften.charAt(4) == "0") {
  adjResult = '0' + ften.charAt(1) + ften.charAt(2) + ften.charAt(3);
  } else {
  adjResult = '0' + ften.charAt(1) + ften.charAt(2) + ften.charAt(3) + ften.charAt(4);
  }
 }
return (adjResult);
}

function displayCart() {
vstrack = document.cookie.indexOf("vsCart");
startcount = (document.cookie.indexOf("=", vstrack) + 1);
finishcount = document.cookie.indexOf(";", vstrack);
if (finishcount == -1) {
 finishcount = document.cookie.length;
 }
alldata = document.cookie.substring(startcount, finishcount);
alltotal = 0;
document.writeln('<TABLE width=70% border=1 cellspacing=1 cellpadding=2 bgcolor=#cccccc cols=5><TR><TD colspan=5><font color=#000080><b>Your&nbsp;Shopping&nbsp;Cart</b><font color=#000000></TD></TR>');
listcount = 0;
 for (var i = 0; i <= alldata.length; i++) {
  if (alldata.substring(i,i+1) == ']') {
  listcount=listcount+1;}
 }	

 if (listcount > 0){
 document.writeln('<TR><TD><img src="images/cart.gif" align="bottom" border="0" hspace="5" width="42" height="31" alt="Your Shopping Cart">Items&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD><TD valign="bottom">Qty</b></TD><TD valign="bottom">Each</TD><td valign="bottom">Total</TD><TD valign="bottom">Remove</TD></TR>');
 } else {
 document.writeln('<TR><TD colspan="5"><img src="images/cart.gif" align="middle" border="0" hspace="5" width="42" height="31" alt="Your Shopping Cart">   <font color=#000000>Empty</TD></TR>');
 }	
listcount = 0;
 for (var i = 0; i <= alldata.length; i++) {
  if (alldata.substring(i,i+1) == '[') {
  listbegin = i+1;
  } else if (alldata.substring(i,i+1) == ']') {
  listfinish = i;
  vsamount = alldata.substring(listbegin, listfinish);
  listtotal = 0;
  listtotal = (eval(vsprice*vsamount));
  liststore = listtotal * 100;
  alltotal = alltotal + listtotal;
  listcount=listcount+1;
  document.writeln('<tr bgcolor=#ffffff><td>'+vsobject+'</td><td>'+vsamount+'</td><td>'+vsprice+'</td><td align=right>'+priceFormat(listtotal)+'</td><td align=center><a href="javascript:clearSlot('+listcount+')"><image src=images/del.gif width=56 height=24 border=0></a></td></tr>');
  document.writeln('<INPUT TYPE="hidden" NAME="Purchase'+listcount+'" VALUE="'+vsobject+'" SIZE="40">');
  document.writeln('<INPUT TYPE="hidden" NAME="Quantity'+listcount+'" VALUE="'+vsamount+'" SIZE="40">');
  document.writeln('<INPUT TYPE="hidden" NAME="Price Each'+listcount+'" VALUE="'+vsprice+'" SIZE="40">');
  document.writeln('<INPUT TYPE="hidden" NAME="Total Cost'+listcount+'" VALUE="'+priceFormat(listtotal)+'" SIZE="40">');
  } else if (alldata.substring(i,i+1) == ',') {
  vsobject = alldata.substring(listbegin, i);
  listbegin = i+1;
  } else if (alldata.substring(i,i+1) == '#') {
  vsprice = alldata.substring(listbegin, i);
  listbegin = i+1;
  }
 }
 if (listcount > 0) {
 document.writeln('<tr><td colspan=3 align=right><b>Grand Total: &#036;</b></td><td align=right><b>'+priceFormat(alltotal)+'</b></td><td>&nbsp;</td></tr>');
 document.writeln('<INPUT TYPE="hidden" NAME="Goods Total" VALUE="'+priceFormat(alltotal)+'">');		
 } else {
 document.writeln('<tr><td colspan=5>&nbsp;</td></tr>');
 }
 document.writeln('</TABLE>');
}

function clearSlot(datnumber) {
wantItList = null;
listcount = 0;
 for (var i = 0; i <= alldata.length; i++) {
  if (alldata.substring(i,i+1) == '[') {
  listbegin = i+1;
  } else if (alldata.substring(i,i+1) == ']') {
  listfinish = i;
  vsobject = alldata.substring(listbegin, listfinish);
  listcount=listcount+1;
   if (listcount != datnumber) {
   wantItList = wantItList+'['+alldata.substring(listbegin, listfinish)+']';
   }
  }
 }
vstrack = document.cookie.indexOf("vsCart");
document.cookie="vsCart="+wantItList;
location = thispage;
}


function addToCart(wantIt, wantPrice, wantAmount) {
pPrice = '';
 if (wantPrice.charAt(wantPrice.length-1) == '%'){
  for (var x = 0; x < wantPrice.length-1; x++) {
  pPrice = pPrice + wantPrice.charAt(x);
  }
 wantPrice = (pPrice * priceFormat(alltotal)) / 100;
 wantPrice = priceFormat(wantPrice);
 }
 pPrice=''
  if ((wantPrice.charAt(wantPrice.length-3) !== '.') && (wantPrice.charAt(wantPrice.length-3) !== "0")){
  for (var x = 0; x < wantPrice.length-1; x++) {
  pPrice = pPrice + wantPrice.charAt(x);
  }
  wantPrice = pPrice;
 }
 if (wantAmount <= 0) {
 rc = alert('You must order at least one.');
 return false;
 }

vstrack = document.cookie.indexOf("vsCart");
startcount = (document.cookie.indexOf("=", vstrack) + 1);
finishcount = document.cookie.indexOf(";", vstrack);


 if (finishcount == -1) {
 finishcount = document.cookie.length;
 document.cookie="vsCart="+document.cookie.substring(startcount, finishcount)+"["+wantIt+","+wantPrice+"#"+wantAmount+"]";
 location = thispage;		
 }
return true;
}

function enlargeBookmark(imageUrl)
{
/*window.open(imageUrl,'','resizable=yes,width=130,height=330,scrollbars=yes');*/
window.open('ebkmk.htm?'+imageUrl, '', 'resizable=yes,width=230,height=520');
return false;
}

function enlargeBookmark4(imageUrl)
{
/*window.open(imageUrl,'','resizable=yes,width=130,height=330,scrollbars=yes');*/
window.open('ebkmk.htm?'+imageUrl, '', 'resizable=yes,width=550,height=350');
return false;
}
function enlargeBookmark2(imageUrl)
{
/*window.open(imageUrl,'','resizable=yes,width=130,height=330,scrollbars=yes');*/
window.open('ebkmk2.htm?'+imageUrl, '', 'resizable=yes,width=270,height=270');
return false;
}
function enlargeBig(imageUrl,w,h)
{
/*window.open(imageUrl,'','resizable=yes,width=130,height=330,scrollbars=yes');*/
window.open('ebbig.htm?'+imageUrl, '', 'resizable=yes,width='+w+',height='+h);
return false;
}
function enlargeBookmark5(imageUrl)
{
/*window.open(imageUrl,'','resizable=yes,width=130,height=330,scrollbars=yes');*/
window.open('ebkmk.htm?'+imageUrl, '', 'resizable=yes,width=550,height=450');
return false;
}
function enlargeBookmark6(imageUrl)
{
/*window.open(imageUrl,'','resizable=yes,width=130,height=330,scrollbars=yes');*/
window.open('ebkmk.htm?'+imageUrl, '', 'resizable=yes,width=600,height=800');
return false;
}
