﻿// JScript File

var order = new Object();  // object to store order items in
var root  = new Object();  // selection criteria
var on    = true;
var off   = false;
var cntr  = 0;             // items in object
var opts  = 5;             // number of options to allow
var shpr  = function (wt) {return 0;} // what to charge for shipping;
var stxt  = "";            // shipping text
var spos  = -1;            // shipping position selector
var ttax  = 0;             // percent for taxes
var ttxt  = "0";           // tax text
var tpos  = -1;            // tax position selector
var tamt=0,tqty=0,twgt=0,wgt=0,thnd=0;  // totals

root.hamt = 0;     // amount, below which, handling charge applies
root.hand = 0;     // handling charge for orders less than hamt
root.shp  = off;    // shipping selection line
root.tax  = off;    // tax selection line
// place for user-specific options
root.xx_can  = "../shopping_cart.aspx"; // place for PayPal cancel return path
root.xx_cur  = ""; // enter default currency code (or null)
root.xx_id   = ""; // PayPal ID
root.xx_img  = ""; // image URL
root.xx_lc   = ""; // enter default country code (or null)
root.xx_ret  = "../products.aspx"; // place for PayPal return path
root.xx_sty  = ""; // place for PayPal page style
root.xx_xtra = ""; // place for other PayPal commands

function SendCart () {  // send the cart to PayPal
var frst = true;  // 1st pass thru items.
var winpar = "width=800,height=600,scrollbars," +
             "location='center',resizable,status";
var strn   = "https://www.paypal.com/cgi-bin/webscr?cmd=_cart" +
             "&upload=1" +
             "&business=" + root.xx_id + root.xx_xtra;
var d = document.orderf;
var i,j=0,des;
  if (root.xx_cur.length > 0)
    strn = strn + "&currency_code=" + root.xx_cur;
  if (root.xx_lc.length > 0)
    strn = strn + "&lc=" + root.xx_lc;
  if (root.xx_can.length > 0)
    strn = strn + "&cancel_return=" + root.xx_can;
  if (root.xx_ret.length > 0)
    strn = strn + "&return=" + root.xx_ret;
  if (root.xx_sty.length > 0)
    strn = strn + "&page_style=" + root.xx_sty;
  if (root.xx_img.length > 0)
    strn = strn + "&image_url=" + root.xx_img;
//  if (tpos > 0) strn = strn + "&tax_cart=" + Dollar (tamt*ttax/100);
 var j=1;
  var c = d.getElementsByTagName("*");
 for (i=0;i<c.length;i++) 
  {  
  var _desc = document.getElementById("lbl_desc_" + j);
    if (c[i].id != "" && _desc!= null)
    {
      if (c[i].id==document.getElementById("lbl_desc_" + j).id)
      {
        if (document.getElementById("lbl_desc_" + j).innerHTML != "Shipping / Handling Costs" )
        {
              strn = strn + "&item_name_"    + j + "=" + escape (document.getElementById("lbl_desc_" + j).innerHTML) +
                            "&item_number_"  + j + "=" + i +
                            "&quantity_"     + j + "=" + document.getElementById("lbl_qty_" + j).innerHTML +
                            "&amount_"       + j + "=" + document.getElementById("lbl_ea_" + j).innerHTML;
        }
        if (document.getElementById("lbl_desc_" + j).innerHTML == "Shipping / Handling Costs" )
        {
                strn = strn + "&item_name_"    + j + "=" + escape (document.getElementById("lbl_desc_" + j).innerHTML) +
                            "&item_number_"  + j + "=" + i +
                            "&quantity_"     + j + "=" + "1" +
                            "&amount_"       + j + "=" + document.getElementById("lbl_tot_" + j).innerHTML;
        }                            
        if (document.getElementById("lbl_desc_" + j).innerHTML == "Taxes" )
        {
                strn = strn + "&item_name_"    + j + "=" + escape (document.getElementById("lbl_desc_" + j).innerHTML) +
                            "&item_number_"  + j + "=" + i +
                            "&quantity_"     + j + "=" + "1" +
                            "&amount_"       + j + "=" + document.getElementById("lbl_tax").innerHTML;
        }
        
          j=j+1
          i=-1
      }
      frst = false;
     }
  }
 //         strn = strn + "&subtotal_"       + j + "=" + escape (document.getElementById("lbl_subtotal").innerHTML) +
 //                       "&shipping_"       + j + "=" + document.getElementById("lbl_shipping").innerHTML +
//                        "&tax_"       + j + "=" + document.getElementById("lbl_tax").innerHTML +
//                        "&totals_"       + j + "=" + document.getElementById("lbl_totals").innerHTML;
                        
  if (j > 0) window.open (strn, "paypal", winpar);
}

/* *******************************************************************  */
function get_total(fld,fld2,fld3)
{
    var _total = parsefloat(fld)* parsefloat(fld2)
    alert(_total)
}

function change_css()
{
var theRules = new Array();
if (document.styleSheets[1].cssRules)
	theRules = document.styleSheets[1].cssRules
else if (document.styleSheets[1].rules)
	//theRules = document.styleSheets[1].rules
    document.styleSheets[1].imports[0].rules[1].style.height="800px"
}


function isBrowserSupp() 
{
if (((navigator.appVersion.indexOf("2.0")) != -1) && (navigator.appName.indexOf("Netscape") != -1))
        {
        return false;
        }
else 
        {
        return true;
        }
}
function TE_openBrWindow(theURL,winName,features) { 
//window.open(theURL,winName,features);
var heightspeed = 2;
var widthspeed = 7;
var leftdist = 450;
var topdist = 350; 
if (document.all) {
var winwidth = 525; 
var winheight = 350; 
var sizer = window.open(theURL,"","left=" + leftdist + ",top=" + topdist + ",width=1,height=1,resizable=no,scrollbars=yes");
for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed) {
sizer.resizeTo("1", sizeheight);
}
for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed) {
sizer.resizeTo(sizewidth, sizeheight);
}
//sizer.location = theURL;
}
else
//window.location = website;
window.open(theURL,winName,features);
}

function close_form()
{
    if(document.getElementById("lbl_set").innerText == 1)
    {
        window.close()
    }
}


