<!-- Function to pop an image in a separate window -->

function popFriend(myCgi) {
    pInfo='toolbar=0,';
    pInfo+='location=0,';
    pInfo+='directories=0,';
    pInfo+='status=0,';
    pInfo+='menubar=1,';
    pInfo+='scrollbars=yes,';
    pInfo+='resizable=1,';
    pInfo+='width=450,';
    pInfo+='height=450,';
    var myPop = window.open(myCgi, 'myPop', pInfo);

    myPop.moveTo(5,5);
    myPop.document.close();
}


function popTxHelp(myCgi) {
    pInfo='toolbar=0,';
    pInfo+='location=0,';
    pInfo+='directories=0,';
    pInfo+='status=0,';
    pInfo+='menubar=1,';
    pInfo+='scrollbars=yes,';
    pInfo+='resizable=1,';
    pInfo+='width=450,';
    pInfo+='height=570,';
    var myPop = window.open(myCgi, 'myPop', pInfo);

    myPop.moveTo(50,5);
    myPop.document.close();
}


// ============================================================================
// In cart_body:
// Prevent user from continue/checkout if user put value in coupon/gift_certs/fundraising field.
//                                                      ALSO:  zip code (request line) 
//     Note: we add the zip_req_id ONLY in the cart_ship_zip_request_line.tmpl
//           NOT in the cart_ship_zip_disp_lie.tmpl so this can work even if we 
//           display the zip in the input field once entered.
//
// USAGE:
//    <form method="post" action="..." onsubmit="return checkNoCodesEntered()">
// Hook the above to the form for the continue and the form for the checkout btn in cart_body.
//
//      -------------------------------------------------
//
// From the cart body page, check the coupon/fundraising/gift_certs fields
// and make sure that they are EMPTY.
// Sometimes users think they can enter a value there and hit
// "continue shopping" or "checkout" and the values will be entered.
//
// The function here is to be tied to onsubmit for the continue and checkout btn.
// It will just warn users to click on the "Enter" for the code they entered to take effect.
//
function checkNoCodesEntered(is_checkout) {

 var zip_obj          = document.getElementById("zip_code_id");
 var zip_form_obj     = document.getElementById("zip_form_id");
 var coupon_obj          = document.getElementById("coupon_code_id");
 var coupon_form_obj     = document.getElementById("coupon_form_id");
 var gift_certs_obj      = document.getElementById("gift_certs_code_id");
 var gift_certs_form_obj = document.getElementById("gift_certs_form_id");
 var fundraiser_obj      = document.getElementById("fundraiser_code_id");
 var fundraiser_form_obj = document.getElementById("fundraiser_form_id");

// Do we have a coupon form in this cart
// If we do, check that its value is empty!
 if (coupon_obj) {
    if (coupon_obj.value) {
      alert("We are now entering your Coupon/Promo code. - Click OK to continue.");
      coupon_form_obj.submit();
      return false;
    }
 }


// Same for gift certs
 if (gift_certs_obj) {
    if (gift_certs_obj.value) {
      alert("We are now entering your Gift Certificate code. - Click OK to continue.");
      gift_certs_form_obj.submit();
      return false;
    }
 }


// Same for fundraiser codes
 if (fundraiser_obj) {
    if (fundraiser_obj.value) {
      alert("We are now entering your Fundraiser code. - Click OK to continue.");
      fundraiser_form_obj.submit();
      return false;
    }
 }



// Same for zip code
// Note: Zip code initial req form is different from display form.
//       We only have the form ID present on the request form
 if (zip_obj) {
    if (zip_obj.value) {
      alert("We are now entering your ZIP code. - Click OK to continue.");
      zip_form_obj.submit();
      return false;
    }
    else {
	if (is_checkout) {
	   alert("Enter a ZIP CODE before checkout. - Click OK to continue.");
   	   return false;
	}	
   }
 }


// If we get here, all the TESTs were OK so return true to proceed with checkout
return true;
}



//	Various validation routines used for the SEO cart
//      -------------------------------------------------

// Warn if a MANDATORY option was not selected:
//
// Because we do not know the names of the forms containing
// the various option types used by a given product, we cannot
// hard code them in the script.  The way we identify a mandatory
// option from the pull down menu is by setting a default 
// value of 999999. Then this function can iterate over all
// the elements in this form, identify which ones are of type "select"
// and if any of those have a selected value of 999999, we
// pop a warning window and return false
//
function checkMandatoryOpt(thisForm) {
  var pass=true;
  if (document.images) {
    for (i=0;i<thisForm.length;i++) {
      var tempobj=thisForm.elements[i];
        if (tempobj.type.toString().charAt(0)=="s") {
          if (tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==0) {
            if (tempobj.options[0].value==999999) {
              pass=false;
              break;
            } else {
              pass=true;
	    }
	  }
	}	 
    }
  }

  if (!pass) {
    // shortFieldName=tempobj.name.toUpperCase();
    // alert("You must first select an option: "+shortFieldName);
    alert("Please pick an option");
    return false;
  }
  else
  return true;
}


function testMe(thisForm) {
    alert("Hello Scoob!");
    return false;
}
