<!--

    function makeRequest(url) {

        var http_request = false;

        //alert(url);

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange = function() { alertContents(http_request); };
        http_request.open('GET', url, true);
        http_request.send(null);
        
        //return alertContents(http_request);;

    }

    function alertContents(http_request) {
        //alert(http_request.readyState);
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
               //alert("Text "+http_request.responseText);

//               var returnedXML = http_request.responseXML.getElementsByTagName("total");
              
                //The node value will give you actual data
//               var sTotal = returnedXML[0].nodeValue; 
               var sTotal = http_request.responseText.split(":")[0];
//               alert("Total " + sTotal);
               document.CartForm.Subtotal.value = sTotal;

               var sDiscount = http_request.responseText.split(":")[1];
//              alert("Discount "+sDiscount);
//               document.CartForm.Discount.value = sDiscount;
               
            } else {
                alert('There was a problem with the request.'+http_request.status);
            }
        }

    }




function removeProduct(id) {
   removeURL = "/shop/removeitem.php?ID="+id;
   makeRequest(removeURL);
   toggleVisibility(id);
}

function removeWish(id) {
   removeURL = "/shop/removewish.php?ID="+id;
   makeRequest(removeURL);
   toggleVisibility(id);
}


function plusProduct(id) {
   var qtyField = eval("document.CartForm." + "qty" + id );
   qtyField.value = Number(qtyField.value)+1;
   //alert(qtyField.value)
   scriptURL = "/shop/plusitem.php?ID="+id;
   makeRequest(scriptURL);
}

function minusProduct(id) {
   var qtyField = eval("document.CartForm." + "qty" + id);
   //alert(qtyField.value)
   qtyField.value = Number(qtyField.value)-1;
   scriptURL = "/shop/minusitem.php?ID="+id;
   makeRequest(scriptURL);
}


function toggleVisibility(id) {
  var obj = null;
  if (  (document.getElementById && (obj = document.getElementById(id)))
     || (document.all && (obj = document.all[ id ]))) {
    obj.style.visibility = "hidden";
    obj.style.display = "none";
    obj.style.overflow = "hidden" ;
    obj.style.clip = "auto";
    obj.style.height = "0";
    }
  else if (document.layers && (obj = document.layers[id])) {
    obj.visibility = "hide";
    obj.style.display = "none";
    obj.style.overflow = "hidden" ;
   obj.style.clip = "auto";
    obj.style.height = "0";
   }


}



  function checkCookie() {
    if (document.cookie != "") {
	    return true;
	}
	else {
	  //alert("No cookie was found");
	  signupwin=window.open('http://www.Niterider.com/signup.html', 'signWin',
        'Toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=1,width=316,height=316')
	  return false;
	  }
  }


  function openCart (location) {
      shopcart=window.open(location, 'shopcart', 'Toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=1,width=445,height=460')
      shopcart.focus();
      return true;
     }

  function openModel (location) {
      modelwin=window.open(location, 'model','Toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=1,width=500,height=400')
      modelwin.focus();
     }



    function ExpressNotice () {
       noticeWindow = window.open('/eorder.html', 'noticeWin',
                     'Toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=1,width=350,height=200')
       noticeWindow.focus();
       }

     function eNotice () {
       ExpressWindow = window.open('/express.html', 'ExpressWin',
                     'Toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=1,width=350,height=200')
       ExpressWindow.focus();
       }

     function checkShipSame() {
      if (document.orderform.ShipSame[0].checked) {
	    alert('You must answer No to \'Same as above?\' if you want to ship to some other address')
		document.orderform.ShipSame[1].focus()
		document.orderform.ShipSame[1].select()
		return true
		}
	  return true
	}

    function validEmail(email) {

       invalidChars = " /:,;"
      if (email == "") {
        return false
      }

      for (i=0; i<invalidChars.length; i++) {
        badChar = invalidChars.charAt(i)
       if (email.indexOf(badChar,0) != -1) {
         return false
       }
      }

      atPos = email.indexOf("@",1)
      if (atPos == -1) {
        return false
      }

      if (email.indexOf("@", atPos+1) != -1) {
        return false
      }

      periodPos = email.indexOf(".",atPos)
      if (periodPos == -1) {
        return false
      }

      if (periodPos+3 > email.length) {
        return false
      }

      return true
   }


   function checkCard() {
     if (document.orderform.CCnum.value != "")
       alert("The credit card field must be empty if you are using this way to pay for your purchase");
      return false;
   }

   function validPaytype(form) {
       payOption=-1
      for (i=0; i<form.PayType.length; i++) {
        if (form.PayType[i].checked) {
         payOption=i
         }
      }
      if (payOption == -1) {
        return false
      }
      return true
   }

   function checkOrder(form) {

     invalidChars = "?&+"
     for (j=0; j<form.length; j++) {
	   //alert("Checking element "+form.elements[j].name);
	   if (!form.elements[j].value)
	     continue;

	   if (form.elements[j].name.indexOf('Item',0) != -1)
	     continue;

	   for (n=0; n<invalidChars.length; n++) {
	     badChar=invalidChars.charAt(n);
	     if (form.elements[j].value.indexOf(badChar,0) != -1) {
		    // Notify the customer
			alert(form.elements[j].name+ " has an invalid character :"+badChar+". Please change this information.")
			return false;
		 }
	   }
	 }

//     if (!validPaytype(form)) {
//      alert("You must select the way you wish to pay for this order")
//      return false
//      }


//    for (i=0; i<form.PayType.length; i++) {
//      if (form.PayType[i].checked) {
//       payOption=form.PayType[i].value
//       }
//    }

    payOption=form.PayType.value

    if (payOption == "CC") {
     //  alert('Checking credit cards');
       if (form.Amount1.value != "") {
          if (!CheckCardNumber(form.CARDNUM, form.CARDMONTH, form.CARDYEAR, form.CardType1))
             return false;
          
          if (form.CardOwner1.value == "") {
             alert("You must provide the name of the card owner")
             form.CardOwner1.focus()
             form.CardOwner1.select()
             return false
          }


          if (form.CVV1.value == "") {
             alert("You must provide the CVV number of the card")
             form.CVV1.focus()
             form.CVV1.select()
             return false
          }

       }
                              
    }


     return true
   }
   

   function checkShip(form) {

     invalidChars = "?&+"
     for (j=0; j<form.length; j++) {
	   //alert("Checking element "+form.elements[j].name);
	   if (!form.elements[j].value)
	     continue;

	   if (form.elements[j].name.indexOf('Item',0) != -1)
	     continue;

	   for (n=0; n<invalidChars.length; n++) {
	     badChar=invalidChars.charAt(n);
	     if (form.elements[j].value.indexOf(badChar,0) != -1) {
		    // Notify the customer
			alert(form.elements[j].name+ " has an invalid character :"+badChar+". Please change this information.")
			return false;
		 }
	   }
	 }

    if (form.FirstName.value == "") {
      alert("You must provide your name.")
      form.FirstName.focus()
      form.FirstName.select()
      return false
    }

    if (form.LastName.value == "") {
      alert("You must provide your name.")
      form.LastName.focus()
      form.LastName.select()
      return false
    }

    if (form.Address1.value == "") {
      alert("You must provide your address.")
      form.Address1.focus()
      form.Address1.select()
      return false
    }

    if (form.City.value == "") {
      alert("You must provide your city.")
      form.City.focus()
      form.City.select()
      return false
    }

    if ((form.State.value == "") && (form.AltState.value == "")) {
      alert("You must provide your state.")
      form.AltState.focus()
      form.AltState.select()
      return false
    }

    if (form.Country.value == "") {
      alert("You must provide your country.")
      return false
    }

    if (form.ZipCode.value == "") {
      alert("You must provide your zip code.")
      form.ZipCode.focus()
      form.ZipCode.select()
      return false
    }

    if (form.Telephone.value == "") {
      alert("You must provide your full telephone number.")
      form.Telephone.focus()
      form.Telephone.select()
      return false
    }

    //  Check size of telephone after stripping off
    //  everything except numbers.
    var strippedPhone = stringFilter(form.Telephone.value, '0987654321')
    if (strippedPhone.length < 10) {
      alert("You must provide your full telephone number.")
      form.Telephone.focus()
      form.Telephone.select()
      return false
    }


    if (form.ShipFirst.value == "") {
      alert("You must provide your ship to name.")
      form.ShipFirst.focus()
      form.ShipFirst.select()
      return false
    }

    if (form.ShipLast.value == "") {
      alert("You must provide your ship to name.")
      form.ShipLast.focus()
      form.ShipLast.select()
      return false
    }

    if (form.ShipAddress1.value == "") {
      alert("You must provide your ship to address.")
      form.ShipAddress1.focus()
      form.ShipAddress1.select()
      return false
    }

    if (form.ShipCity.value == "") {
      alert("You must provide your ship to city.")
      form.ShipCity.focus()
      form.ShipCity.select()
      return false
    }

    if ((form.ShipState.value == "") && (form.ShipAltState.value == "")) {
      alert("You must provide your ship to state.")
      form.ShipAltState.focus()
      form.ShipAltState.select()
      return false
    }

    if (form.ShipZipCode.value == "") {
      alert("You must provide your ship to zip code.")
      form.ShipZipCode.focus()
      form.ShipZipCode.select()
      return false
    }

    if (form.ShipTelephone.value == "") {
      alert("You must provide your ship to  telephone number.")
      form.ShipTelephone.focus()
      form.ShipTelephone.select()
      return false
    }

   return true
   }
   

   function stringFilter (input, keep, drop) {
   	s = input;
		// keep = "1234567890";     // Characters stripped out
		var i;
		var returnString = "";
		for (i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
			var c = s.charAt(i);
			if (keep.indexOf(c) != -1) returnString += c;
		}
//  	   alert('Returning  '+returnString)
		return returnString;
   }


   
   function xferInfo() {
      document.addform.ShipFirst.value = document.addform.FirstName.value;
      document.addform.ShipLast.value = document.addform.LastName.value;
      document.addform.ShipAddress1.value = document.addform.Address1.value;
      document.addform.ShipAddress2.value = document.addform.Address2.value;
      document.addform.ShipCity.value = document.addform.City.value;
      document.addform.ShipState.selectedIndex = document.addform.State.selectedIndex;
      document.addform.ShipAltState.value = document.addform.AltState.value;
      document.addform.ShipZipCode.value = document.addform.ZipCode.value;
      document.addform.ShipCountry.value = document.addform.Country.value;
      document.addform.ShipTelephone.value = document.addform.Telephone.value;
      document.addform.ShipEmailAddress.value = document.addform.EmailAddress.value;
      document.addform.ShipTelephone2.value = document.addform.Telephone2.value;
      document.addform.ShipFaxNumber.value = document.addform.FaxNumber.value;
      
//      if (document.addform.ShipState.options[document.addform.ShipState.selectedIndex].value='CA')
//         document.addform.Amount1.value=document.addform.Amount1.value*1.0725;

//      chgCountry(document.addform.ShipState);
      return true;  
   }


   function chgCountry(statefield) {

      if ((statefield.value == 'AB') ||
          (statefield.value == 'BC') ||
          (statefield.value == 'NB') ||
          (statefield.value == 'NF') ||
          (statefield.value == 'NT') ||
          (statefield.value == 'NS') ||
          (statefield.value == 'ON') ||
          (statefield.value == 'PE') ||
          (statefield.value == 'QC') ||
          (statefield.value == 'SK') ||
          (statefield.value == 'YT')) {

          document.addform.ShipCountry.value = 'CANADA';
       }
       else {
          document.addform.ShipCountry.value = 'USA';
       }
//       alert ("ShipCountry "+document.addform.ShipCountry.value+" State "+statefield.value);
   }


   function updateParent(uform) { 

     for (j=0; j<uform.length; j++) {
	   if (!uform.elements[j].value)
	     continue;
	     
         thiselement = uform.elements[j];
         thisname = thiselement.name;
        // alert("Checking "+thisname+" "+uform.elements[j].value);
         if (uform.elements[j].checked) {
            if (uform.elements[j].value != 'Change Zip Code') {
               parentfield = eval('opener.document.addform.'+thisname);
               parentfield.value=uform.elements[j].value;
            } 
         } 
      } 

     window.close();
     return false; 
    }







-->