

// -------------------------------------------------------------------
function getCookie(name){

     // Simply retreives a cookie

var cname = name + "=";
var dc = document.cookie;
     if (dc.length > 0) {
          begin = dc.indexOf(cname);
          if (begin != -1) {
               begin += cname.length;
               end = dc.indexOf(";", begin);
               if (end == -1) end = dc.length;
               return unescape(dc.substring(begin, end));
          }
     }
return null;
}

// -------------------------------------------------------------------
function GoTo(thisURL) {
     self.location = thisURL;
}

// -------------------------------------------------------------------
function OpenWindow(thisURL) {
     var x = 465;
     var y = 465;
     var gWin = window.open(thisURL,'GraphicWindow',
     'width='+x+',height='+y+',resizable=0,scrollbars=0');
}

// -------------------------------------------------------------------
function formReset(){
     for(i = 0; i < document.forms[0].elements.length; i++){
          var inType = document.forms[0].elements[i].type;
          if(inType == "text"){
               document.forms[0].elements[i].value = "";
          }
     }
}

function checkName(form, val){
    form.elements[val].value = form.elements[val].value.replace("'", "");
}

// -------------------------------------------------------------------
function qtyCheck(){

var qtySelected = parseInt(0);
var sizeAvailable = false;
var availableQty = parseInt(1);
var setupSet = false;

 for(a = 0; a < document.forms.length; a++){
     for(i = 0; i < document.forms[a].elements.length; i++){
          var fieldName = document.forms[a].elements[i].name;
          if(fieldName.substring(0,4) == "SIZE"){
               sizeAvailable = true;
               var fieldValue = parseInt(document.forms[a].elements[i].value);
               if(fieldValue > 0){
                    qtySelected += parseInt(fieldValue);
               }
          }
          if((fieldName.substring(0,8) == "QUANTITY")&&(!sizeAvailable)){
               var fieldValue = parseInt(document.forms[a].elements[i].value);
               if(fieldValue > 0){
                    qtySelected += parseInt(fieldValue);
               }
          }
          if(fieldName.substring(0,12) == "OPTION|setup"){
               var setupSet = document.forms[a].elements[i].options[1].selected;
               //alert(setupSet);
               //return false;
          }

          if(fieldName == "min_qty"){
               var fieldValue = parseInt(document.forms[a].elements[i].value);
               if(fieldValue > 0){
                    availableQty = parseInt(fieldValue);
               }
          }
     }
 }
 if((qtySelected == 0)&&(sizeAvailable)){
     alert("You have not entered a quantity for the size of an item to add to the cart?");
     return false;
 }
 if((qtySelected == 0)&&(!sizeAvailable)){
     alert("You have not entered a quantity for an item to add to the cart?");
     return false;
 }

 if((qtySelected < availableQty)&&(setupSet)){
     alert("You must purchase a minimum quantity of " + availableQty + " for this item");
     return false;
 }



return true;
}
//-->


