jQuery(document).ready(function(){
    jQuery("#doButton700").click(function(){   
    	   var useForm=jQuery(this).parent("form").get(0);
           jQuery.post("/cgi-bin/validateCoupon.cgi",
                {product: 700, coupon: jQuery("#namefield700")[0].value},
                function(data){
                    var message="";
                    var newAmount="";
                    if(data.indexOf("amount")>=0){
                        newAmount=data.substring(data.indexOf("amount")+8);
                        message="Your License Code was accepted. Thank you";
                        useForm.disprice.value=newAmount;
                        useForm.disdes.value=" Upgrade";
                        jQuery("#amount700").text("$"+newAmount);
                    }else{
                        message="<font color='red'>We're sorry, this is not a PX Tracker License Code</font>";
                    }
                    jQuery("#msg700").html(message);

                    }    );
                    
    });
   
    jQuery("#doButton800").click(function(){   
    	   var useForm=jQuery(this).parent("form").get(0);
           jQuery.post("/cgi-bin/validateCoupon.cgi",
                {product: 800, coupon: jQuery("#namefield800")[0].value},
                function(data){
                    var message="";
                    var newAmount="";
                    if(data.indexOf("amount")>=0){
                        newAmount=data.substring(data.indexOf("amount")+8);
                        message="Your License Code was accepted. Thank you";
                        useForm.disprice.value=newAmount;
                        useForm.disdes.value=" Upgrade";
                        jQuery("#amount800").text("$"+newAmount);
                    }else{
                        message="<font color='red'>We're sorry, this is not an XtremeFit Pro License Code</font>";
                    }
                    jQuery("#msg800").html(message);

                    }    );
                    
    });
});



jQuery(document).ready(function(){
	
	jQuery("input[src='https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif']").each(function(i){
		var tmp=jQuery(this).parent("form").get(0);
		jQuery(tmp).submit( function() {
			var getForm="#"+this.couForm.value;
			var usePrice=jQuery(getForm)[0].disprice.value;
			var useDesc=jQuery(getForm)[0].disdes.value;
			if(usePrice.length>0 && useDesc.length>0){
				this.amount.value=usePrice;
				this.item_name.value+=useDesc;
			}
			return true;
		});
	});
});
