function checkIt(xajax, formid, proddesc, imode) {
// debugger;

	if (imode == undefined) {
    // Product Catalog, By Need, Top 20, The Miracle Enzyme
    var cpid = 'pid'+formid;  
		var pid = document.getElementById(cpid).value;
    var dropid = document.getElementById('droplist'+pid).value;
    var selectname = 'attribute_input_'+dropid;
    var dropdownIndex = document.getElementById(selectname).selectedIndex;
    var oa_attribute = document.getElementById(selectname)[dropdownIndex].value;
		if (oa_attribute == "") {alert("You Must First Select an Option"); return false;}
    var str = oa_attribute;
		
		var the_attributes = str.split("|");
		var dropid = the_attributes[0];
		var sec_img_id = the_attributes[1];
		var oa_attribute = the_attributes[2];

		if (pid != dropid) {
  		var oid = document.getElementById('oa_id2'+formid).value;
		} else {
			var oid = document.getElementById('oa_id'+formid).value;
		}
		var quantity = document.getElementById('fquantity'+formid).value;
    var prodadded = document.getElementById(selectname)[dropdownIndex].text;
    var addtype = "0";
		
		// Grab the product image or a default image
		if (parseInt(sec_img_id) > 0) {
			product_image = "images/products/secondary/" + sec_img_id + ".jpg";
		} else {
			switch (parseInt(sec_img_id)) {
				case -1:
					product_image = "images/products/secondary/WSCase.jpg";
					break;
				default:
					product_image = "images/products/secondary/no_graphic.jpg";
			}
		}

	} else if (imode == "2") {
		// Product Long Page
    if (document.getElementById('buyopt'+formid).value == "2") {
			var optvar = "rel_";
		} else {
			var optvar = "";
		}
    var pid = document.getElementById(optvar+'pid'+formid).value;
    var oid = document.getElementById(optvar+'oa_id'+formid).value;
    var oa_attribute = document.getElementById(optvar+'attribute'+formid).value;
    var quantity = document.getElementById('fquantity'+formid).value;
		var prodadded = document.getElementById(optvar+'proddesc'+formid).value;
		if (document.getElementById(optvar+'pop_sec_img'+formid) && document.getElementById(optvar+'pop_sec_img'+formid).value != "") {
	    product_image = "images/products/secondary/"+document.getElementById(optvar+'pop_sec_img'+formid).value+".jpg";
		} else {
			product_image = "images/products/secondary/no_graphic.jpg";
		}
//    var product_image = document.getElementById('oa_id'+formid).value;		
//alert(product_image);

    var addtype = "0";
//		alert(pid);
//		alert(oid);
//    alert(oa_attribute);
//		alert(quantity);
//		alert(prodadded);


} else {
		// A-Z Form
    var pid = document.getElementById('pid'+formid).value;
    var oid = document.getElementById('oa_id'+formid).value;
    var oa_attribute = document.getElementById('attribute'+formid).value;
    var quantity = document.getElementById('fquantity'+formid).value;
		var prodadded = document.getElementById('proddesc'+formid).value;
		
		
//		alert(pid);
//		alert(oid);
//    alert(oa_attribute);
//		alert(quantity);
//		alert(prodadded);
    var addtype = "1";	
	}

  var fade_out_timer = 3;


  if (quantity > 0){
		var pVal = getURLVar('p');
		var ptVal = getURLVar('pt');
		ptVal = ptVal ? ptVal : '0';
		pVal = pVal ? pVal : '';
	  if (imode != 'az'){    
			if (pVal != '') {
				var clean_prod = prodadded.cleanProductDescription();
				clean_prod = clean_prod.replace(' Tablets', ' <span class="tabs_or_caps">TABLETS</span>');
				clean_prod = clean_prod.replace(' Capsules', ' <span class="tabs_or_caps">CAPSULES</span>');
				var showcont = '<table border="0" cellpadding="10" cellspacing="0" id="cartpopup"><tr>';
				showcont += '<td align="center">';
				if (product_image != "") {
					showcont += '<img src="' + product_image + '" height="145" />';
				} else {
					showcont += '&nbsp;';
				}
				showcont += '</td>';
				showcont += '<td width="520" align="left"><p>This product has been added to your <a href="/index.php?p=cart">Shopping Cart.</a><br />';
				showcont += '<span class="desc-block2-t1">' + clean_prod + ' (Qty) ' + quantity + '</span></p>';
				showcont += '<table><tr><td nowrap="nowrap">';
				showcont += '<a href="/index.php?p=home"';
				if (pVal != 'product') showcont += ' onclick="TINY.box.hide(); return false;"';
				showcont += '><img src="/images/buttons/continueshopping.gif" border="0" style="clear:none;" /></a>&nbsp;&nbsp;';
				showcont += '<a href="/index.php?p=cart"><img src="/images/buttons/continuetocheckout.gif" border="0" style="clear:none;" /></a>';
				showcont += '</td></tr></table></td>';
				showcont += '<td width="74" align="right" valign="top"><a href="/index.php?p=home" onclick="TINY.box.hide(); return false;"><img src="/images/buttons/close.gif" border="0" /></a></td>';
				showcont += '</tr></table>';
	
				fade_out_timer = 0;
			} else {
				var showcont = "<h2>Added:  " + quantity + " - " + prodadded.cleanProductDescription() + " to cart...</h2>";
			}
		}
	} else {
		if (imode != 'az') {
			alert('Please enter a quantity of 1 or more.');
			return false;
		}
 // 	var showcont = "<h2>Removed the Product: " + prodadded.cleanProductDescription() + " from the cart...</h2>";	
	}
  xajax_shoppingcart(oid, quantity, oa_attribute, addtype);
	if (imode != 'az') {
		TINY.box.show(showcont, 0, 0, 0, 0, fade_out_timer);
  }

	return false;
}

function clearscart(){
  xajax_emptythecart();
}

function updateopt(payopt,pnum){
	document.getElementById('buyopt'+pnum).value = payopt;
//	alert('just testing this');
}